Hi Ikumi, On 2025-02-12 09:47, Ikumi Keita wrote:
I basically agree with your idea to use symbol `t` for "all modes". Inthat case it isn't much meaningful to "add" t to the mode list; the rest of the elements are totally useless. Instead of a list, we can just havea single `t' for that purpose. Then we can simplify the conditional as (or (eq t (nth 1 elt) (memq major-mode (nth 1 elt)) How about this idea? (If you are fine with it, please adjust the doc string as well.)
Completely agree. New patch attached. Hugo
From d2b1e0b3c8fc81336cbc09dcca83721ce4d6514f Mon Sep 17 00:00:00 2001 From: Hugo Heagren <[email protected]> Date: Tue, 11 Feb 2025 11:10:09 +0000 Subject: [PATCH] Allow `t' in `TeX-doc-backend-alist' to mean `use in all modes' * tex.el (TeX-doc): Support using `t' in `TeX-doc-backend-alist' backend mode list to mean that a backend should be available in all modes. (TeX-doc-backend-alist): Document change. --- tex.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tex.el b/tex.el index 59a3314..39a21eb 100644 --- a/tex.el +++ b/tex.el @@ -6715,7 +6715,8 @@ (defvar TeX-doc-backend-alist The first is a symbol describing the backend's name. -The second is a list of modes the backend should be activated in. +The second is either a list of modes the backend should be activated in, +or the symbol `t', which stands for all modes. The third is a function returning a list of documents available to the backend. It should return nil if the backend is not @@ -6733,7 +6734,8 @@ (defun TeX-doc (&optional name) (let (docs) ;; Build the lists of available documentation used for completion. (dolist (elt TeX-doc-backend-alist) - (when (memq major-mode (nth 1 elt)) + (when (or (eq t (nth 1 elt) + (memq major-mode (nth 1 elt)))) (let ((completions (funcall (nth 2 elt)))) (unless (null completions) (cl-pushnew (cons completions (nth 0 elt)) docs :test #'equal))))) -- 2.39.5
