* Re: [Emacs-diffs] master d48e07a: * lisp/simple.el (next-error-find-buffer-function): New defcustom.
[not found] ` <20180221213027.372932052F@vcs0.savannah.gnu.org>
@ 2018-02-21 22:04 ` Stefan Monnier
2018-02-22 21:38 ` bug#20489: " Juri Linkov
2018-02-26 2:33 ` Dmitry Gutov
0 siblings, 2 replies; 10+ messages in thread
From: Stefan Monnier @ 2018-02-21 22:04 UTC (permalink / raw)
To: emacs-devel; +Cc: Juri Linkov
> +(defcustom next-error-find-buffer-function nil
Why make it a defcustom rather than a defvar?
> + (when next-error-find-buffer-function
> + (funcall next-error-find-buffer-function avoid-current
> + extra-test-inclusive
> + extra-test-exclusive))
Could you arrange for the default value of this new *-function var not
to be nil so we can modify it with add-function?
Stefan
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#20489: [Emacs-diffs] master d48e07a: * lisp/simple.el (next-error-find-buffer-function): New defcustom.
2018-02-21 22:04 ` [Emacs-diffs] master d48e07a: * lisp/simple.el (next-error-find-buffer-function): New defcustom Stefan Monnier
@ 2018-02-22 21:38 ` Juri Linkov
2018-02-23 14:36 ` Stefan Monnier
2018-02-26 2:33 ` Dmitry Gutov
1 sibling, 1 reply; 10+ messages in thread
From: Juri Linkov @ 2018-02-22 21:38 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 20489
>> +(defcustom next-error-find-buffer-function nil
>
> Why make it a defcustom rather than a defvar?
I changed it to defvar in the following patch.
>> + (when next-error-find-buffer-function
>> + (funcall next-error-find-buffer-function avoid-current
>> + extra-test-inclusive
>> + extra-test-exclusive))
>
> Could you arrange for the default value of this new *-function var not
> to be nil so we can modify it with add-function?
Then I guess the default function should return nil. Here is a new patch:
diff --git a/lisp/simple.el b/lisp/simple.el
index 2101cfe..5413b5a 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -170,14 +170,12 @@ next-error-buffer-p
(and extra-test-inclusive
(funcall extra-test-inclusive))))))
-(defcustom next-error-find-buffer-function nil
- "Function called to find a `next-error' capable buffer."
- :type '(choice (const :tag "Single next-error capable buffer on selected frame"
- next-error-buffer-on-selected-frame)
- (const :tag "No default" nil)
- (function :tag "Other function"))
- :group 'next-error
- :version "27.1")
+(defvar next-error-find-buffer-function 'next-error-find-buffer-function-default
+ "Function to find a `next-error' capable buffer.")
+
+(defun next-error-find-buffer-function-default (&optional avoid-current
+ extra-test-inclusive
+ extra-test-exclusive))
(defun next-error-buffer-on-selected-frame (&optional avoid-current
extra-test-inclusive
@@ -212,10 +210,9 @@ next-error-find-buffer
that buffer is rejected."
(or
;; 1. If a customizable function returns a buffer, use it.
- (when next-error-find-buffer-function
- (funcall next-error-find-buffer-function avoid-current
- extra-test-inclusive
- extra-test-exclusive))
+ (funcall next-error-find-buffer-function avoid-current
+ extra-test-inclusive
+ extra-test-exclusive)
;; 2. If next-error-last-buffer is an acceptable buffer, use that.
(if (and next-error-last-buffer
(next-error-buffer-p next-error-last-buffer avoid-current
^ permalink raw reply related [flat|nested] 10+ messages in thread
* bug#20489: [Emacs-diffs] master d48e07a: * lisp/simple.el (next-error-find-buffer-function): New defcustom.
2018-02-22 21:38 ` bug#20489: " Juri Linkov
@ 2018-02-23 14:36 ` Stefan Monnier
2018-02-24 21:34 ` Juri Linkov
0 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2018-02-23 14:36 UTC (permalink / raw)
To: Juri Linkov; +Cc: 20489
>> Could you arrange for the default value of this new *-function var not
>> to be nil so we can modify it with add-function?
> Then I guess the default function should return nil. Here is a new patch:
Fine by me. Tho, see comments below.
Stefan
> +(defun next-error-find-buffer-function-default (&optional avoid-current
> + extra-test-inclusive
> + extra-test-exclusive))
This looks like a syntax error to me (function without body). I know
it's accepted (because various parts of the byte-compiler need special
hacks to deal with it), but please always put a body (i.e. an explicit nil).
This said, I don't think you should define this function. Instead:
> +(defvar next-error-find-buffer-function 'next-error-find-buffer-function-default
should just say
(defvar next-error-find-buffer-function #'ignore
-- Stefan
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#20489: [Emacs-diffs] master d48e07a: * lisp/simple.el (next-error-find-buffer-function): New defcustom.
2018-02-23 14:36 ` Stefan Monnier
@ 2018-02-24 21:34 ` Juri Linkov
2018-02-25 13:19 ` Stefan Monnier
0 siblings, 1 reply; 10+ messages in thread
From: Juri Linkov @ 2018-02-24 21:34 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 20489
>> +(defun next-error-find-buffer-function-default (&optional avoid-current
>> + extra-test-inclusive
>> + extra-test-exclusive))
>
> This looks like a syntax error to me (function without body). I know
> it's accepted (because various parts of the byte-compiler need special
> hacks to deal with it), but please always put a body (i.e. an explicit nil).
And without body there is no way to add a docstring.
>> +(defvar next-error-find-buffer-function 'next-error-find-buffer-function-default
>
> should just say
>
> (defvar next-error-find-buffer-function #'ignore
Ah, before arriving to the function without body I mistakenly tried #'identity
(that didn't work) whereas I actually intended to try #'ignore.
But the question that I really don't understand is what to do with the function
next-error-buffer-on-selected-frame that now will have no reference in code,
no use by default. How the users are supposed to know that it's possible
to put add-function with this function in the init file? Should we document
this in the docstring of next-error-buffer-on-selected-frame or the docstring
of next-error-find-buffer-function together with examples of using add-function?
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#20489: [Emacs-diffs] master d48e07a: * lisp/simple.el (next-error-find-buffer-function): New defcustom.
2018-02-24 21:34 ` Juri Linkov
@ 2018-02-25 13:19 ` Stefan Monnier
2018-02-25 20:40 ` Juri Linkov
0 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2018-02-25 13:19 UTC (permalink / raw)
To: Juri Linkov; +Cc: 20489
> Ah, before arriving to the function without body I mistakenly tried #'identity
> (that didn't work) whereas I actually intended to try #'ignore.
Should we provide the K combinator?
> But the question that I really don't understand is what to do with the
> function next-error-buffer-on-selected-frame that now will have no
> reference in code, no use by default. How the users are supposed to
> know that it's possible to put add-function with this function in the
> init file?
Ah, so that's why you had a defcustom? Then maybe having it be
a defcustom is a good idea.
Stefan "to tell you the truth, I haven't bothered to look at the
code to try to understand what these things are doing,
so I have no opinion on whether it should be a defcustom
or not, or if should be a function defcustom rather
than, say, a boolean defcustom"
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#20489: [Emacs-diffs] master d48e07a: * lisp/simple.el (next-error-find-buffer-function): New defcustom.
2018-02-25 13:19 ` Stefan Monnier
@ 2018-02-25 20:40 ` Juri Linkov
0 siblings, 0 replies; 10+ messages in thread
From: Juri Linkov @ 2018-02-25 20:40 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 20489
>> But the question that I really don't understand is what to do with the
>> function next-error-buffer-on-selected-frame that now will have no
>> reference in code, no use by default. How the users are supposed to
>> know that it's possible to put add-function with this function in the
>> init file?
>
> Ah, so that's why you had a defcustom? Then maybe having it be
> a defcustom is a good idea.
>
>
> Stefan "to tell you the truth, I haven't bothered to look at the
> code to try to understand what these things are doing,
> so I have no opinion on whether it should be a defcustom
> or not, or if should be a function defcustom rather
> than, say, a boolean defcustom"
I think what we need is to support add-function in defcustom.
Probably we already have all building blocks to create a new
widget type using a list of functions together with PLACE symbols
(e.g. ‘:around’, ‘:before’). Then saving such customization should
apply add-function on that list of functions in the customized order.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Emacs-diffs] master d48e07a: * lisp/simple.el (next-error-find-buffer-function): New defcustom.
2018-02-21 22:04 ` [Emacs-diffs] master d48e07a: * lisp/simple.el (next-error-find-buffer-function): New defcustom Stefan Monnier
2018-02-22 21:38 ` bug#20489: " Juri Linkov
@ 2018-02-26 2:33 ` Dmitry Gutov
2018-02-26 3:24 ` Stefan Monnier
1 sibling, 1 reply; 10+ messages in thread
From: Dmitry Gutov @ 2018-02-26 2:33 UTC (permalink / raw)
To: Stefan Monnier, emacs-devel; +Cc: Juri Linkov
On 2/22/18 12:04 AM, Stefan Monnier wrote:
>> +(defcustom next-error-find-buffer-function nil
>
> Why make it a defcustom rather than a defvar?
I think we'll want to provide a set of predefined functions in the
future, for the user to choose one from.
>> + (when next-error-find-buffer-function
>> + (funcall next-error-find-buffer-function avoid-current
>> + extra-test-inclusive
>> + extra-test-exclusive))
>
> Could you arrange for the default value of this new *-function var not
> to be nil so we can modify it with add-function?
Personally, I don't really expect this variable to be modified
programmatically. And if it is, most likely not in a "function
combination" fashion.
But, of course, I might be wrong.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Emacs-diffs] master d48e07a: * lisp/simple.el (next-error-find-buffer-function): New defcustom.
2018-02-26 2:33 ` Dmitry Gutov
@ 2018-02-26 3:24 ` Stefan Monnier
2018-02-27 21:39 ` Juri Linkov
0 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2018-02-26 3:24 UTC (permalink / raw)
To: Dmitry Gutov; +Cc: Juri Linkov, emacs-devel
>>> +(defcustom next-error-find-buffer-function nil
>> Why make it a defcustom rather than a defvar?
> I think we'll want to provide a set of predefined functions in the future,
> for the user to choose one from.
So a defcustom makes sense, good.
>>> + (when next-error-find-buffer-function
>>> + (funcall next-error-find-buffer-function avoid-current
>>> + extra-test-inclusive
>>> + extra-test-exclusive))
>> Could you arrange for the default value of this new *-function var not
>> to be nil so we can modify it with add-function?
> Personally, I don't really expect this variable to be modified
> programmatically. And if it is, most likely not in a "function
> combination" fashion.
But using `ignore` instead of `nil` both simplifies the code and makes
the var compatible with add-function, so it doesn't matter if
`add-function` is really useful with it.
Stefan
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Emacs-diffs] master d48e07a: * lisp/simple.el (next-error-find-buffer-function): New defcustom.
2018-02-26 3:24 ` Stefan Monnier
@ 2018-02-27 21:39 ` Juri Linkov
2018-02-27 22:13 ` Stefan Monnier
0 siblings, 1 reply; 10+ messages in thread
From: Juri Linkov @ 2018-02-27 21:39 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel, Dmitry Gutov
>>>> +(defcustom next-error-find-buffer-function nil
>>> Why make it a defcustom rather than a defvar?
>> I think we'll want to provide a set of predefined functions in the future,
>> for the user to choose one from.
>
> So a defcustom makes sense, good.
>
>>>> + (when next-error-find-buffer-function
>>>> + (funcall next-error-find-buffer-function avoid-current
>>>> + extra-test-inclusive
>>>> + extra-test-exclusive))
>>> Could you arrange for the default value of this new *-function var not
>>> to be nil so we can modify it with add-function?
>> Personally, I don't really expect this variable to be modified
>> programmatically. And if it is, most likely not in a "function
>> combination" fashion.
>
> But using `ignore` instead of `nil` both simplifies the code and makes
> the var compatible with add-function, so it doesn't matter if
> `add-function` is really useful with it.
So I just changed the default value from nil to ‘ignore’.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Emacs-diffs] master d48e07a: * lisp/simple.el (next-error-find-buffer-function): New defcustom.
2018-02-27 21:39 ` Juri Linkov
@ 2018-02-27 22:13 ` Stefan Monnier
0 siblings, 0 replies; 10+ messages in thread
From: Stefan Monnier @ 2018-02-27 22:13 UTC (permalink / raw)
To: Juri Linkov; +Cc: emacs-devel, Dmitry Gutov
> So I just changed the default value from nil to ‘ignore’.
Good, thanks,
Stefan
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2018-02-27 22:13 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20180221213025.27066.69339@vcs0.savannah.gnu.org>
[not found] ` <20180221213027.372932052F@vcs0.savannah.gnu.org>
2018-02-21 22:04 ` [Emacs-diffs] master d48e07a: * lisp/simple.el (next-error-find-buffer-function): New defcustom Stefan Monnier
2018-02-22 21:38 ` bug#20489: " Juri Linkov
2018-02-23 14:36 ` Stefan Monnier
2018-02-24 21:34 ` Juri Linkov
2018-02-25 13:19 ` Stefan Monnier
2018-02-25 20:40 ` Juri Linkov
2018-02-26 2:33 ` Dmitry Gutov
2018-02-26 3:24 ` Stefan Monnier
2018-02-27 21:39 ` Juri Linkov
2018-02-27 22:13 ` Stefan Monnier
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.