From ac25542d3337e026e6ebc3e39fae741a8147817e Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Tue, 17 Jul 2007 21:07:49 +0000 Subject: * files.el (file-remote-p): Introduce optional parameter IDENTIFICATION. --- lisp/files.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lisp/files.el') diff --git a/lisp/files.el b/lisp/files.el index 849d09b4215..ed76e16b183 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -727,7 +727,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 +736,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 +748,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) -- cgit v1.2.3 From 418fd37516f85b5b017f9db2a58eb48e20208769 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 19 Jul 2007 03:29:47 +0000 Subject: (locate-dominating-file): New function. --- lisp/ChangeLog | 5 +++++ lisp/files.el | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) (limited to 'lisp/files.el') diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f8a38266120..daa0bbbdbe7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2007-07-19 Stefan Monnier + + * files.el (locate-dominating-file): New function. + 2007-07-18 Michael Albinus * progmodes/grep.el (grep-host-defaults-alist): New defvar. @@ -13,6 +17,7 @@ files. Change two keybindings to point to new function names. 2007-07-18 Juanma Barranquero + * follow.el (follow-mode-hook, follow-mode-off-hook, follow-mode) (follow-delete-other-windows-and-split, follow-recenter) (follow-windows-aligned-p, follow-point-visible-all-windows-p) diff --git a/lisp/files.el b/lisp/files.el index ed76e16b183..631e75f98d0 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -711,6 +711,24 @@ 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) + (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'." -- cgit v1.2.3 From 6b6b99547b477c24b5575116f1a42b82d045fb17 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Fri, 20 Jul 2007 04:00:37 +0000 Subject: (locate-dominating-file): Add comment. --- lisp/files.el | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lisp/files.el') diff --git a/lisp/files.el b/lisp/files.el index 631e75f98d0..3a922e3d708 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -720,6 +720,10 @@ PATH-AND-SUFFIXES is a pair of lists, (DIRECTORIES . SUFFIXES)." ;; 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)) -- cgit v1.2.3 From 3650f60e8a2d958369818c17f18ed42a85fab8c0 Mon Sep 17 00:00:00 2001 From: Nick Roberts Date: Sun, 22 Jul 2007 23:17:14 +0000 Subject: Mark mode-line-remote as risky. --- lisp/files.el | 1 + src/ChangeLog | 7 +++++++ 2 files changed, 8 insertions(+) (limited to 'lisp/files.el') diff --git a/lisp/files.el b/lisp/files.el index 3a922e3d708..f89ea85f2cc 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -2486,6 +2486,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 diff --git a/src/ChangeLog b/src/ChangeLog index 2c14c0e8eaf..b7bff90947d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2007-07-22 Nick Roberts + + * xdisp.c (decode_mode_spec): Add case 'R' for to test for + remote default-directory. + + * buffer.c (mode-line-format): Describe above case in doc string. + 2007-07-18 Richard Stallman * data.c (Fsetq_default): Doc fix. -- cgit v1.2.3