216 |
(PC-bindings partial-completion-mode) |
(PC-bindings partial-completion-mode) |
217 |
;; Deal with include file feature... |
;; Deal with include file feature... |
218 |
(cond ((not partial-completion-mode) |
(cond ((not partial-completion-mode) |
219 |
(remove-hook 'find-file-not-found-hooks 'PC-look-for-include-file)) |
(remove-hook 'find-file-not-found-functions 'PC-look-for-include-file)) |
220 |
((not PC-disable-includes) |
((not PC-disable-includes) |
221 |
(add-hook 'find-file-not-found-hooks 'PC-look-for-include-file))) |
(add-hook 'find-file-not-found-functions 'PC-look-for-include-file))) |
222 |
;; ... with some underhand redefining. |
;; ... with some underhand redefining. |
223 |
(cond ((and (not partial-completion-mode) |
(cond ((and (not partial-completion-mode) |
224 |
(functionp PC-old-read-file-name-internal)) |
(functionp PC-old-read-file-name-internal)) |
261 |
;; and this command is repeated, scroll that window. |
;; and this command is repeated, scroll that window. |
262 |
(if (and window (window-buffer window) |
(if (and window (window-buffer window) |
263 |
(buffer-name (window-buffer window))) |
(buffer-name (window-buffer window))) |
264 |
(save-excursion |
(with-current-buffer (window-buffer window) |
|
(set-buffer (window-buffer window)) |
|
265 |
(if (pos-visible-in-window-p (point-max) window) |
(if (pos-visible-in-window-p (point-max) window) |
266 |
(set-window-start window (point-min) nil) |
(set-window-start window (point-min) nil) |
267 |
(scroll-other-window))) |
(scroll-other-window))) |
345 |
(defvar PC-delims-list nil) |
(defvar PC-delims-list nil) |
346 |
|
|
347 |
(defvar PC-completion-as-file-name-predicate |
(defvar PC-completion-as-file-name-predicate |
348 |
(function |
(lambda () minibuffer-completing-file-name) |
349 |
(lambda () |
"A function testing whether a minibuffer completion now will work filename-style. |
|
(memq minibuffer-completion-table |
|
|
'(read-file-name-internal read-directory-name-internal)))) |
|
|
"A function testing whether a minibuffer completion now will work filename-style. |
|
350 |
The function takes no arguments, and typically looks at the value |
The function takes no arguments, and typically looks at the value |
351 |
of `minibuffer-completion-table' and the minibuffer contents.") |
of `minibuffer-completion-table' and the minibuffer contents.") |
352 |
|
|
661 |
(eq mode 'help)) |
(eq mode 'help)) |
662 |
(with-output-to-temp-buffer "*Completions*" |
(with-output-to-temp-buffer "*Completions*" |
663 |
(display-completion-list (sort helpposs 'string-lessp)) |
(display-completion-list (sort helpposs 'string-lessp)) |
664 |
(save-excursion |
(with-current-buffer standard-output |
|
(set-buffer standard-output) |
|
665 |
;; Record which part of the buffer we are completing |
;; Record which part of the buffer we are completing |
666 |
;; so that choosing a completion from the list |
;; so that choosing a completion from the list |
667 |
;; knows how much old text to replace. |
;; knows how much old text to replace. |
727 |
or properties are considered." |
or properties are considered." |
728 |
(interactive) |
(interactive) |
729 |
(let* ((end (point)) |
(let* ((end (point)) |
730 |
(buffer-syntax (syntax-table)) |
(beg (save-excursion |
731 |
(beg (unwind-protect |
(with-syntax-table lisp-mode-syntax-table |
732 |
(save-excursion |
(backward-sexp 1) |
733 |
(if lisp-mode-syntax-table |
(while (= (char-syntax (following-char)) ?\') |
734 |
(set-syntax-table lisp-mode-syntax-table)) |
(forward-char 1)) |
735 |
(backward-sexp 1) |
(point)))) |
|
(while (= (char-syntax (following-char)) ?\') |
|
|
(forward-char 1)) |
|
|
(point)) |
|
|
(set-syntax-table buffer-syntax))) |
|
736 |
(minibuffer-completion-table obarray) |
(minibuffer-completion-table obarray) |
737 |
(minibuffer-completion-predicate |
(minibuffer-completion-predicate |
738 |
(if (eq (char-after (1- beg)) ?\() |
(if (eq (char-after (1- beg)) ?\() |
758 |
(goto-char end) |
(goto-char end) |
759 |
(PC-do-completion nil beg end))) |
(PC-do-completion nil beg end))) |
760 |
|
|
761 |
;;; Use the shell to do globbing. |
;; Use the shell to do globbing. |
762 |
;;; This could now use file-expand-wildcards instead. |
;; This could now use file-expand-wildcards instead. |
763 |
|
|
764 |
(defun PC-expand-many-files (name) |
(defun PC-expand-many-files (name) |
765 |
(save-excursion |
(with-current-buffer (generate-new-buffer " *Glob Output*") |
|
(set-buffer (generate-new-buffer " *Glob Output*")) |
|
766 |
(erase-buffer) |
(erase-buffer) |
767 |
(shell-command (concat "echo " name) t) |
(shell-command (concat "echo " name) t) |
768 |
(goto-char (point-min)) |
(goto-char (point-min)) |
794 |
(setq files (cdr files))) |
(setq files (cdr files))) |
795 |
p)))) |
p)))) |
796 |
|
|
797 |
;;; Facilities for loading C header files. This is independent from the |
;; Facilities for loading C header files. This is independent from the |
798 |
;;; main completion code. See also the variable `PC-include-file-path' |
;; main completion code. See also the variable `PC-include-file-path' |
799 |
;;; at top of this file. |
;; at top of this file. |
800 |
|
|
801 |
(defun PC-look-for-include-file () |
(defun PC-look-for-include-file () |
802 |
(if (string-match "[\"<]\\([^\"<>]*\\)[\">]?$" (buffer-file-name)) |
(if (string-match "[\"<]\\([^\"<>]*\\)[\">]?$" (buffer-file-name)) |
807 |
new-buf) |
new-buf) |
808 |
(kill-buffer (current-buffer)) |
(kill-buffer (current-buffer)) |
809 |
(if (equal name "") |
(if (equal name "") |
810 |
(save-excursion |
(with-current-buffer (car (buffer-list)) |
|
(set-buffer (car (buffer-list))) |
|
811 |
(save-excursion |
(save-excursion |
812 |
(beginning-of-line) |
(beginning-of-line) |
813 |
(if (looking-at |
(if (looking-at |
844 |
(if path |
(if path |
845 |
(setq name (concat (file-name-as-directory (car path)) name)) |
(setq name (concat (file-name-as-directory (car path)) name)) |
846 |
(error "No such include file: <%s>" name))) |
(error "No such include file: <%s>" name))) |
847 |
(let ((dir (save-excursion |
(let ((dir (with-current-buffer (car (buffer-list)) |
|
(set-buffer (car (buffer-list))) |
|
848 |
default-directory))) |
default-directory))) |
849 |
(if (file-exists-p (concat dir name)) |
(if (file-exists-p (concat dir name)) |
850 |
(setq name (concat dir name)) |
(setq name (concat dir name)) |
853 |
(if new-buf |
(if new-buf |
854 |
;; no need to verify last-modified time for this! |
;; no need to verify last-modified time for this! |
855 |
(set-buffer new-buf) |
(set-buffer new-buf) |
856 |
(setq new-buf (create-file-buffer name)) |
(set-buffer (create-file-buffer name)) |
|
(set-buffer new-buf) |
|
857 |
(erase-buffer) |
(erase-buffer) |
858 |
(insert-file-contents name t)) |
(insert-file-contents name t)) |
859 |
;; Returning non-nil with the new buffer current |
;; Returning non-nil with the new buffer current |
872 |
env (substring env 0 pos))) |
env (substring env 0 pos))) |
873 |
path))) |
path))) |
874 |
|
|
875 |
;;; This is adapted from lib-complete.el, by Mike Williams. |
;; This is adapted from lib-complete.el, by Mike Williams. |
876 |
(defun PC-include-file-all-completions (file search-path &optional full) |
(defun PC-include-file-all-completions (file search-path &optional full) |
877 |
"Return all completions for FILE in any directory on SEARCH-PATH. |
"Return all completions for FILE in any directory on SEARCH-PATH. |
878 |
If optional third argument FULL is non-nil, returned pathnames should be |
If optional third argument FULL is non-nil, returned pathnames should be |