auctex-devel
[Top][All Lists]
Advanced

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

[AUCTeX-devel] Enhancement for brace pairing


From: Ikumi Keita
Subject: [AUCTeX-devel] Enhancement for brace pairing
Date: Tue, 24 Sep 2013 20:36:49 +0900

Dear AUCTeX developpers,

I enhanced left-right brace paring feature in AUCTeX, inspired from
YaTeX(http://www.yatex.org/).  Could you examine the attached patch?
I would appreciate if it is incorporated into AUCTeX.
The patch introduces the following 3 changes.
1. In LaTeX documents, current AUCTeX has special support for inserting
   \left macro when using TeX-insert-macro(C-c RET).  It asks left brace
   to use and supplies automatically \right macro and corresponding
   right brace as well as the intended \left macro and left brace.  I
   added the similar support to \bigl and its friends, too.
   Simple example key sequence: C-m RET bigl RET ( RET
   Be careful not to turn off the option TeX-arg-right-insert-p
   when trying this feature.
2. Please try enabling new customize option
   LaTeX-electric-left-right-brace.  If this option is on, just typing
   "(", "{" or "[" instantly adds the corresponding right brace ")", "}"
   or "]".  It also recognizes the preceeding backslash or size
   adjusting macros such as \left, \bigl etc., so the following
   completions will occur:
   "(" -> "()"
   "{" -> "{}"
   "[" -> "[]" (when typing single left brace)
   "\(" -> "\(\)"
   "\{" -> "\{\}"
   "\[" -> "\[\]" (when typing left brace just after backslash)
   "\left(" -> "\left(\right)"
   "\bigl[" ->"\bigl[\bigr]" (when typing just after \left or \bigl)
   "\Bigl\{" -> "\Bigl\{\Bigr\}" (just after \Bigl\)
   This feature may be a bit annoying when editing an already existing
   LaTeX document.  In that case, use "C-u 1" or "C-q" before typing
   "(", "{" or "[".  Then no completion is done and just a single left
   brace is inserted in the buffer.  In fact, with any non-nil prefix
   arguments, they behave in the same way as the normal
   self-insert-command.
3. When entering macros such as \langle, \lfloor and \lceil, which
   produce the left part of the paired braces, with C-c RET, they
   are treated similarly as the left braces "(", "{" and "[".
   For example, inserting \lfloor by C-c RET is immediately followed by
   the insertion of \rfloor.  And if the point locates just after \left
   or its friends, the correspoinding \right etc. will be supplied to
   \rfloor.
   Simple example key sequence: C-c RET lfloor RET
   Note that TeX-arg-right-insert-p should not be turned off for this
   case, too.
   As a side effect, when LaTeX-math-mode is on, just typing "`("
   inserts not only "\langle", but also "\rangle", at the point.

All the features described above honor the active region.  I.e., if
active region is present, the left-right brace pair will surround that
region.
As a result, C-c { is almost unnecessary when
LaTeX-electric-left-right-brace is enabled.  Just typing a "{" suffices
for that purpose.

I personally use amsmath quite often, so I enclosed a modification to
style/amsmath.el as well which fits with the above enhancements.  Thus
\lvert and \lVert are treated similarly with \lfloor etc. so that they
are paired with \rvert and \rVert respectively.

Best regards,
Ikumi Keita

P.S. I'm not on this list, so please include me on cc: when replying.

Attachment: diff
Description: enhancement for left right brace pairing


reply via email to

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