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 | |
| 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.
| -rw-r--r-- | lisp/ChangeLog | 62 | ||||
| -rw-r--r-- | lisp/cus-edit.el | 5 | ||||
| -rw-r--r-- | lisp/international/mule-cmds.el | 30 | ||||
| -rw-r--r-- | lisp/mail/mailabbrev.el | 1 | ||||
| -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 | ||||
| -rw-r--r-- | lisp/wid-edit.el | 103 |
10 files changed, 186 insertions, 217 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a7176483152..957c751750b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,41 @@ | |||
| 1 | 2011-06-20 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * wid-edit.el: Use lexical scoping and move towards completion-at-point. | ||
| 4 | (widget-complete): Use new :completion-function property. | ||
| 5 | (widget-completions-at-point): New function. | ||
| 6 | (default): Use :completion-function instead of :complete. | ||
| 7 | (widget-default-completions): Rename from widget-default-complete, rewrite. | ||
| 8 | (widget-string-complete, widget-file-complete, widget-color-complete): | ||
| 9 | Remove functions. | ||
| 10 | (file, symbol, function, variable, coding-system, color): | ||
| 11 | * international/mule-cmds.el (default-input-method, charset) | ||
| 12 | (language-info-custom-alist): | ||
| 13 | * cus-edit.el (face): Use new property :completions. | ||
| 14 | |||
| 15 | * progmodes/pascal.el (pascal-completions-at-point): New function. | ||
| 16 | (pascal-mode): Use it. | ||
| 17 | (pascal-mode-map): Use completion-at-point. | ||
| 18 | (pascal-toggle-completions): Make obsolete. | ||
| 19 | (pascal-complete-word, pascal-show-completions): | ||
| 20 | * progmodes/octave-mod.el (octave-complete-symbol): | ||
| 21 | Redefine as obsolete alias. | ||
| 22 | * progmodes/octave-inf.el (inferior-octave-completion-at-point): | ||
| 23 | Signal absence of completion info for old Octave, | ||
| 24 | (inferior-octave-complete): Redefine as obsolete alias. | ||
| 25 | * progmodes/meta-mode.el: Use lexical-binding and completion-at-point. | ||
| 26 | (meta-completions-at-point): Rename from meta-complete-symbol and | ||
| 27 | adapt it for use on completion-at-point-functions. | ||
| 28 | (meta-common-mode): Use it. | ||
| 29 | (meta-looking-at-backward, meta-match-buffer): Remove. | ||
| 30 | (meta-complete-symbol): Redefine as obsolete alias. | ||
| 31 | (meta-common-mode-map): Use completion-at-point. | ||
| 32 | * progmodes/make-mode.el: Use lexical-binding and completion-at-point. | ||
| 33 | (makefile-mode-map): Use completion-at-point. | ||
| 34 | (makefile-completions-at-point): Rename from makefile-complete and | ||
| 35 | adapt it for use on completion-at-point-functions. | ||
| 36 | (makefile-mode): Use it. | ||
| 37 | (makefile-complete): Redefine as obsolete alias. | ||
| 38 | |||
| 1 | 2011-06-20 Deniz Dogan <deniz@dogan.se> | 39 | 2011-06-20 Deniz Dogan <deniz@dogan.se> |
| 2 | 40 | ||
| 3 | * net/rcirc.el: Delete trailing whitespaces once and for all. | 41 | * net/rcirc.el: Delete trailing whitespaces once and for all. |
| @@ -31,8 +69,8 @@ | |||
| 31 | display-buffer-normalize-options. | 69 | display-buffer-normalize-options. |
| 32 | (display-buffer-normalize-alist-1): New function. | 70 | (display-buffer-normalize-alist-1): New function. |
| 33 | (display-buffer-normalize-specifiers-3): Rename to | 71 | (display-buffer-normalize-specifiers-3): Rename to |
| 34 | display-buffer-normalize-alist. Call | 72 | display-buffer-normalize-alist. |
| 35 | display-buffer-normalize-alist-1. | 73 | Call display-buffer-normalize-alist-1. |
| 36 | (display-buffer-normalize-options-inhibit): New variable. | 74 | (display-buffer-normalize-options-inhibit): New variable. |
| 37 | (display-buffer-normalize-specifiers): Rewrite calling | 75 | (display-buffer-normalize-specifiers): Rewrite calling |
| 38 | display-buffer-normalize-alist, | 76 | display-buffer-normalize-alist, |
| @@ -43,8 +81,8 @@ | |||
| 43 | (window-deletable-p): Use frame-auto-delete. | 81 | (window-deletable-p): Use frame-auto-delete. |
| 44 | (window-list-no-nils, window-state-ignored-parameters) | 82 | (window-list-no-nils, window-state-ignored-parameters) |
| 45 | (window-state-get-1, window-state-get, window-state-put-list) | 83 | (window-state-get-1, window-state-get, window-state-put-list) |
| 46 | (window-state-put-1, window-state-put-2, window-state-put): New | 84 | (window-state-put-1, window-state-put-2, window-state-put): |
| 47 | functions. | 85 | New functions. |
| 48 | (display-buffer-normalize-options): Move special-display-p group | 86 | (display-buffer-normalize-options): Move special-display-p group |
| 49 | after pop-up-frame group (Bug#8851) and (Bug#8856). | 87 | after pop-up-frame group (Bug#8851) and (Bug#8856). |
| 50 | 88 | ||
| @@ -71,12 +109,12 @@ | |||
| 71 | 109 | ||
| 72 | 2011-06-18 Martin Rudalics <rudalics@gmx.at> | 110 | 2011-06-18 Martin Rudalics <rudalics@gmx.at> |
| 73 | 111 | ||
| 74 | * window.el (display-buffer-default-specifiers): Remove | 112 | * window.el (display-buffer-default-specifiers): |
| 75 | pop-up-frame. Add pop-up-window-min-height, | 113 | Remove pop-up-frame. Add pop-up-window-min-height, |
| 76 | pop-up-window-min-width, and another reuse-window specifier | 114 | pop-up-window-min-width, and another reuse-window specifier |
| 77 | (Bug#8882). Reported by Dan Nicolaescu <dann@gnu.org>. | 115 | (Bug#8882). Reported by Dan Nicolaescu <dann@gnu.org>. |
| 78 | (display-buffer-normalize-specifiers-2): Handle | 116 | (display-buffer-normalize-specifiers-2): |
| 79 | split-height-threshold and split-width-threshold also when | 117 | Handle split-height-threshold and split-width-threshold also when |
| 80 | pop-up-windows is unset. Add a reuse-window specifier for the | 118 | pop-up-windows is unset. Add a reuse-window specifier for the |
| 81 | case popping up a new window fails. | 119 | case popping up a new window fails. |
| 82 | (special-display-popup-frame): Remove double quoting. | 120 | (special-display-popup-frame): Remove double quoting. |
| @@ -112,8 +150,8 @@ | |||
| 112 | (display-buffer-normalize-specifiers-2): Treat other-window case | 150 | (display-buffer-normalize-specifiers-2): Treat other-window case |
| 113 | specially. | 151 | specially. |
| 114 | (display-buffer-normalize-specifiers-3): New function. | 152 | (display-buffer-normalize-specifiers-3): New function. |
| 115 | (display-buffer-normalize-specifiers): Call | 153 | (display-buffer-normalize-specifiers): |
| 116 | display-buffer-normalize-specifiers-3. | 154 | Call display-buffer-normalize-specifiers-3. |
| 117 | 155 | ||
| 118 | 2011-06-17 Martin Rudalics <rudalics@gmx.at> | 156 | 2011-06-17 Martin Rudalics <rudalics@gmx.at> |
| 119 | 157 | ||
| @@ -133,8 +171,8 @@ | |||
| 133 | 171 | ||
| 134 | 2011-06-16 Martin Rudalics <rudalics@gmx.at> | 172 | 2011-06-16 Martin Rudalics <rudalics@gmx.at> |
| 135 | 173 | ||
| 136 | * window.el (display-buffer-normalize-specifiers-1): Respect | 174 | * window.el (display-buffer-normalize-specifiers-1): |
| 137 | current value of pop-up-frames for most reasonable values of | 175 | Respect current value of pop-up-frames for most reasonable values of |
| 138 | second argument of display-buffer (Bug#8865). | 176 | second argument of display-buffer (Bug#8865). |
| 139 | (switch-to-buffer-same-frame, switch-to-buffer-other-window) | 177 | (switch-to-buffer-same-frame, switch-to-buffer-other-window) |
| 140 | (switch-to-buffer-other-window-same-frame) | 178 | (switch-to-buffer-other-window-same-frame) |
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index f14c055d7a8..7c96b526f41 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el | |||
| @@ -3830,9 +3830,8 @@ restoring it to the state of a face that has never been customized." | |||
| 3830 | :sample-face-get 'widget-face-sample-face-get | 3830 | :sample-face-get 'widget-face-sample-face-get |
| 3831 | :notify 'widget-face-notify | 3831 | :notify 'widget-face-notify |
| 3832 | :match (lambda (_widget value) (facep value)) | 3832 | :match (lambda (_widget value) (facep value)) |
| 3833 | :complete-function (lambda () | 3833 | :completions (apply-partially #'completion-table-with-predicate |
| 3834 | (interactive) | 3834 | obarray #'facep 'strict) |
| 3835 | (lisp-complete-symbol 'facep)) | ||
| 3836 | :prompt-match 'facep | 3835 | :prompt-match 'facep |
| 3837 | :prompt-history 'widget-face-prompt-value-history | 3836 | :prompt-history 'widget-face-prompt-value-history |
| 3838 | :validate (lambda (widget) | 3837 | :validate (lambda (widget) |
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index 5f4d3ea849e..b3f17bb3fcf 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el | |||
| @@ -1308,11 +1308,11 @@ This is the input method activated automatically by the command | |||
| 1308 | `toggle-input-method' (\\[toggle-input-method])." | 1308 | `toggle-input-method' (\\[toggle-input-method])." |
| 1309 | :link '(custom-manual "(emacs)Input Methods") | 1309 | :link '(custom-manual "(emacs)Input Methods") |
| 1310 | :group 'mule | 1310 | :group 'mule |
| 1311 | :type '(choice (const nil) (string | 1311 | :type '(choice (const nil) |
| 1312 | :completion-ignore-case t | 1312 | (string |
| 1313 | :complete-function widget-string-complete | 1313 | :completions (apply-partially |
| 1314 | :completion-alist input-method-alist | 1314 | #'completion-table-case-fold input-method-alist) |
| 1315 | :prompt-history input-method-history)) | 1315 | :prompt-history input-method-history)) |
| 1316 | :set-after '(current-language-environment)) | 1316 | :set-after '(current-language-environment)) |
| 1317 | 1317 | ||
| 1318 | (put 'input-method-function 'permanent-local t) | 1318 | (put 'input-method-function 'permanent-local t) |
| @@ -1875,10 +1875,10 @@ specifies the character set for the major languages of Western Europe." | |||
| 1875 | (define-widget 'charset 'symbol | 1875 | (define-widget 'charset 'symbol |
| 1876 | "An Emacs charset." | 1876 | "An Emacs charset." |
| 1877 | :tag "Charset" | 1877 | :tag "Charset" |
| 1878 | :complete-function (lambda () | 1878 | :completions (apply-partially #'completion-table-with-predicate |
| 1879 | (interactive) | 1879 | (apply-partially #'completion-table-case-fold |
| 1880 | (lisp-complete-symbol 'charsetp)) | 1880 | obarray) |
| 1881 | :completion-ignore-case t | 1881 | #'charsetp 'strict) |
| 1882 | :value 'ascii | 1882 | :value 'ascii |
| 1883 | :validate (lambda (widget) | 1883 | :validate (lambda (widget) |
| 1884 | (unless (charsetp (widget-value widget)) | 1884 | (unless (charsetp (widget-value widget)) |
| @@ -1912,9 +1912,9 @@ See `set-language-info-alist' for use in programs." | |||
| 1912 | (set-language-environment current-language-environment))) | 1912 | (set-language-environment current-language-environment))) |
| 1913 | :type `(alist | 1913 | :type `(alist |
| 1914 | :key-type (string :tag "Language environment" | 1914 | :key-type (string :tag "Language environment" |
| 1915 | :completion-ignore-case t | 1915 | :completions |
| 1916 | :complete-function widget-string-complete | 1916 | (apply-partially #'completion-table-case-fold |
| 1917 | :completion-alist language-info-alist) | 1917 | language-info-alist)) |
| 1918 | :value-type | 1918 | :value-type |
| 1919 | (alist :key-type symbol | 1919 | (alist :key-type symbol |
| 1920 | :options ((documentation string) | 1920 | :options ((documentation string) |
| @@ -1927,9 +1927,9 @@ See `set-language-info-alist' for use in programs." | |||
| 1927 | (nonascii-translation charset) | 1927 | (nonascii-translation charset) |
| 1928 | (input-method | 1928 | (input-method |
| 1929 | (string | 1929 | (string |
| 1930 | :completion-ignore-case t | 1930 | :completions |
| 1931 | :complete-function widget-string-complete | 1931 | (apply-partially #'completion-table-case-fold |
| 1932 | :completion-alist input-method-alist | 1932 | input-method-alist) |
| 1933 | :prompt-history input-method-history)) | 1933 | :prompt-history input-method-history)) |
| 1934 | (features (repeat symbol)) | 1934 | (features (repeat symbol)) |
| 1935 | (unibyte-display coding-system))))) | 1935 | (unibyte-display coding-system))))) |
diff --git a/lisp/mail/mailabbrev.el b/lisp/mail/mailabbrev.el index b4827cf10ba..901eb002dc1 100644 --- a/lisp/mail/mailabbrev.el +++ b/lisp/mail/mailabbrev.el | |||
| @@ -565,7 +565,6 @@ of a mail alias. The value is set up, buffer-local, when first needed.") | |||
| 565 | 565 | ||
| 566 | (defun mail-abbrev-complete-alias () | 566 | (defun mail-abbrev-complete-alias () |
| 567 | "Perform completion on alias preceding point." | 567 | "Perform completion on alias preceding point." |
| 568 | ;; Based on lisp.el:lisp-complete-symbol | ||
| 569 | (interactive) | 568 | (interactive) |
| 570 | (mail-abbrev-make-syntax-table) | 569 | (mail-abbrev-make-syntax-table) |
| 571 | (let ((end (point)) | 570 | (let ((end (point)) |
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 () |
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index 7b7813db94b..b0d00242f2a 100644 --- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; wid-edit.el --- Functions for creating and using widgets -*-byte-compile-dynamic: t;-*- | 1 | ;;; wid-edit.el --- Functions for creating and using widgets -*-byte-compile-dynamic: t; lexical-binding:t -*- |
| 2 | ;; | 2 | ;; |
| 3 | ;; Copyright (C) 1996-1997, 1999-2011 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1996-1997, 1999-2011 Free Software Foundation, Inc. |
| 4 | ;; | 4 | ;; |
| @@ -1161,10 +1161,29 @@ the field." | |||
| 1161 | "Complete content of editable field from point. | 1161 | "Complete content of editable field from point. |
| 1162 | When not inside a field, signal an error." | 1162 | When not inside a field, signal an error." |
| 1163 | (interactive) | 1163 | (interactive) |
| 1164 | (let ((data (widget-completions-at-point))) | ||
| 1165 | (cond | ||
| 1166 | ((functionp data) (funcall data)) | ||
| 1167 | ((consp data) | ||
| 1168 | (let ((completion-extra-properties (nth 3 data))) | ||
| 1169 | (completion-in-region (nth 0 data) (nth 1 data) (nth 2 data) | ||
| 1170 | (plist-get completion-extra-properties | ||
| 1171 | :predicate)))) | ||
| 1172 | ((widget-field-find (point)) | ||
| 1173 | ;; This defaulting used to be performed in widget-default-complete, but | ||
| 1174 | ;; it seems more appropriate here than in widget-default-completions. | ||
| 1175 | (call-interactively 'widget-complete-field)) | ||
| 1176 | (t | ||
| 1177 | (error "Not in an editable field"))))) | ||
| 1178 | ;; We may want to use widget completion in buffers where the major mode | ||
| 1179 | ;; hasn't added widget-completions-at-point to completion-at-point-functions, | ||
| 1180 | ;; so it's not really obsolete (yet). | ||
| 1181 | ;; (make-obsolete 'widget-complete 'completion-at-point "24.1") | ||
| 1182 | |||
| 1183 | (defun widget-completions-at-point () | ||
| 1164 | (let ((field (widget-field-find (point)))) | 1184 | (let ((field (widget-field-find (point)))) |
| 1165 | (if field | 1185 | (when field |
| 1166 | (widget-apply field :complete) | 1186 | (widget-apply field :completions-function)))) |
| 1167 | (error "Not in an editable field")))) | ||
| 1168 | 1187 | ||
| 1169 | ;;; Setting up the buffer. | 1188 | ;;; Setting up the buffer. |
| 1170 | 1189 | ||
| @@ -1435,7 +1454,7 @@ The value of the :type attribute should be an unconverted widget type." | |||
| 1435 | :value-to-external (lambda (_widget value) value) | 1454 | :value-to-external (lambda (_widget value) value) |
| 1436 | :button-prefix 'widget-button-prefix | 1455 | :button-prefix 'widget-button-prefix |
| 1437 | :button-suffix 'widget-button-suffix | 1456 | :button-suffix 'widget-button-suffix |
| 1438 | :complete 'widget-default-complete | 1457 | :completions-function #'widget-default-completions |
| 1439 | :create 'widget-default-create | 1458 | :create 'widget-default-create |
| 1440 | :indent nil | 1459 | :indent nil |
| 1441 | :offset 0 | 1460 | :offset 0 |
| @@ -1461,13 +1480,20 @@ The value of the :type attribute should be an unconverted widget type." | |||
| 1461 | 1480 | ||
| 1462 | (defvar widget--completing-widget) | 1481 | (defvar widget--completing-widget) |
| 1463 | 1482 | ||
| 1464 | (defun widget-default-complete (widget) | 1483 | (defun widget-default-completions (widget) |
| 1465 | "Call the value of the :complete-function property of WIDGET. | 1484 | "Return completion data, like `completion-at-point-functions' would." |
| 1466 | If that does not exist, call the value of `widget-complete-field'. | 1485 | (let ((completions (widget-get widget :completions))) |
| 1467 | During this call, `widget--completing-widget' is bound to WIDGET." | 1486 | (if completions |
| 1468 | (let ((widget--completing-widget widget)) | 1487 | (list (widget-field-start widget) |
| 1469 | (call-interactively (or (widget-get widget :complete-function) | 1488 | (max (point) (widget-field-text-end widget)) |
| 1470 | widget-complete-field)))) | 1489 | completions) |
| 1490 | (if (widget-get widget :complete) | ||
| 1491 | (lambda () (widget-apply widget :complete)) | ||
| 1492 | (if (widget-get widget :complete-function) | ||
| 1493 | (lambda () | ||
| 1494 | (let ((widget--completing-widget widget)) | ||
| 1495 | (call-interactively | ||
| 1496 | (widget-get widget :complete-function))))))))) | ||
| 1471 | 1497 | ||
| 1472 | (defun widget-default-create (widget) | 1498 | (defun widget-default-create (widget) |
| 1473 | "Create WIDGET at point in the current buffer." | 1499 | "Create WIDGET at point in the current buffer." |
| @@ -3018,20 +3044,6 @@ as the value." | |||
| 3018 | :complete-function 'ispell-complete-word | 3044 | :complete-function 'ispell-complete-word |
| 3019 | :prompt-history 'widget-string-prompt-value-history) | 3045 | :prompt-history 'widget-string-prompt-value-history) |
| 3020 | 3046 | ||
| 3021 | (defun widget-string-complete () | ||
| 3022 | "Complete contents of string field. | ||
| 3023 | Completions are taken from the :completion-alist property of the | ||
| 3024 | widget. If that isn't a list, it's evalled and expected to yield a list." | ||
| 3025 | (interactive) | ||
| 3026 | (let* ((widget widget--completing-widget) | ||
| 3027 | (completion-ignore-case (widget-get widget :completion-ignore-case)) | ||
| 3028 | (alist (widget-get widget :completion-alist)) | ||
| 3029 | (_ (unless (listp alist) | ||
| 3030 | (setq alist (eval alist))))) | ||
| 3031 | (completion-in-region (widget-field-start widget) | ||
| 3032 | (max (point) (widget-field-text-end widget)) | ||
| 3033 | alist))) | ||
| 3034 | |||
| 3035 | (define-widget 'regexp 'string | 3047 | (define-widget 'regexp 'string |
| 3036 | "A regular expression." | 3048 | "A regular expression." |
| 3037 | :match 'widget-regexp-match | 3049 | :match 'widget-regexp-match |
| @@ -3059,21 +3071,13 @@ widget. If that isn't a list, it's evalled and expected to yield a list." | |||
| 3059 | (define-widget 'file 'string | 3071 | (define-widget 'file 'string |
| 3060 | "A file widget. | 3072 | "A file widget. |
| 3061 | It reads a file name from an editable text field." | 3073 | It reads a file name from an editable text field." |
| 3062 | :complete-function 'widget-file-complete | 3074 | :completions #'completion-file-name-table |
| 3063 | :prompt-value 'widget-file-prompt-value | 3075 | :prompt-value 'widget-file-prompt-value |
| 3064 | :format "%{%t%}: %v" | 3076 | :format "%{%t%}: %v" |
| 3065 | ;; Doesn't work well with terminating newline. | 3077 | ;; Doesn't work well with terminating newline. |
| 3066 | ;; :value-face 'widget-single-line-field | 3078 | ;; :value-face 'widget-single-line-field |
| 3067 | :tag "File") | 3079 | :tag "File") |
| 3068 | 3080 | ||
| 3069 | (defun widget-file-complete () | ||
| 3070 | "Perform completion on file name preceding point." | ||
| 3071 | (interactive) | ||
| 3072 | (let ((widget widget--completing-widget)) | ||
| 3073 | (completion-in-region (widget-field-start widget) | ||
| 3074 | (max (point) (widget-field-text-end widget)) | ||
| 3075 | 'completion-file-name-table))) | ||
| 3076 | |||
| 3077 | (defun widget-file-prompt-value (widget prompt value unbound) | 3081 | (defun widget-file-prompt-value (widget prompt value unbound) |
| 3078 | ;; Read file from minibuffer. | 3082 | ;; Read file from minibuffer. |
| 3079 | (abbreviate-file-name | 3083 | (abbreviate-file-name |
| @@ -3113,7 +3117,7 @@ It reads a directory name from an editable text field." | |||
| 3113 | :tag "Symbol" | 3117 | :tag "Symbol" |
| 3114 | :format "%{%t%}: %v" | 3118 | :format "%{%t%}: %v" |
| 3115 | :match (lambda (_widget value) (symbolp value)) | 3119 | :match (lambda (_widget value) (symbolp value)) |
| 3116 | :complete-function 'lisp-complete-symbol | 3120 | :completions obarray |
| 3117 | :prompt-internal 'widget-symbol-prompt-internal | 3121 | :prompt-internal 'widget-symbol-prompt-internal |
| 3118 | :prompt-match 'symbolp | 3122 | :prompt-match 'symbolp |
| 3119 | :prompt-history 'widget-symbol-prompt-value-history | 3123 | :prompt-history 'widget-symbol-prompt-value-history |
| @@ -3141,9 +3145,8 @@ It reads a directory name from an editable text field." | |||
| 3141 | 3145 | ||
| 3142 | (define-widget 'function 'restricted-sexp | 3146 | (define-widget 'function 'restricted-sexp |
| 3143 | "A Lisp function." | 3147 | "A Lisp function." |
| 3144 | :complete-function (lambda () | 3148 | :completions (apply-partially #'completion-table-with-predicate |
| 3145 | (interactive) | 3149 | obarray #'fboundp 'strict) |
| 3146 | (lisp-complete-symbol 'fboundp)) | ||
| 3147 | :prompt-value 'widget-field-prompt-value | 3150 | :prompt-value 'widget-field-prompt-value |
| 3148 | :prompt-internal 'widget-symbol-prompt-internal | 3151 | :prompt-internal 'widget-symbol-prompt-internal |
| 3149 | :prompt-match 'fboundp | 3152 | :prompt-match 'fboundp |
| @@ -3165,9 +3168,8 @@ It reads a directory name from an editable text field." | |||
| 3165 | "A Lisp variable." | 3168 | "A Lisp variable." |
| 3166 | :prompt-match 'boundp | 3169 | :prompt-match 'boundp |
| 3167 | :prompt-history 'widget-variable-prompt-value-history | 3170 | :prompt-history 'widget-variable-prompt-value-history |
| 3168 | :complete-function (lambda () | 3171 | :completions (apply-partially #'completion-table-with-predicate |
| 3169 | (interactive) | 3172 | obarray #'boundp 'strict) |
| 3170 | (lisp-complete-symbol 'boundp)) | ||
| 3171 | :tag "Variable") | 3173 | :tag "Variable") |
| 3172 | 3174 | ||
| 3173 | (define-widget 'coding-system 'symbol | 3175 | (define-widget 'coding-system 'symbol |
| @@ -3178,9 +3180,8 @@ It reads a directory name from an editable text field." | |||
| 3178 | :prompt-history 'coding-system-value-history | 3180 | :prompt-history 'coding-system-value-history |
| 3179 | :prompt-value 'widget-coding-system-prompt-value | 3181 | :prompt-value 'widget-coding-system-prompt-value |
| 3180 | :action 'widget-coding-system-action | 3182 | :action 'widget-coding-system-action |
| 3181 | :complete-function (lambda () | 3183 | :completions (apply-partially #'completion-table-with-predicate |
| 3182 | (interactive) | 3184 | obarray #'coding-system-p 'strict) |
| 3183 | (lisp-complete-symbol 'coding-system-p)) | ||
| 3184 | :validate (lambda (widget) | 3185 | :validate (lambda (widget) |
| 3185 | (unless (coding-system-p (widget-value widget)) | 3186 | (unless (coding-system-p (widget-value widget)) |
| 3186 | (widget-put widget :error (format "Invalid coding system: %S" | 3187 | (widget-put widget :error (format "Invalid coding system: %S" |
| @@ -3317,7 +3318,7 @@ It reads a directory name from an editable text field." | |||
| 3317 | (insert (widget-apply widget :value-get)) | 3318 | (insert (widget-apply widget :value-get)) |
| 3318 | (goto-char (point-min)) | 3319 | (goto-char (point-min)) |
| 3319 | (let (err) | 3320 | (let (err) |
| 3320 | (condition-case data | 3321 | (condition-case data ;Note: We get a spurious byte-compile warning here. |
| 3321 | (progn | 3322 | (progn |
| 3322 | ;; Avoid a confusing end-of-file error. | 3323 | ;; Avoid a confusing end-of-file error. |
| 3323 | (skip-syntax-forward "\\s-") | 3324 | (skip-syntax-forward "\\s-") |
| @@ -3685,7 +3686,7 @@ example: | |||
| 3685 | :size 10 | 3686 | :size 10 |
| 3686 | :tag "Color" | 3687 | :tag "Color" |
| 3687 | :value "black" | 3688 | :value "black" |
| 3688 | :complete 'widget-color-complete | 3689 | :completions (or facemenu-color-alist (defined-colors)) |
| 3689 | :sample-face-get 'widget-color-sample-face-get | 3690 | :sample-face-get 'widget-color-sample-face-get |
| 3690 | :notify 'widget-color-notify | 3691 | :notify 'widget-color-notify |
| 3691 | :action 'widget-color-action) | 3692 | :action 'widget-color-action) |
| @@ -3711,14 +3712,6 @@ example: | |||
| 3711 | (delete-window win))) | 3712 | (delete-window win))) |
| 3712 | (pop-to-buffer ,(current-buffer)))))) | 3713 | (pop-to-buffer ,(current-buffer)))))) |
| 3713 | 3714 | ||
| 3714 | (defun widget-color-complete (widget) | ||
| 3715 | "Complete the color in WIDGET." | ||
| 3716 | (require 'facemenu) ; for facemenu-color-alist | ||
| 3717 | (completion-in-region (widget-field-start widget) | ||
| 3718 | (max (point) (widget-field-text-end widget)) | ||
| 3719 | (or facemenu-color-alist | ||
| 3720 | (sort (defined-colors) 'string-lessp)))) | ||
| 3721 | |||
| 3722 | (defun widget-color-sample-face-get (widget) | 3715 | (defun widget-color-sample-face-get (widget) |
| 3723 | (let* ((value (condition-case nil | 3716 | (let* ((value (condition-case nil |
| 3724 | (widget-value widget) | 3717 | (widget-value widget) |