emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [babel] tangle and Makefile
@ 2010-01-28 10:52 "Martin G. Skjæveland"
  2010-01-28 15:38 ` Dan Davison
  2010-01-28 15:47 ` sometimes we don't want org-src to remove tabs [WAS: Re: tangle and Makefile]] Dan Davison
  0 siblings, 2 replies; 6+ messages in thread
From: "Martin G. Skjæveland" @ 2010-01-28 10:52 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

I have two questions regarding org-babel-tangle and Makefile.

Running org-babel-tangle on the following file

----------------------------------start
* test

#+begin_src makefile :tangle Makefile
   test:
           echo "hello"
#+end_src
----------------------------------end

writes a file 'Makefile.' (with a period). Is it possible to have it
write to a file named 'Makefile' (without a period)?

When I use this makefile

   $make -f Makefile. test

I get

   Makefile.:4: *** missing separator (did you mean TAB instead of 8
   spaces?). Stop.

even though I used TAB and not space when editing the Makefile code. How
can I avoid TABs being converted to space?

Thanks!
Martin


Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

      http://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org-mode mailing list.
------------------------------------------------------------------------



Emacs  : GNU Emacs 23.1.50.1 (i486-pc-linux-gnu, GTK+ Version 2.18.0)
  of 2009-09-27 on palmer, modified by Debian
Package: Org-mode version 6.34trans (release_6.34c.16.ga2cf.dirty)

current state:
==============
(setq
  org-export-latex-after-initial-vars-hook '(org-beamer-after-initial-vars)
  org-metaup-hook '(org-babel-load-in-session-maybe)
  org-after-todo-state-change-hook '(org-clock-out-if-current)
  org-babel-interpreters '("makefile" "tex" "n3" "xml" "java" "python" "dot"
			  "sh" "emacs-lisp")
  org-export-latex-format-toc-function 'org-export-latex-format-toc-default
  org-export-preprocess-hook '(org-export-blocks-preprocess)
  org-tab-first-hook '(org-babel-hide-result-toggle-maybe
		      org-hide-block-toggle-maybe)
  org-src-mode-hook '(org-src-mode-configure-edit-buffer)
  org-confirm-shell-link-function 'yes-or-no-p
  org-export-first-hook '(org-beamer-initialize-open-trackers)
  org-agenda-before-write-hook '(org-agenda-add-entry-text)
  org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers
		  org-cycle-show-empty-lines
		  org-optimize-window-after-visibility-change)
  org-export-latex-classes '(("article" "\\documentclass[11pt]{article}"
			     ("\\section{%s}" . "\\section*{%s}")
			     ("\\subsection{%s}" . "\\subsection*{%s}")
			     ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
			     ("\\paragraph{%s}" . "\\paragraph*{%s}"))
			    ("book" "\\documentclass[11pt]{book}"
			     ("\\chapter{%s}" . "\\chapter*{%s}")
			     ("\\section{%s}" . "\\section*{%s}")
			     ("\\subsection{%s}" . "\\subsection*{%s}")
			     ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))
			    )

  org-export-preprocess-before-normalizing-links-hook 
'(org-remove-file-link-modifiers)
  org-use-speed-commands t
  org-mode-hook '((lambda nil
		  (org-add-hook (quote change-major-mode-hook)
		   (quote org-babel-show-result-all) (quote append)
		   (quote local))
		  )
		 org-babel-result-hide-spec org-babel-hide-all-hashes
		 #[nil "\300\301\302\303\304$\207"
		   [org-add-hook change-major-mode-hook org-show-block-all
		    append local]
		   5]
		 )
  org-ctrl-c-ctrl-c-hook '(org-babel-lob-execute-maybe 
org-babel-hash-at-point
			  org-babel-execute-src-block-maybe)
  org-confirm-elisp-link-function 'yes-or-no-p
  org-export-interblocks '((lob org-babel-exp-lob-one-liners)
			  (src org-babel-exp-inline-src-blocks))
  org-occur-hook '(org-first-headline-recenter)
  org-from-is-user-regexp "\\<Martin G\\. Skjæveland\\>"
  org-export-preprocess-before-selecting-backend-code-hook 
'(org-beamer-select-beamer-code)
  org-export-latex-final-hook '(org-beamer-amend-header org-beamer-fix-toc
			       org-beamer-auto-fragile-frames
			       org-beamer-place-default-actions-for-lists)
  org-metadown-hook '(org-babel-pop-to-session-maybe)
  org-export-blocks '((src org-babel-exp-src-blocks nil)
		     (comment org-export-blocks-format-comment t)
		     (ditaa org-export-blocks-format-ditaa nil)
		     (dot org-export-blocks-format-dot nil))
  )

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [babel] tangle and Makefile
  2010-01-28 10:52 [babel] tangle and Makefile "Martin G. Skjæveland"
