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: Paul Madden
Subject: Re: restore region after replace-string
Date: Sun, 16 Jan 2011 10:08:30 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101207 Lightning/1.0b2 Thunderbird/3.1.7

Le,

Thank you! That was the key.

Here's the working function, in case it helps someone someday:

(defun rs ()
  (interactive)
  (let (deactivate-mark)
    (save-excursion (call interactively 'replace-string)))
  (exchange-point-and-mark)
  (exchange-point-and-mark))

paul

On 01/16/2011 03:28 AM, Le Wang wrote:

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