🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.vm.bug
Article #8966

hooks

#8966
From: Jamie Zawinski
Date: Sun, 05 Jul 1992 09:20
193 lines
7985 bytes
I have added some hooks to VM; patch below.

The line numbers may be skewed, since this diff was made from the
slightly modified version of VM 5.32 that we ship with Lucid Emacs.

The hooks I have added are:

 vm-summary-mode-hooks		Should be no argument with this one :-)

 vm-preview-message-hook	Called when a message is first displayed if
				you have previewing enabled.

 vm-show-message-hook		Called when a message is first fully 
				displayed, which is only different from when
				it is selected if you're using previewing.

 vm-show-new-message-hook	Called just after vm-show-message-hook when
				the message being selected is new (has just
				been incorperated into the folder.)

 vm-show-unread-message-hook	Called just after vm-show-message-hook when
				the message being selected is marked as
				unread.

I have named them -hook instead of -hooks because that's the pattern that
almost all of the emacs hooks follow, but I would have no real argument if
they were called -hooks to be more consistent with the rest of the VM hooks.

I'm not sure that the distinction between "new" messages and "unread"
messages is a useful one, so perhaps those two should be combined into
one hook.

Kyle, will you please put these patches into your next release of VM?

If the answer is "no" or "maybe" or "I'll think about it", then please
send me mail so I can browbeat you in to it.

	-- Jamie

===================================================================
RCS file: /cadillac-inferno-5/cvs-master/lemacs/lisp/vm/vm-vars.el,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 vm-vars.el
*** 1.1.1.1	1992/06/29 22:29:09
--- vm-vars.el	1992/07/05 08:49:49
***************
*** 503,508 ****
--- 503,514 ----
  and local variables.  Mucking about in the folder buffer is certainly
  possible but it is not encouraged.")
  
