emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why does signaling an error not call set-message-function?


From: T.V Raman
Subject: Re: Why does signaling an error not call set-message-function?
Date: Tue, 05 Apr 2022 09:07:15 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Stefan Monnier <monnier@iro.umontreal.ca> writes:
Emacspeak in module emacspeak-advice.el
https://github.com/tvraman/emacspeak/blob/master/lisp/emacspeak-advice.el#L819
uses the following lines to handle this:

(defun emacspeak-error-handler (data context _calling-function)
  "Emacspeak custom error handler."
  (emacspeak-auditory-icon 'warn-user)
  (message "%s %s"
           (or context " ")
           (error-message-string data)))


 
>>> I don't see a problem running arbitrary ELisp code at that time.
>>> After all, we already exited the error-signaling context
>> We did?
>
> You made me doubt, but indeed I see:
>
>     Lisp_Object
>     command_loop_2 (Lisp_Object handlers)
>     {
>       register Lisp_Object val;
>     
>       do
>         val = internal_condition_case (command_loop_1, handlers, cmd_error);
>       while (!NILP (val));
>     
>       return Qnil;
>     }
>
> So `cmd_error` is run after we exit the error-signaling context.
> Also while looking at it, I saw tht `cmd_error` then calls
> `cmd_error_internal` which calls `command-error-function`:
>
>     command-error-function is a variable defined in ??C source code??.
>     
>     Its value is ??help-command-error-confusable-suggestions??
>     
>     Function to output error messages.
>     Called with three arguments:
>     - the error data, a list of the form (SIGNALED-CONDITION . SIGNAL-DATA)
>       such as what ??condition-case?? would bind its variable to,
>     - the context (a string which normally goes at the start of the message),
>     - the Lisp function within which the error was signaled.
>     
>     Also see ??set-message-function?? (which controls how non-error messages
>     are displayed).
>
> So we do already allow running arbitrary ELisp code in there ;-)
>
>
>         Stefan
>
>

-- 

Thanks,

--Raman(I Search, I Find, I Misplace, I Research)
?7?4 Id: kg:/m/0285kf1  ?0?8



reply via email to

[Prev in Thread] Current Thread [Next in Thread]