emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Antero Mejr <antero@mailbox.org>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Move files when using org-babel-tangle-publish
Date: Fri, 08 Dec 2023 21:36:04 +0000	[thread overview]
Message-ID: <871qbwcr7f.fsf@localhost> (raw)
In-Reply-To: <87bkbsgx68.fsf@mailbox.org>

Antero Mejr <antero@mailbox.org> writes:

> When publishing using org-babel-tangle-publish to the same directory
> that contains the org files, copy-file will signal an error, since the
> source and destination files refer to the same file. So use rename-file
> instead.
>
> When publishing to a different directory, this change also cleans up the
> old files, which matches the behavior of the other publishing functions
> like org-html-publish-to-html.

Thanks for the patch!
May you please submit a patch against Org mode git repository -
https://git.savannah.gnu.org/cgit/emacs/org-mode.git, as described at
https://orgmode.org/worg/org-contribute.html ?

Also, may I know if you have an FSF copyright assignment? If not, you
also need to add TINYCHANGE to the commit message - see
https://orgmode.org/worg/org-contribute.html#first-patch

> Fixes copy-file error when publishing to the current directory.
> Don't leave behind the old tangled files when publishing.
>
> * lisp/org/ob-tangle.el (org-babel-tangle-publish): Use rename-file
> instead of copy-file on tangled files.

Please quote `rename-file' and `copy-file' like I do - it is our commit
message convention (https://orgmode.org/worg/org-contribute.html#orgd7441de)

> -  (mapc (lambda (el) (copy-file el pub-dir t)) (org-babel-tangle-file filename)))
> +  (mapc (lambda (el) (rename-file el pub-dir t))
> +        (org-babel-tangle-file filename)))

I think that it would be nice to add a brief comment why `rename-file'
to the code as well.  `copy-file' looks innocent there from a first
glance.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
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>


  reply	other threads:[~2023-12-08 21:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-17 16:30 [PATCH] Move files when using org-babel-tangle-publish Antero Mejr
2023-12-08 21:36 ` Ihor Radchenko [this message]
2023-12-08 23:08   ` Antero Mejr
2023-12-09 10:29     ` Ihor Radchenko
2023-12-09 17:42       ` Bastien Guerry

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=871qbwcr7f.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=antero@mailbox.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).