unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Bob Rogers <rogers-emacs@rgrjr.dyndns.org>
To: emacs-devel <emacs-devel@gnu.org>
Subject: Adding a hook to list-processes
Date: Sat, 27 Nov 2010 13:52:45 -0500	[thread overview]
Message-ID: <19697.21373.201776.909872@rgr.rgrjr.com> (raw)

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



             reply	other threads:[~2010-11-27 18:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-27 18:52 Bob Rogers [this message]
2010-11-27 19:43 ` Adding a hook to list-processes 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19697.21373.201776.909872@rgr.rgrjr.com \
    --to=rogers-emacs@rgrjr.dyndns.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).