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

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

[nongnu] elpa/anzu 7dc4abe0a0 274/288: Merge branch 'master' into fix93


From: ELPA Syncer
Subject: [nongnu] elpa/anzu 7dc4abe0a0 274/288: Merge branch 'master' into fix93
Date: Thu, 6 Jan 2022 03:59:00 -0500 (EST)

branch: elpa/anzu
commit 7dc4abe0a05eac2bee6ea9a1dbeca2457b6e2d31
Merge: 177a328830 5bd8f5511d
Author: Neil Okamoto <neil.okamoto@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge branch 'master' into fix93
---
 .circleci/config.yml | 63 ++++++++++++++++++++++++++++++++++++++++++
 .gitignore           |  2 ++
 Cask                 |  1 +
 Makefile             | 48 ++++++++++++++++++++++++++++++++
 README.md            | 18 +++++++++++-
 anzu.el              | 77 ++++++++++++++++++++++++++++++----------------------
 6 files changed, 176 insertions(+), 33 deletions(-)

diff --git a/.circleci/config.yml b/.circleci/config.yml
new file mode 100644
index 0000000000..a8f07d76b1
--- /dev/null
+++ b/.circleci/config.yml
@@ -0,0 +1,63 @@
+version: 2.1
+
+# Default actions to perform on each Emacs version
+commands:
+  default-steps:
+    steps:
+      - checkout
+      - run: make version
+      - run: make lint
+      - run: make test
+
+# Enumerated list of Emacs versions
+jobs:
+  test-emacs-25:
+    docker:
+      - image: silex/emacs:25-dev
+        entrypoint: bash
+    steps:
+      - default-steps
+
+  test-emacs-26:
+    docker:
+      - image: silex/emacs:26-dev
+        entrypoint: bash
+    steps:
+      - default-steps
+
+  test-emacs-27:
+    docker:
+      - image: silex/emacs:27-dev
+        entrypoint: bash
+    steps:
+      - default-steps
+
+  test-emacs-master:
+    docker:
+      - image: silex/emacs:master-dev
+        entrypoint: bash
+    steps:
+      - default-steps
+
+  # coverage:
+  #   docker:
+  #     - image: silex/emacs:26-dev
+  #       entrypoint: bash
+  #   steps:
+  #     - checkout
+  #     - run: make submit-coverage
+
+# Executing in parallel
+workflows:
+  ci-test-matrix:
+    jobs:
+      - test-emacs-25
+      - test-emacs-26
+      - test-emacs-27
+      - test-emacs-master
+      # - coverage:
+      #     requires:
+      #     - test-emacs-25
+      #     - test-emacs-26
+      #     - test-emacs-27
+      #     - test-emacs-master
diff --git a/.gitignore b/.gitignore
index 64b10531aa..0c6eefb308 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
 /.cask/
