From: Leo Liu Date: Thu, 25 Apr 2013 16:23:56 +0000 (+0800) Subject: * progmodes/octave.el (octave-completion-at-point-function): Make X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~2026^2~372 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=584ea27747d10f9af3d4e3c022153a3d4fc87cc4;p=emacs.git * progmodes/octave.el (octave-completion-at-point-function): Make use of inferior octave process. (octave-initialize-completions): Remove. (inferior-octave-completion-table): New function. (inferior-octave-completion-at-point): Use it. (octave-completion-alist): Remove. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8ac5b5801ef..62424265d96 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,12 @@ +2013-04-25 Leo Liu + + * progmodes/octave.el (octave-completion-at-point-function): Make + use of inferior octave process. + (octave-initialize-completions): Remove. + (inferior-octave-completion-table): New function. + (inferior-octave-completion-at-point): Use it. + (octave-completion-alist): Remove. + 2013-04-25 Stefan Monnier * progmodes/opascal.el: Use font-lock and syntax-propertize. diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el index c652822bf47..0e540ea348a 100644 --- a/lisp/progmodes/octave.el +++ b/lisp/progmodes/octave.el @@ -330,12 +330,6 @@ newline or semicolon after an else or end keyword." :type 'string :group 'octave) -(defvar octave-completion-alist nil - "Alist of Octave symbols for completion in Octave mode. -Each element looks like (VAR . VAR), where the car and cdr are the same -symbol (an Octave command or variable name). -Currently, only builtin variables can be completed.") - (defvar octave-mode-imenu-generic-expression (list ;; Functions @@ -639,8 +633,7 @@ including a reproducible test case and send the message." (set (make-local-variable 'beginning-of-defun-function) 'octave-beginning-of-defun) - (easy-menu-add octave-mode-menu) - (octave-initialize-completions)) + (easy-menu-add octave-mode-menu)) (defcustom inferior-octave-program "octave" @@ -874,6 +867,15 @@ startup file, `~/.emacs-octave'." ;; won't have detrimental effects. (inferior-octave-resync-dirs))) +(defun inferior-octave-completion-table () + (unless inferior-octave-complete-impossible + (completion-table-dynamic + (lambda (command) + (inferior-octave-send-list-and-digest + (list (concat "completion_matches (\"" command "\");\n"))) + (sort (delete-dups inferior-octave-output-list) + 'string-lessp))))) + (defun inferior-octave-completion-at-point () "Return the data to complete the Octave symbol at point." (let* ((end (point)) @@ -887,15 +889,7 @@ startup file, `~/.emacs-octave'." "Your Octave does not have `completion_matches'. " "Please upgrade to version 2.X.")) nil) - (t - (list - start end - (completion-table-dynamic - (lambda (command) - (inferior-octave-send-list-and-digest - (list (concat "completion_matches (\"" command "\");\n"))) - (sort (delete-dups inferior-octave-output-list) - 'string-lessp)))))))) + (t (list start end (inferior-octave-completion-table)))))) (define-obsolete-function-alias 'inferior-octave-complete 'completion-at-point "24.1") @@ -1296,14 +1290,6 @@ otherwise." ;;; Completions -(defun octave-initialize-completions () - "Create an alist for Octave completions." - (if octave-completion-alist - () - (setq octave-completion-alist - (append octave-reserved-words - octave-text-functions - octave-variables)))) (defun octave-completion-at-point-function () "Find the text to complete and the corresponding table." @@ -1313,7 +1299,12 @@ otherwise." ;; Extend region past point, if applicable. (save-excursion (skip-syntax-forward "w_") (setq end (point)))) - (list beg end octave-completion-alist))) + (list beg end (or (and inferior-octave-process + (process-live-p inferior-octave-process) + (inferior-octave-completion-table)) + (append octave-reserved-words + octave-text-functions + octave-variables))))) (define-obsolete-function-alias 'octave-complete-symbol 'completion-at-point "24.1")