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

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

[elpa] externals/swiper 3aede8e 2/3: Merge branch 'master' into external


From: Basil L. Contovounesios
Subject: [elpa] externals/swiper 3aede8e 2/3: Merge branch 'master' into externals/swiper
Date: Sun, 19 Sep 2021 08:29:50 -0400 (EDT)

branch: externals/swiper
commit 3aede8e384e1bb736a3055fcbb2dd3a6d262a464
Merge: 9393004 9baa442
Author: Basil L. Contovounesios <contovob@tcd.ie>
Commit: Basil L. Contovounesios <contovob@tcd.ie>

    Merge branch 'master' into externals/swiper
---
 .github/workflows/test.yml | 52 ++++++++++++++++++++++++++++++++++++++++++++++
 swiper.el                  | 31 ++++++++++++++++++++++-----
 2 files changed, 78 insertions(+), 5 deletions(-)

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..11e6514
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,52 @@
+name: CI
+on:
+  pull_request:
+    paths-ignore:
+    - '**.md'
+    - '**.org'
+    - '.dir-locals.el'
+    - '.elpaignore'
+    - '.gitignore'
+    - 'doc/**'
+    branches:
+      - master
+  push:
+    paths-ignore:
+    - '**.md'
+    - '**.org'
+    - '.dir-locals.el'
+    - '.elpaignore'
+    - '.gitignore'
+    - 'doc/**'
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+    strategy:
+      fail-fast: false
+      matrix:
+        emacs_version:
+          - 24.5
+          - 25.1
+          - 25.2
+          - 25.3
+          - 26.1
+          - 26.2
+          - 26.3
+          - 27.1
+          - snapshot
+
+    steps:
+    - uses: purcell/setup-emacs@master
+      with:
+        version: ${{ matrix.emacs_version }}
+
+    - uses: actions/checkout@v2
+
+    - name: Check Emacs version
+      run: emacs --version
+
+    - name: Test
+      run: |
+        make deps
+        make test
diff --git a/swiper.el b/swiper.el
index fe4fbb7..f3bebab 100644
--- a/swiper.el
+++ b/swiper.el
@@ -1481,11 +1481,15 @@ that we search only for one character."
     (dolist (re (swiper--positive-regexps))
       (swiper--add-overlays re))))
 
+(defun swiper--isearch-candidate-pos (cand)
+  "Return the buffer position of `swiper-isearch' CAND, or nil."
+  (cond ((integer-or-marker-p cand) cand)
+        ((and (stringp cand) (> (length cand) 0))
+         (get-text-property 0 'point cand))))
+
 (defun swiper-isearch-action (x)
   "Move to X for `swiper-isearch'."
-  (if (or (numberp x)
-          (and (> (length x) 0)
-               (setq x (get-text-property 0 'point x))))
+  (if (setq x (swiper--isearch-candidate-pos x))
       (with-ivy-window
         (goto-char x)
         (when (and (or (eq this-command 'ivy-previous-line-or-history)
@@ -1495,7 +1499,11 @@ that we search only for one character."
           (goto-char (match-beginning 0)))
         (funcall isearch-filter-predicate (point) (1+ (point)))
         (swiper--maybe-recenter)
-        (if (eq ivy-exit 'done)
+        (if (or (eq ivy-exit 'done)
+                ;; FIXME: With the default action 'M-o o', `ivy-exit' remains
+                ;; nil for some reason, so check `this-command' instead to
+                ;; tell whether we're "done".
+                (eq this-command #'ivy-dispatching-done))
             (progn
               (swiper--push-mark)
               (swiper--remember-search-history (ivy--regex ivy-text)))
@@ -1512,7 +1520,20 @@ that we search only for one character."
     (line-beginning-position) (line-end-position)))
   (goto-char swiper--opoint))
 
-(ivy-add-actions 'swiper-isearch '(("w" swiper-action-copy "copy")))
+(defun swiper-isearch-action-copy (cand)
+  "Save `swiper-isearch' candidate CAND to `kill-ring'.
+Return to original position."
+  (unwind-protect
+      (progn
+        (unless (and (setq cand (swiper--isearch-candidate-pos cand))
+                     ;; FIXME: Better way of getting current candidate?
+                     (goto-char cand)
+                     (looking-back (ivy-re-to-str ivy-regex) (point-min)))
+          (error "Could not copy `swiper-isearch' candidate: %S" cand))
+        (kill-new (match-string 0)))
+    (goto-char swiper--opoint)))
+
+(ivy-add-actions 'swiper-isearch '(("w" swiper-isearch-action-copy "copy")))
 (ivy-add-actions 'swiper '(("w" swiper-action-copy "copy")))
 
 (defun swiper-isearch-thing-at-point ()



reply via email to

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