+*.elc
+*-autoloads.*
diff --git a/Cask b/Cask
index 3352d705a4..5672dd13b6 100644
--- a/Cask
+++ b/Cask
@@ -4,5 +4,6 @@
 (package-file "anzu.el")
 
 (development
+ (depends-on "elisp-lint")
  (depends-on "powerline")
  (depends-on "migemo"))
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000000..ee7e7d1406
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,48 @@
+.PHONY : clean distclean lint test version
+
+EMACS ?= emacs
+CASK ?= cask
+
+LOADPATH = -L .
+
+ELPA_DIR = $(shell EMACS=$(EMACS) $(CASK) package-directory)
+AUTOLOADS = $(wildcard *-autoloads.el*)
+ELS = $(filter-out $(AUTOLOADS),$(wildcard *.el))
+OBJECTS = $(ELS:.el=.elc)
+BACKUPS = $(ELS:.el=.el~)
+
+version: elpa
+       $(CASK) exec $(EMACS) --version
+
+lint: elpa
+       $(CASK) exec $(EMACS) -Q --batch $(LOADPATH) \
+           -l elisp-lint.el \
+           -f elisp-lint-files-batch \
+           --no-checkdoc \
+           --no-fill-column \
+           $(ELS)
+
+# test: elpa
+#      $(CASK) exec $(EMACS) -Q -batch $(LOADPATH) \
+#              -l test/test.el \
+#              -f ert-run-tests-batch-and-exit
+
+elpa: $(ELPA_DIR)
+$(ELPA_DIR): Cask
+       mkdir -p $(ELPA_DIR)/gnupg && \
+       chmod 700 $(ELPA_DIR)/gnupg && \
+       echo "disable-ipv6" > $(ELPA_DIR)/gnupg/dirmngr.conf && \
+       for i in {1..3}; do \
+       gpg --keyserver keyserver.ubuntu.com \
+           --homedir $(ELPA_DIR)/gnupg \
+           --recv-keys 066DAFCB81E42C40 \
+           && break || sleep 15; \
+       done
+       $(CASK) install
+       touch $@
+
+clean:
+       rm -rf $(OBJECTS) $(BACKUPS) $(AUTOLOADS)
+
+distclean:
+       rm -rf .cask
diff --git a/README.md b/README.md
index a74b67eac1..7a57f28755 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,8 @@
-# anzu.el [![melpa badge][melpa-badge]][melpa-link] [![melpa stable 
badge][melpa-stable-badge]][melpa-stable-link]
+# anzu.el
+
+[![melpa badge][melpa-badge]][melpa-link]
+[![melpa stable badge][melpa-stable-badge]][melpa-stable-link]
+[![circleci badge][circleci-badge]][circleci-link]
 
 ## Introduction
 
@@ -6,6 +10,16 @@
 `anzu.el` provides a minor mode which displays *current match* and *total 
matches*
 information in the mode-line in various search modes.
 
+## New Maintainer
+
+This package has a new maintainer as of March 2020, and based on the
+valuable contribution of insights and fixes from the author, you
+should see issues from years past are now getting resolved.  You may
+also see instability in the short term.  Please bear with us.  Note
+that we have a tag on version 0.62 (dated August 2016) which was the
+last version published before a period of dormancy.  You can get that
+version from MELPA stable if for any reason the recent changes aren't
+working for you.
 
 ## Screenshot
 
@@ -221,5 +235,7 @@ Separator of `to` string.
 
 [melpa-link]: https://melpa.org/#/anzu
 [melpa-stable-link]: https://stable.melpa.org/#/anzu
+[circleci-link]: https://app.circleci.com/pipelines/github/emacsorphanage/anzu
 [melpa-badge]: https://melpa.org/packages/anzu-badge.svg
 [melpa-stable-badge]: https://stable.melpa.org/packages/anzu-badge.svg
+[circleci-badge]: 
https://img.shields.io/circleci/project/github/emacsorphanage/anzu.svg
diff --git a/anzu.el b/anzu.el
index c2993b1eb5..0aaae37fe3 100644
--- a/anzu.el
+++ b/anzu.el
@@ -1,9 +1,10 @@
 ;;; anzu.el --- Show number of matches in mode-line while searching -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2016 by Syohei YOSHIDA
+;; Copyright (C) 2016-2020 Syohei YOSHIDA and Neil Okamoto
 
 ;; Author: Syohei YOSHIDA <syohex@gmail.com>
-;; URL: https://github.com/syohex/emacs-anzu
+;; Maintainer: Neil Okamoto <neil.okamoto+melpa@gmail.com>
+;; URL: https://github.com/emacsorphanage/anzu
 ;; Version: 0.62
 ;; Package-Requires: ((emacs "24.3"))
 
