all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* leaving the region highlighted after a command
@ 2007-06-06 13:24 Jonathan Swartz
  2007-06-06 15:15 ` Drew Adams
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Swartz @ 2007-06-06 13:24 UTC (permalink / raw)
  To: help-gnu-emacs

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

    ;; Yup, still no highlighting
    (defun mb2 ()
      "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)))

So is there something magical about mark-whole-buffer that isn't  
evident in the source? e.g. is it on a list of functions somewhere to  
leave the region highlighted?

I've reproduced this on both Emacs 22.0.50.1 on OS X, and Emacs  
21.3.1 on RHEL4.

Any help much appreciated,
Jon

^ permalink raw reply	[flat|nested] 5+ messages in thread
[parent not found: <mailman.1639.1181136259.32220.help-gnu-emacs@gnu.org>]

end of thread, other threads:[~2007-06-10 10:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-06 13:24 leaving the region highlighted after a command Jonathan Swartz
2007-06-06 15:15 ` Drew Adams
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

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.