[Top][All Lists]

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

Re: bug#68401: 30.0.50; ERC 5.6-git: `erc-cmd-GMSG', `erc-cmd-AMSG', `er

From: Emanuel Berg
Subject: Re: bug#68401: 30.0.50; ERC 5.6-git: `erc-cmd-GMSG', `erc-cmd-AMSG', `erc-cmd-GME', `erc-cmd-AME'. 2nd attempt
Date: Mon, 22 Jan 2024 20:23:17 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

>>>> It might be nice to remove at most one space, for cases
>>>> where a user wants to send preformatted text. OTOH,
>>>> normal /MSG doesn't do this, so perhaps we shouldn't
>>>> here either.
>>> Again, this is in the original `erc-cmd-AMSG'. I have no
>>> opinion, so you can decide it.
>>> "At most one space", what space should that be?
>>> Leading or trailing?
>> Leading. See the test for `erc-extract-command-from-line'
>> to understand the behavior of `do-not-parse-args', which
>> determines LINE. Actually, if we're doing away with
>> `commandp', there should be no reason for "at most one,"
>> only "exactly one" (IIRC).
> So if and only if the initial char is a whitespace, it, and
> only it, should be dropped. E.g. " line string " should be
> transformed into " line string ".

(defun erc-drop-leading-whitespace (str)
  (if (string-match " \\(.*\\)" str)
      (match-string 1 str)
    str) )

>>>> Without first checking for connectivity, we run into
>>>> another situation in which messages may be inserted but
>>>> not sent, similar to the bit about commands being
>>>> potentially "misleading," above. The most obvious way to
>>>> solve this is to check for "physical" connectivity with
>>>> something like:
>>>>   (erc-with-all-buffers-of-server nil #'erc-server-process-alive
>>>>     (when (and erc--target (erc--current-buffer-joined-p))
>>>>       (erc-send-message line))))

If we can drop `erc--target' in the latest Emacs source as you
say that means there is only this left

  (and (erc-server-process-alive) (erc--current-buffer-joined-p))

>>>> Alternatively, you can check for "logical" connectivity,
>>>> which is probably more in keeping with traditional design
>>>> principles:
>>>>   (erc-with-all-buffers-of-server nil nil
>>>>     (when (and erc-server-connected erc--target 
>>>> (erc--current-buffer-joined-p))
>>>>       (erc-send-message line))))

If we again can drop `erc--target' and want
`erc-server-connected' to be returned upon success we can do

  (and (erc--current-buffer-joined-p) erc-server-connected)

If we unify those two tests it will be

(defun erc-connected-and-joined-p ()
  (and (erc-server-process-alive)

underground experts united

reply via email to

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