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: Stefan Monnier
Subject: Re: Why does signaling an error not call set-message-function?
Date: Tue, 05 Apr 2022 10:19:41 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

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




reply via email to

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