summaryrefslogtreecommitdiff
path: root/lisp/files.el
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>2007-07-24 01:25:28 +0000
committerMiles Bader <miles@gnu.org>2007-07-24 01:25:28 +0000
commit492d9f3e3ccd2b640958e840caa451e9e04e86db (patch)
treec87779daf272535b621216ef05179fa48102e57e /lisp/files.el
parent7eb1e4534e88a32fe5e549e630fdabf3e062be2b (diff)
parent1e8995158740b15936887264a3d7183beb5c51d9 (diff)
downloademacs-492d9f3e3ccd2b640958e840caa451e9e04e86db.tar.gz
emacs-492d9f3e3ccd2b640958e840caa451e9e04e86db.tar.bz2
emacs-492d9f3e3ccd2b640958e840caa451e9e04e86db.zip
Merge from emacs--devo--0
Patches applied: * emacs--devo--0 (patch 814-823) - Update from CVS - Merge from emacs--rel--22 * emacs--rel--22 (patch 59-69) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 237-238) - Update from CVS Revision: emacs@sv.gnu.org/emacs--multi-tty--0--patch-26
Diffstat (limited to 'lisp/files.el')
-rw-r--r--lisp/files.el32
1 files changed, 30 insertions, 2 deletions
diff --git a/lisp/files.el b/lisp/files.el
index 73d60b33b51..e91a142f3b8 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -711,6 +711,28 @@ PATH-AND-SUFFIXES is a pair of lists, (DIRECTORIES . SUFFIXES)."
((null action) (try-completion string names))
(t (test-completion string names))))))
+(defun locate-dominating-file (file regexp)
+ "Look up the directory hierarchy from FILE for a file matching REGEXP."
+ (while (and file (not (file-directory-p file)))
+ (setq file (file-name-directory (directory-file-name file))))
+ (catch 'found
+ (let ((user (nth 2 (file-attributes file)))
+ ;; Abbreviate, so as to stop when we cross ~/.
+ (dir (abbreviate-file-name (file-name-as-directory file)))
+ files)
+ ;; As a heuristic, we stop looking up the hierarchy of directories as
+ ;; soon as we find a directory belonging to another user. This should
+ ;; save us from looking in things like /net and /afs. This assumes
+ ;; that all the files inside a project belong to the same user.
+ (while (and dir (equal user (nth 2 (file-attributes dir))))
+ (if (setq files (directory-files dir 'full regexp))
+ (throw 'found (car files))
+ (if (equal dir
+ (setq dir (file-name-directory
+ (directory-file-name dir))))
+ (setq dir nil))))
+ nil)))
+
(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'."
@@ -727,7 +749,7 @@ This is an interface to the function `load'."
(cons load-path (get-load-suffixes)))))
(load library))
-(defun file-remote-p (file &optional connected)
+(defun file-remote-p (file &optional identification connected)
"Test whether FILE specifies a location on a remote system.
Return an identification of the system if the location is indeed
remote. The identification of the system may comprise a method
@@ -736,6 +758,11 @@ to access the system and its hostname, amongst other things.
For example, the filename \"/user@host:/foo\" specifies a location
on the system \"/user@host:\".
+IDENTIFICATION specifies which part of the identification shall
+be returned as string. IDENTIFICATION can be the symbol
+`method', `user' or `host'; any other value is handled like nil
+and means to return the complete identification string.
+
If CONNECTED is non-nil, the function returns an identification only
if FILE is located on a remote system, and a connection is established
to that remote system.
@@ -743,7 +770,7 @@ to that remote system.
`file-remote-p' will never open a connection on its own."
(let ((handler (find-file-name-handler file 'file-remote-p)))
(if handler
- (funcall handler 'file-remote-p file connected)
+ (funcall handler 'file-remote-p file identification connected)
nil)))
(defun file-local-copy (file)
@@ -2460,6 +2487,7 @@ asking you for confirmation."
mode-line-mule-info
mode-line-position
mode-line-process
+ mode-line-remote
mode-name
outline-level
overriding-local-map