]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/meta-mode.el
Close bug#3992.
[gnu-emacs] / lisp / progmodes / meta-mode.el
index c70f5cdb6a1abe163922eb669b4cbfcd0945d4f7..70b38dc399991dd60f6287a8573c293cc23a3552 100644 (file)
@@ -1,6 +1,6 @@
 ;;; meta-mode.el --- major mode for editing Metafont or MetaPost sources
 
-;; Copyright (C) 1997, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+;; Copyright (C) 1997, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;; Free Software Foundation, Inc.
 
 ;; Author: Ulrik Vieth <vieth@thphy.uni-duesseldorf.de>
@@ -9,10 +9,10 @@
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,9 +20,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -489,29 +487,12 @@ If the list was changed, sort the list and remove duplicates first."
                (close (nth 3 entry))
                (begin (match-beginning sub))
                (end (match-end sub))
-               (pattern (meta-match-buffer 0))
-               (symbol (buffer-substring begin end))
-               (list (funcall (nth 2 entry)))
-               (completion (try-completion symbol list)))
-          (cond ((eq completion t)
-                 (and close
-                      (not (looking-at (regexp-quote close)))
-                      (insert close)))
-                ((null completion)
-                 (error "Can't find completion for \"%s\"" pattern))
-                ((not (string-equal symbol completion))
-                 (delete-region begin end)
-                 (insert completion)
-                 (and close
-                      (eq (try-completion completion list) t)
-                      (not (looking-at (regexp-quote close)))
-                      (insert close)))
-                (t
-                 (message "Making completion list...")
-                 (let ((list (all-completions symbol list nil)))
-                   (with-output-to-temp-buffer "*Completions*"
-                     (display-completion-list list symbol)))
-                 (message "Making completion list... done"))))
+               (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)))))