emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

About prog-prettify-symbols


From: Tassilo Horn
Subject: About prog-prettify-symbols
Date: Thu, 13 Jun 2013 17:09:00 +0200
User-agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3.50 (gnu/linux)

Hi all,

I have some issues with `prog-prettify-symbols'.

1. I'd like to get it working with clojure-mode [fn:1].  In clojure,
   `fn' is what `lambda' is in elisp or common lisp.  So I added

--8<---------------cut here---------------start------------->8---
(setq prog-prettify-symbols t)
(add-hook 'clojure-mode-hook
          (lambda ()
            (prog-prettify-install '(("fn" . ?ƒ)))))
--8<---------------cut here---------------end--------------->8---

   to my .emacs.  Unfortunately, when I open a clojure file now, (fn
   ...) is correctly displayed as (ƒ ...), but also (lambda ...) is
   shown using a greek letter.  And most clojure functions and macros
   aren't highlighted any more.

   The reason is that the value of `font-lock-keywords' has nothing to
   do with its original value setup by clojure-mode without the
   prettification.  Basically, the value looks like the correct value
   for `emacs-lisp-mode' + the prettification for lambda and fn.

   Then I added

--8<---------------cut here---------------start------------->8---
(add-hook 'c-mode-hook
          (lambda ()
            (prog-prettify-install '(("main" . ?ƒ)))))
--8<---------------cut here---------------end--------------->8---

   to my .emacs, and when finding a C file, main is indeed displayed as
   ƒ and the other font-locking still works as expected...

   So what makes clojure-mode so special that it gets messed up?  One
   difference I can see is that c-mode and emacs-lisp-mode derive from
   prog-mode directly, whereas in clojure-mode there's

--8<---------------cut here---------------start------------->8---
;; For compatibility with Emacs < 24, derive conditionally
(defalias 'clojure-parent-mode
  (if (fboundp 'prog-mode) 'prog-mode 'fundamental-mode))

;;;###autoload
(define-derived-mode clojure-mode clojure-parent-mode "Clojure"
  ...)
--8<---------------cut here---------------end--------------->8---

   But then I've tried to make it derive from prog-mode directly, and
   it's still messed up in the same respects.

2. Would it be possible to make prettification a bit more flexible?  For
   example, in clojure I'd like to display also (defn ...) as (deƒ ...),
   but currently it seems I can only "replace" a fixed symbol with a
   single character.  I think, it would be better if
   `prog-prettify-symbols-alist' would have the form

     ((REGEX GROUP CHAR) ...)

   so that I could have an alist like

     (("de\\(fn\\)" 1 ?ƒ)
      ("fn" 0 ?ƒ))

   to show (fn ...) as (ƒ ...) and (defn ...) as (deƒ ...).

Bye,
Tassilo

Footnotes:

[fn:1] https://github.com/technomancy/clojure-mode



reply via email to

[Prev in Thread] Current Thread [Next in Thread]