emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/auctex 1a53b23645 3/8: Add completion annotation suppor


From: Tassilo Horn
Subject: [elpa] externals/auctex 1a53b23645 3/8: Add completion annotation support from LaTeX-math-list/default
Date: Tue, 28 Dec 2021 04:06:01 -0500 (EST)

branch: externals/auctex
commit 1a53b236458d195eb7a664a1b645cdfcb96494c8
Author: Tassilo Horn <tsdh@gnu.org>
Commit: Tassilo Horn <tsdh@gnu.org>

    Add completion annotation support from LaTeX-math-list/default
    
    * latex.el (LaTeX--completion-annotation-from-math-menu): New
    function.
    * tex.el (TeX--completion-annotation-function): Use it if bound.
---
 latex.el | 14 ++++++++++++++
 tex.el   |  5 ++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/latex.el b/latex.el
index 6d25559105..e1f217f9ca 100644
--- a/latex.el
+++ b/latex.el
@@ -5762,6 +5762,20 @@ See also `LaTeX-math-menu'."
                                 (const :tag "none" nil)
                                 (integer :tag "Number")))))
 
+(defun LaTeX--completion-annotation-from-math-menu (sym)
+  "Return a completion annotation for a SYM.
+The annotation is usually a unicode representation of the macro
+SYM's compiled representation, e.g., if SYM is alpha, α is
+returned."
+  (catch 'found
+    (dolist (var (list LaTeX-math-list LaTeX-math-default))
+      (dolist (e var)
+        (when (string= (cadr e) sym)
+          (let ((char (nth 3 e)))
+            (when char
+              (throw 'found
+                     (concat " " (char-to-string char))))))))))
+
 (defvar LaTeX-math-mode-menu)
 (define-minor-mode LaTeX-math-mode
   "A minor mode with easy access to TeX math macros.
diff --git a/tex.el b/tex.el
index 8acd12f8d3..a1e3b17223 100644
--- a/tex.el
+++ b/tex.el
@@ -3247,7 +3247,10 @@ Or alternatively:
 Used as `:annotation-function' in `completion-extra-properties'."
   (let ((ann (cdr (assoc (concat "\\" sym)
                          tex--prettify-symbols-alist))))
-    (when ann (concat " " (char-to-string ann)))))
+    (if ann
+        (concat " " (char-to-string ann))
+      (when (fboundp #'LaTeX--completion-annotation-from-math-menu)
+        (LaTeX--completion-annotation-from-math-menu sym)))))
 
 (defun TeX--completion-at-point ()
   "(La)TeX completion at point function.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]