From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#27801: 26.0.50; Dired: Use relative file names when DIR-OR-LIST is a cons Date: Mon, 24 Jul 2017 12:29:48 +0900 Message-ID: <87o9sacy1f.fsf@calancha-pc> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1500867079 15731 195.159.176.226 (24 Jul 2017 03:31:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 24 Jul 2017 03:31:19 +0000 (UTC) To: 27801@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jul 24 05:31:12 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dZU5N-0003T2-DW for geb-bug-gnu-emacs@m.gmane.org; Mon, 24 Jul 2017 05:31:09 +0200 Original-Received: from localhost ([::1]:52740 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZU5R-0004kf-Hk for geb-bug-gnu-emacs@m.gmane.org; Sun, 23 Jul 2017 23:31:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49371) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZU5L-0004kQ-I8 for bug-gnu-emacs@gnu.org; Sun, 23 Jul 2017 23:31:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZU5G-0004va-Is for bug-gnu-emacs@gnu.org; Sun, 23 Jul 2017 23:31:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51046) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dZU5G-0004vU-Fg for bug-gnu-emacs@gnu.org; Sun, 23 Jul 2017 23:31:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dZU5G-0005vM-22 for bug-gnu-emacs@gnu.org; Sun, 23 Jul 2017 23:31:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 24 Jul 2017 03:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 27801 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.150086701022709 (code B ref -1); Mon, 24 Jul 2017 03:31:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 24 Jul 2017 03:30:10 +0000 Original-Received: from localhost ([127.0.0.1]:53723 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dZU4P-0005uD-JQ for submit@debbugs.gnu.org; Sun, 23 Jul 2017 23:30:09 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:58139) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dZU4M-0005sh-Nn for submit@debbugs.gnu.org; Sun, 23 Jul 2017 23:30:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZU4G-0004Ru-9q for submit@debbugs.gnu.org; Sun, 23 Jul 2017 23:30:01 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:44138) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dZU4G-0004Ro-6R for submit@debbugs.gnu.org; Sun, 23 Jul 2017 23:30:00 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49095) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZU4E-0004RU-Rc for bug-gnu-emacs@gnu.org; Sun, 23 Jul 2017 23:29:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZU4B-0004Q3-Oe for bug-gnu-emacs@gnu.org; Sun, 23 Jul 2017 23:29:58 -0400 Original-Received: from mail-pg0-x231.google.com ([2607:f8b0:400e:c05::231]:33545) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dZU4B-0004Pc-I3 for bug-gnu-emacs@gnu.org; Sun, 23 Jul 2017 23:29:55 -0400 Original-Received: by mail-pg0-x231.google.com with SMTP id g14so2379540pgu.0 for ; Sun, 23 Jul 2017 20:29:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=jfauy/WcJL+pDGVRdNeZXX1Dm2oHlyHoQUAo566TooM=; b=ufTEKrVjGc4dhMSiJRh2MbH6VpoX9NSibk8QF8P94RmZEgfRX0YVyXaeQrAczkPJSD Yyi9P38/aKG/J6n8gBUAE7K0Zfrz1BUGeGR/VklycT+w0cyQTqH+BQYnY5gx2fQtStdw nFYSnTFr0P8kd96HmDu/gEPRWlYj8z+f3uJt/MrIBsc0sKjKMVylxsa6N2CbinwhbqtS sHNfBeCIjW1BxPYWxVA7hCVhY6vjduaKlWI1QckeP2VtNhat6ZWsNU8/m8CIZ5z/7kHA LBWLKUIwkdamR3X94r8fBcYPW9AR2Sp6nhjP2z9o+N0iXPrHynANLp18fu0xMMkBbmM8 /TcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=jfauy/WcJL+pDGVRdNeZXX1Dm2oHlyHoQUAo566TooM=; b=N7PzUxuYVjYFAouUBHRiAUdy8Ul4obxODEKwca+WqHgHoSH11OyKW6KTbX36EI5vdG 5/6WX+uOxopmB/EC0zfFRLTc7CmsLhBe7Hsbaj3lYNnvBjJS4AGeCUM4KxadMlVpxTyw ZM9+/xdld+afWSQbpu07ovaxnbCiUwQ0Sxx8BI6ubtTlowF+4cDknrR+LomoN/VhJnBp NVl4EHOjRRwA9Kb3NZ93XrfMGwrOaG04oU87c8Ssb5Grj4nVQDv5tbCstXmaaXQ5VXBG eKdVMTAtXFSNUACZpjKBM/AgpbwpA9Iqm/NZ6wkh+wzKXW/FFvRmTW6wz5VGFYXeDSCR rtWA== X-Gm-Message-State: AIVw113qJv4VOYk6wdxOnaOVI1ovuSs9+SDm0cCJCBH8+ez+9vYT9vYs Fu2vK9xvBLIPiXjK X-Received: by 10.99.173.6 with SMTP id g6mr14881055pgf.1.1500866992844; Sun, 23 Jul 2017 20:29:52 -0700 (PDT) Original-Received: from calancha-pc (170.224.128.101.dy.bbexcite.jp. [101.128.224.170]) by smtp.gmail.com with ESMTPSA id 10sm20402123pfj.61.2017.07.23.20.29.51 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Jul 2017 20:29:52 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:134899 Archived-At: 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 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