[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/el-search c69dd52 205/332: * el-search/el-search.el: So
From: |
Stefan Monnier |
Subject: |
[elpa] externals/el-search c69dd52 205/332: * el-search/el-search.el: Some minor tweaks |
Date: |
Tue, 1 Dec 2020 15:48:45 -0500 (EST) |
branch: externals/el-search
commit c69dd52e90455ce5097c337b6caf6fc09f854d76
Author: Michael Heerdegen <michael_heerdegen@web.de>
Commit: Michael Heerdegen <michael_heerdegen@web.de>
* el-search/el-search.el: Some minor tweaks
(el-search-read-pattern-for-interactive): Add docstring.
(el-search-kill-left-over-search-buffers): Improve docstring.
(el-search-install-shift-bindings): Move defun.
(el-search--format-replacement): Decrease `sit-for' waiting time after
messaging the current head file/buffer to 1.0 seconds.
(el-search--search-and-replace-pattern): Use faster
`el-search--search-pattern-1' instead of `el-search-forward' at one
place.
And some comment changes.
---
el-search.el | 100 +++++++++++++++++++++++++++++++++++------------------------
1 file changed, 60 insertions(+), 40 deletions(-)
diff --git a/el-search.el b/el-search.el
index 348b124..435a8bd 100644
--- a/el-search.el
+++ b/el-search.el
@@ -329,7 +329,7 @@
;; to reading-printing. "Some" because we can handle this problem in
;; most cases.
;;
-;; - Similarly: Comments are normally preserved (where it makes
+;; - Similar: comments are normally preserved (where it makes
;; sense). But when replacing like `(foo ,a ,b) -> `(foo ,b ,a)
;;
;; in a content like
@@ -345,8 +345,8 @@
;; backquotes detected!"
;;
;;
-;; Acknowledgments
-;; ===============
+;; Acknowledgments
+;; ===============
;;
;; Thanks to Stefan Monnier for corrections and advice.
;;
@@ -355,6 +355,10 @@
;;
;; - l is very slow for very long lists. E.g. C-S-e (l "test")
;;
+;; - Emacs bug#30132: 27.0.50; "scan-sexps and ##": Occurrences of the
+;; syntax "##" (a syntax for an interned symbol whose name is the
+;; empty string) can lead to errors while searching.
+;;
;;
;; TODO:
;;
@@ -673,6 +677,16 @@ nil."
(if (not (string= input "")) input (car (symbol-value histvar)))))
(defun el-search-read-pattern-for-interactive (&optional prompt)
+ "Read an \"el-search\" pattern from the minibuffer, prompting with PROMPT.
+
+This function is designed to be used in the interactive form of
+\"el-search\" commands that need to prompt for a pattern. Apart
+from reading the pattern it also sets `this-command' to
+`el-search-pattern' and adds the given input to
+`el-search-pattern-history' and `el-search-query-replace-history'.
+
+PROMPT defaults to \"El-search pattern: \". The return value is the
+`read' input pattern."
(let* ((input (el-search--read-pattern (or prompt "El-search pattern: ")
(car el-search-pattern-history)))
(pattern (read input)))
@@ -1014,7 +1028,12 @@ optional MESSAGE are used to construct the error
message."
(defun el-search-kill-left-over-search-buffers (&optional not-current-buffer)
- "Kill all buffers that were opened for searching."
+ "Kill all buffers that were opened just for searching.
+Buffers where a search had been paused or aborted (e.g. by moving
+the cursor) are not killed.
+
+With NOT-CURRENT-BUFFER non-nil, inhibit the current buffer from
+being killed."
(interactive)
(dolist (buffer (buffer-list))
(when (with-current-buffer buffer el-search--temp-buffer-flag)
@@ -1386,6 +1405,41 @@ in, in order, when called with no arguments."
(el-search-compile-pattern-in-search search)
search))
+
+;;;###autoload
+(defun el-search-install-shift-bindings ()
+ (interactive)
+
+ (define-key emacs-lisp-mode-map [(control ?S)] #'el-search-pattern)
+ (define-key emacs-lisp-mode-map [(control ?R)] #'el-search-pattern-backwards)
+ (define-key emacs-lisp-mode-map [(control ?%)] #'el-search-query-replace)
+ (define-key emacs-lisp-mode-map [(control ?H)] #'el-search-this-sexp) ;H
like in "highlight" or "here"
+ (define-key global-map [(control ?J)]
#'el-search-jump-to-search-head)
+ (define-key global-map [(control ?A)] #'el-search-from-beginning)
+ (define-key global-map [(control ?D)] #'el-search-skip-directory)
+ (define-key global-map [(control ?N)]
#'el-search-continue-in-next-buffer)
+
+ (define-key global-map [(control ?O)] #'el-search-occur)
+
+ (define-key el-search-read-expression-map [(control ?S)] #'exit-minibuffer)
+ (define-key el-search-read-expression-map [(control ?R)] #'exit-minibuffer)
+ (define-key el-search-read-expression-map [(control ?O)]
+ #'el-search-set-occur-flag-exit-minibuffer)
+
+ (define-key isearch-mode-map [(control ?S)] #'el-search-search-from-isearch)
+ (define-key isearch-mode-map [(control ?R)]
#'el-search-search-backwards-from-isearch)
+ (define-key isearch-mode-map [(control ?%)] #'el-search-replace-from-isearch)
+ (define-key isearch-mode-map [(control ?O)] #'el-search-occur-from-isearch)
+
+ (define-key global-map [(control ?E)] #'el-search-emacs-elisp-sources)
+ (define-key global-map [(control ?L)] #'el-search-load-path)
+ (define-key global-map [(control ?B)] #'el-search-buffers)
+
+ (defvar dired-mode-map)
+
+ (with-eval-after-load 'dired
+ (define-key dired-mode-map [(control ?S)] #'el-search-dired-marked-files)))
+
(defun el-search-setup-search-1 (pattern get-buffer-stream &optional
from-here setup-function)
(setq el-search--success nil)
(setq el-search--current-search
@@ -1429,40 +1483,6 @@ that contain a file named \".nosearch\" are excluded as
well."
(directory-files dir-name nil "\\`\\.nosearch\\'" t))))))
t #'el-search--elisp-file-p))
-;;;###autoload
-(defun el-search-install-shift-bindings ()
- (interactive)
-
- (define-key emacs-lisp-mode-map [(control ?S)] #'el-search-pattern)
- (define-key emacs-lisp-mode-map [(control ?R)] #'el-search-pattern-backwards)
- (define-key emacs-lisp-mode-map [(control ?%)] #'el-search-query-replace)
- (define-key emacs-lisp-mode-map [(control ?H)] #'el-search-this-sexp) ;H
like in "highlight" or "here"
- (define-key global-map [(control ?J)]
#'el-search-jump-to-search-head)
- (define-key global-map [(control ?A)] #'el-search-from-beginning)
- (define-key global-map [(control ?D)] #'el-search-skip-directory)
- (define-key global-map [(control ?N)]
#'el-search-continue-in-next-buffer)
-
- (define-key global-map [(control ?O)] #'el-search-occur)
-
- (define-key el-search-read-expression-map [(control ?S)] #'exit-minibuffer)
- (define-key el-search-read-expression-map [(control ?R)] #'exit-minibuffer)
- (define-key el-search-read-expression-map [(control ?O)]
- #'el-search-set-occur-flag-exit-minibuffer)
-
- (define-key isearch-mode-map [(control ?S)] #'el-search-search-from-isearch)
- (define-key isearch-mode-map [(control ?R)]
#'el-search-search-backwards-from-isearch)
- (define-key isearch-mode-map [(control ?%)] #'el-search-replace-from-isearch)
- (define-key isearch-mode-map [(control ?O)] #'el-search-occur-from-isearch)
-
- (define-key global-map [(control ?E)] #'el-search-emacs-elisp-sources)
- (define-key global-map [(control ?L)] #'el-search-load-path)
- (define-key global-map [(control ?B)] #'el-search-buffers)
-
- (defvar dired-mode-map)
-
- (with-eval-after-load 'dired
- (define-key dired-mode-map [(control ?S)] #'el-search-dired-marked-files)))
-
;;;; Additional pattern type definitions
@@ -2998,7 +3018,7 @@ Thanks!"))))
(el-search--message-no-log "%s..."
(or (el-search-head-file
head)
(el-search-head-buffer
head)))
- (sit-for 1.5)))
+ (sit-for 1.)))
(while (and (not done) (el-search--search-pattern-1 matcher
t nil heuristic-matcher))
(setq opoint (point))
@@ -3026,7 +3046,7 @@ Thanks!"))))
(el-search--skip-expression new-expr)
(condition-case nil
(progn (el-search--ensure-sexp-start)
- (el-search-forward pattern nil t))
+ (el-search--search-pattern-1 matcher
'noerror))
(end-of-buffer nil))))
(do-replace
(lambda ()
- [elpa] externals/el-search a26b6e0 152/332: Reset wrap flag even when no match, (continued)
- [elpa] externals/el-search a26b6e0 152/332: Reset wrap flag even when no match, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 6919e8d 141/332: Also count pattern types starting with "_" as internal, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search b8e3812 144/332: Improve half-baked introduction of key bindings, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search e96c054 156/332: Handle read errors when reading and validating replacement, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 6f0f22c 155/332: Some details, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 6e6013a 159/332: Fix and speed up the `change' pattern type, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search c878a24 173/332: Fix "Make amount of context around occur matches adjustable", Stefan Monnier, 2020/12/01
- [elpa] externals/el-search f6b1aec 180/332: Some details, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 8583d46 191/332: Fix resuming a single-buffer query-replace, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 365f93f 197/332: * el-search/el-search.el: Some buffer display related minor tweaks, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search c69dd52 205/332: * el-search/el-search.el: Some minor tweaks,
Stefan Monnier <=
- [elpa] externals/el-search c41288f 208/332: Make el-search key binding installation more flexible, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 8d20f8a 217/332: Add face `el-search-highlight-in-prompt-face', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 75f94f9 218/332: Improve quit/error handling in el-search-query-replace, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search b278fb7 219/332: Update a variable when splicing mode is toggled, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 8175417 237/332: * el-search/el-search.el: More minor tweaks, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 1f81442 241/332: [el-search] Improve forward search functions, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 5c3bd4e 247/332: [el-search] Add bindings for first/last match jumping, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 3699425 246/332: [el-search] Add command 'el-search-last-buffer-match', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search cf68daf 249/332: [el-search] Avoid most calls to 'scan-sexps', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 894f8b1 254/332: [el-search] More minor tweaks, Stefan Monnier, 2020/12/01