emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] 114/299: Wrap dollars around active region typing `$'.


From: Stefan Monnier
Subject: [elpa] 114/299: Wrap dollars around active region typing `$'.
Date: Sun, 02 Nov 2014 03:10:44 +0000

monnier pushed a commit to branch externals/auctex
in repository elpa.

commit d59628f1ee02abccc179c463214baddb5a17bf71
Author: Mosè Giordano <address@hidden>
Date:   Tue May 7 23:48:56 2013 +0200

    Wrap dollars around active region typing `$'.
    
    * tex.el (TeX-electric-dollar): New variable.
    (TeX-insert-dollar): Use it.
    
    * doc/auctex.texi (Quotes): Document `TeX-electric-dollar'.
---
 ChangeLog       |    7 +++++++
 doc/auctex.texi |    9 ++++++++-
 tex.el          |   33 +++++++++++++++++++++++----------
 3 files changed, 38 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ca2086e..62e96e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-05-07  Mos� Giordano  <address@hidden>
+
+       * tex.el (TeX-electric-dollar): New variable.
+       (TeX-insert-dollar): Use it.
+
+       * doc/auctex.texi (Quotes): Document `TeX-electric-dollar'.
+
 2013-04-28  Mos� Giordano  <address@hidden>
 
        * tex-bar.el: Update copyright range.
diff --git a/doc/auctex.texi b/doc/auctex.texi
index fbf37fb..be12d8e 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -12,7 +12,7 @@ This manual is for @AUCTeX{}
 (version @value{VERSION} from @value{UPDATED}),
 a sophisticated TeX environment for Emacs.
 
-Copyright @copyright{} 1992-1995, 2001, 2002, 2004-2012
+Copyright @copyright{} 1992-1995, 2001, 2002, 2004-2013
 Free Software Foundation, Inc.
 
 @quotation
@@ -435,6 +435,13 @@ and put the point between them.  If the variable
 @code{blink-matching-paren} is non-nil the opening dollar will blink.
 @end defopt
 
address@hidden TeX-electric-dollar
+Control the insertion of dollar signs when there is an active region
+outside math mode.  If the variable is non-nil, typing @samp{$} will put
+a pair of single dollar around the active region and leave point after
+the closing dollar.
address@hidden defopt
+
 @subheading Braces
 
 To avoid unbalanced braces, it is useful to insert them pairwise.  You
diff --git a/tex.el b/tex.el
index 329ad12..f18719d 100644
--- a/tex.el
+++ b/tex.el
@@ -5169,6 +5169,13 @@ typing a single `$'."
   :group 'TeX-macro
   :type 'boolean)
 
+(defcustom TeX-electric-dollar nil
+  "When outside math mode, if non-nil and there is an active
+region, typing `$' will put a pair of single dollar around it and
+leave point after the closing dollar."
+  :group 'TeX-macro
+  :type 'boolean)
+
 (defun TeX-insert-dollar (&optional arg)
   "Insert dollar sign.
 
@@ -5217,16 +5224,23 @@ sign.  With optional ARG, insert that many dollar 
signs."
       (insert "$")))
    (t
     ;; Just somewhere in the text.
-    (if TeX-math-close-single-dollar
+    (if (and TeX-electric-dollar (TeX-active-mark))
        (progn
-         (insert "$$")
-         (if blink-matching-paren
-             (progn
-               (backward-char 2)
-               (sit-for blink-matching-delay)
-               (forward-char))
-           (backward-char)))
-      (insert "$"))))
+         (if (> (point) (mark))
+             (exchange-point-and-mark))
+         (insert "$")
+         (exchange-point-and-mark)
+         (insert "$"))
+      (if TeX-math-close-single-dollar
+         (progn
+           (insert "$$")
+           (if blink-matching-paren
+               (progn
+                 (backward-char 2)
+                 (sit-for blink-matching-delay)
+                 (forward-char))
+             (backward-char)))
+       (insert "$")))))
   (TeX-math-input-method-off))
 
 (defvar TeX-math-input-method-off-regexp
@@ -5701,7 +5715,6 @@ NAME may be a package, a command, or a document."
 
 ;; delsel.el, `delete-selection-mode'
 (put 'TeX-newline 'delete-selection t)
-(put 'TeX-insert-dollar 'delete-selection t)
 (put 'TeX-insert-quote 'delete-selection t)
 (put 'TeX-insert-backslash 'delete-selection t)
 



reply via email to

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