[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/el-search c0947c3 295/332: [el-search] Minibuffer patte
From: |
Stefan Monnier |
Subject: |
[elpa] externals/el-search c0947c3 295/332: [el-search] Minibuffer pattern prompt hints part 1: preparations |
Date: |
Tue, 1 Dec 2020 15:49:07 -0500 (EST) |
branch: externals/el-search
commit c0947c31f17f461cefef0b22462d2a29a2c30a55
Author: Michael Heerdegen <michael_heerdegen@web.de>
Commit: Michael Heerdegen <michael_heerdegen@web.de>
[el-search] Minibuffer pattern prompt hints part 1: preparations
* packages/el-search/el-search.el
(el-search--pattern-is-unquoted-symbol-p): New helper function
factored out of 'el-search--maybe-warn-about-unquoted-symbol'.
(el-search--maybe-warn-about-unquoted-symbol): Use it.
(el-search--all-matches): When the new optional argument DONT-COPY is
non-nil, don't use a copy of the given search object to build the
match stream, use the given search directly.
(el-search-display-mb-hints, el-search-mb-hints-delay)
(el-search-mb-hints-timeout): New user options.
(el-search--make-display-animation-function): New helper function to
construct animation functions.
(el-search-query-replace--read-args): Bind new special var
'el-search--reading-input-for-query-replace' non-nil when reading
FROM pattern.
(el-search--search-pattern-1-do-fun): New variable that will be used
to display animations in the minibuffer or echo area.
(el-search--search-pattern-1): Call value of new variable
'el-search--search-pattern-1-do-fun' when non-nil repeatedly while
searching.
---
el-search.el | 54 +++++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 47 insertions(+), 7 deletions(-)
diff --git a/el-search.el b/el-search.el
index 2a389e1..f3a25b0 100644
--- a/el-search.el
+++ b/el-search.el
@@ -474,6 +474,21 @@
"Expression based search and replace for Emacs Lisp."
:group 'lisp)
+(defcustom el-search-display-mb-hints t
+ "Whether to show hints in the search pattern prompt."
+ :type 'boolean)
+
+(defcustom el-search-mb-hints-delay 0.8
+ "Time before displaying minibuffer hints.
+
+Setting this has only an effect if `el-search-display-mb-hints'
+is non-nil."
+ :type 'number)
+
+(defcustom el-search-mb-hints-timeout 15
+ "How long to display minibuffer hints."
+ :type 'number)
+
(defface el-search-match '((((class color) (min-colors 88) (background dark))
(:background "#600000"))
(((class color) (min-colors 88) (background light))
@@ -863,10 +878,13 @@ nil."
input)
(symbol-value histvar)))))
+(defun el-search--pattern-is-unquoted-symbol-p (pattern)
+ (and (symbolp pattern)
+ (not (eq pattern '_))
+ (not (keywordp pattern))))
+
(defun el-search--maybe-warn-about-unquoted-symbol (pattern)
- (when (and (symbolp pattern)
- (not (eq pattern '_))
- (not (keywordp pattern)))
+ (when (el-search--pattern-is-unquoted-symbol-p pattern)
(message "Free variable `%S' (missing a quote?)" pattern)
(sit-for 2.)))
@@ -876,6 +894,25 @@ nil."
(el-search--pushnew-to-history input histvar)
(if (not (string= input "")) input (car (symbol-value histvar)))))
+(defvar el-search--reading-input-for-query-replace nil)
+
+(defvar el-search--search-pattern-1-do-fun nil)
+(defvar el-search--busy-animation
+ ;; '("." "o" "O" "o" "." " ")
+ ;; '("|" "/" "-" "\\")
+ '("* " " * " " * " " *" " * " " * "))
+(defvar el-search-mb-anim-time .33)
+
+(defun el-search--make-display-animation-function (display-fun)
+ (let ((last-update (seconds-to-time 0))
+ (anim (copy-sequence el-search--busy-animation)))
+ (setcdr (last anim) anim)
+ (lambda ()
+ (let ((now (current-time)))
+ (when (< el-search-mb-anim-time (float-time (time-subtract now
last-update)))
+ (setq last-update now)
+ (funcall display-fun (pop anim)))))))
+
(defun el-search-read-pattern-for-interactive (&optional prompt)
"Read an \"el-search\" pattern from the minibuffer, prompting with PROMPT.
@@ -1154,6 +1191,8 @@ be specified as fourth argument, and COUNT becomes the
fifth argument."
(let ((match-beg nil) current-expr)
(if (catch 'no-match
(while (not match-beg)
+ (when el-search--search-pattern-1-do-fun
+ (funcall el-search--search-pattern-1-do-fun))
(condition-case nil
(setq current-expr (el-search--ensure-sexp-start))
(end-of-buffer (throw 'no-match t)))
@@ -1654,7 +1693,7 @@ With ALLOW-LEADING-WHITESPACE non-nil, the match may
be preceded by whitespace."
(el-search--looking-at-1 (el-search-make-matcher pattern)
allow-leading-whitespace))
-(defun el-search--all-matches (search)
+(defun el-search--all-matches (search &optional dont-copy)
"Return a stream of all matches of SEARCH.
The returned stream will always start searching from the
beginning anew even when SEARCH has been used interactively or
@@ -1668,7 +1707,7 @@ The elements of the returned stream will have the form
where BUFFER or FILE is the buffer or file where a match has been
found (exactly one of the two will be nil), and MATCH-BEG is the
position of the beginning of the match."
- (let* ((search (el-search-reset-search (copy-el-search-object search)))
+ (let* ((search (if dont-copy search (el-search-reset-search
(copy-el-search-object search))))
(head (el-search-object-head search)))
(seq-filter
#'identity ;we use `nil' as a "skip" tag
@@ -4401,8 +4440,9 @@ Don't save this buffer and all following buffers; don't
ask again"))))
(el-search-read (car
el-search-query-replace-history)))
(car el-search-query-replace-history)
(car el-search-pattern-history))))))
- (el-search--read-pattern "Query replace pattern: " nil
-
'el-search-query-replace-history)))
+ (let ((el-search--reading-input-for-query-replace t))
+ (el-search--read-pattern "Query replace pattern: " nil
+
'el-search-query-replace-history))))
from to read-from read-to)
(with-temp-buffer
(emacs-lisp-mode)
- [elpa] externals/el-search 668d049 302/332: [el-search] Add el-search-list-defined-patterns, (continued)
- [elpa] externals/el-search 668d049 302/332: [el-search] Add el-search-list-defined-patterns, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search bb978b2 306/332: [el-search] Fix behavior after completed single-buffer search, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 985ca3c 312/332: [el-search] Add "List patterns" menu item, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search f5e8235 321/332: [el-search] C-c C-c in edit-replacement means replace, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 9d8798f 140/332: Work around more manifestations of Emacs bug #24542, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 7d621de 216/332: * el-search/el-search.el: Some minor tweaks, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 29eeda2 228/332: Show progress of automatic el-search-query-replace, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 4b934f1 238/332: * el-search/el-search.el: Skip over #N read syntaxes, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 01d4431 269/332: [el-search] Don't initially fold El Occur buffers, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 1169ef1 294/332: [el-search] Add accessible buffer area to a validity check, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search c0947c3 295/332: [el-search] Minibuffer pattern prompt hints part 1: preparations,
Stefan Monnier <=
- [elpa] externals/el-search 749aa0c 300/332: [el-search] Improvements for 'change' and 'changed', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search e522b71 305/332: [el-search] Enhance docstring of el-search-occur-mode, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search fdc4663 308/332: [el-search] Bump version to 1.11.1, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search e790747 309/332: [el-search] Fix quits in minibuffer in emacs -nw, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 39da179 313/332: [el-search] Minibuffer pattern prompt hints part 3, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 01c663b 315/332: [el-search] Make el-search-query-replace resumable, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search c95de2b 317/332: [el-search] Shorten el-search-query-replace prompt again, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 76d63d9 326/332: [el-search] Extend possible search domains, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 0212cf9 328/332: * packages/el-search/el-search.el: New command el-search-repository, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 6df1362 332/332: * .gitignore: New file, Stefan Monnier, 2020/12/01