]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix bug in wdired-get-filename
authorTino Calancha <tino.calancha@gmail.com>
Thu, 1 Oct 2020 21:25:15 +0000 (23:25 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Thu, 1 Oct 2020 21:34:01 +0000 (23:34 +0200)
* 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
test/lisp/wdired-tests.el

index 6defbf8bc860da567a0f6abaf712bcaada6485a2..806eb304d9fffd0fa161ebbf779af6bb15770f85 100644 (file)
@@ -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))))))
 
index b89e8c876e22d1cae3097fcb405a23885e49bf36..f876967bf981bf3bd9f08f280ed568de233c858c 100644 (file)
@@ -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