Function: idlwave-complete
idlwave-complete is an interactive and byte-compiled function defined
in idlwave.el.gz.
Signature
(idlwave-complete &optional ARG MODULE CLASS)
Documentation
Complete a function, procedure or keyword name at point.
This function is smart and figures out what can be completed
at this point.
- At the beginning of a statement it completes procedure names.
- In the middle of a statement it completes function names.
- After a ( or , in the argument list of a function or procedure,
it completes a keyword of the relevant function or procedure.
- In the first arg of OBJ_NEW, it completes a class name.
When several completions are possible, a list will be displayed in
the *Completions* buffer. If this list is too long to fit into the
window, scrolling can be achieved by repeatedly pressing
M-x idlwave-complete (idlwave-complete).
The function also knows about object methods. When it needs a class
name, the action depends upon idlwave-query-class, which see. You
can force IDLWAVE to ask you for a class name with a
C-u (universal-argument) prefix argument to this command.
See also the variables idlwave-keyword-completion-adds-equal and
idlwave-function-completion-adds-paren.
The optional ARG can be used to specify the completion type in order to override IDLWAVE's idea of what should be completed at point. Possible values are:
0 <=> query for the completion type
1 <=> procedure
2 <=> procedure-keyword
3 <=> function
4 <=> function-keyword
5 <=> procedure-method
6 <=> procedure-method-keyword
7 <=> function-method
8 <=> function-method-keyword
9 <=> class
As a special case, the universal argument C-u (universal-argument) forces completion of
function names in places where the default would be a keyword.
Two prefix argument, C-u (universal-argument) C-u (universal-argument), prompts for a regexp by which to limit
completion.
For Lisp programmers only: When we force a keyword, optional argument MODULE can contain the module name. When we force a method or a method keyword, CLASS can specify the class.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/obsolete/idlwave.el.gz
(defun idlwave-complete (&optional arg module class)
"Complete a function, procedure or keyword name at point.
This function is smart and figures out what can be completed
at this point.
- At the beginning of a statement it completes procedure names.
- In the middle of a statement it completes function names.
- After a `(' or `,' in the argument list of a function or procedure,
it completes a keyword of the relevant function or procedure.
- In the first arg of `OBJ_NEW', it completes a class name.
When several completions are possible, a list will be displayed in
the *Completions* buffer. If this list is too long to fit into the
window, scrolling can be achieved by repeatedly pressing
\\[idlwave-complete].
The function also knows about object methods. When it needs a class
name, the action depends upon `idlwave-query-class', which see. You
can force IDLWAVE to ask you for a class name with a
\\[universal-argument] prefix argument to this command.
See also the variables `idlwave-keyword-completion-adds-equal' and
`idlwave-function-completion-adds-paren'.
The optional ARG can be used to specify the completion type in order
to override IDLWAVE's idea of what should be completed at point.
Possible values are:
0 <=> query for the completion type
1 <=> `procedure'
2 <=> `procedure-keyword'
3 <=> `function'
4 <=> `function-keyword'
5 <=> `procedure-method'
6 <=> `procedure-method-keyword'
7 <=> `function-method'
8 <=> `function-method-keyword'
9 <=> `class'
As a special case, the universal argument \\[universal-argument] forces completion of
function names in places where the default would be a keyword.
Two prefix argument, \\[universal-argument] \\[universal-argument], prompts for a regexp by which to limit
completion.
For Lisp programmers only:
When we force a keyword, optional argument MODULE can contain the module name.
When we force a method or a method keyword, CLASS can specify the class."
(interactive "P")
(idlwave-routines)
(let* ((where-list
(if (and arg
(or (and (integerp arg) (not (equal arg '(16))))
(symbolp arg)))
(idlwave-make-force-complete-where-list arg module class)
(idlwave-where)))
(what (nth 2 where-list))
(idlwave-force-class-query (equal arg '(4)))
(completion-regexp-list
(if (equal arg '(16))
(list (read-string (concat "Completion Regexp: "))))))
(if (and module (string-match "::" module))
(setq class (substring module 0 (match-beginning 0))
module (substring module (match-end 0))))
(cond
((and (null arg)
(eq (car-safe last-command) 'idlwave-display-completion-list)
(get-buffer-window "*Completions*"))
(setq this-command last-command)
(idlwave-scroll-completions))
;; Complete a filename in quotes
((and (idlwave-in-quote)
(not (eq what 'class)))
(idlwave-complete-filename))
;; Check for any special completion functions
((run-hook-with-args-until-success 'idlwave-complete-functions))
((null what)
(error "Nothing to complete here"))
;; Complete a class
((eq what 'class)
(setq idlwave-completion-help-info '(class))
(idlwave-complete-class))
((eq what 'procedure)
;; Complete a procedure name
(let* ((cw-list (nth 3 where-list))
(idlwave--class-selector (idlwave-determine-class cw-list 'pro))
(idlwave--super-classes
(unless (idlwave-explicit-class-listed cw-list)
(idlwave-all-class-inherits idlwave--class-selector)))
(isa (concat "procedure"
(if idlwave--class-selector "-method" "")))
(idlwave--type-selector 'pro))
(setq idlwave-completion-help-info
(list 'routine nil
idlwave--type-selector idlwave--class-selector
nil idlwave--super-classes))
(idlwave-complete-in-buffer
'procedure (if idlwave--class-selector 'method 'routine)
(idlwave-routines) 'idlwave-selector
(format "Select a %s name%s"
isa
(if idlwave--class-selector
(format " (class is %s)"
(if (eq idlwave--class-selector t)
"unknown" idlwave--class-selector))
""))
isa
'idlwave-attach-method-classes 'idlwave-add-file-link-selector)))
((eq what 'function)
;; Complete a function name
(let* ((cw-list (nth 3 where-list))
(idlwave--class-selector (idlwave-determine-class cw-list 'fun))
(idlwave--super-classes
(unless (idlwave-explicit-class-listed cw-list)
(idlwave-all-class-inherits idlwave--class-selector)))
(isa (concat "function" (if idlwave--class-selector "-method" "")))
(idlwave--type-selector 'fun))
(setq idlwave-completion-help-info
(list 'routine nil
idlwave--type-selector idlwave--class-selector
nil idlwave--super-classes))
(idlwave-complete-in-buffer
'function (if idlwave--class-selector 'method 'routine)
(idlwave-routines) 'idlwave-selector
(format "Select a %s name%s"
isa
(if idlwave--class-selector
(format " (class is %s)"
(if (eq idlwave--class-selector t)
"unknown" idlwave--class-selector))
""))
isa
'idlwave-attach-method-classes 'idlwave-add-file-link-selector)))
((and (memq what '(procedure-keyword function-keyword)) ; Special Case
(equal arg '(4)))
(idlwave-complete 3))
((eq what 'procedure-keyword)
;; Complete a procedure keyword
(let* ((where (nth 3 where-list))
(name (car where))
(idlwave--method-selector name)
(idlwave--type-selector 'pro)
(class (idlwave-determine-class where 'pro))
(idlwave--class-selector class)
(idlwave--super-classes (idlwave-all-class-inherits
idlwave--class-selector))
(isa (format "procedure%s-keyword" (if class "-method" "")))
(entry (idlwave-best-rinfo-assq
name 'pro class (idlwave-routines)))
(system (if entry (eq (car (nth 3 entry)) 'system)))
(list (idlwave-entry-keywords entry 'do-link)))
(unless (or entry (eq class t))
(error "Nothing known about procedure %s"
(idlwave-make-full-name class name)))
(setq list (idlwave-fix-keywords name 'pro class list
idlwave--super-classes system))
(unless list (error "No keywords available for procedure %s"
(idlwave-make-full-name class name)))
(setq idlwave-completion-help-info
(list 'keyword name
idlwave--type-selector idlwave--class-selector
entry idlwave--super-classes))
(idlwave-complete-in-buffer
'keyword 'keyword list nil
(format "Select keyword for procedure %s%s"
(idlwave-make-full-name class name)
(if (or (member '("_EXTRA") list)
(member '("_REF_EXTRA") list))
" (note _EXTRA)" ""))
isa
'idlwave-attach-keyword-classes)))
((eq what 'function-keyword)
;; Complete a function keyword
(let* ((where (nth 3 where-list))
(name (car where))
(idlwave--method-selector name)
(idlwave--type-selector 'fun)
(class (idlwave-determine-class where 'fun))
(idlwave--class-selector class)
(idlwave--super-classes (idlwave-all-class-inherits
idlwave--class-selector))
(isa (format "function%s-keyword" (if class "-method" "")))
(entry (idlwave-best-rinfo-assq
name 'fun class (idlwave-routines)))
(system (if entry (eq (car (nth 3 entry)) 'system)))
(list (idlwave-entry-keywords entry 'do-link))
msg-name)
(unless (or entry (eq class t))
(error "Nothing known about function %s"
(idlwave-make-full-name class name)))
(setq list (idlwave-fix-keywords name 'fun class list
idlwave--super-classes system))
;; OBJ_NEW: Messages mention the proper Init method
(setq msg-name (if (and (null class)
(string= (upcase name) "OBJ_NEW"))
(concat idlwave-current-obj_new-class
"::Init (via OBJ_NEW)")
(idlwave-make-full-name class name)))
(unless list (error "No keywords available for function %s"
msg-name))
(setq idlwave-completion-help-info
(list 'keyword name
idlwave--type-selector idlwave--class-selector
nil idlwave--super-classes))
(idlwave-complete-in-buffer
'keyword 'keyword list nil
(format "Select keyword for function %s%s" msg-name
(if (or (member '("_EXTRA") list)
(member '("_REF_EXTRA") list))
" (note _EXTRA)" ""))
isa
'idlwave-attach-keyword-classes)))
(t (error "This should not happen (idlwave-complete)")))))