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

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

[nongnu] elpa/evil 35ebb6be71 3/4: Avoid marker for match-end in :substi


From: ELPA Syncer
Subject: [nongnu] elpa/evil 35ebb6be71 3/4: Avoid marker for match-end in :substitute
Date: Wed, 12 Jul 2023 12:59:23 -0400 (EDT)

branch: elpa/evil
commit 35ebb6be714b21b48329ee1ded4588fc97d33196
Author: Axel Forsman <axelsfor@gmail.com>
Commit: Axel Forsman <axelsfor@gmail.com>

    Avoid marker for match-end in :substitute
---
 evil-commands.el |  93 ++++++++++++++-----------------
 evil-common.el   |  54 ++++++++----------
 evil-macros.el   |  13 ++---
 evil-search.el   | 164 ++++++++++++++++---------------------------------------
 evil-tests.el    |   7 ++-
 5 files changed, 121 insertions(+), 210 deletions(-)

diff --git a/evil-commands.el b/evil-commands.el
index ffd5955834..0f6dfab888 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -1566,7 +1566,7 @@ be joined with the previous line if and only if
 `evil-backspace-join-lines'."
   (interactive "p")
   (if (or evil-backspace-join-lines (not (bolp)))
-      (call-interactively 'delete-backward-char)
+      (call-interactively #'delete-backward-char)
     (signal 'beginning-of-line nil)))
 
 (evil-define-command evil-delete-backward-word ()
@@ -1936,11 +1936,10 @@ Surround line denoted by BORDERLINE with dashes if 
non-nil."
 
 (defun evil--global-print+clear ()
   "Print accumulated print output from :global print, and clear."
-  (unwind-protect
-      (unless (string= "" evil--ex-print-accumulator)
-        (evil--ex-print-to-minibuffer evil--ex-print-accumulator))
-    (setq evil--ex-print-accumulator "")))
-
+  (let ((s evil--ex-print-accumulator))
+    (unless (string= s "")
+      (setq evil--ex-print-accumulator "")
+      (evil--ex-print-to-minibuffer s))))
 (add-hook 'evil-after-global-hook #'evil--global-print+clear)
 
 (evil-define-command evil-ex-print (beg end &optional count)
@@ -2272,7 +2271,7 @@ The return value is the yanked text."
               (backward-char))))
         (when evil--cursor-after
           (if (eq 'evil-yank-line-handler yank-handler)
-              (ignore-errors (evil-next-line-first-non-blank 1))
+              (ignore-errors (evil-next-line-first-non-blank))
             (evil-forward-char 1 nil t))
           (setq evil--cursor-after nil))
         ;; no paste-pop after pasting from a register
@@ -3977,31 +3976,30 @@ to the echo area.  Otherwise, print the number of 
replacements made or found."
   (evil-ex-nohighlight)
   (unless pattern (user-error "No pattern given"))
   (setq replacement (or replacement "")
+        flags (append flags)
         evil-ex-last-was-search nil
         evil-ex-substitute-pattern pattern
-        evil-ex-substitute-replacement replacement)
-  (let* ((flags (append flags nil))
+        evil-ex-substitute-replacement replacement
+        evil-ex-substitute-flags flags)
+  (let* ((inhibit-field-text-motion t)
          (count-only (memq ?n flags))
          (confirm (and (memq ?c flags) (not count-only)))
          (case-fold-search (evil-ex-pattern-ignore-case pattern))
          (case-replace case-fold-search)
          (regex (evil-ex-pattern-regex pattern))
          (nreplaced 0)
+         (orig-point (point-marker))
          (last-point (point))
          (whole-line (evil-ex-pattern-whole-line pattern))
          (evil-ex-substitute-overlay (make-overlay (point) (point)))
-         (orig-point-marker (move-marker (make-marker) (point)))
          (end-marker (move-marker (make-marker) end))
          (use-reveal confirm)
-         (match-end (make-marker))
          match-data
          reveal-open-spots
          transient-mark-mode)
-    (setq evil-ex-substitute-flags flags
-          isearch-string regex)
-    (isearch-update-ring regex t)
     (unwind-protect
         (catch 'exit-search
+          (isearch-update-ring (setq isearch-string regex) t)
           (evil-ex-hl-change 'evil-ex-substitute pattern)
           (overlay-put evil-ex-substitute-overlay 'face 'isearch)
           (overlay-put evil-ex-substitute-overlay 'priority 1001)
@@ -4009,23 +4007,21 @@ to the echo area.  Otherwise, print the number of 
replacements made or found."
           (while (re-search-forward regex end-marker t)
             (unless (and query-replace-skip-read-only
                          (text-property-any (match-beginning 0) (match-end 0) 
'read-only t))
-              (let ((inhibit-field-text-motion t)
-                    (match-beg (match-beginning 0))
-                    match-contains-newline zero-length-match)
-                (move-marker match-end (match-end 0))
+              (let* ((match-beg (match-beginning 0))
+                     (match-end (match-end 0))
+                     (zero-length-match (= match-beg match-end))
+                     match-contains-newline)
                 (goto-char match-beg)
-                (setq match-data (match-data t match-data)
-                      match-contains-newline (< (line-end-position) match-end)
-                      zero-length-match (= match-beg match-end))
                 (when (and (= match-beg end-marker) (> end-marker beg) (bolp))
                   ;; This line is not included due to range being exclusive
-                  (throw 'exit-search t))
-                (setq last-point match-beg)
+                  (throw 'exit-search nil))
+                (setq match-data (match-data t match-data)
+                      match-contains-newline (search-forward "\n" match-end t))
+                (goto-char match-end)
                 (if confirm
                     (let* ((next-replacement
                             (if (stringp replacement) replacement
-                              (funcall (car replacement) (cdr replacement)
-                                       nreplaced)))
+                              (funcall (car replacement) (cdr replacement) 
nreplaced)))
                            (prompt
                             (format "Replace %s with %s (y/n/a/q/l/^E/^Y)? "
                                     (match-string 0)
@@ -4050,33 +4046,30 @@ to the echo area.  Otherwise, print the number of 
replacements made or found."
                              (line-beginning-position 2)
                              (evil-ex-hl-get-max 'evil-ex-substitute)))
                           (cl-case response
-                            ((?y ?n) (throw 'exit-read-char t))
+                            ((?y ?n) (throw 'exit-read-char nil))
                             (?a (setq confirm nil)
-                                (throw 'exit-read-char t))
-                            ((?q ?l ?\C-\[) (throw 'exit-search t))
+                                (throw 'exit-read-char nil))
+                            ((?q ?l ?\C-\[) (throw 'exit-search nil))
                             (?\C-e (evil-scroll-line-down 1))
                             (?\C-y (evil-scroll-line-up 1))))))
                   (unless count-only
                     (let ((next-replacement
                            (if (stringp replacement) replacement
-                             (funcall (car replacement) (cdr replacement)
-                                      nreplaced))))
+                             (funcall (car replacement) (cdr replacement) 
nreplaced))))
                       (set-match-data match-data)
                       (replace-match next-replacement (not case-replace))))
                   (cl-incf nreplaced))
-                (goto-char match-end)
+                (setq last-point (point))
                 (cond ((>= (point) end-marker)
                        ;; Don't want to perform multiple replacements at the 
end
                        ;; of the search region.
-                       (throw 'exit-search t))
+                       (throw 'exit-search nil))
                       ((and (not whole-line)
                             (not match-contains-newline))
                        (forward-line)
                        ;; forward-line just moves to the end of the line on the
                        ;; last line of the buffer.
-                       (when (or (eobp)
-                                 (> (point) end-marker))
-                         (throw 'exit-search t)))
+                       (when (>= (point) end-marker) (throw 'exit-search nil)))
                       ;; For zero-length matches check to see if point won't
                       ;; move next time. This is a problem when matching the
                       ;; regexp "$" because we can enter an infinite loop,
@@ -4086,15 +4079,12 @@ to the echo area.  Otherwise, print the number of 
replacements made or found."
                               (save-excursion
                                 (and (re-search-forward regex end-marker t)
                                      (= pnt (point))))))
-                       (when (eobp) (throw 'exit-search t))
+                       (when (eobp) (throw 'exit-search nil))
                        (forward-char)))))))
       (evil-ex-delete-hl 'evil-ex-substitute)
       (delete-overlay evil-ex-substitute-overlay)
-
-      (goto-char (if count-only orig-point-marker
-                   last-point))
-
-      (move-marker orig-point-marker nil)
+      (goto-char (if count-only orig-point last-point))
+      (move-marker orig-point nil)
       (move-marker end-marker nil)
 
       (when use-reveal
@@ -4102,14 +4092,13 @@ to the echo area.  Otherwise, print the number of 
replacements made or found."
 
     (evil--ex-substitute-final-message nreplaced flags)
 
-    (if (and (= 0 nreplaced) evil-ex-point)
+    (if (and (= nreplaced 0) evil-ex-point)
         (goto-char evil-ex-point)
       (evil-first-non-blank))))
 
-(evil-define-operator evil-ex-repeat-substitute
-  (beg end flags)
+(evil-define-operator evil-ex-repeat-substitute (beg end flags)
   "Repeat last substitute command.
-This is the same as :s//~/"
+This is the same as \":s//~/\"."
   :repeat nil
   :jump t
   :move-point nil
@@ -4118,10 +4107,9 @@ This is the same as :s//~/"
   (apply #'evil-ex-substitute beg end
          (evil-ex-get-substitute-info (concat "//~/" flags))))
 
-(evil-define-operator evil-ex-repeat-substitute-with-flags
-  (beg end flags)
+(evil-define-operator evil-ex-repeat-substitute-with-flags (beg end flags)
   "Repeat last substitute command with last flags.
-This is the same as :s//~/&"
+This is the same as \":s//~/&\"."
   :repeat nil
   :jump t
   :move-point nil
@@ -4130,10 +4118,9 @@ This is the same as :s//~/&"
   (apply #'evil-ex-substitute beg end
          (evil-ex-get-substitute-info (concat "//~/&" flags))))
 
-(evil-define-operator evil-ex-repeat-substitute-with-search
-  (beg end flags)
+(evil-define-operator evil-ex-repeat-substitute-with-search (beg end flags)
   "Repeat last substitute command with last search pattern.
-This is the same as :s//~/r"
+This is the same as \":s//~/r\"."
   :repeat nil
   :jump t
   :move-point nil
@@ -4145,7 +4132,7 @@ This is the same as :s//~/r"
 (evil-define-operator evil-ex-repeat-substitute-with-search-and-flags
   (beg end flags)
   "Repeat last substitute command with last search pattern and last flags.
-This is the same as :s//~/&r"
+This is the same as \":s//~/&r\"."
   :repeat nil
   :jump t
   :move-point nil
@@ -4156,7 +4143,7 @@ This is the same as :s//~/&r"
 
 (evil-define-operator evil-ex-repeat-global-substitute ()
   "Repeat last substitute command on the whole buffer.
-This is the same as :%s//~/&"
+This is the same as \":%s//~/&\"."
   :repeat nil
   :jump t
   :move-point nil
diff --git a/evil-common.el b/evil-common.el
index f3563cce04..5e5f84831f 100644
--- a/evil-common.el
+++ b/evil-common.el
@@ -1854,29 +1854,23 @@ a number, a cons cell (FILE . POS) with FILE being a 
string
 and POS a number, or nil. If RAW is non-nil, then the
 return value may also be a variable, a movement function,
 or a marker object pointing nowhere."
-  (let ((marker (if (evil-global-marker-p char)
-                    (cdr-safe (assq char (default-value
-                                           'evil-markers-alist)))
-                  (cdr-safe (assq char evil-markers-alist)))))
-    (save-excursion
-      (if raw
-          marker
-        (when (and (symbolp marker) (boundp marker))
-          (setq marker (symbol-value marker)))
-        (when (functionp marker)
+  (let ((marker (cdr (assq char (if (evil-global-marker-p char)
+                                    (default-value 'evil-markers-alist)
+                                  evil-markers-alist)))))
+    (if raw
+        marker
+      (when (and (symbolp marker) (boundp marker))
+        (setq marker (symbol-value marker)))
+      (when (functionp marker)
+        (save-excursion
           (save-window-excursion
             (funcall marker)
-            (setq marker (move-marker (make-marker) (point)))))
-        (when (markerp marker)
+            (setq marker (move-marker (make-marker) (point))))))
+      (if (markerp marker)
           (if (eq (marker-buffer marker) (current-buffer))
-              (setq marker (marker-position marker))
-            (setq marker (and (marker-buffer marker) marker))))
-        (when (or (numberp marker)
-                  (markerp marker)
-                  (and (consp marker)
-                       (stringp (car marker))
-                       (numberp (cdr marker))))
-          marker)))))
+              (marker-position marker)
+            (when (marker-buffer marker) marker))
+        marker))))
 
 (defun evil-swap-out-markers ()
   "Turn markers into file references when the buffer is killed."
@@ -2084,7 +2078,7 @@ register instead of replacing its content."
    ((member register '(?: ?. ?%))
     (user-error "Can't modify read-only register"))
    ((eq register ?\") (kill-new text))
-   ((and (<= ?1 register) (<= register ?9))
+   ((<= ?1 register ?9)
     (if (null kill-ring)
         (kill-new text)
       (let ((kill-ring-yank-pointer kill-ring-yank-pointer)
@@ -2104,14 +2098,13 @@ register instead of replacing its content."
   "Return an alist of all registers, but only those named
 with number or character. Registers with symbol or string in names are ignored
 to keep Vim compatibility with register jumps."
-  (sort (append (mapcar #'(lambda (reg)
-                            (cons reg (evil-get-register reg t)))
+  (sort (append (mapcar (lambda (reg) (cons reg (evil-get-register reg t)))
                         '(?\" ?* ?+ ?% ?# ?/ ?: ?. ?-
                               ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9))
                 (list (cons ?= evil-last-=-register-input))
                 (cl-remove-if-not (lambda (reg) (number-or-marker-p (car 
reg))) register-alist)
                 nil)
-        #'(lambda (reg1 reg2) (< (car reg1) (car reg2)))))
+        #'car-less-than-car))
 
 (defsubst evil-kbd-macro-suppress-motion-error ()
   "Return non-nil if a motion error should be suppressed.
@@ -3023,8 +3016,8 @@ understood by thing-at-point.  BEG, END and TYPE specify 
the
 current selection.  If LINE is non-nil, the text object should be
 linewise, otherwise it is character wise."
   (save-restriction
-    (let ((start (save-excursion (beginning-of-line) (point)))
-          (end (save-excursion (end-of-line) (point))))
+    (let ((start (line-beginning-position))
+          (end (line-end-position)))
       (when (/= start end)
         (narrow-to-region start end)))
     (evil-select-an-object thing beg end type count line)))
@@ -3057,8 +3050,7 @@ end of the line of OP and at the beginning of the line of 
CL."
           (when (and (not (bolp)) (< beg end))
             (setq end (1- end)))))
       (cons beg end)))
-   (t
-    (user-error "Unknown selection-type %s" selection-type))))
+   (t (user-error "Unknown selection-type `%s'" selection-type))))
 
 (defun evil-select-block (thing beg end type count
                                 &optional
@@ -3155,8 +3147,7 @@ are the delimiters of a string or comment."
                 cl (cdr sel)))
         (cond
          ((and (equal op orig-beg) (equal cl orig-end)
-               (or (not countcurrent)
-                   (and countcurrent (/= count 1))))
+               (or (not countcurrent) (/= count 1)))
           (error "No surrounding delimiters found"))
          ((save-excursion
             (and (not (evil-visual-state-p))
@@ -3164,8 +3155,7 @@ are the delimiters of a string or comment."
                  (progn (goto-char op) (bolp))
                  (progn (goto-char cl) (bolp))))
           (evil-range op cl 'line :expanded t))
-         (t
-          (evil-range op cl type :expanded t)))))))
+         (t (evil-range op cl type :expanded t)))))))
 
 (defun evil-select-paren (open close beg end type count &optional inclusive)
   "Return a range (BEG END) of COUNT delimited text objects.
diff --git a/evil-macros.el b/evil-macros.el
index 0180dd0a2c..f46daeae1f 100644
--- a/evil-macros.el
+++ b/evil-macros.el
@@ -39,6 +39,10 @@
 (put 'beginning-of-line 'error-message "Beginning of line")
 (put 'end-of-line 'error-conditions '(end-of-line error))
 (put 'end-of-line 'error-message "End of line")
+;; we don't want line boundaries to trigger the debugger
+;; when `debug-on-error' is t
+(cl-pushnew 'beginning-of-line debug-ignored-errors)
+(cl-pushnew 'end-of-line debug-ignored-errors)
 
 (defun evil-motion-range (motion &optional count type)
   "Execute a motion and return the buffer positions.
@@ -161,8 +165,8 @@ Optional keyword arguments are:
 
 (defmacro evil-narrow-to-line (&rest body)
   "Narrow BODY to the current line.
-BODY will signal the errors 'beginning-of-line or 'end-of-line
-upon reaching the beginning or end of the current line."
+BODY will signal `beginning-of-line' or `end-of-line' upon reaching
+the beginning or end of the current line."
   (declare (indent defun) (debug t))
   `(cl-destructuring-bind (beg end &rest) (evil-line-expand (point) (point))
      (when (save-excursion (goto-char end) (bolp))
@@ -184,11 +188,6 @@ upon reaching the beginning or end of the current line."
               (signal 'end-of-line nil)
             (signal (car err) (cdr err))))))))
 
-;; we don't want line boundaries to trigger the debugger
-;; when `debug-on-error' is t
-(cl-pushnew 'beginning-of-line debug-ignored-errors)
-(cl-pushnew 'end-of-line debug-ignored-errors)
-
 (defun evil-eobp (&optional pos)
   "Whether point is at end-of-buffer with regard to end-of-line."
   (save-excursion
diff --git a/evil-search.el b/evil-search.el
index e26325c666..143dc61295 100644
--- a/evil-search.el
+++ b/evil-search.el
@@ -279,7 +279,7 @@ one more than the current position."
 If FORWARD is nil, search backward, otherwise forward. If SYMBOL
 is non-nil then the functions searches for the symbol at point,
 otherwise for the word at point."
-  (let ((string (car-safe regexp-search-ring)))
+  (let ((string (car regexp-search-ring)))
     (setq isearch-forward forward)
     (cond
      ((and (memq last-command
@@ -459,8 +459,20 @@ expression and is not transformed."
 Otherwise PATTERN matches only the first occurence."
   (nth 2 pattern))
 
-;; Highlight
-(defun evil-ex-make-hl (name &rest args)
+;;; Highlight
+
+(cl-defstruct (evil-ex-hl (:type vector) (:constructor nil)
+                          (:copier nil) (:predicate nil))
+  (name nil :read-only t) pattern
+  (face nil :read-only t) (window nil :read-only t)
+  (min nil :documentation "The minimal buffer position of the highlight.")
+  (max nil :documentation "The maximal buffer position of the highlight.")
+  (match-hook nil :read-only t) (update-hook nil :read-only t)
+  (overlays nil :documentation "The active overlays of the highlight."))
+
+(cl-defun evil-ex-make-hl
+    (name &key (face 'evil-ex-lazy-highlight) (win (selected-window))
+          min max match-hook update-hook)
   "Create a new highlight object with name NAME and properties ARGS.
 The following properties are supported:
 :face The face to be used for the highlighting overlays.
@@ -479,99 +491,31 @@ The following properties are supported:
              describing the current match status."
   (unless (symbolp name)
     (user-error "Expected symbol as name of highlight"))
-  (let ((face 'evil-ex-lazy-highlight)
-        (win (selected-window))
-        min max match-hook update-hook)
-    (while args
-      (let ((key (pop args))
-            (val (pop args)))
-        (cond
-         ((eq key :face) (setq face val))
-         ((eq key :win)  (setq win val))
-         ((eq key :min)  (setq min val))
-         ((eq key :max)  (setq max val))
-         ((eq key :match-hook) (setq match-hook val))
-         ((eq key :update-hook) (setq update-hook val))
-         (t (user-error "Unexpected keyword: %s" key)))))
-    (when (assoc name evil-ex-active-highlights-alist)
-      (evil-ex-delete-hl name))
-    (when (null evil-ex-active-highlights-alist)
-      (add-hook 'window-scroll-functions
-                #'evil-ex-hl-update-highlights-scroll nil t)
-      (add-hook 'window-size-change-functions
-                #'evil-ex-hl-update-highlights-resize nil))
-    (push (cons name (vector name
-                             nil
-                             face
-                             win
-                             min
-                             max
-                             match-hook
-                             update-hook
-                             nil))
-          evil-ex-active-highlights-alist)))
-
-(defun evil-ex-hl-name (hl)
-  "Return the name of the highlight HL."
-  (aref hl 0))
-
-(defun evil-ex-hl-pattern (hl)
-  "Return the pattern of the highlight HL."
-  (aref hl 1))
-
-(defun evil-ex-hl-set-pattern (hl pattern)
-  "Set the pattern of the highlight HL to PATTERN."
-  (aset hl 1 pattern))
-
-(defun evil-ex-hl-face (hl)
-  "Return the face of the highlight HL."
-  (aref hl 2))
-
-(defun evil-ex-hl-window (hl)
-  "Return the window of the highlight HL."
-  (aref hl 3))
-
-(defun evil-ex-hl-min (hl)
-  "Return the minimal buffer position of the highlight HL."
-  (aref hl 4))
-
-(defun evil-ex-hl-set-min (hl min)
-  "Set the minimal buffer position of the highlight HL to MIN."
-  (aset hl 4 min))
-
-(defun evil-ex-hl-max (hl)
-  "Return the maximal buffer position of the highlight HL."
-  (aref hl 5))
-
-(defun evil-ex-hl-set-max (hl max)
-  "Set the minimal buffer position of the highlight HL to MAX."
-  (aset hl 5 max))
-
-(defun evil-ex-hl-match-hook (hl)
-  "Return the match-hook of the highlight HL."
-  (aref hl 6))
-
-(defun evil-ex-hl-update-hook (hl)
-  "Return the update-hook of the highlight HL."
-  (aref hl 7))
-
-(defun evil-ex-hl-overlays (hl)
-  "Return the list of active overlays of the highlight HL."
-  (aref hl 8))
-
-(defun evil-ex-hl-set-overlays (hl overlays)
-  "Set the list of active overlays of the highlight HL to OVERLAYS."
-  (aset hl 8 overlays))
+  (when (assq name evil-ex-active-highlights-alist)
+    (evil-ex-delete-hl name))
+  (unless evil-ex-active-highlights-alist
+    (add-hook 'window-scroll-functions
+              #'evil-ex-hl-update-highlights-scroll nil t)
+    (add-hook 'window-size-change-functions
+              #'evil-ex-hl-update-highlights-resize nil))
+  (push (cons name (vector name
+                           nil
+                           face
+                           win
+                           min max
+                           match-hook update-hook
+                           nil))
+        evil-ex-active-highlights-alist))
 
 (defun evil-ex-delete-hl (name)
   "Remove the highlighting object with a certain NAME."
-  (let ((hl (cdr-safe (assoc name evil-ex-active-highlights-alist))))
+  (let ((hl (cdr (assq name evil-ex-active-highlights-alist))))
     (when hl
       (mapc #'delete-overlay (evil-ex-hl-overlays hl))
       (setq evil-ex-active-highlights-alist
             (assq-delete-all name evil-ex-active-highlights-alist))
       (evil-ex-hl-update-highlights))
-    (when (null evil-ex-active-highlights-alist)
+    (unless evil-ex-active-highlights-alist
       (remove-hook 'window-scroll-functions
                    #'evil-ex-hl-update-highlights-scroll t)
       (remove-hook 'window-size-change-functions
@@ -579,29 +523,26 @@ The following properties are supported:
 
 (defun evil-ex-hl-active-p (name)
   "Whether the highlight with a certain NAME is active."
-  (and (assoc name evil-ex-active-highlights-alist) t))
+  (and (assq name evil-ex-active-highlights-alist) t))
 
 (defun evil-ex-hl-change (name pattern)
   "Set the regular expression of highlight NAME to PATTERN."
-  (let ((hl (cdr-safe (assoc name evil-ex-active-highlights-alist))))
+  (let ((hl (cdr (assq name evil-ex-active-highlights-alist))))
     (when hl
-      (evil-ex-hl-set-pattern hl
-                              (if (zerop (length pattern))
-                                  nil
-                                pattern))
+      (setf (evil-ex-hl-pattern hl) pattern)
       (evil-ex-hl-idle-update))))
 
 (defun evil-ex-hl-set-region (name beg end &optional _type)
   "Set minimal and maximal position of highlight NAME to BEG and END."
-  (let ((hl (cdr-safe (assoc name evil-ex-active-highlights-alist))))
+  (let ((hl (cdr (assq name evil-ex-active-highlights-alist))))
     (when hl
-      (evil-ex-hl-set-min hl beg)
-      (evil-ex-hl-set-max hl end)
+      (setf (evil-ex-hl-min hl) beg
+            (evil-ex-hl-max hl) end)
       (evil-ex-hl-idle-update))))
 
 (defun evil-ex-hl-get-max (name)
   "Return the maximal position of the highlight with name NAME."
-  (let ((hl (cdr-safe (assoc name evil-ex-active-highlights-alist))))
+  (let ((hl (cdr (assq name evil-ex-active-highlights-alist))))
     (and hl (evil-ex-hl-max hl))))
 
 (defun evil-ex-hl-update-highlights ()
@@ -682,7 +623,7 @@ The following properties are supported:
                             (forward-char))
                            (t (goto-char (match-end 0))))))))
                   (mapc #'delete-overlay old-ovs)
-                  (evil-ex-hl-set-overlays hl new-ovs)
+                  (setf (evil-ex-hl-overlays hl) new-ovs)
                   (if (or (null pattern) new-ovs)
                       (setq result t)
                     ;; Maybe the match could just not be found somewhere else?
@@ -696,20 +637,12 @@ The following properties are supported:
                                                 (match-beginning 0))))
                         (setq result "No match")))))
 
-              (invalid-regexp
-               (setq result (cadr lossage)))
-
-              (search-failed
-               (setq result (nth 2 lossage)))
-
-              (error
-               (setq result (format "%s" (cadr lossage))))
-
-              (user-error
-               (setq result (format "%s" (cadr lossage))))))
+              (invalid-regexp (setq result (cadr lossage)))
+              (search-failed (setq result (nth 2 lossage)))
+              (error (setq result (format "%s" (cadr lossage))))))
         ;; no pattern, remove all highlights
         (mapc #'delete-overlay old-ovs)
-        (evil-ex-hl-set-overlays hl new-ovs))
+        (setf (evil-ex-hl-overlays hl) new-ovs))
       (when (evil-ex-hl-update-hook hl)
         (funcall (evil-ex-hl-update-hook hl) hl result)))))
 
@@ -740,8 +673,7 @@ Note that this function ignores the whole-line property of 
PATTERN."
            (t
             (goto-char pnt)
             ret)))))
-     (t
-      (user-error "Unknown search direction: %s" direction)))))
+     (t (user-error "Unknown search direction `%s'" direction)))))
 
 (defun evil-ex-hl-idle-update ()
   "Trigger the timer to update the highlights in the current buffer."
@@ -785,8 +717,8 @@ This function does nothing if `evil-ex-search-interactive' 
or
       (unless (evil-ex-hl-active-p 'evil-ex-search)
         (evil-ex-make-hl 'evil-ex-search
                          :win (or (minibuffer-selected-window) 
(selected-window))))
-      (if pattern
-          (evil-ex-hl-change 'evil-ex-search pattern)))))
+      (when pattern
+        (evil-ex-hl-change 'evil-ex-search pattern)))))
 
 (defun evil-ex-search (&optional count)
   "Search forward or backward COUNT times for the current ex search pattern.
@@ -1180,7 +1112,7 @@ point."
               evil-ex-last-was-search t)
         ;; update search history unless this pattern equals the
         ;; previous pattern
-        (unless (equal (car-safe evil-ex-search-history) regex)
+        (unless (equal (car evil-ex-search-history) regex)
           (push regex evil-ex-search-history))
         (evil-push-search-history regex (eq direction 'forward)))
       (evil-ex-delete-hl 'evil-ex-search)
diff --git a/evil-tests.el b/evil-tests.el
index c376acefdd..a6c76bce10 100644
--- a/evil-tests.el
+++ b/evil-tests.el
@@ -7864,10 +7864,13 @@ golf h[o]>tel")))
       (":%s/nothere/foo" [return])
       "abc\nd[e]f\nghi"))
   (ert-info ("Substitute up to EOB works")
-    (evil-test-buffer
-      "[f]oo"
+    (evil-test-buffer "[f]oo"
       (":s/foo")
       ""))
+  (ert-info ("Substitute with multi-line replacement")
+    (evil-test-buffer "x"
+      (":s/./foo\\nbar")
+      "foo\n[b]ar"))
   (ert-info ("Use replace count in substitution")
     (evil-test-buffer "xx"
       (":s/./\\#/g")



reply via email to

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