with this line in a file i'm tangling:
#+BEGIN_SRC shell :tangle ./tangle/aux.0 :comments link :paddling no
on tangling, this prompt appears:
"No comment syntax is define. Use: [ ]"
What needs to be set, or text entered in the source file to avoid the prompt?
I've tried:
# <<example>>
or
#
on the first line.
or ... comment-syntax #
after the ":comments link"
and searched the help for examples.
I'm reading the Org Manual, and emacs help, and not finding any specific instructions.
I believe your problem is because emacs cannot determine/recognise the correct mode for the exported source. As it does not recognise the mode, it cannot determine the correct comment character.
According the the org manual, the correct identifier for shell blocks is sh not shell. Try changing your line to
#+BEGIN_SRC sh :tangle ./tangle/aux.0 :comments link :paddling no
Related
I use the Verilog mode from emacs.
My question is:
What is full syntax of command that includes verilog-library-directories ?
emacs --batch f.sv -q --eval='(setq-default verilog-typedef-regexp
".*_t$")' -f verilog-batch-auto
For including verilog libraries I use the following comment at the end of the file:
// verilog-library-flags:("-y ../rtl")
I think then you can reuse this syntax for command line.
I am using shells using UTF-8 and others using Latin-1. However, when I change the default with set-language-environment, also the existing shells change their buffer-coding-system - indicator in the status-line.
How can I make a shell-buffer stick to its encoding?
Have you tried looking at the Emacs Wiki? It has a tip on how to edit the ~/.emacs file:
Working around a broken LANG
If your LANG is not set up correctly, and you don’t want to fix it,
you can do the setup in your ~/.emacs file:
(set-language-environment "Latin-1")
Usually you would do it interactively: ‘C-x RET l’.
To check the environment you want see ‘M-x
describe-language-environment’ and TAB to see all completions.
as suggested here,
simply create a shell script such as e.g.latinshell.sh (adjust the desired variables):
#!/bin/sh
LANG=de_DE:Latin-1
and then run it in a shell with:
. latinshell.sh
*.zsh files open in the default mode (text-mode for me). However, sh-mode is actually multiple modes including behaviours for zsh, bash, etc. How can I tell emacs to open *.zsh files specifically in the zsh flavor of sh-mode?
The flavor of sh-mode is autodetected from the shebang line (first line of your script). If you have "#!/bin/zsh", zsh will be assumed and (for instance) autoload will be recognized as a keyword. autoload will be not recognized as such if first line is "#!/bin/bash"
To make emacs recognize *.zsh files as shell scripts, just add this to your init file:
(add-to-list 'auto-mode-alist '("\\.zsh\\'" . sh-mode))
A programmatic way of selecting a flavor when you don't want to use the shebang is doing this in a sh-mode buffer:
(sh-set-shell "zsh")
So in your case what you need (unless you use shebang) is to update the auto-mode-alist as above and
(add-hook 'sh-mode-hook
(lambda ()
(if (string-match "\\.zsh$" buffer-file-name)
(sh-set-shell "zsh"))))
Whether your file has a #! shebang or not, you can always use a file mode line or a local variables section to set shell-script mode. Having one of these in your script will allow Emacs to do the right thing even if you haven't updated the auto-mode-alist, so is recommended for any non-standard file extension.
The Emacs file mode line for shell scripts is -*- mode: sh -*-. It should be in a comment, and must appear on the first line (or the second line if the first one is a shebang line).
If you can't put it on the first (second) line for some reason, you can create a local variables section at the end of the file (in the last 3000 characters of the file, and on the last page, according to the manual):
# Local Variables:
# mode: sh
# End:
Note that just setting the Emacs mode will still rely on a shebang line for shell type autodetection, and if no shebang line is detected will default to the current SHELL environment variable or the value of sh-shell-file if set).
If you can't have a shebang line, but want the correct shell type to be selected, the only way to do this is with an eval in the mode line or local variables section. Adding this will generate a confirmation prompt every time the file is loaded into Emacs, so this is not generally recommended, but may be acceptable in some cases.
The mode line would be -*- mode: sh; eval: (sh-set-shell "zsh") -*-, and the local variables form would be:
# Local Variables:
# mode: sh
# eval: (sh-set-shell "zsh")
# End:
If you use the shebang method, a more robust form is
#!/usr/bin/env zsh
# env will search the path for zsh. Some distros may put it a different place.
# env is pretty much guaranteed to be in /usr/bin
I know that emacs can recognize a file by the extension, a -*- mode -*- first line, and even by the shebang line, but what do I do if I want to override the shebang?
For example, a script that starts with
#!/usr/bin/env python2.7
...
won't be recognized by the shebang line alone. I also can't add in a -*-python-*- line, because then the shell tries to parse it. How do I deal with this?
You put the -*- mode: python -*- in the second line (special exception, added specifically for the shebang thingies).
You can try putting something like
(add-to-list 'interpreter-mode-alist '("python2.7" . python-mode))
in your .emacs. See “Choosing File Modes” for more info.
Like this:
#!/usr/bin/env python2.7
print "test"
# Local Variables:
# mode: python
# End:
This information comes from Specifying File Variables node of info.
Use f1 i to enter info.
Use g (emacs) to jump to emacs info.
Use g Specifying File Variables to jump to the page.
You can use tab to complete node names.
I'm using GNU/Linux distro (Arch, if that's relevant), Emacs v23.2.1, ESS v5.9 and AucTeX v11.86.
I want to setup AucTeX to recognize .Rnw files, so I can run LaTeX on .Rnw files with C-c C-c and get .dvi file automatically. I reckon it's quite manageable by editing .emacs file, but I still haven't got a firm grasp on Elisp.
Yet another problem is quite annoying - somehow, LaTeX is not recognizing \usepackage{Sweave} in preambule, so I actually need to copy Sweave.sty file (in my case located in /usr/share/R/texmf/Sweave.sty) to directory where .Rnw file is located (and I'm becoming more frustrated by the fact that this is common bug on Windows platforms!)
My question boils down to two problems:
how to make LaTeX recognize \usepackage{Sweave} (without copying Sweave.sty to "home" folder each time) [Edit: managed to do this; see comment after Dirk's answer]
how to setup AucTeX to compile .Rnw files to .dvi
That's two different questions.
For the first one, my Debian R packages make sure that there is a soft link from the $RHOME/share/texmf/ directory into the TeX file system tree, e.g. as /usr/share/texmf/tex/latex/R.
For the second question: dunno. I tend to run Sweave via a small shell script I crafted years ago even though I do all the editing in Emacs.
Edit, a few months later: Use ESS, rather than AucTeX. Then M-n s (i.e Alt-n followed by s) runs the Sweave step and M-n P runs the LaTeX compilation, with a call to Bibtex if needed.
After brief and efficient Googling, I've found this link, and at first glance, everything seems OK, but pdf file gets garbled after Sweaving... So I tackled this problem another way around: when in doubt, go bash! I've shamelessly stolen error checking function from Dirk's Sweave bash script available here. Basically, this is a workaround: R CMD Sweave gets executed on .Rnw file, hence latex comes in, and pdflatex after that...
I'll post a bash script that does the job for me. I must state that I'm not an advanced bash programmer, moreover I'm not even a programmer by vocation, so there's a great chance that this script can be optimized/written properly. Here goes:
#!/bin/bash
FILEBASE=${1%.*}
FILEXT=${1##*.}
FILEPATH=${1%/*}
TEXFILE=$FILEBASE.tex
PDFFILE=$FILEBASE.pdf
# errorexit
function errorexit () {
echo "Error: $1"
exit 1
}
# check if file exists
if [ ! -f $1 ]; then
errorexit "File $1 not found!"
else
# check for filename length
if [ ${#1} -lt 1 ]; then
errorexit "Need to specify argument file!"
else
# if filelength OK, check extension
if [ $FILEXT != "Rnw" ]; then
errorexit "You must pass Sweave (.Rnw) file!"
# finally, run Sweave
else
cd $FILEPATH && R CMD Sweave $1
# latex $TEXFILE
pdflatex $TEXFILE
# xdg-open $PDFFILE
fi
fi
fi
Then save/copy/move this script in any of echo $PATH folders (I keep mine in /usr/bin/), and make sure that it's named sweave, or choose whatever name you like, then put these lines in your .emacs file:
(global-set-key (kbd "C-c s")
(lambda ()
(interactive)
(shell-command (concat "sweave " buffer-file-name))))
Of course, you can change keybinding to suite your needs, and be sure to change sweave with script name placed in /usr/bin/.
Bare in mind that this is not an answer, but a workaround. If you have found a way to deal with AucTeX/ESS/Sweave integration, post it, and I'll give it a checkmark.
Prior to this workaround, I had to do M-n s to Sweave, followed by C-c C-c which is default keybind in AucTeX for LaTeX file compilation. Produced file is erroneous, so I had to give it a try with bash. It works for me, if you have any suggestions, please let me know.
Kind regards,
aL3xa
EDIT:
Inserted cd $FILEPATH