emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 6d8e0fc: Make wdired-mode ignore ls file indicators


From: Stephen Berman
Subject: [Emacs-diffs] master 6d8e0fc: Make wdired-mode ignore ls file indicators
Date: Thu, 25 Apr 2019 13:17:30 -0400 (EDT)

branch: master
commit 6d8e0fc5aa7673540486af9ecbfc0a3e23c305cf
Author: Stephen Berman <address@hidden>
Commit: Stephen Berman <address@hidden>

    Make wdired-mode ignore ls file indicators
    
    * lisp/wdired.el (wdired--restore-dired-filename-prop): When
    dired-listing-switches includes "F" or "classify", don't treat
    appended indicator characters as part of the file name (bug#34915).
    
    * test/lisp/wdired-tests.el (wdired-test-bug34915): New test.
---
 lisp/wdired.el            | 25 +++++++++++++++++--------
 test/lisp/wdired-tests.el | 45 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+), 8 deletions(-)

diff --git a/lisp/wdired.el b/lisp/wdired.el
index acc62e4..d2a298b 100644
--- a/lisp/wdired.el
+++ b/lisp/wdired.el
@@ -612,14 +612,23 @@ Optional arguments are ignored."
         (when (re-search-forward
                directory-listing-before-filename-regexp lep t)
           (setq beg (point)
-                ;; If the file is a symlink, put the dired-filename
-                ;; property only on the link name.  (Using
-                ;; (file-symlink-p (dired-get-filename)) fails in
-                ;; wdired-mode, bug#32673.)
-                end (if (and (re-search-backward
-                              dired-permission-flags-regexp nil t)
-                             (looking-at "l")
-                             (search-forward " -> " lep t))
+                end (if (or
+                         ;; If the file is a symlink, put the
+                         ;; dired-filename property only on the link
+                         ;; name.  (Using (file-symlink-p
+                         ;; (dired-get-filename)) fails in
+                         ;; wdired-mode, bug#32673.)
+                         (and (re-search-backward
+                               dired-permission-flags-regexp nil t)
+                              (looking-at "l")
+                              (search-forward " -> " lep t))
+                         ;; When dired-listing-switches includes "F"
+                         ;; or "classify", don't treat appended
+                         ;; indicator characters as part of the file
+                         ;; name (bug#34915).
+                         (and (dired-check-switches dired-actual-switches
+                                                    "F" "classify")
+                              (re-search-forward "[*/@|=>]$" lep t)))
                         (goto-char (match-beginning 0))
                       lep))
           (put-text-property beg end 'dired-filename t))))))
diff --git a/test/lisp/wdired-tests.el b/test/lisp/wdired-tests.el
index dc67796..9682843 100644
--- a/test/lisp/wdired-tests.el
+++ b/test/lisp/wdired-tests.el
@@ -124,6 +124,51 @@ wdired-mode."
            (kill-buffer buf)))
        (delete-directory test-dir t)))))
 
+(ert-deftest wdired-test-bug34915 ()
+  "Test editing when dired-listing-switches includes -F.
+Appended file indicators should not count as part of the file
+name, either before or after editing.  Since
+dired-move-to-end-of-filename handles indicator characters, it
+suffices to compare the return values of dired-get-filename and
+wdired-get-filename before and after editing."
+  ;; FIXME: Add a test for a door (indicator ">") only under Solaris?
+  (let* ((test-dir (make-temp-file "test-dir-" t))
+         (server-socket-dir test-dir)
+         (dired-listing-switches "-Fl")
+         (buf (find-file-noselect test-dir)))
+    (unwind-protect
+        (progn
+         (with-current-buffer buf
+            (dired-create-empty-file "foo")
+            (set-file-modes "foo" (file-modes-symbolic-to-number "+x"))
+            (make-symbolic-link "foo" "bar")
+            (make-directory "foodir")
+            (require 'dired-x)
+            (dired-smart-shell-command "mkfifo foopipe")
+            (server-force-delete)
+            (server-start)              ; Add a socket file.
+            (kill-buffer buf))
+          (dired test-dir)
+          (dired-toggle-read-only)
+          (let (names)
+            ;; Test that the file names are the same in Dired and WDired.
+            (while (not (eobp))
+              (should (equal (dired-get-filename 'no-dir t)
+                             (wdired-get-filename t)))
+              (insert "w")
+              (push (wdired-get-filename t) names)
+              (dired-next-line 1))
+            (wdired-finish-edit)
+            ;; Test that editing the file names ignores the indicator
+            ;; character.
+            (let (dir)
+              (while (and (dired-previous-line 1)
+                          (setq dir (dired-get-filename 'no-dir t)))
+                (should (equal dir (pop names)))))))
+      (kill-buffer (get-buffer test-dir))
+      (server-force-delete)
+      (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]