all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Madden <Paul.A.Madden@noaa.gov>
Cc: help-gnu-emacs@gnu.org
Subject: Re: restore region after replace-string
Date: Sun, 16 Jan 2011 10:08:30 -0700	[thread overview]
Message-ID: <4D33260E.5080901@noaa.gov> (raw)
In-Reply-To: <AANLkTikyXrLCByyUgVJ=1xpwAudS=NuCoUZsQnDj3N13@mail.gmail.com>

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	other threads:[~2011-01-16 17:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.10.1295051790.18911.help-gnu-emacs@gnu.org>
2011-01-15 13:23 ` restore region after replace-string LanX
2011-01-15 20:07   ` Paul Madden
2011-01-16 10:28   ` Le Wang
2011-01-16 17:08     ` Paul Madden [this message]
2011-01-17  2:22       ` Le Wang
2011-01-17  2:38         ` Paul Madden
     [not found]   ` <mailman.15.1295181948.22773.help-gnu-emacs@gnu.org>
2011-01-16 18:24     ` LanX
2011-01-14 22:57 Paul Madden

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=4D33260E.5080901@noaa.gov \
    --to=paul.a.madden@noaa.gov \
    --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.