emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Dokos <ndokos@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Wrong comment character when adding file local variables?
Date: Sat, 08 Jun 2013 03:47:48 -0400	[thread overview]
Message-ID: <87sj0tjb6j.fsf@pierrot.dokosmarshall.org> (raw)
In-Reply-To: CAGhLh6Gsp0a-ghjsKejAfT1E=QgqztyCMzHj9nLp0TKaPjU0EA@mail.gmail.com

Rainer M Krug <r.m.krug@gmail.com> 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

      parent reply	other threads:[~2013-06-08  7:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-07 13:12 Wrong comment character when adding file local variables? Rainer M Krug
2013-06-07 13:48 ` Vitalie Spinu
2013-06-07 15:40   ` Rainer M Krug
2013-06-07 16:48     ` Vitalie Spinu
2013-06-10  8:27       ` Rainer M Krug
2013-06-10 13:19         ` Nick Dokos
2013-06-10 14:55           ` Rainer M Krug
2013-06-08  7:47     ` Nick Dokos [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sj0tjb6j.fsf@pierrot.dokosmarshall.org \
    --to=ndokos@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).