summaryrefslogtreecommitdiff
path: root/lisp/progmodes/meta-mode.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2011-06-20 12:02:31 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2011-06-20 12:02:31 -0400
commitbcd70d976f1035f84f55fa6969b9c0c419b7cc06 (patch)
tree50dc843ae8030ef911c788a795f3b14d689045a7 /lisp/progmodes/meta-mode.el
parentaebf69c8b3dc592ea315c187feb5f69b884a850e (diff)
downloademacs-bcd70d976f1035f84f55fa6969b9c0c419b7cc06.tar.gz
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/meta-mode.el')
-rw-r--r--lisp/progmodes/meta-mode.el52
1 files changed, 19 insertions, 33 deletions
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 @@
-;;; meta-mode.el --- major mode for editing Metafont or MetaPost sources
+;;; meta-mode.el --- major mode for editing Metafont or MetaPost sources -*- lexical-binding:t -*-
;; Copyright (C) 1997, 2001-2011 Free Software Foundation, Inc.
@@ -471,16 +471,13 @@ If the list was changed, sort the list and remove duplicates first."
(string-lessp (car a) (car b)))
-(defun meta-complete-symbol ()
- "Perform completion on Metafont or MetaPost symbol preceding point."
- ;; FIXME: Use completion-at-point-functions.
- (interactive "*")
+(defun meta-completions-at-point ()
(let ((list meta-complete-list)
entry)
(while list
(setq entry (car list)
list (cdr list))
- (if (meta-looking-at-backward (car entry) 200)
+ (if (looking-back (car entry) (max (point-min) (- (point) 200)))
(setq list nil)))
(if (numberp (nth 1 entry))
(let* ((sub (nth 1 entry))
@@ -488,31 +485,19 @@ If the list was changed, sort the list and remove duplicates first."
(begin (match-beginning sub))
(end (match-end sub))
(list (funcall (nth 2 entry))))
- (completion-in-region
- begin end
- (if (zerop (length close)) list
- (apply-partially 'completion-table-with-terminator
- close list))))
- (funcall (nth 1 entry)))))
-
-
-(defun meta-looking-at-backward (regexp &optional limit)
- ;; utility function used in `meta-complete-symbol'
- (let ((pos (point)))
- (save-excursion
- (and (re-search-backward
- regexp (if limit (max (point-min) (- (point) limit))) t)
- (eq (match-end 0) pos)))))
-
-(defun meta-match-buffer (n)
- ;; utility function used in `meta-complete-symbol'
- (if (match-beginning n)
- (let ((str (buffer-substring (match-beginning n) (match-end n))))
- (set-text-properties 0 (length str) nil str)
- (copy-sequence str))
- ""))
-
-
+ (list
+ begin end list
+ :exit-function
+ (unless (zerop (length close))
+ (lambda (_s finished)
+ (when (memq finished '(sole finished))
+ (if (looking-at (regexp-quote close))
+ (goto-char (match-end 0))
+ (insert close)))))))
+ (nth 1 entry))))
+
+(define-obsolete-function-alias 'meta-complete-symbol
+ 'completion-at-point "24.1")
;;; Indentation.
@@ -906,7 +891,7 @@ The environment marked is the one that contains point or follows point."
(define-key map "\C-c;" 'meta-comment-region)
(define-key map "\C-c:" 'meta-uncomment-region)
;; Symbol Completion:
- (define-key map "\M-\t" 'meta-complete-symbol)
+ (define-key map "\M-\t" 'completion-at-point)
;; Shell Commands:
;; (define-key map "\C-c\C-c" 'meta-command-file)
;; (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."
["Uncomment Region" meta-uncomment-region
:active (meta-mark-active)]
"--"
- ["Complete Symbol" meta-complete-symbol t]
+ ["Complete Symbol" completion-at-point t]
; "--"
; ["Command on Buffer" meta-command-file t]
; ["Kill Job" meta-kill-job t]
@@ -994,6 +979,7 @@ The environment marked is the one that contains point or follows point."
(set (make-local-variable 'parse-sexp-ignore-comments) t)
+ (add-hook 'completion-at-point-functions #'meta-completions-at-point nil t)
(set (make-local-variable 'comment-indent-function) #'meta-comment-indent)
(set (make-local-variable 'indent-line-function) #'meta-indent-line)
;; No need to define a mode-specific 'indent-region-function.