emacs-elpa-diffs
[Top][All Lists]
Advanced

[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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]