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: Barry Margolin
Subject: Re: running function in hook dependent on value of a variable
Date: Thu, 13 Jun 2013 11:18:11 -0400
User-agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)

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"))))

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


reply via email to

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