I'm pretty new to emacs and giving it a shot because it seems to be much better integrated with the OCaml tool chain than any other editor.
Since OCaml uses a lot of symbols, I want to enable ligature support.
If it's relevant, I'm using spacemacs. Here's what I've added to my dotspacemacs/user-config()
(load "~/.emacs.d/private/local/pragmatapro-prettify-symbols-v0.828.el")
(add-hook 'tuareg-mode-hook #'prettify-hook)
(global-prettify-symbols-mode t)
The .el
file I'm using is available here for reference and defines prettify-hook
.
The strange thing is that after opening a .ml
file in Tuareg mode, I can see that prettify-symbols-mode is active, but none of the symbols are converted to ligatures. However, if I toggle prettify-symbols-mode off and then back on, the symbols render correctly.
Has anyone else had this issue or have any ideas how I can get it to work automatically upon opening a the file?
Edit:
So, interestingly enough, after looking again it seems like some sort of symbol replacement is happening, but it isn't happening with the correct glyphs or for all of the patterns defined in the .el file. For example <= is replaced with a reasonable, but incorrect glyph; |> is not replaced at all. After toggling the mode I end up with the correct replacement glyphs.
See the answers section for the solution I came up with.
global-prettify-symbols-mode
and remove the argumentt
in your code when you are calling this function. – Tobias Jul 6 '20 at 0:17t
; however internally it comes down to(prefix-numeric-value arg)
, and when arg ist
, that will evaluate to1
, just as it does when arg isnil
. – phils Jul 6 '20 at 3:45prettify-symbols-mode
has been enabled beforeprettify-symbols-alist
has been configured for the buffer, but the code looks ok -- the sequence should be correct. I don't have tuareg mode, but I tried your code substitutingc-mode-hook
and it seemed to be working (substitutions were happening for examples from the alist). – phils Jul 6 '20 at 3:57.el
file. For example<=
is replaced with a reasonable, but incorrect glyph;|>
is not replaced at all. After toggling the mode I end up with the correct replacement glyphs. – Evan Jul 8 '20 at 22:47