From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: carlmarcos--- via Users list for the GNU Emacs text editor Newsgroups: gmane.emacs.help Subject: RE: [External] : Executing function only if another function is defined Date: Sun, 24 Jul 2022 17:13:49 +0200 (CEST) Message-ID: References: Reply-To: carlmarcos@tutanota.com Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26126"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'" To: Drew Adams Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 24 17:14:53 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oFdJk-0006cI-JZ for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 24 Jul 2022 17:14:52 +0200 Original-Received: from localhost ([::1]:54896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oFdJj-0006g6-93 for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 24 Jul 2022 11:14:51 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47124) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFdIn-0006e5-9n for help-gnu-emacs@gnu.org; Sun, 24 Jul 2022 11:13:53 -0400 Original-Received: from w1.tutanota.de ([81.3.6.162]:56572) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFdIl-0007Eq-1g for help-gnu-emacs@gnu.org; Sun, 24 Jul 2022 11:13:53 -0400 Original-Received: from w3.tutanota.de (unknown [192.168.1.164]) by w1.tutanota.de (Postfix) with ESMTP id 2C3A4FA030C; Sun, 24 Jul 2022 15:13:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1658675629; s=s1; d=tutanota.com; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Content-Transfer-Encoding:Cc:Cc:Date:Date:In-Reply-To:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:References:Sender; bh=1RFQIxI0nP60ZG4RstlvBOX6jHSzYOqyetN/MuoeJJA=; b=yqOPqJF5M7EAIgwQHVB01fOl9iPK9t/OKE8SzL2PW/J5ZQ5kitNoM6JIj0A7Z2T3 IIf7fUkbiEv50WUw7WfP8B4zbiR0dJ34e+PquqnxMn5ai3D5zKk8tS9POQreYSKv+Rp CwZbJVZS1NvGunkMHn0Imo+TiK7Snhv8m5SQajvZCumQKVCaeiLqls5ORoINJSHH7Kz BSjPZLjJ7cUfbhIzPIZGEli7Yi4gWsVqmIUr4bc8zn3wYfBC9VLsjIrP4JJk5cPG/cp 4uu6slrD4anHB6uIJuFXeP5EnE7Trf5J2cGyRuiCLgj48J0xyOJwlsHgONEYajBlnx4 Mi15afr+qA== In-Reply-To: Received-SPF: pass client-ip=81.3.6.162; envelope-from=carlmarcos@tutanota.com; helo=w1.tutanota.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:138597 Archived-At: Jul 24, 2022, 14:33 by drew.adams@oracle.com: >> I would like to test whether the function `toucan' >> has been defined before I call `docboost'. >> What can I do? >> > > Defined where? By who/what? What's the context? > > Predefined as part of Emacs? Defined in some > 3rd-party package? Defined in some library that > you've already loaded in the current session? > > Defined under the name `toucan'? Defined under > another name (or anonymously) but with the same > code or similar behavior? > I define the function toucan in one of my init files using (require 'myfile= ) Sometimes I comment out the require part, meaning that the function toucan = would not be loaded.=C2=A0 Thus it does not make sense to a information to = its docstring. > A Lisp function, i.e., funcallable? A "function" > more generally (a "function-like object"), i.e., > a symbol with a non-nil `symbol-function' value? > > > > ___ > > -- Function: functionp object > This function returns =E2=80=98t=E2=80=99 if OBJECT is any kind of functi= on, i.e., > can be passed to =E2=80=98funcall=E2=80=99. Note that =E2=80=98functionp= =E2=80=99 returns =E2=80=98t=E2=80=99 for > symbols that are function names, and returns =E2=80=98nil=E2=80=99 for sp= ecial > forms. > > -- Function: fboundp symbol > This function returns =E2=80=98t=E2=80=99 if the symbol has an object in = its > function cell, =E2=80=98nil=E2=80=99 otherwise. It does not check that t= he object > is a legitimate function. > > -- Function: symbol-function symbol > This returns the object in the function cell of SYMBOL. It does > not check that the returned object is a legitimate function. > > If the function cell is void, the return value is =E2=80=98nil=E2=80=99. = To > distinguish between a function cell that is void and one set to > =E2=80=98nil=E2=80=99, use =E2=80=98fboundp=E2=80=99 (see below). > ... > > If you have never given a symbol any function definition, we say that > that symbol=E2=80=99s function cell is =E2=80=9Cvoid=E2=80=9D. In other = words, the function > cell does not have any Lisp object in it. If you try to call the symbol > as a function, Emacs signals a =E2=80=98void-function=E2=80=99 error. > > Note that void is not the same as =E2=80=98nil=E2=80=99 or the symbol =E2= =80=98void=E2=80=99. The > symbols =E2=80=98nil=E2=80=99 and =E2=80=98void=E2=80=99 are Lisp objects= , and can be stored into a > function cell just as any other object can be (and they can be valid > functions if you define them in turn with =E2=80=98defun=E2=80=99). A vo= id function > cell contains no object whatsoever. > > You can test the voidness of a symbol=E2=80=99s function definition with > =E2=80=98fboundp=E2=80=99. After you have given a symbol a function defi= nition, you can > make it void once more using =E2=80=98fmakunbound=E2=80=99. > ___ > > FWIW - > > Your questions tend to be guessing games for > anyone who might want to help. (What is it that > he's asking? Is it bigger than a bread basket? > Animal? Vegetable? Mineral?) > > Do _yourself_ a favor and _ask yourself_ first > what it is that you really want to ask. > > Getting an answer starts with understanding > your own question. If you can't explicate your > question then you don't really understand what > you're asking, as well as you should. Asking > it (badly) at that point can waste your time as > well as that of others. > ___ > > Elisp manual menu, node `Functions': > > 13 Functions > ************ > > A Lisp program is composed mainly of Lisp functions. This chapter > explains what functions are, how they accept arguments, and how to > define them. > > * Menu: > > * What Is a Function:: Lisp functions vs. primitives; terminolog= y. > * Lambda Expressions:: How functions are expressed as Lisp objec= ts. > * Function Names:: A symbol can serve as the name of a funct= ion. > * Defining Functions:: Lisp expressions for defining functions. > * Calling Functions:: How to use an existing function. > * Mapping Functions:: Applying a function to each element of a = list, etc. > * Anonymous Functions:: Lambda expressions are functions with no = names. > * Generic Functions:: Polymorphism, Emacs-style. > * Function Cells:: Accessing or setting the function definit= ion > of a symbol. > * Closures:: Functions that enclose a lexical environm= ent. > * Advising Functions:: Adding to the definition of a function. > * Obsolete Functions:: Declaring functions obsolete. > * Inline Functions:: Functions that the compiler will expand i= nline. > * Declare Form:: Adding additional information about a fun= ction. > * Declaring Functions:: Telling the compiler that a function is d= efined. > * Function Safety:: Determining whether a function is safe to= call. > * Related Topics:: Cross-references to specific Lisp primiti= ves > that have a special bearing on how functions work. > ___ > > Elisp manual `Index', entries starting with > "function" (all with completion from `i'): > > * funcall: Calling Functions. (line 22) > * funcall <1>: Module Misc. (line 56) > * funcall, and debugging: Internals of Debugger. > (line 86) > * funcall-interactively: Interactive Call. (line 73) > * function: Anonymous Functions. (line 39) > * function aliases: Defining Functions. (line 53) > * function call: Function Forms. (line 6) > * function call debugging: Function Debugging. (line 6) > * function cell: Symbol Components. (line 16) > * function cell in autoload: Autoload. (line 70) > * function declaration: Declaring Functions. (line 6) > * function definition: Function Names. (line 6) > * function descriptions: A Sample Function Description. > (line 6) > * function form evaluation: Function Forms. (line 6) > * function input stream: Input Streams. (line 26) > * function invocation: Calling Functions. (line 6) > * function keys: Function Keys. (line 6) > * function name: Function Names. (line 6) > * function not known to be defined, compilation warning: Compiler Errors. > (line 21) > * function output stream: Output Streams. (line 24) > * function quoting: Anonymous Functions. (line 40) > * function safety: Function Safety. (line 6) > * function-documentation property: Documentation Basics. > (line 12) > * function-get: Symbol Plists. (line 58) > * function-put: Symbol Plists. (line 68) > * functionals: Calling Functions. (line 107) > * functionp: What Is a Function. (line 95) > * functions in modes: Major Mode Conventions. > (line 55) > * functions, making them interactive: Defining Commands. (line 6) > ___ > > Someone has gone to a lot of trouble to lay > out for you the answers to your questions. > You just need to learn how to _Ask Emacs_. > And then try your best to do that. >