From: David Edmondson <dme@dme.org>
To: 33043@debbugs.gnu.org
Subject: bug#33043: [PATCH v1 1/1] Support for the truncation of displayed URLs
Date: Mon, 15 Oct 2018 11:06:26 +0100 [thread overview]
Message-ID: <20181015100626.2344-1-dme@dme.org> (raw)
In-Reply-To: <cund0sbwmo8.fsf@dme.org>
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
next prev parent reply other threads:[~2018-10-15 10:06 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 ` David Edmondson [this message]
2018-10-17 22:27 ` bug#33043: [PATCH v1 1/1] Support for the truncation of displayed URLs Basil L. Contovounesios
2018-10-18 9:39 ` David Edmondson
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181015100626.2344-1-dme@dme.org \
--to=dme@dme.org \
--cc=33043@debbugs.gnu.org \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).