emacs-diffs
[Top][All Lists]
Advanced

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

master 29435ec 1/2: Fix bug in wdired-get-filename


From: Lars Ingebrigtsen
Subject: master 29435ec 1/2: Fix bug in wdired-get-filename
Date: Thu, 1 Oct 2020 17:34:26 -0400 (EDT)

branch: master
commit 29435ecd8e31497a9cc461fcf88dbbf00876863a
Author: Tino Calancha <tino.calancha@gmail.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Fix bug in wdired-get-filename
    
    * lisp/wdired.el (wdired-get-filename): Acknowledge the first
    argument (bug#39280).
    * test/lisp/wdired-tests.el (wdired-test-bug39280): Add test.
---
 lisp/wdired.el            |  2 +-
 test/lisp/wdired-tests.el | 16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/lisp/wdired.el b/lisp/wdired.el
index 6defbf8..806eb30 100644
--- a/lisp/wdired.el
+++ b/lisp/wdired.el
@@ -344,7 +344,7 @@ non-nil means return old filename."
        ;; Don't unquote the old name, it wasn't quoted in the first place
         (and file (setq file (wdired-normalize-filename file (not old)))))
       (if (or no-dir old)
-         file
+         (if no-dir (file-relative-name file) file)
        (and file (> (length file) 0)
              (concat (dired-current-directory) file))))))
 
diff --git a/test/lisp/wdired-tests.el b/test/lisp/wdired-tests.el
index b89e8c8..f876967 100644
--- a/test/lisp/wdired-tests.el
+++ b/test/lisp/wdired-tests.el
@@ -178,6 +178,22 @@ wdired-get-filename before and after editing."
       (server-force-delete)
       (delete-directory test-dir t))))
 
+(ert-deftest wdired-test-bug39280 ()
+  "Test for https://debbugs.gnu.org/39280.";
+  (let* ((test-dir (make-temp-file "test-dir" 'dir))
+         (fname "foo")
+         (full-fname (expand-file-name fname test-dir)))
+    (make-empty-file full-fname)
+    (let ((buf (find-file-noselect test-dir)))
+      (unwind-protect
+         (with-current-buffer buf
+           (dired-toggle-read-only)
+            (dolist (old '(t nil))
+              (should (equal fname (wdired-get-filename 'nodir old)))
+              (should (equal full-fname (wdired-get-filename nil old))))
+           (wdired-finish-edit))
+       (if buf (kill-buffer buf))
+       (delete-directory test-dir t)))))
 
 (provide 'wdired-tests)
 ;;; wdired-tests.el ends here



reply via email to

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