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
J.P. wrote:
>> (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.
(drop-prefix "pre" "prefix") ; fix
But, now I think I've done it all?
Have a look to see if everyone is happy, if so I can start
fiddling with the unit test patch.
(defun drop-prefix (pf str)
(if (string-prefix-p pf str)
(substring str (length pf))
str))
(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 (drop-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 (drop-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)
--
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.