Skip to content

Commit c058323

Browse files
Using special characters in Emacs Scheme buffers (#49)
1 parent b6098f5 commit c058323

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Display some symbols in Scheme buffers using special characters
2+
3+
## Problem
4+
5+
In Emacs, one can display some keywords, like `lambda` and `>=`, using
6+
special characters like `λ` and ``.
7+
8+
## Solution
9+
10+
```Emacs-Lisp
11+
(defvar pretty-scheme-keywords
12+
'(("\\(->\\)" . #x2192)
13+
("\\(<=\\)" . #x2264)
14+
("\\(<==\\)" . #x21d0)
15+
("\\(>=\\)" . #x2265)
16+
("\\(==>\\)" . #x21d2))
17+
"alist from regexps to Unicode code points")
18+
19+
(defun prettify-scheme ()
20+
(add-to-list 'prettify-symbols-alist '("lambda" . ?x3bb))
21+
(font-lock-add-keywords
22+
nil
23+
(mapcar (lambda (keyword)
24+
`(,(car keyword)
25+
(0 (progn (compose-region (match-beginning 1) (match-end 1)
26+
,(cdr keyword)
27+
'decompose-region)
28+
nil))))
29+
pretty-scheme-keywords))
30+
(prettify-quotes)
31+
(turn-on-font-lock))
32+
33+
(add-hook 'scheme-mode-hook 'prettify-scheme)
34+
```

0 commit comments

Comments
 (0)