help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

running function in hook dependent on value of a variable


From: Rainer M Krug
Subject: running function in hook dependent on value of a variable
Date: Thu, 13 Jun 2013 16:26:45 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Hi

I want to run a function in a hook only if the value of a variable is
non-nil. I have gotten that far with my less then rudimentary lisp knowledge:

,----
| (defvar org-babel-tangle-run-postTangleScript nil
|   "If non-nil, postTangleScript.sh will be executed")
| (put 'org-babel-tangle-run-postTangleScript 'safe-local-variable 'booleanp)
| 
| (defun org-babel-run-post-tangle-script ()
|   (if org-babel-tangle-run-postTangleScript
|       (       (message "running the postTangleScript.sh bash shell script")
|       (shell-command "bash ./postTangleScript.sh"))))
| 
| (add-hook 'org-babel-post-tangle-hook 'org-babel-run-post-tangle-script)
`----

But something is wrong with the function, as it does not work. 

Any suggestions?

The idea is to be able to enable and disable the execution of this
postTangleScript.sh file on a per-file-basis using file-local-variables.

Ultimately, I would like to be able to execute a script whose name is
stored in the variable org-babel-tangle-run-postTangleScript and not
hardcoded. 

Also, if the variable and the function should follow a certain naming
convention, please let me know.

Thanks,

Rainer

-- 
Rainer M. Krug

email: RMKrug<at>gmail<dot>com

Attachment: pgp4WVwXFFlAw.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]