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

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

[nongnu] elpa/cdlatex 43c047919d 1/2: After-the-fact insertion of left-r


From: ELPA Syncer
Subject: [nongnu] elpa/cdlatex 43c047919d 1/2: After-the-fact insertion of left-right pairs made easier
Date: Fri, 19 Aug 2022 03:58:26 -0400 (EDT)

branch: elpa/cdlatex
commit 43c047919d2aef0cce5571830e01ebc83d4ea0f8
Author: Carsten Dominik <carsten.dominik@gmail.com>
Commit: Carsten Dominik <carsten.dominik@gmail.com>

    After-the-fact insertion of left-right pairs made easier
    
    - The default value of
      `cdlatex-cdlatex-make-sub-superscript-roman-if-pressed-twice' is now
      t, meaning the feature is turned on by default.
    - 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.  Thanks
      to Sinthoras for this proposal.
    - The selection characters for the \overbrace construct has changes.
      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
      content has already been typed.  Just select the content and type '(
      Similarly, you can inject left-right pairs or {, [, <, and | in the
      same way.
---
 CHANGES.org | 18 +++++++++++++++
 README      | 32 +++++++++++++++-----------
 cdlatex.el  | 76 ++++++++++++++++++++++++++++++++++++++++++-------------------
 3 files changed, 89 insertions(+), 37 deletions(-)

diff --git a/CHANGES.org b/CHANGES.org
new file mode 100644
index 0000000000..9ef210b257
--- /dev/null
+++ b/CHANGES.org
@@ -0,0 +1,18 @@
+This file documents some more visible changes, in particular if they
+change previous behavior.
+
+* Version 4.13
+- The default value of
+  `cdlatex-cdlatex-make-sub-superscript-roman-if-pressed-twice' is now
+  t, meaning the feature is turned on by default.
+- 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.  Thanks
+  to Sinthoras for this proposal.
+- The selection characters for the \overbrace construct has changes.
+  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
+  content has already been typed.  Just select the content and type '(
+  Similarly, you can inject left-right pairs or {, [, <, and | in the
+  same way.
diff --git a/README b/README
index b8239be4ac..eaf9879ed3 100644
--- a/README
+++ b/README
@@ -9,13 +9,14 @@ To turn CDLaTeX Minor Mode on and off in a particular buffer, 
use
 To turn on CDLaTeX Minor Mode for all LaTeX files, add one of the
 following lines to your .emacs file:
 
-  (add-hook 'LaTeX-mode-hook 'turn-on-cdlatex)   ; with AUCTeX LaTeX mode
-  (add-hook 'latex-mode-hook 'turn-on-cdlatex)   ; with Emacs latex mode
+  (add-hook 'LaTeX-mode-hook #'turn-on-cdlatex)   ; with AUCTeX LaTeX mode
+  (add-hook 'latex-mode-hook #'turn-on-cdlatex)   ; with Emacs latex mode
 
 For key bindings, see further down in this documentation.
 
-CDLaTeX requires texmathp.el which is distributed with AUCTeX.
-Starting with Emacs 21.3, texmathp.el will be part of Emacs.
+CDLaTeX requires texmathp.el (which is distributed with AUCTeX) to
+auto-insert $...$ when needed, so we recommend you install AUCTeX to get
+this functionality.
 
 --------------------------------------------------------------------------
 
@@ -28,9 +29,9 @@ text development with LaTeX.  CDLaTeX is really about speed.  
AUCTeX
 based system for inserting environments and macros - but while this is
 useful and general, it is sometimes slow to use.  CDLaTeX tries to be
 quick, with very few and easy to remember keys, and intelligent
-on-the-fly help. 
+on-the-fly help.
 
-1. ABBREVIATIONS.  
+1. ABBREVIATIONS.
    -------------
    CDLaTeX has an abbrev-like mechanism to insert full LaTeX
    environments and other templates into the buffer.  Abbreviation
@@ -48,7 +49,7 @@ on-the-fly help.
        template, text needs to be filled in at various places, which we
        call "points of interest".  You can use the TAB key to jump to
        the next point of interest in the template.  If there is an
-       active region, the region will be wrappend into the environment,
+       active region, the region will be wrapped into the environment,
        ignoring the template content.
 
        For many frequently used LaTeX environments, abbreviations are
@@ -70,7 +71,7 @@ on-the-fly help.
        environment it inserts "\item\label{item:25}" and in an eqnarray
        environment, it inserts "\label{eq:25} \n & &".  When
        appropriate, newlines are inserted, and the previous item is also
-       closed with "\\".  `cdlatex-item' can also be invoked with the 
+       closed with "\\".  `cdlatex-item' can also be invoked with the
        abbreviation "it<TAB>".
 
    1b. MATH TEMPLATES
@@ -85,6 +86,9 @@ on-the-fly help.
        inserted.  For example in the `\frac{}{}' template, it will
        move you from the first argument to the second and then out of
        the second.  For a list of available templates, type `C-c ?'.
+       As a special case, the left-right parenthesis combinations can
+       also be applied after writing the content by selecting the
+       content and typing '( or '[ or '{ or '< or '| .
 
 2. MATHEMATICAL SYMBOLS
    --------------------
@@ -101,9 +105,9 @@ on-the-fly help.
    backquote character several times before pressing the letter.  For
    example, typing "`d" inserts "\delta" (level 1), and typing "``d"
    inserts "\partial" (level 2).  Similarly, "`e" inserts "\epsilon"
-   and "``e" inserts "\varepsilon".
+   and "``e" inserts "\vareppsilon".
 
-   On each level, on-the-fly help will pop up automatically if you
+   On each level, on-thy-fly help will pop up automatically if you
    hesitate to press the next key.  The help screen is a window which
    lists all math macros available on the current level.  Initially,
    when you type slowly, this window will pop up each time you press
@@ -147,6 +151,8 @@ on-the-fly help.
      and positions the cursor inside.
    - when a numeric prefix argument is supplied, the command acts on
      whole words before the cursor.
+   - Furthermore, if there is an active region, the change will apply
+     to the content of that region.
 
    In order to insert a normal quote, you can press the quote
    character twice.  Also, if the key character is not associated with
@@ -177,9 +183,9 @@ on-the-fly help.
    inserts "$10^{34}$".
 
    If you press `_' or `^' twice, the template inserted will be
-   `_{\rm }' or `^{\rm }', respectively, to insert a roman
-   sub/super-script.  Style guides require that all sub and
-   superscipts that are descriptive (so not a mathematical or
+   `_{\mathrm{}}' or `^{\mathrm }', respectively, to insert a roman
+   sub/super-script.  Style guides require that all sub- and
+   superscripts that are descriptive (so not a mathematical or
    physical quantity themselves) need to be roman.  So $x_i$ is i
    is an index, but $x_{\rm max}$ to indicate the maximum value.  You
    can disable this behavior through the variable
diff --git a/cdlatex.el b/cdlatex.el
index d1c6c8f994..f0b331e5b8 100644
--- a/cdlatex.el
+++ b/cdlatex.el
@@ -3,7 +3,7 @@
 ;;
 ;; Author: Carsten Dominik <carsten.dominik@gmail.com>
 ;; Keywords: tex
-;; Version: 4.12
+;; Version: 4.13
 ;;
 ;; This file is not part of GNU Emacs.
 ;;
@@ -110,6 +110,9 @@
 ;;        inserted.  For example in the `\frac{}{}' template, it will
 ;;        move you from the first argument to the second and then out of
 ;;        the second.  For a list of available templates, type `C-c ?'.
+;;        As a special case, the left-right parenthesis combinations can
+;;        also be applied after writing the content by selecting the
+;;        content and typing '( or '[ or '{ or '< or '| .
 ;;
 ;; 2. MATHEMATICAL SYMBOLS
 ;;    --------------------
@@ -172,6 +175,8 @@
 ;;      and positions the cursor inside.
 ;;    - when a numeric prefix argument is supplied, the command acts on
 ;;      whole words before the cursor.
+;;    - Furthermore, if there is an active region, the change will apply
+;;      to the content of that region.
 ;;
 ;;    In order to insert a normal quote, you can press the quote
 ;;    character twice.  Also, if the key character is not associated with
@@ -202,7 +207,7 @@
 ;;    inserts "$10^{34}$".
 ;;
 ;;    If you press `_' or `^' twice, the template inserted will be
-;;    `_{\rm }' or `^{\rm }', respectively, to insert a roman
+;;    `_{\mathrm{}}' or `^{\mathrm }', respectively, to insert a roman
 ;;    sub/super-script.  Style guides require that all sub- and
 ;;    superscripts that are descriptive (so not a mathematical or
 ;;    physical quantity themselves) need to be roman.  So $x_i$ is i
@@ -536,7 +541,7 @@ Each element contains 6 items:
                 (boolean :tag "Remove dot in i/j")
                 (boolean :tag "Italic correction"))))
 
-(defcustom cdlatex-make-sub-superscript-roman-if-pressed-twice nil
+(defcustom cdlatex-make-sub-superscript-roman-if-pressed-twice t
   "Non-nil means, pressing `^' or `_' twice inserts roman sub/superscript."
   :group 'cdlatex-math-support
   :type 'boolean)
@@ -1258,9 +1263,12 @@ with a math accent or a style.
 If the character before point is white space, an empty modifying form
 is inserted and the cursor positioned properly.
 If the object before point looks like word, this macro modifies the last
-character of it.
-All this happens only, when the cursor is actually inside a LaTeX math
-environment.  In normal text, it does just a self-insert.
+character of it.  The math-related changes happen only when the cursor
+is actually inside a LaTeX math environment.
+Some of the modification characters denote font style changes like bold
+or italic.  These also work in text mode, on the word before point or,
+if applicable, the active region.
+  In normal text, it does just a self-insert.
 The accent and style commands and their properties are defined in the
 constant `cdlatex-math-modify-alist'."
   (interactive "P")
@@ -1268,7 +1276,8 @@ constant `cdlatex-math-modify-alist'."
 
     (let ((inside-math (cdlatex--texmathp))
           (win (selected-window))
-          char (help-is-on nil) ass acc rmdot it cmd extrabrac)
+          char (help-is-on nil) ass acc rmdot it cmd extrabrac
+          before after)
       (catch 'exit1
         (save-window-excursion
           (while t
@@ -1315,6 +1324,8 @@ constant `cdlatex-math-modify-alist'."
       (setq it     (nth 4 ass))
       (if (not cmd) (error "No such modifier `%c' %s math mode" char
                            (if inside-math "inside" "outside")))
+      (if (string-match "\\(.*\\)\\?\\(.*\\)" cmd)
+          (setq before (match-string 1 cmd) after (match-string 2 cmd)))
       (cond
        ((cdlatex-region-active-p)
         (let ((beg (min (region-beginning) (region-end)))
@@ -1322,30 +1333,40 @@ constant `cdlatex-math-modify-alist'."
           (goto-char end)
           (point-to-register ?x)
           (goto-char beg)
-          (insert "{")
-          (if acc (forward-char -1))
-          (insert cmd)
-          (if (not acc) (insert " "))
+          (if before
+              (insert before)
+            (insert "{")
+            (if acc (forward-char -1))
+            (insert cmd)
+            (if (not acc) (insert " ")))
           (register-to-point ?x)
-          (insert "}")))
+          (if after
+              (insert after)
+            (insert "}"))))
        (arg
         (point-to-register ?x)
         (backward-word arg)
-        (insert "{")
-        (if acc (forward-char -1))
-        (insert cmd)
-        (if (not acc) (insert " "))
+        (if before
+            (insert before)
+          (insert "{")
+          (if acc (forward-char -1))
+          (insert cmd)
+          (if (not acc) (insert " ")))
         (register-to-point ?x)
-        (insert "}"))
+        (if after
+            (insert after)
+          (insert "}")))
        ((or (bolp)
             (not cdlatex-modify-backwards)
             (memq (preceding-char) '(?\  ?$ ?- ?{ ?\( )))
         ;; Just insert empty form and position cursor
-        (if acc
-            (insert cmd "{?")
-          (insert "{" cmd " ?"))
-        (if it (insert "\\/"))
-        (insert "}")
+        (if (string-match "\\?" cmd)
+            (insert cmd)
+          (if acc
+              (insert cmd "{?")
+            (insert "{" cmd " ?"))
+          (if it (insert "\\/"))
+          (insert "}"))
         (search-backward "?")
         (delete-char 1))
        (t
@@ -1423,7 +1444,9 @@ zZ
          (setq value ""))
        ( t
          (setq value (nth level (assoc this-char alist)))
-         (if (not value) (setq value ""))))
+         (if (not value) (setq value ""))
+         (if (string-match "\\(.*?\\) \\? \\(.*\\)" value)
+             (setq value (concat (match-string 1 value) (match-string 2 
value))))))
       (setq this-char (char-to-string this-char)
             value (if (> (length value) 15)
                       (concat (substring value 0 13) "..")
@@ -1571,7 +1594,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 )
@@ -1592,6 +1615,11 @@ 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 )
     )
   "Default for `cdlatex-math-modify-alist'.")
 



reply via email to

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