From: Marcin Borkowski <mbork@mbork.pl>
To: Drew Adams <drew.adams@oracle.com>
Cc: Help Gnu Emacs mailing list <help-gnu-emacs@gnu.org>
Subject: Re: [External] : What is the difference between (deactivate-mark) and (setq deactivate-mark t)?
Date: Wed, 07 Apr 2021 07:14:20 +0200 [thread overview]
Message-ID: <87v98ybrrn.fsf@mbork.pl> (raw)
In-Reply-To: <SA2PR10MB447445CB153C7781895F60DFF3799@SA2PR10MB4474.namprd10.prod.outlook.com>
On 2021-04-03, at 06:11, Drew Adams <drew.adams@oracle.com> wrote:
>> 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.
Well, I don't think that's the case. Take this command:
(defun petrichor ()
(interactive)
(message "Smell of the dust after the rain"))
activate the region and say M-x petrichor - the region is still active.
If I want to change this, I can either say `(deactivate-mark)' or `(setq
deactivate-mark t)'. My question was, why I would want to choose the
latter?
I think I now know the reason - while experimenting with this and
studying the docs, I probably found out. Can anyone correct me if I'm
wrong? It seems that its main use is to actually _prevent_ the code
from deactivating the region _if_ it would do it otherwise, by means of
_modifying_ the buffer. Since every primitive that changes the buffer
(like `insert') sets it to `t', you can say `(setq deactivate-mark nil)`
at the end of a buffer-modifying command and the region will remain
active if it was before running it. (The manual suggests temporarily
binding it with `let' which has a similar effect, as you mentioned.)
Does that make sense?
--
Marcin Borkowski
http://mbork.pl
next prev parent reply other threads:[~2021-04-07 5:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-03 3:42 What is the difference between (deactivate-mark) and (setq deactivate-mark t)? Marcin Borkowski
2021-04-03 4:11 ` [External] : " Drew Adams
2021-04-03 4:13 ` Drew Adams
2021-04-03 4:24 ` Drew Adams
2021-04-07 5:14 ` Marcin Borkowski [this message]
2021-04-07 7:25 ` tomas
2021-04-07 14:58 ` Drew Adams
2021-04-07 15:30 ` tomas
2021-04-07 14:54 ` Drew Adams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87v98ybrrn.fsf@mbork.pl \
--to=mbork@mbork.pl \
--cc=drew.adams@oracle.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.