GNU bug report logs - #27801
26.0.50; Dired: Use relative file names when DIR-OR-LIST is a cons

Previous Next

Package: emacs;

Reported by: Tino Calancha <tino.calancha <at> gmail.com>

Date: Mon, 24 Jul 2017 03:31:01 UTC

Severity: wishlist

Tags: wontfix

Found in version 26.0.50

Done: Tino Calancha <tino.calancha <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#27801: closed (26.0.50; Dired: Use relative file names when
 DIR-OR-LIST is a cons)
Date: Mon, 24 Jul 2017 05:38:01 +0000
[Message part 1 (text/plain, inline)]
Your message dated Mon, 24 Jul 2017 14:37:36 +0900
with message-id <87379mbdjz.fsf <at> calancha-pc>
and subject line Re: bug#27801: 26.0.50; Dired: Use relative file names when DIR-OR-LIST is a cons
has caused the debbugs.gnu.org bug report #27801,
regarding 26.0.50; Dired: Use relative file names when DIR-OR-LIST is a cons
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
27801: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=27801
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Tino Calancha <tino.calancha <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.0.50; Dired: Use relative file names when DIR-OR-LIST is a cons
Date: Mon, 24 Jul 2017 12:29:48 +0900
Severity: wishlist

emacs -Q /tmp

;; Following form shows the full file name in the Dired buffer.
(let* ((dir source-directory)
       (file1 (expand-file-name "lisp/subr.el" dir))
       (file2 (expand-file-name "src/data.c" dir)))
  (dired (list dir file1 file2)))

;; Usually, Dired just shows the relative file name to
;; 'default-directory'.  That is more clear, specially for
;; long file names.

--8<-----------------------------cut here---------------start------------->8---
commit 192c9b0179adbe4ae65d956f064eb9c2197a0a01
Author: Tino Calancha <tino.calancha <at> gmail.com>
Date:   Mon Jul 24 12:25:24 2017 +0900

    Dired: Use relative file names when DIR-OR-LIST is a cons
    
    * lisp/dired.el (dired-internal-noselect): Use relative file
    names when DIR-OR-LIST is a cons.
    * test/lisp/dired-tests.el (dired-test-bug27801): Add test.

diff --git a/lisp/dired.el b/lisp/dired.el
index 9d500a9f52..718c2b8cf9 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -926,6 +926,11 @@ dired-internal-noselect
 	    ;; if it was the name of a directory at all.
 	    (file-name-directory dirname))
       (or switches (setq switches dired-listing-switches))
+      ;; If `dir-or-list' is a cons, use file names relative
+      ;; to default-directory.
+      (when (and (consp dir-or-list) (file-name-absolute-p (cadr dir-or-list)))
+        (setf (cdr dir-or-list)
+              (mapcar #'file-relative-name (cdr dir-or-list))))
       (if mode (funcall mode)
         (dired-mode dir-or-list switches))
       ;; default-directory and dired-actual-switches are set now
diff --git a/test/lisp/dired-tests.el b/test/lisp/dired-tests.el
index 69331457c0..4241609ec6 100644
--- a/test/lisp/dired-tests.el
+++ b/test/lisp/dired-tests.el
@@ -175,5 +175,25 @@
           (should (looking-at "src")))
       (when (buffer-live-p buf) (kill-buffer buf)))))
 
+(ert-deftest dired-test-bug27801 ()
+  "Test for http://debbugs.gnu.org/27801 ."
+  (let* ((dir (make-temp-file "bug27801" 'dir))
+         (foo (expand-file-name "foo" dir))
+         (bar (expand-file-name "bar" dir))
+         (f1 (expand-file-name "file" foo))
+         (f2 (expand-file-name "file" bar))
+         buf)
+    (unwind-protect
+        (progn
+          (make-directory foo)
+          (make-directory bar)
+          (with-temp-file f1 nil)
+          (with-temp-file f2 nil)
+          (setq buf (dired (list dir f1 f2)))
+          (dired-goto-file f1)
+          (should (looking-at "foo/file$")))
+      (when (buffer-live-p buf) (kill-buffer buf))
+      (delete-directory dir t))))
+
 (provide 'dired-tests)
 ;; dired-tests.el ends here
--8<-----------------------------cut here---------------end--------------->8---
In GNU Emacs 26.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
 of 2017-07-23
Repository revision: 1f450f1d3531cb53ebe50744c85c90141fce7ad0


[Message part 3 (message/rfc822, inline)]
From: Tino Calancha <tino.calancha <at> gmail.com>
To: 27801-done <at> debbugs.gnu.org
Cc: Drew Adams <drew.adams <at> oracle.com>
Subject: Re: bug#27801: 26.0.50;
 Dired: Use relative file names when DIR-OR-LIST is a cons
Date: Mon, 24 Jul 2017 14:37:36 +0900
Drew Adams <drew.adams <at> oracle.com> writes:

> 2. If you call (dired (list DIR FILES)) and you want FILES
> to be relative rather than absolute, why can't you just
> (for your particular use case) use something like
> (dired (list DIR (mapcar #'dired-make-relative FILES)))?
> What am I missing?
Your right.  Thank you!
This is the proper way to do it: pass a list with
the relative names.


This bug report was last modified 7 years and 309 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.