From: "Drew Adams" <drew.adams@oracle.com>
To: "Jonathan Swartz" <swartz@pobox.com>, <help-gnu-emacs@gnu.org>
Subject: RE: leaving the region highlighted after a command
Date: Wed, 6 Jun 2007 08:15:23 -0700 [thread overview]
Message-ID: <DNEMKBNJBGPAOPIJOOICEEDFDNAA.drew.adams@oracle.com> (raw)
In-Reply-To: <26943C77-0CBA-43FB-BC9E-7829B8181A73@pobox.com>
> 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'.
next prev parent reply other threads:[~2007-06-06 15:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-06 13:24 leaving the region highlighted after a command Jonathan Swartz
2007-06-06 15:15 ` Drew Adams [this message]
2007-06-06 19:25 ` Jonathan Swartz
2007-06-07 14:30 ` Drew Adams
[not found] <mailman.1639.1181136259.32220.help-gnu-emacs@gnu.org>
2007-06-10 10:15 ` Johan Bockgård
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DNEMKBNJBGPAOPIJOOICEEDFDNAA.drew.adams@oracle.com \
--to=drew.adams@oracle.com \
--cc=help-gnu-emacs@gnu.org \
--cc=swartz@pobox.com \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).