bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#68395: 30.0.50; ERC 5.6-git: erc-cmd-GMSG, erc-cmd-AMSG, erc-cmd-GME


From: J.P.
Subject: bug#68395: 30.0.50; ERC 5.6-git: erc-cmd-GMSG, erc-cmd-AMSG, erc-cmd-GME, erc-cmd-AME
Date: Thu, 11 Jan 2024 21:34:15 -0800
User-agent: Gnus/5.13 (Gnus v5.13)

Emanuel Berg <incal@dataswamp.org> writes:

> Patch

I think debbugs wants the full "Tags: patch".

> From 2aea60a6ab47431fa7da913a8de8d325d1c62030 Mon Sep 17 00:00:00 2001
> From: Emanuel Berg <moasenwood@zoho.eu>
> Date: Fri, 12 Jan 2024 05:16:11 +0100
> Subject: [PATCH] `erc-cmd-GMSG', `erc-cmd-AMSG', `erc-cmd-GME' and
>  `erc-cmd-AME'.

At some point, you'll need to include a commit message. Please see "**
Commit messages" in CONTRIBUTE.

> ---
>  lisp/erc/erc.el | 156 ++++++++++++++++++++++++++++--------------------
>  1 file changed, 90 insertions(+), 66 deletions(-)
>
> diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
> index 478683a77f5..12078f6970d 100644
> --- a/lisp/erc/erc.el
> +++ b/lisp/erc/erc.el
> @@ -2003,10 +2003,10 @@ erc-get-buffer
>  (defun erc--buffer-p (buf predicate proc)
>    (with-current-buffer buf
>      (and (derived-mode-p 'erc-mode)
> -      (or (not proc)
> -          (eq proc erc-server-process))
> -      (funcall predicate)
> -      buf)))
> +         (or (not proc)
> +             (eq proc erc-server-process))
> +         (funcall predicate)
> +         buf)))

I haven't looked at the proposed commands yet, but can you remove all
these hopefully inadvertent white space changes in the meantime, please?

Both vc and Magit should have tools for helping with this. Assuming
"[PATCH] `erc-cmd-GMSG' ..." sits on HEAD, you'd do something like this
in manual Git:

  1. $ git reset --patch @^
  2. Mark all offending hunks as "y" in the interactive menu
  3. $ git restore '*'
  4. $ git commit --amend
  5. Provide a commit message that accords with CONTRIBUTE

Or, alternatively:

  1. $ git revert @
  2. Reinstate only the intended changes, which I think I've found below
  3. $ git add -A
  4. $ git commit --amend
  5. Replace generated message

