Say there is no maintainer.
[bpt/emacs.git] / lisp / dired.el
index 69dafbe..e01299f 100644 (file)
@@ -253,7 +253,7 @@ The directory name must be absolute, but need not be fully expanded.")
               "-[-r][-w].[-r][-w].[-r][-w][xst]")
             "\\|"))
 (defvar dired-re-perms "[-bcdlps][-r][-w].[-r][-w].[-r][-w].")
-(defvar dired-re-dot "^.* \\.\\.?$")
+(defvar dired-re-dot "^.* \\.\\.?/?$")
 
 ;; The subdirectory names in this list are expanded.
 (defvar dired-subdir-alist nil
@@ -1350,7 +1350,12 @@ Creates a buffer if necessary."
 (defun dired-get-file-for-visit ()
   "Get the current line's file name, with an error if file does not exist."
   (interactive)
-  (let ((file-name (file-name-sans-versions (dired-get-filename) t)))
+  ;; We pass t for second arg so that we don't get error for `.' and `..'.
+  (let ((raw (dired-get-filename nil t))
+       file-name)
+    (if (null raw)
+       (error "No file on this line"))
+    (setq file-name (file-name-sans-versions raw t))
     (if (file-exists-p file-name)
        file-name
       (if (file-symlink-p file-name)
@@ -1362,7 +1367,10 @@ Creates a buffer if necessary."
 (defun dired-find-file ()
   "In Dired, visit the file or directory named on this line."
   (interactive)
-  (find-file (dired-get-file-for-visit)))
+  ;; Bind `find-file-run-dired' so that the command works on directories
+  ;; too, independent of the user's setting.
+  (let ((find-file-run-dired t))
+    (find-file (dired-get-file-for-visit))))
 
 (defun dired-find-alternate-file ()
   "In Dired, visit this file or directory instead of the dired buffer."
@@ -1417,8 +1425,11 @@ see `dired-view-command-alist'.  Otherwise, display it in another buffer."
          (if (string-match (car elt) file)
              (setq cmd (cdr elt))))
        (if cmd
-           (dired-run-shell-command (concat cmd " "
-                                            (shell-quote-argument file)))
+           (call-process shell-file-name nil 0 nil
+                         "-c"
+                         (concat cmd " "
+                                 (shell-quote-argument file)
+                                 " &"))
          (view-file file))))))
 
 (defun dired-find-file-other-window ()
@@ -1437,11 +1448,12 @@ see `dired-view-command-alist'.  Otherwise, display it in another buffer."
   "In Dired, return name of file mentioned on this line.
 Value returned normally includes the directory name.
 Optional arg LOCALP with value `no-dir' means don't include directory
-  name in result.  A value of `verbatim' means to return the name exactly as
-  it occurs in the buffer, and a value of t means construct name relative to
-  `default-directory', which still may contain slashes if in a subdirectory.
-Optional arg NO-ERROR-IF-NOT-FILEP means return nil if no filename on
-  this line, otherwise an error occurs."
+name in result.  A value of `verbatim' means to return the name exactly as
+it occurs in the buffer, and a value of t means construct name relative to
+`default-directory', which still may contain slashes if in a subdirectory.
+Optional arg NO-ERROR-IF-NOT-FILEP means treat `.' and `..' as
+regular filenames and return nil if no filename on this line.
+Otherwise, an error occurs in these cases."
   (let (case-fold-search file p1 p2 already-absolute)
     (save-excursion
       (if (setq p1 (dired-move-to-filename (not no-error-if-not-filep)))
@@ -1462,21 +1474,27 @@ Optional arg NO-ERROR-IF-NOT-FILEP means return nil if no filename on
                         (or (dired-string-replace-match
                              "\\([^\\]\\|\\`\\)\"" file "\\1\\\\\"" nil t)
                             file)
-                        "\"")))))
+                        "\"")))
+         ;; The above `read' will return a unibyte string if FILE
+         ;; contains eight-bit-control/graphic characters.
+         (if (and enable-multibyte-characters
+                  (not (multibyte-string-p file)))
+             (setq file (string-to-multibyte file)))))
     (and file (file-name-absolute-p file)
         ;; A relative file name can start with ~.
         ;; Don't treat it as absolute in this context.
         (not (eq (aref file 0) ?~))
         (setq already-absolute t))
-    (and file buffer-file-coding-system
-        (not file-name-coding-system)
-        (not default-file-name-coding-system)
-        (setq file (encode-coding-string file buffer-file-coding-system)))
     (cond
      ((null file)
       nil)
      ((eq localp 'verbatim)
       file)
+     ((and (not no-error-if-not-filep)
+          (save-excursion
+            (beginning-of-line)
+            (looking-at dired-re-dot)))
+      (error "Cannot operate on `.' or `..'"))
      ((and (eq localp 'no-dir) already-absolute)
       (file-name-nondirectory file))
      (already-absolute
@@ -1502,7 +1520,7 @@ Optional arg NO-ERROR-IF-NOT-FILEP means return nil if no filename on
       (concat (dired-current-directory localp) file)))))
 
 (defun dired-string-replace-match (regexp string newtext
-                                         &optional literal global)
+                                   &optional literal global)
   "Replace first match of REGEXP in STRING with NEWTEXT.
 If it does not match, nil is returned instead of the new string.
 Optional arg LITERAL means to take NEWTEXT literally.
@@ -1547,9 +1565,11 @@ DIR must be a directory name, not a file name."
 
 (defvar dired-move-to-filename-regexp
   (let* ((l "\\([A-Za-z]\\|[^\0-\177]\\)")
+        (l-or-quote "\\([A-Za-z']\\|[^\0-\177]\\)")
         ;; In some locales, month abbreviations are as short as 2 letters,
         ;; and they can be followed by ".".
-        (month (concat l l "+\\.?"))
+        ;; In Breton, a month name  can include a quote character.
+        (month (concat l-or-quote l-or-quote "+\\.?"))
         (s " ")
         (yyyy "[0-9][0-9][0-9][0-9]")
         (dd "[ 0-3][0-9]")
@@ -2651,8 +2671,10 @@ Type SPC or `y' to unmark one file, DEL or `n' to skip to next,
                 (re-search-forward dired-re-mark nil t)
               (search-forward string nil t))
        (if (or (not arg)
-               (dired-query 'query "Unmark file `%s'? "
-                            (dired-get-filename t)))
+               (let ((file (dired-get-filename t t)))
+                 (and file
+                      (dired-query 'query "Unmark file `%s'? "
+                                   file))))
            (progn (subst-char-in-region (1- (point)) (point)
                                         (preceding-char) ?\ )
                   (setq count (1+ count)))))