From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Wrong comment character when adding file local variables? Date: Sat, 08 Jun 2013 03:47:48 -0400 Message-ID: <87sj0tjb6j.fsf@pierrot.dokosmarshall.org> References: <87wqq6gj39.fsf@krugs.de> <87y5amdoae.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59502) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UlDsY-00019A-Iq for emacs-orgmode@gnu.org; Sat, 08 Jun 2013 03:48:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UlDsX-00041R-9W for emacs-orgmode@gnu.org; Sat, 08 Jun 2013 03:48:02 -0400 Received: from plane.gmane.org ([80.91.229.3]:51226) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UlDsX-00040S-3a for emacs-orgmode@gnu.org; Sat, 08 Jun 2013 03:48:01 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UlDsV-0002Wo-Rc for emacs-orgmode@gnu.org; Sat, 08 Jun 2013 09:47:59 +0200 Received: from pool-108-7-96-134.bstnma.fios.verizon.net ([108.7.96.134]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 08 Jun 2013 09:47:59 +0200 Received: from ndokos by pool-108-7-96-134.bstnma.fios.verizon.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 08 Jun 2013 09:47:59 +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 Rainer M Krug writes: > On Friday, June 7, 2013, Vitalie Spinu wrote: > > All your examples are placed in fundamental mode. The comments are > treated by org and thus are correct, local variables are inserted > according to the major mode. > > The question is why - all .R files are automatically in r mode when I > open them and all other R files tangle fine. > That's because the auto-mode-alist tells emacs that .R files should be in R-mode, so after emacs opens the file, it calls the R-mode function. > I don't how this could be easily fixed on org side, but you can > solve it straightforwardly with: > > (add-to-list 'auto-mode-alist (cons "NAME\\|DESC" 'R-mode)) > > Ok - I'check it out on Monday. > That's one way: it's got its downside in that the names have to match, so you have to remember to modify the auto-mode-alist when you use different names when tangling. Another way is to modify the function below: > > I use the following in my .emacs file to set the > > post-tangle-hook to add the local file variables: > > > ,---- > > | (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 () (R-mode) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< > > | (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) > > `---- > > to call R-mode explicitly. That's got its own downside: all your tangled files are going to be in R-mode. The point is that you have to tell emacs somehow what you are doing: it can't guess that you are producing R-mode files without some help. -- Nick