[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [External] : What is the difference between (deactivate-mark) and (s
From: |
Drew Adams |
Subject: |
RE: [External] : What is the difference between (deactivate-mark) and (setq deactivate-mark t)? |
Date: |
Sat, 3 Apr 2021 04:11:18 +0000 |
> Well, I understand what each of them does, but whay was the variable
> introduced and why would I want to say `(setq deactivate-mark t)' in
> a command instead of just calling `(deactivate-mark)'? I can't think of
> any possible reasons. Any ideas?
I may be repeating what you say you already
understand, but...
Function `deactivate-mark' deactivates the mark
(duh), and it does so right away.
After a command finishes and returns, the command
loop normally automatically deactivates the mark.
IOW, for the next command the mark is inactive.
But if you set variable `deactivate-mark' to `nil'
in your command then the command loop won't
deactivate it when your command is done.
As the manual says:
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 " "))
Setting the variable to nil says do NOT deactivate
the mark. See (elisp) `The Mark'.
https://www.gnu.org/software/emacs/manual/html_node/elisp/The-Mark.html