From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jonathan Swartz Newsgroups: gmane.emacs.help Subject: Re: leaving the region highlighted after a command Date: Wed, 6 Jun 2007 12:25:02 -0700 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1181157958 12535 80.91.229.12 (6 Jun 2007 19:25:58 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 6 Jun 2007 19:25:58 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Drew Adams Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jun 06 21:25:55 2007 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.50) id 1Hw18j-0007b8-5u for geh-help-gnu-emacs@m.gmane.org; Wed, 06 Jun 2007 21:25:53 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hw18i-0002XP-GA for geh-help-gnu-emacs@m.gmane.org; Wed, 06 Jun 2007 15:25:52 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Hw17y-0002Ni-0B for help-gnu-emacs@gnu.org; Wed, 06 Jun 2007 15:25:06 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Hw17w-0002My-4a for help-gnu-emacs@gnu.org; Wed, 06 Jun 2007 15:25:05 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hw17v-0002Mo-UL for help-gnu-emacs@gnu.org; Wed, 06 Jun 2007 15:25:03 -0400 Original-Received: from sceptre.pobox.com ([207.106.133.20]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Hw17v-0006FB-HC for help-gnu-emacs@gnu.org; Wed, 06 Jun 2007 15:25:03 -0400 Original-Received: from sceptre (localhost.localdomain [127.0.0.1]) by sceptre.pobox.com (Postfix) with ESMTP id CB9AA2F0; Wed, 6 Jun 2007 15:25:24 -0400 (EDT) Original-Received: from [192.168.4.131] (unknown [74.93.108.201]) by sceptre.sasl.smtp.pobox.com (Postfix) with ESMTP id 78DB9567D0; Wed, 6 Jun 2007 15:25:23 -0400 (EDT) In-Reply-To: X-Priority: 3 (Normal) X-Mailer: Apple Mail (2.752.2) X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) 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:44719 Archived-At: On Jun 6, 2007, at 8:15 AM, Drew Adams wrote: >> I use transient-mark-mode. I'm trying to write a command like mark- >> whole-buffer that selects a certain region and leaves it highlighted. >> But I cannot seem to get this to work; at the end of my command, the >> region is never highlighted. >> >> Here's the definition of mark-whole-buffer in simple.el: >> >> (defun mark-whole-buffer () >> "Put point at beginning and mark at end of buffer. >> You probably should not use this function in Lisp programs; >> it is usually a mistake for a Lisp function to use any subroutine >> that uses or sets the mark." >> (interactive) >> (push-mark (point)) >> (push-mark (point-max) nil t) >> (goto-char (point-min))) >> >> This leaves the region highlighted. But if I simply call mark-whole- >> buffer from another function or copy its code verbatim to another >> function, the new other functions do NOT leave the region >> highlighted: >> >> ;; No highlighting >> (defun mb () >> (interactive) >> (mark-whole-buffer)) > > Try (setq deactivate-mark nil). > > I use something like this in some situations, in a particular post- > command > hook: > > (defun foo () > (when (not executing-kbd-macro) (setq deactivate-mark nil))) > > In general, see the Elisp manual for `deactivate-mark'. > > That did it! I still don't understand why my mb function doesn't work above, when all it does is call mark-whole-buffer...but adding deactivate-mark fixed it. Thanks Jon