From: Dan Davison <dandavison7@gmail.com>
To: lists@manor-farm.org
Cc: Org Mode Mailing List <emacs-orgmode@gnu.org>
Subject: Re: [babel] After Tangle Change File Permission
Date: Wed, 09 Feb 2011 10:18:19 +0000 [thread overview]
Message-ID: <m1oc6l1pg4.fsf@94.196.91.150.threembb.co.uk> (raw)
In-Reply-To: <4D525B84.9060206@manor-farm.org> (Ian Barton's message of "Wed, 09 Feb 2011 09:16:52 +0000")
Ian Barton <lists@manor-farm.org> writes:
> I am starting to use babel to maintain my collection of shell
> scripts. I want to automate the process as much as possible, so I
> would like to be able to set the execute bit on my tangled .sh scripts
> after the tangle process.
>
> I see that there is an after-tangle hook. Can anyone give me some
> hints as to how I might use this to execute a chmod *.sh on the
> directory containing my tangles shell scripts.
Hi Ian,
It looks like Eric has already implemented this particular case in a
different way: if the :shebang header arg is set, then the file will be
made executable. E.g. :shebang #!/bin/bash.
However, to use the hook function, does something like this not work?
#+begin_src emacs-lisp
(defun dan/make-tangled-shell-files-executable () (shell-command "chmod +x *.sh"))
(add-hook 'org-babel-post-tangle-hook 'dan/make-tangled-shell-files-executable)
#+end_src
I admit I was getting some inconsistent results just then that I didn't
understand. It should be possible to use
#+begin_src emacs-lisp
(add-hook 'org-babel-post-tangle-hook
'dan/make-tangled-shell-files-executable nil 'local)
#+end_src
so that the hook is set locally for the buffer in question.
The code is
#+begin_src emacs-lisp
(when org-babel-post-tangle-hook
(mapc
(lambda (file)
(org-babel-with-temp-filebuffer file
(run-hooks 'org-babel-post-tangle-hook)))
path-collector))
#+end_src
, where `path-collector' is a list of tangled files. I believe that this
implies that, each time the hook is run, default-directory will be equal
to the directory containing the file in question, so the shell-command
should run in that directory. Otoh, the above shows that the hook is run
for each tangled file, so chmod +x *.sh would be executed more times
than necessary.
Dan
>
> Ian.
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
next prev parent reply other threads:[~2011-02-09 10:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-09 9:16 [babel] After Tangle Change File Permission Ian Barton
2011-02-09 9:57 ` Rainer M Krug
2011-02-09 10:18 ` Dan Davison [this message]
2011-02-10 1:10 ` Eric Schulte
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=m1oc6l1pg4.fsf@94.196.91.150.threembb.co.uk \
--to=dandavison7@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=lists@manor-farm.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).