[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#74781: [PATCH] Add `browse-url-qutebrowser'
From: |
Daniel Mendler |
Subject: |
bug#74781: [PATCH] Add `browse-url-qutebrowser' |
Date: |
Wed, 11 Dec 2024 15:38:13 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Björn Bidar <bjorn.bidar@thaodan.de> writes:
> Daniel Mendler via "Bug reports for GNU Emacs, the Swiss army knife of
> text editors" <bug-gnu-emacs@gnu.org> writes:
>
>> Robert Pluim <rpluim@gmail.com> writes:
>>
>>>>>>>> On Wed, 11 Dec 2024 10:07:08 +0100, Daniel Mendler
>>>>>>>> <mail@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
bug#74781: [PATCH] Add `browse-url-qutebrowser', Eli Zaretskii, 2024/12/11
bug#74781: Status: [PATCH] Add `browse-url-qutebrowser', Daniel Mendler, 2024/12/14