2

I have ("lambda" . 955) in my prettify-symbols-alist for Emacs Lisp to transform lambda to λ. I would like to do something similar for -lambda from dash.el. I have tried adding ("-lambda" . (?- (Br . Bl) 955)) to my prettify-symbols-alist but this does not work. Curiously, it works if I make it "-lambd" instead, so I suspect that the previous lambda prettification is conflicting. How can I resolve this?

  • 1
    what does your code look like? This works fine for me using (setq prettify-symbols-alist (list '("-lambda" . (?- (Br . Bl) 955)) '("lambda" . 955))) – Jordon Biondo Aug 19 at 17:50
  • 1
    @JordonBiondo has a point. check your code. make sure there are no typos. i used prettify-symbol-alist (singular) or prettify-symbols-mode (instead of -alist) several times while typing up my answer. ;) – nega Aug 19 at 18:13
2

That should work just fine, but you'll need to "reload" prettify-symbols-mode for the buffer you're working with.

For instance after starting emacs with -q and doing M-x prettify-symbols-mode to turn it on, in my scratch buffer I did the following:

;; we're in lisp-interaction mode where ^J runs eval-print-last-sexp

;; starting with prettify-symbols-mode ON
;; two lambda examples, the first is prettified by default
(λ  () )
(-lambda () )

(print prettify-symobls-alist)^J


(("lambda" . 955))
(("lambda" . 955))

(push '("-lambda" . (?- (Br . Bl) 955)) prettify-symbols-alist)^J
(("-lambda" 45 (Br . Bl) 955) ("lambda" . 955))

(prettify-symbols-mode -1)^J
nil

;; the above lambdas are now not "prettified"

(prettify-symbols-mode 1)^J
t

;; now, both above lambdas are "prettified"

In fact, I've added that to my own prettify-symbols-alist in my init file, and after restarting Emacs, it's working just fine.

  • It works! Sorry, I had not properly sanitized my testing environment. I had some code ligatures on a hook elsewhere that for some reason were interfering (though I haven't found out why yet). This answer is great. – Matthew Piziak Aug 19 at 22:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.