>  (defun erc-buffer-filter (predicate &optional proc)
>    "Return a list of `erc-mode' buffers matching certain criteria.
> @@ -2021,7 +2021,7 @@ erc-buffer-filter
>       nil
>       (mapcar (lambda (buf)
>                 (when (buffer-live-p buf)
> -              (erc--buffer-p buf predicate proc)))
> +                 (erc--buffer-p buf predicate proc)))
>               (buffer-list)))))
>  
>  (defalias 'erc-buffer-do 'erc-buffer-filter
> @@ -2042,14 +2042,14 @@ erc-buffer-list
>  (define-obsolete-function-alias 'erc-iswitchb #'erc-switch-to-buffer "25.1")
>  (defun erc--switch-to-buffer (&optional arg)
>    (read-buffer "Switch to ERC buffer: "
> -            (when (boundp 'erc-modified-channels-alist)
> -              (buffer-name (caar (last erc-modified-channels-alist))))
> -            t
> -            ;; Only allow ERC buffers in the same session.
> -            (let ((proc (unless arg erc-server-process)))
> -              (lambda (bufname)
> -                (let ((buf (if (consp bufname)
> -                               (cdr bufname) (get-buffer bufname))))
> +               (when (boundp 'erc-modified-channels-alist)
> +                 (buffer-name (caar (last erc-modified-channels-alist))))
> +               t
> +               ;; Only allow ERC buffers in the same session.
> +               (let ((proc (unless arg erc-server-process)))
> +                 (lambda (bufname)
> +                   (let ((buf (if (consp bufname)
> +                                  (cdr bufname) (get-buffer bufname))))
>                       (and buf (erc--buffer-p buf (lambda () t) proc)))))))
>  (defun erc-switch-to-buffer (&optional arg)
>    "Prompt for an ERC buffer to switch to.
> @@ -2581,7 +2581,7 @@ erc-initialize-log-marker
>      (unless (markerp erc-last-saved-position)
>        (setq erc-last-saved-position (make-marker))
>        (move-marker erc-last-saved-position
> -                (1- (marker-position erc-insert-marker))))))
> +                   (1- (marker-position erc-insert-marker))))))
>  
>  ;; interactive startup
>  
> @@ -3590,7 +3590,7 @@ erc-display-message-highlight
>           (erc-put-text-property
>            0 (length string)
>            'font-lock-face (or (intern-soft
> -                            (concat "erc-" (symbol-name type) "-face"))
> +                               (concat "erc-" (symbol-name type) "-face"))
>                                'erc-default-face)
>            string)
>           string)))
> @@ -3667,8 +3667,8 @@ erc-lurker-cleanup
>       (maphash
>        (lambda (nick last-PRIVMSG-time)
>          (when
> -         (time-less-p erc-lurker-threshold-time
> -                      (time-since last-PRIVMSG-time))
> +            (time-less-p erc-lurker-threshold-time
> +                         (time-since last-PRIVMSG-time))
>            (remhash nick hash)))
>        hash)
>       (if (zerop (hash-table-count hash))
> @@ -3735,8 +3735,8 @@ erc-lurker-p
>            (gethash (erc-lurker-maybe-trim nick)
>                     (gethash server erc-lurker-state (make-hash-table)))))
>      (or (null last-PRIVMSG-time)
> -     (time-less-p erc-lurker-threshold-time
> -                  (time-since last-PRIVMSG-time)))))
> +        (time-less-p erc-lurker-threshold-time
> +                     (time-since last-PRIVMSG-time)))))
>  
>  (defcustom erc-common-server-suffixes
>    '(("openprojects.net\\'" . "OPN")
> @@ -3760,7 +3760,7 @@ erc-canonicalize-server-name
>  
>  (defun erc-add-targets (scope target-list)
>    (let ((targets
> -      (mapcar (lambda (targets) (member scope targets)) target-list)))
> +         (mapcar (lambda (targets) (member scope targets)) target-list)))
>      (cdr (apply #'append (delete nil targets)))))
>  
>  (defun erc-hide-current-message-p (parsed)
> @@ -3776,16 +3776,16 @@ erc-hide-current-message-p
>           (sender (car (erc-parse-user (erc-response.sender parsed))))
>           (channel (car (erc-response.command-args parsed)))
>           (network (or (and (erc-network) (erc-network-name))
> -                   (erc-shorten-server-name
> -                    (or erc-server-announced-name
> -                        erc-session-server))))
> -      (current-hide-list
> -       (when erc-network-hide-list
> -         (erc-add-targets network erc-network-hide-list)))
> -      (current-hide-list
> -       (append current-hide-list
> -               (when erc-channel-hide-list
> -                 (erc-add-targets channel erc-channel-hide-list)))))
> +                      (erc-shorten-server-name
> +                       (or erc-server-announced-name
> +                           erc-session-server))))
> +         (current-hide-list
> +          (when erc-network-hide-list
> +            (erc-add-targets network erc-network-hide-list)))
> +         (current-hide-list
> +          (append current-hide-list
> +                  (when erc-channel-hide-list
> +                    (erc-add-targets channel erc-channel-hide-list)))))
>      (or (member command erc-hide-list)
>          (member command current-hide-list)
>          (and (member command erc-lurker-hide-list) (erc-lurker-p sender)))))
> @@ -3871,9 +3871,9 @@ erc-display-message
>          (erc--route-insertion string buffer)
>        (unless (erc-hide-current-message-p parsed)
>          (erc-put-text-property 0 (length string) 'erc-parsed parsed string)
> -     (when (erc-response.tags parsed)
> -       (erc-put-text-property 0 (length string) 'tags (erc-response.tags 
> parsed)
> -                              string))
> +        (when (erc-response.tags parsed)
> +          (erc-put-text-property 0 (length string) 'tags (erc-response.tags 
> parsed)
> +                                 string))
>          (erc--route-insertion string buffer)))))
>  
>  (defun erc-message-type-member (position list)
> @@ -4016,16 +4016,40 @@ erc--split-string-shell-cmd
>  ;;                    Input commands handlers
>  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>  
> -(defun erc-cmd-AMSG (line)
> -  "Send LINE to all channels of the current server that you are on."
> -  (interactive "sSend to all channels you're on: ")
> +(defun erc-cmd-GMSG (line)
> +  "Send LINE to all channels on all networks you are on."
> +  (interactive "sSend to all channels: ")
>    (setq line (erc-trim-string line))
>    (erc-with-all-buffers-of-server nil
> -    (lambda ()
> -      (erc-channel-p (erc-default-target)))
> +    (lambda () (erc-channel-p (erc-default-target)))
> +    (erc-send-message line)))
> +(put 'erc-cmd-GMSG 'do-not-parse-args t)
> +
> +(defun erc-cmd-AMSG (line)
> +  "Send LINE to all channels of the current network."
> +  (interactive "sSend to all channels on this network: ")
> +  (setq line (erc-trim-string line))
> +  (erc-with-all-buffers-of-server erc-server-process
> +    (lambda () (erc-channel-p (erc-default-target)))
>      (erc-send-message line)))
>  (put 'erc-cmd-AMSG 'do-not-parse-args t)
>  
> +(defun erc-cmd-GME (line)
> +  "Send LINE as an action to all channels on all networks you are on."
> +  (interactive "sSend action to all channels: ")
> +  (erc-with-all-buffers-of-server nil
> +    (lambda () (erc-channel-p (erc-default-target)))
> +    (erc-cmd-ME line) ))
> +(put 'erc-cmd-GME 'do-not-parse-args t)
> +
> +(defun erc-cmd-AME (line)
> +  "Send LINE as an action to all channels on the current network."
> +  (interactive "sSend action to all channels on this network: ")
> +  (erc-with-all-buffers-of-server erc-server-process
> +    (lambda () (erc-channel-p (erc-default-target)))
> +    (erc-cmd-ME line) ))
> +(put 'erc-cmd-AME 'do-not-parse-args t)

I'm guessing this hunk is the only one you intended to add? At first
glance, it appears to be the right location for such commands. Anyway,
please resubit once the white space issues have been resolved. Thanks.

> +
>  (defun erc-cmd-SAY (line)
>    "Send LINE to the current query or channel as a message, not a command.
>  
> @@ -5213,8 +5237,8 @@ erc-cmd-TOPIC
>            (topic (match-string 2 topic)))
>        ;; Ignore all-whitespace topics.
>        (unless (equal (string-trim topic) "")
> -     (erc-log (format "cmd: TOPIC [%s]: %s" ch topic))
> -     (erc-server-send (format "TOPIC %s :%s" ch topic) nil ch)))
> +        (erc-log (format "cmd: TOPIC [%s]: %s" ch topic))
> +        (erc-server-send (format "TOPIC %s :%s" ch topic) nil ch)))
>      t)
>     ;; /topic #channel
>     ((string-match "^\\s-*\\([&#+!]\\S-+\\)" topic)
> @@ -5493,7 +5517,7 @@ erc-input-message
>          (read-map minibuffer-local-map))
>      (insert (read-from-minibuffer "Message: "
>                                    (string last-command-event)
> -                               read-map))
> +                                  read-map))
>      (erc-send-current-line)))
>  
>  (defvar erc-action-history-list ()
> @@ -5776,11 +5800,11 @@ erc-wash-quit-reason
>    (or (when (string-match (concat "^\\(Read error\\) to "
>                                    nick "\\[" host "\\]: "
>                                    "\\(.+\\)$")
> -                       reason)
> +                          reason)
>          (concat (match-string 1 reason) ": " (match-string 2 reason)))
>        (when (string-match (concat "^\\(Ping timeout\\) for "
>                                    nick "\\[" host "\\]$")
> -                       reason)
> +                          reason)
>          (match-string 1 reason))
>        reason))
>  
> @@ -5820,7 +5844,7 @@ erc-nickname-in-use
>                                     ;; server's setting if we haven't
>                                     ;; established a connection yet
>                                     (- 9 (length erc-nick-uniquifier))))
> -                             erc-nick-uniquifier)))
> +                                erc-nick-uniquifier)))
>        (erc--nickname-in-use-make-request nick newnick)
>        (erc-display-error-notice
>         nil
> @@ -6801,30 +6825,30 @@ erc-channel-receive-names
>           (adm-ch (cdr (assq ?a prefix)))
>           (own-ch (cdr (assq ?q prefix)))
>           (names (delete "" (split-string names-string)))
> -      name op voice halfop admin owner)
> +         name op voice halfop admin owner)
>      (let ((erc-channel-members-changed-hook nil))
>        (dolist (item names)
>          (let ((updatep t)
> -           (ch (aref item 0)))
> +              (ch (aref item 0)))
>            (setq name item op 'off voice 'off halfop 'off admin 'off owner 
> 'off)
>            (if (rassq ch prefix)
>                (if (= (length item) 1)
> -               (setq updatep nil)
> -             (setq name (substring item 1))
> -             (setf (pcase ch
> -                     ((pred (eq voice-ch)) voice)
> -                     ((pred (eq hop-ch))   halfop)
> -                     ((pred (eq op-ch))    op)
> -                     ((pred (eq adm-ch))   admin)
> -                     ((pred (eq own-ch))   owner)
> -                     (_ (message "Unknown prefix char `%S'" ch) voice))
> -                   'on)))
> +                  (setq updatep nil)
> +                (setq name (substring item 1))
> +                (setf (pcase ch
> +                        ((pred (eq voice-ch)) voice)
> +                        ((pred (eq hop-ch))   halfop)
> +                        ((pred (eq op-ch))    op)
> +                        ((pred (eq adm-ch))   admin)
> +                        ((pred (eq own-ch))   owner)
> +                        (_ (message "Unknown prefix char `%S'" ch) voice))
> +                      'on)))
>            (when updatep
> -         ;; If we didn't issue the NAMES request (consider two clients
> -         ;; talking to an IRC proxy), `erc-channel-begin-receiving-names'
> -         ;; will not have been called, so we have to do it here.
> -         (unless erc-channel-new-member-names
> -           (erc-channel-begin-receiving-names))
> +            ;; If we didn't issue the NAMES request (consider two clients
> +            ;; talking to an IRC proxy), `erc-channel-begin-receiving-names'
> +            ;; will not have been called, so we have to do it here.
> +            (unless erc-channel-new-member-names
> +              (erc-channel-begin-receiving-names))
>              (puthash (erc-downcase name) t
>                       erc-channel-new-member-names)
>              (erc-update-current-channel-member
> @@ -7767,7 +7791,7 @@ erc-send-current-line
>    (let ((now (current-time)))
>      (if (or (not erc-accidental-paste-threshold-seconds)
>              (time-less-p erc-accidental-paste-threshold-seconds
> -                      (time-subtract now erc-last-input-time)))
> +                         (time-subtract now erc-last-input-time)))
>          (save-restriction
>            ;; If there's an abbrev at the end of the line, expand it.
>            (when (and abbrev-mode
> @@ -7909,8 +7933,8 @@ erc-send-input
>        (defvar str))
>      (let ((str input)
>            (erc-insert-this t)
> -       (erc-send-this t)
> -       state)
> +          (erc-send-this t)
> +          state)
>        ;; The calling convention of `erc-send-pre-hook' is that it
>        ;; should change the dynamic variable `str' or set
>        ;; `erc-send-this' to nil.  This has now been deprecated:
> @@ -7918,8 +7942,8 @@ erc-send-input
>        ;; allow both changing and suppressing the string.
>        (run-hook-with-args 'erc-send-pre-hook input)
>        (setq state (make-erc-input :string str ;May be != from `input' now!
> -                               :insertp erc-insert-this
> -                               :sendp erc-send-this))
> +                                  :insertp erc-insert-this
> +                                  :sendp erc-send-this))
>        (run-hook-with-args 'erc-pre-send-functions state)
>        (when (and (erc-input-sendp state)
>                   erc-send-this)
> -- 
> 2.39.2





reply via email to

[Prev in Thread] Current Thread [Next in Thread]