aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2007-08-18 23:44:21 +0000
committerGlenn Morris2007-08-18 23:44:21 +0000
commite5eeb98c62797a1e2fabf8f70ff92a50bf98dc7c (patch)
tree4e3faf6fbe092a88aa647c27c77f7eb1d1c1d63c
parent131cd1540450cbae40f037e62d437c75721e659d (diff)
downloademacs-e5eeb98c62797a1e2fabf8f70ff92a50bf98dc7c.tar.gz
emacs-e5eeb98c62797a1e2fabf8f70ff92a50bf98dc7c.zip
(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.
-rw-r--r--lisp/ChangeLog3
-rw-r--r--lisp/emacs-lisp/eldoc.el94
2 files changed, 56 insertions, 41 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f678581664c..23e7c844773 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -12,6 +12,9 @@
12 (eldoc-function-argstring-format): Change the behavior. Now it 12 (eldoc-function-argstring-format): Change the behavior. Now it
13 applies `eldoc-argument-case' to a string. 13 applies `eldoc-argument-case' to a string.
14 14
15 * progmodes/scheme.el (scheme-mode-variables): Set
16 font-lock-comment-start-skip.
17
152007-08-18 Martin Rudalics <rudalics@gmx.at> 182007-08-18 Martin Rudalics <rudalics@gmx.at>
16 19
17 * progmodes/ada-mode.el (ada-create-syntax-table): Move 20 * progmodes/ada-mode.el (ada-create-syntax-table): Move
diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 2ff273ebab3..19b5c325556 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -264,30 +264,40 @@ Emacs Lisp mode) that support Eldoc.")
264 ;; so we need to be careful that errors aren't ignored. 264 ;; so we need to be careful that errors aren't ignored.
265 (error (message "eldoc error: %s" err)))) 265 (error (message "eldoc error: %s" err))))
266 266
267;; Return a string containing the function parameter list, or 1-line 267;; FIXME improve doc-string.
268;; docstring if function is a subr and no arglist is obtainable from the
269;; docstring or elsewhere.
270(defun eldoc-get-fnsym-args-string (sym &optional argument-index) 268(defun eldoc-get-fnsym-args-string (sym &optional argument-index)
271 (let ((args nil) 269 "Return a string containing the parameter list of the function SYM.
272 (doc nil)) 270If SYM is a subr and no arglist is obtainable from the docstring
271or elsewhere, return a 1-line docstring."
272 (let (args doc)
273 (cond ((not (and sym (symbolp sym) (fboundp sym)))) 273 (cond ((not (and sym (symbolp sym) (fboundp sym))))
274 ((and (eq sym (aref eldoc-last-data 0)) 274 ((and (eq sym (aref eldoc-last-data 0))
275 (eq 'function (aref eldoc-last-data 2))) 275 (eq 'function (aref eldoc-last-data 2)))
276 (setq doc (aref eldoc-last-data 1))) 276 (setq doc (aref eldoc-last-data 1)))
277 ((setq doc (help-split-fundoc (documentation sym t) sym)) 277 ((setq doc (help-split-fundoc (documentation sym t) sym))
278 (setq args (car doc)) 278 (setq args (car doc))
279 ;; Remove any enclosing (), since e-function-argstring adds them.
279 (string-match "\\`[^ )]* ?" args) 280 (string-match "\\`[^ )]* ?" args)
280 (setq args (concat "(" (substring args (match-end 0)))) 281 (setq args (substring args (match-end 0)))
281 (eldoc-last-data-store sym args 'function)) 282 (if (string-match ")\\'" args)
282 (t 283 (setq args (substring args 0 -1))))
283 (setq args (eldoc-function-argstring sym)))) 284 (t
284 (and args 285 (setq args (help-function-arglist sym))))
285 argument-index 286 (if args
286 (setq doc (eldoc-highlight-function-argument sym args argument-index))) 287 ;; Stringify, and store before highlighting, downcasing, etc.
287 doc)) 288 ;; FIXME should truncate before storing.
289 (eldoc-last-data-store sym (setq args (eldoc-function-argstring args))
290 'function)
291 (setq args doc)) ; use stored value
292 ;; Change case, highlight, truncate.
293 (if args
294 (eldoc-highlight-function-argument
295 ;; FIXME apply word by word, ignore &optional, &rest.
296 sym (eldoc-function-argstring-format args) argument-index))))
288 297
289;; Highlight argument INDEX in ARGS list for SYM. 298;; Highlight argument INDEX in ARGS list for SYM.
290(defun eldoc-highlight-function-argument (sym args index) 299;; In the absence of INDEX, just call eldoc-docstring-format-sym-doc.
300(defun eldoc-highlight-function-argument (sym args &optional index)
291 (let ((start nil) 301 (let ((start nil)
292 (end 0) 302 (end 0)
293 (argument-face 'bold)) 303 (argument-face 'bold))
@@ -298,7 +308,7 @@ Emacs Lisp mode) that support Eldoc.")
298 ;; (defun NAME ARGLIST [DOCSTRING] BODY...) case? 308 ;; (defun NAME ARGLIST [DOCSTRING] BODY...) case?
299 ;; The problem is there is no robust way to determine if 309 ;; The problem is there is no robust way to determine if
300 ;; the current argument is indeed a docstring. 310 ;; the current argument is indeed a docstring.
301 (while (>= index 1) 311 (while (and index (>= index 1))
302 (if (string-match "[^ ()]+" args end) 312 (if (string-match "[^ ()]+" args end)
303 (progn 313 (progn
304 (setq start (match-beginning 0) 314 (setq start (match-beginning 0)
@@ -438,29 +448,31 @@ Emacs Lisp mode) that support Eldoc.")
438 (error (setq defn nil)))) 448 (error (setq defn nil))))
439 defn)) 449 defn))
440 450
441(defun eldoc-function-argstring (fn) 451(defun eldoc-function-argstring (arglist)
442 (eldoc-function-argstring-format (help-function-arglist fn))) 452 "Return ARGLIST as a string enclosed by ().
443 453ARGLIST is either a string, or a list of strings or symbols."
444(defun eldoc-function-argstring-format (arglist) 454 (cond ((stringp arglist))
445 (cond ((not (listp arglist)) 455 ((not (listp arglist))
446 (setq arglist nil)) 456 (setq arglist nil))
447 ((symbolp (car arglist)) 457 ((symbolp (car arglist))
448 (setq arglist 458 (setq arglist
449 (mapcar (function (lambda (s) 459 (mapconcat (lambda (s) (symbol-name s))
450 (if (memq s '(&optional &rest)) 460 arglist " ")))
451 (symbol-name s) 461 ((stringp (car arglist))
452 (funcall eldoc-argument-case 462 (setq arglist
453 (symbol-name s))))) 463 (mapconcat (lambda (s) s)
454 arglist))) 464 arglist " "))))
455 ((stringp (car arglist)) 465 (if arglist
456 (setq arglist 466 (format "(%s)" arglist)))
457 (mapcar (function (lambda (s) 467
458 (if (member s '("&optional" "&rest")) 468(defun eldoc-function-argstring-format (argstring)
459 s 469 "Apply `eldoc-argument-case' to each word in argstring.
460 (funcall eldoc-argument-case s)))) 470The words \"&rest\", \"&optional\" are returned unchanged."
461 arglist)))) 471 (mapconcat (lambda (s)
462 (concat "(" (mapconcat 'identity arglist " ") ")")) 472 (if (member s '("&optional" "&rest"))
463 473 s
474 (funcall eldoc-argument-case s)))
475 (split-string argstring) " "))
464 476
465;; When point is in a sexp, the function args are not reprinted in the echo 477;; When point is in a sexp, the function args are not reprinted in the echo
466;; area after every possible interactive command because some of them print 478;; area after every possible interactive command because some of them print