changeset 51444:b53bffc0cbaf

(dired-get-filename): Err for . and .. in usual case. (dired-get-file-for-visit): Specify no-error to dired-get-filename, and check for real errors here. (dired-unmark-all-files): Specify no-error to dired-get-filename.
author Richard M. Stallman <rms@gnu.org>
date Wed, 04 Jun 2003 09:02:45 +0000
parents 77bc7a2e6bef
children 4955d5bb9ee0
files lisp/dired.el
diffstat 1 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/dired.el	Wed Jun 04 09:00:22 2003 +0000
+++ b/lisp/dired.el	Wed Jun 04 09:02:45 2003 +0000
@@ -1350,7 +1350,12 @@
 (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)
@@ -1482,6 +1487,11 @@
     (cond
      ((null file)
       nil)
+     ((and (not no-error-if-not-filep)
+	   (save-excursion
+	     (beginning-of-line)
+	     (looking-at dired-re-dir)))
+      (error "Cannot operate on `.' or `..'"))
      ((eq localp 'verbatim)
       file)
      ((and (eq localp 'no-dir) already-absolute)
@@ -2658,8 +2668,10 @@
 		 (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)))))