unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Adding a hook to list-processes
@ 2010-11-27 18:52 Bob Rogers
  2010-11-27 19:43 ` Davis Herring
  2010-11-28 18:49 ` Stefan Monnier
  0 siblings, 2 replies; 13+ messages in thread
From: Bob Rogers @ 2010-11-27 18:52 UTC (permalink / raw)
  To: emacs-devel

   I tried to do this using the patch below; it compiles without
warning, but seems to have no effect.  Evaluating the following code in
src/emacs:

	(defun rgr-list-processes-hook ()
	  (message "In buffer %S" (current-buffer)))
	(add-hook 'after-list-processes-hook 'rgr-list-processes-hook)

and then "M-x list-processes RET" does not produce the expected message.
I cargo-culted this based on Qmouse_leave_buffer_hook; what did I do
wrong?  TIA,

					-- Bob Rogers
					   http://www.rgrjr.com/

P.S.  FWIW, I'm trying to turn the buffer names into buttons.  Given my
C skills, using a hook seemed like a safer bet.

------------------------------------------------------------------------
diff --git a/src/process.c b/src/process.c
index f8ca095..e95d465 100644
--- a/src/process.c
+++ b/src/process.c
@@ -113,6 +113,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "nsterm.h"
 #endif
 
+Lisp_Object Vafter_list_processes_hook, Qafter_list_processes_hook;
 Lisp_Object Qeuid, Qegid, Qcomm, Qstate, Qppid, Qpgrp, Qsess, Qttname, Qtpgid;
 Lisp_Object Qminflt, Qmajflt, Qcminflt, Qcmajflt, Qutime, Qstime, Qcstime;
 Lisp_Object Qcutime, Qpri, Qnice, Qthcount, Qstart, Qvsize, Qrss, Qargs;
@@ -1493,6 +1494,11 @@ list_processes_1 (Lisp_Object query_only)
       status_notify (NULL);
       redisplay_preserve_echo_area (13);
     }
+
+  /* Give other code a chance to tweak the buffer.  */
+  if (!NILP (Vafter_list_processes_hook))
+    call1 (Vrun_hooks, Qafter_list_processes_hook);
+
   return Qnil;
 }
 
@@ -7736,6 +7742,13 @@ The variable takes effect when `start-process' is called.  */);
 
 #endif	/* subprocesses */
 
+  Qafter_list_processes_hook = intern_c_string ("mouse-leave-buffer-hook");
+  staticpro (&Qafter_list_processes_hook);
+
+  DEFVAR_LISP ("after-list-processes-hook", &Vafter_list_processes_hook,
+	       doc: /* Hook run after list-processes.  */);
+  Vafter_list_processes_hook = Qnil;
+
   defsubr (&Sget_buffer_process);
   defsubr (&Sprocess_inherit_coding_system_flag);
   defsubr (&Slist_system_processes);



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

end of thread, other threads:[~2010-12-02  2:48 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-27 18:52 Adding a hook to list-processes Bob Rogers
2010-11-27 19:43 ` Davis Herring
2010-11-27 20:25   ` Bob Rogers
2010-11-28 18:49 ` Stefan Monnier
2010-11-28 18:54   ` Bob Rogers
2010-11-30  6:05   ` Elisp implementation of list-processes Bob Rogers
2010-11-30 21:06     ` Elisp implementation of list-processes (and: Why is list-processes implemented in C?) Stefan Monnier
2010-12-01  3:27       ` Leo
2010-12-01  4:16       ` Elisp implementation of list-processes (and: Why islist-processes " Drew Adams
2010-12-01 10:55     ` Elisp implementation of list-processes Leo
2010-12-01 11:12     ` Leo
2010-12-02  2:48       ` Bob Rogers
2010-12-01 21:12     ` Richard Stallman

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