[Top][All Lists]

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

Re: my:erc-predicate

From: J.P.
Subject: Re: my:erc-predicate
Date: Mon, 09 Oct 2023 16:32:02 -0700
User-agent: Gnus/5.13 (Gnus v5.13)

Corwin Brust <corwin@bru.st> writes:

> Answering my own question here (maybe correctly, even!)...
> On Fri, Oct 6, 2023 at 10:59 AM Corwin Brust <corwin@bru.st> wrote:
>  I'm using a custom command to clear my tracking indicators from modelines.
>  Does it seem "normal" to have a custom predicate for finding the right
>  buffer or did I miss core functionality I should use instead?

You can call `erc-get-buffer' with `erc-server-process' as the PROC
argument to find a target buffer belonging to the same network process.
The macro `erc-with-buffer' does exactly that, except it (optionally)
specifies the current `erc-server-process' for you.

  (erc-with-buffer ("#chan") (do-something))

Your `my:erc-predicate' also checks for network process connectivity,
which is something `erc-get-buffer' doesn't do. Basically, anything
built atop `erc-buffer-filter' (usually) works when offline because
`erc-server-process' should still be the same object in all buffers
associated with the (disconnected) server session. But if network
connectivity is important, you could use

  (erc-buffer-filter #'my:erc:predicate erc-server-process)

for the (seq-find ...) part of `erc-connected-p', but you'd obviously
need to tweak `my:erc-predicate' so it defaults to the current buffer
when there's no argument.

> I believe I should be using `erc-default-target' to direct an "it
> worked" message to the correct buffer following an ERC command.
> Gotchas here?

You can also use the symbol `active' as the BUFFER argument to
`erc-display-line' to make it reuse the most recent buffer to have
inserted a message during the session. When disconnected, this is most
often the server buffer.

reply via email to

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