auctex-diffs
[Top][All Lists]
Advanced

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

[AUCTeX-diffs] GNU AUCTeX branch, master, updated. 377a97a2434fab69bf9e9


From: Tassilo Horn
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. 377a97a2434fab69bf9e91457de94ad33c09b548
Date: Wed, 4 Jan 2017 09:10:00 +0000 (UTC)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU AUCTeX".

The branch, master has been updated
       via  377a97a2434fab69bf9e91457de94ad33c09b548 (commit)
      from  436371c63da26af56ea076bce8636dcb41fcdfd1 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 377a97a2434fab69bf9e91457de94ad33c09b548
Author: Tassilo Horn <address@hidden>
Date:   Wed Jan 4 10:06:55 2017 +0100

    Completion for math macros
    
    * latex.el (LaTeX--after-math-macro-prefix-p): New function.
    (LaTeX-common-initialization): Use it for new TeX-complete-list entry.
    * tex.el (TeX-complete-list): Also allow match-data setting predicates in
    entries.
    (TeX-complete-symbol,TeX--completion-at-point): Adapt to new possibility.

diff --git a/latex.el b/latex.el
index e5601fb..6960749 100644
--- a/latex.el
+++ b/latex.el
@@ -5966,6 +5966,17 @@ i.e. you do _not_ have to cater for this yourself by 
adding \\\\' or $."
   :type '(repeat regexp)
   :group 'TeX-command)
 
+(defun LaTeX--after-math-macro-prefix-p ()
+  "Return non-nil if point is after a macro prefix in math mode.
+Also sets `match-data' so that group 1 is the already typed
+prefix.
+
+For example, in $a + \a| - 17$ with | denoting point, the
+function would return non-nil and `(match-string 1)' would return
+\"a\" afterwards."
+  (and (texmathp)
+       (TeX-looking-at-backward "\\\\\\([a-zA-Z]*\\)")))
+
 (defun LaTeX-common-initialization ()
   "Common initialization for LaTeX derived modes."
   (VirTeX-common-initialization)
@@ -6038,7 +6049,12 @@ i.e. you do _not_ have to cater for this yourself by 
adding \\\\' or $."
                  ("\\\\renewenvironment\\*?{\\([A-Za-z]*\\)"
                   1 LaTeX-environment-list-filtered "}")
                   ("\\\\\\(this\\)?pagestyle{\\([A-Za-z]*\\)"
-                  2 LaTeX-pagestyle-list "}"))
+                  2 LaTeX-pagestyle-list "}")
+                 (LaTeX--after-math-macro-prefix-p
+                  1 (lambda ()
+                      (append (mapcar #'cadr LaTeX-math-list)
+                              (mapcar #'cadr LaTeX-math-default)))
+                  (if TeX-insert-braces "{}")))
                TeX-complete-list))
 
   (LaTeX-add-environments
diff --git a/tex.el b/tex.el
index ac81b74..894e076 100644
--- a/tex.el
+++ b/tex.el
@@ -3143,8 +3143,10 @@ Expert %s are completed depending on 
`TeX-complete-expert-commands'."
 
 Each entry is a list with the following elements:
 
-0. Regexp matching the preceding text.
-1. A number indicating the subgroup in the regexp containing the text.
+0. Regexp matching the preceding text or a predicate of arity 0
+which checks its applicability and sets `match-data'.
+1. A number indicating the subgroup in the regexp containing the
+text.
 2. A function returning an alist of possible completions.
 3. Text to append after a succesful completion.
 
@@ -3161,7 +3163,9 @@ Or alternatively:
     (while list
       (setq entry (car list)
            list (cdr list))
-      (if (TeX-looking-at-backward (car entry) 250)
+      (if (if (functionp (car entry))
+             (funcall (car entry))
+           (TeX-looking-at-backward (car entry) 250))
          (setq list nil)))
     (if (numberp (nth 1 entry))
        (let* ((sub (nth 1 entry))
@@ -3210,7 +3214,9 @@ See `completion-at-point-functions'."
     (while list
       (setq entry (car list)
            list (cdr list))
-      (if (TeX-looking-at-backward (car entry) 250)
+      (if (if (functionp (car entry))
+             (funcall (car entry))
+           (TeX-looking-at-backward (car entry) 250))
          (setq list nil)))
     (if (numberp (nth 1 entry))
        (let* ((sub (nth 1 entry))

-----------------------------------------------------------------------

Summary of changes:
 latex.el |   18 +++++++++++++++++-
 tex.el   |   14 ++++++++++----
 2 files changed, 27 insertions(+), 5 deletions(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

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