[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/loccur 9cd6c9eb17 10/13: Merge pull request #14 from as
From: |
ELPA Syncer |
Subject: |
[elpa] externals/loccur 9cd6c9eb17 10/13: Merge pull request #14 from astoff/master |
Date: |
Mon, 10 Jun 2024 15:58:53 -0400 (EDT) |
branch: externals/loccur
commit 9cd6c9eb17756156ecedebfb49736654d3706b71
Merge: d4b286a0db 75bbd853d5
Author: Alexey Veretennikov <fourier@protonmail.ch>
Commit: GitHub <noreply@github.com>
Merge pull request #14 from astoff/master
Make the Isearch trick official
---
README.md | 21 ++++++++++-----------
loccur.el | 47 +++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 53 insertions(+), 15 deletions(-)
diff --git a/README.md b/README.md
index 6bcfcb684b..7aaba8f3a2 100644
--- a/README.md
+++ b/README.md
@@ -46,23 +46,22 @@ Below is the list of interactive commands available for
user:
* `loccur-previous-match` repeat previous `loccur` command
* `loccur-no-highlight` is the same as `loccur` but not highlighting matches
* `loccur-toggle-highlight` toggles highlighting of matches
+* `loccur-isearch`: incremental occur (more details below)
### Customization
* `loccur-jump-beginning-of-line` variable specifies if move the cursor to the
beginning of the matching line. Default `nil`
* `loccur-highlight-matching-regexp` variable whenever `loccur` should
highlight matching words. Default `t`.
* `loccur-face` face to be used while highlighting. Default points to
`isearch` face.
-### Tips and tricks
-To combine **Loccur** and **isearch** functionality (narrowing-search) one can
use the following hooks:
-```lisp
-(add-hook 'isearch-update-post-hook
- (lambda ()
- (let ((loccur-mode nil))
- (loccur (regexp-quote isearch-string)))))
-
-(add-hook 'isearch-mode-end-hook
- (lambda ()
- (loccur nil)))
+### Isearch integration
+The `loccur-isearch` command filters buffer lines incrementally as you
+type a search string. It can also be called when Isearch is already
+active to turn filtering on or off. For the latter functionality, you
+should bind the command in `isearch-mode-map`, for example as follows:
+
+``` elisp
+(define-key global-map (kbd "M-s C-o") 'loccur-isearch)
+(define-key isearch-mode-map (kbd "C-o") 'loccur-isearch)
```
diff --git a/loccur.el b/loccur.el
index b184eb2af4..040629791a 100644
--- a/loccur.el
+++ b/loccur.el
@@ -6,10 +6,10 @@
;;
;; Created: 2009-09-08
;; Version: 1.2.4
-;; Package-Requires: ((emacs "24.3"))
+;; Package-Requires: ((emacs "25.1"))
;; Keywords: matching
;; URL: https://github.com/fourier/loccur
-;; Compatibility: GNU Emacs 24.3
+;; Compatibility: GNU Emacs 25.1
;;
;; This file is part of GNU Emacs.
;;
@@ -350,9 +350,48 @@ containing match"
(forward-line 1))
(setq lines (nreverse lines)))))
+(defun loccur-isearch--update ()
+ "Apply `loccur' according the current Isearch state."
+ (let ((loccur-mode nil)
+ (loccur-highlight-matching-regexp nil)
+ (case-fold-search isearch-case-fold-search)
+ (search-spaces-regexp (if (if isearch-regexp
+ isearch-regexp-lax-whitespace
+ isearch-lax-whitespace)
+ search-whitespace-regexp)))
+ (loccur (cond
+ ((functionp isearch-regexp-function)
+ (funcall isearch-regexp-function isearch-string))
+ (isearch-regexp-function (word-search-regexp isearch-string))
+ (isearch-regexp isearch-string)
+ (t (regexp-quote isearch-string))))))
+
+(defun loccur-isearch--exit ()
+ "Deactivate `loccur-isearch'."
+ (remove-hook 'isearch-update-post-hook 'loccur-isearch--update)
+ (remove-hook 'isearch-mode-end-hook 'loccur-isearch--exit)
+ (loccur nil))
-
-
+;;;###autoload
+(defun loccur-isearch (&optional mode)
+ "Incrementally filter buffer lines.
+
+Like Isearch, but hide buffer lines not matching the search
+string. If Isearch is already active, toggle filtering on or
+off.
+
+MODE only has effect if called from outside Isearch, and has the
+same meaning as `search-default-mode'. Interactively, that
+default value is used."
+ (interactive (list search-default-mode))
+ (unless isearch-mode
+ (isearch-mode t (eq t mode) nil nil (and (functionp mode) mode)))
+ (if (memq 'loccur-isearch--update isearch-update-post-hook)
+ (loccur-isearch--exit)
+ (add-hook 'isearch-update-post-hook 'loccur-isearch--update)
+ (add-hook 'isearch-mode-end-hook 'loccur-isearch--exit)
+ (isearch-update))
+ (funcall (or isearch-message-function #'isearch-message)))
(provide 'loccur)
;;; loccur.el ends here
- [elpa] externals/loccur updated (b232bc34d4 -> f47c53a24a), ELPA Syncer, 2024/06/10
- [elpa] externals/loccur 0e3234586d 01/13: Set minimum Emacs version, ELPA Syncer, 2024/06/10
- [elpa] externals/loccur 194d70e6be 04/13: Fixed issue #8, ELPA Syncer, 2024/06/10
- [elpa] externals/loccur 5650277d58 03/13: Implemented solution for the issue #9., ELPA Syncer, 2024/06/10
- [elpa] externals/loccur 650d91dda0 02/13: Merge pull request #7 from syohex/fix-min-version, ELPA Syncer, 2024/06/10
- [elpa] externals/loccur 099e8999b0 05/13: Fixed issue #12, ELPA Syncer, 2024/06/10
- [elpa] externals/loccur 4934c0560d 06/13: Updated version and comments, ELPA Syncer, 2024/06/10
- [elpa] externals/loccur 284d7bb285 07/13: Added melpa badge, ELPA Syncer, 2024/06/10
- [elpa] externals/loccur 9cd6c9eb17 10/13: Merge pull request #14 from astoff/master,
ELPA Syncer <=
- [elpa] externals/loccur 2120345933 11/13: Updated version to 1.2.5, ELPA Syncer, 2024/06/10
- [elpa] externals/loccur d4b286a0db 09/13: Updated contribution information and added license, ELPA Syncer, 2024/06/10
- [elpa] externals/loccur 75bbd853d5 08/13: Add loccur-isearch, ELPA Syncer, 2024/06/10
- [elpa] externals/loccur 01b7afa625 12/13: Updated function names, ELPA Syncer, 2024/06/10
- [elpa] externals/loccur f47c53a24a 13/13: Merge branch 'externals/loccur' of https://git.sv.gnu.org/git/emacs/elpa, ELPA Syncer, 2024/06/10