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

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

[elpa] master c7a6156 22/22: Merge commit 'e2452a3e77ef6ea6b193292d2c0bb


From: Oleh Krehel
Subject: [elpa] master c7a6156 22/22: Merge commit 'e2452a3e77ef6ea6b193292d2c0bbbe93dd4b078' from swiper
Date: Wed, 22 Apr 2015 19:51:53 +0000

branch: master
commit c7a61562ece53fb673269352706efa452022672c
Merge: e86b27e e2452a3
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    Merge commit 'e2452a3e77ef6ea6b193292d2c0bbbe93dd4b078' from swiper
---
 packages/swiper/README.md   |    6 +-
 packages/swiper/counsel.el  |   53 +++++----
 packages/swiper/ivy-test.el |    8 +-
 packages/swiper/ivy.el      |  290 ++++++++++++++++++++++++++-----------------
 packages/swiper/swiper.el   |   32 +++---
 5 files changed, 230 insertions(+), 159 deletions(-)

diff --git a/packages/swiper/README.md b/packages/swiper/README.md
index 6482463..7f06e50 100644
--- a/packages/swiper/README.md
+++ b/packages/swiper/README.md
@@ -13,4 +13,8 @@ The package uses the `ivy` back end for the overview, see also
 
 ![ivy-swiper-1.png](http://oremacs.com/download/ivy-swiper-1.png)
 
-There's also a one minute [video 
demo](https://www.youtube.com/watch?v=s3qwiAtKjuA).
+There's also a ten minute [video 
demo](https://www.youtube.com/watch?v=VvnJQpTFVDc).
+
+## Issues
+
+Recently, the `ivy` package that provided `ivy.el` was removed from MELPA.  
Now, the `swiper` package provides `ivy.el`. You should remove the outdated 
`ivy` package from your system.
diff --git a/packages/swiper/counsel.el b/packages/swiper/counsel.el
index 7ad7787..a99bda8 100644
--- a/packages/swiper/counsel.el
+++ b/packages/swiper/counsel.el
@@ -66,6 +66,9 @@
            (error "Couldn't fild definition of %s"
                   sym)))))
 
+(defvar counsel-describe-symbol-history nil
+  "History for `counsel-describe-variable' and `counsel-describe-function'.")
+
 (defun counsel-describe-variable (variable &optional buffer frame)
   "Forward to (`describe-variable' VARIABLE BUFFER FRAME)."
   (interactive
@@ -75,10 +78,7 @@
          val)
      (setq ivy--action nil)
      (setq val (ivy-read
-                (if (symbolp v)
-                    (format
-                     "Describe variable (default %s): " v)
-                  "Describe variable: ")
+                "Describe variable: "
                 (let (cands)
                   (mapatoms
                    (lambda (vv)
@@ -86,8 +86,11 @@
                                (and (boundp vv) (not (keywordp vv))))
                        (push (symbol-name vv) cands))))
                   cands)
-                nil nil counsel-describe-map preselect
-                nil t))
+                :keymap counsel-describe-map
+                :preselect preselect
+                :history 'counsel-describe-symbol-history
+                :require-match t
+                :sort t))
      (list (if (equal val "")
                v
              (intern val)))))
@@ -102,17 +105,18 @@
          (preselect (thing-at-point 'symbol))
          val)
      (setq ivy--action nil)
-     (setq val (ivy-read (if fn
-                             (format "Describe function (default %s): " fn)
-                           "Describe function: ")
+     (setq val (ivy-read "Describe function: "
                          (let (cands)
                            (mapatoms
                             (lambda (x)
                               (when (fboundp x)
                                 (push (symbol-name x) cands))))
                            cands)
-                         nil nil counsel-describe-map preselect
-                         nil t))
+                         :keymap counsel-describe-map
+                         :preselect preselect
+                         :history 'counsel-describe-symbol-history
+                         :require-match t
+                         :sort t))
      (list (if (equal val "")
                fn (intern val)))))
   (unless (eq ivy--action 'counsel--find-symbol)
@@ -181,11 +185,15 @@
     (when file
       (find-file file))))
 
