[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 177/299: Add new customizable variable TeX-insert-braces-alist.
From: |
Stefan Monnier |
Subject: |
[elpa] 177/299: Add new customizable variable TeX-insert-braces-alist. |
Date: |
Sun, 02 Nov 2014 03:11:16 +0000 |
monnier pushed a commit to branch externals/auctex
in repository elpa.
commit 9a09a35edf990d718c34da756f12df5a967aa6d3
Author: Mosè Giordano <address@hidden>
Date: Sun Oct 6 20:40:47 2013 +0200
Add new customizable variable TeX-insert-braces-alist.
* tex.el (TeX-insert-braces-alist): New customizable variable.
(TeX-insert-braces): Mention it in doc-string.
(TeX-parse-macro): Use `TeX-insert-braces-alist'.
* style/booktabs.el: Update copyright years.
(LaTeX-booktabs-arg-paren): Let-bind `TeX-arg-opening-brace' and
`TeX-arg-closing-brace' instead of `<' and `>'.
("booktabs"): Add `toprule', `midrule', and `bottomrule' macros to
`TeX-insert-braces-alist'.
("booktabs"): Add a dummy `ignore' in `cmidrule' macro in order to
reset `last-optional-rejected' to nil.
* doc/auctex.texi (Completion): Document
`TeX-insert-braces-alist'.
* doc/changes.texi: Mention `TeX-insert-braces-alist'.
---
ChangeLog | 19 +++++++++++++++++++
doc/auctex.texi | 13 +++++++++++++
doc/changes.texi | 4 ++--
style/booktabs.el | 22 +++++++++++++---------
tex.el | 39 +++++++++++++++++++++++++++++++--------
5 files changed, 78 insertions(+), 19 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3ef787e..4093ce3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2013-10-06 Mos� Giordano <address@hidden>
+
+ * tex.el (TeX-insert-braces-alist): New customizable variable.
+ (TeX-insert-braces): Mention it in doc-string.
+ (TeX-parse-macro): Use `TeX-insert-braces-alist'.
+
+ * style/booktabs.el: Update copyright years.
+ (LaTeX-booktabs-arg-paren): Let-bind `TeX-arg-opening-brace' and
+ `TeX-arg-closing-brace' instead of `<' and `>'.
+ ("booktabs"): Add `toprule', `midrule', and `bottomrule' macros to
+ `TeX-insert-braces-alist'.
+ ("booktabs"): Add a dummy `ignore' in `cmidrule' macro in order to
+ reset `last-optional-rejected' to nil.
+
+ * doc/auctex.texi (Completion): Document
+ `TeX-insert-braces-alist'.
+
+ * doc/changes.texi: Mention `TeX-insert-braces-alist'.
+
2013-09-27 Mos� Giordano <address@hidden>
* latex.el (TeX-arg-insert-braces): : Move
diff --git a/doc/auctex.texi b/doc/auctex.texi
index 8a1fc1a..4156a0b 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -1107,6 +1107,19 @@ This can be stopped by entering @code{LaTeX-math-mode},
If non-nil, append a empty pair of braces after inserting a macro.
@end defopt
address@hidden TeX-insert-braces-alist
+Control the insertion of a pair of braces after a macro on a per macro
+basis.
+
+This variable is an alist. Each element is a cons cell, whose car is
+the macro name, and the cdr is non-nil or nil, depending on whether a
+pair of braces should be, respectively, appended or not to the macro.
+
+If a macro has an element in this variable, @code{TeX-parse-macro} will
+use its value to decided what to do, whatever the value of the variable
address@hidden
address@hidden defopt
+
Completions work because @AUCTeX{} can analyze @TeX{} files, and store
symbols in Emacs Lisp files for later retrieval. @xref{Automatic}, for
more information.
diff --git a/doc/changes.texi b/doc/changes.texi
index a7ed8db..df69cb4 100644
--- a/doc/changes.texi
+++ b/doc/changes.texi
@@ -30,8 +30,8 @@ Completion for class options of the standard @LaTeX{} classes
is
provided as well.
@item
-New user option @code{LaTeX-default-author}. It is used as initial
-input to @kbd{C-c RET author RET}.
+New user options @code{LaTeX-default-author} and
address@hidden
@item
@samp{biblatex} support was greatly expanded. If parsing is enabled,
diff --git a/style/booktabs.el b/style/booktabs.el
index e126872..ee19459 100644
--- a/style/booktabs.el
+++ b/style/booktabs.el
@@ -1,6 +1,6 @@
;;; booktabs.el -- AUCTeX style for booktabs.sty
-;; Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2004, 2013 Free Software Foundation, Inc.
;; Author: Ralf Angeli <address@hidden>
;; Maintainer: address@hidden
@@ -34,23 +34,27 @@
"Prompt for a value and use parentheses when it is inserted.
If OPTIONAL is non-nil the parameter is labeled as optional.
PROMPT is the value of the prompt to be shown."
- (let ((< "\(")
- (> "\)"))
+ (let ((TeX-arg-opening-brace "\(")
+ (TeX-arg-closing-brace "\)"))
(TeX-parse-argument optional prompt)))
(TeX-add-style-hook
"booktabs"
(lambda ()
-
+ ;; Do not append an empty group to toprule, midrule, and bottomrule macros,
+ ;; otherwise one gets a wrong spacing in the table.
+ (setq TeX-insert-braces-alist (append TeX-insert-braces-alist
+ '(("toprule" . nil)
+ ("midrule" . nil)
+ ("bottomrule" . nil))))
;; New symbols
(TeX-add-symbols
'("toprule" [ "Thickness" ])
'("midrule" [ "Thickness" ])
'("bottomrule" [ "Thickness" ])
- ;; FIXME: The qestion for the trim parameter will only be asked if
- ;; a value for the thickness parameter was given. Is this a
- ;; feature of `TeX-parse-arguments'?
- '("cmidrule" [ "Thickness" ] [ LaTeX-booktabs-arg-paren "Trim" ]
+ ;; The `ignore' resets `last-optional-rejected' to nil so that the trim
+ ;; argument is prompted also when the thickness is skipped.
+ '("cmidrule" [ "Thickness" ] (ignore) [ LaTeX-booktabs-arg-paren "Trim" ]
"Column(s)")
'("addlinespace" [ "Height" ])
'("morecmidrules")
@@ -69,6 +73,6 @@ PROMPT is the value of the prompt to be shown."
'function))))
(defvar LaTeX-booktabs-package-options nil
- "Package options for the booktabs package.")
+ "Package options for the booktabs package.")
;;; booktabs.el ends here
diff --git a/tex.el b/tex.el
index 66e22cd..1ab9647 100644
--- a/tex.el
+++ b/tex.el
@@ -2587,10 +2587,27 @@ Or alternatively:
(make-variable-buffer-local 'TeX-default-macro)
(defcustom TeX-insert-braces t
- "*If non-nil, append a empty pair of braces after inserting a macro."
+ "*If non-nil, append a empty pair of braces after inserting a macro.
+
+See also `TeX-insert-braces-alist'."
:group 'TeX-macro
:type 'boolean)
+(defcustom TeX-insert-braces-alist nil
+ "Alist of macros to which braces should or should not be appended.
+
+Each element is a cons cell, whose CAR is the macro name, and the
+CDR is non-nil or nil, depending on whether a pair of braces
+should be, respectively, appended or not to the macro.
+
+If a macro has an element in this variable, `TeX-parse-macro'
+will use its value to decided what to do, whatever the value of
+the variable `TeX-insert-braces'."
+ :group 'TeX-macro
+ :type '(repeat (cons (string :tag "Macro name")
+ (boolean :tag "Append braces?"))))
+(make-variable-buffer-local 'TeX-insert-braces-alist)
+
(defcustom TeX-insert-macro-default-style 'show-optional-args
"Specifies whether `TeX-insert-macro' will ask for all optional arguments.
@@ -2713,13 +2730,19 @@ type of ARGS:
(cond ((marker-position exit-mark)
(goto-char (marker-position exit-mark))
(set-marker exit-mark nil))
- ((and TeX-insert-braces
- ;; Do not add braces if the argument is 0 or -1.
- (not (and (= (safe-length args) 1)
- (numberp (car args))
- (<= (car args) 0)))
- (equal position (point))
- (string-match "[a-zA-Z]+" symbol))
+ ((let ((element (assoc symbol TeX-insert-braces-alist)))
+ ;; If in `TeX-insert-braces-alist' there is an element associated
+ ;; to the current macro, use its value to decide whether inserting
+ ;; a pair of braces, otherwise use the standard criterion.
+ (if element
+ (cdr element)
+ (and TeX-insert-braces
+ ;; Do not add braces if the argument is 0 or -1.
+ (not (and (= (safe-length args) 1)
+ (numberp (car args))
+ (<= (car args) 0)))
+ (equal position (point))
+ (string-match "[a-zA-Z]+" symbol))))
(if (texmathp)
(when (TeX-active-mark)
(insert TeX-grop)
- [elpa] 172/299: * tex-buf.el (TeX-next-error, TeX-active-buffer): Fix a problem with `TeX-next-error' in multi-file documents., (continued)
- [elpa] 172/299: * tex-buf.el (TeX-next-error, TeX-active-buffer): Fix a problem with `TeX-next-error' in multi-file documents., Stefan Monnier, 2014/11/01
- [elpa] 163/299: Don't prompt for reference format when RefTeX is active., Stefan Monnier, 2014/11/01
- [elpa] 173/299: Fix unit name in siunitx style file., Stefan Monnier, 2014/11/01
- [elpa] 180/299: fix author in ChangeLog, Stefan Monnier, 2014/11/01
- [elpa] 175/299: Detect a couple of hyperref rerun messages., Stefan Monnier, 2014/11/01
- [elpa] 174/299: Enhance brace pairing feature., Stefan Monnier, 2014/11/01
- [elpa] 176/299: Fix in TeX-arg-insert-braces. Again., Stefan Monnier, 2014/11/01
- [elpa] 181/299: Fix typos., Stefan Monnier, 2014/11/01
- [elpa] 179/299: Docs for paired braces feature., Stefan Monnier, 2014/11/01
- [elpa] 178/299: Add new possible value for `TeX-insert-macro-default-style'., Stefan Monnier, 2014/11/01
- [elpa] 177/299: Add new customizable variable TeX-insert-braces-alist.,
Stefan Monnier <=
- [elpa] 182/299: Add indentation for tabular environment., Stefan Monnier, 2014/11/01
- [elpa] 183/299: Use enhanced tabular indentation for more envs., Stefan Monnier, 2014/11/01
- [elpa] 187/299: Fix in biblatex style file., Stefan Monnier, 2014/11/01
- [elpa] 188/299: Really fix bug in biblatex style file., Stefan Monnier, 2014/11/01
- [elpa] 189/299: Run style files of the bibliography files when inserting bibliography macros., Stefan Monnier, 2014/11/01
- [elpa] 186/299: Add narrowing commands., Stefan Monnier, 2014/11/01
- [elpa] 190/299: Document missing folding variables., Stefan Monnier, 2014/11/01
- [elpa] 193/299: void-function error fix., Stefan Monnier, 2014/11/01
- [elpa] 184/299: Mention new tabular indentation in changes.texi., Stefan Monnier, 2014/11/01
- [elpa] 185/299: Add completion for ProvidesPackage, ProvidesClass, and ProvidesFile., Stefan Monnier, 2014/11/01