From: Christian Barthel <bch@online.de>
To: info-gnus-english@gnu.org
Cc: Narendra Joshi <narendraj9@gmail.com>
Subject: Re: How to shorten urls displayed in text version of mail in Gnus
Date: Sat, 23 May 2020 19:39:38 +0200 [thread overview]
Message-ID: <875zcmr1np.fsf@barthel.ch> (raw)
In-Reply-To: <mailman.67.1590181841.2541.info-gnus-english@gnu.org> (Narendra Joshi's message of "Fri, 22 May 2020 22:59:15 +0200")
Narendra Joshi <narendraj9@gmail.com> writes:
> A lot of mail happens to have very long URLs that I would like to
> shorten while displaying them in the Article buffer. It would be great
> if there is something in Gnus that does this already. Is there any
> function to wash the article buffer and shorten the text displayed for
> URL present in it?
Here are two functions that replace long URLs with the string
"URL" and make them clickable (<ENTER>):
(defun gnus-buttonize-and-shorten ()
(interactive)
(progn
(goto-char (point-min))
(while (re-search-forward
"\\(https*://[-~_a-zA-Z0-9][-~_\\.a-zA-Z0-9/]*\\)"
(point-max) t)
(let* ((start (match-beginning 0))
(end (match-end 0)))
(message "%d %d" start end)
(goto-char start)
(let ((thisurl (thing-at-point 'url)))
(kill-region start end)
(insert-text-button "URL"
'url thisurl
'action (lambda (btn)
(browse-url (button-get btn 'url)))
))
(goto-char (+ start 1))))))
(defun gnus-wash-long-urls ()
(interactive "")
(gnus-summary-select-article)
(gnus-eval-in-buffer-window gnus-article-buffer
(let ((inhibit-read-only t))
(save-excursion
(save-restriction
(gnus-buttonize-and-shorten))))
(gnus-treat-article nil)))
A better approach would be to use the button mechanism of Gnus
and set the text to something different. But I did not find [1]
any option to set the button text.
[1] https://www.gnu.org/software/emacs/manual/html_node/gnus/Article-Buttons.html
--
Christian Barthel <bch@online.de>
_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
https://lists.gnu.org/mailman/listinfo/info-gnus-english
prev parent reply other threads:[~2020-05-23 17:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-22 20:59 Narendra Joshi
2020-05-22 22:40 ` Emanuel Berg via info-gnus-english
2020-05-23 11:13 ` Colin Baxter
2020-05-23 11:31 ` Emanuel Berg via info-gnus-english
2020-05-23 11:35 ` Narendra Joshi
2020-05-23 11:50 ` Emanuel Berg via info-gnus-english
[not found] ` <mailman.67.1590181841.2541.info-gnus-english@gnu.org>
2020-05-23 17:39 ` Christian Barthel [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=875zcmr1np.fsf@barthel.ch \
--to=bch@online.de \
--cc=info-gnus-english@gnu.org \
--cc=narendraj9@gmail.com \
/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.
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 NNTP newsgroup(s).