[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: leaving the region highlighted after a command

From: Drew Adams
Subject: RE: leaving the region highlighted after a command
Date: Wed, 6 Jun 2007 08:15:23 -0700

> 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

(defun foo ()
  (when (not executing-kbd-macro) (setq deactivate-mark nil)))

In general, see the Elisp manual for `deactivate-mark'.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]