unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* using command-error-function in emacspeak
@ 2013-11-03 19:56 Jarek Czekalski
  2013-11-03 21:20 ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Jarek Czekalski @ 2013-11-03 19:56 UTC (permalink / raw)
  To: emacs-devel, T. V. Raman

> It doesn't work with the recommended means of using add-function
> -- so perhaps there is a bug in nadvice

I wouldn't call this a bug. add-function documentation says about 
OLDFUN. It seems to assume that there already was a function there. It's 
not true in Emacs 24, but we are working on that. In Emacs 25 it will 
have a default value that will be a standard error output function.

Without testing Emacs version you could just work 2 ways:
1. if command-error-function is nil - set it
2. otherwise - add-function

However I agree that add-function would be better if it did that job for us.

Jarek




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

* Re: using command-error-function in emacspeak
  2013-11-03 19:56 using command-error-function in emacspeak Jarek Czekalski
@ 2013-11-03 21:20 ` Stefan Monnier
  2013-11-05  6:47   ` Jarek Czekalski
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2013-11-03 21:20 UTC (permalink / raw)
  To: Jarek Czekalski; +Cc: T. V. Raman, emacs-devel

> However I agree that add-function would be better if it did that job for us.

add-function is the to modify the behavior of a function.
It can't know what `nil' represents.

OTOH, it works if you use add-function with :override.


        Stefan



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

* Re: using command-error-function in emacspeak
  2013-11-03 21:20 ` Stefan Monnier
@ 2013-11-05  6:47   ` Jarek Czekalski
  2013-11-05 14:07     ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Jarek Czekalski @ 2013-11-05  6:47 UTC (permalink / raw)
  To: emacs-devel


W dniu 2013-11-03 22:20, Stefan Monnier pisze:
>> However I agree that add-function would be better if it did that job for us.
> add-function is the to modify the behavior of a function.
> It can't know what `nil' represents.

This is what nil represents:

(defun nil-fun () nil)

Add-function may add such a function to a chain if it couldn't deal with 
nil values in another way.

What am I missing?

BTW: Please let me know if I should do something about the patch here: 
http://lists.gnu.org/archive/html/emacs-devel/2013-11/msg00048.html. If 
I should first follow Xue's suggestion, sure I'll do it.

Jarek




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

* Re: using command-error-function in emacspeak
  2013-11-05  6:47   ` Jarek Czekalski
@ 2013-11-05 14:07     ` Stefan Monnier
  2013-11-05 14:45       ` Jarek Czekalski
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2013-11-05 14:07 UTC (permalink / raw)
  To: Jarek Czekalski; +Cc: emacs-devel

>> add-function is the to modify the behavior of a function.
>> It can't know what `nil' represents.
> This is what nil represents:
> (defun nil-fun () nil)

