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

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

[elpa] externals/auctex d68d9ad279 7/8: Merge remote-tracking branch 'or


From: Tassilo Horn
Subject: [elpa] externals/auctex d68d9ad279 7/8: Merge remote-tracking branch 'origin/master' into externals/auctex
Date: Tue, 28 Dec 2021 04:06:02 -0500 (EST)

branch: externals/auctex
commit d68d9ad2790f8b07bc0ec7e2aa6854035b585815
Merge: 1b05afe088 3cf393d43d
Author: Tassilo Horn <tsdh@gnu.org>
Commit: Tassilo Horn <tsdh@gnu.org>

    Merge remote-tracking branch 'origin/master' into externals/auctex
---
 latex.el          | 14 ++++++++++++++
 latex/preview.dtx | 35 +++++++++++++++++++++++++++++++----
 style/stabular.el | 11 +++++++++++
 tex.el            | 54 ++++++++++++++++++++++++++++++++++++++++++------------
 4 files changed, 98 insertions(+), 16 deletions(-)

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/latex/preview.dtx b/latex/preview.dtx
index ff686cef7c..4ecaaab2f4 100644
--- a/latex/preview.dtx
+++ b/latex/preview.dtx
@@ -20,7 +20,7 @@
 %     Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 %     Boston, MA 02110-1301  USA
 % \fi
-% \CheckSum{1760}
+% \CheckSum{1794}
 % \GetFileInfo{preview.sty}
 % \date{\filedate}
 % \author{David Kastrup\thanks{\texttt{bug-auctex@gnu.org}}}
@@ -781,14 +781,41 @@
 % pretty much the same as in |everyshi.sty|.  One of its implications
 % is that if someone does a \cmd{\shipout} of a \emph{void} box,
 % things will go horribly wrong.
-% \begin{macro}{\shipout}
+% \begin{macro}{\pr@@shipout}
 %    \begin{macrocode}
