[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Losing tabs when tangling or editing
From: |
Thomas S. Dye |
Subject: |
Re: [O] Losing tabs when tangling or editing |
Date: |
Mon, 28 May 2012 02:30:58 -1000 |
Michael Hannon <address@hidden> writes:
> Greetings. I was trying to set up a little demo in which I included a
> Makefile inside a "sh" source-code block in an Org-mode file, then tangled the
> file and ran "make" on the tangled file (either in the actual shell or in
> another sh block in Org).
>
> It appears that Org is removing tabs when it tangles the file, and the lack of
> tabs causes "make" to complain.
>
> I've appended a toy example which exhibits the problem. BTW, if I edit the
> source block via C-c ' I also lose the tabs, i.e., even before tangling.
>
> Any thoughts about this?
>
> Thanks,
>
> -- Mike
Hi Mike,
I stumbled across this, too, in a somewhat different context. My
"solution" was to hard code the newlines and tabs with \n\t using an
emacs-lisp source block and (format), then evaluate to a file, rather
than tangle. I don't think it's a pretty solution, but it does work.
hth,
Tom
#+name: configure-makefile
#+header: :file Makefile
#+header: :var emacs="/Applications/Emacs-23-4.app/Contents/MacOS/Emacs"
#+header: :var init-file="init-new.el"
#+header: :var exporter="new"
#+header: :eval noexport
#+BEGIN_SRC emacs-lisp
(let ((f (file-name-sans-extension (file-name-nondirectory
(buffer-file-name))))
(g (if (string= exporter "old") "org-export-as-latex"
"org-e-latex-export-to-latex")))
(format "CC=gcc
EMACS=%s
BATCH_EMACS=$(EMACS) --batch -Q -l %s %s
all: %s.pdf
%s.tex: %s.org\n\t$(BATCH_EMACS) -f %s
%s.pdf: %s.tex\n\trm -f %s.aux\n\tif pdflatex %s.tex </dev/null; then
\\\n\t\ttrue; \\\n\telse \\\n\t\tstat=$$?; touch %s.pdf; exit $$stat;
\\\n\tfi\n\tbibtex %s\n\twhile grep \"Rerun to get\" %s.log; do \\\n\t\tif
pdflatex %s.tex </dev/null; then \\\n\t\t\ttrue; \\\n\t\telse
\\\n\t\t\tstat=$$?; touch %s.pdf; exit $$stat; \\\n\t\tfi; \\\n\tdone
%s.ps: %s.pdf\n\tpdf2ps %s.pdf
clean:\n\trm -f *.aux *.log *.dvi *.blg *.bbl *.toc *.tex *~ *.out %s.pdf
*.xml *.lot *.lof
" emacs init-file (file-name-nondirectory (buffer-file-name)) f f f g f f f
f f f f f f f f f f))
#+END_SRC
>
>
> $ cat Makefile.original
> hw: hw.cpp
> g++ -o hw hw.cpp
>
> $ grep -P "\t" Makefile.original
> hw: hw.cpp
> g++ -o hw hw.cpp
>
> $ make -f Makefile.original
> g++ -o hw hw.cpp
>
> $ ./hw
> Hello, world!
>
> $ \rm hw
>
> $ cat hw.org
> * test preservation of tabs when tangling
>
> #+BEGIN_SRC sh :tangle Makefile.tangled
>
> hw: hw.cpp
> g++ -o hw hw.cpp
>
> #+END_SRC
>
> $ make -f Makefile.tangled
> Makefile.tangled:3: *** missing separator (did you mean TAB instead of 8
> spaces?). Stop.
>
>
--
Thomas S. Dye
http://www.tsdye.com