[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/cdlatex 25e8e65acc 04/13: First full and working implement
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/cdlatex 25e8e65acc 04/13: First full and working implementation. |
Date: |
Sat, 12 Aug 2023 12:59:19 -0400 (EDT) |
branch: elpa/cdlatex
commit 25e8e65acc2689dc490b2c132696af46058a59aa
Author: Carsten Dominik <dominik@sp-byods-145-109-124-208.wireless.uva.nl>
Commit: Carsten Dominik <dominik@sp-byods-145-109-124-208.wireless.uva.nl>
First full and working implementation.
---
electricindex.el | 48 ++++++++++++++++++++++++++++++++++++------------
1 file changed, 36 insertions(+), 12 deletions(-)
diff --git a/electricindex.el b/electricindex.el
index 46b6d61e16..1b3e512030 100644
--- a/electricindex.el
+++ b/electricindex.el
@@ -1,9 +1,9 @@
-;;; electricindex.el --- Fast input methods for LaTeX environments and math
-*- lexical-binding: t; -*-
-;; Copyright (c) 2010-2022 Free Software Foundation, Inc.
+;;; electricindex.el --- Fast digit index insertion -*- lexical-binding: t; -*-
+;; Copyright (c) 2022 Free Software Foundation, Inc.
;;
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: tex
-;; Version: 4.14
+;; Version: 0.1
;;
;; This file is not part of GNU Emacs.
;;
@@ -24,8 +24,8 @@
;;
;;; Commentary:
;;
-;; Electricindex is a minor mode supporting fast insertion of environment
-;; templates and math stuff in LaTeX.
+;; Electricindex is a minor mode supporting fast digit index insertation in
+;; LaTeX math. For example typing x 1 2 will insert x_{12}.
;;
;; To turn Electricindex Minor Mode on and off in a particular buffer, use
;; `M-x electricindex-mode'.
@@ -33,8 +33,11 @@
;; To turn on Electricindex Minor Mode for all LaTeX files, add one of the
;; following lines to your .emacs file:
;;
-;; (add-hook 'LaTeX-mode-hook #'turn-on-electricindex) ; with AUCTeX LaTeX
mode
-;; (add-hook 'latex-mode-hook #'turn-on-electricindex) ; with Emacs latex
mode
+;; (add-hook 'latex-mode-hook #'turn-on-electricindex)
+;;
+;; This index insertion will only work when the cursor is in a LaTeX math
+;; environment, based on (texmathp). If texmathp is not available, math
+;; math-mode will be assumed.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
@@ -89,9 +92,7 @@
Here is a list of features: \\<electricindex-mode-map>
Entering `electricindex-mode' calls the hook electricindex-mode-hook."
- :lighter " EI"
- (when electricindex-mode
- (electricindex-compute-tables)))
+ :lighter " EI")
(defalias 'electricindex--texmathp
(if (fboundp 'texmathp) #'texmathp
@@ -99,11 +100,34 @@ Entering `electricindex-mode' calls the hook
electricindex-mode-hook."
;; can install AUCTeX. Tho maybe we should move texmathp into its
;; own package so it can be used even when AUCTeX is not
;; installed/activated.
- #'ignore))
+ t))
;;; ===========================================================================
;;;
-;;; Functions that check out the surroundings
+
+(defun electricindex-digit ()
+ "Insert digit, maybe as an index to a quantity in math environment."
+ (interactive)
+ (if (not (electricindex--texmathp))
+ (self-insert-command 1)
+ (let ((digit (char-to-string (event-basic-type last-command-event))))
+ (if (looking-back "[a-zA-Z]" (1- (point)))
+ (insert "_" digit " ")
+ (if (looking-back "\\(_[0-9]\\) ?" (- (point) 3))
+ (progn
+ (goto-char (match-beginning 1))
+ (forward-char 1)
+ (insert "{")
+ (forward-char 1)
+ (insert digit "}")
+ (if (looking-at "")
+ (forward-char 1)
+ (insert "")))
+ (if (looking-back "_{\\([0-9]+\\)} ?" (max (- (point) 10)
(point-min)))
+ (save-excursion
+ (goto-char (match-end 1))
+ (insert digit))
+ (self-insert-command 1)))))))
(provide 'electricindex)
- [nongnu] elpa/cdlatex updated (a0153ef889 -> c13f089e96), ELPA Syncer, 2023/08/12
- [nongnu] elpa/cdlatex 25e8e65acc 04/13: First full and working implementation.,
ELPA Syncer <=
- [nongnu] elpa/cdlatex d97ba0a51d 03/13: Create the basic structure for the minor mode, ELPA Syncer, 2023/08/12
- [nongnu] elpa/cdlatex f6d5ad9dd6 02/13: Rename the new file to electricindex.el, ELPA Syncer, 2023/08/12
- [nongnu] elpa/cdlatex ccf8f878b2 01/13: Start a branch to implement electric indices, ELPA Syncer, 2023/08/12
- [nongnu] elpa/cdlatex 3c464be7b4 06/13: Fix whitespace handling at end of line, ELPA Syncer, 2023/08/12
- [nongnu] elpa/cdlatex 594eb697ef 08/13: Merge branch 'electricindex', ELPA Syncer, 2023/08/12
- [nongnu] elpa/cdlatex 84fe596341 09/13: Electricindex-mode now added to cdlatex., ELPA Syncer, 2023/08/12
- [nongnu] elpa/cdlatex 64c1440441 05/13: No check for math environment outside of latex buffers, ELPA Syncer, 2023/08/12
- [nongnu] elpa/cdlatex 200ae37f70 07/13: Add mathring command, ELPA Syncer, 2023/08/12
- [nongnu] elpa/cdlatex b27b1bb79a 10/13: Integrate cdlatex-electricindex-mode, ELPA Syncer, 2023/08/12
- [nongnu] elpa/cdlatex 8b18d27cf6 11/13: add new file, ELPA Syncer, 2023/08/12