[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dired-preview 8f23847768 17/67: Remove the advice syste
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dired-preview 8f23847768 17/67: Remove the advice system to restore buffer-local mode |
Date: |
Sat, 8 Jul 2023 15:57:52 -0400 (EDT) |
branch: externals/dired-preview
commit 8f238477686ad94ad8978e634a6f3d690ca4017c
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Remove the advice system to restore buffer-local mode
This commit changes the approach that was followed for commit 3304286.
The intention is to still get the same result, but do it in a way that
preserves the original design of a buffer-local minor mode.
This follows from the discussion with Christian Tietze:
<https://lists.sr.ht/~protesilaos/general-issues/%3Cm1zg4noej2.fsf%40christiantietze.de%3E>.
---
dired-preview.el | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/dired-preview.el b/dired-preview.el
index 5171596ce2..cea218a573 100644
--- a/dired-preview.el
+++ b/dired-preview.el
@@ -263,37 +263,38 @@ Only do it with the current major mode is Dired."
(run-with-timer dired-preview-delay nil
#'dired-preview--display-buffer buffer)))
-(defun dired-preview-display-file (&rest _)
+(defun dired-preview-display-file ()
"Display preview of `dired-file-name-at-point' if appropriate.
-Return buffer object of displayed buffer. Ignore any arguments.
-
-Use this as advice after relevant Dired commands (see
-`dired-preview-enable-preview', `dired-preview-disable-preview')."
+Return buffer object of displayed buffer."
(if-let* ((file (dired-file-name-at-point))
(buffer (dired-preview--return-preview-buffer file)))
(dired-preview--display-buffer-with-delay buffer)
(dired-preview--close-previews)))
+(defvar dired-preview-trigger-commands
+ '(dired-next-line dired-previous-line dired-mark dired-goto-file)
+ "List of Dired commands that trigger a preview.")
+
+(defun dired-preview-trigger ()
+ "Trigger display of file at point after `dired-preview-trigger-commands'."
+ (when (memq last-command dired-preview-trigger-commands)
+ (dired-preview-display-file)))
+
(defun dired-preview-disable-preview ()
"Disable Dired preview."
(unless (eq major-mode 'dired-mode)
(error "Can only use `dired-preview' in Dired"))
- (dolist (command '(dired-next-line dired-previous-line dired-mark
dired-goto-file))
- (advice-remove command #'dired-preview-display-file))
+ (remove-hook 'post-command-hook #'dired-preview-trigger :local)
(dired-preview--close-previews))
(defun dired-preview-enable-preview ()
"Enable Dired preview."
(unless (eq major-mode 'dired-mode)
(error "Can only use `dired-preview' in Dired"))
- (dolist (command '(dired-next-line dired-previous-line dired-mark
dired-goto-file))
- (advice-add command :after #'dired-preview-display-file))
+ (add-hook 'post-command-hook #'dired-preview-trigger nil :local)
(add-hook 'post-command-hook #'dired-preview--close-previews-outside-dired
nil :local)
(dired-preview-display-file))
-;; FIXME 2023-06-28: The :global nil and the `advice-add' contradict
-;; each other. I still prefer a buffer-local mode and must thus
-;; arrange for the same job via the `post-command-hook'.
;;;###autoload
(define-minor-mode dired-preview-mode
"Buffer-local mode to preview file at point in Dired."
- [elpa] branch externals/dired-preview created (now 6673bb1cd3), ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview 3304286c17 04/67: Use an advice instead of defining new commands; delete our keymap, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview 4dc5a9f430 06/67: Reorganise a couple of functions, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview 5dd110bea6 02/67: Fix typo in backronym, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview 36afd90371 01/67: Add initial version of dired-preview, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview c89b7ceb32 08/67: Delete negative space, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview caec7a973e 15/67: Add FIXME for the advice and minor mode setup, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview 8f23847768 17/67: Remove the advice system to restore buffer-local mode,
ELPA Syncer <=
- [elpa] externals/dired-preview 6e10fd0381 19/67: Fix how delayed-mode-hooks are called, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview bf30367ffe 21/67: Add FIXME for dired-preview-set-up-preview-window, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview f422a2e2d9 07/67: Check if file exists for previewing, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview ae937209cc 03/67: add advice to dired-mark to preview the current file, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview 80a2233cca 16/67: Update a couple of doc strings, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview 1d3befd70c 20/67: Make sure to unset delayed-mode-hooks after they are ran, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview bf25ef53e1 23/67: Run the preview on an idle timer, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview 3ba4c3f533 25/67: Add FIXME to preview only when it is still the current one, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview 837d3c7e94 14/67: Rename private function, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview 8d545491d4 05/67: Update documentation to match commit 3304286 (command+keymap removal), ELPA Syncer, 2023/07/08