GNU bug report logs -
#74781
[PATCH] Add `browse-url-qutebrowser'
Previous Next
Reported by: Daniel Mendler <mail <at> daniel-mendler.de>
Date: Wed, 11 Dec 2024 07:05:01 UTC
Severity: normal
Tags: patch
Done: Daniel Mendler <mail <at> daniel-mendler.de>
Bug is archived. No further changes may be made.
Full log
Message #26 received at submit <at> debbugs.gnu.org (full text, mbox):
Björn Bidar <bjorn.bidar <at> thaodan.de> writes:
> Daniel Mendler via "Bug reports for GNU Emacs, the Swiss army knife of
> text editors" <bug-gnu-emacs <at> gnu.org> writes:
>
>> Robert Pluim <rpluim <at> gmail.com> writes:
>>
>>>>>>>> On Wed, 11 Dec 2024 10:07:08 +0100, Daniel Mendler <mail <at> daniel-mendler.de> said:
>>> The emacs help system applies heuristics which are not always
>>> accurate, and donʼt always return an answer, hence the version tags.
>>
>> Thanks, I added the version tags. See the updated patch.
>>
>>> >> We have `xdg-runtime-dir' in xdg.el
>>>
>>> Daniel> The goal was to avoid loading `xdg.el' unnecessarily for this trivial
>>> Daniel> function, which is just a wrapper around `getenv'. Do you suggest to use
>>> Daniel> `declare-function' and require xdg inside `browse-url-qutebrowser-send'?
>>>
>>> That would work.
>>
>> I would be pragmatic and keep the (getenv "XDG_RUNTIME_DIR"), instead
>> of replacing it by this:
>>
>> (declare-function xdg-runtime-dir "xdg")
>> (require 'xdg)
>
> These are only required because you load a new dependency.
> Further these functions can take care of later eventualities if needed,
> e.g. such as handling when a xdg variable isn't set.
> Also using these functions makes the code easier to read as you can
> follow the code down further to the documentation.
The entire function looks like this:
(defun xdg-runtime-dir ()
(getenv "XDG_RUNTIME_DIR"))
No eventualities are handled there right now, so it does not seem
justified to load xdg.el only for this small wrapper. Note that
`browse-url' contains other platform-specific code, including
xdg-related code, without loading xdg.el - all the code around
`browse-url-xdg-open'.
See also the files files.el, server.el, startup.el and mpc.el, which all
access XDG_* environment variables via `getenv' without requiring
xdg.el. The `getenv' function calls are certainly not less readable than
`xdg-runtime-dir'.
That being said, I would not mind if there was a (require 'xdg) at the
top of the browse-url.el file, if that's considered acceptable, even on
systems which do not conform to xdg. For example xdg.el is also required
unconditionally by eww.el and xdg is a fairly small library. Then using
`xdg-runtime-dir' would be the better solution of course.
Daniel
This bug report was last modified 209 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.