emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Dokos <ndokos@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: org-ctags land grab
Date: Thu, 23 Mar 2023 01:14:29 -0400	[thread overview]
Message-ID: <87jzz8f3re.fsf@alphaville.usersys.redhat.com> (raw)
In-Reply-To: 87pm91ngb8.fsf@localhost

Ihor Radchenko <yantar92@posteo.net> writes:

> Nick Dokos <ndokos@gmail.com> writes:
>
>> `org-ctags' unilaterally sets the hook `org-open-link-functions' to a
>> bunch of org-ctags functions and enables itself by default. That has
>> the unfortunate consequence of invalidating the documentation for
>> internal CUSTOM_ID links - see
>>
>> https://emacs.stackexchange.com/questions/76351/how-to-follow-an-internal-link-in-recent-org-mode
>
> As documented in the top comment of org-ctags.el, the default behaviour
> of C-c C-o is modified as you observe:
>
>     ;; By default, with org-ctags loaded, org will first try and visit the tag
>     ;; with the same name as the link; then, if unsuccessful, ask the user if
>     ;; he/she wants to rebuild the 'TAGS' database and try again; then ask if
>     ;; the user wishes to append 'tag' as a new toplevel heading at the end of
>     ;; the buffer; and finally, defer to org's default behavior which is to
>     ;; search the entire text of the current buffer for 'tag'.
>
>> I proposed a work-around, but it seems to me that `org-ctags'
>> functionality should be opt-in and there should be a way to turn it
>> off.
>
> It is off by default.

It is off until org-ctags is loaded. *When* it is loaded, it runs
`(org-ctags-enable)' and the behavior changes.

Now I'm not loading it explicitly, but nevertheless, *somebody* does
because it goes ahead and mucks with my `org-open-link-functions'.
One clue was that it does not happen in 28.2 (which is the version
in Fedora 36 and 37) but it *does* happen in a 30.0.50 Emacs built
from upstream sources.

So I ran some tests, all with -Q so my init file is out of the
picture.

It turns out that it is enough to ask for help on an Org variable to
have `org-ctags' loaded!  I put a watch on `org-open-link-functions'
and did `C-h v org-latex-pdf-process': it stopped once on setting it to
nil and it stopped again with this backtrace (I elided long lines but I left
the relevant portion of the one that mentions `org-ctags'):