+(defvar counsel--git-grep-dir nil
+  "Store the base git directory.")
+
 (defun counsel-git-grep-count (str)
   "Quickly count the amount of git grep STR matches."
-  (let ((out (shell-command-to-string
-              (format "git grep -c '%s' | sed 's/.*:\\(.*\\)/\\1/g' | awk 
'{s+=$1} END {print s}'"
-                      (ivy--regex str)))))
+  (let* ((default-directory counsel--git-grep-dir)
+         (out (shell-command-to-string
+               (format "git grep -i -c '%s' | sed 's/.*:\\(.*\\)/\\1/g' | awk 
'{s+=$1} END {print s}'"
+                       (ivy--regex str)))))
     (string-to-number out)))
 
 (defvar counsel--git-grep-count nil
@@ -199,14 +207,15 @@
         (setq ivy--full-length counsel--git-grep-count)
         (list ""
               (format "%d chars more" (- 3 (length ivy-text)))))
-    (let ((cmd (format "git --no-pager grep --full-name -n --no-color -i -e 
\"%s\""
-                       (ivy--regex string t)))
-          res)
+    (let* ((default-directory counsel--git-grep-dir)
+           (cmd (format "git --no-pager grep --full-name -n --no-color -i -e 
\"%s\""
+                        (ivy--regex string t)))
+           res)
       (if (<= counsel--git-grep-count 20000)
           (progn
             (setq res (shell-command-to-string cmd))
             (setq ivy--full-length nil))
-        (setq res (shell-command-to-string (concat cmd " | head -n 5000")))
+        (setq res (shell-command-to-string (concat cmd " | head -n 2000")))
         (setq ivy--full-length (counsel-git-grep-count ivy-text)))
       (split-string res "\n" t))))
 
