auctex
[Top][All Lists]
Advanced

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

Re: Feature request: Show the characters corresponding to the LaTeX comm


From: Tassilo Horn
Subject: Re: Feature request: Show the characters corresponding to the LaTeX commands displayed in minibuffer.
Date: Tue, 21 Dec 2021 06:57:54 +0100
User-agent: mu4e 1.7.5; emacs 29.0.50

Hongyi Zhao <hongyi.zhao@gmail.com> writes:

>> Could someone here give a minimal working example for the question
>> discussed here with `completion-table-dynamic'?
>
> I found an example here [1], but I still can't figure out how to
> modify it to meet the problems discussed in this topic:

Here's a patch against tex.el which provides the basic skeleton.  What's
missing in the actual TeX-symbol name -> unicode character translation
which TeX--symbol-annotation-function is supposed to do.  Right now, it
just emits the annotation TODO.

--8<---------------cut here---------------start------------->8---
@@ -3322,6 +3322,17 @@ The variable will be temporarily let-bound with the 
necessary value.")
 
 (defvar TeX-macro-history nil)
 
+(defun TeX--symbol-annotation-function (_sym)
+  "Annotation function for symbol/macro completion.
+Used as `:annotation-function' in `completion-extra-properties'."
+  "\tTODO")
+
+(defun TeX--symbol-completion-table ()
+  (completion-table-dynamic
+   (lambda (_str)
+     (TeX-symbol-list-filtered))
+   t))
+
 (defun TeX-insert-macro (symbol)
   "Insert TeX macro SYMBOL with completion.
 
@@ -3333,12 +3344,15 @@ is called with \\[universal-argument]."
   ;; details.  Note that this behavior may be changed in favor of a more
   ;; flexible solution in the future, therefore we don't document it at the
   ;; moment.
-  (interactive (list (completing-read (concat "Macro (default "
-                                              TeX-default-macro
-                                              "): "
-                                              TeX-esc)
-                                      (TeX-symbol-list-filtered) nil nil nil
-                                      'TeX-macro-history TeX-default-macro)))
+  (interactive (list
+                (let ((completion-extra-properties
+                       (list :annotation-function 
#'TeX--symbol-annotation-function)))
+                  (completing-read (concat "Macro (default "
+                                           TeX-default-macro
+                                           "): "
+                                           TeX-esc)
+                                   (TeX--symbol-completion-table) nil nil nil
+                                   'TeX-macro-history TeX-default-macro))))
   (when (called-interactively-p 'any)
     (setq TeX-default-macro symbol))
   (TeX-parse-macro symbol (cdr-safe (assoc symbol (TeX-symbol-list))))
--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo



reply via email to

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