--8<---------------cut here---------------start------------->8---
Debugger entered--setting org-open-link-functions to (org-ctags-find-tag): 
  debug--implement-debug-watch(org-open-link-functions (org-ctags-find-tag) set nil)
  set-default(org-open-link-functions (org-ctags-find-tag))
  add-hook(org-open-link-functions org-ctags-find-tag t)
  org-ctags-enable()
  byte-code("\300 \210\301\302!\207" [org-ctags-enable provide org-ctags] 2)
  load("org-ctags" noerror nomessage)
  help--load-prefixes((("org-" "ox-latex" "ox" "org-src" "org-refile" "org-protocol" "org-plot" "org-pcomplete" "org-mouse" "org-macs" "org-list" "org-keys" "org-habit" "org-faces" "org-ctags" ...
  help--symbol-completion-table("org-latex-pdf-process" ...
  test-completion("org-latex-pdf-process" help--symbol-completion-table ...
  completion--complete-and-exit(20 41 exit-minibuffer ...
  completion-complete-and-exit(20 41 exit-minibuffer)
  minibuffer-complete-and-exit()
  funcall-interactively(minibuffer-complete-and-exit)
  call-interactively(minibuffer-complete-and-exit nil nil)
  command-execute(minibuffer-complete-and-exit)
  read-from-minibuffer("Describe variable: " nil ...
  completing-read-default("Describe variable: " help--symbol-completion-table ...
  completing-read("Describe variable: " help--symbol-completion-table ...
  byte-code(...
  call-interactively(describe-variable nil nil)
  command-execute(describe-variable)
--8<---------------cut here---------------end--------------->8---

As you see, `help--load-prefixes' loads `org-ctags'. If you look at
the `help-definition-prefixes' radix tree, `org-ctags' is subsumed
under the `org-' prefix, so any lookup with that prefix will end up
loading it (and therefore enabling it). The reason it does not happen
in 28.2 is that it is only under the `org-ctags` prefix.

It seems to me that `org-ctags' should be registered under the
`org-ctags' prefix only, just like in 28.2 (the registration is in
`org-loaddefs.el' but I don't know how it ends up there. I guess
`org-fixup.el' is doing it, but I didn't chase it any further).

I also think that loading `org-ctags' should not automatically enable
it: it should require the user to explicitly run `org-ctags-enable' to
do that. That way, if there is a mechanism that loads it
surreptitiously, it wouldn't cause the confusion that it causes
now. That would require documentation changes, but it would avoid
unpleasant surprises, and preserve some toes even if users load it
accidentally. Eventually, it might be nice to provide a disabling
function as well, although the workaround in the SE post works well
enough for now. Maybe the thing to do is to turn it into a proper
minor mode.

Thoughts?

-- 
Nick



  reply	other threads:[~2023-03-23  5:15 UTC|newest]

Thread overview: 112+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-21  3:36 org-ctags land grab Nick Dokos
2023-03-21 16:40 ` Rudolf Adamkovič
2023-03-22 12:03 ` Ihor Radchenko
2023-03-23  5:14   ` Nick Dokos [this message]
2023-03-23 10:49     ` Ihor Radchenko
2023-03-23 14:50       ` Max Nikulin
2023-03-25 17:45         ` [POLL] Should we accept breaking changes to get rid of Org libraries that perform side effects when loading? (was: org-ctags land grab) Ihor Radchenko
2023-03-27 15:14           ` [POLL] Should we accept breaking changes to get rid of Org libraries that perform side effects when loading? Max Nikulin
2023-03-28 10:02             ` Ihor Radchenko
2023-03-27 16:10           ` [POLL] Should we accept breaking changes to get rid of Org libraries that perform side effects when loading? (was: org-ctags land grab) Dr. Arne Babenhauserheide
2023-03-28  9:55             ` Ihor Radchenko
2023-08-08  4:19           ` [POLL] Should we accept breaking changes to get rid of Org libraries that perform side effects when loading? Bastien Guerry
2023-08-08  8:48             ` Ihor Radchenko
2023-08-08 13:29               ` Bastien Guerry
2023-08-09  7:48                 ` Max Nikulin
2023-08-10 19:50                   ` Nick Dokos
2023-08-11  7:36                     ` Ihor Radchenko
2023-08-11  9:44                 ` Ihor Radchenko
2023-08-12 12:46                   ` Bastien Guerry
2023-08-12 22:18                     ` Samuel Wales
2023-08-13  8:59                       ` Ihor Radchenko
2023-08-14  0:57                         ` Samuel Wales
2023-08-14 10:34                           ` Ihor Radchenko
2023-08-14 13:19                       ` Fraga, Eric
2023-08-22 15:15                         ` Bastien Guerry
2023-08-23  9:33                           ` Ihor Radchenko
2023-08-24 11:39                             ` Bastien Guerry
2023-08-24 11:44                               ` Ihor Radchenko
2023-08-24 12:08                                 ` Bastien Guerry
2023-08-24 12:15                                   ` Ihor Radchenko
2023-08-24 12:36                                     ` Bastien Guerry
2023-08-24 12:40                                       ` Ihor Radchenko
2023-08-24 12:48                                         ` Bastien Guerry
2023-08-24 12:56                                           ` Ihor Radchenko
2023-08-24 13:01                                             ` Russell Adams
2023-08-24 13:33                                               ` Ihor Radchenko
2023-08-24 13:41                                                 ` Russell Adams
2023-08-24 13:47                                                   ` Ihor Radchenko
2023-08-24 13:02                                             ` Bastien Guerry
2023-08-24 13:36                                               ` Ihor Radchenko
2023-08-24 13:43                                                 ` Russell Adams
2023-08-25  9:16                                                   ` Ihor Radchenko
2023-08-24 14:08                                                 ` Bastien Guerry
2023-08-25  2:59                                                   ` spookygostee
2023-08-25  9:53                                                     ` Ihor Radchenko
2023-08-25  9:44                                                   ` [DISCUSSION] Re-design of inlinetasks (was: [POLL] Should we accept breaking changes to get rid of Org libraries that perform side effects when loading?) Ihor Radchenko
2023-08-25 17:58                                                     ` [DISCUSSION] Re-design of inlinetasks Juan Manuel Macías
2023-08-26 10:58                                                       ` Ihor Radchenko
2023-08-26 11:42                                                         ` Juan Manuel Macías
2023-08-26 12:33                                                           ` Ihor Radchenko
2023-08-26 14:21                                                             ` Juan Manuel Macías
2023-08-26 16:33                                                               ` Ihor Radchenko
2023-08-26 17:31                                                                 ` Juan Manuel Macías
2023-08-26 17:43                                                                   ` Ihor Radchenko
2023-08-26 19:19                                                                     ` Juan Manuel Macías
2023-08-27  9:21                                                                       ` Ihor Radchenko
2023-08-27 17:25                                                                         ` Juan Manuel Macías
2023-08-31  9:15                                                                           ` Ihor Radchenko
2023-08-26 18:01                                                                   ` Russell Adams
2023-08-29 13:00                                                                     ` Russell Adams
2023-08-30 11:49                                                                       ` Alain.Cochard
2023-08-30 12:36                                                                         ` Russell Adams
2023-08-30 14:06                                                                           ` Alain.Cochard
2023-08-30 14:31                                                                             ` Russell Adams
2023-08-30 14:39                                                                               ` Alain.Cochard
2023-08-30 15:08                                                                                 ` Russell Adams
2023-08-30 15:13                                                                                   ` Russell Adams
2023-08-30 18:32                                                                                     ` Ihor Radchenko
2023-08-24 12:53                                         ` [POLL] Should we accept breaking changes to get rid of Org libraries that perform side effects when loading? Russell Adams
2023-08-24 13:04                                           ` Ihor Radchenko
2023-08-24 13:11                                             ` Russell Adams
2023-08-24 13:41                                               ` Ihor Radchenko
2023-08-24 13:49                                                 ` Russell Adams
2023-08-25  9:18                                                   ` Ihor Radchenko
2023-08-24 14:20                                                 ` Russell Adams
2023-08-24 13:23                                       ` tomas
2023-08-24 13:29                                         ` Ihor Radchenko
2023-08-24 13:36                                           ` Russell Adams
2023-08-24 13:44                                             ` Ihor Radchenko
2023-08-24 14:00                                               ` Russell Adams
2023-08-25  2:48                                                 ` spookygostee
2023-08-25  9:52                                                 ` Ihor Radchenko
2023-08-24 13:50                                           ` tomas
2023-08-25  9:49                                             ` Ihor Radchenko
2023-08-24 12:11                                 ` Russell Adams
2023-08-24 12:21                                   ` Ihor Radchenko
2023-08-24 14:43                                     ` Max Nikulin
2023-08-24 23:07                                       ` Samuel Wales
2023-08-24 23:23                                         ` Samuel Wales
2023-08-24 23:24                                           ` Samuel Wales
2023-08-25  9:56                                             ` Ihor Radchenko
2023-08-25  9:56                                         ` Ihor Radchenko
2023-08-26  8:59                             ` Fraga, Eric
2023-08-26 12:30                               ` Ihor Radchenko
2023-08-27 13:16                                 ` Fraga, Eric
2023-08-22 15:40                         ` Russell Adams
2023-08-13  8:53                     ` [DISCUSSION] The future of org-mouse.el and org-inlinetask.el (was: [POLL] Should we accept breaking changes to get rid of Org libraries that perform side effects when loading?) Ihor Radchenko
2023-08-13  9:33                       ` [DISCUSSION] The future of org-mouse.el and org-inlinetask.el Bastien Guerry
2023-08-13 10:29                         ` Ihor Radchenko
2023-08-14  7:48                     ` [POLL] Should we accept breaking changes to get rid of Org libraries that perform side effects when loading? Tom Gillespie
2023-08-15 14:10                     ` Timothy
2023-08-15 14:38                       ` Russell Adams
2023-08-15 15:21                         ` Ihor Radchenko
2023-08-15 18:58                           ` Tom Gillespie
2023-08-16 10:24                             ` Ihor Radchenko
2023-08-09 22:30               ` Or probably just fix the org-ctags hook functions? (was: Should we accept breaking changes ...) Jens Schmidt
2023-08-10 19:56                 ` Or probably just fix the org-ctags hook functions? Nick Dokos
2023-08-11  7:37                   ` Ihor Radchenko
2023-08-11 17:01                     ` Nick Dokos
2023-08-11 21:40                       ` Jens Schmidt
2023-08-11 21:48                         ` Ihor Radchenko
2023-08-11 22:43                           ` Jens Schmidt

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.orgmode.org/

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

  git send-email \
    --in-reply-to=87jzz8f3re.fsf@alphaville.usersys.redhat.com \
    --to=ndokos@gmail.com \
    --cc=emacs-orgmode@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/org-mode.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).