etags-regen: Don't try to generate tags during completion, by default

* etc/NEWS: Describe the change.

* lisp/progmodes/etags-regen.el
(etags-regen-create-on-completion): New option.
(etags-regen-create-on-completion--set): New function.
(etags-regen-mode): Use it.  Discussed in
https://lists.gnu.org/archive/html/emacs-devel/2026-03/msg00405.html
This commit is contained in:
Dmitry Gutov
2026-03-14 04:11:51 +02:00
parent 9dbcb01153
commit 949f035544
2 changed files with 26 additions and 2 deletions

View File

@@ -3763,6 +3763,14 @@ the mode line without polling for changes every
means the mode line will update only when the battery power state,
percentage, or presence in the bay changes.
** Etags Regen mode
*** Tags table is not created during completion anymore.
Previously, when there was no tags table loaded and the default
completion function was called, 'etags-regen-mode' ensured that tags
were created. This has been disabled, and the new user option
'etags-regen-create-on-completion' can be used to enable it again.
* New Modes and Packages in Emacs 31.1

View File

@@ -142,6 +142,21 @@ File extensions to generate the tags for."
(string :tag "Glob to ignore"))
:version "30.1")
(defun etags-regen-create-on-completion--set (symbol value)
(when (and etags-regen-mode value)
(advice-add 'tags-completion-at-point-function :before
#'etags-regen--maybe-generate))
(set-default-toplevel-value symbol value))
(defcustom etags-regen-create-on-completion nil
"Non-nil to ensure tags are created before completion.
This applies to the function `tags-completion-at-point-function', which
is used in buffers that have no alternative completion configured."
:type 'boolean
:set #'etags-regen-create-on-completion--set
:version "31.1")
;;;###autoload
(put 'etags-regen-ignores 'safe-local-variable
(lambda (value) (and (listp value) (seq-every-p #'stringp value))))
@@ -471,8 +486,9 @@ to countermand the effect of a previous \\[visit-tags-table]."
(progn
(advice-add 'etags--xref-backend :before
#'etags-regen--maybe-generate)
(advice-add 'tags-completion-at-point-function :before
#'etags-regen--maybe-generate))
(when etags-regen-create-on-completion
(advice-add 'tags-completion-at-point-function :before
#'etags-regen--maybe-generate)))
(advice-remove 'etags--xref-backend #'etags-regen--maybe-generate)
(advice-remove 'tags-completion-at-point-function #'etags-regen--maybe-generate)
(etags-regen--tags-cleanup)))