Created
January 30, 2012 18:57
-
-
Save magnars/1705973 to your computer and use it in GitHub Desktop.
push-mark not behaving as expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun mark-five-next () | |
| "Marks the next five chars as expected" | |
| (interactive) | |
| (push-mark (+ 5 (point)) t t)) | |
| (defun delete-region-then-mark-five-next (start end) | |
| "Does not mark the next five chars" | |
| (interactive "r") | |
| (delete-region start end) | |
| (push-mark (+ 5 (point)) t t)) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It turns out that all editing commands set the var
deactivate-markwhich does just that after the command has finished.To avoid this behavior, you have to wrap the buffer-altering functions in a
let-statement, preventing the change of the globaldeactivate-markvar.I spent more than an hour on this problem, because I just skipped over deactivate-mark in the manual, thinking it was a description of the function. Of course, as I already knew, but have now properly learned: emacs lisp has a different namespace for functions and variables.