bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#9115: 24.0.50; `documentation' should not return args list for CL de


From: Thierry Volpiatto
Subject: bug#9115: 24.0.50; `documentation' should not return args list for CL defun*.
Date: Tue, 02 Aug 2011 21:43:43 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> (defun* foo (&rest args) nil)
>> (help-split-fundoc (documentation 'foo) nil)
>> =>("(nil &rest ARGS)")
>
>> (defun bar (&rest args) nil)
>> (help-split-fundoc (documentation 'bar) nil)
>> =>nil
>
>> (defmacro foo-1 (&rest args) "some doc." nil)
>> (help-split-fundoc (documentation 'foo-1) nil)
>> nil
>
> Right, as explained in help-split-fundoc's docstring:
>
>    Return (USAGE . DOC) or nil if there's no usage info.
>
> So if you just want the docstring, you'll need something like
>
>   (let ((doc (documentation bidule)))
>     (or (cdr (help-split-fundoc doc nil)) doc))
>
> I agree this is not super convenient.
Yes, i think i have tried that, but it doesn't return nil for the case
of CL-style functions.

What i wanted was return only the first line of docstring or nil or "not
documented" if no docstring.
(to display in mode-line when completing lisp symbols)

Here what i use finally:


#+BEGIN_SRC lisp
(defun anything-c-get-first-line-documentation (sym)
  "Return first line documentation of symbol SYM.
If SYM is not documented, return \"Not documented\"."
  (let ((doc (cond ((fboundp sym)
                    (documentation sym t))
                   ((boundp sym)
                    (documentation-property sym 'variable-documentation t))
                   ((facep sym)
                    (face-documentation sym))
                   (t nil))))
    (if (and doc (not (string= doc ""))
             ;; `documentation' return "\n\n(args...)"
             ;; for CL-style functions.
             (not (string-match-p "^\n\n" doc)))
        (car (split-string doc "\n"))
        "Not documented")))

#+END_SRC


-- 
A+ Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]