all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "J.P." <jp@neverwas.me>
To: Nacho Barrientos <nacho.barrientos@cern.ch>
Cc: 59805@debbugs.gnu.org, emacs-erc@gnu.org, git@david.leatherman.fm
Subject: bug#59805: 28.2; erc-track: handle faces modified with erc-button-add-face
Date: Wed, 07 Dec 2022 06:28:43 -0800	[thread overview]
Message-ID: <87pmcv47ac.fsf__48625.5755111173$1670423360$gmane$org@neverwas.me> (raw)
In-Reply-To: <87tu28fjdz.fsf@cern.ch> (Nacho Barrientos's message of "Tue, 06 Dec 2022 19:56:06 +0100")

Nacho Barrientos <nacho.barrientos@cern.ch> writes:

> Hi J.P.,

Hi Nacho,

>> Looks like the default value of `erc-track-faces-priority-list' contains
>> some composite faces, such as
>>
>>   (erc-nick-default-face erc-current-nick-face)
>>
>> So whatever happens, I think we'll have to preserve compatibility for
>> people already used to searching for such composites.
>
> I was totally unaware that "face composites" were a thing, so
> perhaps my proposal to flatten the return value of `erc-faces-in' does
> not make sense anymore.

FWIW, "composite" was just some term I conjured up to refer to what's
described in the third `face' bullet point of "(elisp) Special
Properties":

  A list of faces.  Each list element should be either a face
  name or an anonymous face.  This specifies a face which is an
  aggregate of the attributes of each of the listed faces.
  Faces occurring earlier in the list have higher priority.

While perhaps less common than lone face names, such values do appear in
the wild, for example, when `whitespace-mode' is active.

> For 2) I don't have an elegant/generic solution to propose, but adding
>
>   (erc-hl-nicks-nick-nacho-face erc-current-nick-face)
>
> to `erc-track-faces-priority-list' can definitely work for me. My
> nickname is stable across networks, however I think that the rather
> valid use case of being notified no matter what your nick name is cannot
> be honoured elegantly when using erc-hl-nicks.

From what I can gather, you still believe this despite the more recent
findings in your followup just below.

> Hi again,
>
> [...]
>
> Actually there's something else that can be done from the erc-hl-nicks
> side, which is:
>
>   (setq erc-hl-nicks-skip-nicks '("nacho"))

Good find!

> Which comes again with the problematic of having to hardcode known nicks
> but it does the job. If that variable is set as indicated above,
> erc-hl-nicks will never create the composite face on the mention and
> hence:
>
>   λ> (erc-faces-in (buffer-substring (point) (+ 1 (point))))
>   (erc-current-nick-face)
>
> (in the example above, `point' is on a mention to the current nick)
>
> Making erc-track's matching work. The current nickname is coloured
> anyway by ERC so if erc-hl-nicks does not act on it should be okay.

Re the "hardcode problem": I'm not sure it's incumbent upon ERC to offer
a solution uniquely tailored to updating `erc-hl-nicks-skip-nicks'
specifically (not that you were suggesting such a thing). However, I do
think the current offering of `erc-nick-changed-functions' has proven
insufficient for servicing a variety of legitimate needs. It only runs
under really specific circumstances, such as when a server-mandated nick
change occurs or a confirmation arrives following a NickServ IDENTIFY
(or similar action). However, it does *not* run on confirmation of a
client-initiated NICK command, whether manually issued by a user or
executed as library code.

Unfortunately, for compatibility reasons, we can't just repurpose
`erc-nick-changed-functions' willy-nilly. Thus, I think introducing a
*new* abnormal hook to be run by `erc-set-current-nick' might be
justified, likely defined as compatible with functions taking a new nick
and giving nothing in return. Users and downstream packages could then
do whatever needs doing in reaction to nick changes, for example:

  (add-hook 'erc-set-current-nick-functions
            (lambda (n)
              (customize-set-variable
               'erc-hl-nicks-skip-nicks
               (cl-pushnew n erc-hl-nicks-skip-nicks :test #'equal))))

> This approach is good enough for me so feel free to close the bug if you
> don't want to go down this rabbit hole further :)

Regardless of this bug's original title, the mission of improving the
user experience remains paramount, wherever that may lead. If you're up
for it, I for one would welcome a patch adding a hook like the one
described above (whenever time allows). Otherwise, we could always just
kick the can down the road and rename this bug to something like "ERC
needs a smarter way to run user code on nick changes" in hopes some
enterprising future person will find it. Either way, I appreciate your
willingness to contribute to ERC.

J.P.





  parent reply	other threads:[~2022-12-07 14:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-03 11:28 bug#59805: 28.2; erc-track: handle faces modified with erc-button-add-face Nacho Barrientos
2022-12-06 14:19 ` J.P.
     [not found] ` <87bkoglilv.fsf@neverwas.me>
2022-12-06 16:06   ` Nacho Barrientos
2022-12-06 18:56     ` Nacho Barrientos
     [not found]     ` <87tu28fjdz.fsf@cern.ch>
2022-12-07 14:28       ` J.P. [this message]
2022-12-12 14:36   ` J.P.
2023-07-29  1:17 ` J.P.

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='87pmcv47ac.fsf__48625.5755111173$1670423360$gmane$org@neverwas.me' \
    --to=jp@neverwas.me \
    --cc=59805@debbugs.gnu.org \
    --cc=emacs-erc@gnu.org \
    --cc=git@david.leatherman.fm \
    --cc=nacho.barrientos@cern.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.