[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: activate-mark-hook
From: |
Chong Yidong |
Subject: |
Re: activate-mark-hook |
Date: |
Sun, 6 Mar 2005 01:13:35 -0500 (EST) |
User-agent: |
SquirrelMail/1.4.4 |
I didn't receive any reply about this. If the patch is correct, can it be
applied?
> 1. activate-mark-hook and deactivate-mark-hook do not have docstrings,
> even though they are documented in the Emacs Lisp reference manual (Elisp
> -> Markers -> The Mark).
>
> 2. If push-mark-command is run with no prefix arg and mark already set at
> the current position, it activates the mark, but fails to run
> activate-mark-hook. I noticed this because I have the following in my
> `.emacs':
>
> (transient-mark-mode t)
> (add-hook 'deactivate-mark-hook '(lambda () (setq cursor-type t)))
> (add-hook 'activate-mark-hook '(lambda () (setq cursor-type 'bar)))
>
> If I type C-SPC C-g C-SPC, the hook is not run on the second invocation of
> C-g, and the cursor doesn't change.
*** emacs/lisp/simple.el~ Thu Mar 3 14:59:58 2005
--- emacs/lisp/simple.el Thu Mar 3 15:45:42 2005
***************
*** 2875,2880 ****
--- 2875,2888 ----
(put 'mark-inactive 'error-conditions '(mark-inactive error))
(put 'mark-inactive 'error-message "The mark is not active now")
+ (defvar activate-mark-hook nil
+ "Hook run when the mark becomes active.
+ It is also run at the end of a command, if the mark is active and
+ it is possible that the region may have changed")
+
+ (defvar deactivate-mark-hook nil
+ "Hook run when the mark becomes inactive.")
+
(defun mark (&optional force)
"Return this buffer's mark value as integer; error if mark inactive.
If optional argument FORCE is non-nil, access the mark value
***************
*** 2966,2971 ****
--- 2974,2980 ----
(if (or arg (null mark) (/= mark (point)))
(push-mark nil nomsg t)
(setq mark-active t)
+ (run-hooks 'activate-mark-hook)
(unless nomsg
(message "Mark activated")))))