From: Ihor Radchenko <yantar92@posteo.net>
To: Derek Chen-Becker <derek@chen-becker.org>
Cc: emacs-orgmode@gnu.org
Subject: Re: [BUG] Cannot tangle src block in capture buffer [9.7.6]
Date: Sun, 12 Jan 2025 16:45:33 +0000 [thread overview]
Message-ID: <87sepox9oy.fsf@localhost> (raw)
In-Reply-To: <CAMbmz5n4QqAkUQ8yN7z6on4QRmJvTrrr7mx0Zk+XhZ8_P+DBiA@mail.gmail.com>
Derek Chen-Becker <derek@chen-becker.org> writes:
> OK, I've attached the patch. It wasn't clear from
> https://orgmode.org/worg/org-contribute.html#first-patch whether this
> should be sent in the thread or as a new thread. I can start a new one if
> needed.
Thanks!
The same thread is the right place - we want everything related to the
same bug report discussed in the same thread.
Also, see https://orgmode.org/worg/org-contribute.html#fixbug
> +(defun org-base-buffer-file-name (&optional BUFFER)
> + "Resolve the base file name for the provided BUFFER.
> +If BUFFER is not provided, default to the current buffer. If
> +BUFFER does not have a file name associated with it (e.g. a
> +transient buffer) then return nil."
> + (buffer-file-name (buffer-base-buffer BUFFER)))
What if BUFFER is provided, but that buffer is already a base buffer?
Your function will then return file name for _current buffer_, not BUFFER.
Also, what about other places in the code that use `buffer-file-name'?
We may want to use the new function there as well.
> +** Keep test artifacts
> +
> +Set the ~TEST_NO_AUTOCLEAN~ variable to leave the test directory
> +around for inspection.
Thanks for helping to improve the documentation here, but may you (1)
sepearate it into a new patch (this change is not relevant to
`buffer-file-name' bug); (2) maybe give an example of how to set
TEST_NO_AUTOCLEAN.
> +;; See https://list.orgmode.org/87msfxd81c.fsf@localhost/T/#t
> +(ert-deftest ob-tangle/tangle-from-capture-buffer ()
> + "Test tangling of source blocks from within a capture buffer.
> +This is to ensure that we properly resolve the buffer name."
> + (org-test-with-temp-text-in-file
> + "* Header\n\nCapture after this point:\n<point>"
> + (should
> + (progn
> + (let ((org-capture-templates '(("t" "Test" entry (here) "* Test Header\n\n"))))
> + (org-capture nil "t")
> + (goto-char (point-max))
> + (insert "
> +#+begin_src elisp :tangle yes :comments org
> + (message \"FOO\")
> +#+end_src")
> + (search-backward "message")
> + (org-babel-tangle 4))))))
This will leave the tangled file lying around.
Please explicitly remove it via
(unwind-protect ...
(delete-file <tangled-file-name>)
See how `org-test-with-temp-text-in-file' macro does it.
--
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
next prev parent reply other threads:[~2025-01-12 16:44 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-26 16:29 [BUG] Cannot tangle src block in capture buffer [9.7.6] Dilip
2024-08-05 14:03 ` Ihor Radchenko
2024-12-16 3:26 ` Derek Chen-Becker
2024-12-16 17:39 ` Ihor Radchenko
2024-12-19 17:56 ` Derek Chen-Becker
2024-12-19 19:17 ` Ihor Radchenko
2024-12-23 23:36 ` Derek Chen-Becker
2024-12-24 9:14 ` Ihor Radchenko
2025-01-10 15:25 ` Derek Chen-Becker
2025-01-11 9:17 ` Ihor Radchenko
2025-01-12 15:52 ` Derek Chen-Becker
2025-01-12 16:45 ` Ihor Radchenko [this message]
2025-01-12 22:24 ` Derek Chen-Becker
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=87sepox9oy.fsf@localhost \
--to=yantar92@posteo.net \
--cc=derek@chen-becker.org \
--cc=emacs-orgmode@gnu.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 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).