@ 2010-01-28 15:38 ` Dan Davison
  2010-01-28 17:00   ` Eric Schulte
  2010-01-28 15:47 ` sometimes we don't want org-src to remove tabs [WAS: Re: tangle and Makefile]] Dan Davison
  1 sibling, 1 reply; 6+ messages in thread
From: Dan Davison @ 2010-01-28 15:38 UTC (permalink / raw)
  To: Martin G. Skjæveland; +Cc: emacs-orgmode

"Martin G. Skjæveland" <martige@ifi.uio.no> writes:

> Hi,
>
> I have two questions regarding org-babel-tangle and Makefile.
>
> Running org-babel-tangle on the following file
>
> ----------------------------------start
> * test
>
> #+begin_src makefile :tangle Makefile
>   test:
>           echo "hello"
> #+end_src
> ----------------------------------end
>
> writes a file 'Makefile.' (with a period). Is it possible to have it
> write to a file named 'Makefile' (without a period)?

Hi Martin,

I've had this problem too. Here's a patch. Eric -- can you apply if
it looks OK?

Dan

From 5c4d56a2e43a97186bf2971b6406f5fa2257130d Mon Sep 17 00:00:00 2001
From: Dan Davison <davison@stats.ox.ac.uk>
Date: Thu, 28 Jan 2010 10:23:11 -0500
Subject: [PATCH] babel: prevent trailing periods in tangled file names without extensions

---
 contrib/babel/lisp/org-babel-tangle.el |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/contrib/babel/lisp/org-babel-tangle.el b/contrib/babel/lisp/org-babel-tangle.el
index c805373..66e2c26 100644
--- a/contrib/babel/lisp/org-babel-tangle.el
+++ b/contrib/babel/lisp/org-babel-tangle.el
@@ -102,9 +102,10 @@ exported source code blocks by language."
                                      ((> (length tangle) 0) tangle))
                                     target-file))
                      (file-name (when base-name
-                                  (if (string= base-name
-                                               (file-name-sans-extension base-name))
-                                      (concat base-name "." ext) base-name))))
+                                  (if (and ext
+                                          (string= base-name
+                                                   (file-name-sans-extension base-name)))
+                                     (concat base-name "." ext) base-name))))
                 ;; ;; debugging
                 ;; (message "tangle=%S base-name=%S file-name=%S"
                 ;;          tangle base-name file-name)
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* sometimes we don't want org-src to remove tabs [WAS: Re: tangle and Makefile]]
  2010-01-28 10:52 [babel] tangle and Makefile "Martin G. Skjæveland"
  2010-01-28 15:38 ` Dan Davison
@ 2010-01-28 15:47 ` Dan Davison
  2010-01-28 18:21   ` Carsten Dominik
  1 sibling, 1 reply; 6+ messages in thread
From: Dan Davison @ 2010-01-28 15:47 UTC (permalink / raw)
  To: Martin G. Skjæveland; +Cc: emacs-orgmode, Carsten Dominik

"Martin G. Skjæveland" <martige@ifi.uio.no> writes:

> Hi,
>
> I have two questions regarding org-babel-tangle and Makefile.
>
> Running org-babel-tangle on the following file
>
> ----------------------------------start
> * test
>
> #+begin_src makefile :tangle Makefile
>   test:
>           echo "hello"
> #+end_src
> ----------------------------------end
>
[...]
> When I use this makefile
>
>   $make -f Makefile. test
>
> I get
>
>   Makefile.:4: *** missing separator (did you mean TAB instead of 8
>   spaces?). Stop.
>
> even though I used TAB and not space when editing the Makefile code. How
> can I avoid TABs being converted to space?

Hi again Martin,

This is more to do with org-mode sensu strictu (non-babel). When you
exit a code edit buffer, tabs are automatically converted to
spaces. There is an org-mode variable org-src-preserve-indentation which
already has a few different effects. Perhaps a solution is to add
not_removing_tabs to the effects of this variable, as in the patch
below. I can't think off hand what that's going to break -- anyone?

Dan


From d854544d24377434c2ace13aac45e85e42bcc7aa Mon Sep 17 00:00:00 2001
From: Dan Davison <davison@stats.ox.ac.uk>
Date: Thu, 28 Jan 2010 10:36:29 -0500
Subject: [PATCH] org-src: Don't remove tabs when org-src-preserve-indentation is non-nil

---
 lisp/org-src.el |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lisp/org-src.el b/lisp/org-src.el
index cdad99b..1d155cc 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -525,7 +525,7 @@ the language, a switch telling if the content should be in a single line."
 			   org-edit-src-content-indentation))
 	 (preserve-indentation org-src-preserve-indentation)
 	 (delta 0) code line col indent)
