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

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

[elpa] externals/dired-duplicates 3c16f56388 48/57: Install workarounds


From: ELPA Syncer
Subject: [elpa] externals/dired-duplicates 3c16f56388 48/57: Install workarounds for Emacs Dired bug #57565
Date: Sat, 4 Nov 2023 06:58:31 -0400 (EDT)

branch: externals/dired-duplicates
commit 3c16f563880453ad65e1b19ec92d7c4c5a6269f2
Author: Harald Judt <h.judt@gmx.at>
Commit: Harald Judt <h.judt@gmx.at>

    Install workarounds for Emacs Dired bug #57565
    
    In current release versions, Emacs has a bug that causes the dired buffer 
not
    to update properly after delete operations. While a fix has been applied to 
and
    will be available in the future, old versions will continue to suffer from
    this. This commit installs a workaround by providing supplemental functions 
for
    dired-duplicates dired buffers only, modifying the local keymap without
    hopefully touching any other dired buffers.
    
    This fix will only be applied for Emacs versions < 29, which has not been
    released yet, but will hopefully contain this fix.
    
    Reference:
    https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=1d9e4900
---
 dired-duplicates.el | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/dired-duplicates.el b/dired-duplicates.el
index b9fc64b015..a9e46c85f9 100644
--- a/dired-duplicates.el
+++ b/dired-duplicates.el
@@ -200,6 +200,40 @@ The args ARG and NOCONFIRM are passed through from
     (dired-duplicates--post-process-dired-buffer results))
   (message "Reverting buffer complete."))
 
+(when (< emacs-major-version 29)
+  (defun dired-duplicates--do-delete (&optional arg)
+    "Delete all marked (or next ARG) files.
+
+This is the same as `dired-do-delete', but calls
+`dired-duplicates-dired-revert' afterwards."
+    (interactive)
+    (dired-do-delete arg)
+    (dired-duplicates-dired-revert)))
+
+(when (< emacs-major-version 29)
+  (defun dired-duplicates--do-flagged-delete (&optional nomessage)
+    "Delete flagged files.
+
+If NOMESSAGE is non-nil, we don't display any message
+if there are no flagged files.
+
+This is the same as `dired-do-flagged-delete', but calls
+`dired-duplicates-dired-revert' afterwards."
+    (interactive)
+    (dired-do-flagged-delete nomessage)
+    (dired-duplicates-dired-revert)))
+
+(defvar dired-duplicates-map
+  (let ((map (make-sparse-keymap)))
+    ;; workaround for Emacs bug #57565
+    (when (< emacs-major-version 29)
+      (define-key map (kbd "x") 'dired-duplicates--do-flagged-delete)
+      (define-key map (kbd "D") 'dired-duplicates--do-delete))
+    map)
+  "This keymap overrides the default `dired-mode-map'.
+
+It will be local to the `dired-duplicates' buffer.")
+
 ;;;###autoload
 (defun dired-duplicates (directories)
   "Find a list of duplicate files inside one or more DIRECTORIES.
@@ -222,6 +256,8 @@ The results will be shown in a Dired buffer."
         (progn
           (message "Finding duplicate files in %s completed." truncated-dirs)
           (dired (cons "/" (flatten-list results)))
+          (set-keymap-parent dired-duplicates-map (current-local-map))
+          (setf (current-local-map) dired-duplicates-map)
           (setq-local dired-duplicates-directories directories)
           (setq-local revert-buffer-function 'dired-duplicates-dired-revert)
           (dired-duplicates--post-process-dired-buffer results))



reply via email to

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