From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Le Wang Newsgroups: gmane.emacs.help Subject: Re: restore region after replace-string Date: Sun, 16 Jan 2011 18:28:21 +0800 Message-ID: References: <0dfdb0af-c0b4-446b-8d3d-d194b128d85f@u32g2000yqe.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=90e6ba5bb92d645aae0499f42046 X-Trace: dough.gmane.org 1295173746 13078 80.91.229.12 (16 Jan 2011 10:29:06 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 16 Jan 2011 10:29:06 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: LanX Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jan 16 11:29:02 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PePr3-000712-Q1 for geh-help-gnu-emacs@m.gmane.org; Sun, 16 Jan 2011 11:29:02 +0100 Original-Received: from localhost ([127.0.0.1]:33212 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PePr3-0003nF-7z for geh-help-gnu-emacs@m.gmane.org; Sun, 16 Jan 2011 05:29:01 -0500 Original-Received: from [140.186.70.92] (port=41374 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PePqS-0003n2-FT for help-gnu-emacs@gnu.org; Sun, 16 Jan 2011 05:28:25 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PePqR-00039D-CJ for help-gnu-emacs@gnu.org; Sun, 16 Jan 2011 05:28:24 -0500 Original-Received: from mail-ew0-f41.google.com ([209.85.215.41]:60776) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PePqR-00038o-3P for help-gnu-emacs@gnu.org; Sun, 16 Jan 2011 05:28:23 -0500 Original-Received: by ewy27 with SMTP id 27so2016891ewy.0 for ; Sun, 16 Jan 2011 02:28:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=SROjhrFqVmiYUc6SvyRfckQGpWDLjyS8CTnILghZOm4=; b=fggq7yVfC0RpNqD1ZXMAJSmLhcl06BbJdDdoLxIg/j8v33S1LVeY6hipoGBQEfin7n LidgRJ1tXGPV8hF/44Gnfhfo8sNlLPiksF9unD0NYGgl/noTZej423owr+QTkwhgKFpN 5N6idn2ZEQ37SZqXawkjKB0pbL1TYdE4P65a0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=fsS+C1rGoFOGprz8zop17AnF/R4xMMwUf0JSy65hV4Q+ZY4A6xEWaaFgC8jyretNgI yAFILaD5n2elYWDBaQUU+B0UMRgaBKSTufIjdROJGrYjyCvuTXKsw/aTsPuWXyJpAktD ANhs3PL0bp3cBdi/Hc+8/1HXpGRiMVtW1gQuA= Original-Received: by 10.14.53.66 with SMTP id f42mr2122037eec.3.1295173701359; Sun, 16 Jan 2011 02:28:21 -0800 (PST) Original-Received: by 10.14.119.11 with HTTP; Sun, 16 Jan 2011 02:28:21 -0800 (PST) In-Reply-To: <0dfdb0af-c0b4-446b-8d3d-d194b128d85f@u32g2000yqe.googlegroups.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:78476 Archived-At: --90e6ba5bb92d645aae0499f42046 Content-Type: text/plain; charset=ISO-8859-1 On Sat, Jan 15, 2011 at 9:23 PM, LanX 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 --90e6ba5bb92d645aae0499f42046 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Sat, Jan 15, 2011 at 9:23 PM, LanX=A0<lanx.perl@googlemail.com>=A0wr= ote:
> Can anybody shed any light on this, or point me in a better di= rection?

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

Variable:=A0deactivate-mar= k

If an editor command sets this variable non-nil, then the editor command loop deactivates the mar= k after the command returns (if Transient Mark mode is enabled). All the= primitives that change the buffer set=A0deac= tivate-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=A0deactivate-mark=A0to=A0= nil=A0around the code that does the modification. For example:

          (let (deactivate-mark)
            (insert " "))


--
Le
--90e6ba5bb92d645aae0499f42046--