[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex 377a97a 32/57: Completion for math macros
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex 377a97a 32/57: Completion for math macros |
Date: |
Wed, 11 Jan 2017 18:01:39 +0000 (UTC) |
branch: externals/auctex
commit 377a97a2434fab69bf9e91457de94ad33c09b548
Author: Tassilo Horn <address@hidden>
Commit: Tassilo Horn <address@hidden>
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.
---
latex.el | 18 +++++++++++++++++-
tex.el | 14 ++++++++++----
2 files changed, 27 insertions(+), 5 deletions(-)
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))
- [elpa] externals/auctex 5ddbd04 12/57: Add new style/titleps.el, (continued)
- [elpa] externals/auctex 5ddbd04 12/57: Add new style/titleps.el, Tassilo Horn, 2017/01/11
- [elpa] externals/auctex 225bade 14/57: Add new style/titletoc.el, Tassilo Horn, 2017/01/11
- [elpa] externals/auctex 343ca9c 36/57: Fix script unfontification bug, Tassilo Horn, 2017/01/11
- [elpa] externals/auctex 501b0de 47/57: Use RefTeX for multiple references in cleveref, Tassilo Horn, 2017/01/11
- [elpa] externals/auctex bfc7e90 16/57: Fix fontification for natbib compat macros, Tassilo Horn, 2017/01/11
- [elpa] externals/auctex 1de2359 13/57: Add new style/titlesec.el, Tassilo Horn, 2017/01/11
- [elpa] externals/auctex ccec850 24/57: Remove multi-level/invisible feature of font-latex-fontify-script, Tassilo Horn, 2017/01/11
- [elpa] externals/auctex 4c42f7a 25/57: Revert "Remove multi-level/invisible feature of font-latex-fontify-script", Tassilo Horn, 2017/01/11
- [elpa] externals/auctex 4747c24 29/57: Simple docfix, Tassilo Horn, 2017/01/11
- [elpa] externals/auctex 69fc320 27/57: Add a newline only if \label is inserted, Tassilo Horn, 2017/01/11
- [elpa] externals/auctex 377a97a 32/57: Completion for math macros,
Tassilo Horn <=
- [elpa] externals/auctex 0e54895 34/57: Improve completion docs, Tassilo Horn, 2017/01/11
- [elpa] externals/auctex 00df9a5 37/57: Check new custom option before activating RefTeX cite format, Tassilo Horn, 2017/01/11
- [elpa] externals/auctex 0766526 41/57: Don't use cl function copy-list, Tassilo Horn, 2017/01/11
- [elpa] externals/auctex c70b7f9 21/57: Add new style/exam.sty, Tassilo Horn, 2017/01/11
- [elpa] externals/auctex d185bcb 49/57: * Makefile.in (release-commit): Fix name of preview ChangeLog., Tassilo Horn, 2017/01/11
- [elpa] externals/auctex e9c4b68 35/57: ; * doc/auctex.texi (Completion): Use @defun and not @deffn., Tassilo Horn, 2017/01/11
- [elpa] externals/auctex 74c5ac9 09/57: Update style/tcolorbox.el to package v3.96, Tassilo Horn, 2017/01/11
- [elpa] externals/auctex 0b16551 51/57: * Makefile.in (release-commit): Use UTF-8 coding for ChangeLog entry., Tassilo Horn, 2017/01/11
- [elpa] externals/auctex 826f17a 54/57: Release_11.90, Tassilo Horn, 2017/01/11
- [elpa] externals/auctex 61e56f2 40/57: Fix bug where font-latex-sub/superscript-face was not applied to ^_, Tassilo Horn, 2017/01/11