diff lisp/files.el @ 90180:62afea0771d8

Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-51 Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 289-301) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 68) - Update from CVS
author Miles Bader <miles@gnu.org>
date Thu, 12 May 2005 03:41:19 +0000
parents 08185296b491 b484427cfa6b
children f042e7c0fe20
line wrap: on
line diff
--- a/lisp/files.el	Thu May 12 02:47:44 2005 +0000
+++ b/lisp/files.el	Thu May 12 03:41:19 2005 +0000
@@ -541,9 +541,6 @@
 the value of `default-directory'."
   (unless dir
     (setq dir default-directory))
-  (unless default-dirname
-    (setq default-dirname
-	  (if initial (concat dir initial) default-directory)))
   (read-file-name prompt dir (or default-dirname 
 				 (if initial (expand-file-name initial dir)
 				   dir))
@@ -632,8 +629,13 @@
 
 (defun locate-file (filename path &optional suffixes predicate)
   "Search for FILENAME through PATH.
+If found, return the absolute file name of FILENAME, with its suffixes;
+otherwise return nil.
+PATH should be a list of directories to look in, like the lists in
+`exec-path' or `load-path'.
 If SUFFIXES is non-nil, it should be a list of suffixes to append to
 file name when searching.  If SUFFIXES is nil, it is equivalent to '(\"\").
+Use '(\"/\") to disable PATH search, but still try the suffixes in SUFFIXES.
 If non-nil, PREDICATE is used instead of `file-readable-p'.
 PREDICATE can also be an integer to pass to the `access' system call,
 in which case file-name handlers are ignored.  This usage is deprecated.
@@ -674,6 +676,13 @@
        ((null action) (try-completion string names))
        (t (test-completion string names))))))
 
+(defun executable-find (command)
+  "Search for COMMAND in `exec-path' and return the absolute file name.
+Return nil if COMMAND is not found anywhere in `exec-path'."
+  ;; Use 1 rather than file-executable-p to better match the behavior of
+  ;; call-process.
+  (locate-file command exec-path exec-suffixes 1))
+
 (defun load-library (library)
   "Load the library named LIBRARY.
 This is an interface to the function `load'."
@@ -2142,6 +2151,26 @@
        (goto-char beg)
        end))))
 
+(defun hack-local-variables-confirm ()
+  (or (eq enable-local-variables t)
+      (and enable-local-variables
+	   (save-window-excursion
+	     (condition-case nil
+		 (switch-to-buffer (current-buffer))
+	       (error
+		;; If we fail to switch in the selected window,
+		;; it is probably a minibuffer or dedicated window.
+		;; So try another window.
+		(let ((pop-up-frames nil))
+		  ;; Refrain from popping up frames since it can't
+		  ;; be undone by save-window-excursion.
+		  (pop-to-buffer (current-buffer)))))
+	     (save-excursion
+	       (beginning-of-line)
+	       (set-window-start (selected-window) (point)))
+	     (y-or-n-p (format "Set local variables as specified in -*- line of %s? "
+			       (file-name-nondirectory buffer-file-name)))))))
+
 (defun hack-local-variables-prop-line (&optional mode-only)
   "Set local variables specified in the -*- line.
 Ignore any specification for `mode:' and `coding:';
@@ -2196,21 +2225,7 @@
       (if mode-only mode-specified
 	(if (and result
 		 (or mode-only
-		     (eq enable-local-variables t)
-		     (and enable-local-variables
-			  (save-window-excursion
-			    (condition-case nil
-				(switch-to-buffer (current-buffer))
-			      (error
-			       ;; If we fail to switch in the selected window,
-			       ;; it is probably a minibuffer.
-			       ;; So try another window.
-			       (condition-case nil
-				   (switch-to-buffer-other-window (current-buffer))
-				 (error
-				  (switch-to-buffer-other-frame (current-buffer))))))
-			    (y-or-n-p (format "Set local variables as specified in -*- line of %s? "
-					      (file-name-nondirectory buffer-file-name)))))))
+		     (hack-local-variables-confirm)))
 	    (let ((enable-local-eval enable-local-eval))
 	      (while result
 		(hack-one-local-variable (car (car result)) (cdr (car result)))
@@ -2239,20 +2254,8 @@
       (search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) 'move)
       (when (let ((case-fold-search t))
 	      (and (search-forward "Local Variables:" nil t)
-		   (or (eq enable-local-variables t)
-		       mode-only
-		       (and enable-local-variables
-			    (save-window-excursion
-			      (switch-to-buffer (current-buffer))
-			      (save-excursion
-				(beginning-of-line)
-				(set-window-start (selected-window) (point)))
-			      (y-or-n-p (format "Set local variables as specified at end of %s? "
-						(if buffer-file-name
-						    (file-name-nondirectory
-						     buffer-file-name)
-						  (concat "buffer "
-							  (buffer-name))))))))))
+		   (or mode-only
+		       (hack-local-variables-confirm))))
 	(skip-chars-forward " \t")
 	(let ((enable-local-eval enable-local-eval)
 	      ;; suffix is what comes after "local variables:" in its line.
@@ -2473,18 +2476,7 @@
 		      (hack-one-local-variable-eval-safep val))
 		 ;; Permit eval if not root and user says ok.
 		 (and (not (zerop (user-uid)))
-		      (or (eq enable-local-eval t)
-			  (and enable-local-eval
-			       (save-window-excursion
-				 (switch-to-buffer (current-buffer))
-				 (save-excursion
-				   (beginning-of-line)
-				   (set-window-start (selected-window) (point)))
-				 (setq enable-local-eval
-				       (y-or-n-p (format "Process `eval' or hook local variables in %s? "
-							 (if buffer-file-name
-							     (concat "file " (file-name-nondirectory buffer-file-name))
-							   (concat "buffer " (buffer-name)))))))))))
+		      (hack-local-variables-confirm)))
 	     (if (eq var 'eval)
 		 (save-excursion (eval val))
 	       (make-local-variable var)
@@ -4870,5 +4862,5 @@
 (define-key ctl-x-5-map "\C-f" 'find-file-other-frame)
 (define-key ctl-x-5-map "r" 'find-file-read-only-other-frame)
 
-;;; arch-tag: bc68d3ea-19ca-468b-aac6-3a4a7766101f
+;; arch-tag: bc68d3ea-19ca-468b-aac6-3a4a7766101f
 ;;; files.el ends here