@@ -214,14 +223,14 @@
   "Grep for a string in the current git repository."
   (interactive)
   (unwind-protect
-       (let* ((counsel--git-grep-count (counsel-git-grep-count ""))
+       (let* ((counsel--git-grep-dir (locate-dominating-file
+                                      default-directory ".git"))
+              (counsel--git-grep-count (counsel-git-grep-count ""))
               (ivy--dynamic-function (when (> counsel--git-grep-count 20000)
                                        'counsel-git-grep-function))
-              (git-dir (locate-dominating-file
-                        default-directory ".git"))
               (ivy--persistent-action (lambda (x)
                                         (setq lst (split-string x ":"))
-                                        (find-file (expand-file-name (car lst) 
git-dir))
+                                        (find-file (expand-file-name (car lst) 
counsel--git-grep-dir))
                                         (goto-char (point-min))
                                         (forward-line (1- (string-to-number 
(cadr lst))))
                                         (setq swiper--window (selected-window))
diff --git a/packages/swiper/ivy-test.el b/packages/swiper/ivy-test.el
index 957f824..13a1467 100644
--- a/packages/swiper/ivy-test.el
+++ b/packages/swiper/ivy-test.el
@@ -45,12 +45,6 @@
 
 (ert-deftest ivy-read ()
   (should (equal
-           (ivy-read "pattern: " nil)
-           nil))
-  (should (equal
-           (ivy-read "pattern: " '("42"))
-           "42"))
-  (should (equal
            (ivy-with '(ivy-read "pattern: " '("blue" "yellow"))
                      "C-m")
            "blue"))
@@ -65,4 +59,4 @@
   (should (equal
            (ivy-with '(ivy-read "pattern: " '("blue" "yellow"))
                      "z C-m")
-           nil)))
+           "z")))
diff --git a/packages/swiper/ivy.el b/packages/swiper/ivy.el
index b83b1f0..6fca361 100644
--- a/packages/swiper/ivy.el
+++ b/packages/swiper/ivy.el
@@ -103,6 +103,7 @@ Only \"./\" and \"../\" apply here. They appear in reverse 
order."
     (define-key map (kbd "M-v") 'ivy-scroll-down-command)
     (define-key map (kbd "C-M-n") 'ivy-next-line-and-call)
     (define-key map (kbd "C-M-p") 'ivy-previous-line-and-call)
+    (define-key map (kbd "M-q") 'ivy-toggle-regexp-quote)
     map)
   "Keymap used in the minibuffer.")
 
@@ -162,53 +163,80 @@ When non-nil, it should contain one %d.")
 (defvar ivy--old-cands nil
   "Store the candidates matched by `ivy--old-re'.")
 
+(defvar ivy--regex-function 'ivy--regex
+  "Current function for building a regex.")
+
 ;;** Commands
 (defun ivy-done ()
   "Exit the minibuffer with the selected candidate."
   (interactive)
   (delete-minibuffer-contents)
-  (cond (ivy--directory
-         (insert
-          (cond ((string= ivy-text "")
-                 (if (equal ivy--current "./")
-                     ivy--directory
-                   (if (string-match "\\*" ivy--current)
-                       ivy--current
-                     (expand-file-name ivy--current ivy--directory))))
-                ((zerop ivy--length)
-                 (expand-file-name ivy-text ivy--directory))
-                (t
-                 (expand-file-name ivy--current ivy--directory))))
-         (setq ivy-exit 'done))
-        ((zerop ivy--length)
-         (when (memq ivy-require-match
-                     '(nil confirm confirm-after-completion))
-           (insert ivy-text)
-           (setq ivy-exit 'done)))
-        (t
-         (insert ivy--current)
-         (setq ivy-exit 'done)))
-  (exit-minibuffer))
-
-(defun ivy-alt-done ()
-  "Exit the minibuffer with the selected candidate."
+  (when (cond (ivy--directory
+               (insert
+                (cond ((string= ivy-text "")
+                       (if (equal ivy--current "./")
+                           ivy--directory
+                         (if (string-match "\\*" ivy--current)
+                             ivy--current
+                           (expand-file-name ivy--current ivy--directory))))
+                      ((zerop ivy--length)
+                       (expand-file-name ivy-text ivy--directory))
+                      (t
+                       (expand-file-name ivy--current ivy--directory))))
+               (setq ivy-exit 'done))
+              ((zerop ivy--length)
+               (if (memq ivy-require-match
+                         '(nil confirm confirm-after-completion))
+                   (progn
+                     (insert ivy-text)
+                     (setq ivy-exit 'done))
+                 (unless (string-match "match required" ivy--prompt)
+                   (setq ivy--prompt
+                         (if (string-match ": $" ivy--prompt)
+                             (concat
+                              (substring ivy--prompt 0 -2)
+                              " (match required): ")
+                           (concat
+                            ivy--prompt
+                            "(match required) "))))
+                 (insert ivy-text)
+                 (ivy--exhibit)
+                 nil))
+              (t
+               (insert ivy--current)
+               (setq ivy-exit 'done)))
+    (exit-minibuffer)))
+
+(defun ivy-alt-done (&optional arg)
+  "Exit the minibuffer with the selected candidate.
+When ARG is t, exit with current text, ignoring the candidates."
+  (interactive "P")
+  (if arg
+      (ivy-immediate-done)
+    (let (dir)
+      (cond ((and ivy--directory
+                  (= 0 ivy--index)
+                  (= 0 (length ivy-text)))
+             (ivy-done))
+
+            ((and ivy--directory
+                  (cl-plusp ivy--length)
+                  (file-directory-p
+                   (setq dir (expand-file-name
+                              ivy--current ivy--directory))))
+             (ivy--cd dir)
+             (ivy--exhibit))
+
+            (t
+             (ivy-done))))))
+
+(defun ivy-immediate-done ()
+  "Exit the minibuffer with the current input."
   (interactive)
-  (let (dir)
-    (cond ((and ivy--directory
-                (= 0 ivy--index)
-                (= 0 (length ivy-text)))
-           (ivy-done))
-
-          ((and ivy--directory
-                (cl-plusp ivy--length)
-                (file-directory-p
-                 (setq dir (expand-file-name
-                            ivy--current ivy--directory))))
-           (ivy--cd dir)
-           (ivy--exhibit))
-
-          (t
-           (ivy-done)))))
+  (delete-minibuffer-contents)
+  (insert ivy-text)
+  (setq ivy-exit 'done)
+  (exit-minibuffer))
 
 (defun ivy-beginning-of-buffer ()
   "Select the first completion candidate."
@@ -323,6 +351,15 @@ On error (read-only), call `ivy-on-del-error-function'."
        (when ivy-on-del-error-function
          (funcall ivy-on-del-error-function))))))
 
+(defvar ivy--regexp-quote 'regexp-quote
+  "Store the regexp quoting state.")
+
+(defun ivy-toggle-regexp-quote ()
+  "Toggle the regexp quoting."
+  (interactive)
+  (setq ivy--old-re nil)
+  (cl-rotatef ivy--regex-function ivy--regexp-quote))
+
 (defun ivy-sort-file-function-default (x y)
   "Compare two files X and Y.
 Prioritize directories."
@@ -339,10 +376,17 @@ Prioritize directories."
     (internal-complete-buffer . nil)
     (counsel-git-grep-function . nil)
     (t . string-lessp))
-  "And alist of sorting functions for each collection function.
+  "An alist of sorting functions for each collection function.
 For each entry, nil means no sorting.
 The entry associated to t is used for all fall-through cases.")
 
+(defvar ivy-re-builders-alist
+  '((t . ivy--regex))
+  "An alist of regex building functions for each collection function.
+Each function should take a string and return a valid regex.
+The entry associated to t is used for all fall-through cases.
+Possible choices: `ivy--regex', `regexp-quote'.")
+
 (defcustom ivy-sort-max-size 30000
   "Sorting won't be done for collections larger than this."
   :type 'integer)
@@ -366,17 +410,12 @@ Directories come first."
         (setq seq (cl-sort seq sort-fn)))
       (dolist (dir ivy-extra-directories)
         (push dir seq))
-      (cl-case (length seq)
-        (0
-         '("" ""))
-        (1
-         (cons "" seq))
-        (t
-         seq)))))
+      seq)))
 
 ;;** Entry Point
-(defun ivy-read (prompt collection
-                 &optional predicate initial-input keymap preselect update-fn 
sort)
+(cl-defun ivy-read (prompt collection
+                           &key predicate require-match initial-input
+                           history preselect keymap update-fn sort)
   "Read a string in the minibuffer, with completion.
 
 PROMPT is a string to prompt with; normally it ends in a colon
@@ -397,7 +436,15 @@ UPDATE-FN is called each time the current candidate(s) is 
changed.
 
 When SORT is t, refer to `ivy-sort-functions-alist' for sorting."
   (setq ivy--directory nil)
+  (setq ivy-require-match require-match)
   (setq ivy-window (selected-window))
+  (setq ivy--regex-function
+        (or (and (functionp collection)
+                 (cdr (assoc collection ivy-re-builders-alist)))
+            (cdr (assoc t ivy-re-builders-alist))
+            'ivy--regex))
+  (setq ivy--subexps 0)
+  (setq ivy--regexp-quote 'regexp-quote)
   (let (coll sort-fn)
     (cond ((eq collection 'Info-read-node-name-1)
            (if (equal Info-current-file "dir")
@@ -409,9 +456,13 @@ When SORT is t, refer to `ivy-sort-functions-alist' for 
sorting."
              (setq coll (all-completions "" collection predicate))))
           ((eq collection 'read-file-name-internal)
            (setq ivy--directory default-directory)
-           (setq initial-input nil)
            (setq coll
-                 (ivy--sorted-files default-directory)))
+                 (ivy--sorted-files default-directory))
+           (when initial-input
+             (unless (or require-match
+                         (equal initial-input default-directory))
+               (setq coll (cons initial-input coll)))
+             (setq initial-input nil)))
           ((or (functionp collection)
                (vectorp collection)
                (listp (car collection)))
@@ -430,57 +481,54 @@ When SORT is t, refer to `ivy-sort-functions-alist' for 
sorting."
                  (<= (length coll) ivy-sort-max-size))
             (setq coll (cl-sort (copy-sequence coll) sort-fn)))))
     (when preselect
-      (unless (or ivy-require-match
-                  (all-completions preselect collection))
+      (unless (or require-match
+                  (member preselect coll))
         (setq coll (cons preselect coll))))
-    (cl-case (length coll)
-      (0 nil)
-      (1 (car coll))
-      (t
-       (setq ivy--index (or
-                         (and preselect
-                              (ivy--preselect-index
-                               coll initial-input preselect))
-                         0))
-       (setq ivy--old-re nil)
-       (setq ivy--old-cands nil)
-       (setq ivy-text "")
-       (setq ivy--all-candidates coll)
-       (setq ivy--update-fn update-fn)
-       (setq ivy-exit nil)
-       (setq ivy--default (or (thing-at-point 'symbol) ""))
-       (setq ivy--prompt
-             (cond ((string-match "%.*d" prompt)
-                    prompt)
-                   ((string-match "%.*d" ivy-count-format)
-                    (concat ivy-count-format prompt))
-                   (ivy--directory
-                    prompt)
-                   (t
-                    nil)))
-       (setq ivy--action nil)
-       (prog1
-           (unwind-protect
-                (minibuffer-with-setup-hook
-                    #'ivy--minibuffer-setup
-                  (let ((res (read-from-minibuffer
-                              prompt
-                              initial-input
-                              (make-composed-keymap keymap ivy-minibuffer-map)
-                              nil
-                              'ivy-history)))
-                    (when (eq ivy-exit 'done)
-                      (pop ivy-history)
-                      (setq ivy-history
-                            (cons ivy-text (delete ivy-text ivy-history)))
-                      res)))
-             (remove-hook 'post-command-hook #'ivy--exhibit))
-         (when ivy--action
-           (funcall ivy--action)))))))
+    (setq ivy--index (or
+                      (and preselect
+                           (ivy--preselect-index
+                            coll initial-input preselect))
+                      0))
+    (setq ivy--old-re nil)
+    (setq ivy--old-cands nil)
+    (setq ivy-text "")
+    (setq ivy--all-candidates coll)
+    (setq ivy--update-fn update-fn)
+    (setq ivy-exit nil)
+    (setq ivy--default (or (thing-at-point 'symbol) ""))
+    (setq ivy--prompt
+          (cond ((string-match "%.*d" prompt)
+                 prompt)
+                ((string-match "%.*d" ivy-count-format)
+                 (concat ivy-count-format prompt))
+                (ivy--directory
+                 prompt)
+                (t
+                 nil)))
+    (setq ivy--action nil)
+    (prog1
+        (unwind-protect
+             (minibuffer-with-setup-hook
+                 #'ivy--minibuffer-setup
+               (let* ((hist (or history 'ivy-history))
+                      (res (read-from-minibuffer
+                            prompt
+                            initial-input
+                            (make-composed-keymap keymap ivy-minibuffer-map)
+                            nil
+                            hist)))
+                 (when (eq ivy-exit 'done)
+                   (set hist (cons ivy-text
+                                   (delete ivy-text
+                                           (cdr (symbol-value hist)))))
+                   res)))
+          (remove-hook 'post-command-hook #'ivy--exhibit))
+      (when ivy--action
+        (funcall ivy--action)))))
 
 (defun ivy-completing-read (prompt collection
                             &optional predicate require-match initial-input
-                              _history def _inherit-input-method)
+                              history def _inherit-input-method)
   "Read a string in the minibuffer, with completion.
 
 This is an interface that conforms to `completing-read', so that
@@ -499,8 +547,14 @@ _INHERIT-INPUT-METHOD is ignored for now.
 The history, defaults and input-method arguments are ignored for now."
   (when (listp def)
     (setq def (car def)))
-  (setq ivy-require-match require-match)
-  (ivy-read prompt collection predicate initial-input nil def nil t))
+  (ivy-read prompt collection
+            :predicate predicate
+            :require-match require-match
+            :initial-input initial-input
+            :preselect def
+            :history history
+            :keymap nil
+            :sort t))
 
 ;;;###autoload
 (define-minor-mode ivy-mode
@@ -574,8 +628,6 @@ When GREEDY is non-nil, join words in a greedy way."
   (set (make-local-variable 'minibuffer-default-add-function)
        (lambda ()
          (list ivy--default)))
-  (use-local-map (make-composed-keymap ivy-minibuffer-map
-                                       (current-local-map)))
   (setq-local max-mini-window-height ivy-height)
   (add-hook 'post-command-hook #'ivy--exhibit nil t)
   ;; show completions with empty input
@@ -633,13 +685,14 @@ Should be run via minibuffer `post-command-hook'."
   (if ivy--dynamic-function
       ;; while-no-input would cause annoying
       ;; "Waiting for process to die...done" message interruptions
-      (progn
-        (unless (equal ivy--old-text ivy-text)
-          (let ((store ivy--dynamic-function)
-                (ivy--dynamic-function nil))
-            (setq ivy--all-candidates (funcall store ivy-text)))
-          (setq ivy--old-text ivy-text))
-        (ivy--insert-minibuffer (ivy--format ivy--all-candidates)))
+      (let ((inhibit-message t))
+       (while-no-input
+         (unless (equal ivy--old-text ivy-text)
+           (let ((store ivy--dynamic-function)
+                 (ivy--dynamic-function nil))
+             (setq ivy--all-candidates (funcall store ivy-text)))
+           (setq ivy--old-text ivy-text))
+         (ivy--insert-minibuffer (ivy--format ivy--all-candidates))))
     (when ivy--directory
       (if (string-match "/$" ivy-text)
           (if (member ivy-text ivy--all-candidates)
@@ -668,17 +721,19 @@ Should be run via minibuffer `post-command-hook'."
   "Propertize STR with FACE.
 `font-lock-append-text-property' is used, since it's better than
 `propertize' or `add-face-text-property' in this case."
-  (font-lock-append-text-property 0 (length str) 'face face str)
+  (ignore-errors
+    (font-lock-append-text-property 0 (length str) 'face face str))
   str)
 
 (defun ivy--filter (name candidates)
   "Return the matches for NAME for CANDIDATES.
 CANDIDATES are assumed to be static."
-  (let* ((re (ivy--regex name))
+  (let* ((re (funcall ivy--regex-function name))
          (cands (cond ((and (equal re ivy--old-re)
                             ivy--old-cands)
                        ivy--old-cands)
                       ((and ivy--old-re
+                            (not (string-match "\\\\" ivy--old-re))
                             (not (equal ivy--old-re ""))
                             (memq (cl-search
                                    (if (string-match "\\\\)$" ivy--old-re)
@@ -698,7 +753,14 @@ CANDIDATES are assumed to be static."
          idx)
     (when (and tail ivy--old-cands)
       (unless (and (not (equal re ivy--old-re))
-                   (setq ivy--index (cl-position re cands :test 'equal)))
+                   (or (setq ivy--index
+                             (or
+                              (cl-position re cands
+                                           :test 'equal)
+                              (and ivy--directory
+                                   (cl-position
+                                    (concat re "/") cands
+                                    :test 'equal))))))
         (while (and tail (null idx))
           ;; Compare with eq to handle equal duplicates in cands
           (setq idx (cl-position (pop tail) cands)))
diff --git a/packages/swiper/swiper.el b/packages/swiper/swiper.el
index b46702b..c58f20f 100644
--- a/packages/swiper/swiper.el
+++ b/packages/swiper/swiper.el
@@ -90,8 +90,9 @@
       (delete-minibuffer-contents)
       (setq ivy--action
             (lambda ()
-              (perform-replace from to
-                               t t t)))
+              (with-selected-window swiper--window
+                (perform-replace from to
+                                 t t t))))
       (swiper--cleanup)
       (exit-minibuffer))))
 
@@ -186,11 +187,11 @@ When non-nil, INITIAL-INPUT is the initial search 
pattern."
                     (replace-regexp-in-string
                      "%s" "pattern: " swiper--format-spec)
                     candidates
-                    nil
-                    initial-input
-                    swiper-map
-                    preselect
-                    #'swiper--update-input-ivy))
+                    :initial-input initial-input
+                    :keymap swiper-map
+                    :preselect preselect
+                    :require-match t
+                    :update-fn #'swiper--update-input-ivy))
       (swiper--cleanup)
       (if (null ivy-exit)
           (goto-char swiper--opoint)
@@ -236,8 +237,9 @@ When non-nil, INITIAL-INPUT is the initial search pattern."
           (recenter)))
       (swiper--add-overlays re))))
 
-(defun swiper--add-overlays (re)
-  "Add overlays for RE regexp in visible part of the current buffer."
+(defun swiper--add-overlays (re &optional beg end)
+  "Add overlays for RE regexp in visible part of the current buffer.
+BEG and END, when specified, are the point bounds."
   (let ((ov (make-overlay
              (line-beginning-position)
              (1+ (line-end-position)))))
@@ -245,12 +247,12 @@ When non-nil, INITIAL-INPUT is the initial search 
pattern."
     (overlay-put ov 'window swiper--window)
     (push ov swiper--overlays))
   (let* ((wh (window-height))
-         (beg (save-excursion
-                (forward-line (- wh))
-                (point)))
-         (end (save-excursion
-                (forward-line wh)
-                (point))))
+         (beg (or beg (save-excursion
+                        (forward-line (- wh))
+                        (point))))
+         (end (or end (save-excursion
+                        (forward-line wh)
+                        (point)))))
     (when (>= (length re) swiper-min-highlight)
       (save-excursion
         (goto-char beg)



reply via email to

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