(octave-complete-symbol): Use completion-in-region.
authorStefan Monnier <monnier@iro.umontreal.ca>
Thu, 3 Dec 2009 02:58:16 +0000 (02:58 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Thu, 3 Dec 2009 02:58:16 +0000 (02:58 +0000)
lisp/ChangeLog
lisp/progmodes/octave-mod.el

index 8cc536e..f0b2de4 100644 (file)
@@ -1,5 +1,8 @@
 2009-12-03  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+       * progmodes/octave-mod.el (octave-complete-symbol):
+       Use completion-in-region.
+
        Misc cleanup.
        * progmodes/idlwave.el (idlwave-comment-hook): Simplify with `or'.
        (idlwave-code-abbrev, idlwave-display-user-catalog-widget)
index 0671dbe..ab3c778 100644 (file)
@@ -1237,45 +1237,10 @@ otherwise."
   "Perform completion on Octave symbol preceding point.
 Compare that symbol against Octave's reserved words and builtin
 variables."
-  ;; This code taken from lisp-complete-symbol
   (interactive)
   (let* ((end (point))
-        (beg (save-excursion (backward-sexp 1) (point)))
-        (string (buffer-substring-no-properties beg end))
-        (completion (try-completion string octave-completion-alist)))
-    (cond ((eq completion t))          ; ???
-         ((null completion)
-          (message "Can't find completion for \"%s\"" string)
-          (ding))
-         ((not (string= string completion))
-           (delete-region beg end)
-           (insert completion))
-         (t
-          (let ((list (all-completions string octave-completion-alist))
-                (conf (current-window-configuration)))
-            ;; Taken from comint.el
-            (message "Making completion list...")
-            (with-output-to-temp-buffer "*Completions*"
-              (display-completion-list list string))
-            (message "Hit space to flush")
-            (let (key first)
-              (if (with-current-buffer (get-buffer "*Completions*")
-                    (setq key (read-key-sequence nil)
-                          first (aref key 0))
-                    (and (consp first) (consp (event-start first))
-                         (eq (window-buffer (posn-window (event-start
-                                                          first)))
-                             (get-buffer "*Completions*"))
-                         (eq (key-binding key) 'mouse-choose-completion)))
-                  (progn
-                    (if (fboundp 'mouse-choose-completion)
-                        (mouse-choose-completion first)
-                      (choose-completion first)) ; Emacs >= 23.2
-                    (set-window-configuration conf))
-                (if (eq first ?\ )
-                    (set-window-configuration conf)
-                  (setq unread-command-events
-                        (listify-key-sequence key))))))))))
+        (beg (save-excursion (backward-sexp 1) (point))))
+    (completion-in-region beg end octave-completion-alist)))
 
 \f
 ;;; Electric characters && friends