From: Tassilo Horn <tsdh@gnu.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: bug-reference.el: Allow custom handlers for opening URLs
Date: Mon, 04 May 2020 19:09:23 +0200 [thread overview]
Message-ID: <87h7wvd3uk.fsf@gnu.org> (raw)
In-Reply-To: <jwvftcfafgo.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Mon, 04 May 2020 11:32:56 -0400")
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> And when hacking that up, I've seen that this feature is already
>> implemented!
>>
>> The value of `browse-url-browser-function' may already be a (REGEXP
>> . FUNCTION) alist itself and then it works the same way as my new
>> `browse-url-handlers'.
>
> Hmm... right. Ideally we should have 2 places to specify those
> redirections: one autoload-set by packages to change the default
> behavior, and one custom-set by the user to override that default
> behavior.
So you mean we need to have a `browse-url-handlers' defcustom and a
`browse-url-handlers-default' defvar? Maybe you are right. On the
other hand, we haven't something like that for similar candidates like
`auto-mode-alist', too. There, we use the "if you don't like it, remove
it yourself" approach.
Another way would be to cross fingers and hope that package authors are
responsible enough to provide a defcustom which controls if a handler is
added to `browse-url-handlers'. That would be much more convenient as
both adding an override and removing an entry.
> But if we use `browse-url-browser-function` as the user-override, then
> as soon as the user sets it to `browse-url-firefox` it would override
> all the defaults :-(
>
> So we still need to deprecate this old hack on
> `browse-url-browser-function`.
Right.
>> But removing the alist from `browse-url--browser-defcustom-type'
>> would break the customize interface if the user's value is indeed an
>> alist... So is there a better way to deprecate a single choice of a
>> defcustom type? Just writing that in the docstring?
>
> Good question, hopefully someone else knows.
Hm, the info docs say that every custom type may have a :doc string:
--8<---------------cut here---------------start------------->8---
‘:doc DOC’
Use DOC as the documentation string for this value (or part of the
value) that corresponds to this type. In order for this to work,
you must specify a value for ‘:format’, and use ‘%d’ or ‘%h’ in
that value.
The usual reason to specify a documentation string for a type is to
provide more information about the meanings of alternatives inside
a ‘:choice’ type or the parts of some other composite type.
--8<---------------cut here---------------end--------------->8---
That second paragraph sounds exactly like what we would need, so I added
:doc "Deprecated. Use `browse-url-handlers' instead."
to the alist choice. However, I cannot see that in the customize
interface. Am I doing something wrong?
And another question. The definition below breaks the build.
--8<---------------cut here---------------start------------->8---
;;;###autoload ;; FIXME: This autoload breaks the build...
(defcustom browse-url-handlers
`(("\\`mailto:" . ,browse-url-mailto-function)
("\\`man:" . ,browse-url-man-function)
("\\`file://" . browse-url-emacs))
"An alist with elements of the form (REGEXP HANDLER).
Each REGEXP is matched against each URL to be opened in turn and
the first match's HANDLER is invoked with the URL.
A HANDLER must either be a function with the same arguments as
`browse-url' or a variable whos value is such a function.
If no REGEXP matches, the bug reference URL is opened using the
value of `browse-url-browser-function'."
:type '(alist :key-type (regexp :tag "Regexp")
:value-type (function :tag "Handler"))
:version "28.1")
--8<---------------cut here---------------end--------------->8---
The error is:
--8<---------------cut here---------------start------------->8---
Loading files...
Loading emacs-lisp/macroexp...
Loading cus-face...
Loading faces...
Loading button...
Loading loaddefs.el (source)...
Symbol's value as variable is void: browse-url-mailto-function
make[2]: *** [Makefile:584: emacs.pdmp] Error 255
make[2]: Leaving directory '/home/horn/Repos/el/emacs/src'
make[1]: *** [Makefile:424: src] Error 2
make[1]: Leaving directory '/home/horn/Repos/el/emacs'
make: *** [Makefile:1119: bootstrap] Error 2
--8<---------------cut here---------------end--------------->8---
When removing the autoload cookie, it builds fine. Why is that?
`browse-url-mailto-function' and `browse-url-man-function' are defined
way before `browse-url-handlers'.
Bye,
Tassilo
next prev parent reply other threads:[~2020-05-04 17:09 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-03 8:50 bug-reference.el: Allow custom handlers for opening URLs Tassilo Horn
2020-05-03 14:44 ` Stefan Monnier
2020-05-03 15:24 ` Tassilo Horn
2020-05-03 20:39 ` Stefan Monnier
2020-05-04 9:41 ` Tassilo Horn
2020-05-04 15:32 ` Stefan Monnier
2020-05-04 17:09 ` Tassilo Horn [this message]
2020-05-04 18:54 ` Stefan Monnier
2020-05-05 7:06 ` Tassilo Horn
2020-05-05 13:49 ` Stefan Monnier
2020-05-05 15:51 ` Tassilo Horn
2020-05-05 17:44 ` Stefan Monnier
2020-05-05 19:48 ` browse-url.el: Custom handlers for certain URLs (was: bug-reference.el: Allow custom handlers for opening URLs) Tassilo Horn
2020-05-04 6:52 ` bug-reference.el: Allow custom handlers for opening URLs Yuri Khan
2020-05-05 19:55 ` Arash Esbati
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h7wvd3uk.fsf@gnu.org \
--to=tsdh@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).