From: Gilles Marait <gilles.marait@inria.fr>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>,
emmanuel agullo <emmanuel.agullo@inria.fr>
Subject: Re: Change behavior of "org-babel-tangle-publish" from org 9.6 to 9.7 -- deleting source files and not tangling properly
Date: Thu, 19 Dec 2024 14:15:35 +0100 (CET) [thread overview]
Message-ID: <1991176959.2790668.1734614135886.JavaMail.zimbra@inria.fr> (raw)
In-Reply-To: <877c819hjz.fsf@localhost>
[-- Attachment #1: Type: text/plain, Size: 1575 bytes --]
Hello Ihor,
Yes, it works perfectly.
Thank you very much for the patch. I don't think I would have been able
to do it properly with my limited knowledge of elisp.
Gilles
----- Mail original -----
> De: "Ihor Radchenko" <yantar92@posteo.net>
> À: "Gilles Marait" <gilles.marait@inria.fr>
> Cc: "emacs-orgmode" <emacs-orgmode@gnu.org>, "emmanuel agullo" <emmanuel.agullo@inria.fr>
> Envoyé: Dimanche 15 Décembre 2024 14:55:44
> Objet: Re: Change behavior of "org-babel-tangle-publish" from org 9.6 to 9.7 -- deleting source files and not tangling
> properly
> Ihor Radchenko <yantar92@posteo.net> writes:
>
>> IMHO, it makes more sense to preserve _and also document_ (in the
>> docstring) the old behavior. We just need to make sure that the bug
>> fixed in 478576749d does not re-surface - when publishing directory is
>> "." the old code failed trying to copy tangled file into self.
>>
>> I think that we can simply call `org-publish-attachment' on every
>> tangled file in `org-babel-tangle-publish' - `org-publish-attachment'
>> takes care about the situation when the tangled file is already in the
>> publishing dir.
>
> Gilles, may you please check if the attached patch works for you?
>
>
>
> [Documents
> texte:0001-org-babel-tangle-publish-Keep-the-original-tangled-f.patch]
>
>
> --
> 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>
[-- Attachment #2: Type: text/x-patch, Size: 1935 bytes --]
From 778a29dcc64e7f400f94145adf01dca67f5588f4 Mon Sep 17 00:00:00 2001
Message-ID: <778a29dcc64e7f400f94145adf01dca67f5588f4.1734270889.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Sun, 15 Dec 2024 14:52:39 +0100
Subject: [PATCH] org-babel-tangle-publish: Keep the original tangled files
* lisp/ob-tangle.el (org-babel-tangle-publish): When publishing
tangled files, do not remove the original versions of these files.
Keeping was the old behaviour that some users relied upon. Removing
the tangled files may also be unexpected when they were tangled
outside publishing, during normal user workflows. Update the
docstring to explicitly state that the tangled files are copied.
Reported-by: Gilles Marait <gilles.marait@inria.fr>
Link: https://orgmode.org/list/878qvtkwhn.fsf@localhost
---
lisp/ob-tangle.el | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index fe143b039f..9554a3226d 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -227,13 +227,11 @@ (defun org-babel-tangle-file (file &optional target-file lang-re)
(org-babel-tangle nil target-file lang-re)))))
(defun org-babel-tangle-publish (_ filename pub-dir)
- "Tangle FILENAME and place the results in PUB-DIR."
- (unless (file-exists-p pub-dir)
- (make-directory pub-dir t))
- (setq pub-dir (file-name-as-directory pub-dir))
- ;; Rename files to avoid copying to same file when publishing to ./
- ;; `copy-file' would throw an error when copying file to self.
- (mapc (lambda (el) (rename-file el pub-dir t))
+ "Tangle FILENAME and copy the tangled file to PUB-DIR."
+ (require 'ox-publish)
+ (declare-function org-publish-attachment "ox-publish"
+ (plist filename pub-dir))
+ (mapc (lambda (el) (org-publish-attachment nil el pub-dir))
(org-babel-tangle-file filename)))
;;;###autoload
--
2.47.1
next prev parent reply other threads:[~2024-12-19 13:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-02 14:52 Change behavior of "org-babel-tangle-publish" from org 9.6 to 9.7 -- deleting source files and not tangling properly Gilles Marait
2024-09-09 17:40 ` Ihor Radchenko
2024-09-10 8:49 ` Gilles Marait
2024-09-15 11:05 ` Ihor Radchenko
2024-12-15 13:55 ` Ihor Radchenko
2024-12-19 13:15 ` Gilles Marait [this message]
2024-12-21 9:41 ` Ihor Radchenko
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=1991176959.2790668.1734614135886.JavaMail.zimbra@inria.fr \
--to=gilles.marait@inria.fr \
--cc=emacs-orgmode@gnu.org \
--cc=emmanuel.agullo@inria.fr \
--cc=yantar92@posteo.net \
/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.