emacs-orgmode
[Top][All Lists]
Advanced

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

[O] SOLVED: Automatically adding local variables to tangled file


From: Rainer M Krug
Subject: [O] SOLVED: Automatically adding local variables to tangled file
Date: Mon, 10 Jun 2013 13:32:50 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Eric Schulte <address@hidden> writes:

[snip (41 lines)]

>>> He added the following to his config file to test the approach:
>>> 
>>> ,----
>>> |  (defvar org-babel-tangled-file nil
>>> |      "If non-nill, current file was tangled with org-babel-tangle")
>>> |    (put 'org-babel-tangled-file 'safe-local-variable 'booleanp)
>>> |    
>>> |    (defun org-babel-mark-file-as-tangled ()
>>> |      (add-file-local-variable 'org-babel-tangled-file t)
>>> |      (basic-save-buffer))
>>> | 
>>> |    (add-hook 'org-babel-post-tangle-hook 'org-babel-mark-file-as-tangled)
>>> `----
>>> 

[snip (5 lines)]


I tried the above approach, but I was struggling with setting up the
rules in the function definition which files should get the local
variables and which not.

I ended up with the following:

,----
| (defvar org-babel-tangled-file nil
|   "If non-nill, current file was tangled with org-babel-tangle")
| (put 'org-babel-tangled-file 'safe-local-variable 'booleanp)
| 
| (defun org-babel-mark-file-as-tangled ()
|   
|   (when  (string-match "[.]R" (buffer-file-name))
|       (add-file-local-variable 'org-babel-tangled-file t)
|     (add-file-local-variable 'buffer-read-only t)
|     ;; (add-file-local-variable 'eval: (auto-revert-mode))
|     (basic-save-buffer)))
| 
| (add-hook 'org-babel-post-tangle-hook 'org-babel-mark-file-as-tangled)
`----

Thanks everybody for their help,

Rainer



>

-- 
Rainer M. Krug

email: RMKrug<at>gmail<dot>com

Attachment: pgpxKsNqlBMkq.pgp
Description: PGP signature


reply via email to

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