branch: elpa/cdlatex commit 9a09c2ad32e45889ab7696a8cedbf99d6a17edd6 Author: Carsten Dominik <domi...@carstens-mbp.speedport.ip> Commit: Carsten Dominik <domi...@carstens-mbp.speedport.ip>
$ puts active region into math mode --- CHANGES.org | 6 +++++- cdlatex.el | 20 ++++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/CHANGES.org b/CHANGES.org index efe9d53d99..c4a43a90db 100644 --- a/CHANGES.org +++ b/CHANGES.org @@ -1,6 +1,10 @@ This file documents some more visible changes, in particular if they change previous behavior. +* Version 4.15 +When the region is active, pressing dollar will bracket the region +with two $ characters, putting it into math mode. + * Version 4.13 - The default value of `cdlatex-cdlatex-make-sub-superscript-roman-if-pressed-twice' is now @@ -8,7 +12,7 @@ change previous behavior. - We used to use _{\rm ...} to create roman subscripts. This is not longer up to standards with LaTeX, so we have now switched to using \mathrm instead. Thanks to Sinthoras for pointing this out. -- The selection characters for the \overbrace construct has changes. +- The selection characters for the \overbrace construct has changed. It used to be '{ and it is now '] . The changes was needed to free up the { character for the next point. - It is now easier to inject a \left( ... \right) construct after the diff --git a/cdlatex.el b/cdlatex.el index 4c85b87c9d..c03e321c20 100644 --- a/cdlatex.el +++ b/cdlatex.el @@ -3,7 +3,7 @@ ;; ;; Author: Carsten Dominik <carsten.domi...@gmail.com> ;; Keywords: tex -;; Version: 4.14 +;; Version: 4.15 ;; ;; This file is not part of GNU Emacs. ;; @@ -197,6 +197,9 @@ ;; delimiter are inserted pairwise by configuring the variable ;; `cdlatex-paired-parens'. ;; +;; If the region is active when you press $, the region will be +;; bracketed by a pair of $ characters. +;; ;; Also, the keys `_' and `^' will insert "_{}" and "^{}", ;; respectively, and, if necessary, also a pair of dollar signs to ;; switch to math mode. You can use TAB to exit paired parenthesis. @@ -823,6 +826,12 @@ Elements of KEEP-LIST are not removed even if duplicate." With ARG, insert pair of double dollars." (interactive "P") (cond + ((region-active-p) + (let ((s (region-beginning)) (e (region-end))) + (goto-char s) + (insert "$") + (goto-char (1+ e)) + (insert "$"))) ((cdlatex-number-of-backslashes-is-odd) (insert "$")) ((cdlatex--texmathp) @@ -856,7 +865,6 @@ When pressed twice, make the sub/superscript roman." (if (and cdlatex-make-sub-superscript-roman-if-pressed-twice (equal this-command last-command)) (progn - ;; (insert "\\rm ") (insert "\\mathrm{}") (backward-char 1)) (if (cdlatex-number-of-backslashes-is-odd) @@ -1595,7 +1603,7 @@ zZ ( ?\- "\\bar" nil t t nil ) ( ?T "\\overline" nil t nil nil ) ( ?\_ "\\underline" nil t nil nil ) - ( ?\] "\\overbrace" nil t nil nil ) + ( ?\] "\\overbrace" nil t nil nil ) ( ?\} "\\underbrace" nil t nil nil ) ( ?\> "\\vec" nil t t nil ) ( ?/ "\\grave" nil t t nil ) @@ -1616,9 +1624,9 @@ zZ ( ?1 "\\displaystyle" nil nil nil nil ) ( ?2 "\\scriptstyle" nil nil nil nil ) ( ?3 "\\scriptscriptstyle" nil nil nil nil ) - ( ?\( "\\left( ? \\right)" nil nil nil nil ) - ( ?\[ "\\left[ ? \\right]" nil nil nil nil ) - ( ?\{ "\\left\\{ ? \\right\\}" nil nil nil nil ) + ( ?\( "\\left( ? \\right)" nil nil nil nil ) + ( ?\[ "\\left[ ? \\right]" nil nil nil nil ) + ( ?\{ "\\left\\{ ? \\right\\}" nil nil nil nil ) ( ?< "\\left< ? \\right>" nil nil nil nil ) ( ?| "\\left| ? \\right|" nil nil nil nil ) )