-    (untabify (point-min) (point-max))
+    (unless preserve-indentation (untabify (point-min) (point-max)))
     (save-excursion
       (goto-char (point-min))
       (if (looking-at "[ \t\n]*\n") (replace-match ""))
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [babel] tangle and Makefile
  2010-01-28 15:38 ` Dan Davison
@ 2010-01-28 17:00   ` Eric Schulte
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Schulte @ 2010-01-28 17:00 UTC (permalink / raw)
  To: Dan Davison; +Cc: emacs-orgmode

This patch has been applied. Thanks -- Eric

Dan Davison <davison@stats.ox.ac.uk> writes:

> "Martin G. Skjæveland" <martige@ifi.uio.no> writes:
>
>> Hi,
>>
>> I have two questions regarding org-babel-tangle and Makefile.
>>
>> Running org-babel-tangle on the following file
>>
>> ----------------------------------start
>> * test
>>
>> #+begin_src makefile :tangle Makefile
>>   test:
>>           echo "hello"
>> #+end_src
>> ----------------------------------end
>>
>> writes a file 'Makefile.' (with a period). Is it possible to have it
>> write to a file named 'Makefile' (without a period)?
>
> Hi Martin,
>
> I've had this problem too. Here's a patch. Eric -- can you apply if
> it looks OK?
>
> Dan
>
> From 5c4d56a2e43a97186bf2971b6406f5fa2257130d Mon Sep 17 00:00:00 2001
> From: Dan Davison <davison@stats.ox.ac.uk>
> Date: Thu, 28 Jan 2010 10:23:11 -0500
> Subject: [PATCH] babel: prevent trailing periods in tangled file names without extensions
>
> ---
>  contrib/babel/lisp/org-babel-tangle.el |    7 ++++---
>  1 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/contrib/babel/lisp/org-babel-tangle.el b/contrib/babel/lisp/org-babel-tangle.el
> index c805373..66e2c26 100644
> --- a/contrib/babel/lisp/org-babel-tangle.el
> +++ b/contrib/babel/lisp/org-babel-tangle.el
> @@ -102,9 +102,10 @@ exported source code blocks by language."
>                                       ((> (length tangle) 0) tangle))
>                                      target-file))
>                       (file-name (when base-name
> -                                  (if (string= base-name
> -                                               (file-name-sans-extension base-name))
> -                                      (concat base-name "." ext) base-name))))
> +                                  (if (and ext
> +                                          (string= base-name
> +                                                   (file-name-sans-extension base-name)))
> +                                     (concat base-name "." ext) base-name))))
>                  ;; ;; debugging
>                  ;; (message "tangle=%S base-name=%S file-name=%S"
>                  ;;          tangle base-name file-name)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: sometimes we don't want org-src to remove tabs [WAS: Re: tangle and Makefile]]
  2010-01-28 15:47 ` sometimes we don't want org-src to remove tabs [WAS: Re: tangle and Makefile]] Dan Davison
@ 2010-01-28 18:21   ` Carsten Dominik
  2010-01-29 15:28     ` Dan Davison
  0 siblings, 1 reply; 6+ messages in thread
From: Carsten Dominik @ 2010-01-28 18:21 UTC (permalink / raw)
  To: Dan Davison; +Cc: emacs-orgmode


On Jan 28, 2010, at 4:47 PM, Dan Davison wrote:

> "Martin G. Skjæveland" <martige@ifi.uio.no> writes:
>
>> Hi,
>>
>> I have two questions regarding org-babel-tangle and Makefile.
>>
>> Running org-babel-tangle on the following file
>>
>> ----------------------------------start
>> * test
>>
>> #+begin_src makefile :tangle Makefile
>>  test:
>>          echo "hello"
>> #+end_src
>> ----------------------------------end
>>
> [...]
>> When I use this makefile
>>
>>  $make -f Makefile. test
>>
>> I get
>>
>>  Makefile.:4: *** missing separator (did you mean TAB instead of 8
>>  spaces?). Stop.
>>
>> even though I used TAB and not space when editing the Makefile  
>> code. How
>> can I avoid TABs being converted to space?
>
> Hi again Martin,
>
> This is more to do with org-mode sensu strictu (non-babel). When you
> exit a code edit buffer, tabs are automatically converted to
> spaces. There is an org-mode variable org-src-preserve-indentation  
> which
> already has a few different effects. Perhaps a solution is to add
> not_removing_tabs to the effects of this variable, as in the patch
> below. I can't think off hand what that's going to break -- anyone?
>
> Dan
>
>
> From d854544d24377434c2ace13aac45e85e42bcc7aa Mon Sep 17 00:00:00 2001
> From: Dan Davison <davison@stats.ox.ac.uk>
> Date: Thu, 28 Jan 2010 10:36:29 -0500
> Subject: [PATCH] org-src: Don't remove tabs when org-src-preserve- 
> indentation is non-nil
>
> ---
> lisp/org-src.el |    2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/lisp/org-src.el b/lisp/org-src.el
> index cdad99b..1d155cc 100644
> --- a/lisp/org-src.el
> +++ b/lisp/org-src.el
> @@ -525,7 +525,7 @@ the language, a switch telling if the content  
> should be in a single line."
> 			   org-edit-src-content-indentation))
> 	 (preserve-indentation org-src-preserve-indentation)
> 	 (delta 0) code line col indent)
> -    (untabify (point-min) (point-max))
> +    (unless preserve-indentation (untabify (point-min) (point-max)))
>     (save-excursion
>       (goto-char (point-min))
>       (if (looking-at "[ \t\n]*\n") (replace-match ""))
> -- 
> 1.6.3.3

If you have an *indented* code block where the #+begin src is already  
indented, this might mess up the relative indentation in the Org-mode  
buffer because TAB can
land on odd places in the line.  But I can see that this is a problem  
with Makefiles, so please apply the patch.

Thanks

- Carsten


- Carsten

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: sometimes we don't want org-src to remove tabs [WAS: Re: tangle and Makefile]]
  2010-01-28 18:21   ` Carsten Dominik
