diff options
| author | Stefan Monnier | 2007-07-19 03:29:47 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2007-07-19 03:29:47 +0000 |
| commit | 418fd37516f85b5b017f9db2a58eb48e20208769 (patch) | |
| tree | 0678e8ee8552b8ff2966ceed0a50026ab6900382 | |
| parent | 6e3aa3f58ef253559ce6416d6aa02885cd944ff1 (diff) | |
| download | emacs-418fd37516f85b5b017f9db2a58eb48e20208769.tar.gz emacs-418fd37516f85b5b017f9db2a58eb48e20208769.zip | |
(locate-dominating-file): New function.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/files.el | 18 |
2 files changed, 23 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f8a38266120..daa0bbbdbe7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2007-07-19 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * files.el (locate-dominating-file): New function. | ||
| 4 | |||
| 1 | 2007-07-18 Michael Albinus <michael.albinus@gmx.de> | 5 | 2007-07-18 Michael Albinus <michael.albinus@gmx.de> |
| 2 | 6 | ||
| 3 | * progmodes/grep.el (grep-host-defaults-alist): New defvar. | 7 | * progmodes/grep.el (grep-host-defaults-alist): New defvar. |
| @@ -13,6 +17,7 @@ | |||
| 13 | files. Change two keybindings to point to new function names. | 17 | files. Change two keybindings to point to new function names. |
| 14 | 18 | ||
| 15 | 2007-07-18 Juanma Barranquero <lekktu@gmail.com> | 19 | 2007-07-18 Juanma Barranquero <lekktu@gmail.com> |
| 20 | |||
| 16 | * follow.el (follow-mode-hook, follow-mode-off-hook, follow-mode) | 21 | * follow.el (follow-mode-hook, follow-mode-off-hook, follow-mode) |
| 17 | (follow-delete-other-windows-and-split, follow-recenter) | 22 | (follow-delete-other-windows-and-split, follow-recenter) |
| 18 | (follow-windows-aligned-p, follow-point-visible-all-windows-p) | 23 | (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)." | |||
| 711 | ((null action) (try-completion string names)) | 711 | ((null action) (try-completion string names)) |
| 712 | (t (test-completion string names)))))) | 712 | (t (test-completion string names)))))) |
| 713 | 713 | ||
| 714 | (defun locate-dominating-file (file regexp) | ||
| 715 | "Look up the directory hierarchy from FILE for a file matching REGEXP." | ||
| 716 | (while (and file (not (file-directory-p file))) | ||
| 717 | (setq file (file-name-directory (directory-file-name file)))) | ||
| 718 | (catch 'found | ||
| 719 | (let ((user (nth 2 (file-attributes file))) | ||
| 720 | ;; Abbreviate, so as to stop when we cross ~/. | ||
| 721 | (dir (abbreviate-file-name (file-name-as-directory file))) | ||
| 722 | files) | ||
| 723 | (while (and dir (equal user (nth 2 (file-attributes dir)))) | ||
| 724 | (if (setq files (directory-files dir 'full regexp)) | ||
| 725 | (throw 'found (car files)) | ||
| 726 | (if (equal dir | ||
| 727 | (setq dir (file-name-directory | ||
| 728 | (directory-file-name dir)))) | ||
| 729 | (setq dir nil)))) | ||
| 730 | nil))) | ||
| 731 | |||
| 714 | (defun executable-find (command) | 732 | (defun executable-find (command) |
| 715 | "Search for COMMAND in `exec-path' and return the absolute file name. | 733 | "Search for COMMAND in `exec-path' and return the absolute file name. |
| 716 | Return nil if COMMAND is not found anywhere in `exec-path'." | 734 | Return nil if COMMAND is not found anywhere in `exec-path'." |