Agenda: Fix problems with follow mode.
[org-mode.git] / contrib / scripts / org2hpda
blob048c4bd1e27ab9986316777b9d7dfa864950f80e
1 # org2hpda - a small utility to generate hipster pda style printouts from org mode 
2 # Copyright (C) 2007  Christian Egli
3
4 # Version: 0.5
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 # Commentary:
20
21 # set cal-tex-diary to true so that diary entries show up in the calendar 
23 # the pdf* commands are part of the pdfjam package which can be found
24 # at http://www.warwick.ac.uk/go/pdfjam
26 EMACS = emacs -batch -l ~/.emacs
27 LATEX = latex
28 DIARY = ~/diary
30 hipsterFiles =  weekCalendar.pdf yearCalendar.pdf monthCalendar3.pdf monthCalendar2.pdf monthCalendar1.pdf
31 pocketModFiles =  weekCalendar.pdf yearCalendar-rotated.pdf \
32         monthCalendar3-rotated.pdf monthCalendar2-rotated.pdf monthCalendar1-rotated.pdf
34 all: pocketMod.pdf hipsterPDA.pdf
36 %.dvi: %.tex
37         # Quick hack to massage the LaTeX produced by cal-tex
38         # quote '@', then increase font size of week calendars,
39         # increase font of diary entries in moth calendar and 
40         # finally reduce links to their destination, i.e. 
41         # change '[[http://foo][bar]]' to 'bar'
42         sed     -e 's/\\verb|@|/\@/g' \
43                 -e 's/documentclass\[11pt\]/documentclass[12pt]/g' \
44                 -e 's/{\\tiny \\raggedright #3}/{\\small \\raggedright #3}/g' \
45                 -e 's/\[\[[^]]\+\]\[\([^]]\+\)\]\]/\1/g' \
46                 < $< > /tmp/temp-org-file.$$$$; mv /tmp/temp-org-file.$$$$ $<
47         $(LATEX) $^
49 %.pdf: %.dvi
50         dvipdf $^
52 %-rotated.pdf: %.pdf
53         cp $^ $@
54         for n in 1 2 3; do \
55                 pdf90 --outfile tmp.pdf $@; mv tmp.pdf $@; \
56         done
58 weekCalendar.tex: $(DIARY)
59         $(EMACS) -eval "(progn (calendar) (cal-tex-cursor-week-iso 4) (with-current-buffer cal-tex-buffer (write-file \"$@\")))"
61 monthCalendar1.tex: $(DIARY)
62          $(EMACS) -eval "(progn (calendar) (cal-tex-cursor-month-landscape 1) (with-current-buffer cal-tex-buffer (write-file \"$@\")))"
64 monthCalendar2.tex: $(DIARY)
65          $(EMACS) -eval "(progn (calendar) (calendar-forward-month 1) (cal-tex-cursor-month-landscape 1) (with-current-buffer cal-tex-buffer (write-file \"$@\")))"
67 monthCalendar3.tex: $(DIARY)
68          $(EMACS) -eval "(progn (calendar) (calendar-forward-month 2) (cal-tex-cursor-month-landscape 1) (with-current-buffer cal-tex-buffer (write-file \"$@\")))"
70 yearCalendar.tex: $(DIARY)
71          $(EMACS) -eval "(progn (calendar) (calendar-forward-month 2) (cal-tex-cursor-year-landscape 1) (with-current-buffer cal-tex-buffer (write-file \"$@\")))"
73 pocketMod.pdf: $(pocketModFiles)
74         pdfjoin --outfile tmp.pdf $^
75         pdfnup tmp.pdf --outfile $@ --nup 4x2 --frame true
77 hipsterPDA.pdf: $(hipsterFiles)
78         pdfnup weekCalendar.pdf --outfile page1.pdf --nup 2x2 --frame true
79         pdfjoin --outfile tmp.pdf monthCalendar[1-3]-rotated.pdf yearCalendar-rotated.pdf
80         pdfnup tmp.pdf --outfile page2.pdf --nup 2x2 --frame true
81         pdfjoin --outfile $@ page1.pdf page2.pdf
83 clean:
84         rm -rf *.aux *.dvi *.tex *.log *.pdf