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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/consult 2aaa9547b3: Tweak file preview (See #538)


From: ELPA Syncer
Subject: [elpa] externals/consult 2aaa9547b3: Tweak file preview (See #538)
Date: Tue, 5 Apr 2022 07:57:24 -0400 (EDT)

branch: externals/consult
commit 2aaa9547b3d74b4bd6638c9821f6db76b8b1d6ba
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Tweak file preview (See #538)
    
    - Replace consult-preview-excluded-hooks with consult-preview-allowed-hooks
    - Increase consult-preview-raw-size
    - Ensure that previewed buffers are read-only
---
 CHANGELOG.org |  2 ++
 README.org    |  4 ++--
 consult.el    | 24 +++++++++++++-----------
 3 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/CHANGELOG.org b/CHANGELOG.org
index e00f8f48ec..7bf8651ed7 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -14,6 +14,8 @@
   to the actual configuration values.
 - Mode hooks in previewed files are delayed. The buffer is only fully
   initialized when leaving the minibuffer for recursive editing.
+- Increase =consult-preview-raw-size=
+- Replace =consult-preview-excluded-hooks= by =consult-preview-allowed-hooks=
 
 * Version 0.16 (2022-03-08)
 
diff --git a/README.org b/README.org
index ce47d32c20..0034252c38 100644
--- a/README.org
+++ b/README.org
@@ -456,7 +456,7 @@ their descriptions.
  The main difference is that the files opened by manual preview are closed 
again
  after the completion session. Furthermore during preview some functionality is
  disabled to improve the performance, see for example
- =consult-preview-excluded-hooks=. Files larger than =consult-preview-raw-size=
+ =consult-preview-allowed-hooks=. Files larger than =consult-preview-raw-size=
  are previewed literally without syntax highlighting and without changing the
  major mode.
 
@@ -946,7 +946,7 @@ configuration examples.
  | consult-mode-histories           | Mode-specific history variables          
             |
  | consult-narrow-key               | Narrowing prefix key during completion   
             |
  | consult-preview-key              | Keys which triggers preview              
             |
- | consult-preview-excluded-hooks   | List of =find-file= hooks to avoid 
during preview       |
+ | consult-preview-allowed-hooks    | List of =find-file= hooks to enable 
during preview      |
  | consult-preview-max-count        | Maximum number of files to keep open 
during preview   |
  | consult-preview-max-size         | Files larger than this size are not 
previewed         |
  | consult-preview-raw-size         | Files larger than this size are 
previewed in raw form |
diff --git a/consult.el b/consult.el
index e439ff7c57..8d518efa80 100644
--- a/consult.el
+++ b/consult.el
@@ -79,7 +79,8 @@ This is the key representation accepted by `define-key'."
   :type '(choice key-sequence (const nil)))
 
 (defvar consult-project-root-function nil)
-(make-obsolete-variable 'consult-project-root-function "Deprecated in favor of 
`consult-project-function'." "0.15")
+(make-obsolete-variable 'consult-project-root-function
+                        "Deprecated in favor of `consult-project-function'." 
"0.15")
 
 (defcustom consult-project-function
   #'consult--default-project-function
@@ -287,7 +288,7 @@ The dynamically computed arguments are appended."
   "Files larger than this byte limit are not previewed."
   :type 'integer)
 
-(defcustom consult-preview-raw-size 102400
+(defcustom consult-preview-raw-size 524288
   "Files larger than this byte limit are previewed in raw form."
   :type 'integer)
 
@@ -295,13 +296,13 @@ The dynamically computed arguments are appended."
   "Number of files to keep open at once during preview."
   :type 'integer)
 
-(defcustom consult-preview-excluded-hooks
-  '(epa-file-find-file-hook
-    recentf-track-opened-file
-    vc-refresh-state)
-  "List of `find-file' hooks, which should not be executed during file preview.
-In particular we don't want to modify the list of recent files and we
-don't want to see epa password prompts."
+(defvar consult-preview-excluded-hooks nil)
+(make-obsolete-variable 'consult-preview-excluded-hooks
+                        "Deprecated in favor of 
`consult-preview-allowed-hooks'." "0.16")
+
+(defcustom consult-preview-allowed-hooks
+  '(global-font-lock-mode-check-buffers)
+  "List of `find-file' hooks, which should be executed during file preview."
   :type '(repeat symbol))
 
 (defcustom consult-bookmark-narrow
@@ -1157,8 +1158,8 @@ MARKER is the cursor position."
                                  name (file-size-human-readable size)))
                  (cl-letf* (((default-value 'delay-mode-hooks) t)
                             ((default-value 'find-file-hook)
-                             (seq-remove (lambda (x)
-                                           (memq x 
consult-preview-excluded-hooks))
+                             (seq-filter (lambda (x)
+                                           (memq x 
consult-preview-allowed-hooks))
                                          (default-value 'find-file-hook)))
                             (buf (find-file-noselect
                                   name 'nowarn
@@ -1167,6 +1168,7 @@ MARKER is the cursor position."
                    (unless (or (memq buf temporary-buffers) (memq buf 
orig-buffers))
                      (add-hook 'window-selection-change-functions hook)
                      (push buf temporary-buffers)
+                     (with-current-buffer buf (setq buffer-read-only t))
                      ;; Only keep a few buffers alive
                      (while (> (length temporary-buffers) 
consult-preview-max-count)
                        (kill-buffer (car (last temporary-buffers)))



reply via email to

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