Discussion:
How to shorten urls displayed in text version of mail in Gnus
(too old to reply)
Narendra Joshi
2020-05-22 20:59:15 UTC
Permalink
Hi,

I have configured Gnus to try to display mail with the `text/plain`
version if available.

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?


Best,
--
Narendra Joshi
Emanuel Berg
2020-05-22 22:40:46 UTC
Permalink
Post by Narendra Joshi
I have configured Gnus to try to display mail with
the `text/plain` version if available.
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?
Don't know but search here:

https://www.gnu.org/software/emacs/manual/html_node/gnus/Article-Washing.html

https://www.gnu.org/software/emacs/manual/html_node/gnus/Customizing-Articles.html

https://www.gnu.org/software/emacs/manual/html_node/gnus/Article-Buttons.html
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
Colin Baxter
2020-05-23 11:13:35 UTC
Permalink
Hi, I have configured Gnus to try to display mail with the
`text/plain` version if available.
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?
There's https://www.emacswiki.org/emacs/TinyUrl.
--
Colin Baxter
URL: http://www.Colin-Baxter.com
Emanuel Berg
2020-05-23 11:31:10 UTC
Permalink
Post by Colin Baxter
Hi, I have configured Gnus to try to display mail
with the `text/plain` version if available.
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?
There's https://www.emacswiki.org/emacs/TinyUrl.
And in MELPA:

isgd 20150414.936 available melpa
Shorten URLs using the isgd.com shortener service
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
Narendra Joshi
2020-05-23 11:35:21 UTC
Permalink
I am looking for shortening the url using an external service. I would like
the text displayed for the url to not take a lot of space. I have gone
through the washing documentation but nothing seems to cover my use case.

On Sat, 23 May 2020, 13:31 Emanuel Berg via info-gnus-english, <
Post by Emanuel Berg
Post by Colin Baxter
Hi, I have configured Gnus to try to display mail
with the `text/plain` version if available.
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?
There's https://www.emacswiki.org/emacs/TinyUrl.
isgd 20150414.936 available melpa
Shorten URLs using the isgd.com shortener service
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
_______________________________________________
info-gnus-english mailing list
https://lists.gnu.org/mailman/listinfo/info-gnus-english
Emanuel Berg
2020-05-23 11:50:26 UTC
Permalink
Post by Narendra Joshi
I am looking for shortening the url using an
external service. I would like the text displayed
for the url to not take a lot of space. I have gone
through the washing documentation but nothing seems
to cover my use case.
Check out the Emacs-wiki suggestion and the MELPA
pack :)
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
Christian Barthel
2020-05-23 17:39:38 UTC
Permalink
Post by Narendra Joshi
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 <***@online.de>
Loading...