GNU bug report logs -
#68401
30.0.50; ERC 5.6-git: `erc-cmd-GMSG', `erc-cmd-AMSG', `erc-cmd-GME', `erc-cmd-AME'. 2nd attempt
Previous Next
Reported by: Emanuel Berg <incal <at> dataswamp.org>
Date: Fri, 12 Jan 2024 10:44:01 UTC
Severity: normal
Tags: patch
Merged with 68395
Found in version 30.0.50
Done: "J.P." <jp <at> neverwas.me>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
>>>> (defun erc-drop-leading-whitespace (str)
>>>> (if (string-match "^ \\(.*\\)$" str)
>>>> (match-string 1 str)
>>>> str) )
>>>
>>> Why not use `string-prefix-p' and `substring' to
>>> accomplish this? Also, please name this using the internal
>>> "--" convention, something like
>>> `erc--drop-initial-space-char' or
>>> `erc--drop-single-leading-space'.
>>
>> Good idea to use `string-prefix-p' and `substring', but it
>> hasn't anything to do with ERC at this point - it should be
>> put in some string manipulation library and then ERC should
>> `require' it. [...]
Someone told me (thanks) there is already
a `string-remove-prefix' to do this so that whole thing can
be dropped.
;;; -*- lexical-binding: t -*-
;;
;; this file:
;; https://dataswamp.org/~incal/emacs-init/erc/erc-misc.el
;;
;; Make erc-cmd-AMSG session-local, add /GMSG /AME /GME
;;
;; * lisp/erc/erc.el (erc-cmd-AMSG): Make good on behavior described in
;; the doc string by limiting damage to the current connection.
;; (erc-cmd-GMSG, erc-cmd-GME, erc-cmd-AME): New functions, all IRC
;; "slash commands". (Bug#68401)
(require 'erc)
(defun erc--connected-and-joined-p ()
(and (erc--current-buffer-joined-p)
erc-server-connected))
(defun erc-cmd-GMSG (line)
"Send LINE to all channels on all networks you are on."
(setq line (string-remove-prefix " " line))
(erc-with-all-buffers-of-server nil
(lambda () (erc-channel-p (erc-default-target)))
(when (erc--connected-and-joined-p)
(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.
Interactively, prompt for the line of text to send."
(interactive "sSend to all channels on this network: ")
(setq line (string-remove-prefix " " line))
(erc-with-all-buffers-of-server erc-server-process
(lambda () (erc-channel-p (erc-default-target)))
(when (erc--connected-and-joined-p)
(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."
(erc-with-all-buffers-of-server nil
(lambda () (erc-channel-p (erc-default-target)))
(when (erc--connected-and-joined-p)
(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."
(erc-with-all-buffers-of-server erc-server-process
(lambda () (erc-channel-p (erc-default-target)))
(when (erc--connected-and-joined-p)
(erc-cmd-ME line))))
(put 'erc-cmd-AME 'do-not-parse-args t)
(provide 'erc-misc)
--
underground experts united
https://dataswamp.org/~incal
This bug report was last modified 1 year and 79 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.