Created
November 28, 2012 03:26
-
-
Save ScatteredRay/4158860 to your computer and use it in GitHub Desktop.
font-lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun substitute-pattern (pattern symbol) | |
"Add a font lock hook to replace the matched part of PATTERN with the | |
Unicode symbol SYMBOL looked up with UNICODE-SYMBOL." | |
(interactive) | |
(font-lock-add-keywords | |
nil `((,pattern (0 (progn (put-text-property (match-beginning 1) (match-end 1) | |
'display ,symbol) | |
nil)))))) | |
(defun substitute-patterns (patterns) | |
"Call SUBSTITUTE-PATTERN repeatedly." | |
(mapcar #'(lambda (x) | |
(substitute-pattern (car x) | |
(cdr x))) | |
patterns)) | |
(defun pretty-coffee-symbols () | |
(substitute-patterns '(("[ \t]\\(and\\)[ \t]" . "&&") | |
("[ \t]\\(not\\)[ \t]" . "!") | |
("[ \t]\\(or\\)[ \t]" . "||")))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(defun substitute-pattern (pattern symbol)
"Add a font lock hook to replace the matched part of PATTERN with the
Unicode symbol SYMBOL looked up with UNICODE-SYMBOL."
(interactive)
(font-lock-add-keywords
nil `((,pattern (0 (progn (put-text-property (match-beginning 1) (match-end 1)
'display ,symbol)
nil))))))
(defun substitute-patterns (patterns)
"Call SUBSTITUTE-PATTERN repeatedly."
(mapcar #'(lambda (x)
(substitute-pattern (car x)
(cdr x)))
patterns))
(defun pretty-coffee-symbols ()
(substitute-patterns '(("[ \t](and)[ \t]" . "&&")
("[ \t](not)[ \t]" . "!")
("[ \t](or)[ \t]" . "||"))))