help-gnu-emacs
[Top][All Lists]
Advanced

[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: Wed, 7 Apr 2021 14:54:47 +0000

> > 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...
>
> 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.

Yes.  I should have said just what the doc says:

  If an editor command sets this variable non-'nil',
  then the editor command loop deactivates the mark
  after the command returns (if Transient Mark mode
  is enabled).

What I said gave the impression that that is always
the case.  The point is that it is often the case,
or sometimes the case.  And as you say, the real
point is that your command can't know whether it
will be the case.  Setting the variable to nil makes
sure it won't be deactivated by the command loop.

The doc, which I pointed to, is very clear about all
of this, I think.

> 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.

Yes, I believe I said that.  And not just if it was
active before running your command.  Your command
can intentionally activate the region and use the
variable (non-nil) to tell the command loop not to
deactivate it.  I gave examples of that.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]