emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Joost Kremers <joostkremers@fastmail.fm>
To: "Thomas S. Dye" <tsd@tsdye.online>
Cc: emacs-orgmode@gnu.org
Subject: Re: Babel Forth
Date: Thu, 23 Jan 2025 09:16:19 +0100	[thread overview]
Message-ID: <86v7u6gd2k.fsf@fastmail.fm> (raw)
In-Reply-To: <874j1qlgxe.fsf@tsdye.online> (Thomas S. Dye's message of "Wed, 22 Jan 2025 10:41:49 -1000")

On Wed, Jan 22 2025, Thomas S. Dye wrote:
> Aloha all,
>
> I'm drafting ob-doc-forth.org and haven't been able to get ob-forth.el to
> recognize a working GForth in Spacemacs.  I get "Symbol's function
> definition is void: forth-proc" when I evaluate a Forth source block.
>
> In ob-forth.el there is this: (declare-function forth-proc "ext:gforth" ())
>
> My hunch is that the ext: part of ext:gforth expects that forth-mode is
> setup to use the forth-mode distributed with GForth.

No. `declare-function` doesn't do anything except silence the
byte-compiler. It's used when you use a function in your Elisp source that
may not be loaded into your running Emacs session while editing the .el
file. In such a case, the byte compiler cannot find the function, so it
issues a warning. With `declare-function`, you tell the byte compiler where
to look for the function. The prefix "ext:" indicates that the file is an
external file (i.e., doesn't come with Emacs), so it may not even be found
at all, and that if that happens, the byte compiler still shouldn't complain.

The important thing to note is that `declare-function` doesn't make the
function available for *running* the code, it really is meant *just* for
the byte compiler. To make sure `gforth.el` is loaded, you need to use a
`require` in your source code.

> Spacemacs appears to
> use forth-mode from Elpa, instead, and I find forth-mode.el in the elpa
> subdirectory of my Spacemacs.

The `declare-function` call says that `forth-proc` can be found in
`gforth.el`, so the fact that you have `forth-mode.el` installed is
(probably) irrelevant. What you need is the file `gforth.el`. Where it
comes from is irrelevant, it just needs to be on Emacs' `load-path`. (And
it needs to actually provide `forth-proc`, of course, and make it
autoloadable, but I assume that's the case.)

What I don't understand, though, is why there's no `(require 'gforth)` in
`ob-forth.el`. It seems that `forth-proc` is essential for running Forth
source blocks, so a `require` seems in order.

The point is that `declare-function` is usually only used to declare
functions that are optional, meaning that `ob-forth.el` should check if
it's available and gracefully handle the case where it's not.

> What is the best way forward here?

What does the documentation for `ob-forth.el` say? Does it say `gforth.el`
needs to be installed? Otherwise perhaps ask the Org mailing list or the
ob-forth maintainer directly?

-- 
Joost Kremers
Life has its moments


  reply	other threads:[~2025-01-23  8:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-22 20:41 Babel Forth Thomas S. Dye
2025-01-23  8:16 ` Joost Kremers [this message]
2025-01-23  8:22   ` Joost Kremers

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

  List information: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to=86v7u6gd2k.fsf@fastmail.fm \
    --to=joostkremers@fastmail.fm \
    --cc=emacs-orgmode@gnu.org \
    --cc=tsd@tsdye.online \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).