all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: carlmarcos--- via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: Emanuel Berg <incal@dataswamp.org>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Executing function only if another function is defined
Date: Mon, 25 Jul 2022 12:24:04 +0200 (CEST)	[thread overview]
Message-ID: <N7oseAp--3-2@tutanota.com> (raw)
In-Reply-To: <87czduhsxe.fsf@dataswamp.org>


Jul 25, 2022, 01:39 by incal@dataswamp.org:

> carlmarcos--- via Users list for the GNU Emacs text editor wrote:
>
>> Because it may be possible that some functions are not
>> available (e.g. during testing or debugging phases), I would
>> like to test whether the function `toucan' has been defined
>> before I call `docboost'. What can I do?
>>
>> (defun toucan-usage ()
>>  "TODO"
>>
>>  (docboost 'toucan "Usage Information"))
>>
>
> (Why are you using no-break space?)
>
> What you can do?
>
> You can ...
>
> 1. `require' the library where "toucan" is defined.
>
> 2. Use the hash/sharp-quote, #', instead of just the quote for
>  toucan. (#' is `function' and ' is `quote' BTW.)
>
> 3. Byte-compile. The byte compiler will tell you if toucan
>  is undefined.
>
I have modified the function as follows

(defun docboost (fname doc-boost)
  "Appends a string to the documentation of a function.
FNAME       Name of function
DOC-BOOST   Documentation"

  (if (functionp fname)
      (put fname 'function-documentation
   (concat (documentation fname t) doc-boost))))

Then doing as you suggest with

(typex-docboost #'toucan "Additional Text:")

Is `functionp' appropriate for testing whether `fname' was defined?

Adding a newline before printing the additional documentation would be a sensible thing to do.
How to do it within docboost?





  parent reply	other threads:[~2022-07-25 10:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-24 11:35 Executing function only if another function is defined carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-24 14:33 ` [External] : " Drew Adams
     [not found] ` <SJ0PR10MB548801BBE63F2CC264989A84F3929@SJ0PR10MB5488.namprd10.prod.outlook.com-N7kcFo0----2>
2022-07-24 15:13   ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-25  1:42     ` Emanuel Berg
2022-07-25  1:39 ` Emanuel Berg
2022-07-25  8:08   ` help as a function of a NEWS problem (was: Re: Executing function only if another function is defined) Emanuel Berg
2022-07-25 10:24   ` carlmarcos--- via Users list for the GNU Emacs text editor [this message]
2022-07-25 11:14     ` Executing function only if another function is defined Emanuel Berg
2022-07-25 11:30       ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-25 11:45         ` Emanuel Berg
2022-07-25 11:51           ` carlmarcos--- via Users list for the GNU Emacs text editor

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=N7oseAp--3-2@tutanota.com \
    --to=help-gnu-emacs@gnu.org \
    --cc=carlmarcos@tutanota.com \
    --cc=incal@dataswamp.org \
    /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.