+2013-04-25 Leo Liu <sdl.web@gmail.com>
+
+ * 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 <monnier@iro.umontreal.ca>
* progmodes/opascal.el: Use font-lock and syntax-propertize.
: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
(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))
\f
(defcustom inferior-octave-program "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))
"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")
\f
;;; 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."
;; 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")