all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Thierry Volpiatto <thierry.volpiatto@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 9115@debbugs.gnu.org
Subject: bug#9115: 24.0.50; `documentation' should not return args list for CL defun*.
Date: Tue, 02 Aug 2011 21:43:43 +0200	[thread overview]
Message-ID: <87bow7r440.fsf@gmail.com> (raw)
In-Reply-To: <jwvei13eie4.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Tue, 02 Aug 2011 15:16:19 -0400")

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	other threads:[~2011-08-02 19:43 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-18  6:05 bug#9115: 24.0.50; `documentation' should not return args list for CL defun* Thierry Volpiatto
2011-07-18  6:24 ` Leo
2011-07-18  7:18   ` Thierry Volpiatto
2011-07-18  8:26     ` Leo
2011-07-18  8:34       ` Thierry Volpiatto
2011-07-18 17:51     ` Andreas Schwab
2011-07-18 16:02 ` Stefan Monnier
2011-07-19  6:06   ` Thierry Volpiatto
2011-08-01 21:33     ` Stefan Monnier
2011-08-02  5:21       ` Thierry Volpiatto
2011-08-02 19:16         ` Stefan Monnier
2011-08-02 19:43           ` Thierry Volpiatto [this message]
2011-08-02 20:31             ` Stefan Monnier
2011-08-02 20:50               ` Thierry Volpiatto
2011-08-03  1:16                 ` Stefan Monnier
2011-08-03  5:10                   ` Thierry Volpiatto
2011-08-03 14:31                     ` Stefan Monnier
2011-08-03 14:45                       ` Thierry Volpiatto
2019-10-12  5:02                         ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bow7r440.fsf@gmail.com \
    --to=thierry.volpiatto@gmail.com \
    --cc=9115@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.