unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "J.P." <jp@neverwas.me>
To: 60933@debbugs.gnu.org
Cc: emacs-erc@gnu.org
Subject: bug#60933: 30.0.50; ERC >5.5: Make buttonizing more extensible
Date: Tue, 23 May 2023 06:35:05 -0700	[thread overview]
Message-ID: <87y1lfrx12.fsf__6370.67675577185$1684848988$gmane$org@neverwas.me> (raw)
In-Reply-To: <878rhzc3gk.fsf@neverwas.me> (J. P.'s message of "Wed, 18 Jan 2023 06:38:51 -0800")

[-- Attachment #1: Type: text/plain, Size: 479 bytes --]

The new DWIM `erc-tab' command defers to pcomplete inside the prompt
area and runs a hook otherwise. But the hook's interface demands that
implementing members handle a raw prefix arg for no compelling reason.
And most of these members are movement-focused commands whose natural
interactive spec tends to be numeric, making for some roundabout
boilerplate awkwardness. This patch switches to numeric prefixes
everywhere, which is how things likely should have been originally.


[-- Attachment #2: 0001-5.6-Simplify-erc-tab-interface.patch --]
[-- Type: text/x-patch, Size: 4266 bytes --]

From 3ad4da1dc674226339af1437de8c0552316d5b89 Mon Sep 17 00:00:00 2001
From: "F. Jason Park" <jp@neverwas.me>
Date: Mon, 22 May 2023 23:42:11 -0700
Subject: [PATCH] [5.6] Simplify erc-tab interface

* etc/ERC-NEWS: Improve section mentioning `erc-tab'.
* lisp/erc/erc-button.el (erc-button-alist): Restore a commented out
version of the "<URL ...>" entry, which was dropped in 5adda2f4683
"Revise FORM-as-function interface in erc-button-alist" for being
redundant and hence wasteful.  This may help any unlikely objectors
better adapt to the churn.
(erc-button-next, erc-button-previous): Don't bother accommodating raw
prefix arguments; expect numeric arguments only.
* lisp/erc/erc.el (erc-tab): Change interactive spec to lowercase
"p".  (Bug#60933)
---
 etc/ERC-NEWS           | 12 ++++++------
 lisp/erc/erc-button.el |  7 +++----
 lisp/erc/erc.el        |  8 ++++----
 3 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/etc/ERC-NEWS b/etc/ERC-NEWS
index d257bdcbf51..3d110ca43c6 100644
--- a/etc/ERC-NEWS
+++ b/etc/ERC-NEWS
@@ -215,12 +215,12 @@ changes are encouraged to voice their concerns on the bug list.
 *** Miscellaneous changes
 Two helper macros from GNU ELPA's Compat library are now available to
 third-party modules as 'erc-compat-call' and 'erc-compat-function'.
-In the area of buttons, 'Info-goto-node' has been supplanted by plain
-old 'info' in 'erc-button-alist', and the bracketed "<URL:...>"
-pattern entry has been removed because it was more or less redundant.
-And the "TAB" key is now bound to a new command, 'erc-tab', that only
-calls 'completion-at-point' when point is in the input area and
-module-specific commands, like 'erc-button-next', otherwise.
+In 'erc-button-alist', 'Info-goto-node' has been supplanted by plain
+old 'info', and the "<URL:...>" entry has been removed because it was
+more or less redundant.  In all ERC buffers, the "<TAB>" key is now
+bound to a new command, 'erc-tab', that calls 'completion-at-point'
+inside the input area and otherwise dispatches module-specific
+commands, like 'erc-button-next'.
 
 \f
 * Changes in ERC 5.5
diff --git a/lisp/erc/erc-button.el b/lisp/erc/erc-button.el
index 4307dc3b860..33b93ff6744 100644
--- a/lisp/erc/erc-button.el
+++ b/lisp/erc/erc-button.el
@@ -128,6 +128,7 @@ erc-button-alist
   ;; things hard to maintain.
   '((nicknames 0 erc-button-buttonize-nicks erc-nick-popup 0)
     (erc-button-url-regexp 0 t browse-url-button-open-url 0)
+    ;; ("<URL: *\\([^<> ]+\\) *>" 0 t browse-url-button-open-url 1)
 ;;; ("(\\(\\([^~\n \t@][^\n \t@]*\\)@\\([a-zA-Z0-9.:-]+\\)\\)" 1 t finger 2 3)
     ;; emacs internal
     ("[`‘]\\([a-zA-Z][-a-zA-Z_0-9!*<=>+]+\\)['’]"
@@ -629,15 +630,13 @@ erc-button-next
   "Go to the ARGth next button."
   (declare (advertised-calling-convention (arg) "30.1"))
   (interactive "p")
-  (setq arg (pcase arg ((pred listp) (prefix-numeric-value arg)) (_ arg)))
-  (erc--button-next arg))
+  (erc--button-next (or arg 1)))
 
 (defun erc-button-previous (&optional arg)
   "Go to ARGth previous button."
   (declare (advertised-calling-convention (arg) "30.1"))
   (interactive "p")
-  (setq arg (pcase arg ((pred listp) (prefix-numeric-value arg)) (_ arg)))
-  (erc--button-next (- arg)))
+  (erc--button-next (- (or arg 1))))
 
 (defun erc-button-previous-of-nick (arg)
   "Go to ARGth previous button for nick at point."
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 0be9eb69432..b8ad37a55a0 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -4773,11 +4773,11 @@ erc--tab-functions
   "Functions to try when user hits \\`TAB' outside of input area.
 Called with a numeric prefix arg.")
 
-(defun erc-tab (&optional arg)
+(defun erc-tab (arg)
   "Call `completion-at-point' when typing in the input area.
-Otherwise call members of `erc--tab-functions' with raw prefix
-ARG until one of them returns non-nil."
-  (interactive "P")
+Otherwise call members of `erc--tab-functions' with a numeric
+prefix ARG until one of them returns non-nil."
+  (interactive "p")
   (if (>= (point) erc-input-marker)
       (completion-at-point)
     (run-hook-with-args-until-success 'erc--tab-functions arg)))
-- 
2.40.0


  parent reply	other threads:[~2023-05-23 13:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-18 14:38 bug#60933: 30.0.50; ERC >5.5: Make buttonizing more extensible J.P.
2023-02-19 15:04 ` J.P.
2023-03-09 14:42 ` J.P.
     [not found] ` <87fsaekmv4.fsf@neverwas.me>
2023-04-18 14:11   ` J.P.
     [not found]   ` <877cu9qnyo.fsf@neverwas.me>
2023-04-29 15:56     ` J.P.
2023-05-23 13:35 ` J.P. [this message]
2023-06-02 14:07 ` J.P.
2023-09-13 14:09 ` J.P.
     [not found] ` <87wmwuyxjh.fsf@neverwas.me>
2023-09-19 13:28   ` J.P.

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='87y1lfrx12.fsf__6370.67675577185$1684848988$gmane$org@neverwas.me' \
    --to=jp@neverwas.me \
    --cc=60933@debbugs.gnu.org \
    --cc=emacs-erc@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).