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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: restore region after replace-string


From: Le Wang
Subject: Re: restore region after replace-string
Date: Sun, 16 Jan 2011 18:28:21 +0800

On Sat, Jan 15, 2011 at 9:23 PM, LanX <lanx.perl@googlemail.com> wrote:
> Can anybody shed any light on this, or point me in a better direction?

I had to solve this recently -- keeping the region active after a command modifies the buffer.  The relevant documentation is here: http://www.gnu.org/s/emacs/manual/html_node/elisp/The-Mark.html

Variable: deactivate-mark

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). All the primitives that change the buffer set deactivate-mark, to deactivate the mark when the command is finished.

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 " "))


--
Le

reply via email to

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