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

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

[nongnu] elpa/helm 712f78358c 4/5: Remove Wdired advices


From: ELPA Syncer
Subject: [nongnu] elpa/helm 712f78358c 4/5: Remove Wdired advices
Date: Tue, 17 Jan 2023 10:59:13 -0500 (EST)

branch: elpa/helm
commit 712f78358c11f3397107c1f78ee853bbe33b86af
Author: Thierry Volpiatto <thievol@posteo.net>
Commit: Thierry Volpiatto <thievol@posteo.net>

    Remove Wdired advices
---
 helm-files.el |  11 ++---
 helm-lib.el   | 145 ----------------------------------------------------------
 2 files changed, 4 insertions(+), 152 deletions(-)

diff --git a/helm-files.el b/helm-files.el
index 8c5ad68dc7..3a173d0957 100644
--- a/helm-files.el
+++ b/helm-files.el
@@ -3038,13 +3038,10 @@ and should be used carefully elsewhere, or not at all, 
using
 (defun helm-marked-files-in-dired (_candidate)
   "Open a dired buffer with only marked files.
 
-With a prefix arg toggle dired buffer to wdired mode."
-  (when (< emacs-major-version 29)
-    ;; Fix emacs bug
-    ;; https://lists.gnu.org/archive/html/bug-gnu-emacs/2022-08/msg01994.html
-    ;; up to emacs-28.1 and should be fixed in emacs-29+.
-    (advice-add 'wdired-finish-edit :override 
#'helm--advice-wdired-finish-edit)
-    (advice-add 'wdired-get-filename :override 
#'helm--advice-wdired-get-filename))
+With a prefix arg toggle dired buffer to wdired mode.
+
+Note: This function works only in Emacs-29+ because Wdired doesn't support
+editing absolute fnames in previous Emacs versions."
   (let* ((marked (helm-marked-candidates :with-wildcard t))
          (current (car marked)))
     (unless (and helm--url-regexp
diff --git a/helm-lib.el b/helm-lib.el
index e944a6bd9c..66ab85395b 100644
--- a/helm-lib.el
+++ b/helm-lib.el
@@ -193,151 +193,6 @@ available APPEND is ignored."
       (add-face-text-property beg end face append object)
       (add-text-properties beg end `(face ,face) object)))
 
-;; Override `wdired-finish-edit'.
-;; Fix emacs bug in `wdired-finish-edit' where
-;; Wdired is not handling the case where `dired-directory' is a cons
-;; cell instead of a string.
-(defun helm--advice-wdired-finish-edit ()
-  (interactive)
-  (wdired-change-to-dired-mode)
-  ;; `wdired-old-marks' has been removed in emacs-28+.
-  (unless (boundp 'wdired-old-marks)
-    (setq-local wdired-old-marks nil))
-  (let ((changes nil)
-       (errors 0)
-       files-deleted
-       files-renamed
-       some-file-names-unchanged
-       file-old file-new tmp-value)
-    (save-excursion
-      (when (and wdired-allow-to-redirect-links
-                (fboundp 'make-symbolic-link))
-       (setq tmp-value (wdired-do-symlink-changes))
-       (setq errors (cdr tmp-value))
-       (setq changes (car tmp-value)))
-      (when (and wdired-allow-to-change-permissions
-                (boundp 'wdired-col-perm)) ; could have been changed
-       (setq tmp-value (wdired-do-perm-changes))
-       (setq errors (+ errors (cdr tmp-value)))
-       (setq changes (or changes (car tmp-value))))
-      (goto-char (point-max))
-      (while (not (bobp))
-       (setq file-old (wdired-get-filename nil t))
-       (when file-old
-         (setq file-new (wdired-get-filename))
-          (if (equal file-new file-old)
-             (setq some-file-names-unchanged t)
-            (setq changes t)
-            (if (not file-new)         ;empty filename!
-                (push file-old files-deleted)
-             (when wdired-keep-marker-rename
-               (let ((mark (cond ((integerp wdired-keep-marker-rename)
-                                  wdired-keep-marker-rename)
-                                 (wdired-keep-marker-rename
-                                  (cdr (assoc file-old wdired-old-marks)))
-                                 (t nil))))
-                 (when mark
-                   (push (cons (substitute-in-file-name file-new) mark)
-                         wdired-old-marks))))
-              (push (cons file-old (substitute-in-file-name file-new))
-                    files-renamed))))
-       (forward-line -1)))
-    (when files-renamed
-      (setq errors (+ errors (wdired-do-renames files-renamed))))
-    (if changes
-       (progn
-         ;; If we are displaying a single file (rather than the
-         ;; contents of a directory), change dired-directory if that
-         ;; file was renamed.  (This ought to be generalized to
-         ;; handle the multiple files case, but that's less trivial)
-          ;; fixit [1].
-         (cond ((and (stringp dired-directory)
-                      (not (file-directory-p dired-directory))
-                      (null some-file-names-unchanged)
-                      (= (length files-renamed) 1))
-                 (setq dired-directory (cdr (car files-renamed))))
-                ;; Fix [1] i.e dired buffers created with
-                ;; (dired '(foo f1 f2 f3)).
-                ((and (consp dired-directory)
-                      (cdr dired-directory)
-                      files-renamed)
-                 (setq dired-directory
-                       ;; Replace in `dired-directory' files that have
-                       ;; been modified with their new name keeping
-                       ;; the ones that are unmodified at the same place.
-                       (cons (car dired-directory)
-                             (cl-loop for f in (cdr dired-directory)
-                                      collect (or (assoc-default f 
files-renamed)
-                                                  f))))))
-         ;; Re-sort the buffer if all went well.
-         (unless (> errors 0) (revert-buffer))
-         (let ((inhibit-read-only t))
-           (dired-mark-remembered wdired-old-marks)))
-      (let ((inhibit-read-only t))
-       (remove-text-properties (point-min) (point-max)
-                               '(old-name nil end-name nil old-link nil
-                                          end-link nil end-perm nil
-                                          old-perm nil perm-changed nil))
-       (message "(No changes to be performed)")))
-    (when files-deleted
-      (wdired-flag-for-deletion files-deleted))
-    (when (> errors 0)
-      (dired-log-summary (format "%d rename actions failed" errors) nil)))
-  (set-buffer-modified-p nil)
-  (setq buffer-undo-list nil))
-
-;; Override `wdired-get-filename'.
-;; Fix emacs bug in `wdired-get-filename' which returns the current
-;; directory concatened with the filename i.e
-;; "/home/you//home/you/foo" when filename is absolute in dired
-;; buffer.
-;; In consequence Wdired try to rename files even when buffer have
-;; been modified and corrected, e.g delete one char and replace it so
-;; that no change to file is done.
-;; This also lead to ask confirmation for every files even when not
-;; modified and when `wdired-use-interactive-rename' is nil.
-;; Obviously, we could make an :around advice like this:
-;; (defun helm--advice-wdired-get-filename (old--fn &rest args)
-;;   (let* ((file  (apply old--fn args))
-;;          (split (and file (split-string file "//"))))
-;;     (if (and (cdr split)
-;;              (string-match (format "\\(%s/\\)\\1" (car split)) file))
-;;         (replace-match "" nil nil file 1)
-;;       file)))
-;; But for some reasons the original function in emacs-28 is returning
-;; nil in some conditions and operation fails with no errors but with
-;; something like "(no change performed)", so use an old version of
-;; `wdired-get-filename' with its output modified and advice it with
-;; :override.
-(defun helm--advice-wdired-get-filename (&optional no-dir old)
-  ;; FIXME: Use dired-get-filename's new properties.
-  (let (beg end file)
-    (save-excursion
-      (setq end (line-end-position))
-      (beginning-of-line)
-      (setq beg (next-single-property-change (point) 'old-name nil end))
-      (unless (eq beg end)
-       (if old
-           (setq file (get-text-property beg 'old-name))
-         ;; In the following form changed `(1+ beg)' to `beg' so that
-         ;; the filename end is found even when the filename is empty.
-         ;; Fixes error and spurious newlines when marking files for
-         ;; deletion.
-         (setq end (next-single-property-change beg 'end-name))
-         (setq file (buffer-substring-no-properties (1+ beg) end)))
-       ;; Don't unquote the old name, it wasn't quoted in the first place
-        (and file (setq file (condition-case _err
-                                 ;; emacs-25+
-                                 (apply #'wdired-normalize-filename
-                                        (list file (not old)))
-                               (wrong-number-of-arguments
-                                ;; emacs-24
-                                (wdired-normalize-filename file))))))
-      (if (or no-dir old (and file (file-name-absolute-p file)))
-         file
-       (and file (> (length file) 0)
-             (expand-file-name file (dired-current-directory)))))))
-
 ;;; Override `push-mark'
 ;;
 ;; Fix duplicates in `mark-ring' and `global-mark-ring' and update



reply via email to

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