about summary refs log tree commit diff stats
path: root/.emacs.d/lisp
diff options
context:
space:
mode:
authorDavid Morgan <djm_uk@protonmail.com>2021-09-17 16:37:43 +0100
committerDavid Morgan <djm_uk@protonmail.com>2021-09-17 16:37:43 +0100
commit1447feb491454649da2994b3d18e19869ba65645 (patch)
tree8a2eb3dc81aba91a0203f0682c7a7e215f62b844 /.emacs.d/lisp
parentbe55778d76ad884aefb68b31d0a2ac3e951bcb4a (diff)
downloaddotfiles-1447feb491454649da2994b3d18e19869ba65645.tar.gz
Improve consult-project-buffer
Diffstat (limited to '.emacs.d/lisp')
-rw-r--r--.emacs.d/lisp/init-minibuffer.el38
1 files changed, 22 insertions, 16 deletions
diff --git a/.emacs.d/lisp/init-minibuffer.el b/.emacs.d/lisp/init-minibuffer.el
index 4b5028b..fcad4fa 100644
--- a/.emacs.d/lisp/init-minibuffer.el
+++ b/.emacs.d/lisp/init-minibuffer.el
@@ -336,31 +336,37 @@ DEFS is a plist associating completion categories to commands."
   (add-to-list 'consult-buffer-sources 'consult--source-perspective-files t)
 
   ;; Versions of consult--source-project-buffer and consult--source-project-file for use by consult-project-buffer
-  ;; They allow narrowing with b and f (instead of p)
-  ;; The file version uses fd to find items, so that all files (rather than using recentf) are listed, respecing .gitignore
+  ;; They allow narrowing with b, f and a (instead of p)
+  ;; f is the recentf version provided by consult
+  ;; a is an "all files" version based on fd (respecting .gitignore, hidden by default)
   (defvar consult--project-source-project-buffer
     (plist-put (plist-put (copy-sequence consult--source-project-buffer)
                           :hidden nil)
                :narrow '(?b . "Buffer")))
-  (defvar consult--project-source-project-file
-    (plist-put (plist-put (plist-put (copy-sequence consult--source-project-file)
-                                     :hidden nil)
-                          :narrow '(?f . "File"))
+  (defvar consult--project-source-project-file-recentf
+    (plist-put (plist-put (copy-sequence consult--source-project-file)
+                          :hidden nil)
+               :narrow '(?f . "File (Recentf)")))
+  (defvar consult--project-source-project-file-all
+    (plist-put (plist-put (copy-sequence consult--source-project-file)
+                          :narrow '(?a . "File (All)"))
                :items '(lambda ()
-                         (when-let (root (consult--project-root))
-                           (let ((len (length root))
-                                 (inv-root (propertize root 'invisible t)))
-                             (mapcar (lambda (x)
-                                       (concat inv-root (substring x len)))
-                                     (split-string
-                                      (shell-command-to-string
-                                       (format  "fd --color never -t f -0 . %s" root))
-                                      "\0" t)))))))
+                         (when (eq 0 (call-process-shell-command "fd"))
+                           (when-let (root (consult--project-root))
+                             (let ((len (length root))
+                                   (inv-root (propertize root 'invisible t)))
+                               (mapcar (lambda (x)
+                                         (concat inv-root (substring x len)))
+                                       (split-string
+                                        (shell-command-to-string
+                                         (format  "fd --color never -t f -0 . %s" root))
+                                        "\0" t))))))))
 
   (defun consult-project-buffer ()
     (interactive)
     (let ((consult-buffer-sources '(consult--project-source-project-buffer
-                                    consult--project-source-project-file)))
+                                    consult--project-source-project-file-recentf
+                                    consult--project-source-project-file-all)))
       (consult-buffer)))
 
   (defun consult--orderless-regexp-compiler (input type)



       
                                                    
                                           
                                     
                                                                

                                                                  
                            
                                                               
                                                        
                                                        
Console

   (X) #0   09/12/06  console commands
   (X) #1   09/12/06  quick find
   (X) #2   09/12/06  open with
   (X) #4   09/12/06  history for console
   (X) #13  09/12/27  display docstring of a command


General

   (X) #5   09/12/06  move code from fm into objects
   (X) #6   09/12/06  move main to __init__
   (X) #7   09/12/06  cooler titlebar
   (X) #8   09/12/17  Add operations to modify files/directories
   (X) #9   09/12/24  add a widget for managing running operations
   (X) #10  09/12/24  sorting
   (X) #11  09/12/27  filter
   (X) #12  09/12/27  jump through the list in a specific order
   (X) #14  09/12/29  make filelists inherit from pagers
   ( ) #15  09/12/29  better way of running processes!!~