diff options
| author | Stefan Monnier | 2011-06-20 12:02:31 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2011-06-20 12:02:31 -0400 |
| commit | bcd70d976f1035f84f55fa6969b9c0c419b7cc06 (patch) | |
| tree | 50dc843ae8030ef911c788a795f3b14d689045a7 /lisp/progmodes | |
| parent | aebf69c8b3dc592ea315c187feb5f69b884a850e (diff) | |
| download | emacs-bcd70d976f1035f84f55fa6969b9c0c419b7cc06.tar.gz emacs-bcd70d976f1035f84f55fa6969b9c0c419b7cc06.zip | |
Use completion-at-point rather than completion-in-region.
* lisp/wid-edit.el: Use lexical scoping and move towards completion-at-point.
(widget-complete): Use new :completion-function property.
(widget-completions-at-point): New function.
(default): Use :completion-function instead of :complete.
(widget-default-completions): Rename from widget-default-complete, rewrite.
(widget-string-complete, widget-file-complete, widget-color-complete):
Remove functions.
(file, symbol, function, variable, coding-system, color):
* lisp/international/mule-cmds.el (default-input-method, charset)
(language-info-custom-alist):
* lisp/cus-edit.el (face): Use new property :completions.
* lisp/progmodes/pascal.el (pascal-completions-at-point): New function.
(pascal-mode): Use it.
(pascal-mode-map): Use completion-at-point.
(pascal-toggle-completions): Make obsolete.
(pascal-complete-word, pascal-show-completions):
* lisp/progmodes/octave-mod.el (octave-complete-symbol):
Redefine as obsolete alias.
* lisp/progmodes/octave-inf.el (inferior-octave-completion-at-point):
Signal absence of completion info for old Octave,
(inferior-octave-complete): Redefine as obsolete alias.
* lisp/progmodes/meta-mode.el: Use lexical-binding and completion-at-point.
(meta-completions-at-point): Rename from meta-complete-symbol and
adapt it for use on completion-at-point-functions.
(meta-common-mode): Use it.
(meta-looking-at-backward, meta-match-buffer): Remove.
(meta-complete-symbol): Redefine as obsolete alias.
(meta-common-mode-map): Use completion-at-point.
* lisp/progmodes/make-mode.el: Use lexical-binding and completion-at-point.
(makefile-mode-map): Use completion-at-point.
(makefile-completions-at-point): Rename from makefile-complete and
adapt it for use on completion-at-point-functions.
(makefile-mode): Use it.
(makefile-complete): Redefine as obsolete alias.
Diffstat (limited to 'lisp/progmodes')
| -rw-r--r-- | lisp/progmodes/make-mode.el | 44 | ||||
| -rw-r--r-- | lisp/progmodes/meta-mode.el | 52 | ||||
| -rw-r--r-- | lisp/progmodes/octave-inf.el | 23 | ||||
| -rw-r--r-- | lisp/progmodes/octave-mod.el | 8 | ||||
| -rw-r--r-- | lisp/progmodes/pascal.el | 75 |
5 files changed, 71 insertions, 131 deletions
diff --git a/lisp/progmodes/make-mode.el b/lisp/progmodes/make-mode.el index 22e5d2f7c5c..293ba49d4ae 100644 --- a/lisp/progmodes/make-mode.el +++ b/lisp/progmodes/make-mode.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; make-mode.el --- makefile editing commands for Emacs | 1 | ;;; make-mode.el --- makefile editing commands for Emacs -*- lexical-binding:t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1992, 1994, 1999-2011 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1992, 1994, 1999-2011 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -602,7 +602,7 @@ The function must satisfy this calling convention: | |||
| 602 | (define-key map "\C-c\C-m\C-p" 'makefile-makepp-mode) | 602 | (define-key map "\C-c\C-m\C-p" 'makefile-makepp-mode) |
| 603 | (define-key map "\M-p" 'makefile-previous-dependency) | 603 | (define-key map "\M-p" 'makefile-previous-dependency) |
| 604 | (define-key map "\M-n" 'makefile-next-dependency) | 604 | (define-key map "\M-n" 'makefile-next-dependency) |
| 605 | (define-key map "\e\t" 'makefile-complete) | 605 | (define-key map "\e\t" 'completion-at-point) |
| 606 | 606 | ||
| 607 | ;; Make menus. | 607 | ;; Make menus. |
| 608 | (define-key map [menu-bar makefile-mode] | 608 | (define-key map [menu-bar makefile-mode] |
| @@ -653,7 +653,7 @@ The function must satisfy this calling convention: | |||
| 653 | '(menu-item "Find Targets and Macros" makefile-pickup-everything | 653 | '(menu-item "Find Targets and Macros" makefile-pickup-everything |
| 654 | :help "Notice names of all macros and targets in Makefile")) | 654 | :help "Notice names of all macros and targets in Makefile")) |
| 655 | (define-key map [menu-bar makefile-mode complete] | 655 | (define-key map [menu-bar makefile-mode complete] |
| 656 | '(menu-item "Complete Target or Macro" makefile-complete | 656 | '(menu-item "Complete Target or Macro" completion-at-point |
| 657 | :help "Perform completion on Makefile construct preceding point")) | 657 | :help "Perform completion on Makefile construct preceding point")) |
| 658 | (define-key map [menu-bar makefile-mode backslash] | 658 | (define-key map [menu-bar makefile-mode backslash] |
| 659 | '(menu-item "Backslash Region" makefile-backslash-region | 659 | '(menu-item "Backslash Region" makefile-backslash-region |
| @@ -852,6 +852,8 @@ Makefile mode can be configured by modifying the following variables: | |||
| 852 | List of special targets. You will be offered to complete | 852 | List of special targets. You will be offered to complete |
| 853 | on one of those in the minibuffer whenever you enter a `.'. | 853 | on one of those in the minibuffer whenever you enter a `.'. |
| 854 | at the beginning of a line in Makefile mode." | 854 | at the beginning of a line in Makefile mode." |
| 855 | (add-hook 'completion-at-point-functions | ||
| 856 | #'makefile-completions-at-point nil t) | ||
| 855 | (add-hook 'write-file-functions | 857 | (add-hook 'write-file-functions |
| 856 | 'makefile-warn-suspicious-lines nil t) | 858 | 'makefile-warn-suspicious-lines nil t) |
| 857 | (add-hook 'write-file-functions | 859 | (add-hook 'write-file-functions |
| @@ -1147,11 +1149,7 @@ and adds all qualifying names to the list of known targets." | |||
| 1147 | 1149 | ||
| 1148 | ;;; Completion. | 1150 | ;;; Completion. |
| 1149 | 1151 | ||
| 1150 | (defun makefile-complete () | 1152 | (defun makefile-completions-at-point () |
| 1151 | "Perform completion on Makefile construct preceding point. | ||
| 1152 | Can complete variable and target names. | ||
| 1153 | The context determines which are considered." | ||
| 1154 | (interactive) | ||
| 1155 | (let* ((beg (save-excursion | 1153 | (let* ((beg (save-excursion |
| 1156 | (skip-chars-backward "^$(){}:#= \t\n") | 1154 | (skip-chars-backward "^$(){}:#= \t\n") |
| 1157 | (point))) | 1155 | (point))) |
| @@ -1168,22 +1166,26 @@ The context determines which are considered." | |||
| 1168 | ;; Preceding "$(" or "${" means macros only. | 1166 | ;; Preceding "$(" or "${" means macros only. |
| 1169 | ((and (memq pc '(?\{ ?\()) | 1167 | ((and (memq pc '(?\{ ?\()) |
| 1170 | (progn | 1168 | (progn |
| 1171 | (setq paren (if (eq paren ?\{) ?\} ?\))) | 1169 | (setq paren (if (eq pc ?\{) ?\} ?\))) |
| 1172 | (backward-char) | 1170 | (backward-char) |
| 1173 | (= (preceding-char) ?$))) | 1171 | (= (preceding-char) ?$))) |
| 1174 | t))))) | 1172 | t))))) |
| 1175 | 1173 | (suffix (cond | |
| 1176 | (table (apply-partially 'completion-table-with-terminator | 1174 | (do-macros (if paren (string paren))) |
| 1177 | (cond | 1175 | ((save-excursion (goto-char beg) (bolp)) ":") |
| 1178 | (do-macros (or paren "")) | 1176 | (t " ")))) |
| 1179 | ((save-excursion (goto-char beg) (bolp)) ":") | 1177 | (list beg (point) |
| 1180 | (t " ")) | 1178 | (append (if do-macros '() makefile-target-table) |
| 1181 | (append (if do-macros | 1179 | makefile-macro-table) |
| 1182 | '() | 1180 | :exit-function |
| 1183 | makefile-target-table) | 1181 | (if suffix |
| 1184 | makefile-macro-table)))) | 1182 | (lambda (_s finished) |
| 1185 | (completion-in-region beg (point) table))) | 1183 | (when (memq finished '(sole finished)) |
| 1186 | 1184 | (if (looking-at (regexp-quote suffix)) | |
| 1185 | (goto-char (match-end 0)) | ||
| 1186 | (insert suffix)))))))) | ||
| 1187 | |||
| 1188 | (define-obsolete-function-alias 'makefile-complete 'completion-at-point "24.1") | ||
| 1187 | 1189 | ||
| 1188 | 1190 | ||
| 1189 | ;; Backslashification. Stolen from cc-mode.el. | 1191 | ;; Backslashification. Stolen from cc-mode.el. |
diff --git a/lisp/progmodes/meta-mode.el b/lisp/progmodes/meta-mode.el index b36104bf49b..ab640c0e270 100644 --- a/lisp/progmodes/meta-mode.el +++ b/lisp/progmodes/meta-mode.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; meta-mode.el --- major mode for editing Metafont or MetaPost sources | 1 | ;;; meta-mode.el --- major mode for editing Metafont or MetaPost sources -*- lexical-binding:t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1997, 2001-2011 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1997, 2001-2011 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -471,16 +471,13 @@ If the list was changed, sort the list and remove duplicates first." | |||
| 471 | (string-lessp (car a) (car b))) | 471 | (string-lessp (car a) (car b))) |
| 472 | 472 | ||
| 473 | 473 | ||
| 474 | (defun meta-complete-symbol () | 474 | (defun meta-completions-at-point () |
| 475 | "Perform completion on Metafont or MetaPost symbol preceding point." | ||
| 476 | ;; FIXME: Use completion-at-point-functions. | ||
| 477 | (interactive "*") | ||
| 478 | (let ((list meta-complete-list) | 475 | (let ((list meta-complete-list) |
| 479 | entry) | 476 | entry) |
| 480 | (while list | 477 | (while list |
| 481 | (setq entry (car list) | 478 | (setq entry (car list) |
| 482 | list (cdr list)) | 479 | list (cdr list)) |
| 483 | (if (meta-looking-at-backward (car entry) 200) | 480 | (if (looking-back (car entry) (max (point-min) (- (point) 200))) |
| 484 | (setq list nil))) | 481 | (setq list nil))) |
| 485 | (if (numberp (nth 1 entry)) | 482 | (if (numberp (nth 1 entry)) |
| 486 | (let* ((sub (nth 1 entry)) | 483 | (let* ((sub (nth 1 entry)) |
| @@ -488,31 +485,19 @@ If the list was changed, sort the list and remove duplicates first." | |||
| 488 | (begin (match-beginning sub)) | 485 | (begin (match-beginning sub)) |
| 489 | (end (match-end sub)) | 486 | (end (match-end sub)) |
| 490 | (list (funcall (nth 2 entry)))) | 487 | (list (funcall (nth 2 entry)))) |
| 491 | (completion-in-region | 488 | (list |
| 492 | begin end | 489 | begin end list |
| 493 | (if (zerop (length close)) list | 490 | :exit-function |
| 494 | (apply-partially 'completion-table-with-terminator | 491 | (unless (zerop (length close)) |
| 495 | close list)))) | 492 | (lambda (_s finished) |
| 496 | (funcall (nth 1 entry))))) | 493 | (when (memq finished '(sole finished)) |
| 497 | 494 | (if (looking-at (regexp-quote close)) | |
| 498 | 495 | (goto-char (match-end 0)) | |
| 499 | (defun meta-looking-at-backward (regexp &optional limit) | 496 | (insert close))))))) |
| 500 | ;; utility function used in `meta-complete-symbol' | 497 | (nth 1 entry)))) |
| 501 | (let ((pos (point))) | 498 | |
| 502 | (save-excursion | 499 | (define-obsolete-function-alias 'meta-complete-symbol |
| 503 | (and (re-search-backward | 500 | 'completion-at-point "24.1") |
| 504 | regexp (if limit (max (point-min) (- (point) limit))) t) | ||
| 505 | (eq (match-end 0) pos))))) | ||
| 506 | |||
| 507 | (defun meta-match-buffer (n) | ||
| 508 | ;; utility function used in `meta-complete-symbol' | ||
| 509 | (if (match-beginning n) | ||
| 510 | (let ((str (buffer-substring (match-beginning n) (match-end n)))) | ||
| 511 | (set-text-properties 0 (length str) nil str) | ||
| 512 | (copy-sequence str)) | ||
| 513 | "")) | ||
| 514 | |||
| 515 | |||
| 516 | 501 | ||
| 517 | ;;; Indentation. | 502 | ;;; Indentation. |
| 518 | 503 | ||
| @@ -906,7 +891,7 @@ The environment marked is the one that contains point or follows point." | |||
| 906 | (define-key map "\C-c;" 'meta-comment-region) | 891 | (define-key map "\C-c;" 'meta-comment-region) |
| 907 | (define-key map "\C-c:" 'meta-uncomment-region) | 892 | (define-key map "\C-c:" 'meta-uncomment-region) |
| 908 | ;; Symbol Completion: | 893 | ;; Symbol Completion: |
| 909 | (define-key map "\M-\t" 'meta-complete-symbol) | 894 | (define-key map "\M-\t" 'completion-at-point) |
| 910 | ;; Shell Commands: | 895 | ;; Shell Commands: |
| 911 | ;; (define-key map "\C-c\C-c" 'meta-command-file) | 896 | ;; (define-key map "\C-c\C-c" 'meta-command-file) |
| 912 | ;; (define-key map "\C-c\C-k" 'meta-kill-job) | 897 | ;; (define-key map "\C-c\C-k" 'meta-kill-job) |
| @@ -935,7 +920,7 @@ The environment marked is the one that contains point or follows point." | |||
| 935 | ["Uncomment Region" meta-uncomment-region | 920 | ["Uncomment Region" meta-uncomment-region |
| 936 | :active (meta-mark-active)] | 921 | :active (meta-mark-active)] |
| 937 | "--" | 922 | "--" |
| 938 | ["Complete Symbol" meta-complete-symbol t] | 923 | ["Complete Symbol" completion-at-point t] |
| 939 | ; "--" | 924 | ; "--" |
| 940 | ; ["Command on Buffer" meta-command-file t] | 925 | ; ["Command on Buffer" meta-command-file t] |
| 941 | ; ["Kill Job" meta-kill-job t] | 926 | ; ["Kill Job" meta-kill-job t] |
| @@ -994,6 +979,7 @@ The environment marked is the one that contains point or follows point." | |||
| 994 | 979 | ||
| 995 | (set (make-local-variable 'parse-sexp-ignore-comments) t) | 980 | (set (make-local-variable 'parse-sexp-ignore-comments) t) |
| 996 | 981 | ||
| 982 | (add-hook 'completion-at-point-functions #'meta-completions-at-point nil t) | ||
| 997 | (set (make-local-variable 'comment-indent-function) #'meta-comment-indent) | 983 | (set (make-local-variable 'comment-indent-function) #'meta-comment-indent) |
| 998 | (set (make-local-variable 'indent-line-function) #'meta-indent-line) | 984 | (set (make-local-variable 'indent-line-function) #'meta-indent-line) |
| 999 | ;; No need to define a mode-specific 'indent-region-function. | 985 | ;; No need to define a mode-specific 'indent-region-function. |
diff --git a/lisp/progmodes/octave-inf.el b/lisp/progmodes/octave-inf.el index 803a542563c..cb64b2436c6 100644 --- a/lisp/progmodes/octave-inf.el +++ b/lisp/progmodes/octave-inf.el | |||
| @@ -267,8 +267,12 @@ startup file, `~/.emacs-octave'." | |||
| 267 | (save-excursion | 267 | (save-excursion |
| 268 | (skip-syntax-backward "w_" (comint-line-beginning-position)) | 268 | (skip-syntax-backward "w_" (comint-line-beginning-position)) |
| 269 | (point)))) | 269 | (point)))) |
| 270 | (cond (inferior-octave-complete-impossible nil) | 270 | (cond ((eq start end) nil) |
| 271 | ((eq start end) nil) | 271 | (inferior-octave-complete-impossible |
| 272 | (message (concat | ||
| 273 | "Your Octave does not have `completion_matches'. " | ||
| 274 | "Please upgrade to version 2.X.")) | ||
| 275 | nil) | ||
| 272 | (t | 276 | (t |
| 273 | (list | 277 | (list |
| 274 | start end | 278 | start end |
| @@ -279,19 +283,8 @@ startup file, `~/.emacs-octave'." | |||
| 279 | (sort (delete-dups inferior-octave-output-list) | 283 | (sort (delete-dups inferior-octave-output-list) |
| 280 | 'string-lessp)))))))) | 284 | 'string-lessp)))))))) |
| 281 | 285 | ||
| 282 | (defun inferior-octave-complete () | 286 | (define-obsolete-function-alias 'inferior-octave-complete |
| 283 | "Perform completion on the Octave symbol preceding point. | 287 | 'completion-at-point "24.1") |
| 284 | This is implemented using the Octave command `completion_matches' which | ||
| 285 | is NOT available with versions of Octave prior to 2.0." | ||
| 286 | (interactive) | ||
| 287 | (if inferior-octave-complete-impossible | ||
| 288 | (error (concat | ||
| 289 | "Your Octave does not have `completion_matches'. " | ||
| 290 | "Please upgrade to version 2.X.")) | ||
| 291 | (let ((data (inferior-octave-completion-at-point))) | ||
| 292 | (if (null data) | ||
| 293 | (message "Cannot complete an empty string") | ||
| 294 | (apply #'completion-in-region data))))) | ||
| 295 | 288 | ||
| 296 | (defun inferior-octave-dynamic-list-input-ring () | 289 | (defun inferior-octave-dynamic-list-input-ring () |
| 297 | "List the buffer's input history in a help buffer." | 290 | "List the buffer's input history in a help buffer." |
diff --git a/lisp/progmodes/octave-mod.el b/lisp/progmodes/octave-mod.el index 39d997e1d5e..183347cdeca 100644 --- a/lisp/progmodes/octave-mod.el +++ b/lisp/progmodes/octave-mod.el | |||
| @@ -983,12 +983,8 @@ otherwise." | |||
| 983 | (setq end (point)))) | 983 | (setq end (point)))) |
| 984 | (list beg end octave-completion-alist))) | 984 | (list beg end octave-completion-alist))) |
| 985 | 985 | ||
| 986 | (defun octave-complete-symbol () | 986 | (define-obsolete-function-alias 'octave-complete-symbol |
| 987 | "Perform completion on Octave symbol preceding point. | 987 | 'completion-at-point "24.1") |
| 988 | Compare that symbol against Octave's reserved words and builtin | ||
| 989 | variables." | ||
| 990 | (interactive) | ||
| 991 | (apply 'completion-in-region (octave-completion-at-point-function))) | ||
| 992 | 988 | ||
| 993 | ;;; Electric characters && friends | 989 | ;;; Electric characters && friends |
| 994 | 990 | ||
diff --git a/lisp/progmodes/pascal.el b/lisp/progmodes/pascal.el index e28bb14bb9a..57ed13969b4 100644 --- a/lisp/progmodes/pascal.el +++ b/lisp/progmodes/pascal.el | |||
| @@ -40,7 +40,6 @@ | |||
| 40 | ;; pascal-tab-always-indent t | 40 | ;; pascal-tab-always-indent t |
| 41 | ;; pascal-auto-endcomments t | 41 | ;; pascal-auto-endcomments t |
| 42 | ;; pascal-auto-lineup '(all) | 42 | ;; pascal-auto-lineup '(all) |
| 43 | ;; pascal-toggle-completions nil | ||
| 44 | ;; pascal-type-keywords '("array" "file" "packed" "char" | 43 | ;; pascal-type-keywords '("array" "file" "packed" "char" |
| 45 | ;; "integer" "real" "string" "record") | 44 | ;; "integer" "real" "string" "record") |
| 46 | ;; pascal-start-keywords '("begin" "end" "function" "procedure" | 45 | ;; pascal-start-keywords '("begin" "end" "function" "procedure" |
| @@ -79,8 +78,8 @@ | |||
| 79 | ;; These are user preferences, so not to set by default. | 78 | ;; These are user preferences, so not to set by default. |
| 80 | ;;(define-key map "\r" 'electric-pascal-terminate-line) | 79 | ;;(define-key map "\r" 'electric-pascal-terminate-line) |
| 81 | ;;(define-key map "\t" 'electric-pascal-tab) | 80 | ;;(define-key map "\t" 'electric-pascal-tab) |
| 82 | (define-key map "\M-\t" 'pascal-complete-word) | 81 | (define-key map "\M-\t" 'completion-at-point) |
| 83 | (define-key map "\M-?" 'pascal-show-completions) | 82 | (define-key map "\M-?" 'completion-help-at-point) |
| 84 | (define-key map "\177" 'backward-delete-char-untabify) | 83 | (define-key map "\177" 'backward-delete-char-untabify) |
| 85 | (define-key map "\M-\C-h" 'pascal-mark-defun) | 84 | (define-key map "\M-\C-h" 'pascal-mark-defun) |
| 86 | (define-key map "\C-c\C-b" 'pascal-insert-block) | 85 | (define-key map "\C-c\C-b" 'pascal-insert-block) |
| @@ -232,13 +231,13 @@ will do all lineups." | |||
| 232 | (const :tag "Case statements" case)) | 231 | (const :tag "Case statements" case)) |
| 233 | :group 'pascal) | 232 | :group 'pascal) |
| 234 | 233 | ||
| 235 | (defcustom pascal-toggle-completions nil | 234 | (defvar pascal-toggle-completions nil |
| 236 | "*Non-nil means \\<pascal-mode-map>\\[pascal-complete-word] should try all possible completions one by one. | 235 | "*Non-nil meant \\<pascal-mode-map>\\[pascal-complete-word] would try all possible completions one by one. |
| 237 | Repeated use of \\[pascal-complete-word] will show you all of them. | 236 | Repeated use of \\[pascal-complete-word] would show you all of them. |
| 238 | Normally, when there is more than one possible completion, | 237 | Normally, when there is more than one possible completion, |
| 239 | it displays a list of all possible completions." | 238 | it displays a list of all possible completions.") |
| 240 | :type 'boolean | 239 | (make-obsolete-variable 'pascal-toggle-completions |
| 241 | :group 'pascal) | 240 | 'completion-cycle-threshold "24.1") |
| 242 | 241 | ||
| 243 | (defcustom pascal-type-keywords | 242 | (defcustom pascal-type-keywords |
| 244 | '("array" "file" "packed" "char" "integer" "real" "string" "record") | 243 | '("array" "file" "packed" "char" "integer" "real" "string" "record") |
| @@ -303,9 +302,9 @@ are handled in another way, and should not be added to this list." | |||
| 303 | "Major mode for editing Pascal code. \\<pascal-mode-map> | 302 | "Major mode for editing Pascal code. \\<pascal-mode-map> |
| 304 | TAB indents for Pascal code. Delete converts tabs to spaces as it moves back. | 303 | TAB indents for Pascal code. Delete converts tabs to spaces as it moves back. |
| 305 | 304 | ||
| 306 | \\[pascal-complete-word] completes the word around current point with respect \ | 305 | \\[completion-at-point] completes the word around current point with respect \ |
| 307 | to position in code | 306 | to position in code |
| 308 | \\[pascal-show-completions] shows all possible completions at this point. | 307 | \\[completion-help-at-point] shows all possible completions at this point. |
| 309 | 308 | ||
| 310 | Other useful functions are: | 309 | Other useful functions are: |
| 311 | 310 | ||
| @@ -354,6 +353,7 @@ no args, if that value is non-nil." | |||
| 354 | (set (make-local-variable 'comment-start) "{") | 353 | (set (make-local-variable 'comment-start) "{") |
| 355 | (set (make-local-variable 'comment-start-skip) "(\\*+ *\\|{ *") | 354 | (set (make-local-variable 'comment-start-skip) "(\\*+ *\\|{ *") |
| 356 | (set (make-local-variable 'comment-end) "}") | 355 | (set (make-local-variable 'comment-end) "}") |
| 356 | (add-hook 'completion-at-point-functions 'pascal-completions-at-point nil t) | ||
| 357 | ;; Font lock support | 357 | ;; Font lock support |
| 358 | (set (make-local-variable 'font-lock-defaults) | 358 | (set (make-local-variable 'font-lock-defaults) |
| 359 | '(pascal-font-lock-keywords nil t)) | 359 | '(pascal-font-lock-keywords nil t)) |
| @@ -1287,54 +1287,17 @@ indent of the current line in parameterlist." | |||
| 1287 | (defvar pascal-last-word-shown nil) | 1287 | (defvar pascal-last-word-shown nil) |
| 1288 | (defvar pascal-last-completions nil) | 1288 | (defvar pascal-last-completions nil) |
| 1289 | 1289 | ||
| 1290 | (defun pascal-complete-word () | 1290 | (defun pascal-completions-at-point () |
| 1291 | "Complete word at current point. | ||
| 1292 | \(See also `pascal-toggle-completions', `pascal-type-keywords', | ||
| 1293 | `pascal-start-keywords' and `pascal-separator-keywords'.)" | ||
| 1294 | (interactive) | ||
| 1295 | (let* ((b (save-excursion (skip-chars-backward "a-zA-Z0-9_") (point))) | 1291 | (let* ((b (save-excursion (skip-chars-backward "a-zA-Z0-9_") (point))) |
| 1296 | (e (save-excursion (skip-chars-forward "a-zA-Z0-9_") (point)))) | 1292 | (e (save-excursion (skip-chars-forward "a-zA-Z0-9_") (point)))) |
| 1293 | (when (> e b) | ||
| 1294 | (list b e #'pascal-completion)))) | ||
| 1297 | 1295 | ||
| 1298 | ;; Toggle-completions inserts whole labels | 1296 | (define-obsolete-function-alias 'pascal-complete-word |
| 1299 | (if pascal-toggle-completions | 1297 | 'completion-at-point "24.1") |
| 1300 | (let* ((pascal-str (buffer-substring b e)) | 1298 | |
| 1301 | (allcomp (if (and pascal-toggle-completions | 1299 | (define-obsolete-function-alias 'pascal-show-completions |
| 1302 | (string= pascal-last-word-shown pascal-str)) | 1300 | 'completion-help-at-point "24.1") |
| 1303 | pascal-last-completions | ||
| 1304 | (all-completions pascal-str 'pascal-completion)))) | ||
| 1305 | ;; Update entry number in list | ||
| 1306 | (setq pascal-last-completions allcomp | ||
| 1307 | pascal-last-word-numb | ||
| 1308 | (if (>= pascal-last-word-numb (1- (length allcomp))) | ||
| 1309 | 0 | ||
| 1310 | (1+ pascal-last-word-numb))) | ||
| 1311 | (setq pascal-last-word-shown (elt allcomp pascal-last-word-numb)) | ||
| 1312 | ;; Display next match or same string if no match was found | ||
| 1313 | (if allcomp | ||
| 1314 | (progn | ||
| 1315 | (goto-char e) | ||
| 1316 | (insert-before-markers pascal-last-word-shown) | ||
| 1317 | (delete-region b e)) | ||
| 1318 | (message "(No match)"))) | ||
| 1319 | ;; The other form of completion does not necessarily do that. | ||
| 1320 | (completion-in-region b e 'pascal-completion)))) | ||
| 1321 | |||
| 1322 | (defun pascal-show-completions () | ||
| 1323 | "Show all possible completions at current point." | ||
| 1324 | (interactive) | ||
| 1325 | (let* ((b (save-excursion (skip-chars-backward "a-zA-Z0-9_") (point))) | ||
| 1326 | (e (save-excursion (skip-chars-forward "a-zA-Z0-9_") (point))) | ||
| 1327 | (pascal-str (buffer-substring b e)) | ||
| 1328 | (allcomp (if (and pascal-toggle-completions | ||
| 1329 | (string= pascal-last-word-shown pascal-str)) | ||
| 1330 | pascal-last-completions | ||
| 1331 | (all-completions pascal-str 'pascal-completion)))) | ||
| 1332 | ;; Show possible completions in a temporary buffer. | ||
| 1333 | (with-output-to-temp-buffer "*Completions*" | ||
| 1334 | (display-completion-list allcomp pascal-str)) | ||
| 1335 | ;; Wait for a keypress. Then delete *Completion* window | ||
| 1336 | (momentary-string-display "" (point)) | ||
| 1337 | (delete-window (get-buffer-window (get-buffer "*Completions*"))))) | ||
| 1338 | 1301 | ||
| 1339 | 1302 | ||
| 1340 | (defun pascal-get-default-symbol () | 1303 | (defun pascal-get-default-symbol () |