[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [BUG] Cannot tangle src block in capture buffer [9.7.6]
From: |
Ihor Radchenko |
Subject: |
Re: [BUG] Cannot tangle src block in capture buffer [9.7.6] |
Date: |
Sun, 12 Jan 2025 16:45:33 +0000 |
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>
- Re: [BUG] Cannot tangle src block in capture buffer [9.7.6], Derek Chen-Becker, 2025/01/10
- Re: [BUG] Cannot tangle src block in capture buffer [9.7.6], Ihor Radchenko, 2025/01/11
- Re: [BUG] Cannot tangle src block in capture buffer [9.7.6], Derek Chen-Becker, 2025/01/12
- Re: [BUG] Cannot tangle src block in capture buffer [9.7.6],
Ihor Radchenko <=
- Re: [BUG] Cannot tangle src block in capture buffer [9.7.6], Derek Chen-Becker, 2025/01/12
- Re: [BUG] Cannot tangle src block in capture buffer [9.7.6], Ihor Radchenko, 2025/01/13
- Re: [BUG] Cannot tangle src block in capture buffer [9.7.6], Derek Chen-Becker, 2025/01/13
- Re: [BUG] Cannot tangle src block in capture buffer [9.7.6], Ihor Radchenko, 2025/01/14
- Re: [BUG] Cannot tangle src block in capture buffer [9.7.6], Derek Chen-Becker, 2025/01/14
- Re: [BUG] Cannot tangle src block in capture buffer [9.7.6], Derek Chen-Becker, 2025/01/15
- Re: [BUG] Cannot tangle src block in capture buffer [9.7.6], Ihor Radchenko, 2025/01/15
- Re: [BUG] Cannot tangle src block in capture buffer [9.7.6], Derek Chen-Becker, 2025/01/16
- Re: [BUG] Cannot tangle src block in capture buffer [9.7.6], Ihor Radchenko, 2025/01/16
- Re: [BUG] Cannot tangle src block in capture buffer [9.7.6], Derek Chen-Becker, 2025/01/18