From 949f0355446f6a179bd92d1948e65a63ac58f3a5 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Sat, 14 Mar 2026 04:11:51 +0200 Subject: [PATCH] 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 --- etc/NEWS | 8 ++++++++ lisp/progmodes/etags-regen.el | 20 ++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 44b285eafb9..b4a40fc5a50 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -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 diff --git a/lisp/progmodes/etags-regen.el b/lisp/progmodes/etags-regen.el index 3d3ddc0521f..b9cb75358c0 100644 --- a/lisp/progmodes/etags-regen.el +++ b/lisp/progmodes/etags-regen.el @@ -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)))