I’m having a small issue with a minor mode I’m writing. I’m using
post-command-hook in order to know whether a command just enabled/disabled the mark/region (I’m using transient mark mode). It’s mostly working, for instance
C-SPC, or Shift+arrows or selecting with the mouse all do exactly as I expect, but not the
kill-ring-save command (
M-w). In the
kill-ring-save, the variable
mark-active is still true even though
M-w actually disables the mark (visually at least).
Any idea what is going on? I’m now working around it by explicitly checking whether
kill-ring-save, but it feels like I shouldn’t have to do that.
Code to test:
(defun before-hook () (message "(before) Mark active: %s, region: %d to %d" mark-active (region-beginning) (region-end))) (defun after-hook () (message "(after) Mark active: %s, region: %d to %d" mark-active (region-beginning) (region-end))) (add-hook 'pre-command-hook 'before-hook nil t) (add-hook 'post-command-hook 'after-hook nil t)