GNU bug report logs -
#35177
27.0.50; Binding deactivate-mark to nil unexpectedly deactivates the mark
Previous Next
Full log
View this message in rfc822 format
> From: Markus Triska <triska <at> metalevel.at>
> Date: Sun, 07 Apr 2019 02:11:02 +0200
>
> Please start Emacs with "emacs -Q" and insert the following form in the
> *scratch* buffer:
>
> (progn
> (let (deactivate-mark)
> (switch-to-buffer (get-buffer-create "t"))
> (erase-buffer)
> (insert "hello"))
> (let (deactivate-mark)
> (set-mark-command nil)
> (move-beginning-of-line nil)))
>
> then place point at the end of the form and evaluate it with C-x C-e.
>
> You will see a new buffer ("t"), where "hello" is inserted and nothing
> is highlighted because the mark is inactive.
>
> However, I expect the mark to be active and the region highlighted,
> because the form binds deactivate-mark to nil. This is the way that is
> recommended in the Elisp manual, see for Example 31.7 "The Mark":
>
> To write Lisp code that modifies the buffer without causing
> deactivation of the mark at the end of the command, bind
> ‘deactivate-mark’ to ‘nil’ around the code that does the
> modification. For example:
>
> (let (deactivate-mark)
> (insert " "))
>
I think you need to put the entire progn inside the binding of
deactivate-mark. IOW, the binding should be in effect when the
command terminates.
This bug report was last modified 6 years and 164 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.