[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/anzu 8c501d85cd 001/288: init repos
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/anzu 8c501d85cd 001/288: init repos |
Date: |
Thu, 6 Jan 2022 03:58:34 -0500 (EST) |
branch: elpa/anzu
commit 8c501d85cd871e5146c213960ee89f10bba40148
Author: Syohei YOSHIDA <syohex@gmail.com>
Commit: Syohei YOSHIDA <syohex@gmail.com>
init repos
---
README.md | 33 +++++++++++++++
anzu.el | 126 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
image/anzu.gif | Bin 0 -> 624780 bytes
3 files changed, 159 insertions(+)
diff --git a/README.md b/README.md
new file mode 100644
index 0000000000..8f91ff5c31
--- /dev/null
+++ b/README.md
@@ -0,0 +1,33 @@
+# anzu.el
+
+## Introduction
+
+`anzu.el` is Emacs port of [anzu.vim](https://github.com/osyo-manga/vim-anzu).
+`anzu.el` shows search point information on mode-line in isearch-mode.
+
+
+## Screenshot
+
+![anzu.gif](image/anzu.gif)
+
+
+## Requirements
+
+* Emacs 23 or higher
+
+
+## Basic Usage
+
+#### `anzu-mode`
+
+Enable anzu minor mode
+
+#### `global-anzu-mode`
+
+Enable global anzu mode
+
+## Customization
+
+#### `anzu-mode-line`
+
+Face of mode-line anzu information
diff --git a/anzu.el b/anzu.el
new file mode 100644
index 0000000000..20f0d01d15
--- /dev/null
+++ b/anzu.el
@@ -0,0 +1,126 @@
+;;; anzu.el --- Emacs Port of anzu.vim
+
+;; Copyright (C) 2013 by Syohei YOSHIDA
+
+;; Author: Syohei YOSHIDA <syohex@gmail.com>
+;; URL: https://github.com/syohex/emacs-anzu
+;; Version: 0.01
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Code:
+
+(eval-when-compile
+ (require 'cl))
+
+(defgroup anzu nil
+ "Show searched position in mode-line"
+ :group 'isearch)
+
+(defcustom anzu-mode-lighter " Anzu"
+ "Lighter of anzo-mode"
+ :type 'string
+ :group 'anzu)
+
+(defcustom anzu-mode-line-format "(%s/%s)"
+ "Format string of mode-line. This value should have two `%d'
+First `%d' is current position, second `%d' is total number of matched"
+ :type 'string
+ :group 'anzu)
+
+(defface anzu-mode-line
+ '((t (:foreground "magenta" :weight bold)))
+ "face of anzu modeline"
+ :group 'anzu)
+
+(defun anzu--search-all-position (str)
+ (save-excursion
+ (goto-char (point-min))
+ (let ((positions '())
+ (count 0))
+ (while (re-search-forward str nil t)
+ (push (cons (match-beginning 0) (match-end 0)) positions)
+ (incf count))
+ (let ((result (cons count (reverse positions))))
+ (setq anzu--cached-positions (copy-sequence result))
+ result))))
+
+(defun anzu--where-is-here (positions here)
+ (loop for (start . end) in positions
+ for i = 1 then (1+ i)
+ when (and (>= here start) (<= here end))
+ return i
+ finally return 0))
+
+(defvar anzu--total-matched 0)
+(defvar anzu--current-posion 0)
+(defvar anzu--last-isearch-string nil)
+(defvar anzu--cached-positions nil)
+
+(defun anzu--update ()
+ (unless (string= isearch-string "")
+ (let ((result (if (string= isearch-string anzu--last-isearch-string)
+ anzu--cached-positions
+ (anzu--search-all-position isearch-string))))
+ (let ((total (car result))
+ (positions (cdr result)))
+ (setq anzu--total-matched total
+ anzu--current-posion (anzu--where-is-here positions (point))
+ anzu--last-isearch-string isearch-string)
+ (force-mode-line-update)))))
+
+(defsubst anzu--mode-line-not-set-p ()
+ (equal (car mode-line-format) '(:eval (anzu--update-mode-line))))
+
+(defun anzu--cons-mode-line ()
+ (unless (anzu--mode-line-not-set-p)
+ (setq mode-line-format (cons '(:eval (anzu--update-mode-line))
+ mode-line-format))))
+
+(defun anzu--reset-mode-line ()
+ (when (anzu--mode-line-not-set-p)
+ (setq mode-line-format (cdr mode-line-format))))
+
+(defun anzu--update-mode-line ()
+ (propertize (format anzu-mode-line-format anzu--current-posion
anzu--total-matched)
+ 'face 'anzu-mode-line))
+
+;;;###autoload
+(define-minor-mode anzu-mode
+ "anzu"
+ :group 'anzu
+ :init-value nil
+ :global nil
+ :lighter anzu-mode-lighter
+ (if anzu-mode
+ (progn
+ (add-hook 'isearch-update-post-hook 'anzu--update nil t)
+ (add-hook 'isearch-mode-hook 'anzu--cons-mode-line nil t)
+ (add-hook 'isearch-mode-end-hook 'anzu--reset-mode-line nil t))
+ (remove-hook 'isearch-update-post-hook 'anzu--update t)
+ (remove-hook 'isearch-mode-hook 'anzu--cons-mode-line nil t)
+ (remove-hook 'isearch-mode-end-hook 'anzu--reset-mode-line t)))
+
+;;;###autoload
+(define-global-minor-mode global-anzu-mode
+ anzu-mode
+ (lambda ()
+ (unless (minibufferp)
+ (anzu-mode t)))
+ :group 'anzu)
+
+(provide 'anzu)
+;;; anzu.el ends here
diff --git a/image/anzu.gif b/image/anzu.gif
new file mode 100644
index 0000000000..5d8718b0b2
Binary files /dev/null and b/image/anzu.gif differ
- [nongnu] branch elpa/anzu created (now 5abb37455e), ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 51a39670af 005/288: update gif image, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 8c501d85cd 001/288: init repos,
ELPA Syncer <=
- [nongnu] elpa/anzu b61877bf18 006/288: fixed an error at when the variable has a string value, not a list., ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 450b4ddb4b 008/288: Fix byte compile warnings(#1), ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 69518308a0 009/288: Remove needless customization variable, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 9c56ab9875 014/288: Update document about anzu-cons-mode-line-p, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 241af32b99 002/288: Add update mode-line function, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu a52dca6f92 010/288: Support migemo(#2), ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 66807d27a7 012/288: Add Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu c2f8cbc234 016/288: Fix header, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu f570e01b4c 032/288: Merge pull request #8 from bbatsov/doc-improvement, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu f57d1e6ceb 033/288: bump up version and update Changes, ELPA Syncer, 2022/01/06