unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* activate-mark-hook
@ 2005-03-03  7:49 Chong Yidong
  0 siblings, 0 replies; 2+ messages in thread
From: Chong Yidong @ 2005-03-03  7:49 UTC (permalink / raw)


Two issues:

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.

Here is a patch:

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: activate-mark-hook
       [not found] <2873.220.255.169.59.1109836196.squirrel@www.stupidchicken.com>
@ 2005-03-06  6:13 ` Chong Yidong
  0 siblings, 0 replies; 2+ messages in thread
From: Chong Yidong @ 2005-03-06  6:13 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-03-06  6:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <2873.220.255.169.59.1109836196.squirrel@www.stupidchicken.com>
2005-03-06  6:13 ` activate-mark-hook Chong Yidong
2005-03-03  7:49 activate-mark-hook Chong Yidong

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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