[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] scratch/mheerdegen-preview e4bf180 25/32: WIP: [el-search] Some m
From: |
Michael Heerdegen |
Subject: |
[elpa] scratch/mheerdegen-preview e4bf180 25/32: WIP: [el-search] Some minor tweaks |
Date: |
Sat, 20 Oct 2018 18:19:02 -0400 (EDT) |
branch: scratch/mheerdegen-preview
commit e4bf180cdf5055ac9add78a6e286652426438535
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 | 52 ++++++++++++++++++++++++++++-----------
2 files changed, 42 insertions(+), 16 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..0a3c9bd 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
- [elpa] scratch/mheerdegen-preview e43d95b 10/32: WIP [el-search] Implement 'el-search-keyboard-quit', (continued)
- [elpa] scratch/mheerdegen-preview e43d95b 10/32: WIP [el-search] Implement 'el-search-keyboard-quit', Michael Heerdegen, 2018/10/20
- [elpa] scratch/mheerdegen-preview 163a7c7 03/32: WIP: Add package "sscell", Michael Heerdegen, 2018/10/20
- [elpa] scratch/mheerdegen-preview 216fd06 07/32: WIP: New file el-search/el-search-pp.el, Michael Heerdegen, 2018/10/20
- [elpa] scratch/mheerdegen-preview 4f3d9bf 11/32: WIP [el-search] Add quick help command, Michael Heerdegen, 2018/10/20
- [elpa] scratch/mheerdegen-preview 5b994a5 17/32: WIP [el-search] Fix C-j with numeric arg in error case, Michael Heerdegen, 2018/10/20
- [elpa] scratch/mheerdegen-preview 54e3b67 16/32: WIP: Optimize caching, Michael Heerdegen, 2018/10/20
- [elpa] scratch/mheerdegen-preview 3aa418f 20/32: WIP: Improvements for change and changed, Michael Heerdegen, 2018/10/20
- [elpa] scratch/mheerdegen-preview 8c8e364 30/32: WIP: Small fix in 'el-search--reset-wrap-flag', Michael Heerdegen, 2018/10/20
- [elpa] scratch/mheerdegen-preview 009dc4d 32/32: WIP: [el-search] Enhance doc of el-search-occur-mode, Michael Heerdegen, 2018/10/20
- [elpa] scratch/mheerdegen-preview 4ce7e1d 06/32: WIP: Add el-search-hi-lock.el, Michael Heerdegen, 2018/10/20
- [elpa] scratch/mheerdegen-preview e4bf180 25/32: WIP: [el-search] Some minor tweaks,
Michael Heerdegen <=
- [elpa] scratch/mheerdegen-preview df185f6 24/32: WIP: Test: Make mouse clicks not abort the search, Michael Heerdegen, 2018/10/20
- [elpa] scratch/mheerdegen-preview a1b1039 21/32: WIP: More colorful match count, Michael Heerdegen, 2018/10/20
- [elpa] scratch/mheerdegen-preview 654133c 26/32: WIP: Don't initially fold occur buffer, Michael Heerdegen, 2018/10/20
- [elpa] scratch/mheerdegen-preview 7de5824 23/32: WIP: Improvise eldoc support for search pattern prompt, Michael Heerdegen, 2018/10/20
- [elpa] scratch/mheerdegen-preview 0275476 09/32: WIP: qr: Make shown replacement editable and ediffable; r twice restores match; stop for problematic comments, Michael Heerdegen, 2018/10/20
- [elpa] scratch/mheerdegen-preview 62fc5c5 14/32: WIP [el-search] Minibuffer hints when entering pattern, Fix case when search pattern fails for some sexps, Michael Heerdegen, 2018/10/20
- [elpa] scratch/mheerdegen-preview a0b93f3 13/32: WIP [el-search] Discourage using symbols as LPATS in `append' and `l', Michael Heerdegen, 2018/10/20
- [elpa] scratch/mheerdegen-preview 2fd5340 28/32: WIP: Add alarm-clock.el, Michael Heerdegen, 2018/10/20