[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Wrong comment character when adding file local variables?
From: |
Nick Dokos |
Subject: |
Re: [O] Wrong comment character when adding file local variables? |
Date: |
Sat, 08 Jun 2013 03:47:48 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
Rainer M Krug <address@hidden> 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