diff options
| author | Stefan Monnier | 2005-11-27 20:53:55 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2005-11-27 20:53:55 +0000 |
| commit | f679907bf2c41126ab045cfe4b9015d754b841ca (patch) | |
| tree | ee4f68da11543bdaf02ae082808cfd4a6fc81f7f | |
| parent | ec121b963251ab28c0be548d3cf71f3da1e678a9 (diff) | |
| download | emacs-f679907bf2c41126ab045cfe4b9015d754b841ca.tar.gz emacs-f679907bf2c41126ab045cfe4b9015d754b841ca.zip | |
(PC-completion-as-file-name-predicate): Use minibuffer-completing-file-name.
(partial-completion-mode): Use find-file-not-found-functions.
(PC-lisp-complete-symbol): Use with-syntax-table.
(PC-look-for-include-file): Remove dead setq.
(PC-look-for-include-file, PC-expand-many-files, PC-do-completion)
(PC-complete): Use with-current-buffer.
| -rw-r--r-- | lisp/complete.el | 57 |
1 files changed, 22 insertions, 35 deletions
diff --git a/lisp/complete.el b/lisp/complete.el index 4a2ce48f152..f5ab178e1b3 100644 --- a/lisp/complete.el +++ b/lisp/complete.el | |||
| @@ -216,9 +216,9 @@ the *Completions* buffer." | |||
| 216 | (PC-bindings partial-completion-mode) | 216 | (PC-bindings partial-completion-mode) |
| 217 | ;; Deal with include file feature... | 217 | ;; Deal with include file feature... |
| 218 | (cond ((not partial-completion-mode) | 218 | (cond ((not partial-completion-mode) |
| 219 | (remove-hook 'find-file-not-found-hooks 'PC-look-for-include-file)) | 219 | (remove-hook 'find-file-not-found-functions 'PC-look-for-include-file)) |
| 220 | ((not PC-disable-includes) | 220 | ((not PC-disable-includes) |
| 221 | (add-hook 'find-file-not-found-hooks 'PC-look-for-include-file))) | 221 | (add-hook 'find-file-not-found-functions 'PC-look-for-include-file))) |
| 222 | ;; ... with some underhand redefining. | 222 | ;; ... with some underhand redefining. |
| 223 | (cond ((and (not partial-completion-mode) | 223 | (cond ((and (not partial-completion-mode) |
| 224 | (functionp PC-old-read-file-name-internal)) | 224 | (functionp PC-old-read-file-name-internal)) |
| @@ -261,8 +261,7 @@ Word-delimiters for the purposes of Partial Completion are \"-\", \"_\", | |||
| 261 | ;; and this command is repeated, scroll that window. | 261 | ;; and this command is repeated, scroll that window. |
| 262 | (if (and window (window-buffer window) | 262 | (if (and window (window-buffer window) |
| 263 | (buffer-name (window-buffer window))) | 263 | (buffer-name (window-buffer window))) |
| 264 | (save-excursion | 264 | (with-current-buffer (window-buffer window) |
| 265 | (set-buffer (window-buffer window)) | ||
| 266 | (if (pos-visible-in-window-p (point-max) window) | 265 | (if (pos-visible-in-window-p (point-max) window) |
| 267 | (set-window-start window (point-min) nil) | 266 | (set-window-start window (point-min) nil) |
| 268 | (scroll-other-window))) | 267 | (scroll-other-window))) |
| @@ -346,11 +345,8 @@ See `PC-complete' for details." | |||
| 346 | (defvar PC-delims-list nil) | 345 | (defvar PC-delims-list nil) |
| 347 | 346 | ||
| 348 | (defvar PC-completion-as-file-name-predicate | 347 | (defvar PC-completion-as-file-name-predicate |
| 349 | (function | 348 | (lambda () minibuffer-completing-file-name) |
| 350 | (lambda () | 349 | "A function testing whether a minibuffer completion now will work filename-style. |
| 351 | (memq minibuffer-completion-table | ||
| 352 | '(read-file-name-internal read-directory-name-internal)))) | ||
| 353 | "A function testing whether a minibuffer completion now will work filename-style. | ||
| 354 | The function takes no arguments, and typically looks at the value | 350 | The function takes no arguments, and typically looks at the value |
| 355 | of `minibuffer-completion-table' and the minibuffer contents.") | 351 | of `minibuffer-completion-table' and the minibuffer contents.") |
| 356 | 352 | ||
| @@ -665,8 +661,7 @@ of `minibuffer-completion-table' and the minibuffer contents.") | |||
| 665 | (eq mode 'help)) | 661 | (eq mode 'help)) |
| 666 | (with-output-to-temp-buffer "*Completions*" | 662 | (with-output-to-temp-buffer "*Completions*" |
| 667 | (display-completion-list (sort helpposs 'string-lessp)) | 663 | (display-completion-list (sort helpposs 'string-lessp)) |
| 668 | (save-excursion | 664 | (with-current-buffer standard-output |
| 669 | (set-buffer standard-output) | ||
| 670 | ;; Record which part of the buffer we are completing | 665 | ;; Record which part of the buffer we are completing |
| 671 | ;; so that choosing a completion from the list | 666 | ;; so that choosing a completion from the list |
| 672 | ;; knows how much old text to replace. | 667 | ;; knows how much old text to replace. |
| @@ -732,16 +727,12 @@ Otherwise, all symbols with function definitions, values | |||
| 732 | or properties are considered." | 727 | or properties are considered." |
| 733 | (interactive) | 728 | (interactive) |
| 734 | (let* ((end (point)) | 729 | (let* ((end (point)) |
| 735 | (buffer-syntax (syntax-table)) | 730 | (beg (save-excursion |
| 736 | (beg (unwind-protect | 731 | (with-syntax-table lisp-mode-syntax-table |
| 737 | (save-excursion | 732 | (backward-sexp 1) |
| 738 | (if lisp-mode-syntax-table | 733 | (while (= (char-syntax (following-char)) ?\') |
| 739 | (set-syntax-table lisp-mode-syntax-table)) | 734 | (forward-char 1)) |
| 740 | (backward-sexp 1) | 735 | (point)))) |
| 741 | (while (= (char-syntax (following-char)) ?\') | ||
| 742 | (forward-char 1)) | ||
| 743 | (point)) | ||
| 744 | (set-syntax-table buffer-syntax))) | ||
| 745 | (minibuffer-completion-table obarray) | 736 | (minibuffer-completion-table obarray) |
| 746 | (minibuffer-completion-predicate | 737 | (minibuffer-completion-predicate |
| 747 | (if (eq (char-after (1- beg)) ?\() | 738 | (if (eq (char-after (1- beg)) ?\() |
| @@ -767,12 +758,11 @@ or properties are considered." | |||
| 767 | (goto-char end) | 758 | (goto-char end) |
| 768 | (PC-do-completion nil beg end))) | 759 | (PC-do-completion nil beg end))) |
| 769 | 760 | ||
| 770 | ;;; Use the shell to do globbing. | 761 | ;; Use the shell to do globbing. |
| 771 | ;;; This could now use file-expand-wildcards instead. | 762 | ;; This could now use file-expand-wildcards instead. |
| 772 | 763 | ||
| 773 | (defun PC-expand-many-files (name) | 764 | (defun PC-expand-many-files (name) |
| 774 | (save-excursion | 765 | (with-current-buffer (generate-new-buffer " *Glob Output*") |
| 775 | (set-buffer (generate-new-buffer " *Glob Output*")) | ||
| 776 | (erase-buffer) | 766 | (erase-buffer) |
| 777 | (shell-command (concat "echo " name) t) | 767 | (shell-command (concat "echo " name) t) |
| 778 | (goto-char (point-min)) | 768 | (goto-char (point-min)) |
| @@ -804,9 +794,9 @@ or properties are considered." | |||
| 804 | (setq files (cdr files))) | 794 | (setq files (cdr files))) |
| 805 | p)))) | 795 | p)))) |
| 806 | 796 | ||
| 807 | ;;; Facilities for loading C header files. This is independent from the | 797 | ;; Facilities for loading C header files. This is independent from the |
| 808 | ;;; main completion code. See also the variable `PC-include-file-path' | 798 | ;; main completion code. See also the variable `PC-include-file-path' |
| 809 | ;;; at top of this file. | 799 | ;; at top of this file. |
| 810 | 800 | ||
| 811 | (defun PC-look-for-include-file () | 801 | (defun PC-look-for-include-file () |
| 812 | (if (string-match "[\"<]\\([^\"<>]*\\)[\">]?$" (buffer-file-name)) | 802 | (if (string-match "[\"<]\\([^\"<>]*\\)[\">]?$" (buffer-file-name)) |
| @@ -817,8 +807,7 @@ or properties are considered." | |||
| 817 | new-buf) | 807 | new-buf) |
| 818 | (kill-buffer (current-buffer)) | 808 | (kill-buffer (current-buffer)) |
| 819 | (if (equal name "") | 809 | (if (equal name "") |
| 820 | (save-excursion | 810 | (with-current-buffer (car (buffer-list)) |
| 821 | (set-buffer (car (buffer-list))) | ||
| 822 | (save-excursion | 811 | (save-excursion |
| 823 | (beginning-of-line) | 812 | (beginning-of-line) |
| 824 | (if (looking-at | 813 | (if (looking-at |
| @@ -855,8 +844,7 @@ or properties are considered." | |||
| 855 | (if path | 844 | (if path |
| 856 | (setq name (concat (file-name-as-directory (car path)) name)) | 845 | (setq name (concat (file-name-as-directory (car path)) name)) |
| 857 | (error "No such include file: <%s>" name))) | 846 | (error "No such include file: <%s>" name))) |
| 858 | (let ((dir (save-excursion | 847 | (let ((dir (with-current-buffer (car (buffer-list)) |
| 859 | (set-buffer (car (buffer-list))) | ||
| 860 | default-directory))) | 848 | default-directory))) |
| 861 | (if (file-exists-p (concat dir name)) | 849 | (if (file-exists-p (concat dir name)) |
| 862 | (setq name (concat dir name)) | 850 | (setq name (concat dir name)) |
| @@ -865,8 +853,7 @@ or properties are considered." | |||
| 865 | (if new-buf | 853 | (if new-buf |
| 866 | ;; no need to verify last-modified time for this! | 854 | ;; no need to verify last-modified time for this! |
| 867 | (set-buffer new-buf) | 855 | (set-buffer new-buf) |
| 868 | (setq new-buf (create-file-buffer name)) | 856 | (set-buffer (create-file-buffer name)) |
| 869 | (set-buffer new-buf) | ||
| 870 | (erase-buffer) | 857 | (erase-buffer) |
| 871 | (insert-file-contents name t)) | 858 | (insert-file-contents name t)) |
| 872 | ;; Returning non-nil with the new buffer current | 859 | ;; Returning non-nil with the new buffer current |
| @@ -885,7 +872,7 @@ or properties are considered." | |||
| 885 | env (substring env 0 pos))) | 872 | env (substring env 0 pos))) |
| 886 | path))) | 873 | path))) |
| 887 | 874 | ||
| 888 | ;;; This is adapted from lib-complete.el, by Mike Williams. | 875 | ;; This is adapted from lib-complete.el, by Mike Williams. |
| 889 | (defun PC-include-file-all-completions (file search-path &optional full) | 876 | (defun PC-include-file-all-completions (file search-path &optional full) |
| 890 | "Return all completions for FILE in any directory on SEARCH-PATH. | 877 | "Return all completions for FILE in any directory on SEARCH-PATH. |
| 891 | If optional third argument FULL is non-nil, returned pathnames should be | 878 | If optional third argument FULL is non-nil, returned pathnames should be |