[Top][All Lists]

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

Inserting in other buffer deactivates the mark

From: Lennart Borgman (gmail)
Subject: Inserting in other buffer deactivates the mark
Date: Wed, 28 Feb 2007 13:05:18 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20061207 Thunderbird/ Mnenhy/

Inserting text in another buffer than the current can deactivate the mark in the current buffer. To see this start emacs with

  emacs -Q

then paste this code into the *scratch* buffer and evaluate it:

  (global-set-key [f9] 'temp-save)

  (defun temp-save(start end)
    (interactive "r")
    (unless cua-mode
      (error "Enable cua-mode to see the region"))
    (unless mark-active
      (error "The Region is not active"))
    (let ((b (get-buffer-create "temporary temp-save buffer")))
      (switch-to-buffer-other-window b)
      (other-window 1)
      (with-current-buffer b
        (goto-char (1- (point-max)))
        (when (y-or-n-p "Insert A? ")
          (insert "A")(message "inserted A")(sit-for 2))
      (message "After with-current-buffer, mark-active=%s"
                mark-active)(sit-for 2)
    (message "At end, mark-active=%s" mark-active)(sit-for 2)

Press F9 to test. First answer "n" to the question whether to insert "A" in the other buffer. In this case the mark is not deactivated.

Then press F9 again to test. Now answer "y". The mark is now deactivated at the return from the function temp-save.

In GNU Emacs (i386-mingw-nt5.1.2600)
 of 2007-02-24

reply via email to

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