[O] Bug in table export for latex? (underscore and ampersand)

2012-07-03 Thread Frozenlock
I'm trying to export a table with the following cell:
BAT_30_CCR01_OUV_ZONE_PCE_30_2A_102_&_30_2A_101


The ampersand seems to be messing everything... I obtain this when I export:

BAT\_{}30\_{}CCR01\_{}OUV\_{}ZONE\_{}PCE\_{}30\_{}2A\_{}102_\&_30\_{}2A\_{}101

For this to export normally, I would expect this:

BAT\_{}30\_{}CCR01\_{}OUV\_{}ZONE\_{}PCE\_{}30\_{}2A\_{}102\_{}\&\_{}30\_{}2A\_{}101

Here is the difference:
102_\&_30
102\_{}\&\_{}30


The underscore isn't escaped, which results in an unwanted subscript in the
exported table.

Is this a bug?
Any quick fix?

Thanks in advance!


Re: [O] [BUG?][babel] Re: Including source when exporting in PDF

2012-01-17 Thread Frozenlock
I'm sorry, but I don't quite understand...

Would it be possible to send a minimum working example of your org file?



On Mon, Jan 16, 2012 at 6:21 AM, Rainer M Krug  wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> On 15/01/12 06:29, Frozenlock wrote:
>> This babel block should do the following:
>>
>> - When exporting, automatically tangle the babel blocks. - Then
>> take the resulting files and add them to a zip file, along with the
>> original .org file. - Add the necessary \usepackage and latex
>> commands to insert the zipfile.
>>
>> Let me know if something isn't like you want.
>>
>> Here is the babel block to add to your source (org) file:
>>
>>  #+BEGIN_SRC emacs-lisp
>> :results org :exports results :var
>> buffer-file-name=(buffer-file-name) (let ((filename
>> (file-name-nondirectory (file-name-sans-extension
>> buffer-file-name (shell-command (concat "zip -j " filename
>> ".zip " filename".org " (mapconcat '(lambda (arg)
>> (convert-standard-filename (expand-file-name arg)))
>> (org-babel-tangle) " "))) (concat
>> "#+LATEX_HEADER:\\usepackage{attachfile2}\n" "#+LATEX: \\vfill
>> \\textattachfile[print=false,color=0.5 0.5
>> 0.5]{"filename".zip}{Source (.org) \\& other files...}\n"))
>> #+END_SRC ==
>
> Thanks for this code - it looks good, but there is a serious problem:
>
> src_emacs_lisp{} expressions are evaluated and replaced with the
> result in the org file, which does not happen when tangling from the
> buffer itself.
> Example:
>
> 
> * name src_emacs-lisp{(buffer-file-name)}
> #+BEGIN_SRC emacs-lisp :results org :exports results :var
> buffer-file-name=(buffer-file-name)
>  (org-babel-tangle)
> #+END_SRC
> 
>
> If I export the file above, the file get changed to:
>
> 
> * name
>
> #+BEGIN_SRC emacs-lisp :results org :exports results :var
> buffer-file-name=(buffer-file-name)
>  (org-babel-tangle)
> #+END_SRC
> 
>
> Is there something wrong with the code?
>
> Rainer
>
>
>>
>>
>> On a related note, I've added some improvements to my own way to
>> export in multiple format and add the files along with the source.
>> The latex commands and usepackage are included, so no need to add
>> them elswhere in the org file:
>>
>> == # Make sure this babel block is the
>> last one in the buffer; # block after this one won't be evaluated
>> before the txt and html export. #+BEGIN_SRC emacs-lisp :results org
>> :exports results :var buffer-file-name=(buffer-file-name) (let
>> ((org-export-babel-evaluate nil)); don't evaluate in 'recursive'
>> exports (save-window-excursion ;; avoid leakage when more than one
>> org export in block (org-export-as-ascii
>> org-export-headline-levels)) (save-window-excursion
>> (org-export-as-html org-export-headline-levels)) (let ((filename
>> (file-name-nondirectory (file-name-sans-extension
>> buffer-file-name))) (to-include-files (directory-files
>> (file-name-directory buffer-file-name (shell-command (concat
>> "zip -j " filename  ".zip " (mapconcat '(lambda (arg) arg)
>> (remove-if '(lambda (file) (string-match
>> "\\.$\\|\\.pdf$\\|\\.atfi$\\|\\.tex$\\|#" file)) ;; don't include
>> useless files to-include-files) " "))) (concat
>> "#+LATEX_HEADER:\\usepackage{attachfile2}\n" "#+LATEX: \\vfill
>> \\textattachfile[print=false,color=0.5 0.5
>> 0.5]{"filename".zip}{Source (.org) & html, txt...}\n"))) #+END_SRC
>> ==
>>
>>
>> Enjoy!
>>
>>
>>
>> On Thu, Jan 12, 2012 at 8:59 AM, Rainer M Krug 
>> wrote:
>>> On 12 January 2012 14:54, Frozenlock 
>>> wrote:
>>>> The code block I previously sent only require you to specify
>>>> which _extension_ you want or don't want. No need to include
>>>> any specific filename (other than the .zip file in the latex
>>>> "include" command).
>>>>
>>>> Am I to understand you want something to include *all and only*
>>>> tangled files?
>>>
>>> Yes - and the files do have different extensions (e.g. .R, .sh,
>>> .sub, 

[O] [BUG] ORG-LIST-END-MARKER when exporting from within a babel block with an exclude or include tag

2012-01-15 Thread Frozenlock
Ok, I know this a very specific application. Perhaps it's not even a
bug and I'm using it the wrong way.

Here is a minimum working example:


#+TITLE: Test org file
#+EXPORT_INCLUDE_TAGS: test2

* First heading   :test1:
Testing, 1-2, 1-2.

* Second heading  :test2:
Because we can.

** Now a list
   - First item
   - Second item

#+BEGIN_SRC emacs-lisp :results raw :exports results :var
buffer-file-name=(buffer-file-name)
(let ((org-export-babel-evaluate nil)); don't evaluate in 'recursive' exports
   (org-export-as-ascii org-export-headline-levels))
#+END_SRC



If you export this file to PDF (C-c C-e d), babel will evaluate and
export the file as ascii. However, the ascii file will have the
undesirable "ORG-LIST-END-MARKER" in it.
Here is the resulting ascii export:


Test org file
=

Author:
Date: 2012-01-15 23:51:47


Table of Contents
=
1 First heading
2 Second heading
2.1 Now a list


1 First heading :test1:
---
Testing, 1-2, 1-2.

2 Second heading :test2:

Because we can.

2.1 Now a list
===
   - First item
   - Second item
ORG-LIST-END-MARKER



Any idea on how to fix this?



Re: [O] Including source when exporting in PDF

2012-01-14 Thread Frozenlock
This babel block should do the following:

- When exporting, automatically tangle the babel blocks.
- Then take the resulting files and add them to a zip file, along with
the original .org file.
- Add the necessary \usepackage and latex commands to insert the zipfile.

Let me know if something isn't like you want.

Here is the babel block to add to your source (org) file:


#+BEGIN_SRC emacs-lisp :results org :exports results :var
buffer-file-name=(buffer-file-name)
(let ((filename (file-name-nondirectory (file-name-sans-extension
buffer-file-name
(shell-command
 (concat "zip -j " filename  ".zip " filename".org "
 (mapconcat '(lambda (arg)
   (convert-standard-filename
(expand-file-name arg)))
(org-babel-tangle)
" ")))
(concat "#+LATEX_HEADER:\\usepackage{attachfile2}\n"
"#+LATEX: \\vfill \\textattachfile[print=false,color=0.5
0.5 0.5]{"filename".zip}{Source (.org) \\& other files...}\n"))
#+END_SRC
==


On a related note, I've added some improvements to my own way to
export in multiple format and add the files along with the source. The
latex commands and usepackage are included, so no need to add them
elswhere in the org file:

==
# Make sure this babel block is the last one in the buffer;
# block after this one won't be evaluated before the txt and html export.
#+BEGIN_SRC emacs-lisp :results org :exports results :var
buffer-file-name=(buffer-file-name)
(let ((org-export-babel-evaluate nil)); don't evaluate in 'recursive' exports
  (save-window-excursion ;; avoid leakage when more than one org export in block
(org-export-as-ascii org-export-headline-levels))
  (save-window-excursion (org-export-as-html org-export-headline-levels))
  (let ((filename (file-name-nondirectory (file-name-sans-extension
buffer-file-name)))
(to-include-files (directory-files (file-name-directory 
buffer-file-name
(shell-command
 (concat "zip -j " filename  ".zip "
 (mapconcat '(lambda (arg) arg)
(remove-if
 '(lambda (file)
(string-match 
"\\.$\\|\\.pdf$\\|\\.atfi$\\|\\.tex$\\|#" file))
 ;; don't include useless files
 to-include-files)
" ")))
(concat "#+LATEX_HEADER:\\usepackage{attachfile2}\n"
"#+LATEX: \\vfill \\textattachfile[print=false,color=0.5 0.5
0.5]{"filename".zip}{Source (.org) & html, txt...}\n")))
#+END_SRC
==


Enjoy!



On Thu, Jan 12, 2012 at 8:59 AM, Rainer M Krug  wrote:
> On 12 January 2012 14:54, Frozenlock  wrote:
>> The code block I previously sent only require you to specify which
>> _extension_ you want or don't want. No need to include any specific
>> filename (other than the .zip file in the latex "include" command).
>>
>> Am I to understand you want something to include *all and only* tangled 
>> files?
>
> Yes - and the files do have different extensions (e.g. .R, .sh, .sub,
> none) and are not tangled necessarily in a specific directory.
>
> and the original org file, but that is not a problem.
>
> Rainer
>
>>
>> --
>>
>> I tried ":exports result" with no success. I'll try to send a minimum
>> working example shortly.
>>
>> On Thu, Jan 12, 2012 at 4:11 AM, Rainer M Krug  wrote:
>>> -BEGIN PGP SIGNED MESSAGE-
>>> Hash: SHA1
>>>
>>> On 12/01/12 03:06, Frozenlock wrote:
>>>> To include multiple files, I export all of the required files
>>>> before the PDF creation and zip them. This way, I only need to
>>>> include a single zip file.
>>>
>>> Good idea.
>>>
>>>>
>>>> #+BEGIN_SRC emacs-lisp :exports none ;; various exports
>>>> (save-window-excursion (org-export-as-ascii
>>>> org-export-headline-levels)) (save-window-excursion
>>>> (org-export-as-html org-export-headline-levels))
>>>>
>>>> ;;zip the required files (let ((filename (file-name-sans-extension
>>>> (file-name-nondirectory (buffer-file-name) (shell-command
>>>> (concat "zip " filename ".zip " (mapconcat '(lambda (arg) arg)
>>>> (remove-if '(lambda (filename) (string-match
>>>> "\\.$\\|\\.pdf$\\|\\.atfi$\\|#" filename)) (directory-files
>>>> (file-name-directory (buffer

Re: [O] Including source when exporting in PDF

2012-01-12 Thread Frozenlock
The code block I previously sent only require you to specify which
_extension_ you want or don't want. No need to include any specific
filename (other than the .zip file in the latex "include" command).

Am I to understand you want something to include *all and only* tangled files?

--

I tried ":exports result" with no success. I'll try to send a minimum
working example shortly.

On Thu, Jan 12, 2012 at 4:11 AM, Rainer M Krug  wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> On 12/01/12 03:06, Frozenlock wrote:
>> To include multiple files, I export all of the required files
>> before the PDF creation and zip them. This way, I only need to
>> include a single zip file.
>
> Good idea.
>
>>
>> #+BEGIN_SRC emacs-lisp :exports none ;; various exports
>> (save-window-excursion (org-export-as-ascii
>> org-export-headline-levels)) (save-window-excursion
>> (org-export-as-html org-export-headline-levels))
>>
>> ;;zip the required files (let ((filename (file-name-sans-extension
>> (file-name-nondirectory (buffer-file-name) (shell-command
>> (concat "zip " filename ".zip " (mapconcat '(lambda (arg) arg)
>> (remove-if '(lambda (filename) (string-match
>> "\\.$\\|\\.pdf$\\|\\.atfi$\\|#" filename)) (directory-files
>> (file-name-directory (buffer-file-name " " #+END_SRC
>>
>> (I've added this code in a babel block to evaluate just before the
>> PDF export.)
>
> I actually did not want to fiddle with the file names, as it is to
> easy to forget some: this concerns in my case literate programming of
> a simulation model in R, resul;ting in several files of different
> extensions - it is to easy to forget one.
>
> If I tangle, I get all the names of the tangled files, but I do not
> know how I can feed them into the zip file.
>
>>
>> As you can see, I make sure I don't include a previous PDF, or any
>> other useless file.
>
> True.
>
>>
>> If you wish to add only a single type of file, simply replace
>> "remove-if" by "remove-if-not" and change the value in the
>> string-match function. For example,
>> "\\.$\\|\\.pdf$\\|\\.atfi$\\|#" would become "\\.lisp$" to include
>> all your exported lisp files.
>>
>> Hope this helps!
>>
>>
>> By the way, I can't get the code block to be evaluated
>> automatically when I export to PDF, any clue on how to do that?
>
> I assume, it is caused by the :exports none - so no evaluation is done
> on export. Try changing it to :exports result and then generate an
> empty result, or a list of files included in the zip file.
>
> Cheers,
>
> Rainer
>
>
>>
>>
>>
>> On Wed, Jan 11, 2012 at 10:28 AM, Rainer M Krug
>>  wrote: On 06/01/12 08:45, Eric Schulte wrote:
>>>>> Frozenlock  writes:
>>>>>
>>>>>> I am a strong advocate in keeping the source of
>>>>>> everything.
>>>>>>
>>>>>> However, Â a source can easily be lost if it doesn't follow
>>>>>> the document. In LaTeX, there's a package to attach a file
>>>>>> to a PDF (like when you attach a file to an email). By
>>>>>> doing so, the source will follow the PDF even if the common
>>>>>> reader have no clue what it's for, or even how to use it.
>>>>>>
>>>>>
>>>>> This sounds like a great Reproducible Research practice.
>>>>>
>>>>>>
>>>>>> Here is how I attach my org source to every document I
>>>>>> export to PDF:
>>>>>>
>>>>>> ;; Include the source file for every exported PDF
>>>>>> (org-mode) (eval-after-load "org-exp" '(defadvice
>>>>>> org-export-as-latex (around org-export-add-source-pdf
>>>>>> activate) "Add the source (org file) to the resulting pdf
>>>>>> file" (let ((filename (buffer-name))) ad-do-it ;do the
>>>>>> function (let ((latex-buffer ad-return-value)) (set-buffer
>>>>>> latex-buffer) (while (re-search-forward
>>>>>> "usepackage{.+}" nil t)); go to the end of packages
>>>>>> (insert "\n\\usepackage{attachfile2}"); the package needed
>>>>>> to attach files (when (re-search-forward
>>>>>> "end{document}" nil t) (forward-line -1) (insert
>>>>>> (concat "\\vfill\n&qu

Re: [O] Including source when exporting in PDF

2012-01-11 Thread Frozenlock
To include multiple files, I export all of the required files before
the PDF creation and zip them. This way, I only need to include a
single zip file.

#+BEGIN_SRC emacs-lisp :exports none
;; various exports
 (save-window-excursion
  (org-export-as-ascii org-export-headline-levels))
(save-window-excursion
  (org-export-as-html org-export-headline-levels))

;;zip the required files
(let ((filename (file-name-sans-extension (file-name-nondirectory
(buffer-file-name)
  (shell-command
   (concat "zip " filename ".zip "
   (mapconcat '(lambda (arg) arg)
(remove-if
 '(lambda (filename)
(string-match "\\.$\\|\\.pdf$\\|\\.atfi$\\|#" filename))
 (directory-files (file-name-directory (buffer-file-name
" "
#+END_SRC

(I've added this code in a babel block to evaluate just before the PDF export.)

As you can see, I make sure I don't include a previous PDF, or any
other useless file.

If you wish to add only a single type of file, simply replace
"remove-if" by "remove-if-not" and change the value in the
string-match function. For example, "\\.$\\|\\.pdf$\\|\\.atfi$\\|#"
would become "\\.lisp$" to include all your exported lisp files.

Hope this helps!


By the way, I can't get the code block to be evaluated automatically
when I export to PDF, any clue on how to do that?



On Wed, Jan 11, 2012 at 10:28 AM, Rainer M Krug  wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> On 06/01/12 08:45, Eric Schulte wrote:
>> Frozenlock  writes:
>>
>>> I am a strong advocate in keeping the source of everything.
>>>
>>> However,  a source can easily be lost if it doesn't follow the
>>> document. In LaTeX, there's a package to attach a file to a PDF
>>> (like when you attach a file to an email). By doing so, the
>>> source will follow the PDF even if the common reader have no clue
>>> what it's for, or even how to use it.
>>>
>>
>> This sounds like a great Reproducible Research practice.
>>
>>>
>>> Here is how I attach my org source to every document I export to
>>> PDF:
>>>
>>> ;; Include the source file for every exported PDF (org-mode)
>>> (eval-after-load "org-exp" '(defadvice org-export-as-latex
>>> (around org-export-add-source-pdf activate) "Add the source (org
>>> file) to the resulting pdf file" (let ((filename (buffer-name)))
>>> ad-do-it ;do the function (let ((latex-buffer ad-return-value))
>>> (set-buffer latex-buffer) (while (re-search-forward
>>> "usepackage{.+}" nil t)); go to the end of packages (insert
>>> "\n\\usepackage{attachfile2}"); the package needed to attach
>>> files (when (re-search-forward "end{document}" nil t)
>>> (forward-line -1) (insert (concat "\\vfill\n" "\\footnotesize\n"
>>> "The source of this document is an Org-Mode file attached here:"
>>> "\n\\attachfile" "{" filename "}"))) (save-buffer)
>>>
>>>
>>> This is by no mean a patch, but rather a quick hack. Perhaps
>>> someone with a working knowledge of the org-export could find a
>>> way to add a source option?
>>>
>>
>> I think this practice may not actually require any changes to the
>> Org-mode core.  The attached small Org-mode file will attach itself
>> to pdf exports using only features already present in Org-mode.
>
> Following this idea - how can I easily attach all files created by
> tangling? Is there a programmatic way, without having to specify them
> manually?
>
> Thanks,
>
> Rainer
>
>
>>
>>
>>
>>
>>
>> Thanks for sharing this idea!
>>
>>>
>>>
>>> Cheers!
>>>
>>
>
>
> - --
> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
> Biology, UCT), Dipl. Phys. (Germany)
>
> Centre of Excellence for Invasion Biology
> Stellenbosch University
> South Africa
>
> Tel :       +33 - (0)9 53 10 27 44
> Cell:       +33 - (0)6 85 62 59 98
> Fax :       +33 - (0)9 58 10 27 44
>
> Fax (D):    +49 - (0)3 21 21 25 22 44
>
> email:      rai...@krugs.de
>
> Skype:      RMkrug
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk8NqqwACgkQoYgNqgF2egro/wCfTlVxaVNR1/5395UC8wWrL9Ku
> jhIAn3f3Lud1aFrHz1uzo7SlFH+CsmFi
> =wU4r
> -END PGP SIGNATURE-



[O] Org exports leaking into each other?

2012-01-10 Thread Frozenlock
I'm trying to do simultaneous exports of an org document by doing the following:

#+begin_src emacs-lisp
(org-export-as-ascii org-export-headline-levels)
(org-export-as-html org-export-headline-levels)
#+end_src

Each export done manually is fine, but when done like my code, the
.txt file seems to be leaking into the .html file.

Any suggestion to fix this?



Also, when I export a babel latex code, it asks me if I want to
evaluate. When I I export a babel /emasc-lisp/ code however, it
doesn't ask me for anything and goes straight by. I would like it to
be executed at each export, if it's possible.

Thank you in advance!



[O] Including source when exporting in PDF

2012-01-04 Thread Frozenlock
I am a strong advocate in keeping the source of everything.

However,  a source can easily be lost if it doesn't follow the document.
In LaTeX, there's a package to attach a file to a PDF (like when you
attach a file to an email).
By doing so, the source will follow the PDF even if the common reader
have no clue what it's for, or even how to use it.

Here is how I attach my org source to every document I export to PDF:

--8<---cut here---start->8---

;; Include the source file for every exported PDF (org-mode)
(eval-after-load "org-exp"
  '(defadvice org-export-as-latex (around org-export-add-source-pdf activate)
 "Add the source (org file) to the resulting pdf file"
 (let ((filename (buffer-name)))
   ad-do-it ;do the function
   (let ((latex-buffer ad-return-value))
 (set-buffer latex-buffer)
 (while (re-search-forward "usepackage{.+}" nil t)); go to the
end of packages
 (insert "\n\\usepackage{attachfile2}"); the package needed to attach 
files
 (when (re-search-forward "end{document}" nil t)
   (forward-line -1)
   (insert
(concat
 "\\vfill\n"
 "\\footnotesize\n"
 "The source of this document is an Org-Mode file attached here:"
 "\n\\attachfile"
 "{" filename "}")))
 (save-buffer)

--8<---cut here---end--->8---

This is by no mean a patch, but rather a quick hack. Perhaps someone
with a working knowledge of the org-export could find a way to add a
source option?


Cheers!



[O] Exclude column from table when exporting

2011-12-22 Thread Frozenlock
Is there a way to exclude columns when exporting a document containing tables?

I know it is somewhat possible by using radio tables and :skipcols,
but that would be a problem. I have _many_ tables and duplicate each
of them, in addition of naming all of them, would be really
complicated.

I'm searching for a solution similar to the exclude row method "/".

Thanks in advance!



Re: [O] Bill-of-materials

2011-10-25 Thread Frozenlock
Hi Bastien,

I'm trying to push my changes to the Worg repo, but it asks me for my
repo.or.cz's password.
This confuses me, as the repo.or.cz states that they don't use password.

One of the changes I've made is to host the org-bom.el on github
(better than pastebin).
https://github.com/Frozenlock/Org-Bill-of-materials

I've also corrected a bug which caused a mixed section when more than
one was specified per row.

Have a nice day!


On Sat, Oct 22, 2011 at 4:26 AM, Bastien  wrote:
> Hi Frozenlock,
>
> Frozenlock  writes:
>
>> This is a much better version of the little add-on I've written:
>>
>> Bill-of-materials (org-bom.el)
>
> Thanks -- I add this to Worg/org-contrib/index.org.  Please check the
> description when it goes online and improve it if necessary.
>
>> I've used this for over 6 months now, daily.
>> If you ever need to quickly make a quote for a client, or simply
>> make easy to-buy list, this should help you.
>>
>> You can find the code here: http://pastebin.com/K11QpQ6Q
>
> I used http://pastebin.com/raw.php?i=K11QpQ6Q as the location for
> getting the raw code -- hopefully pastebin will keep this URL valid.
>
>> The tutorial is included with it, but here is an eye-friendly version:
>>
>> http://frozenlock.wordpress.com/2011/10/20/bom-bills-of-materials/
>
> Thanks!
>
> --
>  Bastien
>



Re: [O] Bill-of-materials

2011-10-22 Thread Frozenlock
Of course I do, it would be an honor! ;-)

On Sat, Oct 22, 2011 at 12:32 PM, Nick Dokos  wrote:
> Bastien  wrote:
>
>> Hi Frozenlock,
>>
>> Frozenlock  writes:
>>
>> > This is a much better version of the little add-on I've written:
>> >
>> > Bill-of-materials (org-bom.el)
>>
>> Thanks -- I add this to Worg/org-contrib/index.org.  Please check the
>> description when it goes online and improve it if necessary.
>>
>> > I've used this for over 6 months now, daily.
>> > If you ever need to quickly make a quote for a client, or simply
>> > make easy to-buy list, this should help you.
>> >
>> > You can find the code here: http://pastebin.com/K11QpQ6Q
>>
>> I used http://pastebin.com/raw.php?i=K11QpQ6Q as the location for
>> getting the raw code -- hopefully pastebin will keep this URL valid.
>>
>
> Seems like org-bom.el is a good candidate for contrib/ (assuming
> Frozenlock agrees).
>
> Nick
>



[O] Bill-of-materials

2011-10-20 Thread Frozenlock
Hi,

This is a much better version of the little add-on I've written:

Bill-of-materials (org-bom.el)

I've used this for over 6 months now, daily.
If you ever need to quickly make a quote for a client, or simply
make easy to-buy list, this should help you.

You can find the code here: http://pastebin.com/K11QpQ6Q

The tutorial is included with it, but here is an eye-friendly version:

http://frozenlock.wordpress.com/2011/10/20/bom-bills-of-materials/


Finally, just to tease you, this is a table generated from various
data gathered inside a buffer:

#+BEGIN: bom :total t :no-tag t :description t :price t
| Component       | Quantity | Price | Description  |
|-+--+---+--|
| CDs             |       50 |       | Not DVDs     |
| Headset         |        1 |       | N/A          |
| Keyboard        |        3 |   120 | Used to type |
| Mouse           |        2 |       | N/A          |
| USB flash drive |       23 |       | N/A          |
|-+--+---+--|
| TOTAL:          |          |   120 |              |
    #+TBLFM: @>$3=vsum(@I..@>>)
 #+END:


Enjoy!



[O] New contribution: Bill-of-materials -- org-bom.el

2011-04-03 Thread frozenlock

Hello all!

This is my contribution to the wonderful world of org mode: a  
bill-of-materials maker.


This module will scan your entire buffer, collect data, store it in a local  
database and give it to you in a table. The power users might also want to  
use the database directly.

For more info, please read the tutorial!

Also please keep in mind that I'm in no way an expert elisper and that my  
program is surely not the most pretty or optimized one around.


Here is the program: http://pastebin.com/w28yaUFz

I've also included it in this email, please enjoy!

;; Copyright 2011 Christian Fortin
;;
;; Filename: org-bom.el
;; Version: 0.1
;; Author: Christian Fortin 
;; Keywords: org, bill-of-materials, collection, tables
;; Description: Create a bill-of-materials (bom) of the entire org buffer
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see .
;;
;;---
;;
;;* BOM tutorial
;;
;; This module collects information across the entire org buffer, making it  
easy to retrieve and sort data.
;; It uses the column name as a landmark. We will refer to them  
as 'Keywords'. The keywords are searched using a string-match function,  
which gives the ability to have multiple column with the same  
functionality, but also to use the column name as we would usually with  
org-mode. For example, we can have 'tag' and 'tag2', both are recognized by  
the BOM module and can be used in a spreadsheet-like formula without any  
confusion.

;;
;; The BOM is compiled and printed by using a dynamic block;
;;
;; '#+BEGIN: bom'
;;
;; '#+END'
;;
;; Here is the keyword's list:
;;
;; 1. _Component_
;;
;; This is the most important keyword and act as the trigger.
;; For this example, let's say we write down things we want to buy. In this  
case, a new keyboard for our computer.

;; This is how the table should be:
;; | | Material |
;; | ! | Component |
;; |---+---|
;; | | Keyboard |
;;
;; And here is what the bill of material for this table is:
;;
;; #+BEGIN: bom :no-tag t
;; | Section | Component | Quantity |
;; |--+---+--|
;; | BOM tutorial | Keyboard | 1 |
;; #+END:
;;
;; As you can see, the heading was automatically used as the 'section',  
which doesn't require attention for now. The quantity is, unsurprisingly,  
1. Now suppose that our friend too wants a new keyboard.

;;
;; | | For | Material |
;; | ! | | Component |
;; |---++---|
;; | | Me | Keyboard |
;; | | Friend | Keyboard |
;;
;; #+BEGIN: bom :no-tag t
;; | Section | Component | Quantity |
;; |--+---+--|
;; | BOM tutorial | Keyboard | 2 |
;; #+END:
;;
;; As expected, we get 2 keyboards.
;;
;; 2. _Section_
;;
;; The section is used to separate what would otherwise be an identical  
component. Suppose we don't want our friend's wishes to be in the same BOM  
as our, but still have them in the same table.

;;
;; | | For | Material |
;; | ! | Section | Component |
;; |---+-+---|
;; | | Me | Keyboard |
;; | | Friend | Keyboard |
;;
;; This will results in the following BOM:
;;
;; #+BEGIN: bom :no-tag t
;; | Section | Component | Quantity |
;; |-+---+--|
;; | Friend | Keyboard | 1 |
;; | Me | Keyboard | 1 |
;; #+END:
;;
;; Please note that when a component is given a section, it isn't  
associated with the heading anymore. In fact a section should almost always  
be given. Using headings will simply complicate your writing by forcing you  
to pre-sort materials in an unnatural way. As an alternative, you can set  
a ':SECTION:' property in the heading, which will be inherited by all the  
components without a specified section.

;;
;; 3. _Qty_
;;
;; With this keyword, it is possible to specify a quantity for the  
associated component. In our always improving scenario, we now want to give  
a keyboard to another of our friend (as a gift). This is going to be bought  
at the same time as our keyboard, so they belong together.

;;
;; | | For | Material | |
;; | ! | Section | Component | Qty |
;; |---+-+---+-|
;; | | Me | Keyboard | 2 |
;; | | Friend | Keyboard | 1 |
;;
;; #+BEGIN: bom :no-tag t
;; | Section | Component | Quantity |
;; |-+---+--|
;; | Friend | Keyboard | 1 |
;; | Me | Keyboard | 2 |
;;
;; #+END:
;;
;; *Important*: If Qty keyword is present, then any empty field will be  
c

Re: Re: [O] Why does a column's name need to start with a letter? Changed source with no perceivable

2011-03-05 Thread frozenlock

Yes, it's very well explained, thank you.
I'll try to encode my names by removing any "-" and by adding a dummy  
letter at the beginning.


Is there another way of doing simple database in org-mode? By putting a  
component's name in a cell, I would like if the other columns could fill  
them-self with the component's characteristics.


(My apologies for the double e-mail, the first one wasn't sent to the  
mailing list)



On , Carsten Dominik  wrote:

Hi Christian,





On 5.3.2011, at 04:35, Frozenlock wrote:





> Greetings,



>


> First and foremost, I must say I'ma new Org-mode user... as well as a  
new emacs user... and have only limited experience with lisp.



>


> I'm using a table in org-mode as a database, from which I retrieve  
information as needed from other tables.


> This database stores multiples components with names starting by  
numbers and with the character "-" in them. For example: "10K-AN-D8".


> I want to be able to refer to its column with $10K-AN-D8. Yet, this is  
impossible at the moment.



>



> I've looked in org-table.el and found, at line 2038:



>



> (if (string-match "^[a-zA-Z][a-zA-Z0-9]*$" name)



>



> which, once replaced by this:



>



> (if (string-match "^[-_a-zA-Z0-9]*$" name)



>


> Provides me with the ability to name (and refer) columns in any way I  
want.



>


> However, I'm reluctant to use this feature; surely there was a reason  
for this limitation.



> Could someone point it out for me?





This is limitation is present to disambiguate formulas.



In you example $10K-AN-D8, D8 is already a field reference,



so Org does not know if you mean $10K-AN - @8$4.



Furthermore, you could easily arrive at variables like



$10-AN-D8, and then what should the $10 mean?





Of cause one could disambiguate heuristically by checking



which names have been defined. In fact, name replacement



happens first, and this is why your patch appears to



work. But the side effect would be that introducing



new names could change the interpretation of an



existing equation. All this is unstable and



unpredictable.





Hope this makes it clear.





- Carsten


[O] Why does a column's name need to start with a letter? Changed source with no perceivable side-effects

2011-03-04 Thread Frozenlock
Greetings,

First and foremost, I must say I'm a new Org-mode user... as well as a new
emacs user... and have only limited experience with lisp.

I'm using a table in org-mode as a database, from which I retrieve
information as needed from other tables.
This database stores multiples components with names starting by numbers and
with the character "-" in them. For example: "10K-AN-D8".
I want to be able to refer to its column with $10K-AN-D8. Yet, this is
impossible at the moment.

I've looked in org-table.el and found, at line 2038:

(if (string-match "^[a-zA-Z][a-zA-Z0-9]*$" name)

which, once replaced by this:

(if (string-match "^[-_a-zA-Z0-9]*$" name)

Provides me with the ability to name (and refer) columns in any way I want.

However, I'm reluctant to use this feature; surely there was a reason for
this limitation.
Could someone point it out for me?

If there's no reason not to name columns as we want, perhaps it could be
modified in future versions?

Thank you very much in advance!

Christian