@@ -39,8 +40,6 @@
 (require 'cl-lib)
 (require 'thingatpt)
 
-(declare-function migemo-forward 'migemo)
-
 (defgroup anzu nil
   "Show searched position in mode-line"
   :group 'isearch)
@@ -204,7 +203,7 @@
               (finish nil)
               (search-func (if (anzu--use-migemo-p)
                                (lambda (word &optional bound noerror count)
-                                 (ignore-errors
+                                 (with-no-warnings
                                    (migemo-forward word bound noerror count)))
                              #'re-search-forward))
               (case-fold-search (anzu--case-fold-search)))
@@ -380,7 +379,7 @@
 
 ;; Return highlighted count
 (defun anzu--count-and-highlight-matched (buf str replace-beg replace-end
-                                          use-regexp overlay-limit 
case-sensitive)
+                                              use-regexp overlay-limit 
case-sensitive)
   (anzu--cleanup-markers)
   (when (not use-regexp)
     (setq str (regexp-quote str)))
@@ -388,24 +387,28 @@
       anzu--cached-count
     (with-current-buffer buf
       (save-excursion
-        (let* ((overlay-beg replace-beg)
-               (overlay-end (min replace-end overlay-limit)))
-          (goto-char overlay-beg)
+        (let* ((backward (> replace-beg replace-end))
+               (overlay-beg (if backward (max replace-end overlay-limit) 
replace-beg))
+               (overlay-end (if backward replace-beg (min replace-end 
overlay-limit))))
+          (goto-char replace-beg)
           (let ((count 0)
                 (overlayed 0)
                 (finish nil)
+                (cmp-func (if backward #'< #'>))
+                (search-func (if backward #'re-search-backward 
#'re-search-forward))
+                (step (if backward -1 1))
                 (case-fold-search (if case-sensitive
                                       nil
-                                    (anzu--case-fold-search))))
-            (while (and (not finish) (re-search-forward str replace-end t))
+                                    (anzu--case-fold-search str))))
+            (while (and (not finish) (funcall search-func str replace-end t))
               (cl-incf count)
               (let ((beg (match-beginning 0))
                     (end (match-end 0)))
                 (when (= beg end)
                   (if (eobp)
                       (setq finish t)
-                    (forward-char 1)))
-                (when (and replace-end (> (point) replace-end))
+                    (forward-char step)))
+                (when (and replace-end (funcall cmp-func (point) replace-end))
                   (setq finish t))
                 (when (and (>= beg overlay-beg) (<= end overlay-end) (not 
finish))
                   (cl-incf overlayed)
@@ -414,13 +417,15 @@
             overlayed))))))
 
 (defun anzu--search-outside-visible (buf input beg end use-regexp)
-  (let ((searchfn (if use-regexp #'re-search-forward #'search-forward)))
-    (when (or (not use-regexp) (anzu--validate-regexp input))
+  (let* ((regexp (if use-regexp input (regexp-quote input)))
+         (backward (> beg end))
+         (searchfn (if backward #'re-search-backward #'re-search-forward)))
+    (when (anzu--validate-regexp regexp)
       (with-selected-window (get-buffer-window buf)
         (goto-char beg)
-        (when (funcall searchfn input end t)
+        (when (funcall searchfn regexp end t)
           (setq anzu--outside-point (match-beginning 0))
-          (let ((overlay-limit (anzu--overlay-limit)))
+          (let ((overlay-limit (anzu--overlay-limit backward)))
             (anzu--count-and-highlight-matched buf input beg end use-regexp
                                                overlay-limit nil)))))))
 
@@ -556,7 +561,7 @@
   (< (overlay-start a) (overlay-start b)))
 
 (defsubst anzu--overlays-in-range (beg end)
-  (cl-loop for ov in (overlays-in beg end)
+  (cl-loop for ov in (overlays-in (min beg end) (max beg end))
            when (overlay-get ov 'anzu-replace)
            collect ov into anzu-overlays
            finally
@@ -638,10 +643,10 @@
      to)
    use-regexp))
 
-(defun anzu--overlay-limit ()
+(defun anzu--overlay-limit (backward)
   (save-excursion
-    (move-to-window-line -1)
-    (forward-line 1)
+    (move-to-window-line (if backward 1 -1))
+    (forward-line (if backward -1 1))
     (point)))
 
 (defun anzu--query-from-at-cursor (buf beg end overlay-limit)
@@ -678,9 +683,9 @@
 
 (defun anzu--region-begin (use-region thing backward)
   (cond (use-region (region-beginning))
-        (current-prefix-arg (line-beginning-position))
+        (backward (point))
         (thing (anzu--thing-begin thing))
-        (backward (point-min))
+        (current-prefix-arg (line-beginning-position))
         (t (point))))
 
 (defsubst anzu--line-end-position (num)
@@ -688,8 +693,9 @@
     (forward-line (1- num))
     (line-end-position)))
 
-(defun anzu--region-end (use-region thing)
+(defun anzu--region-end (use-region thing backward)
   (cond (use-region (region-end))
+        (backward (point-min))
         (current-prefix-arg
          (anzu--line-end-position (prefix-numeric-value current-prefix-arg)))
         (thing (anzu--thing-end thing))
@@ -734,16 +740,20 @@
   (save-excursion
     (goto-char beg)
     (cl-loop with curbuf = (current-buffer)
-             with search-func = (if use-regexp #'re-search-forward 
#'search-forward)
-             while (funcall search-func from end t)
+             with backward = (> beg end)
+             with input = (if use-regexp from (regexp-quote from))
+             with search-func = (if backward #'re-search-backward 
#'re-search-forward)
+             with cmp-func = (if backward #'< #'>)
+             with step = (if backward -1 1)
+             while (funcall search-func input end t)
              do
              (progn
                (anzu--set-marker (match-beginning 0) curbuf)
                (when (= (match-beginning 0) (match-end 0))
                  (if (eobp)
                      (cl-return nil)
-                   (forward-char 1)))
-               (when (and end (> (point) end))
+                   (forward-char step)))
+               (when (and end (funcall cmp-func (point) end))
                  (cl-return nil))))))
 
 (cl-defun anzu--query-replace-common (use-regexp
@@ -752,9 +762,9 @@
   (let* ((use-region (use-region-p))
          (orig-point (point))
          (backward (anzu--replace-backward-p prefix-arg))
-         (overlay-limit (anzu--overlay-limit))
+         (overlay-limit (anzu--overlay-limit backward))
          (beg (anzu--region-begin use-region (anzu--begin-thing at-cursor 
thing) backward))
-         (end (anzu--region-end use-region thing))
+         (end (anzu--region-end use-region thing backward))
          (prompt (anzu--query-prompt use-region use-regexp at-cursor 
isearch-p))
          (delimited (and current-prefix-arg (not (eq current-prefix-arg '-))))
          (curbuf (current-buffer))
@@ -783,7 +793,7 @@
                          (t
                           (anzu--query-replace-read-to
                            from prompt beg end use-regexp overlay-limit)))))
-          (anzu--clear-overlays curbuf beg end)
+          (anzu--clear-overlays curbuf (min beg end) (max beg end))
           (anzu--set-replaced-markers from beg end use-regexp)
           (setq anzu--state 'replace anzu--current-position 0
                 anzu--replaced-markers (reverse anzu--replaced-markers)
@@ -796,7 +806,7 @@
                                       from to delimited beg end backward)))))
       (progn
         (unless clear-overlay
-          (anzu--clear-overlays curbuf beg end))
+          (anzu--clear-overlays curbuf (min beg end) (max beg end)))
         (when (zerop anzu--current-position)
           (goto-char orig-point))
         (anzu--cleanup-markers)
@@ -868,7 +878,10 @@
   (anzu--isearch-query-replace-common t arg))
 
 (provide 'anzu)
+
 ;; Local Variables:
 ;; indent-tabs-mode: nil
+;; fill-column: 85
 ;; End:
+
 ;;; anzu.el ends here



reply via email to

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