No, it's not.
Try to (setq command-error-function #'nil-fun)
to see if it's really the same as nil.


        Stefan



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

* Re: using command-error-function in emacspeak
  2013-11-05 14:07     ` Stefan Monnier
@ 2013-11-05 14:45       ` Jarek Czekalski
  2013-11-05 19:01         ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Jarek Czekalski @ 2013-11-05 14:45 UTC (permalink / raw)
  To: emacs-devel


W dniu 2013-11-05 15:07, Stefan Monnier pisze:
>>> add-function is the to modify the behavior of a function.
>>> It can't know what `nil' represents.
>> This is what nil represents:
>> (defun nil-fun () nil)
> No, it's not.
> Try to (setq command-error-function #'nil-fun)
> to see if it's really the same as nil.

Do you mean some subtle elisp difference (which I do not see) or the way 
command-error-function works? Or you just caught me that I didn't 
include "&rest args" in nil-fun definition?

I know that (setq command-error-function 'nil-fun) changes Emacs 
behaviour, but this is not the case. I think the case is that

(add-function command-error-function something) ;; forgive me wrong 
syntax here

should do the same as

(setq command-error-function something)

in case when command-error-function is nil beforehand.

And the latter would be equivalent to:
(setq command-error-function 'nil-fun)
(add-function command-error-function something)
which is what I propose as a simplification of what add-function should do.

Please explain, what you had in mind. I still don't understand why 
add-function couldn't work on nils. Could you give one counter-example?

Thanks,
Jarek




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

* Re: using command-error-function in emacspeak
  2013-11-05 14:45       ` Jarek Czekalski
@ 2013-11-05 19:01         ` Stefan Monnier
  2013-11-05 19:57           ` Jarek Czekalski
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2013-11-05 19:01 UTC (permalink / raw)
  To: Jarek Czekalski; +Cc: emacs-devel

> (add-function command-error-function something) ;; forgive me wrong syntax
> here should do the same as
> (setq command-error-function something)
> in case when command-error-function is nil beforehand.

But that can't be right.
E.g.

   (add-function :before command-error-function
                 (lambda (&rest _ignore)
                   (cl-incf command-error-function-counter)))

Should not affect Emacs's behavior other than to keep a counter of calls
to command-error-function.  But

  (setq command-error-function
        (lambda (&rest _ignore) (cl-incf command-error-function-counter))

will not do that, since it will instead silence all the
command-error messages.
        

        Stefan



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

* Re: using command-error-function in emacspeak
  2013-11-05 19:01         ` Stefan Monnier
@ 2013-11-05 19:57           ` Jarek Czekalski
  2013-11-05 22:48             ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Jarek Czekalski @ 2013-11-05 19:57 UTC (permalink / raw)
  To: emacs-devel


W dniu 2013-11-05 20:01, Stefan Monnier pisze:
>> (add-function command-error-function something) ;; forgive me wrong syntax
>> here should do the same as
>> (setq command-error-function something)
>> in case when command-error-function is nil beforehand.
> But that can't be right.
> E.g.
>
>     (add-function :before command-error-function
>                   (lambda (&rest _ignore)
>                     (cl-incf command-error-function-counter)))
>
> Should not affect Emacs's behavior other than to keep a counter of calls
> to command-error-function.  But
>
>    (setq command-error-function
>          (lambda (&rest _ignore) (cl-incf command-error-function-counter))
>
> will not do that, since it will instead silence all the
> command-error messages.
>          
>
>          Stefan
>

So this is regarding command-error-function specific variable, right? 
Not add-function in general? This will be fixed soon, the patch is 
waiting for a review.

Are there examples of any other ...-function variables that work in this 
way: nil has a special meaning and nil value results in calling some 
system hidden handler? I think this is not a good logic to follow. The 
better is this:

nil value for a AAA-function variable means that no action is taken when 
AAA happens.

When this logic is used, add-function should operate on nil values as 
well as on function values.

Which logic is used in general in Emacs for ...-function variables - I 
don't know. If you can point me to some reading, that would help. 
Currently I try to understand it by intuition.

I also reviewed a couple of examples:

adaptive-fill-function - nil by default, means no action
browse-url-browser-function - not nil
buffer-stale-function - not nil
comment-indent-function - not nil
... stopped, this seems to confirm my logic.

add-function may be used by packages for their own goals, but nil value 
should always have a common meaning. No action seems to be intuitive.

Jarek




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

* Re: using command-error-function in emacspeak
  2013-11-05 19:57           ` Jarek Czekalski
@ 2013-11-05 22:48             ` Stefan Monnier
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Monnier @ 2013-11-05 22:48 UTC (permalink / raw)
  To: Jarek Czekalski; +Cc: emacs-devel

> So this is regarding command-error-function specific variable, right?

No, it's true of any foo-function variable where nil means "use some
default behavior" instead "do nothing".  Sadly, it's the case of the
majority of the foo-function variables.


        Stefan



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

end of thread, other threads:[~2013-11-05 22:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-03 19:56 using command-error-function in emacspeak Jarek Czekalski
2013-11-03 21:20 ` Stefan Monnier
2013-11-05  6:47   ` Jarek Czekalski
2013-11-05 14:07     ` Stefan Monnier
2013-11-05 14:45       ` Jarek Czekalski
2013-11-05 19:01         ` Stefan Monnier
2013-11-05 19:57           ` Jarek Czekalski
2013-11-05 22:48             ` 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).