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

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

[nongnu] elpa/evil-numbers f48504348f 121/145: Add evil-numbers-case opt


From: ELPA Syncer
Subject: [nongnu] elpa/evil-numbers f48504348f 121/145: Add evil-numbers-case option
Date: Thu, 6 Jan 2022 03:00:24 -0500 (EST)

branch: elpa/evil-numbers
commit f48504348f4d021a81aaa6190b65b8c4ea62ace8
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>

    Add evil-numbers-case option
    
    Allow setting the default case for hexadecimal values.
---
 CHANGELOG.org   |  4 ++++
 README.org      |  8 ++++++++
 evil-numbers.el | 21 +++++++++++++++++++--
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.org b/CHANGELOG.org
index ee6ff741d5..841450d480 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -2,6 +2,10 @@
 
 * In Development
 
+** Additions
+
++ Add =evil-numbers-case= option for the case to use for hexadecimal values 
(defaults to the current case).
+
 ** Fixes
 
 + Fix #24 hexadecimal values case changes when incrementing/decrementing.
diff --git a/README.org b/README.org
index bc33334e04..86fe5641c0 100644
--- a/README.org
+++ b/README.org
@@ -35,6 +35,14 @@
      Set  to =t= if you want numbers to be padded with zeros (numbers with a 
leading zero are always padded).
      If you want both behaviors, all commands take an optional argument 
=padded=.
 
+   - =evil-numbers-case=
+
+     The case to use for hexadecimal numbers.
+
+     - =nil= Current case (default).
+     - '=upcase= Always upper case.
+     - '=downcase= Always lower case.
+
 ** Key Bindings
    Example key bindings:
 
diff --git a/evil-numbers.el b/evil-numbers.el
index 62b9e8decb..a4fadf5058 100644
--- a/evil-numbers.el
+++ b/evil-numbers.el
@@ -80,6 +80,15 @@
   :type 'boolean
   :options '(nil t))
 
+(defcustom evil-numbers-case nil
+  "Case to use for hexadecimal numbers."
+  :group 'evil-numbers
+  :type
+  '(choice
+    (const :tag "Current Case" nil)
+    (const :tag "Upper Case" upcase)
+    (const :tag "Lower Case" downcase)))
+
 
 ;; ---------------------------------------------------------------------------
 ;; Internal Variables
@@ -328,8 +337,16 @@ replace number incremented by AMOUNT in BASE and return 
non-nil."
 
         ;; Maintain case.
         (when do-case
-          (when (eq -1 (or (evil-numbers--case-category str-prev -1) -1))
-            (setq str-next (downcase str-next))))
+          (cond
+           ;; Upper case (already set).
+           ((eq evil-numbers-case 'upcase)
+            nil)
+           ((eq evil-numbers-case 'downcase)
+            (setq str-next (downcase str-next)))
+           ;; Keep current case.
+           (t
+            (when (eq -1 (or (evil-numbers--case-category str-prev -1) -1))
+              (setq str-next (downcase str-next))))))
 
         ;; Replace the sign (as needed).
         (cond



reply via email to

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