From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rainer M Krug Subject: SOLVED: Automatically adding local variables to tangled file Date: Mon, 10 Jun 2013 13:32:50 +0200 Message-ID: <87y5aifbfh.fsf_-_@krugs.de> References: <878v2omz5g.fsf@krugs.de> <51af4bfd.0c95ec0a.2372.097e@mx.google.com> <87ehcf6xey.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36056) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Um0La-0008O4-2U for emacs-orgmode@gnu.org; Mon, 10 Jun 2013 07:33:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Um0LY-0001fa-BF for emacs-orgmode@gnu.org; Mon, 10 Jun 2013 07:33:13 -0400 Received: from plane.gmane.org ([80.91.229.3]:46482) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Um0LY-0001fH-4p for emacs-orgmode@gnu.org; Mon, 10 Jun 2013 07:33:12 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Um0LU-0006sI-Md for emacs-orgmode@gnu.org; Mon, 10 Jun 2013 13:33:08 +0200 Received: from arn78-1-88-186-171-7.fbx.proxad.net ([88.186.171.7]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 10 Jun 2013 13:33:08 +0200 Received: from Rainer by arn78-1-88-186-171-7.fbx.proxad.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 10 Jun 2013 13:33:08 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Eric Schulte writes: [snip (41 lines)] >>> He added the following to his config file to test the approach: >>>=20 >>> ,---- >>> | (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) >>> |=20=20=20=20 >>> | (defun org-babel-mark-file-as-tangled () >>> | (add-file-local-variable 'org-babel-tangled-file t) >>> | (basic-save-buffer)) >>> |=20 >>> | (add-hook 'org-babel-post-tangle-hook 'org-babel-mark-file-as-tang= led) >>> `---- >>>=20 [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) |=20 | (defun org-babel-mark-file-as-tangled () |=20=20=20 | (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))) |=20 | (add-hook 'org-babel-post-tangle-hook 'org-babel-mark-file-as-tangled) `---- Thanks everybody for their help, Rainer > =2D-=20 Rainer M. Krug email: RMKruggmailcom --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQEcBAEBAgAGBQJRtbliAAoJENvXNx4PUvmCEJwH/jQnFIwsQiyqr/EkR6Zlh73u X6JulTwFD7eOvWitiMwc3B/Vz0ykUaPSszczCeP1Fv926QJQ/aoMYcosvb4i62IZ 8V5nk+y8n2lLCGx0lF8/mWBZIRPCkbtxACQAX/kDDUnpvCdgJNU8pXytrwffZtsm AP6wLrrDntDE0k7IBzJDuVg6NhUZhskxIPV2dQetQuY/4O0XZWT9me/ohBe8d4XN w80N8qrcOHKs+XGt35G+vKMb8Eg4tP5cXhtlxq+2xs2BtCU+hhKVM9Px8JP290+s 4pKHGiaKd3kI9a9gLwm0pCfDM6CmocOUvhewlguYNT2/ZH5v/2MfSoXE9wrzR6s= =Utp7 -----END PGP SIGNATURE----- --=-=-=--