GNU bug report logs -
#33043
27.0.50; wishlist: rcirc should allow truncation of visible URLs
Previous Next
Reported by: David Edmondson <dme <at> dme.org>
Date: Mon, 15 Oct 2018 10:05:02 UTC
Severity: wishlist
Tags: patch
Found in version 27.0.50
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 33043 in the body.
You can then email your comments to 33043 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33043
; Package
emacs
.
(Mon, 15 Oct 2018 10:05:03 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
David Edmondson <dme <at> dme.org>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Mon, 15 Oct 2018 10:05:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
With the use of IRC as a gateway to other protocols (Mastodon, Twitter,
...) it is very common to see long URLs in rcirc buffers. It would be
nice if the visible part of these could be truncated to improve their
display.
Proposed patch in followup...
dme.
--
The band is just fantastic, that is really what I think.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33043
; Package
emacs
.
(Mon, 15 Oct 2018 10:07:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 33043 <at> debbugs.gnu.org (full text, mbox):
When applying markup to URLs in the buffer, truncate the visible
portion to `rcirc-url-max-length' characters. By default no truncation
is done.
---
lisp/net/rcirc.el | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index fe9c71a21c..1c0b540563 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -168,6 +168,13 @@ rcirc-fill-prefix
(string :tag "Prefix text"))
:group 'rcirc)
+(defcustom rcirc-url-max-length nil
+ "Maximum number of characters in displayed URLs.
+If nil, no maximum is applied."
+ :type '(choice (const :tag "No maximum" nil)
+ (integer :tag "Number of characters"))
+ :group 'rcirc)
+
(defvar rcirc-ignore-buffer-activity-flag nil
"If non-nil, ignore activity in this buffer.")
(make-variable-buffer-local 'rcirc-ignore-buffer-activity-flag)
@@ -2491,6 +2498,16 @@ rcirc-markup-urls
(end (match-end 0))
(url (match-string-no-properties 0))
(link-text (buffer-substring-no-properties start end)))
+ ;; Truncate the visible part of URLs if required and necessary.
+ (when (and rcirc-url-max-length
+ (> (- end start) rcirc-url-max-length))
+ (let* ((ellipsis "...")
+ (new-end (- (+ start rcirc-url-max-length)
+ (length ellipsis))))
+ (delete-region new-end end)
+ (goto-char new-end)
+ (insert ellipsis)
+ (setq end (point))))
;; Add a button for the URL. Note that we use `make-text-button',
;; rather than `make-button', as text-buttons are much faster in
;; large buffers.
--
2.19.1
Added tag(s) patch.
Request was from
David Edmondson <dme <at> dme.org>
to
control <at> debbugs.gnu.org
.
(Tue, 16 Oct 2018 10:05:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33043
; Package
emacs
.
(Wed, 17 Oct 2018 22:28:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 33043 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Thanks for working on this David, I like the idea.
David Edmondson <dme <at> dme.org> writes:
> @@ -2491,6 +2498,16 @@ rcirc-markup-urls
> (end (match-end 0))
> (url (match-string-no-properties 0))
> (link-text (buffer-substring-no-properties start end)))
> + ;; Truncate the visible part of URLs if required and necessary.
> + (when (and rcirc-url-max-length
> + (> (- end start) rcirc-url-max-length))
> + (let* ((ellipsis "...")
> + (new-end (- (+ start rcirc-url-max-length)
> + (length ellipsis))))
> + (delete-region new-end end)
> + (goto-char new-end)
> + (insert ellipsis)
> + (setq end (point))))
> ;; Add a button for the URL. Note that we use `make-text-button',
> ;; rather than `make-button', as text-buttons are much faster in
> ;; large buffers.
Couldn't we reuse url-truncate-url-for-viewing, which tries to be smart
about where it places the ellipsis, for this? I think the existing code
can also be cleaned up a little:
[rcirc.diff (text/x-diff, inline)]
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index fe9c71a21c..de28cdb054 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -2485,24 +2485,25 @@ rcirc-markup-my-nick
(rcirc-record-activity (current-buffer) 'nick)))))
(defun rcirc-markup-urls (_sender _response)
- (while (and rcirc-url-regexp ;; nil means disable URL catching
+ (while (and rcirc-url-regexp ; nil means disable URL catching.
(re-search-forward rcirc-url-regexp nil t))
- (let* ((start (match-beginning 0))
+ (let* ((beg (match-beginning 0))
(end (match-end 0))
- (url (match-string-no-properties 0))
- (link-text (buffer-substring-no-properties start end)))
- ;; Add a button for the URL. Note that we use `make-text-button',
- ;; rather than `make-button', as text-buttons are much faster in
- ;; large buffers.
- (make-text-button start end
- 'face 'rcirc-url
- 'follow-link t
- 'rcirc-url url
- 'action (lambda (button)
- (browse-url (button-get button 'rcirc-url))))
- ;; record the url if it is not already the latest stored url
- (when (not (string= link-text (caar rcirc-urls)))
- (push (cons link-text start) rcirc-urls)))))
+ (url (buffer-substring-no-properties beg end)))
+ (delete-region beg end)
+ ;; Add a button for the URL. Note that we use
+ ;; `insert-text-button', rather than `insert-button', as text
+ ;; property buttons are much faster in large buffers.
+ (insert-text-button
+ (url-truncate-url-for-viewing url rcirc-url-max-length)
+ 'face 'rcirc-url
+ 'follow-link t
+ 'rcirc-url url
+ 'action (lambda (button)
+ (browse-url (button-get button 'rcirc-url))))
+ ;; Record the URL if it is not already the latest stored URL.
+ (unless (string= url (caar rcirc-urls))
+ (push (cons url beg) rcirc-urls)))))
(defun rcirc-markup-keywords (sender response)
(when (and (string= response "PRIVMSG")
[Message part 3 (text/plain, inline)]
WDYT?
--
Basil
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33043
; Package
emacs
.
(Thu, 18 Oct 2018 09:40:01 GMT)
Full text and
rfc822 format available.
Message #16 received at 33043 <at> debbugs.gnu.org (full text, mbox):
On Wednesday, 2018-10-17 at 23:27:45 +01, Basil L. Contovounesios wrote:
> Couldn't we reuse url-truncate-url-for-viewing, which tries to be smart
> about where it places the ellipsis, for this? I think the existing code
> can also be cleaned up a little:
I didn't know about url-truncate-url-for-viewing, no other reason.
I'd be happy with your change, but note that it will always truncate
URLs that are wider than the current frame - there is no way to have no
truncation take place.
If a user is most familiar with something like ffap to open URLs then
this is unfortunate - ffap doesn't see the full URL in the buffer.
> diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
> index fe9c71a21c..de28cdb054 100644
> --- a/lisp/net/rcirc.el
> +++ b/lisp/net/rcirc.el
> @@ -2485,24 +2485,25 @@ rcirc-markup-my-nick
> (rcirc-record-activity (current-buffer) 'nick)))))
>
> (defun rcirc-markup-urls (_sender _response)
> - (while (and rcirc-url-regexp ;; nil means disable URL catching
> + (while (and rcirc-url-regexp ; nil means disable URL catching.
> (re-search-forward rcirc-url-regexp nil t))
> - (let* ((start (match-beginning 0))
> + (let* ((beg (match-beginning 0))
> (end (match-end 0))
> - (url (match-string-no-properties 0))
> - (link-text (buffer-substring-no-properties start end)))
> - ;; Add a button for the URL. Note that we use `make-text-button',
> - ;; rather than `make-button', as text-buttons are much faster in
> - ;; large buffers.
> - (make-text-button start end
> - 'face 'rcirc-url
> - 'follow-link t
> - 'rcirc-url url
> - 'action (lambda (button)
> - (browse-url (button-get button 'rcirc-url))))
> - ;; record the url if it is not already the latest stored url
> - (when (not (string= link-text (caar rcirc-urls)))
> - (push (cons link-text start) rcirc-urls)))))
> + (url (buffer-substring-no-properties beg end)))
> + (delete-region beg end)
> + ;; Add a button for the URL. Note that we use
> + ;; `insert-text-button', rather than `insert-button', as text
> + ;; property buttons are much faster in large buffers.
> + (insert-text-button
> + (url-truncate-url-for-viewing url rcirc-url-max-length)
> + 'face 'rcirc-url
> + 'follow-link t
> + 'rcirc-url url
> + 'action (lambda (button)
> + (browse-url (button-get button 'rcirc-url))))
> + ;; Record the URL if it is not already the latest stored URL.
> + (unless (string= url (caar rcirc-urls))
> + (push (cons url beg) rcirc-urls)))))
>
> (defun rcirc-markup-keywords (sender response)
> (when (and (string= response "PRIVMSG")
>
> WDYT?
>
> --
> Basil
dme.
--
I've still got sand in my shoes.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33043
; Package
emacs
.
(Thu, 18 Oct 2018 10:39:01 GMT)
Full text and
rfc822 format available.
Message #19 received at 33043 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
David Edmondson <dme <at> dme.org> writes:
> On Wednesday, 2018-10-17 at 23:27:45 +01, Basil L. Contovounesios wrote:
>
>> Couldn't we reuse url-truncate-url-for-viewing, which tries to be smart
>> about where it places the ellipsis, for this? I think the existing code
>> can also be cleaned up a little:
>
> I didn't know about url-truncate-url-for-viewing, no other reason.
>
> I'd be happy with your change, but note that it will always truncate
> URLs that are wider than the current frame - there is no way to have no
> truncation take place.
>
> If a user is most familiar with something like ffap to open URLs then
> this is unfortunate - ffap doesn't see the full URL in the buffer.
Sorry, that was an oversight. Here's how the last patch can be patched
to support the default of no truncation:
[rcirc.diff (text/x-diff, inline)]
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index de28cdb054..31f0baddc0 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -2495,7 +2495,9 @@ rcirc-markup-urls
;; `insert-text-button', rather than `insert-button', as text
;; property buttons are much faster in large buffers.
(insert-text-button
- (url-truncate-url-for-viewing url rcirc-url-max-length)
+ (if rcirc-url-max-length
+ (url-truncate-url-for-viewing url rcirc-url-max-length)
+ url)
'face 'rcirc-url
'follow-link t
'rcirc-url url
[Message part 3 (text/plain, inline)]
If you prefer to avoid deletion and insertion when rcirc-url-max-length
is nil, you can also write the following:
[rcirc-alt.diff (text/x-diff, inline)]
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index fe9c71a21c..4d62b382a6 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -2485,24 +2485,27 @@ rcirc-markup-my-nick
(rcirc-record-activity (current-buffer) 'nick)))))
(defun rcirc-markup-urls (_sender _response)
- (while (and rcirc-url-regexp ;; nil means disable URL catching
+ (while (and rcirc-url-regexp ; nil means disable URL catching.
(re-search-forward rcirc-url-regexp nil t))
- (let* ((start (match-beginning 0))
+ (let* ((beg (match-beginning 0))
(end (match-end 0))
- (url (match-string-no-properties 0))
- (link-text (buffer-substring-no-properties start end)))
+ (url (buffer-substring-no-properties beg end)))
+ (when rcirc-url-max-length
+ (replace-match (url-truncate-url-for-viewing url rcirc-url-max-length)
+ t t)
+ (setq end (point)))
;; Add a button for the URL. Note that we use `make-text-button',
;; rather than `make-button', as text-buttons are much faster in
;; large buffers.
- (make-text-button start end
+ (make-text-button beg end
'face 'rcirc-url
'follow-link t
'rcirc-url url
'action (lambda (button)
(browse-url (button-get button 'rcirc-url))))
- ;; record the url if it is not already the latest stored url
- (when (not (string= link-text (caar rcirc-urls)))
- (push (cons link-text start) rcirc-urls)))))
+ ;; Record the URL if it is not already the latest stored URL.
+ (unless (string= url (caar rcirc-urls))
+ (push (cons url beg) rcirc-urls)))))
(defun rcirc-markup-keywords (sender response)
(when (and (string= response "PRIVMSG")
[Message part 5 (text/plain, inline)]
Thanks,
--
Basil
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33043
; Package
emacs
.
(Thu, 18 Oct 2018 10:51:02 GMT)
Full text and
rfc822 format available.
Message #22 received at 33043 <at> debbugs.gnu.org (full text, mbox):
On Thursday, 2018-10-18 at 11:38:04 +0100, Basil L. Contovounesios wrote:
> David Edmondson <dme <at> dme.org> writes:
>
>> On Wednesday, 2018-10-17 at 23:27:45 +01, Basil L. Contovounesios wrote:
>>
>>> Couldn't we reuse url-truncate-url-for-viewing, which tries to be smart
>>> about where it places the ellipsis, for this? I think the existing code
>>> can also be cleaned up a little:
>>
>> I didn't know about url-truncate-url-for-viewing, no other reason.
>>
>> I'd be happy with your change, but note that it will always truncate
>> URLs that are wider than the current frame - there is no way to have no
>> truncation take place.
>>
>> If a user is most familiar with something like ffap to open URLs then
>> this is unfortunate - ffap doesn't see the full URL in the buffer.
>
> Sorry, that was an oversight. Here's how the last patch can be patched
> to support the default of no truncation:
Either of your versions looks fine to me, thanks for looking into it.
> diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
> index de28cdb054..31f0baddc0 100644
> --- a/lisp/net/rcirc.el
> +++ b/lisp/net/rcirc.el
> @@ -2495,7 +2495,9 @@ rcirc-markup-urls
> ;; `insert-text-button', rather than `insert-button', as text
> ;; property buttons are much faster in large buffers.
> (insert-text-button
> - (url-truncate-url-for-viewing url rcirc-url-max-length)
> + (if rcirc-url-max-length
> + (url-truncate-url-for-viewing url rcirc-url-max-length)
> + url)
> 'face 'rcirc-url
> 'follow-link t
> 'rcirc-url url
>
> If you prefer to avoid deletion and insertion when rcirc-url-max-length
> is nil, you can also write the following:
>
> diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
> index fe9c71a21c..4d62b382a6 100644
> --- a/lisp/net/rcirc.el
> +++ b/lisp/net/rcirc.el
> @@ -2485,24 +2485,27 @@ rcirc-markup-my-nick
> (rcirc-record-activity (current-buffer) 'nick)))))
>
> (defun rcirc-markup-urls (_sender _response)
> - (while (and rcirc-url-regexp ;; nil means disable URL catching
> + (while (and rcirc-url-regexp ; nil means disable URL catching.
> (re-search-forward rcirc-url-regexp nil t))
> - (let* ((start (match-beginning 0))
> + (let* ((beg (match-beginning 0))
> (end (match-end 0))
> - (url (match-string-no-properties 0))
> - (link-text (buffer-substring-no-properties start end)))
> + (url (buffer-substring-no-properties beg end)))
> + (when rcirc-url-max-length
> + (replace-match (url-truncate-url-for-viewing url rcirc-url-max-length)
> + t t)
> + (setq end (point)))
> ;; Add a button for the URL. Note that we use `make-text-button',
> ;; rather than `make-button', as text-buttons are much faster in
> ;; large buffers.
> - (make-text-button start end
> + (make-text-button beg end
> 'face 'rcirc-url
> 'follow-link t
> 'rcirc-url url
> 'action (lambda (button)
> (browse-url (button-get button 'rcirc-url))))
> - ;; record the url if it is not already the latest stored url
> - (when (not (string= link-text (caar rcirc-urls)))
> - (push (cons link-text start) rcirc-urls)))))
> + ;; Record the URL if it is not already the latest stored URL.
> + (unless (string= url (caar rcirc-urls))
> + (push (cons url beg) rcirc-urls)))))
>
> (defun rcirc-markup-keywords (sender response)
> (when (and (string= response "PRIVMSG")
>
> Thanks,
>
> --
> Basil
dme.
--
Does everyone stare the way I do?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33043
; Package
emacs
.
(Sat, 27 Oct 2018 08:55:02 GMT)
Full text and
rfc822 format available.
Message #25 received at 33043 <at> debbugs.gnu.org (full text, mbox):
> From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
> Date: Thu, 18 Oct 2018 11:38:04 +0100
> Cc: 33043 <at> debbugs.gnu.org
>
> > I didn't know about url-truncate-url-for-viewing, no other reason.
> >
> > I'd be happy with your change, but note that it will always truncate
> > URLs that are wider than the current frame - there is no way to have no
> > truncation take place.
> >
> > If a user is most familiar with something like ffap to open URLs then
> > this is unfortunate - ffap doesn't see the full URL in the buffer.
>
> Sorry, that was an oversight. Here's how the last patch can be patched
> to support the default of no truncation:
If you two are in agreement wrt what should be installed, I'd need a
full changeset from Basil to push.
Thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33043
; Package
emacs
.
(Sun, 28 Oct 2018 03:15:01 GMT)
Full text and
rfc822 format available.
Message #28 received at 33043 <at> debbugs.gnu.org (full text, mbox):
[0001-Add-URL-truncation-support-to-rcirc-bug-33043.patch (text/x-diff, attachment)]
[0002-Reuse-URL-truncation-function-in-rcirc-bug-33043.patch (text/x-diff, attachment)]
[Message part 3 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
>> Date: Thu, 18 Oct 2018 11:38:04 +0100
>> Cc: 33043 <at> debbugs.gnu.org
>>
>> > I didn't know about url-truncate-url-for-viewing, no other reason.
>> >
>> > I'd be happy with your change, but note that it will always truncate
>> > URLs that are wider than the current frame - there is no way to have no
>> > truncation take place.
>> >
>> > If a user is most familiar with something like ffap to open URLs then
>> > this is unfortunate - ffap doesn't see the full URL in the buffer.
>>
>> Sorry, that was an oversight. Here's how the last patch can be patched
>> to support the default of no truncation:
>
> If you two are in agreement wrt what should be installed, I'd need a
> full changeset from Basil to push.
I attach two patches. The first comprises David's original patch, but
with an added :version tag and reworded commit message. The second
switches to reusing url-truncate-url-for-viewing. WDYT?
Thanks,
--
Basil
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33043
; Package
emacs
.
(Mon, 29 Oct 2018 16:02:02 GMT)
Full text and
rfc822 format available.
Message #31 received at 33043 <at> debbugs.gnu.org (full text, mbox):
On Sunday, 2018-10-28 at 03:14:39 +00, Basil L. Contovounesios wrote:
> I attach two patches. The first comprises David's original patch, but
> with an added :version tag and reworded commit message. The second
> switches to reusing url-truncate-url-for-viewing. WDYT?
It would be simpler just to smash them together. I don't care about the
credit or anything.
dme.
--
Hello? Is anybody home? Well, you don't know me, but I know you.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33043
; Package
emacs
.
(Mon, 29 Oct 2018 18:29:02 GMT)
Full text and
rfc822 format available.
Message #34 received at 33043 <at> debbugs.gnu.org (full text, mbox):
[0001-Add-URL-truncation-support-to-rcirc-bug-33043.patch (text/x-diff, attachment)]
[Message part 2 (text/plain, inline)]
David Edmondson <dme <at> dme.org> writes:
> On Sunday, 2018-10-28 at 03:14:39 +00, Basil L. Contovounesios wrote:
>
>> I attach two patches. The first comprises David's original patch, but
>> with an added :version tag and reworded commit message. The second
>> switches to reusing url-truncate-url-for-viewing. WDYT?
>
> It would be simpler just to smash them together. I don't care about the
> credit or anything.
I don't either. How's the attached patch, which additionally announces
the new user option in etc/NEWS?
Thanks,
--
Basil
Reply sent
to
Eli Zaretskii <eliz <at> gnu.org>
:
You have taken responsibility.
(Sat, 03 Nov 2018 09:12:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
David Edmondson <dme <at> dme.org>
:
bug acknowledged by developer.
(Sat, 03 Nov 2018 09:12:04 GMT)
Full text and
rfc822 format available.
Message #39 received at 33043-done <at> debbugs.gnu.org (full text, mbox):
> From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
> Cc: Eli Zaretskii <eliz <at> gnu.org>, 33043 <at> debbugs.gnu.org
> Date: Mon, 29 Oct 2018 18:27:54 +0000
>
> David Edmondson <dme <at> dme.org> writes:
>
> > On Sunday, 2018-10-28 at 03:14:39 +00, Basil L. Contovounesios wrote:
> >
> >> I attach two patches. The first comprises David's original patch, but
> >> with an added :version tag and reworded commit message. The second
> >> switches to reusing url-truncate-url-for-viewing. WDYT?
> >
> > It would be simpler just to smash them together. I don't care about the
> > credit or anything.
>
> I don't either. How's the attached patch, which additionally announces
> the new user option in etc/NEWS?
Thanks, pushed to the master branch.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sat, 01 Dec 2018 12:24:06 GMT)
Full text and
rfc822 format available.
This bug report was last modified 6 years and 196 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.