GNU bug report logs -
#9115
`documentation' should let you choose whether to include `usage'
Previous Next
Full log
Message #38 received at 9115 <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier <monnier <at> 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
This bug report was last modified 5 years and 219 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.