Closed zhaojiangbin closed 5 years ago
Please provide an example file.
I narrowed it down to the prettify-symbols-mode
and the particular font I am using for ligatures. The issue is actually not specific to js2-mode. It can happen in probably any major mode. I have it reproduced in js2-mode, text-mode, c++-mode and even fundamental-mode.
If it's too much of a trouble for you to set up and look into it, I can live with the issue not fixed.
I am using Emacs 26.1 on macOS High Sierra, from https://emacsformacosx.com/: "GNU Emacs 26.1 (build 1, x86_64-apple-darwin14.5.0, NS appkit-1348.17 Version 10.10.5 (Build 14F2511)) of 2018-05-30"
I got the patched version of the Fira Code font and the lisp code for setup here: https://gist.github.com/reiver-dev/82da77ba3f0008c56624661a7375e0e8#file-ligatures-el
The processed font file can be found here: https://github.com/tonsky/FiraCode/files/1734878/FiraCode-private-area.zip
After the font is installed and font setup code loaded in Emacs, it is easy to reproduce the issue in an empty scratch buffer:
(ligatures-fira-code-setup)
and M-x prettify-symbols-mode
.x /* y */ z
avy-goto-char-in-line
, then type '/'.If you change major mode, you'll need to re-run ligatures-fira-code-setup
and prettify-symbols-mode
again.
This is what it looked like in my Emacs. The cursor was on 'y', only the first '/' was highlighted by key 'a':
You can try patching e.g. avy--overlay-at-full
with:
(setq beg (or (plist-get (text-properties-at beg) 'prettify-symbols-start) beg))
The overlay will be visible, but I don't think the result is satisfactory.
It's probably better to just add an advice to disable prettify-symbols-mode
before avy-read
is called, and enable it back afterwards.
(defun without-prettify-symbols (orig-fun &rest args)
(prettify-symbols-mode -1)
(let ((r (apply orig-fun args)))
(prettify-symbols-mode 1)
r))
(advice-add 'avy-read :around 'without-prettify-symbols)
The advice works great. Thanks very much.
You're welcome.
Neither can it find the first '/' in '/ /'. There are more permutations that I have run into but didn't take note of.
In my limited tests, the issue goes away after font-lock-mode is disabled. Turning font-lock back on may or may not have the issue again.
It also does not appear to be happening in C mode.