+ (defvar vm-summary-mode-hooks nil
+   "*List of hook functions to run when a buffer enters vm-summary-mode.
+ These hook functions should generally be used to set key bindings
+ and local variables.  Mucking about in the folder buffer is certainly
+ possible but it is not encouraged.")
+ 
  (defvar vm-berkeley-mail-compatibility
    (memq system-type '(berkeley-unix))
    "*Non-nil means to read and write BSD Mail(1) style Status: headers.
***************
*** 534,539 ****
--- 540,577 ----
  (defvar mail-yank-hooks nil
    "*List of hook functions called after yanking a message into a *mail*
  buffer.  See the documentation for the function vm-yank-message for details.")
+ 
+ (defvar vm-show-message-hook nil
+   "*List of hook functions called when a VM message is selected.
+ See also vm-preview-message-hook.")
+ 
+ (defvar vm-preview-message-hook nil
+   "*List of hook functions called when a VM message is previewed,
+ if and only if vm-preview-lines is non-nil.  See also vm-show-message-hook.")
+ 
+ (defvar vm-show-new-message-hook nil
+   "*List of hook functions called when VM selects a new message, 
+ that is, just after the ``message new'' flag has been set to false.
+ 
+ This is subtly different from the vm-show-unread-message-hook: a `new' 
+ message is one that has been added to this folder in this session, before
+ vm-quit has been executed.  An `unread' message is one that has simply
+ never been selected before; most likely this is because the message was
+ added to the folder by something other than VM.
+ 
+ The vm-show-message-hook will be run immediately after this hook.")
+ 
+ (defvar vm-show-unread-message-hook nil
+   "*List of hook functions called when VM selects a message for the first time,
+ that is, just after the ``message new'' flag has been set to false.  The 
+ 
+ This is subtly different from the vm-show-unread-message-hook: a `new' 
+ message is one that has been added to this folder in this session, before
+ vm-quit has been executed.  An `unread' message is one that has simply
+ never been selected before; most likely this is because the message was
+ added to the folder by something other than VM.
+ 
+ vm-show-message-hook will be run immediately after this hook.")
  
  (defvar vm-movemail-program "movemail"
    "*Name of program to use to move mail from the system spool
===================================================================
RCS file: /cadillac-inferno-5/cvs-master/lemacs/lisp/vm/vm-summary.el,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 vm-summary.el
*** 1.1.1.1	1992/06/29 22:29:08
--- vm-summary.el	1992/07/05 08:45:10
***************
*** 25,31 ****
  	buffer-read-only t
  	vm-summary-pointer nil
  	truncate-lines t)
!   (use-local-map vm-mode-map))
  
  (put 'vm-summary-mode 'mode-class 'special)
  
--- 25,32 ----
  	buffer-read-only t
  	vm-summary-pointer nil
  	truncate-lines t)
!   (use-local-map vm-mode-map)
!   (run-hooks 'vm-summary-mode-hooks))
  
  (put 'vm-summary-mode 'mode-class 'special)
  
===================================================================
RCS file: /cadillac-inferno-5/cvs-master/lemacs/lisp/vm/vm-page.el,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 vm-page.el
*** 1.1.1.1	1992/06/29 22:29:07
--- vm-page.el	1992/07/05 07:52:53
***************
*** 185,195 ****
  	       (not (vm-new-flag (car vm-message-pointer)))
  	       (not (vm-unread-flag (car vm-message-pointer)))))
        (vm-show-current-message)
!     (vm-update-summary-and-mode-line)))
  
  (defun vm-show-current-message ()
    (setq vm-system-state 'showing)
!   (let ((vmp vm-message-pointer))
      (vm-within-current-message-buffer
       (let ((vm-message-pointer vmp))
         (save-excursion
--- 185,199 ----
  	       (not (vm-new-flag (car vm-message-pointer)))
  	       (not (vm-unread-flag (car vm-message-pointer)))))
        (vm-show-current-message)
!     (vm-update-summary-and-mode-line)
!     (run-hooks 'vm-preview-message-hook)	; jwz
!     ))
  
  (defun vm-show-current-message ()
    (setq vm-system-state 'showing)
!   (let ((vmp vm-message-pointer)
! 	(newp nil)
! 	(unreadp nil))
      (vm-within-current-message-buffer
       (let ((vm-message-pointer vmp))
         (save-excursion
***************
*** 200,211 ****
  	   (progn
  	     (if (looking-at page-delimiter)
  		 (forward-page 1))
! 	     (vm-narrow-to-page))))))
    (cond ((vm-new-flag (car vm-message-pointer))
  	 (vm-set-new-flag (car vm-message-pointer) nil))
  	((vm-unread-flag (car vm-message-pointer))
  	 (vm-set-unread-flag (car vm-message-pointer) nil)))
!   (vm-update-summary-and-mode-line))
  
  (defun vm-expose-hidden-headers ()
    "Toggle exposing and hiding message headers that are normally not visible."
--- 204,221 ----
  	   (progn
  	     (if (looking-at page-delimiter)
  		 (forward-page 1))
! 	     (vm-narrow-to-page)))))
    (cond ((vm-new-flag (car vm-message-pointer))
+ 	 (setq newp t)		; jwz: for vm-show-new-message-hook.
  	 (vm-set-new-flag (car vm-message-pointer) nil))
  	((vm-unread-flag (car vm-message-pointer))
+ 	 (setq unreadp t)	; jwz: for vm-show-unread-message-hook.
  	 (vm-set-unread-flag (car vm-message-pointer) nil)))
!   (vm-update-summary-and-mode-line)
!   (cond (newp (run-hooks 'vm-show-new-message-hook))
! 	(unreadp (run-hooks 'vm-show-unread-message-hook)))
!   (run-hooks 'vm-show-message-hook)
!   ))
  
  (defun vm-expose-hidden-headers ()
    "Toggle exposing and hiding message headers that are normally not visible."
Technical Details
Message-ID: <9207050920.AA22276@thalidomide.lucid>
Path: arc1-ca.pugleaf.net!sparky!uunet!wendy-fate.uu.net!bug-vm

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f6829,58e2dd845b76f6d1,start
X-Google-Attributes: gidf6829,public
X-Google-ArrivalTime: 1992-07-04 21:14:22 PST
Newsgroups: gnu.emacs.vm.bug
Sender: bug-vm-request@uunet.uu.net
Date: Sun, 5 Jul 92 02:20:40 PDT
Message-ID: <9207050920.AA22276@thalidomide.lucid>
X-Windows: There's got to be a better way.
From: Jamie Zawinski <jwz@lucid.com>
Subject: hooks
Path: arc1-ca.pugleaf.net!sparky!uunet!wendy-fate.uu.net!bug-vm
Lines: 193