@ 2010-01-29 15:28     ` Dan Davison
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Davison @ 2010-01-29 15:28 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

Carsten Dominik <carsten.dominik@gmail.com> writes:

> On Jan 28, 2010, at 4:47 PM, Dan Davison wrote:
>
>> "Martin G. Skjæveland" <martige@ifi.uio.no> writes:
>>
>>> Hi,
>>>
>>> I have two questions regarding org-babel-tangle and Makefile.
>>>
>>> Running org-babel-tangle on the following file
>>>
>>> ----------------------------------start
>>> * test
>>>
>>> #+begin_src makefile :tangle Makefile
>>>  test:
>>>          echo "hello"
>>> #+end_src
>>> ----------------------------------end
>>>
>> [...]
>>> When I use this makefile
>>>
>>>  $make -f Makefile. test
>>>
>>> I get
>>>
>>>  Makefile.:4: *** missing separator (did you mean TAB instead of 8
>>>  spaces?). Stop.
>>>
>>> even though I used TAB and not space when editing the Makefile
>>> code. How
>>> can I avoid TABs being converted to space?
>>
>> Hi again Martin,
>>
>> This is more to do with org-mode sensu strictu (non-babel). When you
>> exit a code edit buffer, tabs are automatically converted to
>> spaces. There is an org-mode variable org-src-preserve-indentation
>> which
>> already has a few different effects. Perhaps a solution is to add
>> not_removing_tabs to the effects of this variable, as in the patch
>> below. I can't think off hand what that's going to break -- anyone?
>>
>> Dan
>>
>>
>> From d854544d24377434c2ace13aac45e85e42bcc7aa Mon Sep 17 00:00:00 2001
>> From: Dan Davison <davison@stats.ox.ac.uk>
>> Date: Thu, 28 Jan 2010 10:36:29 -0500
>> Subject: [PATCH] org-src: Don't remove tabs when org-src-preserve-
>> indentation is non-nil
>>
>> ---
>> lisp/org-src.el |    2 +-
>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/lisp/org-src.el b/lisp/org-src.el
>> index cdad99b..1d155cc 100644
>> --- a/lisp/org-src.el
>> +++ b/lisp/org-src.el
>> @@ -525,7 +525,7 @@ the language, a switch telling if the content
>> should be in a single line."
>> 			   org-edit-src-content-indentation))
>> 	 (preserve-indentation org-src-preserve-indentation)
>> 	 (delta 0) code line col indent)
>> -    (untabify (point-min) (point-max))
>> +    (unless preserve-indentation (untabify (point-min) (point-max)))
>>     (save-excursion
>>       (goto-char (point-min))
>>       (if (looking-at "[ \t\n]*\n") (replace-match ""))
>> --
>> 1.6.3.3
>
> If you have an *indented* code block where the #+begin src is already
> indented, this might mess up the relative indentation in the Org-mode
> buffer because TAB can
> land on odd places in the line.  But I can see that this is a problem
> with Makefiles, so please apply the patch.

OK, applied.

Martin -- with the latest git version, and with
org-src-preserve-indentation set to a non-nil value, you should be able
to tangle makefiles correctly. Please let us know if not.

Dan

>
> Thanks
>
> - Carsten
>
>
> - Carsten
>
>
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-01-29 15:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-28 10:52 [babel] tangle and Makefile "Martin G. Skjæveland"
2010-01-28 15:38 ` Dan Davison
2010-01-28 17:00   ` Eric Schulte
2010-01-28 15:47 ` sometimes we don't want org-src to remove tabs [WAS: Re: tangle and Makefile]] Dan Davison
2010-01-28 18:21   ` Carsten Dominik
2010-01-29 15:28     ` Dan Davison

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).