Emacs: problems activating tags in an interactive command

It seems that it somehow modifies the buffer, stops defun from activating the label:

(defun mark-five-next () "Marks the next five chars as expected" (interactive) (push-mark (+ 5 (point)) tt)) (defun insert-an-a-then-mark-five-next () "Does not mark the next five chars" (interactive) (insert "a") (push-mark (+ 5 (point)) tt)) 

I would prefer to fix this, but just an explanation is also good.

+4
source share
1 answer

It turns out that all editing commands set var deactivate-mark , which does this only after the command completes.

To avoid this behavior, you should wrap the buffer change functions in let -statement, preventing the global deactivate-mark var from changing.

 (let (deactivate-mark) (...)) 

I spent more than an hour on this problem, because I just skipped the deactivate-mark in the manual, believing that this is a description of the function. Of course, as I already knew, but now I understand correctly: emacs lisp has a different namespace for functions and variables.

+8
source

Source: https://habr.com/ru/post/1393840/


All Articles