[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/cdlatex 437c06ebf8 18/49: Simplify the insertion of roman
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/cdlatex 437c06ebf8 18/49: Simplify the insertion of roman supscripts and superscripts. |
Date: |
Mon, 11 Jul 2022 02:58:32 -0400 (EDT) |
branch: elpa/cdlatex
commit 437c06ebf8827e373afe317f1bbbe14a3e551268
Author: Carsten Dominik <carsten.dominik@gmail.com>
Commit: Carsten Dominik <carsten.dominik@gmail.com>
Simplify the insertion of roman supscripts and superscripts.
If you press `_' or `^' twice, the templat will enforce a roman
supscript or superscript, as required for descriptive subscripts and
superscripts.
---
README.md | 10 +++++++++-
cdlatex.el | 63 ++++++++++++++++++++++++++++++++++----------------------------
2 files changed, 44 insertions(+), 29 deletions(-)
diff --git a/README.md b/README.md
index 4a7d8d818f..635d98c3bf 100644
--- a/README.md
+++ b/README.md
@@ -171,7 +171,15 @@ As a special case, when you use TAB to exit a pair of
braces that
belong to a subscript or superscript, CDLaTeX removes the braces if
the sub/superscript consists of a single character. For example
typing "$10^3<TAB>" inserts "$10^3$", but typing "$10^34<TAB>"
-inserts "$10^{34}$"
+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 physical quantity themselves) need to be roman.
+So $x_i$ is i is an index, but $x_{\rm max}$ to indicate the maximum
+value.
+
### THE OVERLOADED TAB KEY
You may have noticed that we use the TAB key for many different
diff --git a/cdlatex.el b/cdlatex.el
index e9c60b38bc..47a3bfcf54 100644
--- a/cdlatex.el
+++ b/cdlatex.el
@@ -3,7 +3,7 @@
;;
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: tex
-;; Version: 4.9
+;; Version: 4.10
;;
;; This file is not part of GNU Emacs.
;;
@@ -196,7 +196,16 @@
;; belong to a subscript or superscript, CDLaTeX removes the braces if
;; the sub/superscript consists of a single character. For example
;; typing "$10^3<TAB>" inserts "$10^3$", but typing "$10^34<TAB>"
-;; inserts "$10^{34}$"
+;; 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
+;; 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
+;; `cdlatex-make-sub-superscript-roman-if-pressed-twice'.
;;
;; 5. THE OVERLOADED TAB KEY
;; ----------------------
@@ -523,6 +532,17 @@ 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
+ "*Non-nil means, pressing `^` or `_' twice inserts roman sub/superscript."
+ :group 'cdlatex-math-support
+ :type 'boolean)
+
+(defcustom cdlatex-use-dollar-to-ensure-math t
+ "*Non-nil means, use $...$ to force a math mode setting where needed.
+When nil, use \\(...\\) instead."
+ :group 'cdlatex-math-support
+ :type '(boolean))
+
;; Miscellaneous configurations -----------------------------------------
(defgroup cdlatex-miscellaneous-configurations nil
@@ -558,12 +578,6 @@ When nil, `_' and `^' will just self-insert."
:group 'cdlatex-miscellaneous-configurations
:type '(boolean))
-(defcustom cdlatex-use-dollar-to-ensure-math t
- "*Non-nil means, use $...$ to force a math mode setting where needed.
-When nil, use \\(...\\) instead."
- :group 'cdlatex-miscellaneous-configurations
- :type '(boolean))
-
(defcustom cdlatex-auto-help-delay 1.5
"Number of idle seconds before display of auto-help.
When executing cdlatex-math-symbol or cdlatex-math-modify, display
@@ -783,27 +797,20 @@ With arg, insert pair of double dollars."
(defun cdlatex-sub-superscript ()
"Insert ^{} or _{} unless the number of backslashes before point is odd.
-When not in LaTeX math environment, _{} and ^{} will have dollars."
+When not in LaTeX math environment, _{} and ^{} will have dollars.
+When pressed twice, make the sub/superscript roman."
(interactive)
- (if (cdlatex-number-of-backslashes-is-odd)
- ;; Quoted
- (insert (event-basic-type last-command-event))
- ;; Check if we are in math mode, if not switch to or only add _ or ^
- (if (and (not (texmathp))
- (not cdlatex-sub-super-scripts-outside-math-mode))
- (insert (event-basic-type last-command-event))
- (if (not (texmathp)) (cdlatex-ensure-math))
- (if (string= (buffer-substring (max (point-min) (- (point) 2)) (point))
- (concat (char-to-string (event-basic-type
last-command-event))
- "{"))
- ;; We are at the start of a sub/suberscript. Allow a__{b} and a^^{b}
- ;; This is an undocumented feature, please keep it in. It supports
- ;; a special notation which can be used for upright sub- and
- ;; superscripts.
- (progn
- (backward-char 1)
- (insert (event-basic-type last-command-event))
- (forward-char 1))
+ (if (and cdlatex-make-sub-superscript-roman-if-pressed-twice
+ (equal this-command last-command))
+ (insert "\\rm ")
+ (if (cdlatex-number-of-backslashes-is-odd)
+ ;; Quoted
+ (insert (event-basic-type last-command-event))
+ ;; Check if we are in math mode, if not switch to or only add _ or ^
+ (if (and (not (texmathp))
+ (not cdlatex-sub-super-scripts-outside-math-mode))
+ (insert (event-basic-type last-command-event))
+ (if (not (texmathp)) (cdlatex-ensure-math))
;; Insert the normal template.
(insert (event-basic-type last-command-event))
(insert "{}")
- [nongnu] elpa/cdlatex 6fe5992805 01/49: Initial commit, (continued)
- [nongnu] elpa/cdlatex 6fe5992805 01/49: Initial commit, ELPA Syncer, 2022/07/11
- [nongnu] elpa/cdlatex a9f3833566 05/49: Update README file, ELPA Syncer, 2022/07/11
- [nongnu] elpa/cdlatex ff534912b9 12/49: Merge pull request #6 from songpeng/master, ELPA Syncer, 2022/07/11
- [nongnu] elpa/cdlatex b7af5a9884 16/49: Make `C-u C-c ?' call TeX-documentation-texdoc, ELPA Syncer, 2022/07/11
- [nongnu] elpa/cdlatex aa298afc87 02/49: Initial commit, ELPA Syncer, 2022/07/11
- [nongnu] elpa/cdlatex a0e0ad9efa 04/49: Change version number to 4.7, ELPA Syncer, 2022/07/11
- [nongnu] elpa/cdlatex 1d491c2ddd 06/49: Fix copyright notice, ELPA Syncer, 2022/07/11
- [nongnu] elpa/cdlatex a43e1f9e90 03/49: Overwrite using version 4.6, ELPA Syncer, 2022/07/11
- [nongnu] elpa/cdlatex 31b0d9372b 10/49: update README and make sure cdlatex is new., ELPA Syncer, 2022/07/11
- [nongnu] elpa/cdlatex fea53d325b 15/49: Merge pull request #10 from benide/master, ELPA Syncer, 2022/07/11
- [nongnu] elpa/cdlatex 437c06ebf8 18/49: Simplify the insertion of roman supscripts and superscripts.,
ELPA Syncer <=
- [nongnu] elpa/cdlatex 7ce2c74171 07/49: Add texmathp.el, ELPA Syncer, 2022/07/11
- [nongnu] elpa/cdlatex 575f7bfcf9 08/49: Added dash to conform to header rules, ELPA Syncer, 2022/07/11
- [nongnu] elpa/cdlatex a5cb624ef5 19/49: Fix some typografic issues in README file, ELPA Syncer, 2022/07/11
- [nongnu] elpa/cdlatex 480387b39f 26/49: Fix bug in Makefile, ELPA Syncer, 2022/07/11
- [nongnu] elpa/cdlatex acc1282b73 27/49: Use cl-lib instead of cl, ELPA Syncer, 2022/07/11
- [nongnu] elpa/cdlatex adf96bab0b 29/49: Switch to use `cl-lib', now correctly, ELPA Syncer, 2022/07/11
- [nongnu] elpa/cdlatex 6ae740fccd 34/49: Fixed a couple typos, ELPA Syncer, 2022/07/11
- [nongnu] elpa/cdlatex f215b70c5c 33/49: Fix test and math flags for spl abbreviation, ELPA Syncer, 2022/07/11
- [nongnu] elpa/cdlatex 355614380c 48/49: * cdlatex.el: Fix typos and minor stylistic issues., ELPA Syncer, 2022/07/11
- [nongnu] elpa/cdlatex 7791fa94d5 46/49: Bump version to 4.12, ELPA Syncer, 2022/07/11