Frage

I have written a minor mode that highlights various parts of the buffer as the cursor moves around the buffer. I do this by advising the movement functions like this.

...
(defadvice next-line (after showcss/advise-main)
  "Advice around cursor movement"
  (highlight-some-stuff))
(defadvice previous-line (after showcss/advise-main)
  "Advice around cursor movement"
  (highlight-some-stuff))
(defadvice right-char (after showcss/advise-main)
  "Advice around cursor movement"
  (highlight-some-stuff))
(defadvice left-char (after showcss/advise-main)
  "Advice around cursor movement"
  (highlight-some-stuff))
(defadvice forward-word (after showcss/advise-main)
  "Advice around cursor movement"
  (highlight-some-stuff))
(defadvice backward-word (after showcss/advise-main)
  "Advice around cursor movement"
  (highlight-some-stuff))
...

But this seems like the wrong way to do this. I've looked for a hook for cursor movement but there doesn't appear to be one.

Am I missing a hook I can use instead of advising a bunch of movement functions, or is there a better way to approach this?

War es hilfreich?

Lösung

Hmm... I sent you an email a few days ago suggesting to include showcss in GNU ELPA in which I also suggested you use post-command-hook instead of those defadvices.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top