[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] scratch/mheerdegen-preview 10e346c 25/33: WIP: [el-search] Some m
From: |
Michael Heerdegen |
Subject: |
[elpa] scratch/mheerdegen-preview 10e346c 25/33: WIP: [el-search] Some minor tweaks |
Date: |
Wed, 24 Oct 2018 18:30:52 -0400 (EDT) |
branch: scratch/mheerdegen-preview
commit 10e346c73dd28a0640aedfd95294ce6559cbcb8d
Author: Michael Heerdegen <address@hidden>
Commit: Michael Heerdegen <address@hidden>
WIP: [el-search] Some minor tweaks
Add one newline.
>el-search-use-prefix-transient-map, el-search-use-prefix-key-transient-map.
---
packages/el-search/el-search-x.el | 6 ++--
packages/el-search/el-search.el | 67 +++++++++++++++++++++++++++------------
2 files changed, 50 insertions(+), 23 deletions(-)
diff --git a/packages/el-search/el-search-x.el
b/packages/el-search/el-search-x.el
index 1a40322..5b84cb9 100644
--- a/packages/el-search/el-search-x.el
+++ b/packages/el-search/el-search-x.el
@@ -247,8 +247,10 @@ COMMIT defaults to HEAD."
(let ((default-directory repo-root-dir))
(mapcar #'expand-file-name
(split-string
- (shell-command-to-string
- (format "git diff -z --name-only %s --" (shell-quote-argument
commit)))
+ (let ((current-message (current-message)))
+ (with-temp-message (concat current-message " [Running Git...]")
+ (shell-command-to-string
+ (format "git diff -z --name-only %s --"
(shell-quote-argument commit)))))
"\0" t))))
(defvar vc-git-diff-switches)
diff --git a/packages/el-search/el-search.el b/packages/el-search/el-search.el
index ca4cb20..16757cf 100644
--- a/packages/el-search/el-search.el
+++ b/packages/el-search/el-search.el
@@ -425,6 +425,8 @@
;;
;; TODO:
;;
+;; - Add menus?
+;;
;; - Make searching work in comments, too? (->
;; `parse-sexp-ignore-comments'). Related: should the pattern
;; `symbol' also match strings that contain matches for a symbol so
@@ -584,7 +586,7 @@ from the prompt."
(const :tag "On" t)
(const :tag "Ask" ask)))
-(defvar el-search-use-transient-map nil
+(defvar el-search-use-prefix-key-transient-map nil
"Whether el-search should make commands repeatable."
;; I originally wanted to make commands repeatable by looking at the
;; command keys. But that got overly complicated: It interfered with
@@ -612,7 +614,7 @@ from the prompt."
digit-argument negative-argument)
"List of commands that don't end repeatability of el-search commands.
-When `el-search-use-transient-map' is non-nil, when any
+When `el-search-use-prefix-key-transient-map' is non-nil, when any
\"repeatable\" el-search command had been invoked, executing any
of these commands will keep the
`el-search-prefix-key-transient-map' further in effect.")
@@ -788,6 +790,22 @@ nil."
(`(,(pred (equal args)) . ,result) result)
(_ (cdr (setq cached (cons args (apply function args)))))))))
+;; (defun el-search-with-long-term-memory (function &optional predicate)
+;; "Wrap FUNCTION to cache all calls.
+;; With PREDICATE given, only cache calls where the arguments
+;; fulfill PREDICATE. In this case, the last call is always
+;; remembered as in `el-search-with-short-term-memory'."
+;; (let ((cached (make-hash-table :test #'equal)))
+;; (el-search-with-short-term-memory
+;; (lambda (&rest args)
+;; (if-let ((cache-entry (gethash args cached)))
+;; (cdr cache-entry)
+;; (let ((result (apply function args)))
+;; (when (or (not predicate)
+;; (apply predicate args))
+;; (puthash args (cons t result) cached))
+;; result))))))
+
(defmacro el-search-when-unwind (body-form &rest unwindforms)
"Like `unwind-protect' but eval the UNWINDFORMS only if unwinding."
(declare (indent 1))
@@ -1742,13 +1760,12 @@ PATTERN and combining the heuristic matchers of the
subpatterns."
(setq buffer (or (find-buffer-visiting next)
(let ((warning-minimum-level :error)
(inhibit-message t))
- (let ((fresh-buffer (generate-new-buffer "
el-search-helper-buffer"))
- (inhibit-message t))
+ (let ((fresh-buffer (generate-new-buffer "
el-search-helper-buffer")))
(with-current-buffer fresh-buffer
(insert-file-contents next)
(emacs-lisp-mode)
(setq-local el-search--temp-file-buffer-flag
next)
- (setq-local buffer-file-name next) ;make
`file' pattern work as expected
+ (setq-local buffer-file-name next) ;make
`file' pat work as expected
(set-visited-file-modtime)
(set-buffer-modified-p nil))
fresh-buffer)))))
@@ -2032,7 +2049,7 @@ any case."
(defun el-search-prefix-key-maybe-set-transient-map ()
(set-transient-map
- (if el-search-use-transient-map
+ (if el-search-use-prefix-key-transient-map
el-search-prefix-key-transient-map
el-search-basic-transient-map)
(lambda () (or (memq this-command el-search-keep-transient-map-commands)
@@ -2057,7 +2074,7 @@ any case."
(defun el-search-install-bindings-under-prefix (prefix-key)
(el-search-loop-over-bindings
(el-search-bind-under-prefix-key-function prefix-key))
- (setq el-search-use-transient-map t))
+ (setq el-search-use-prefix-key-transient-map t))
(defun el-search-setup-search-1 (pattern get-buffer-stream &optional
from-here setup-function)
(unless el-search-occur-flag
@@ -2129,7 +2146,8 @@ currently enabled."
(`(,(and (pred listp) bindings)
,(pred stringp))
(cl-every
- (lambda (binding) (pcase binding ((or (pred symbolp) `(,(pred symbolp))
`(,(pred symbolp) ,_)) t)))
+ (lambda (binding)
+ (pcase binding ((or (pred symbolp) `(,(pred symbolp)) `(,(pred
symbolp) ,_)) t)))
bindings))))
(defun el-search--string-matcher (regexp-like)
@@ -2411,7 +2429,8 @@ function implicitly (but support to specify a :key
nonetheless)."
(el-search-defpattern dir (&rest regexps)
"Like \"filename\" but matches REGEXPS against directory names."
- (declare (heuristic-matcher (apply-partially #'el-search--filename-matcher
#'el-search--file-directory))
+ (declare (heuristic-matcher (apply-partially #'el-search--filename-matcher
+ #'el-search--file-directory))
(inverse-heuristic-matcher t))
(el-search-defpattern--check-args "dir"
(if (eq (car-safe regexps) :key) (cddr
regexps) regexps)
@@ -2569,7 +2588,8 @@ created.")
(largest-match-start-not-after-pos-here nil))
(pcase-let ((`(,_ ,_ ,matches)
el-search--buffer-match-count-data))
(setq total-matches (let ((inhibit-message t))
(seq-length matches)))
- (while (and (not (stream-empty-p matches)) (<
(stream-first matches) (cdr defun-bounds)))
+ (while (and (not (stream-empty-p matches))
+ (< (stream-first matches) (cdr
defun-bounds)))
(when (<= (stream-first matches) pos-here)
(setq largest-match-start-not-after-pos-here
(stream-first matches))
(unless (= (stream-first matches) pos-here)
@@ -2628,7 +2648,8 @@ created.")
(concat (if (not just-count) "[Not at a match]
" "")
(if (= matches-<=-here total-matches)
(format "(%s/%s <-)" matches-<=-here
total-matches)
- (format "(-> %s/%s)" (1+
matches-<=-here) total-matches))))))))))))
+ (format "(-> %s/%s)" (1+
matches-<=-here) total-matches)))))))))
+ )))
(when quit-flag (el-search-keyboard-quit 'dont-quit)))))
(defun el-search-hl-other-matches (matcher)
@@ -2884,7 +2905,8 @@ continued."
(and from-here
(save-excursion
(goto-char (point-min))
- (el-search--search-pattern-1 matcher
t nil heuristic-matcher)))))
+ (el-search--search-pattern-1
+ matcher t nil heuristic-matcher)))))
(progn
(el-search--message-no-log "No matches")
(sit-for .7))
@@ -3208,7 +3230,8 @@ Use the normal search commands to seize the search."
(if (and symbol-at-point-text
;; That should ideally be always true but
isn't
(condition-case nil
- (symbolp (setq symbol-at-point
(el-search-read symbol-at-point-text)))
+ (symbolp (setq symbol-at-point
+ (el-search-read
symbol-at-point-text)))
(invalid-read-syntax nil)))
symbol-at-point
(if (thing-at-point 'sexp)
@@ -3589,7 +3612,8 @@ Prompt for a new pattern and revert."
(when (< cbeg context-beg)
(setq context-beg cbeg)
(setq context-end
- (or
(el-search--end-of-sexp cbeg) context-end)))))))))
+ (or
(el-search--end-of-sexp cbeg)
+
context-end)))))))))
(setq matches
(car (stream-divide-with-get-rest-fun
buffer-matches+counts+contexts
@@ -4325,15 +4349,16 @@ modify it")
(not (alist-get
'is-single-buffer
(el-search-object-properties
el-search--current-search)))
- (eq (car
(read-multiple-choice
- "Replace in
all following buffers?"
- '((?! "Only
this"
- "\
+ (eq
+ (car
(read-multiple-choice
+ "Also replace in
all following buffers?"
+ '((?! "Only this"
+ "\
Replace only remaining matches in this buffer")
- (?A "All
buffers"
- "\
+ (?A "All
buffers"
+ "\
Replace all matches in all buffers"))))
- ?A))
+ ?A))
(setq replace-all-and-following
t))
(setq replace-all t)
(unless replaced-this (funcall
do-replace))
- [elpa] scratch/mheerdegen-preview fb5a73b 30/33: WIP: Small fix in 'el-search--reset-wrap-flag', (continued)
- [elpa] scratch/mheerdegen-preview fb5a73b 30/33: WIP: Small fix in 'el-search--reset-wrap-flag', Michael Heerdegen, 2018/10/24
- [elpa] scratch/mheerdegen-preview 86f4f18 17/33: WIP [el-search] Fix C-j with numeric arg in error case, Michael Heerdegen, 2018/10/24
- [elpa] scratch/mheerdegen-preview 1d22a6c 14/33: WIP [el-search] Minibuffer hints when entering pattern, Fix case when search pattern fails for some sexps, Michael Heerdegen, 2018/10/24
- [elpa] scratch/mheerdegen-preview 0e37f94 28/33: WIP: Add alarm-clock.el, Michael Heerdegen, 2018/10/24
- [elpa] scratch/mheerdegen-preview 6a048a7 26/33: WIP: Don't initially fold occur buffer, Michael Heerdegen, 2018/10/24
- [elpa] scratch/mheerdegen-preview 6de70fb 20/33: WIP: Improvements for change and changed, Michael Heerdegen, 2018/10/24
- [elpa] scratch/mheerdegen-preview 0d07bb8 33/33: WIP: [el-search] Don't kill modified buffers, Michael Heerdegen, 2018/10/24
- [elpa] scratch/mheerdegen-preview 8391d56 31/33: WIP: Small fix in el-search--changed-files-in-repo, Michael Heerdegen, 2018/10/24
- [elpa] scratch/mheerdegen-preview 19bbc05 21/33: WIP: More colorful match count, Michael Heerdegen, 2018/10/24
- [elpa] scratch/mheerdegen-preview 4900664 29/33: WIP: Fix C-A and C-J after finished single-buffer search, Michael Heerdegen, 2018/10/24
- [elpa] scratch/mheerdegen-preview 10e346c 25/33: WIP: [el-search] Some minor tweaks,
Michael Heerdegen <=
- [elpa] scratch/mheerdegen-preview dc25f93 09/33: WIP: qr: Make shown replacement editable and ediffable; r twice restores match; stop for problematic comments, Michael Heerdegen, 2018/10/24
- [elpa] scratch/mheerdegen-preview ae9928e 06/33: WIP: Add el-search-hi-lock.el, Michael Heerdegen, 2018/10/24