Function: idlwave-parse-definition
idlwave-parse-definition is a byte-compiled function defined in
idlwave.el.gz.
Signature
(idlwave-parse-definition STRING)
Documentation
Parse a module definition.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/idlwave.el.gz
(defun idlwave-parse-definition (string)
"Parse a module definition."
(let ((case-fold-search t)
start name args type keywords class)
;; Remove comments
(while (string-match ";.*" string)
(setq string (replace-match "" t t string)))
;; Remove the continuation line stuff
(while (string-match "\\([^a-zA-Z0-9$_]\\)\\$[ \t]*\n" string)
(setq string (replace-match "\\1 " t nil string)))
(while (string-match "\n" string)
(setq string (replace-match " " t nil string)))
;; Match the name and type.
(when (string-match
"\\<\\(pro\\|function\\)\\>\\s-+\\(\\([a-zA-Z0-9$_]+\\)::\\)?\\([a-zA-Z0-9$_]+\\)" string)
(setq start (match-end 0))
(setq type (downcase (match-string 1 string)))
(if (match-beginning 3)
(setq class (match-string 3 string)))
(setq name (match-string 4 string)))
;; Match normal args and keyword args
(while (string-match
",\\s-*\\([a-zA-Z][a-zA-Z0-9$_]*\\|\\(_ref\\)?_extra\\)\\s-*\\(=\\)?"
string start)
(setq start (match-end 0))
(if (match-beginning 3)
(push (match-string 1 string) keywords)
(push (match-string 1 string) args)))
;; Normalize and sort.
(setq args (nreverse args))
(setq keywords (sort keywords (lambda (a b)
(string< (downcase a) (downcase b)))))
;; Make and return the entry
;; We don't know which argument are optional, so this information
;; will not be contained in the calling sequence.
(list name
(if (equal type "pro") 'pro 'fun)
class
(cond ((not (boundp 'idlwave-scanning-lib))
(list 'buffer (buffer-file-name)))
; ((string= (downcase (file-name-base (buffer-file-name))
; (downcase name))
; (list 'lib))
; (t (cons 'lib (file-name-nondirectory (buffer-file-name))))
(t (list 'user (file-name-nondirectory (buffer-file-name))
idlwave-scanning-lib-dir "UserLib")))
(concat
(if (string= type "function") "Result = " "")
(if class "Obj ->[%s::]" "")
"%s"
(if args
(concat
(if (string= type "function") "(" ", ")
(mapconcat #'identity args ", ")
(if (string= type "function") ")" ""))))
(if keywords
(cons nil (mapcar #'list keywords)) ;No help file
nil))))