(eldoc-get-fnsym-args-string): Convert
comment to basic doc string. Also apply eldoc-argument-case in the help-split-fundoc case. Adapt for changed behavior of eldoc-function-argstring, eldoc-function-argstring-format, and eldoc-highlight-function-argument. (eldoc-highlight-function-argument): Make INDEX argument optional, just call eldoc-docstring-format-sym-doc if absent. (eldoc-function-argstring): Change the behavior. Now it converts an argument list to a string. (eldoc-function-argstring-format): Change the behavior. Now it applies `eldoc-argument-case' to a string.
This commit is contained in:
parent
131cd15404
commit
e5eeb98c62
2 changed files with 55 additions and 40 deletions
|
@ -12,6 +12,9 @@
|
||||||
(eldoc-function-argstring-format): Change the behavior. Now it
|
(eldoc-function-argstring-format): Change the behavior. Now it
|
||||||
applies `eldoc-argument-case' to a string.
|
applies `eldoc-argument-case' to a string.
|
||||||
|
|
||||||
|
* progmodes/scheme.el (scheme-mode-variables): Set
|
||||||
|
font-lock-comment-start-skip.
|
||||||
|
|
||||||
2007-08-18 Martin Rudalics <rudalics@gmx.at>
|
2007-08-18 Martin Rudalics <rudalics@gmx.at>
|
||||||
|
|
||||||
* progmodes/ada-mode.el (ada-create-syntax-table): Move
|
* progmodes/ada-mode.el (ada-create-syntax-table): Move
|
||||||
|
|
|
@ -264,30 +264,40 @@ Emacs Lisp mode) that support Eldoc.")
|
||||||
;; so we need to be careful that errors aren't ignored.
|
;; so we need to be careful that errors aren't ignored.
|
||||||
(error (message "eldoc error: %s" err))))
|
(error (message "eldoc error: %s" err))))
|
||||||
|
|
||||||
;; Return a string containing the function parameter list, or 1-line
|
;; FIXME improve doc-string.
|
||||||
;; docstring if function is a subr and no arglist is obtainable from the
|
|
||||||
;; docstring or elsewhere.
|
|
||||||
(defun eldoc-get-fnsym-args-string (sym &optional argument-index)
|
(defun eldoc-get-fnsym-args-string (sym &optional argument-index)
|
||||||
(let ((args nil)
|
"Return a string containing the parameter list of the function SYM.
|
||||||
(doc nil))
|
If SYM is a subr and no arglist is obtainable from the docstring
|
||||||
|
or elsewhere, return a 1-line docstring."
|
||||||
|
(let (args doc)
|
||||||
(cond ((not (and sym (symbolp sym) (fboundp sym))))
|
(cond ((not (and sym (symbolp sym) (fboundp sym))))
|
||||||
((and (eq sym (aref eldoc-last-data 0))
|
((and (eq sym (aref eldoc-last-data 0))
|
||||||
(eq 'function (aref eldoc-last-data 2)))
|
(eq 'function (aref eldoc-last-data 2)))
|
||||||
(setq doc (aref eldoc-last-data 1)))
|
(setq doc (aref eldoc-last-data 1)))
|
||||||
((setq doc (help-split-fundoc (documentation sym t) sym))
|
((setq doc (help-split-fundoc (documentation sym t) sym))
|
||||||
(setq args (car doc))
|
(setq args (car doc))
|
||||||
|
;; Remove any enclosing (), since e-function-argstring adds them.
|
||||||
(string-match "\\`[^ )]* ?" args)
|
(string-match "\\`[^ )]* ?" args)
|
||||||
(setq args (concat "(" (substring args (match-end 0))))
|
(setq args (substring args (match-end 0)))
|
||||||
(eldoc-last-data-store sym args 'function))
|
(if (string-match ")\\'" args)
|
||||||
(t
|
(setq args (substring args 0 -1))))
|
||||||
(setq args (eldoc-function-argstring sym))))
|
(t
|
||||||
(and args
|
(setq args (help-function-arglist sym))))
|
||||||
argument-index
|
(if args
|
||||||
(setq doc (eldoc-highlight-function-argument sym args argument-index)))
|
;; Stringify, and store before highlighting, downcasing, etc.
|
||||||
doc))
|
;; FIXME should truncate before storing.
|
||||||
|
(eldoc-last-data-store sym (setq args (eldoc-function-argstring args))
|
||||||
|
'function)
|
||||||
|
(setq args doc)) ; use stored value
|
||||||
|
;; Change case, highlight, truncate.
|
||||||
|
(if args
|
||||||
|
(eldoc-highlight-function-argument
|
||||||
|
;; FIXME apply word by word, ignore &optional, &rest.
|
||||||
|
sym (eldoc-function-argstring-format args) argument-index))))
|
||||||
|
|
||||||
;; Highlight argument INDEX in ARGS list for SYM.
|
;; Highlight argument INDEX in ARGS list for SYM.
|
||||||
(defun eldoc-highlight-function-argument (sym args index)
|
;; In the absence of INDEX, just call eldoc-docstring-format-sym-doc.
|
||||||
|
(defun eldoc-highlight-function-argument (sym args &optional index)
|
||||||
(let ((start nil)
|
(let ((start nil)
|
||||||
(end 0)
|
(end 0)
|
||||||
(argument-face 'bold))
|
(argument-face 'bold))
|
||||||
|
@ -298,7 +308,7 @@ Emacs Lisp mode) that support Eldoc.")
|
||||||
;; (defun NAME ARGLIST [DOCSTRING] BODY...) case?
|
;; (defun NAME ARGLIST [DOCSTRING] BODY...) case?
|
||||||
;; The problem is there is no robust way to determine if
|
;; The problem is there is no robust way to determine if
|
||||||
;; the current argument is indeed a docstring.
|
;; the current argument is indeed a docstring.
|
||||||
(while (>= index 1)
|
(while (and index (>= index 1))
|
||||||
(if (string-match "[^ ()]+" args end)
|
(if (string-match "[^ ()]+" args end)
|
||||||
(progn
|
(progn
|
||||||
(setq start (match-beginning 0)
|
(setq start (match-beginning 0)
|
||||||
|
@ -438,29 +448,31 @@ Emacs Lisp mode) that support Eldoc.")
|
||||||
(error (setq defn nil))))
|
(error (setq defn nil))))
|
||||||
defn))
|
defn))
|
||||||
|
|
||||||
(defun eldoc-function-argstring (fn)
|
(defun eldoc-function-argstring (arglist)
|
||||||
(eldoc-function-argstring-format (help-function-arglist fn)))
|
"Return ARGLIST as a string enclosed by ().
|
||||||
|
ARGLIST is either a string, or a list of strings or symbols."
|
||||||
(defun eldoc-function-argstring-format (arglist)
|
(cond ((stringp arglist))
|
||||||
(cond ((not (listp arglist))
|
((not (listp arglist))
|
||||||
(setq arglist nil))
|
(setq arglist nil))
|
||||||
((symbolp (car arglist))
|
((symbolp (car arglist))
|
||||||
(setq arglist
|
(setq arglist
|
||||||
(mapcar (function (lambda (s)
|
(mapconcat (lambda (s) (symbol-name s))
|
||||||
(if (memq s '(&optional &rest))
|
arglist " ")))
|
||||||
(symbol-name s)
|
((stringp (car arglist))
|
||||||
(funcall eldoc-argument-case
|
(setq arglist
|
||||||
(symbol-name s)))))
|
(mapconcat (lambda (s) s)
|
||||||
arglist)))
|
arglist " "))))
|
||||||
((stringp (car arglist))
|
(if arglist
|
||||||
(setq arglist
|
(format "(%s)" arglist)))
|
||||||
(mapcar (function (lambda (s)
|
|
||||||
(if (member s '("&optional" "&rest"))
|
|
||||||
s
|
|
||||||
(funcall eldoc-argument-case s))))
|
|
||||||
arglist))))
|
|
||||||
(concat "(" (mapconcat 'identity arglist " ") ")"))
|
|
||||||
|
|
||||||
|
(defun eldoc-function-argstring-format (argstring)
|
||||||
|
"Apply `eldoc-argument-case' to each word in argstring.
|
||||||
|
The words \"&rest\", \"&optional\" are returned unchanged."
|
||||||
|
(mapconcat (lambda (s)
|
||||||
|
(if (member s '("&optional" "&rest"))
|
||||||
|
s
|
||||||
|
(funcall eldoc-argument-case s)))
|
||||||
|
(split-string argstring) " "))
|
||||||
|
|
||||||
;; When point is in a sexp, the function args are not reprinted in the echo
|
;; When point is in a sexp, the function args are not reprinted in the echo
|
||||||
;; area after every possible interactive command because some of them print
|
;; area after every possible interactive command because some of them print
|
||||||
|
|
Loading…
Add table
Reference in a new issue