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

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

[nongnu] elpa/evil 1226944a5d 4/6: Remove some unnecessary evil-normaliz


From: ELPA Syncer
Subject: [nongnu] elpa/evil 1226944a5d 4/6: Remove some unnecessary evil-normalize-position:s
Date: Thu, 29 Dec 2022 12:58:49 -0500 (EST)

branch: elpa/evil
commit 1226944a5d7a409400394e34b673e57544bb8abb
Author: Axel Forsman <axelsfor@gmail.com>
Commit: Tom Dalziel <33435574+tomdl89@users.noreply.github.com>

    Remove some unnecessary evil-normalize-position:s
    
    All Emacs functions that take positions as arguments such as goto-char
    already do the normalization performed by evil-normalize-position. The
    only case where it would be necessary is when a marker that may be
    mutated is stored. Therefore it would probably be a good idea to replace
    evil-normalize-position with conditional marker-position altogether.
---
 evil-commands.el | 15 ++++++---------
 evil-common.el   |  6 +-----
 evil-macros.el   |  8 ++------
 evil-states.el   | 14 ++++++--------
 4 files changed, 15 insertions(+), 28 deletions(-)

diff --git a/evil-commands.el b/evil-commands.el
index 3b73dfdd54..d624717cde 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -492,12 +492,11 @@ and jump to the corresponding one."
    (count
     (evil-ensure-column
       (goto-char
-       (evil-normalize-position
-        (let ((size (- (point-max) (point-min))))
-          (+ (point-min)
-             (if (> size 80000)
-                 (* count (/ size 100))
-               (/ (* count size) 100)))))))
+       (let ((size (- (point-max) (point-min))))
+         (+ (point-min)
+            (if (> size 80000)
+                (* count (/ size 100))
+              (/ (* count size) 100))))))
     (setq evil-this-type 'line))
    ((and (evil-looking-at-start-comment t)
          (let ((pnt (point)))
@@ -4252,9 +4251,7 @@ range. The given argument is passed straight to
 Default position is the beginning of the buffer."
   :jump t
   (interactive "<N>")
-  (let ((position (evil-normalize-position
-                   (or position (point-min)))))
-    (goto-char position)))
+  (goto-char (or position (point-min))))
 
 (evil-define-operator evil-ex-line-number (beg end)
   "Print the last line number."
diff --git a/evil-common.el b/evil-common.el
index 1ea0f8732c..ae03ae8b90 100644
--- a/evil-common.el
+++ b/evil-common.el
@@ -1014,9 +1014,7 @@ so it is more compatible with Evil's notions of eol & 
tracking."
   "Restrict the buffer to BEG and END.
 BEG or END may be nil, specifying a one-sided restriction including
 `point-min' or `point-max'. See also `evil-with-restriction.'"
-  (setq beg (or (evil-normalize-position beg) (point-min)))
-  (setq end (or (evil-normalize-position end) (point-max)))
-  (narrow-to-region beg end))
+  (narrow-to-region (or beg (point-min)) (or end (point-max))))
 
 (defmacro evil-with-restriction (beg end &rest body)
   "Execute BODY with the buffer narrowed to BEG and END.
@@ -2315,8 +2313,6 @@ variable `evil-kbd-macro-suppress-motion-error'."
 (defun evil-move-mark (pos)
   "Set buffer's mark to POS.
 If POS is nil, delete the mark."
-  (when pos
-    (setq pos (evil-normalize-position pos)))
   (set-marker (mark-marker) pos))
 
 (defun evil-save-transient-mark-mode ()
diff --git a/evil-macros.el b/evil-macros.el
index 4ee9ec693f..10ccddd630 100644
--- a/evil-macros.el
+++ b/evil-macros.el
@@ -707,9 +707,7 @@ be transformations on buffer positions, like `:expand' and 
`:contract'.
            `(defun ,name (beg end &rest properties)
               ,(format "Return size of %s from BEG to END \
 with PROPERTIES.\n\n%s%s" type string doc)
-              (let ((beg (evil-normalize-position beg))
-                    (end (evil-normalize-position end))
-                    (type ',type)
+              (let ((type ',type)
                     plist range)
                 (when (and beg end)
                   (save-excursion
@@ -731,9 +729,7 @@ with PROPERTIES.\n\n%s%s" type string doc)
            `(defun ,name (beg end &rest properties)
               ,(format "Perform %s transformation on %s from BEG to END \
 with PROPERTIES.\n\n%s%s" sym type string doc)
-              (let ((beg (evil-normalize-position beg))
-                    (end (evil-normalize-position end))
-                    (type ',type)
+              (let ((type ',type)
                     plist range)
                 (when (and beg end)
                   (save-excursion
diff --git a/evil-states.el b/evil-states.el
index 2bdf015927..05f46a571f 100644
--- a/evil-states.el
+++ b/evil-states.el
@@ -500,14 +500,12 @@ mark and point, use `evil-visual-select' instead."
 If TYPE is given, also set the Visual type.
 If MESSAGE is given, display it in the echo area."
   (interactive)
-  (let* ((point (evil-normalize-position
-                 (or point (point))))
-         (mark (evil-normalize-position
-                (or mark
-                    (when (or (evil-visual-state-p)
-                              (region-active-p))
-                      (mark t))
-                    point))))
+  (let* ((point (or point (point)))
+         (mark (or mark
+                   (when (or (evil-visual-state-p)
+                             (region-active-p))
+                     (mark t))
+                   point)))
     (unless (evil-visual-state-p)
       (evil-visual-state))
     (evil-active-region 1)



reply via email to

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