0

I use AucTeX as my latex major mode. I have been trying to setup the minor mode latex-pretty-symbols which is available from melpa. I did:

;; Install from package-list-packages
(require 'latex-pretty-symbols)
(add-hook 'LaTeX-mode-hook
  (lambda () (message "Show that my code ran") (latex-unicode-simplified)))

What's supposed to happen is that font-lock should render \alpha = 1 as α = 1 in a latex buffer.

Unfortunately, this doesn't happen in AucTex. Instead I have to either interactively call latex-unicode-simplified or manually evaluate M-:(latex-unicode-simplified) from the buffer.

Is there a way to programmatically send keystrokes after a mode is loaded? Is there some other way to tell auctex to do what I want ? I have been trying to solve this for 2.5 hours now so any help is welcome.

NB 1: This problem only happens when I use auctex. When I deleted auctex and did (add-hook 'latex-mode-hook 'latex-unicode-simplified) then the problem got resolved. But I can't stop using AucTex.

NB 2: This problem is not resolved through file local variables, I tried to put a % eval: (latex-unicode-simplified) but that did not work

NB 3: The package author is using bitbucket, with issues disabled.

  • 1
    Incidentally, (add-hook 'LaTeX-mode-hook #'prettify-symbols-mode) should also do the trick if you use Emacs≥25. – Stefan Feb 18 '16 at 13:53
  • Regarding NB 3, bitbucket does have issue trackers, but repository managers can disable them. This is the case for that particular repository. – giordano Feb 18 '16 at 14:48
  • @Stefan : It seems that to actually make good use of prettify-symbols-mode I would have to write the prettification rules myself. Is there some code with those rules already written? I can understand that latex-pretty-symbols is basically doing that. – Pushpendre Feb 18 '16 at 19:01
  • Yes, Emacs≥25 has such rules. – Stefan Feb 19 '16 at 4:16
1

A couple of things:

  1. The sharp-quote (#') is used only before functions, not all symbols.
  2. For easy debug and addition/removal of functions to hooks, it's better to first define a function and then add that to the hook.
  3. Bare lambdas should not be quoted.
(require 'latex-pretty-symbols)

(defun my/LaTeX-mode-stuff ()
  (message "Show that my code ran")
  (latex-unicode-simplified))
(add-hook 'LaTeX-mode-hook #'my/LaTeX-mode-stuff)

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.