Emacs: make browsing URLs friendlier with Helm
Ori
ori at oribarbut.com
Fri Apr 24 12:46:20 PDT 2020
Hi,
This is a fairly small point and was easy for me to locally address, and
that in itself may be valuable in sharing, but I wondered if it would be
worth putting a change behind a defcustom option, or depending on how this
works with other completion frameworks, changing it altogether?
The "B" shortcut calls notmuch-show-browse-urls, which calls completing-read
with an INITIAL-INPUT of the first URL in the message. On Helm, this shows
a near-blank list (blank unless other URLs have the first one as a
substring). It's a nicer behavior for Helm to start off with no initial
input, as that first URL is highlighted automatically anyway.
Locally I simply redefine the function with a minor change (highlighted)
after loading notmuch:
(defun notmuch-show-browse-urls (&optional kill)
"Offer to browse any URLs in the current message.
With a prefix argument, copy the URL to the kill ring rather than
browsing."
(interactive "P")
(let ((urls (notmuch-show--gather-urls))
(prompt (if kill "Copy URL to kill ring: " "Browse URL: "))
(fn (if kill #'kill-new #'browse-url)))
(if urls
(funcall fn (completing-read prompt urls))
(message "No URLs found."))))
For reference, in notmuch-show.el that highlighted part is:
(completing-read prompt (cdr urls) nil nil (car urls))
As I said, I'm not sure how this works with other popular completion
alternatives like ivy and if the redefined function is better or worse with
those. Perhaps this post is only here to be useful for other Helm users!
Ori
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20200424/9a63cbe5/attachment.htm>
More information about the notmuch
mailing list