How can I return "fancy lambdas" after editing

When editing clojure code in emacs, usually to configure font lock to insert "fancy" characters for lambdas, sets, anon functions.

This is achieved using some variant of the following (see clojure-mode, emacs-live, etc.)

(dolist (mode '(clojure-mode clojurescript-mode nrepl-interaction-mode)) (eval-after-load mode (font-lock-add-keywords mode '(("(\\(fn\\)[\[[:space:]]" ; anon funcs 1 (0 (progn (compose-region (match-beginning 1) (match-end 1) "λ") nil))) ("\\(#\\)(" ; anon funcs 2 (0 (progn (compose-region (match-beginning 1) (match-end 1) "ƒ") nil))) ("\\(#\\){" ; sets (0 (progn (compose-region (match-beginning 1) (match-end 1) "∈") nil))))))) 

This works great until you make edits around a fashionable character. You can leave the hanging characters according to the following screenshot ... enter image description here

How can I make emacs return to "real" characters when I did the editing. nil (s) in the above code may be a modification function that (presumably) does this, and there is a (decompose-region) , which apparently corresponds to the count. How it should be called, passing it as a symbol, does not work.

eg. I tried this:

 (dolist (mode '(clojure-mode clojurescript-mode nrepl-interaction-mode)) (eval-after-load mode (font-lock-add-keywords mode '(("(\\(fn\\)[\[[:space:]]" ; anon funcs 1 (0 (progn (compose-region (match-beginning 1) (match-end 1) "λ") 'decompose-region))) ("\\(#\\)(" ; anon funcs 2 (0 (progn (compose-region (match-beginning 1) (match-end 1) "ƒ") 'decompose-region))) ("\\(#\\){" ; sets (0 (progn (compose-region (match-beginning 1) (match-end 1) "∈") 'decompose-region))))))) 
+4
source share
1 answer

The easiest way is to add (set (make-local-variable 'font-lock-extra-managed-props) '(composition)) .

+1
source

Source: https://habr.com/ru/post/1500588/


All Articles