-\let\pr@shipout=\shipout
-\def\shipout{\deadcycles\z@\bgroup\setbox\z@\box\voidb@x
+\def\pr@@shipout{\deadcycles\z@\bgroup\setbox\z@\box\voidb@x
   \afterassignment\pr@shipoutegroup\setbox\z@}
 \def\pr@shipoutegroup{\ifvoid\z@ \expandafter\aftergroup\fi \egroup}
 %    \end{macrocode}
 % \end{macro}
+% \begin{macro}{\pr@shipout}
+%   We now need to check which command we are replacing.  Before
+%   things got sophisticated in 2020 or 2021, this had been
+%   \cmd{\shipout} but now it could be \cmd{\tex\_shipout:D}.  \LaTeX\
+%   got a hook mechanism for managing output routines, but it doesn't
+%   really work well for wholesale replacement of the \cmd{\shipout}
+%   command like |preview| does.
+%    \begin{macrocode}
+\ifx\shipout\@undefined
+  \begingroup
+  \catcode`\:=10
+  \catcode`\_=10
+  \ifx\tex_shipout:D\@undefined
+    \PackageError{preview}{Cannot find \protect\shipout\space primitive}%
+    {preview needs to replace the \protect\shipout\space primitive with
+      its own routine to do its work.  Due to packages or formats
+      interfering, it cannot be identified.  Please report this.}
+  \else
+    \global\let\pr@shipout=\tex_shipout:D
+    \global\let\tex_shipout:D=\pr@@shipout
+  \fi
+  \endgroup
+\else
+  \let\pr@shipout=\shipout
+  \let\shipout=\pr@@shipout
+\fi
+%    \end{macrocode}
+% \end{macro}
 % \subsection{Parsing commands}
 % \begin{macro}{\pr@parseit}
 % \begin{macro}{\pr@endparse}
diff --git a/style/stabular.el b/style/stabular.el
index 5f3ca02dd8..4b4eb96ed6 100644
--- a/style/stabular.el
+++ b/style/stabular.el
@@ -47,6 +47,17 @@
     '("stabular" LaTeX-env-array)
     '("stabular*" LaTeX-env-tabular*))
 
+   ;; Use the enhanced tabular indentation.  Append to
+   ;; `LaTeX-indent-environment-list' in order not to override custom
+   ;; settings.
+   (make-local-variable 'LaTeX-indent-environment-list)
+   (add-to-list 'LaTeX-indent-environment-list
+                '("stabular" LaTeX-indent-tabular)
+                t)
+   (add-to-list 'LaTeX-indent-environment-list
+                '("stabular*" LaTeX-indent-tabular)
+                t)
+
    ;; Append the environments to `LaTeX-item-list':
    (add-to-list 'LaTeX-item-list
                 '("stabular" . LaTeX-item-array)
diff --git a/tex.el b/tex.el
index ab6d3d9e78..3cf8f65ec2 100644
--- a/tex.el
+++ b/tex.el
@@ -3133,9 +3133,10 @@ Possible values are nil, t, or a list of style names.
 
 (defmacro TeX-complete-make-expert-command-functions (thing list-var prefix)
   (let* ((plural (concat thing "s"))
-         (upcase-plural (upcase plural)))
+         (upcase-plural (upcase plural))
+         (table-var (intern (format "%s-expert-%s-table" prefix thing))))
     `(progn
-       (defvar ,(intern (format "%s-expert-%s-table" prefix thing))
+       (defvar ,table-var
          (make-hash-table :test #'equal)
          ,(format "A hash-table mapping %s names to the style name providing 
it.
 
@@ -3149,8 +3150,8 @@ Expert %s are completed depending on 
`TeX-complete-expert-commands'."
                   upcase-plural plural plural)
          (dolist (x ,(intern plural))
            (if (null style)
-               (remhash x TeX-expert-macro-table)
-             (puthash x style TeX-expert-macro-table))))
+               (remhash x ,table-var)
+             (puthash x style ,table-var))))
 
        (defun ,(intern (format "%s-filtered" list-var)) ()
          ,(format "Filter (%s) depending on `TeX-complete-expert-commands'."
@@ -3161,7 +3162,7 @@ Expert %s are completed depending on 
`TeX-complete-expert-commands'."
                   (if (eq t TeX-complete-expert-commands)
                       entry
                     (let* ((cmd (car entry))
-                           (style (gethash cmd TeX-expert-macro-table)))
+                           (style (gethash cmd ,table-var)))
                       (when (or (null style)
                                 (member style TeX-complete-expert-commands))
                         entry))))
@@ -3242,6 +3243,23 @@ Or alternatively:
                                          (all-completions symbol list nil)))))
         (funcall (nth 1 entry))))))
 
+(defun TeX--completion-annotation-from-tex--prettify-symbols-alist (sym)
+  (when (boundp 'tex--prettify-symbols-alist)
+    (let ((ann (cdr (assoc (concat "\\" sym)
+                           tex--prettify-symbols-alist))))
+      (when ann
+        (concat " " (char-to-string ann))))))
+
+(declare-function LaTeX--completion-annotation-from-math-menu
+                  "latex" (sym))
+
+(defun TeX--completion-annotation-function (sym)
+  "Annotation function for symbol/macro completion.
+Used as `:annotation-function' in `completion-extra-properties'."
+  (or (TeX--completion-annotation-from-tex--prettify-symbols-alist sym)
+      (and (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.
 See `completion-at-point-functions'."
@@ -3253,7 +3271,9 @@ See `completion-at-point-functions'."
                  (end (match-end sub))
                  (symbol (buffer-substring-no-properties begin end))
                  (list (funcall (nth 2 entry))))
-            (list begin end (all-completions symbol list)))
+            (list begin end (all-completions symbol list)
+                  :annotation-function
+                  #'TeX--completion-annotation-function))
         ;; We intentionally don't call the fallback completion functions 
because
         ;; they do completion on their own and don't work too well with things
         ;; like company-mode.  And the default function `ispell-complete-word'
@@ -3322,6 +3342,12 @@ The variable will be temporarily let-bound with the 
necessary value.")
 
 (defvar TeX-macro-history nil)
 
+(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 +3359,16 @@ 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--completion-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))))



reply via email to

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