unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* command-error-function default handler
@ 2013-10-26 19:16 Jarek Czekalski
  2013-10-26 21:14 ` Jarek Czekalski
  2013-10-27  3:44 ` Stefan Monnier
  0 siblings, 2 replies; 7+ messages in thread
From: Jarek Czekalski @ 2013-10-26 19:16 UTC (permalink / raw)
  To: emacs-devel

I was adviced to use command-error-function. However despite my 
selective error handling I want a default error handling to be performed 
too. I look into keyboard.c and see that the main activity of default 
handler is calling print_error_message.

But how do I do that from elisp?

It would be nice if command-error-function documentation explicitly say 
how to install custom error handling so that default handling still 
occured. Or at least how to display the message in most compatible way.

The similar issue is with bell. The docs does not say how to mimic 
default bell.

Thanks
Jarek




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

* Re: command-error-function default handler
  2013-10-26 19:16 command-error-function default handler Jarek Czekalski
@ 2013-10-26 21:14 ` Jarek Czekalski
  2013-10-27  3:44 ` Stefan Monnier
  1 sibling, 0 replies; 7+ messages in thread
From: Jarek Czekalski @ 2013-10-26 21:14 UTC (permalink / raw)
  To: emacs-devel

Probably in other languages there are solutions like that: if the 
function returns false, the default handler is called. If it returns 
true, the processing stops.

Isn't it a good idea? And sounds like it could be implemented.

I tried to find a discussion about it, but failed.

Jarek




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

* Re: command-error-function default handler
  2013-10-26 19:16 command-error-function default handler Jarek Czekalski
  2013-10-26 21:14 ` Jarek Czekalski
@ 2013-10-27  3:44 ` Stefan Monnier
  2013-10-27 13:48   ` Jarek Czekalski
  1 sibling, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2013-10-27  3:44 UTC (permalink / raw)
  To: Jarek Czekalski; +Cc: emacs-devel

> I was adviced to use command-error-function. However despite my selective
> error handling I want a default error handling to be performed too. I look
> into keyboard.c and see that the main activity of default handler is calling
> print_error_message.

> But how do I do that from elisp?

The way to do that right is as follows:
- change command-error-function's default value to not be nil.
- don't set command-error-function via `setq' but via `add-function'.
The first step may require changes to the C code.


        Stefan



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

* Re: command-error-function default handler
  2013-10-27  3:44 ` Stefan Monnier
@ 2013-10-27 13:48   ` Jarek Czekalski
  2013-10-28  0:23     ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Jarek Czekalski @ 2013-10-27 13:48 UTC (permalink / raw)
  To: emacs-devel


W dniu 2013-10-27 04:44, Stefan Monnier pisze:
> The way to do that right is as follows:
> - change command-error-function's default value to not be nil.
> - don't set command-error-function via `setq' but via `add-function'.
> The first step may require changes to the C code.

Now I noticed that in current state of Emacs command-error-function may 
not be used by a package. Only user can use it. If a package grabs it, 
no other package can use it. So no package at all may grab it as a result.

A cumbersome workaround is possible. If the value is nil, create a first 
handler with standard output included. If the value is not nil (there is 
already other handler), do add-function and don't produce standard 
output. But this is a workaround, not a reasonable usage of the feature.

In the meantime I probably found the answer to my question. Looking at 
usage of print_error_message in other files I came up with something 
that resembles the default handler behaviour:

(defun test-handler (&optional conditions context source)
   (message "%s%s: %s" context source (error-message-string conditions))
   ; we would also like to ring a bell here
)

So this is probably something that could be added to docs. Still this 
feature is not yet useful for packages. A package is the place where I 
wanted to use it. See related bug report: 15670 [1]

If I am wrong, please correct me.

Jarek

[1] http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15670




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

* Re: command-error-function default handler
  2013-10-27 13:48   ` Jarek Czekalski
@ 2013-10-28  0:23     ` Stefan Monnier
  2013-10-28  7:44       ` Jarek Czekalski
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2013-10-28  0:23 UTC (permalink / raw)
  To: Jarek Czekalski; +Cc: emacs-devel

> In the meantime I probably found the answer to my question. Looking at usage
> of print_error_message in other files I came up with something that
> resembles the default handler behaviour:

> (defun test-handler (&optional conditions context source)
>   (message "%s%s: %s" context source (error-message-string conditions))
>   ; we would also like to ring a bell here
> )

Could you provide a patch to Emacs that changes the default value of
command-error-function to a function that does the same as the current
default behavior?


        Stefan



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

* Re: command-error-function default handler
  2013-10-28  0:23     ` Stefan Monnier
@ 2013-10-28  7:44       ` Jarek Czekalski
  2013-10-28 12:46         ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Jarek Czekalski @ 2013-10-28  7:44 UTC (permalink / raw)
  To: emacs-devel


W dniu 2013-10-28 01:23, Stefan Monnier pisze:
>
> Could you provide a patch to Emacs that changes the default value of
> command-error-function to a function that does the same as the current
> default behavior?
>
>
>          Stefan

With pleasure, but this may take up to 2 weeks.

Best,
Jarek



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

* Re: command-error-function default handler
  2013-10-28  7:44       ` Jarek Czekalski
@ 2013-10-28 12:46         ` Stefan Monnier
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2013-10-28 12:46 UTC (permalink / raw)
  To: Jarek Czekalski; +Cc: emacs-devel

>> Could you provide a patch to Emacs that changes the default value of
>> command-error-function to a function that does the same as the current
>> default behavior?
> With pleasure, but this may take up to 2 weeks.

Take your time,


        Stefan


PS: And in case the patch is a bit longer than the 20-ish-lines limit
(in which case we'd need you to sign some copyright paperwork), you
might want to start the paperwork process.  If so, just fill the form
below and email it as instructed so the FSF can send you the appropriate
paperwork to sign.


Please email the following information to assign@gnu.org, and we
will send you the assignment form for your past and future changes.

Please use your full legal name (in ASCII characters) as the subject
line of the message.
----------------------------------------------------------------------
REQUEST: SEND FORM FOR PAST AND FUTURE CHANGES

[What is the name of the program or package you're contributing to?]
Emacs

[Did you copy any files or text written by someone else in these changes?
Even if that material is free software, we need to know about it.]


[Do you have an employer who might have a basis to claim to own
your changes?  Do you attend a school which might make such a claim?]


[For the copyright registration, what country are you a citizen of?]


[What year were you born?]


[Please write your email address here.]


[Please write your postal address here.]





[Which files have you changed so far, and which new files have you written
so far?]




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

end of thread, other threads:[~2013-10-28 12:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-26 19:16 command-error-function default handler Jarek Czekalski
2013-10-26 21:14 ` Jarek Czekalski
2013-10-27  3:44 ` Stefan Monnier
2013-10-27 13:48   ` Jarek Czekalski
2013-10-28  0:23     ` Stefan Monnier
2013-10-28  7:44       ` Jarek Czekalski
2013-10-28 12:46         ` Stefan Monnier

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