jkitchin / ov-highlight

A persistent highlighter for Emacs
60 stars 6 forks source link

ov-highlight-clear doesn't clear the highlight at point #7

Open nhmacuk opened 4 years ago

nhmacuk commented 4 years ago

ov-highlight-clear doesn't clear the highlight at point, not by calling it through M-x, in either insert/normal mode, or through a key bound to the function, or going over every letter of the word and calling the function at every letter( also start/end of the line, and position before and after word). No error messages. All functions in this package seems to work great (see screenshor), including ov-highlight-clear-all. image

jkitchin commented 4 years ago

This is a weird bug, sometimes it works if I run it twice, and while debugging sometimes it works like it should. I have not figured out what the problem is yet.

jstaursky commented 4 years ago

Here is how I fixed it.

(defun ov-highlight-clear ()
  "Clear highlight at point."
  (interactive)

  (when-let (ov (ov-at))
    (delete-overlay ov)
    (ov-clear (ov-beg (ov-at)) (ov-end (ov-at)))
    )

  (set-buffer-modified-p t)
  (let ((buf (get-buffer "*ov-highlights*")))
    (when buf
      (with-current-buffer buf
    (ov-highlight-refresh-list)))))

Obviously could use some clean up--but it's late and I don't feel like restarting emacs for more testing. Just wanted to put the fix out there.

jkitchin commented 4 years ago

Hopefully I got the fix right! It seems to work ok for me.