[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-numbers cbbfd83c79 044/145: Merge https://github.com/
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-numbers cbbfd83c79 044/145: Merge https://github.com/unhammer/evil-numbers |
Date: |
Thu, 6 Jan 2022 03:00:17 -0500 (EST) |
branch: elpa/evil-numbers
commit cbbfd83c79ecbd598ba7be68dbcff98889a2d23a
Merge: e5dd1e2e31 b754f53c82
Author: Jan Path <jan@jpath.de>
Commit: Jan Path <jan@jpath.de>
Merge https://github.com/unhammer/evil-numbers
---
evil-numbers.el | 39 +++++++++++++++++++++++++++++++++++++--
1 file changed, 37 insertions(+), 2 deletions(-)
diff --git a/evil-numbers.el b/evil-numbers.el
index 4b676eb5df..a4610ec8d9 100644
--- a/evil-numbers.el
+++ b/evil-numbers.el
@@ -58,6 +58,29 @@
;;; Code:
+(defun evil-number-to-superscript (number)
+ "Turn NUMBER like 29 into superscript like ²⁹.
+If argument is a string, uses `number-to-string' on it."
+ (let ((number (if (numberp number)
+ number
+ (number-to-string number))))
+ (concat
+ (mapcar (lambda (digit)
+ (aref "⁰¹²³⁴⁵⁶⁷⁸⁹" (- digit 48)))
+ (number-to-string number)))))
+
+(defun evil-superscript-to-number (string)
+ "Turn a superscript-number STRING like ²⁹ into a regular number like 29."
+ (let ((map ; (⁰ . ?0)
+ (mapcar (lambda (i) (cons (aref "⁰¹²³⁴⁵⁶⁷⁸⁹" i)
+ (aref (number-to-string i) 0)))
+ (number-sequence 0 9))))
+ (string-to-number
+ (concat
+ (mapcar (lambda (c)
+ (cdr (assoc c map)))
+ string)))))
+
;;;###autoload
(evil-define-operator evil-numbers/inc-at-pt (amount beg end type &optional
incremental)
"Increment the number at point or after point before end-of-line by `amount'.
@@ -85,7 +108,7 @@ INCREMENTAL causes the first number to be increased by
1*amount, the second by
(lambda (f) (funcall f beg end)))
(lambda (beg end)
(evil-with-restriction beg end
- (while (re-search-forward
"\\(?:0\\(?:[Bb][01]+\\|[Oo][0-7]+\\|[Xx][0-9A-Fa-f]+\\)\\|-?[0-9]+\\)" nil t)
+ (while (re-search-forward
"\\(?:0\\(?:[Bb][01]+\\|[Oo][0-7]+\\|[Xx][0-9A-Fa-f]+\\)\\|-?[0-9]+\\|⁻?[⁰¹²³⁴⁵⁶⁷⁸⁹]\\)"
nil t)
;; Backward char, to cancel out the forward-char below. We
need
;; this, as re-search-forwards puts us behind the match.
(backward-char)
@@ -110,6 +133,17 @@ INCREMENTAL causes the first number to be increased by
1*amount, the second by
"0123456789abcdefABCDEF"
"\\([0-9a-fA-F]+\\)" amount 16)
+ ;; find superscript literals
+ (progn
+ (skip-chars-backward "⁰¹²³⁴⁵⁶⁷⁸⁹")
+ (when (looking-at "⁻?\\([⁰¹²³⁴⁵⁶⁷⁸⁹]+\\)")
+ (replace-match
+ (format (format "%%0%ds" (- (match-end 1) (match-beginning 1)))
+ (evil-number-to-superscript
+ (+ amount (evil-superscript-to-number (match-string
0))))))
+ ;; Moves point one position back to conform with Vim
+ (forward-char -1)
+ t))
;; find decimal literals
(progn
(skip-chars-backward "0123456789")
@@ -167,6 +201,7 @@ decimal: [0-9]+, e.g. 42 or 23"
(or
;; numbers or format specifier in front
(looking-back (rx (or (+? digit)
+ (in "⁰¹²³⁴⁵⁶⁷⁸⁹")
(and "0" (or (and (in "bB") (*? (in "01")))
(and (in "oO") (*? (in "0-7")))
(and (in "xX") (*? (in digit
"A-Fa-f"))))))))
@@ -174,7 +209,7 @@ decimal: [0-9]+, e.g. 42 or 23"
;; match 0 of specifier or digit, being in a literal and after specifier is
;; handled above
(and
- (re-search-forward "[[:digit:]]" (point-at-eol) t)
+ (re-search-forward "[[:digit:]⁰¹²³⁴⁵⁶⁷⁸⁹]" (point-at-eol) t)
(or
(not (memq (char-after) '(?b ?B ?o ?O ?x ?X)))
(/= (char-before) ?0)
- [nongnu] elpa/evil-numbers 6e13c0450a 030/145: Update documentation., (continued)
- [nongnu] elpa/evil-numbers 6e13c0450a 030/145: Update documentation., ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-numbers 0a376ace35 021/145: Add autoload comments., ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-numbers 30b13905a7 013/145: Move search and replace out of increment., ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-numbers 9e2d6f721f 045/145: Support negative superscripts and fix padding of negative numbers, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-numbers 7ff262f36b 042/145: Support block selections, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-numbers 8da2221b7b 047/145: Make padding optional and off by default (can be configured), ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-numbers cfa8650393 040/145: Remove extra &optional, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-numbers f033965377 046/145: Support subscript numbers, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-numbers 154703dca7 048/145: Make binary, octal and hexadecimal numbers honour padDefault, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-numbers b711ef787e 035/145: Document keypad binding variants., ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-numbers cbbfd83c79 044/145: Merge https://github.com/unhammer/evil-numbers,
ELPA Syncer <=
- [nongnu] elpa/evil-numbers ebfb368851 055/145: Create evil-numbers customisation group, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-numbers d1b1f503a5 057/145: Autoload operators as interactive commands, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-numbers d988041c1f 056/145: List myself as maintainer, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-numbers c2cfdd1eb1 058/145: Merge pull request #6 from hlissner/patch-1, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-numbers 02de70f481 062/145: Quiet checkdoc warnings, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-numbers 6fa8e02e3b 073/145: Cleanup: avoid right shift, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-numbers 963e78cb44 069/145: Change repo URLs in Readme too, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-numbers 26ec2d4a52 066/145: Use lexical binding, remove unused function 'pad', ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-numbers a75c4b0a24 071/145: Cleanup: replace tabs with spaces, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-numbers 626ea72a21 084/145: Cleanup: add missing argument to doc-string, ELPA Syncer, 2022/01/06