From: David Edmondson <dme@dme.org>
To: "Basil L. Contovounesios" <contovob@tcd.ie>
Cc: 33043@debbugs.gnu.org
Subject: bug#33043: [PATCH v1 1/1] Support for the truncation of displayed URLs
Date: Thu, 18 Oct 2018 10:39:08 +0100 [thread overview]
Message-ID: <cuny3avvbk3.fsf@dme.org> (raw)
In-Reply-To: <87r2go2opq.fsf@tcd.ie>
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.
next prev parent reply other threads:[~2018-10-18 9:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-15 10:04 bug#33043: 27.0.50; wishlist: rcirc should allow truncation of visible URLs David Edmondson
2018-10-15 10:06 ` bug#33043: [PATCH v1 1/1] Support for the truncation of displayed URLs David Edmondson
2018-10-17 22:27 ` Basil L. Contovounesios
2018-10-18 9:39 ` David Edmondson [this message]
2018-10-18 10:38 ` Basil L. Contovounesios
2018-10-18 10:50 ` David Edmondson
2018-10-27 8:54 ` Eli Zaretskii
2018-10-28 3:14 ` Basil L. Contovounesios
2018-10-29 16:01 ` David Edmondson
2018-10-29 18:27 ` Basil L. Contovounesios
2018-11-03 9:11 ` Eli Zaretskii
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=cuny3avvbk3.fsf@dme.org \
--to=dme@dme.org \
--cc=33043@debbugs.gnu.org \
--cc=contovob@tcd.ie \
/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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.