78 |
;; The regular M-TAB (lisp-complete-symbol) command also supports |
;; The regular M-TAB (lisp-complete-symbol) command also supports |
79 |
;; partial completion in this package. |
;; partial completion in this package. |
80 |
|
|
|
;; File name completion does not do partial completion of directories |
|
|
;; on the path, e.g., "/u/b/f" will not complete to "/usr/bin/foo", |
|
|
;; but you can put *'s in the path to accomplish this: "/u*/b*/f". |
|
|
;; Stars are required for performance reasons. |
|
|
|
|
81 |
;; In addition, this package includes a feature for accessing include |
;; In addition, this package includes a feature for accessing include |
82 |
;; files. For example, `C-x C-f <sys/time.h> RET' reads the file |
;; files. For example, `C-x C-f <sys/time.h> RET' reads the file |
83 |
;; /usr/include/sys/time.h. The variable PC-include-file-path is a |
;; /usr/include/sys/time.h. The variable PC-include-file-path is a |
383 |
(delete-region beg end) |
(delete-region beg end) |
384 |
(insert str) |
(insert str) |
385 |
(setq end (+ beg (length str))))) |
(setq end (+ beg (length str))))) |
386 |
|
|
387 |
;; Prepare various delimiter strings |
;; Prepare various delimiter strings |
388 |
(or (equal PC-word-delimiters PC-delims) |
(or (equal PC-word-delimiters PC-delims) |
389 |
(setq PC-delims PC-word-delimiters |
(setq PC-delims PC-word-delimiters |
391 |
PC-ndelims-regex (concat "[^" PC-delims "]*") |
PC-ndelims-regex (concat "[^" PC-delims "]*") |
392 |
PC-delims-list (append PC-delims nil))) |
PC-delims-list (append PC-delims nil))) |
393 |
|
|
394 |
|
;; Add wildcards if necessary |
395 |
|
(and filename |
396 |
|
(let ((dir (file-name-directory str)) |
397 |
|
(file (file-name-nondirectory str))) |
398 |
|
(while (and (stringp dir) (not (file-directory-p dir))) |
399 |
|
(setq dir (directory-file-name dir)) |
400 |
|
(setq file (concat (replace-regexp-in-string |
401 |
|
PC-delim-regex "*\\&" |
402 |
|
(file-name-nondirectory dir)) |
403 |
|
"*/" file)) |
404 |
|
(setq dir (file-name-directory dir))) |
405 |
|
(setq str (concat dir file)))) |
406 |
|
|
407 |
;; Look for wildcard expansions in directory name |
;; Look for wildcard expansions in directory name |
408 |
(and filename |
(and filename |
409 |
(string-match "\\*.*/" str) |
(string-match "\\*.*/" str) |
891 |
;;; This is adapted from lib-complete.el, by Mike Williams. |
;;; This is adapted from lib-complete.el, by Mike Williams. |
892 |
(defun PC-include-file-all-completions (file search-path &optional full) |
(defun PC-include-file-all-completions (file search-path &optional full) |
893 |
"Return all completions for FILE in any directory on SEARCH-PATH. |
"Return all completions for FILE in any directory on SEARCH-PATH. |
894 |
If optional third argument FULL is non-nil, returned pathnames should be |
If optional third argument FULL is non-nil, returned pathnames should be |
895 |
absolute rather than relative to some directory on the SEARCH-PATH." |
absolute rather than relative to some directory on the SEARCH-PATH." |
896 |
(setq search-path |
(setq search-path |
897 |
(mapcar (lambda (dir) |
(mapcar (lambda (dir) |
901 |
;; It's an absolute file name, so don't need search-path |
;; It's an absolute file name, so don't need search-path |
902 |
(progn |
(progn |
903 |
(setq file (expand-file-name file)) |
(setq file (expand-file-name file)) |
904 |
(file-name-all-completions |
(file-name-all-completions |
905 |
(file-name-nondirectory file) (file-name-directory file))) |
(file-name-nondirectory file) (file-name-directory file))) |
906 |
(let ((subdir (file-name-directory file)) |
(let ((subdir (file-name-directory file)) |
907 |
(ndfile (file-name-nondirectory file)) |
(ndfile (file-name-nondirectory file)) |
919 |
(if (file-directory-p dir) |
(if (file-directory-p dir) |
920 |
(progn |
(progn |
921 |
(setq file-lists |
(setq file-lists |
922 |
(cons |
(cons |
923 |
(mapcar (lambda (file) (concat subdir file)) |
(mapcar (lambda (file) (concat subdir file)) |
924 |
(file-name-all-completions ndfile |
(file-name-all-completions ndfile |
925 |
(car search-path))) |
(car search-path))) |
926 |
file-lists)))) |
file-lists)))) |
927 |
(setq search-path (cdr search-path)))) |
(setq search-path (cdr search-path)))) |