all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Lars Magne Ingebrigtsen <larsi@gnus.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Juanma Barranquero <lekktu@gmail.com>, sds@gnu.org, emacs-devel@gnu.org
Subject: Re: more candidates for obsoletion
Date: Sun, 13 May 2012 20:34:46 +0200	[thread overview]
Message-ID: <m31umokjzt.fsf@stories.gnus.org> (raw)
In-Reply-To: <jwvtxzy4tyz.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Wed, 02 May 2012 09:02:34 -0400")

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> That is, say `M-x backtrace-message RET obsolete RET', and then get a
>> backtrace whenever a string matching "obsolete" is messaged.
>
> Sounds good (tho I'd call it debug-on-message or something like that).
> Patch welcome,

If we want to get all the messages, I think set_message might be the
most likely place to put this.

The main problem is then how to avoid debugging recursively forever.
The following works, but surely there's an easier way to do this...

Proof of concept patch follows.  The real one would be structured
slightly differently:

=== modified file 'src/xdisp.c'
--- src/xdisp.c	2012-05-11 06:39:26 +0000
+++ src/xdisp.c	2012-05-13 18:32:19 +0000
@@ -10407,11 +10407,22 @@
    Doesn't GC, as with_echo_area_buffer binds Qinhibit_modification_hooks
    to t before calling set_message_1 (which calls insert).
   */
+Lisp_Object call_debugger (Lisp_Object arg);
+static int debugging = 0;
+
+Lisp_Object
+undo_debugging (Lisp_Object arg)
+{
+  debugging = 0;
+  return Qnil;
+}
 
 static void
 set_message (const char *s, Lisp_Object string,
 	     EMACS_INT nbytes, int multibyte_p)
 {
+  int count = SPECPDL_INDEX ();
+
   message_enable_multibyte
     = ((s && multibyte_p)
        || (STRINGP (string) && STRING_MULTIBYTE (string)));
@@ -10420,6 +10431,19 @@
 			 (intptr_t) s, string, nbytes, multibyte_p);
   message_buf_print = 0;
   help_echo_showing_p = 0;
+
+  record_unwind_save_match_data ();
+
+  if (! debugging &&
+      ! NILP (Vdebug_on_message) &&
+      STRINGP (Vdebug_on_message) &&
+      ! NILP (Fstring_match (Vdebug_on_message, string, Qnil))) {
+    debugging = 1;
+    record_unwind_protect (undo_debugging, Qnil);
+    call_debugger (Fcons (Qerror, Fcons (string, Qnil)));
+  }
+
+  unbind_to (count, Qnil);
 }
 
 
@@ -28824,6 +28848,10 @@
   Vglyphless_char_display = Fmake_char_table (Qglyphless_char_display, Qnil);
   Fset_char_table_extra_slot (Vglyphless_char_display, make_number (0),
 			      Qempty_box);
+
+  DEFVAR_LISP ("debug-on-message", Vdebug_on_message,
+    doc: /* If non-nil, debug if a message matching this regexp is displayed.  */);
+  Vdebug_on_message = Qnil;
 }
 
 



-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/



  reply	other threads:[~2012-05-13 18:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-01  6:43 more candidates for obsoletion Glenn Morris
2012-05-01 19:51 ` Sam Steingold
2012-05-01 22:06   ` Juanma Barranquero
2012-05-01 22:25     ` Lars Magne Ingebrigtsen
2012-05-01 22:28       ` Lars Magne Ingebrigtsen
2012-05-02 13:02         ` Stefan Monnier
2012-05-13 18:34           ` Lars Magne Ingebrigtsen [this message]
2012-05-14  2:20             ` Stefan Monnier
2012-09-04 18:10               ` Lars Ingebrigtsen
2012-09-04 19:29                 ` Stefan Monnier
2012-09-04 21:24                   ` Lars Ingebrigtsen
2012-05-02  5:03       ` Thierry Volpiatto
2012-05-02  9:25 ` Michael Albinus

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

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

  git send-email \
    --in-reply-to=m31umokjzt.fsf@stories.gnus.org \
    --to=larsi@gnus.org \
    --cc=emacs-devel@gnu.org \
    --cc=lekktu@gmail.com \
    --cc=monnier@iro.umontreal.ca \
    --cc=sds@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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.