From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 15 06:04:57 2018 Received: (at submit) by debbugs.gnu.org; 15 Oct 2018 10:04:57 +0000 Received: from localhost ([127.0.0.1]:49816 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gBzk9-0007HF-6S for submit@debbugs.gnu.org; Mon, 15 Oct 2018 06:04:57 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57068) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gBzk7-0007H1-FR for submit@debbugs.gnu.org; Mon, 15 Oct 2018 06:04:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gBzk0-00075g-BU for submit@debbugs.gnu.org; Mon, 15 Oct 2018 06:04:50 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,UNPARSEABLE_RELAY autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:42526) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gBzk0-00075W-72 for submit@debbugs.gnu.org; Mon, 15 Oct 2018 06:04:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38432) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gBzjz-0004LL-E0 for bug-gnu-emacs@gnu.org; Mon, 15 Oct 2018 06:04:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gBzjw-00072b-A5 for bug-gnu-emacs@gnu.org; Mon, 15 Oct 2018 06:04:47 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:51243) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gBzjw-00071b-2E for bug-gnu-emacs@gnu.org; Mon, 15 Oct 2018 06:04:44 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 143-v6so18149276wmf.1 for ; Mon, 15 Oct 2018 03:04:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dme-org.20150623.gappssmtp.com; s=20150623; h=to:subject:from:date:message-id:mime-version; bh=Mw4zmuEAZxRK5qTksyjVkPp3W+XPBDpXvAYGdz6qAIA=; b=NFfdig+rL/fS/w7WsC+Otjqtkigs96pJKQmNzwcrgdz7guFqryzYvk1SBW6RjQLTN/ /lShW+fFNQakQfZBx89zaebMROaHv71yx5uANjn1iEb/34pLiomCA8EAt5Hb/ukagYS6 n2Yc5UaLEFqH0MaMfjm7QFP6t6OYOODos6pdsEdk1ASPa9VnnaOrJ35JbVak8ZpL0hps n9dN+hG2UW3EIXZM7Is3/Q6daDYYWUq/Htma8d2ZvCsp8n7XsXB3wj4HGKUl4eCANQfd LNG8ChF19gsxFYDVQk1j/PwG3VJFvaXvuq/l4F9kLMT1a08tchwjX0j06sxlaei0tQhH GGdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:subject:from:date:message-id:mime-version; bh=Mw4zmuEAZxRK5qTksyjVkPp3W+XPBDpXvAYGdz6qAIA=; b=fHuun7FpKuJbNe5x720Q3EYT3ja8+fyBiN7wfMwpv3CLxvTMjDcXBu34HYvxjTwDa7 OcvuJtVKC0+//ywDcxGOgp/E1dppFD+9dXHZvAa0MmYvxhaCX05Tj4rWBBDsJSe2TfsC t/evEANtbBu064A82ORNBBSGwsvZUdI/jp2IjQ6X/nBDQFNPBe7VLCoPYgGKiVf8ewhQ IA9y6bxEgK4l99WdvULu3rOpCHeZgeVNk9vIAt8Z3EGJJd2L0CvhVa0UG3PFGVmJSDEW SzHuF4JruEa/3iZef3XXNW4V/wUtJKhiQMZk7JOgZLD9ClnBojGTHF9Pqpg2oXgIWgKf KoMA== X-Gm-Message-State: ABuFfogaWa5c5Y7UasUbzZEV0x0XZpHobbrHPLR84rXnMt0uc2YGM/ds ZGae1KS4/emREMpYG74GYaQbkF9+wUw= X-Google-Smtp-Source: ACcGV608l7MeTt23rrKslM9gK+ygrviA+6xXlDcN2yzZ692Hw/IN++YZ+vmtJmiNBQA/I+0Ev4HvuA== X-Received: by 2002:a1c:e12:: with SMTP id 18-v6mr12125025wmo.30.1539597881961; Mon, 15 Oct 2018 03:04:41 -0700 (PDT) Received: from disaster-area.hh.sledj.net (disaster-area.hh.sledj.net. [81.149.164.25]) by smtp.gmail.com with ESMTPSA id s10-v6sm7318042wmf.15.2018.10.15.03.04.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Oct 2018 03:04:41 -0700 (PDT) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 4a977456; Mon, 15 Oct 2018 10:04:39 +0000 (UTC) To: bug-gnu-emacs@gnu.org Subject: 27.0.50; wishlist: rcirc should allow truncation of visible URLs X-HGTTG: gag-halfrunt From: David Edmondson Date: Mon, 15 Oct 2018 11:04:39 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.3 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.3 (-----) 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. From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 15 06:06:36 2018 Received: (at 33043) by debbugs.gnu.org; 15 Oct 2018 10:06:36 +0000 Received: from localhost ([127.0.0.1]:49822 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gBzlk-0007Kh-K5 for submit@debbugs.gnu.org; Mon, 15 Oct 2018 06:06:36 -0400 Received: from mail-wm1-f49.google.com ([209.85.128.49]:54239) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gBzli-0007KR-R3 for 33043@debbugs.gnu.org; Mon, 15 Oct 2018 06:06:35 -0400 Received: by mail-wm1-f49.google.com with SMTP id y11-v6so18221606wma.3 for <33043@debbugs.gnu.org>; Mon, 15 Oct 2018 03:06:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dme-org.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=wBxxlUQ516J7xbLXO811C33JEs5ctkohN5srJZiRMJ4=; b=xuG83aPHI7/IgTTOj3HlyUu5ae9xrVlfd2tZyo4Woa+2M+qEIDWTVPyIGedd5JTDeC hfHLg2XmgYRp/WtwwZEbHU62gCtwSPsQ/2ADXnL2ON8PT5YXUSu0yum7qoyQ1hFAeYTH c3wNSeK0kJCJgrPYycUareYbCrETpt/d1aQ0mB8P/e7k5SBUIMmRiHZB0QdyzRcMeZ/o s1lCSNUX4tImecTISwbMUG5dS9a6MWEPIadnM18DOzDCPbkdKqQ7LZMP+zJRP5cdxaCJ 8C4Uuda1Qesv08h5f/adCZ9DwtlOlmpWktDMsHMXKD5+Eie1ArMD0a1Y8jeLHYTXAfDm y43w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=wBxxlUQ516J7xbLXO811C33JEs5ctkohN5srJZiRMJ4=; b=Y1EXFiuAqzfDi8Dav2VEqM0hyhBacp0XILeoZ18m2JtyGEsmS8mTX2Ez4s1a2gzaXI 5IA2O8WOR+6TNpotVKg1wci1puaLoLbr6wa4zPJ6Ouh5PgGtQhipB/u0I9UC4+f+jtF2 tzUkVXbdHYas3q+0yOQnMmftyGRer2L/NokVlwmauzmEGcK2kmEBMffOH6S2o1Yf6vXo vNZHTVMS3T9MBrDfgntrUa7WOa4xY4UetI3i01ccTQSWFTaeazMaZuhZy7oBZnrPL4Qw D+mn+0GkJZoAgXDmtOIzaNrvxcdy7EYM7p46JU0VvQrmoY++bGo5+YKIUpdjNOdZCmBW hl+w== X-Gm-Message-State: ABuFfohBM+q+RiypYb/esLYUOyvv/ux1V4VWAL7S6EBxujXG7uyovd8E QGg7hrFtj6BA1OHGdFGKkWKWgXbjW2M= X-Google-Smtp-Source: ACcGV62F9isT1mzUrU0RxL/gXeKYW3cvS0xMqS+6/iwoH9utFTTbVJbrtt9s8liOnI0cT+X3u6aWSA== X-Received: by 2002:a1c:1812:: with SMTP id 18-v6mr12950917wmy.34.1539597988724; Mon, 15 Oct 2018 03:06:28 -0700 (PDT) Received: from disaster-area.hh.sledj.net (disaster-area.hh.sledj.net. [81.149.164.25]) by smtp.gmail.com with ESMTPSA id a1-v6sm8024978wrt.79.2018.10.15.03.06.27 for <33043@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Oct 2018 03:06:27 -0700 (PDT) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 1badbadf for <33043@debbugs.gnu.org>; Mon, 15 Oct 2018 10:06:27 +0000 (UTC) From: David Edmondson To: 33043@debbugs.gnu.org Subject: [PATCH v1 1/1] Support for the truncation of displayed URLs Date: Mon, 15 Oct 2018 11:06:26 +0100 Message-Id: <20181015100626.2344-1-dme@dme.org> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: 33043 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.3 (/) 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 From debbugs-submit-bounces@debbugs.gnu.org Tue Oct 16 06:04:08 2018 Received: (at control) by debbugs.gnu.org; 16 Oct 2018 10:04:08 +0000 Received: from localhost ([127.0.0.1]:51853 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gCMCu-000445-8p for submit@debbugs.gnu.org; Tue, 16 Oct 2018 06:04:08 -0400 Received: from mail-wm1-f44.google.com ([209.85.128.44]:40947) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gCMCs-00043b-6M for control@debbugs.gnu.org; Tue, 16 Oct 2018 06:04:06 -0400 Received: by mail-wm1-f44.google.com with SMTP id z204-v6so22666011wmc.5 for ; Tue, 16 Oct 2018 03:04:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dme-org.20150623.gappssmtp.com; s=20150623; h=date:to:from:subject:message-id; bh=mubakgiv78AfNh/I1K3NHzXlXDZIU3KYbgMaXlvzbmQ=; b=S9ZQF52PAOQ+nzohZDoF4FJiBIube/0IOkIQvqd9oYl3m9E/+LhaES8IQaaL0A/bcx ksEp2v4qLKHEx3wNw0+7ysHB9SElrk7mypIHQMj8Q30eCbe2Bb4xUp09k0THg4nmsqyv j8ps7g5p6jDBY7rBD9u9kb4ofVOrqyPkRbbwgqk1GCEZ2xCt5FuQJgKYF6dvvlrLb+ck ybPZdOCGeMNutXnoNA7UCjPE7no2byurVnnfynAJksH4VAI3BgGVExZR5p9ed3gH2Niw 48tKn2cPhBReOFuS9RIHssJZdm+ughWBOYoqn898IXP4AhO4gs6pCBkAoymaJFO6SDlb 3olg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:to:from:subject:message-id; bh=mubakgiv78AfNh/I1K3NHzXlXDZIU3KYbgMaXlvzbmQ=; b=fBCHcaca/92JjB+hEfP1tlpS/W/2HD59Fgs0jjZ67OpyGxIHCgGP/e6T9o21M5PSZK 3mV8ybq7xxx6z45+yby2E0bTogJ3DXcecAlnbqOSwkr/30POOPUwzQrxG2A2/9hZeY8m hx4bgvKzZj5YRWzIZLnCcSf3Ej9CimXJaQ8YQ+A3qIL2OhSdQBygTHI7sC0zbV46b2lG zGY6vpZGZoZn6wZ8zumuCq7mNqsarE8yaB0/gF1F5tDvMKwRRoSC4uHg35Swtdl0nuKX hSgeSwAmPCDWWlGhAZjj9Fbp5Ym+0kAdXgYq2JXrksz00ac4X4DarhC5NvOZ1rOFtn33 UgyQ== X-Gm-Message-State: ABuFfojX+zsaf4bOsQ39IYGIsekUNxMdOMB4ntFFWBjZRQsGUj9D/bpU lnF96lF2kazhSRpiFwGm4kLsnVPOWUw= X-Google-Smtp-Source: ACcGV63QK/BD8kiIbxBKS/SxMX7Bc6sbKzGWqROaAyOUwO7cvyGBrV6u5Z1LPFohFv9dl+73B6QXRw== X-Received: by 2002:a1c:6655:: with SMTP id a82-v6mr16920442wmc.10.1539684239777; Tue, 16 Oct 2018 03:03:59 -0700 (PDT) Received: from disaster-area.hh.sledj.net (disaster-area.hh.sledj.net. [81.149.164.25]) by smtp.gmail.com with ESMTPSA id 195-v6sm12097887wmx.21.2018.10.16.03.03.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Oct 2018 03:03:58 -0700 (PDT) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 84b3fe4a for ; Tue, 16 Oct 2018 10:03:57 +0000 (UTC) Date: Tue, 16 Oct 2018 11:03:57 +0100 (BST) To: control@debbugs.gnu.org From: David Edmondson Subject: control message for bug #33043 Message-Id: <06c9bff116def07c@disaster-area.hh.sledj.net> X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.3 (/) tags 33043 patch From debbugs-submit-bounces@debbugs.gnu.org Wed Oct 17 18:27:54 2018 Received: (at 33043) by debbugs.gnu.org; 17 Oct 2018 22:27:54 +0000 Received: from localhost ([127.0.0.1]:55922 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gCuIE-0003mI-B0 for submit@debbugs.gnu.org; Wed, 17 Oct 2018 18:27:54 -0400 Received: from mail-ed1-f46.google.com ([209.85.208.46]:44019) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gCuID-0003lz-7W for 33043@debbugs.gnu.org; Wed, 17 Oct 2018 18:27:53 -0400 Received: by mail-ed1-f46.google.com with SMTP id y20-v6so26387424eds.10 for <33043@debbugs.gnu.org>; Wed, 17 Oct 2018 15:27:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=TU90oDWjr1s9JIYE6dsWL6GZENmPmH+mWPOzOb4PqpM=; b=g7c3gczr1Hc/7RPP5IX2rYtQdGxnl/o1U3+O3EIlyApMkQY44PjiqGNJcoyF0mBtp0 kbag+8iOu4ai4rfFmd6YsyWbLw40hfi4smuYGvBGkcPm8QZGULhpt0c0WkW9BM2RO17C 562aQT012ELx1tcIeeOOhr+e8bLm3V+a9kDqp0dtRH6r+uA76CkrFnbG8gZYdps8yyKB BQEaD8s4rWj6cJVOXuSFq3X97/7E/EDmRWs0PIterUqdS8NhI8TDiI6srbu3xl2Qb+yB EQGvwuPhayxY6gaFgMrHyhSduj30tyvbwjz0AUmj9zHca5SbyBteAsNkMrkb4s6fd30D bIgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=TU90oDWjr1s9JIYE6dsWL6GZENmPmH+mWPOzOb4PqpM=; b=fhPNPN2Xty44vB1wISDSC29hc1HFIN33aNMjuZZFD25WMzriOvPl4Pd9/7wBDVpn7m t5pNi6ZHi63MiJINa+i5LSgH7fNjiwlbsOh7+sYLwf9ybYZL/GzSiPRkyeJrFFg8QBsn AjYrdFkwJBasSAiEzVvGhj9Jw2E7P+OdGnvZqCptEWkclSc3KhA7ecSbAgAeVaMWRoAf TLnW7YLr20TIVjiuuart7tbOFivtXmhk7fLc0UVKbZH5PcX28IA0ifsSMVYfbA3GeSi6 gKND2cZH9hrqqwBQzVWb4IkEAY42hMzoEh5y6gwLLvPY8o6oHlLK+3PwvXjxUJ4nBH3l 9JAQ== X-Gm-Message-State: ABuFfoi9qeV4toYX3JDL6snkVGcFF7w9N9WIqX8+TLNyN0/FXtUe4Rdk guC9HYfLJ4dTKxJeGPOKiTYGdJl3LRo= X-Google-Smtp-Source: ACcGV61QK30dXFjRpSQ1VocVMqXuBmJpKZ83klvEflklYker94Qv7sH8/OQRpfaKgoEcyKPKL7dJPg== X-Received: by 2002:a17:906:a2c4:: with SMTP id by4-v6mr27353714ejb.86.1539815267279; Wed, 17 Oct 2018 15:27:47 -0700 (PDT) Received: from localhost (51-171-243-2-dynamic.agg2.clk.blp-srl.eircom.net. [51.171.243.2]) by smtp.gmail.com with ESMTPSA id k13-v6sm7592014edb.89.2018.10.17.15.27.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Oct 2018 15:27:46 -0700 (PDT) From: "Basil L. Contovounesios" To: David Edmondson Subject: Re: bug#33043: [PATCH v1 1/1] Support for the truncation of displayed URLs References: <20181015100626.2344-1-dme@dme.org> Date: Wed, 17 Oct 2018 23:27:45 +0100 In-Reply-To: <20181015100626.2344-1-dme@dme.org> (David Edmondson's message of "Mon, 15 Oct 2018 11:06:26 +0100") Message-ID: <87r2go2opq.fsf@tcd.ie> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 33043 Cc: 33043@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Thanks for working on this David, I like the idea. David Edmondson 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: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=rcirc.diff 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") --=-=-= Content-Type: text/plain WDYT? -- Basil --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 18 05:39:19 2018 Received: (at 33043) by debbugs.gnu.org; 18 Oct 2018 09:39:19 +0000 Received: from localhost ([127.0.0.1]:56132 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gD4lz-0002Pb-FT for submit@debbugs.gnu.org; Thu, 18 Oct 2018 05:39:19 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:55680) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gD4lx-0002PM-37 for 33043@debbugs.gnu.org; Thu, 18 Oct 2018 05:39:18 -0400 Received: by mail-wm1-f65.google.com with SMTP id 206-v6so4734609wmb.5 for <33043@debbugs.gnu.org>; Thu, 18 Oct 2018 02:39:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dme-org.20150623.gappssmtp.com; s=20150623; h=to:cc:subject:in-reply-to:references:from:date:message-id :mime-version; bh=H4UNFLgfC/2jlNnWjnmarkZ0iS/iT3zg3aZ3J4qTaGQ=; b=09ESvfTAogIj7BchlgLP9ti7U4elnO3uVw8Zwy2uo/yDtyn2bKlalcbLjDS1As4oGs Te0ElSlc2MiJ8QwrlaEi9/c8ws/0lQfWOPJsmPuOq7+KkMtri0SONz+FCtdeTqpXG0Wq UM1UpKNhDHKmtBo36xwFP8hjOsEtQPO8Nyvvmh0QfgeOYP37iG2lHxDwCa8CWTq2OEZz X6ZFx9ay3gRt7OtOOXuvTPaGpdmZ3zU1k6P7ninMLSXQCB26g6dyxRz7p/JQufJ3fHTq cw/aY1YKCd/rwqdQgAskJqyHWwh8lLyQypfg0sPBPC3qV302yZc0yFnOFEmpawKYnl0M nL1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:subject:in-reply-to:references:from:date :message-id:mime-version; bh=H4UNFLgfC/2jlNnWjnmarkZ0iS/iT3zg3aZ3J4qTaGQ=; b=p7+ux9cOkj+uZTymhvfbhDt/b5R+HEAZlrqNIcJh5C0tY0xHYoNo045Q8L9nhfcoN0 JTp43XPz+TNvGHiGKCSYhefWmhexZsUITco0nBXt4/GYwSOuic3/1CzeW9dghkLYtPHe iTAEJFxB0UOcDQ7X82pobT5vnCmBG5Mr0QuHDLWNiRJQr0H5TIyHH1dDR0e4VQOIDusP lXs3KRhuUr0MMkHYc81gNkskMN7q4St/3HjUVXlk6lOoQmO79qjfCpLOvS+CHKBXuLxS uf2YjodlAeZF0oiGV7WYKTkq47RUSsnLF+5GjFAZAdUt5hI3JssngMuVAx+Enpb0T7uu UqYg== X-Gm-Message-State: ABuFfoiv4abrMPX1NIw4qR/22RGvFANsDQz/53OQ6Wjybq4ArO5UHwh1 3HsxrudL2mCXFfRTHwyv+RlqBmN3YLA= X-Google-Smtp-Source: ACcGV61uOaleMA2wJAV61QpIJWmGhbOfV/1GiQUOJ542PTo5HxrOVrsTh56CcOjWyKTmNybitNR2yg== X-Received: by 2002:a1c:b7c1:: with SMTP id h184-v6mr6823581wmf.33.1539855550712; Thu, 18 Oct 2018 02:39:10 -0700 (PDT) Received: from disaster-area.hh.sledj.net (disaster-area.hh.sledj.net. [81.149.164.25]) by smtp.gmail.com with ESMTPSA id g3-v6sm12847851wrw.81.2018.10.18.02.39.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Oct 2018 02:39:09 -0700 (PDT) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 988926e7; Thu, 18 Oct 2018 09:39:08 +0000 (UTC) To: "Basil L. Contovounesios" Subject: Re: bug#33043: [PATCH v1 1/1] Support for the truncation of displayed URLs In-Reply-To: <87r2go2opq.fsf@tcd.ie> References: <20181015100626.2344-1-dme@dme.org> <87r2go2opq.fsf@tcd.ie> X-HGTTG: gag-halfrunt From: David Edmondson Date: Thu, 18 Oct 2018 10:39:08 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: 33043 Cc: 33043@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.3 (/) 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. From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 18 06:38:18 2018 Received: (at 33043) by debbugs.gnu.org; 18 Oct 2018 10:38:18 +0000 Received: from localhost ([127.0.0.1]:56146 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gD5h4-00047r-B1 for submit@debbugs.gnu.org; Thu, 18 Oct 2018 06:38:18 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:39436) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gD5h2-00047d-Mc for 33043@debbugs.gnu.org; Thu, 18 Oct 2018 06:38:17 -0400 Received: by mail-ed1-f65.google.com with SMTP id d15-v6so27762963edq.6 for <33043@debbugs.gnu.org>; Thu, 18 Oct 2018 03:38:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=0SJX0gbwyAvjKjSx9FFs0veVS3/HpJgWMEsN69HnVCA=; b=G/taUC/2d+i389dEdzFOLAcIx3jEnSYtHZwa/7nxtHiTBkAz1C2Ic6GpYgRW6kTt2n vtLWTvAWPV3/EQx+C6pifQkIyuCadTO38wxpwn3OXHr5eAxr76PAjcUvYQurgl9oXYwc ce85sSJ4VuCoy9AC9WRIxlbzCAr2PrXae5TM2t68SFxx3zLy29ltuwxvTPZ1OAaoW1Zj 2ab945ayMiVkJioUsHth4USpS/E7G3Q91sYHInHtKmBpfDWqTeesls6o72KRBQsJfyA6 7hncLX8mJfuRp0kXJVW7RaGNCkqJOUGLjA8EI9AArTIDIDeuPJA4zTiaMmNcRFM5X5Mw c8Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=0SJX0gbwyAvjKjSx9FFs0veVS3/HpJgWMEsN69HnVCA=; b=H6Cis5SYKc6ksJa6I+A3BLgqVxW88FRrc/JVW1+5FHPRR1Qkq+PCLX1hcZq1ONm9zI hf6VkvE6xAsWBXVguUoasLZ69GVEQGslZg/j7CCCk+Hto6lQL51QfeWQsJTkkN0NO2T0 Gp1iD2SxFO/KS/RRUeCSQFUrvajHoFVcoXzS8uxDwVJ1TZSpVFaSvEmjlV15GQ8UYRKF L56Dngs+jts53FkHK2l0xGQQ2Mn1jsJPPRFiGJQOQVpb1Ny5EJEPdEbIcZj+XcfI2dYX oXwcu94qCgvkVEeHRctOwmqkTwt94fgZz1zmgG2Pq9FA6qpxBbnWZbChZ0vh/qkgUUY9 iRyw== X-Gm-Message-State: ABuFfohJgceHS754+uQjq5Qc+y8qtmXV5k76ao3lY3Dipd37sujIE0sd oQvLPkpGARPer9S2CWCQuhW7BA== X-Google-Smtp-Source: ACcGV63cdT7TIBgyMShyOVbeTUNZnWPXxeW1HbwDMIiizJvTrdlrqFZquucjLjkYl5jULxB5YE8ceA== X-Received: by 2002:a17:906:48cd:: with SMTP id d13-v6mr28585117ejt.85.1539859090747; Thu, 18 Oct 2018 03:38:10 -0700 (PDT) Received: from localhost (51-171-243-2-dynamic.agg2.clk.blp-srl.eircom.net. [51.171.243.2]) by smtp.gmail.com with ESMTPSA id p57-v6sm7099580edc.92.2018.10.18.03.38.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 03:38:09 -0700 (PDT) From: "Basil L. Contovounesios" To: David Edmondson Subject: Re: bug#33043: [PATCH v1 1/1] Support for the truncation of displayed URLs References: <20181015100626.2344-1-dme@dme.org> <87r2go2opq.fsf@tcd.ie> Date: Thu, 18 Oct 2018 11:38:04 +0100 In-Reply-To: (David Edmondson's message of "Thu, 18 Oct 2018 10:39:08 +0100") Message-ID: <87pnw7fskz.fsf@tcd.ie> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 33043 Cc: 33043@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain David Edmondson 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: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=rcirc.diff 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 --=-=-= Content-Type: text/plain If you prefer to avoid deletion and insertion when rcirc-url-max-length is nil, you can also write the following: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=rcirc-alt.diff 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") --=-=-= Content-Type: text/plain Thanks, -- Basil --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 18 06:50:35 2018 Received: (at 33043) by debbugs.gnu.org; 18 Oct 2018 10:50:36 +0000 Received: from localhost ([127.0.0.1]:56153 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gD5sv-0004Vn-J7 for submit@debbugs.gnu.org; Thu, 18 Oct 2018 06:50:33 -0400 Received: from mail-wm1-f51.google.com ([209.85.128.51]:33290) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gD5ss-0004VW-Ir for 33043@debbugs.gnu.org; Thu, 18 Oct 2018 06:50:31 -0400 Received: by mail-wm1-f51.google.com with SMTP id y140-v6so1578100wmd.0 for <33043@debbugs.gnu.org>; Thu, 18 Oct 2018 03:50:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dme-org.20150623.gappssmtp.com; s=20150623; h=to:cc:subject:in-reply-to:references:from:date:message-id :mime-version; bh=WHT61lS+QlyEQ9YMcnF6+77OwZUsMVENIrsL+9KW1ic=; b=hS4AAbwNTk9An5lqrsAdOhyb5Alhq7xcHOFsMCynrVx+E919z03rUK1NrpHVMgke7A zHWwu0dL7oh/hPkKio7MTRxJGvggWLQ8v5OChpNmxB2gy2EUlj3HOB97bzY5bC3sz9Gp 5MrnaVuzYNglhXg7NdbPOYDlhUgWXWY9Qn1tDdxj8ntmhL+X3r+Bbzl+Ai6BsTGIFw8A Wwa5fTilRvKdthfPFoHhrwxZKsxYs+813TwAHAN7Wr9ULdTOi37NffabWk5IRMJY4CVQ mFqKlFIHIyXGwukgSod8Tvk/BEozybetI8k3XeNkjcx1i+52rpkx1PrDLuxqd8KueR7y r8Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:subject:in-reply-to:references:from:date :message-id:mime-version; bh=WHT61lS+QlyEQ9YMcnF6+77OwZUsMVENIrsL+9KW1ic=; b=dD6BglbGxo9zIqhrSXjcGBFsnZ6zwz6ZZE/3gPIzCe9alWiRQo9PV1aIOPXSOQbZAZ PNxcEtH8q8pql3+HdELFLh+HG7OuZQoTM7fqPTVHX/SPvSnfy+2BZYFhG9OpKhUDNvp8 txmUqSjbniYmnKTsubSWuqGELdGQhCP7bSDgeqMlLMyd30x0fiNbN9m3jCSHgMA6lEtL JY8UAyH63YzttnrwRFE4koJE8TKdzIO1Qy09H0X7Ud9/c7ixJ71E/Yu8KSt5RsqMKq22 AMZEUe/iiwskcq/+eFS4Y46Mh9NAgCUyCHabHfI4ligcl8Kw2ta0MJMpZwbDbaNg0keU tC4A== X-Gm-Message-State: ABuFfojWAkpfPpCDfjWe+VPGUmZFp2jQy+6ECUhDsqSLJkMHlD2UrDSX pc2qxGCCFl5UZ2c+GpVfRLhT5w== X-Google-Smtp-Source: ACcGV62pqy28w1vWoLfNsj9qoM+HlX86z0tQNvSzqpuH+HJsct/C+fZ4y4v6Wh4qIkNf95k2kWc58w== X-Received: by 2002:a1c:e08a:: with SMTP id x132-v6mr7143910wmg.60.1539859824555; Thu, 18 Oct 2018 03:50:24 -0700 (PDT) Received: from disaster-area.hh.sledj.net (disaster-area.hh.sledj.net. [81.149.164.25]) by smtp.gmail.com with ESMTPSA id t13-v6sm11554764wrn.22.2018.10.18.03.50.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Oct 2018 03:50:23 -0700 (PDT) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 92c85286; Thu, 18 Oct 2018 10:50:22 +0000 (UTC) To: "Basil L. Contovounesios" Subject: Re: bug#33043: [PATCH v1 1/1] Support for the truncation of displayed URLs In-Reply-To: <87pnw7fskz.fsf@tcd.ie> References: <20181015100626.2344-1-dme@dme.org> <87r2go2opq.fsf@tcd.ie> <87pnw7fskz.fsf@tcd.ie> X-HGTTG: disaster-area From: David Edmondson Date: Thu, 18 Oct 2018 11:50:22 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: 33043 Cc: 33043@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.3 (/) On Thursday, 2018-10-18 at 11:38:04 +0100, Basil L. Contovounesios wrote: > David Edmondson 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? From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 27 04:54:26 2018 Received: (at 33043) by debbugs.gnu.org; 27 Oct 2018 08:54:26 +0000 Received: from localhost ([127.0.0.1]:44538 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGKMU-0004s5-4e for submit@debbugs.gnu.org; Sat, 27 Oct 2018 04:54:26 -0400 Received: from eggs.gnu.org ([208.118.235.92]:55875) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGKMR-0004rt-U2 for 33043@debbugs.gnu.org; Sat, 27 Oct 2018 04:54:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gGKMI-0007uF-2f for 33043@debbugs.gnu.org; Sat, 27 Oct 2018 04:54:18 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:52927) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gGKMH-0007u0-Ua; Sat, 27 Oct 2018 04:54:13 -0400 Received: from [176.228.60.248] (port=4124 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1gGKMH-0007D6-I9; Sat, 27 Oct 2018 04:54:13 -0400 Date: Sat, 27 Oct 2018 11:54:17 +0300 Message-Id: <83h8h7ojly.fsf@gnu.org> From: Eli Zaretskii To: "Basil L. Contovounesios" In-reply-to: <87pnw7fskz.fsf@tcd.ie> (contovob@tcd.ie) Subject: Re: bug#33043: [PATCH v1 1/1] Support for the truncation of displayed URLs References: <20181015100626.2344-1-dme@dme.org> <87r2go2opq.fsf@tcd.ie> <87pnw7fskz.fsf@tcd.ie> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 33043 Cc: 33043@debbugs.gnu.org, dme@dme.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) > From: "Basil L. Contovounesios" > Date: Thu, 18 Oct 2018 11:38:04 +0100 > Cc: 33043@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. From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 27 23:14:49 2018 Received: (at 33043) by debbugs.gnu.org; 28 Oct 2018 03:14:49 +0000 Received: from localhost ([127.0.0.1]:46134 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGbXM-0003q6-L3 for submit@debbugs.gnu.org; Sat, 27 Oct 2018 23:14:48 -0400 Received: from mail-ed1-f42.google.com ([209.85.208.42]:37908) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGbXL-0003pv-HC for 33043@debbugs.gnu.org; Sat, 27 Oct 2018 23:14:48 -0400 Received: by mail-ed1-f42.google.com with SMTP id c1-v6so4426250ede.5 for <33043@debbugs.gnu.org>; Sat, 27 Oct 2018 20:14:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=SqZqhqAuTfJI5MnzVyrsZRdGG5F08708JKknu5sMrpE=; b=v2Mh9Z1hcIKWGt/x+s23Z8Zmkr4HbSinbke1W6lpta7juhr9/6y55KBBcEPCBC+5Y6 0VL1IhcbjZfPeX4kHH25352dVmBXX/32tmFEGT7Ov+ErlXbFFvBmSdjkVLZfiHqIJH6m 8kVIYqw6kBEdcN4ypnCY2Qe7sJ1w3GOfCCbU3oW8fRS8/kVTB+aylLYjemeOfefVOwro v2xjeBTgoC+IsuV/28jPNvlUL0p82r/KhCcSbQMTMbzCrRb4Eh0ic2qlwIHeEvxnGqp9 wYaXCg7qIiE8K+c28V3vc7f21/urKFEThkqGqO7WEfAXF66MsnNvPZrqpBuWWgTiyJob NV0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=SqZqhqAuTfJI5MnzVyrsZRdGG5F08708JKknu5sMrpE=; b=cI8nbJxkhApyUtU0xCuiWPcFP4cAn8FE/u9rx3eKOyBPLV9DCvkhEJX9bWhccV24Ao /gtPYnnxzrtwRfnYNfd0RH4gbp+PKPgX+pufan52tpFLDLrZU6jby6g2vtsEzR44XD0k U8ZdnIdb3tTePHCFxE0//ZR4MXP9QIT4LOL8Sd6BsMpi/AxMWbCYh8mIV175eXmFUQsE 1/9nhlnJGidIlctea2VoPTU9si7SVo7zFukKHatr9rB+u8S2lZaxNy2KP5Qe8w/T56vC YgWHYvIrEqjm4zwO+E9G/QQvByaTrZ6FbKCI56urm/0twEorNOY4P9yvK0YehxYCsUcC jgxA== X-Gm-Message-State: AGRZ1gLkhfgNbAzc8obfzMoo9q3bo7Xl7kyHRfVmTEDfxR730vS57dxg UnL8P+/Do5WpoCFesg7aGHw0BtiwGQM= X-Google-Smtp-Source: AJdET5fOjJvv8nkofesvqhbzDU2YTaRNmm0CPCyTtsbP4TjH1gUxfFtQz0dw2pD9l/5VXB+ZO4v3tQ== X-Received: by 2002:a50:f4ac:: with SMTP id s41-v6mr8764169edm.269.1540696481804; Sat, 27 Oct 2018 20:14:41 -0700 (PDT) Received: from localhost (51-171-243-2-dynamic.agg2.clk.blp-srl.eircom.net. [51.171.243.2]) by smtp.gmail.com with ESMTPSA id n3-v6sm2950671eje.26.2018.10.27.20.14.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 27 Oct 2018 20:14:40 -0700 (PDT) From: "Basil L. Contovounesios" To: Eli Zaretskii Subject: Re: bug#33043: [PATCH v1 1/1] Support for the truncation of displayed URLs References: <20181015100626.2344-1-dme@dme.org> <87r2go2opq.fsf@tcd.ie> <87pnw7fskz.fsf@tcd.ie> <83h8h7ojly.fsf@gnu.org> Date: Sun, 28 Oct 2018 03:14:39 +0000 In-Reply-To: <83h8h7ojly.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 27 Oct 2018 11:54:17 +0300") Message-ID: <87h8h6iwyo.fsf@tcd.ie> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 33043 Cc: 33043@debbugs.gnu.org, dme@dme.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-URL-truncation-support-to-rcirc-bug-33043.patch >From 76dc7ed5d5b9c6273e99a2659ba304e9e7eb8e03 Mon Sep 17 00:00:00 2001 From: David Edmondson Date: Sun, 28 Oct 2018 03:11:21 +0000 Subject: [PATCH 1/2] Add URL truncation support to rcirc (bug#33043) * lisp/net/rcirc.el (rcirc-url-max-length): New user option controlling extent of URL truncation, defaulting to none. (rcirc-markup-urls): Use it. --- lisp/net/rcirc.el | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index fe9c71a21c..50e4d8ffb2 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el @@ -168,6 +168,14 @@ 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." + :version "27.1" + :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 +2499,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 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-Reuse-URL-truncation-function-in-rcirc-bug-33043.patch >From 8d7f03b12ccb07cd9ffe953b99d519e289b61df9 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Sun, 28 Oct 2018 02:51:18 +0000 Subject: [PATCH 2/2] Reuse URL truncation function in rcirc (bug#33043) * lisp/net/rcirc.el (rcirc-markup-urls): Simplify using url-truncate-url-for-viewing. --- lisp/net/rcirc.el | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index 50e4d8ffb2..ca707341be 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el @@ -2493,34 +2493,26 @@ 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)) - (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)))) + (url (buffer-substring-no-properties start (point)))) + (when rcirc-url-max-length + ;; Replace match with truncated URL. + (delete-region start (point)) + (insert (url-truncate-url-for-viewing url rcirc-url-max-length))) ;; 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 start (point) '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 start) rcirc-urls))))) (defun rcirc-markup-keywords (sender response) (when (and (string= response "PRIVMSG") -- 2.19.1 --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: "Basil L. Contovounesios" >> Date: Thu, 18 Oct 2018 11:38:04 +0100 >> Cc: 33043@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 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 29 12:01:17 2018 Received: (at 33043) by debbugs.gnu.org; 29 Oct 2018 16:01:17 +0000 Received: from localhost ([127.0.0.1]:52049 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gH9yf-0001Jy-7k for submit@debbugs.gnu.org; Mon, 29 Oct 2018 12:01:17 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:46355) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gH9yd-0001Jl-Bj for 33043@debbugs.gnu.org; Mon, 29 Oct 2018 12:01:15 -0400 Received: by mail-wr1-f66.google.com with SMTP id 74-v6so1073801wrb.13 for <33043@debbugs.gnu.org>; Mon, 29 Oct 2018 09:01:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dme-org.20150623.gappssmtp.com; s=20150623; h=to:cc:subject:in-reply-to:references:from:date:message-id :mime-version; bh=S488xdtHSJOWTaY/RUblYkmVQTxaVoOePBHWZQ080QE=; b=t19OVhAvcn/SAis0Sx7umTjEAHvA3nUIY3h5q4qT6B0GwVIeOEV3osZYMyt1Rd4TxE SLUhSz9Kot6PtDIFD0HNz39SP9AGn021xUJKArXgKAgst9lT/bBXodo3nffOOFJ5A/qy KHXFZSXMtIe1c9F7/iksFmxAQ6zVAn6udocH665IPuNzeXx8jyOAh5LULUO4Lik0e9d5 XhjzGxqPBMn7Yhl4j6cag+mPhIFRJAbv3ZH0Hnb4I8sr25BN1WIhXs+089JNy2ZELBl4 vdZK8o9jxED0hIz1titkyES2yrrmQACMe/Sx0ahon7iLbI/swfjIcIaHQ1MfJBhHQmVr Ymww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:subject:in-reply-to:references:from:date :message-id:mime-version; bh=S488xdtHSJOWTaY/RUblYkmVQTxaVoOePBHWZQ080QE=; b=mhJ1IjaJGwF+TAb9+FBXpUIfcdlGKSdk7SeZtRHkoIB3jhWI1YsAZ9OA4L6WyVOSGr /TiC7JRdc/OlgM8hlW48lT19K5eKAdtZOMm80QciZ5l+2Ls9s4pKHhU75zmldfFcMcWI nBOBcKogMOJNfEhcs5Uudg+pZWhZjiDt4Zsdn7Se66fJgX+hSLcEKyLfDmvV7lFRZb6v IlujesTEWht5jenQcD5GWhnbR1sneay+nrwYNxxQTYoARTC82SprlOcXdzF+hfyC94Tm Rf+KkYYu+2knSiQ7+3ki9Hgbcfptt+0s0S0UwRMnVowxRSYe6kgVQ09VgfH+o7lTwywb 0UgQ== X-Gm-Message-State: AGRZ1gIR2vxxLHi/98SbBDCoOYXfGXx6lyWPPmeIC2a9dFJ66aQ5tc6N vVToocKuWKnUUJLrxswD2tO8WA== X-Google-Smtp-Source: AJdET5fk4HJygoLJBkU2+L9aA39febssPAp93v8+O15zwJOaYOj2buXJqIS3FPJps4knRXaunyYy+w== X-Received: by 2002:adf:e0ce:: with SMTP id e14-v6mr15495119wri.199.1540828868967; Mon, 29 Oct 2018 09:01:08 -0700 (PDT) Received: from disaster-area.hh.sledj.net (disaster-area.hh.sledj.net. [81.149.164.25]) by smtp.gmail.com with ESMTPSA id l6-v6sm5161408wrs.85.2018.10.29.09.01.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Oct 2018 09:01:07 -0700 (PDT) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 633ec6e0; Mon, 29 Oct 2018 16:01:04 +0000 (UTC) To: "Basil L. Contovounesios" , Eli Zaretskii Subject: Re: bug#33043: [PATCH v1 1/1] Support for the truncation of displayed URLs In-Reply-To: <87h8h6iwyo.fsf@tcd.ie> References: <20181015100626.2344-1-dme@dme.org> <87r2go2opq.fsf@tcd.ie> <87pnw7fskz.fsf@tcd.ie> <83h8h7ojly.fsf@gnu.org> <87h8h6iwyo.fsf@tcd.ie> X-HGTTG: heart-of-gold From: David Edmondson Date: Mon, 29 Oct 2018 16:01:04 +0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: 33043 Cc: 33043@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.3 (/) 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. From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 29 14:28:05 2018 Received: (at 33043) by debbugs.gnu.org; 29 Oct 2018 18:28:05 +0000 Received: from localhost ([127.0.0.1]:52202 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gHCGj-0004wy-Bw for submit@debbugs.gnu.org; Mon, 29 Oct 2018 14:28:05 -0400 Received: from mail-ed1-f48.google.com ([209.85.208.48]:44627) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gHCGg-0004wT-VS for 33043@debbugs.gnu.org; Mon, 29 Oct 2018 14:28:03 -0400 Received: by mail-ed1-f48.google.com with SMTP id z21-v6so8191233edb.11 for <33043@debbugs.gnu.org>; Mon, 29 Oct 2018 11:28:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=ruGuAY69ENpkwf1FVneCxhg8m5iCvgu4LEKdH9v5RzA=; b=nSEYHxIcK/d2ih0gpIOFthwyr5r67bdKSUOFXXdY0W+2qPum3c5M4j/XRNoeb6I4yT jMykSV94laXqhzarbq1I9W4a1VzJ9dG8dQNH/ndsLnzMTvIdDmAYk+TJyaZDgUFZn5+M IHoyy5dLuueKSU4e2/c7f0IqBh9YW5knJG+gFMGA+NENKqoF6XDNk2nd/JijQViDoZN9 wuIoG9/RR+x1y/PrxbJ8u3ppBJzVY2FYRowfh83TooVvVz/OrJASdmt8msVD7x6QcbQC 5CfA/pWGmDvJH0xcwhBQbfGBZtKTsUvu5r8ArxKUMOdIpxZSSYenkk3EH0xTalSOn9dn JWig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=ruGuAY69ENpkwf1FVneCxhg8m5iCvgu4LEKdH9v5RzA=; b=lQwEehbUz0tXaMZc77nNfJwxseX0spm4OvIg/gfkv/yHr0ylTF86/eYmEu37rfuzA7 KH+iRc6r9ACJkgTTwVBMGxEDRFB38ZmfvSFLmThREDTM8vsKXFArr9M/fKI7A4wbQFzj fz4nX+TbkIYL7J5b4CktlCtE9OTF5cbHzTfa/sdIDEMVHsZU5+n+cjZVxsqcpY17Ru+8 p16+r9pmxpNQFJ5QbFwTVhDxFZ96TC5YxMhLKsepcIF49NR/AKutj1rmCRN6B0PX8d1V i0fyakaKeujv8ge0U0eRigg76GCjgCZirpw1qUep5HmXrtBel4uQjaimv5yRXsmJ+Wki 5/cA== X-Gm-Message-State: AGRZ1gIl8AtMOmpZEQEutaPzbV8ayyCFhKgXJolBipegdAWY+NpTpAOR D4FaRpIp7ofCeGM5/qYI13xilw== X-Google-Smtp-Source: AJdET5eeZDBf4vWzORBHbxrsgtObs51nfiWXNrQUdcH7h9EYC7Egqtd+qHfRuRLtXFaUlJBcBqEujA== X-Received: by 2002:a17:906:6616:: with SMTP id b22-v6mr10490673ejp.184.1540837677150; Mon, 29 Oct 2018 11:27:57 -0700 (PDT) Received: from localhost (51-171-243-2-dynamic.agg2.clk.blp-srl.eircom.net. [51.171.243.2]) by smtp.gmail.com with ESMTPSA id m15-v6sm3828519ejq.24.2018.10.29.11.27.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 29 Oct 2018 11:27:56 -0700 (PDT) From: "Basil L. Contovounesios" To: David Edmondson Subject: Re: bug#33043: [PATCH v1 1/1] Support for the truncation of displayed URLs References: <20181015100626.2344-1-dme@dme.org> <87r2go2opq.fsf@tcd.ie> <87pnw7fskz.fsf@tcd.ie> <83h8h7ojly.fsf@gnu.org> <87h8h6iwyo.fsf@tcd.ie> Date: Mon, 29 Oct 2018 18:27:54 +0000 In-Reply-To: (David Edmondson's message of "Mon, 29 Oct 2018 16:01:04 +0000") Message-ID: <87tvl4ip5h.fsf@tcd.ie> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 33043 Cc: Eli Zaretskii , 33043@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-URL-truncation-support-to-rcirc-bug-33043.patch >From 41d7f52984e6220123b8ccc7da1b1d56a9a7eb49 Mon Sep 17 00:00:00 2001 From: David Edmondson Date: Sun, 28 Oct 2018 03:11:21 +0000 Subject: [PATCH] Add URL truncation support to rcirc (bug#33043) Suggested by David Edmondson . * lisp/net/rcirc.el (rcirc-url-max-length): New user option controlling extent of URL truncation, defaulting to none. (rcirc-markup-urls): Use it. * etc/NEWS: Announce it. --- etc/NEWS | 7 +++++++ lisp/net/rcirc.el | 26 ++++++++++++++++++-------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 226ae1e135..f7fdd0add9 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -758,6 +758,13 @@ Tramp for some look-alike remote file names. *** For some connection methods, like "su" or "sudo", the host name in ad-hoc multi-hop file names must match the previous hop. +** Rcirc + +--- +*** New user option 'rcirc-url-max-length'. +Setting this option to an integer causes URLs displayed in Rcirc +buffers to be truncated to that many characters. + ** Register --- *** The return value of method 'register-val-describe' includes the diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index fe9c71a21c..ca707341be 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el @@ -168,6 +168,14 @@ 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." + :version "27.1" + :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) @@ -2485,24 +2493,26 @@ 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)) - (end (match-end 0)) - (url (match-string-no-properties 0)) - (link-text (buffer-substring-no-properties start end))) + (url (buffer-substring-no-properties start (point)))) + (when rcirc-url-max-length + ;; Replace match with truncated URL. + (delete-region start (point)) + (insert (url-truncate-url-for-viewing url rcirc-url-max-length))) ;; 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 start (point) '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 start) rcirc-urls))))) (defun rcirc-markup-keywords (sender response) (when (and (string= response "PRIVMSG") -- 2.19.1 --=-=-= Content-Type: text/plain David Edmondson 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 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 03 05:11:48 2018 Received: (at 33043-done) by debbugs.gnu.org; 3 Nov 2018 09:11:48 +0000 Received: from localhost ([127.0.0.1]:60616 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gIry8-0007uW-05 for submit@debbugs.gnu.org; Sat, 03 Nov 2018 05:11:48 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35609) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gIry6-0007uK-EZ for 33043-done@debbugs.gnu.org; Sat, 03 Nov 2018 05:11:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gIrxx-0007wu-D5 for 33043-done@debbugs.gnu.org; Sat, 03 Nov 2018 05:11:41 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:35520) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIrxo-0007qj-9x; Sat, 03 Nov 2018 05:11:32 -0400 Received: from [176.228.60.248] (port=3887 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1gIrxh-0001Ai-Ci; Sat, 03 Nov 2018 05:11:23 -0400 Date: Sat, 03 Nov 2018 11:11:11 +0200 Message-Id: <83bm76frv4.fsf@gnu.org> From: Eli Zaretskii To: "Basil L. Contovounesios" In-reply-to: <87tvl4ip5h.fsf@tcd.ie> (contovob@tcd.ie) Subject: Re: bug#33043: [PATCH v1 1/1] Support for the truncation of displayed URLs References: <20181015100626.2344-1-dme@dme.org> <87r2go2opq.fsf@tcd.ie> <87pnw7fskz.fsf@tcd.ie> <83h8h7ojly.fsf@gnu.org> <87h8h6iwyo.fsf@tcd.ie> <87tvl4ip5h.fsf@tcd.ie> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 33043-done Cc: 33043-done@debbugs.gnu.org, dme@dme.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) > From: "Basil L. Contovounesios" > Cc: Eli Zaretskii , 33043@debbugs.gnu.org > Date: Mon, 29 Oct 2018 18:27:54 +0000 > > David Edmondson 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. From unknown Sat Jun 14 19:28:24 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 01 Dec 2018 12:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator