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

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

[External] : Supplying DOC string in a `defun' using `defvar'


From: ludvig-faddeev
Subject: [External] : Supplying DOC string in a `defun' using `defvar'
Date: Tue, 1 Jun 2021 23:50:07 +0200

> Sent: Wednesday, June 02, 2021 at 2:26 AM
> From: "Michael Heerdegen" <michael_heerdegen@web.de>
> To: help-gnu-emacs@gnu.org
> Subject: Re: [External] : Supplying DOC string in a `defun' using `defvar'
>
> ludvig-faddeev@gmx.com writes:
>
> > Is it possible to define a function that sets a documentation string and
> > then calls
> >
> > (put 'wyfunc
> >      'function-documentation 'mydetail)
>
> You don't need a variable as an intermediate step in that case at all,
> that would be redundant -- because can use `get' to look up what is
> stored in the function-documentation property of your symbol so far.

Could I ust use the string directly in the "put" statement?

(put 'myfunc
     'function-documentation <doc-string>)

I want to only have a brief docstring in the function definition, with more 
details
done somewhere else (which at the current time I can do using a put).

I could call the following function

(defun defun-detail (fname detail)
   "Put DETAIL in function-documentation property of FNAME.
Usage:  (defun-detail 'fname 'detail)"

   (put fname 'function-documentation detail))

-------- code -------

(defvar detail-ziggurat-bufr-wlabel
   "Generate new temporary buffer with a user defined label.
User gets asked for a label name through thu mini-buffer.

Usage:  C-u M-x ziggurat-bufr-wlabel
        M-x ziggurat-bufr-wlabel

One can use a key-sequence to call ziggurat-bufr-wlabel

  (global-unset-key (kbd \"<f5>\"))
  (global-set-key (kbd \"<f5>\")  #'ziggurat-bufr-wlabel)"
  "Detailed doc-string for ziggurat-bufr-wlabel")

--------

;; puts documentation in function-documentation property
(defun-detail 'ziggurat-bufr-wlabel 'detail-ziggurat-bufr-wlabel)

-------

(defun ziggurat-bufr-wlabel ()
  "Generate new temporary buffer with a user defined label."

  (interactive)
  (ziggurat-bufr
     (read-from-minibuffer "Buffer name: ")))

--------

> Use `put' to set it to something else, whether that reuses the old value
> or not.  There is really no magic here at all, it's just that trivial.
> That symbol property is where the documentation is stored, just like a
> variable - only the way of getting and setting the value looks different
> compared to a variable.
>
> If you need a more concrete suggestion, I need to know more about your
> use case.
>
>
> Regards,
>
> Michael.
>
>
>
>



reply via email to

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