Hi all, the attached patch adds support for activating a TeX-doc backend in all modes, by adding `t' to the list which specifies which modes to use it in.
A use case. I have been doing a lot of (for me) advanced LaTeX work recently, and frequently find myself looking up references in several manuals at once, or keeping notes in an org/markdown/scratch buffer. TeX Doc is very useful in for this, but I don't get the backend completion I would in a LaTeX buffer. I could add all the relevant modes to the backend list manually, but then if I encounter some niche new usecase, I will have to manually support that as well. It seemed useful to me to have a way of just activating a backend in all modes. Which modes have which backends by default has been left unchanged, on the assumption that the current way is best for most users. I couldn't find a CONTRIBUTING doc or similar, so sorry if I've not hit all the commit conventions. Would be happy to reformat if necessary. I have contributed to Emacs before, so I've assigned copyright to the FSF already, if relevant. best, Hugo
From 1dc48e6570db17ef190b8deb8b666130fe52f4eb Mon Sep 17 00:00:00 2001 From: Hugo Heagren <h...@heagren.com> 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..4a86aa4 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 a list of modes the backend should be activated in. The +symbol `t' 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 (memq major-mode (nth 1 elt)) + (memq t (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