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

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

Re: running function in hook dependent on value of a variable


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

Barry Margolin <barmar@alum.mit.edu> writes:

> In article <mailman.1558.1371133630.22516.help-gnu-emacs@gnu.org>,
>  Rainer M Krug <Rainer@krugs.de> wrote:
>
>> 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?
>
> (defun org-babel-run-post-tangle-script ()
>   (if org-babel-tangle-run-postTangleScript
>       (progn
>         (message "running the PostTangleScript.sh bash shell script")
>         (shell-command "bash ./postTangleScript.sh"))))
<#secure method=pgpmime mode=sign>

Thanks,

Rainer

-- 
Rainer M. Krug

email: RMKrug<at>gmail<dot>com




reply via email to

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