unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Jim Porter <jporterbugs@gmail.com>, 66752@debbugs.gnu.org, tsdh@gnu.org
Subject: bug#66752: 30.0.50; [PATCH] Add support for 'thing-at-point' to 'bug-reference-mode'
Date: Sun, 05 Nov 2023 18:20:29 -0500	[thread overview]
Message-ID: <jwvr0l36bxa.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <83fs1k4vgt.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 05 Nov 2023 07:31:30 +0200")

>> I'm not sure. The only example I saw for adding to
>> 'thing-at-provider-alist' was for EWW (a major mode).  I thought, "What
>> if someone activated and deactivated 'bug-reference-mode' and then later
>> added something to the default value of 'thing-at-provider-alist'?"

It's a general problem we have in Emacs, indeed.  We have solutions for
it for the specific case of hooks (with `add/remove-hook` and their
`local` argument), and for variables holding functions (with
`add-function`), but not for anything else :-(

I've played with the idea of adding a new set of functions to help
major&minor modes set variables in a more declarative way, so that any
sequence of enabling/disabling or major/minor modes would still result
in "the right" value, and I even have some basic PoC code but nothing
good enough for `master`.

The basic idea would be something like:

   (changevar-add VAR FUNCTION &optional ID LOCAL PRIO)
   (changevar-remove VAR FUNCTION-OR-ID &optional LOCAL)

where `changevar-add` conceptually does something akin to

    (set VAR (funcall FUNCTION (symbol-value VAR)))

and you use `changevar-remove` to set it back to its "previous" value.

But as it stands, you're trying to solve a problem in your code which
affects pretty much every other minor mode out there, so I think it's OK
to just disregard the problem, like everyone else has done until now.
Maybe you can even get away with modifying the variable globally and
not removing the entry when the mode is disabled.


        Stefan






  parent reply	other threads:[~2023-11-05 23:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-25 22:33 bug#66752: 30.0.50; [PATCH] Add support for 'thing-at-point' to 'bug-reference-mode' Jim Porter
2023-11-04  8:12 ` Eli Zaretskii
2023-11-04 19:24 ` Tassilo Horn
2023-11-04 20:07   ` Jim Porter
2023-11-05  5:31     ` Eli Zaretskii
2023-11-05  6:21       ` Jim Porter
2023-11-05 14:19         ` Stefan Kangas
2023-11-05 23:20       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-11-06  4:55         ` Jim Porter
2023-11-12  5:41           ` Jim Porter

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=jwvr0l36bxa.fsf-monnier+emacs@gnu.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=66752@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=jporterbugs@gmail.com \
    --cc=monnier@iro.umontreal.ca \
    --cc=tsdh@gnu.org \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).