mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-26 07:33:47 +00:00
Merge Org version 8.2.3a.
This commit is contained in:
parent
f201cf3a81
commit
271672fad7
@ -1,3 +1,483 @@
|
||||
2013-11-12 Aaron Ecay <aaronecay@gmail.com>
|
||||
|
||||
* org.texi (Exporting code blocks): Document the 'inline-only
|
||||
setting for `org-export-babel-evaluate'. Document how :var
|
||||
introduces code block dependencies.
|
||||
|
||||
2013-11-12 Achim Gratz <Stromeko@Stromeko.DE>
|
||||
|
||||
* org.texi (Header arguments): Document header-args[:lang]
|
||||
properties and remove deprecated old-style properties from
|
||||
documentation.
|
||||
|
||||
* org.texi (Agenda commands): Remove footnote from @tsubheading
|
||||
and add a sentence with the reference instead.
|
||||
|
||||
2013-11-12 Bastien Guerry <bzg@gnu.org>
|
||||
|
||||
* org.texi (Catching invisible edits):
|
||||
* org.texi (Plain lists, Plain lists):
|
||||
* org.texi (Advanced configuration):
|
||||
* org.texi (Tag groups):
|
||||
* org.texi (Conventions):
|
||||
* org.texi (Checkboxes, Radio lists):
|
||||
* org.texi (Top, Summary, Exporting):
|
||||
* org.texi (In-buffer settings): Fix typos.
|
||||
|
||||
* org.texi (Refile and copy): Document `org-copy' and `C-3 C-c
|
||||
C-w'. Add an index entry for `org-refile-keep'.
|
||||
|
||||
* org.texi (Plain lists): Add an index entry for sorting plain
|
||||
list. Document sorting by checked status for check lists.
|
||||
|
||||
* org.texi (Publishing options): Fix old variable names.
|
||||
|
||||
* org.texi (Orgstruct mode): Fix suggested setting of
|
||||
`orgstruct-heading-prefix-regexp'.
|
||||
|
||||
* org.texi (Export settings): Document
|
||||
`org-export-allow-bind-keywords'.
|
||||
|
||||
* org.texi (History and Acknowledgments): Small rephrasing.
|
||||
|
||||
* org.texi (Template elements): Add a footnote about tags accepted
|
||||
in a year datetree.
|
||||
|
||||
* org.texi (Beamer export, @LaTeX{} and PDF export)
|
||||
(Header and sectioning, @LaTeX{} specific attributes): Enhance
|
||||
style.
|
||||
|
||||
* org.texi (Agenda commands): Add a footnote about dragging agenda
|
||||
lines: it does not persist and it does not change the .org files.
|
||||
|
||||
* org.texi (Agenda commands): Add a table heading for dragging
|
||||
agenda lines forward/backward.
|
||||
|
||||
* org.texi (Agenda commands): Add documentation for
|
||||
`org-agenda-bulk-toggle' and `org-agenda-bulk-toggle-all'.
|
||||
|
||||
* org.texi (Publishing options): Update the list of options.
|
||||
(Simple example, Complex example): Fix the examples.
|
||||
|
||||
* org.texi (Formula syntax for Calc): Don't use a bold font the
|
||||
warning.
|
||||
|
||||
* org.texi (Other built-in back-ends): New section.
|
||||
|
||||
* org.texi (Editing source code): Document
|
||||
`org-edit-src-auto-save-idle-delay' and
|
||||
`org-edit-src-turn-on-auto-save'.
|
||||
|
||||
* org.texi (External links): Document contributed link types
|
||||
separately.
|
||||
|
||||
* org.texi (Closing items): Document
|
||||
`org-closed-keep-when-no-todo'.
|
||||
|
||||
* org.texi (Export back-ends): Rename from "Export formats".
|
||||
(The Export Dispatcher): Remove reference to
|
||||
`org-export-run-in-background'.
|
||||
(Export settings): Minor rewrites.
|
||||
(ASCII/Latin-1/UTF-8 export): Update variable's name.
|
||||
(In-buffer settings): Add #+HTML_HEAD_EXTRA.
|
||||
|
||||
* org.texi (Export in foreign buffers): New section.
|
||||
(Exporting): Remove documentation about converting the selected
|
||||
region.
|
||||
|
||||
* org.texi (Advanced configuration): Put the filter valid types in
|
||||
a table. Use @lisp and @smalllisp.
|
||||
|
||||
* org.texi: Use @code{nil} instead of nil. Update the maintainer
|
||||
contact info.
|
||||
|
||||
* org.texi (Exporting): Better introductory sentence. Add a note
|
||||
about conversion commands.
|
||||
(Feedback, Orgstruct mode, Built-in table editor)
|
||||
(Built-in table editor, Orgtbl mode, Updating the table)
|
||||
(Property syntax, Capturing column view, Capture)
|
||||
(Agenda files, Agenda commands, CDLaTeX mode, CDLaTeX mode)
|
||||
(Exporting, Extending ODT export)
|
||||
(Working with @LaTeX{} math snippets, dir, Customization)
|
||||
(Radio tables, A @LaTeX{} example, Pulling from MobileOrg):
|
||||
Uniformly use @kbd{M-x command RET}.
|
||||
|
||||
* org.texi (Filtering/limiting agenda items): New subsection.
|
||||
Document the use of `org-agenda-max-*' options and
|
||||
`org-agenda-limit-interactively' from the agenda.
|
||||
(Agenda commands): Move details about filtering commands to
|
||||
the new section, only include a summary here.
|
||||
(Customizing tables in ODT export)
|
||||
(System-wide header arguments, Conflicts, Dynamic blocks): Use
|
||||
spaces for indentation.
|
||||
|
||||
* org.texi (Emphasis and monospace): Mention `org-emphasis-alist'.
|
||||
|
||||
* org.texi (Links in HTML export, Images in HTML export)
|
||||
(post): Fix syntax within #+ATTR_*.
|
||||
(Tables in HTML export): Document `org-html-table-row-tags'
|
||||
and use `org-html-table-default-attributes' instead of
|
||||
`org-html-table-tag'.
|
||||
|
||||
* org.texi (Publishing action, Publishing options)
|
||||
(Publishing links): Major rewrite. Enhance explanations for
|
||||
`org-org-publish-to-org'. Remove reference to
|
||||
`org-export-run-in-background'.
|
||||
|
||||
* org.texi: Fix many small typos. Use #+NAME instead of
|
||||
#+TBLNAME. Use @smalllisp instead of @example.
|
||||
(Special symbols): Add index?
|
||||
(HTML preamble and postamble): Don't mention obsolete use of
|
||||
opt-plist.
|
||||
(JavaScript support): Don't mention the org-jsinfo.el file as it
|
||||
has been merged with ox-html.el.
|
||||
|
||||
* org.texi (Installation, Feedback, Setting Options)
|
||||
(Code evaluation security, org-crypt.el): Use @lisp instead of
|
||||
@example.
|
||||
(Agenda commands): Use @table instead of @example.
|
||||
|
||||
* org.texi (Adding hyperlink types): New appendix.
|
||||
|
||||
* org.texi (ODT export commands, Extending ODT export)
|
||||
(Applying custom styles, Images in ODT export)
|
||||
(Labels and captions in ODT export)
|
||||
(Literal examples in ODT export)
|
||||
(Configuring a document converter)
|
||||
(Working with OpenDocument style files)
|
||||
(Customizing tables in ODT export)
|
||||
(Validating OpenDocument XML): Fix options names.
|
||||
|
||||
* org.texi (History and Acknowledgments): Update acknowledgments
|
||||
to Nicolas. Add Nicolas Goaziou to the list of contributors.
|
||||
|
||||
* org.texi (System-wide header arguments): Don't use "customizing"
|
||||
for setting a variable. Also remove comments.
|
||||
|
||||
* org.texi (Weekly/daily agenda): Add `org-agenda-start-day' and
|
||||
`org-agenda-start-on-weekday' to the variable index and document
|
||||
them.
|
||||
|
||||
* org.texi (Sparse trees, Agenda commands)
|
||||
(@LaTeX{} fragments, Selective export, Export options)
|
||||
(The export dispatcher, ASCII/Latin-1/UTF-8 export)
|
||||
(HTML Export commands, @LaTeX{}/PDF export commands)
|
||||
(iCalendar export, Publishing options, Triggering publication)
|
||||
(In-buffer settings): Update to reflect changes from the new
|
||||
export engine.
|
||||
|
||||
* org.texi (Matching tags and properties): More examples. Explain
|
||||
group tags expansion as regular expressions.
|
||||
|
||||
* org.texi (Tag groups): New section.
|
||||
|
||||
* org.texi (Setting tags): Tiny formatting fixes.
|
||||
|
||||
* org.texi (Plain lists, Checkboxes): Use non-obsolete variable
|
||||
names.
|
||||
|
||||
* org.texi (Storing searches): Add "agenda" and "agenda*" to the
|
||||
concept index. Include example for these agenda views.
|
||||
(Special agenda views): Mention the "agenda*" agenda view.
|
||||
|
||||
* org.texi (Repeated tasks): Document how to ignore a repeater
|
||||
when using both a scheduled and a deadline timetamp.
|
||||
|
||||
* org.texi (Global and local cycling): Wrap in a new subsection.
|
||||
(Initial visibility, Catching invisible edits): New subsections.
|
||||
|
||||
* org.texi (Visibility cycling): Mention that
|
||||
`org-agenda-inhibit-startup' will prevent visibility setting when
|
||||
the agenda opens an Org file for the first time.
|
||||
|
||||
* org.texi (Org syntax): New section.
|
||||
|
||||
* org.texi (Orgstruct mode): Document
|
||||
`orgstruct-heading-prefix-regexp'.
|
||||
|
||||
* org.texi (Speeding up your agendas): New section.
|
||||
|
||||
* org.texi (Installation): When installing Org from ELPA, users
|
||||
should do this from an Emacs session where no .org file has been
|
||||
visited.
|
||||
|
||||
* org.texi (CSS support, In-buffer settings): Update HTML options
|
||||
names.
|
||||
|
||||
* org.texi (Structure editing): Update documentation for
|
||||
`org-insert-heading-or-item'.
|
||||
(Plain lists, Relative timer): Update index entry.
|
||||
|
||||
* org.texi (JavaScript support): Update variable names.
|
||||
|
||||
* org.texi (comments): Minor formatting fix.
|
||||
|
||||
* org.texi (@LaTeX{} fragments): Minor enhancement.
|
||||
|
||||
* org.texi: Update the list contributions.
|
||||
|
||||
* org.texi (Agenda commands): Exporting the agenda to an .org file
|
||||
will not copy the subtrees and the inherited tags. Document
|
||||
`org-agenda-filter-by-regexp'.
|
||||
|
||||
* org.texi (Publishing action, Complex example): Fix names of
|
||||
publishing functions.
|
||||
|
||||
* org.texi (Top, Exporting): Delete references to Freemind.
|
||||
(Freemind export): Delete section.
|
||||
|
||||
* org.texi (Top, Exporting): Delete references to the XOXO export.
|
||||
(XOXO export): Delete section.
|
||||
|
||||
* org.texi (Capture): Mention that org-remember.el is not
|
||||
supported anymore.
|
||||
|
||||
* org.texi (Top, Exporting, Beamer class export): Delete
|
||||
references to the TaskJuggler export.
|
||||
(History and Acknowledgments): Mention that the TaskJuggler has
|
||||
been rewritten by Nicolas and now lives in the contrib/ directory
|
||||
of Org's distribution. Mention that Jambunathan rewrote the HTML
|
||||
exporter. Remove Jambunathan from my own acknowledgments.
|
||||
(TaskJuggler export): Delete.
|
||||
|
||||
* org.texi (HTML preamble and postamble)
|
||||
(Tables in HTML export, Images in HTML export)
|
||||
(Math formatting in HTML export, CSS support)
|
||||
(@LaTeX{} and PDF export, Publishing options): Fix the names of
|
||||
the HTML export and publishing options.
|
||||
|
||||
* org.texi (Literal examples, Export options)
|
||||
(@LaTeX{} and PDF export, Header and sectioning)
|
||||
(Publishing options): Fix LaTeX options names.
|
||||
|
||||
* org.texi (Export options, CSS support, In-buffer settings): Fix
|
||||
references to HTML_LINK_* and HTML_STYLE keywords.
|
||||
|
||||
* org.texi (Export options, In-buffer settings): Fix references to
|
||||
#+SELECT_TAGS and #+EXCLUDE_TAGS and remove reference to #+XSLT.
|
||||
|
||||
* org.texi (Top, Markup, Initial text, Images and tables)
|
||||
(@LaTeX{} fragments, @LaTeX{} fragments, Exporting)
|
||||
(Export options, JavaScript support, Beamer class export): Remove
|
||||
references to the DocBook export, which has been deleted.
|
||||
(History and Acknowledgments): Mention that DocBook has been
|
||||
deleted, suggest to use the Texinfo exporter instead, then to
|
||||
convert the .texi to DocBook with makeinfo.
|
||||
(Links in ODT export, Tables in ODT export): Fix indices.
|
||||
|
||||
* org.texi (Deadlines and scheduling): Add a variable to the
|
||||
index. Add documentation about delays for scheduled tasks.
|
||||
|
||||
* org.texi (Emphasis and monospace): Mention
|
||||
`org-fontify-emphasized-text' and
|
||||
`org-emphasis-regexp-components'.
|
||||
|
||||
* org.texi (References): Small enhancement.
|
||||
|
||||
* org.texi (Column width and alignment): Make the example visually
|
||||
more clear.
|
||||
|
||||
* org.texi (The clock table): Document :mstart and :wstart as a
|
||||
way to set the starting day of the week.
|
||||
|
||||
* org.texi (In-buffer settings): Document new startup keywords.
|
||||
Thanks to John J Foerch for this idea.
|
||||
|
||||
* org.texi (Include files): Tiny formatting fix.
|
||||
|
||||
* org.texi (Activation): Point to the "Conflicts" section.
|
||||
|
||||
2013-11-12 Carsten Dominik <carsten.dominik@gmail.com>
|
||||
|
||||
* org.texi (CSS support): Clarify this section.
|
||||
|
||||
* org.texi (@LaTeX{} specific attributes): Document that tabu and
|
||||
tabularx packages are not in the default set of packages.
|
||||
|
||||
* org.texi (Agenda commands): Document fortnight view.
|
||||
|
||||
* org.texi: Document conflict with ecomplete.el.
|
||||
|
||||
* org.texi (History and Acknowledgments): Acknowledgements for
|
||||
Jason Dunsmore and Rakcspace.
|
||||
|
||||
* org.texi: Rename org-crypt.el node to org-crypt.
|
||||
|
||||
* org.texi (A @LaTeX{} example): Fix typo in variable name.
|
||||
|
||||
* org.texi (MobileOrg): Mention the new iPhone developer.
|
||||
|
||||
* org.texi (Table of contents) Improve documentation of TOC
|
||||
placement.
|
||||
|
||||
* org.texi: Explain that date/time information at read-date prompt
|
||||
should start at the beginning, not anywhere in the middle of a
|
||||
long string.
|
||||
|
||||
2013-11-12 Christopher Schmidt <christopher@ch.ristopher.com>
|
||||
|
||||
* org.texi (Orgstruct mode): Fix wrong regexp.
|
||||
|
||||
2013-11-12 Eric Abrahamsen <eric@ericabrahamsen.net>
|
||||
|
||||
* org.texi: Document export to (X)HTML flavors.
|
||||
|
||||
2013-11-12 Eric Schulte <schulte.eric@gmail.com>
|
||||
|
||||
* org.texi (Extracting source code): Mention the prefix argument
|
||||
to org-babel-tangle.
|
||||
(noweb): Removed erroneous negative.
|
||||
(Specific header arguments): Document new header arguments.
|
||||
Documentation for new tangle-mode header argument.
|
||||
(Top): Documentation for new tangle-mode header argument.
|
||||
(rownames): Documentation for new tangle-mode header argument.
|
||||
Mention elisp as special rowname case.
|
||||
(tangle-mode): Documentation for new tangle-mode header argument.
|
||||
(post): Documentation and an example of usage.
|
||||
(var): Remove the "Alternate argument syntax" section from the
|
||||
documentation.
|
||||
(hlines): Note that :hline has no effect for Emacs Lisp code
|
||||
blocks.
|
||||
|
||||
2013-11-12 Feng Shu <tumashu@gmail.com>
|
||||
|
||||
* org.texi (@LaTeX{} fragments, Previewing @LaTeX{} fragments)
|
||||
(Math formatting in HTML export)
|
||||
(Working with @LaTeX{} math snippets): Add document about creating
|
||||
formula image with imagemagick.
|
||||
|
||||
* org.texi (@LaTeX{} specific attributes): Document `:caption'
|
||||
attribute of #+ATTR_LATEX.
|
||||
|
||||
2013-11-12 Grégoire Jadi <gregoire.jadi@gmail.com>
|
||||
|
||||
* org.texi (Handling links): Fix a typo in
|
||||
`org-startup-with-inline-images' documentation.
|
||||
|
||||
* org.texi (Previewing @LaTeX{} fragments): Document the startup
|
||||
keywords to use for previewing LaTeX fragments or not.
|
||||
(Summary of in-buffer settings): Improve formatting and add an
|
||||
entry for the variable `org-startup-with-latex-preview'.
|
||||
|
||||
* org.texi (Property syntax): Recall the user to refresh the org
|
||||
buffer when properties are set on a per-file basis.
|
||||
|
||||
2013-11-12 Gustav Wikström <gustav.erik@gmail.com> (tiny change)
|
||||
|
||||
* org.texi (Matching tags and properties): Clarification.
|
||||
|
||||
2013-11-12 Ippei Furuhashi <top.tuna+orgmode@gmail.com>
|
||||
|
||||
* org.texi (Editing and debugging formulas): Add an example when a
|
||||
table has multiple #+TBLFM lines.
|
||||
|
||||
2013-11-12 Ivan Vilata i Balaguer <ivan@selidor.net> (tiny change)
|
||||
|
||||
* org.texi (The clock table): Document acceptance of relative
|
||||
times in tstart and tend, link to syntax description and provide
|
||||
example.
|
||||
|
||||
2013-11-12 Jarmo Hurri <jarmo.hurri@syk.fi>
|
||||
|
||||
* org.texi (The spreadsheet): Document lookup functions.
|
||||
|
||||
2013-11-12 Kodi Arfer <git@arfer.net> (tiny change)
|
||||
|
||||
* org.text (CSS support): Mention .figure-number, .listing-number,
|
||||
and .table-number.
|
||||
|
||||
2013-11-12 Michael Brand <michael.ch.brand@gmail.com>
|
||||
|
||||
* org.texi
|
||||
(Formula syntax for Calc, Emacs Lisp forms as formulas): Reformat
|
||||
spreadsheet formula mode strings and some examples from @example
|
||||
block with xy @r{yz} to @table.
|
||||
|
||||
* org.texi (Formula syntax for Calc): Improve the documentation of
|
||||
empty fields in formulas for spreadsheet. Add explanation and
|
||||
example for empty field. Extend explanations of format
|
||||
specifiers. Add a sentence to mention Calc defmath.
|
||||
|
||||
* org.texi (Column formulas): Add a sentence to be more explicit
|
||||
about when a table header is mandatory.
|
||||
|
||||
2013-11-12 Nicolas Goaziou <n.goaziou@gmail.com>
|
||||
|
||||
* org.texi (Subscripts and superscripts): Remove reference to
|
||||
quoted underscores until this mechanism is implemented again.
|
||||
|
||||
* org.texi (Beamer export): Be more accurate about BEAMER_OPT
|
||||
property.
|
||||
|
||||
* org.texi (Document title): Subtree export is no longer triggered
|
||||
by marking one as the region.
|
||||
(Horizontal rules): LaTeX export doesn't use "\hrule" anymore, and
|
||||
giving examples isn't very useful: "horizontal rule" is, at least,
|
||||
as explicit as <hr/>.
|
||||
|
||||
* org.texi (HTML doctypes): Reflect keyword removal.
|
||||
(CSS support): Reflect keyword removal.
|
||||
|
||||
* org.texi (@LaTeX{} specific attributes): Document new :float
|
||||
values.
|
||||
|
||||
* org.texi (Export settings): Improve documentation.
|
||||
|
||||
* org.texi (Math formatting in HTML export): Fix OPTIONS item's name.
|
||||
(Text areas in HTML export): Update text areas.
|
||||
(HTML Export commands): Update export commands.
|
||||
|
||||
* org.texi (Header and sectioning): Add a footnote about the
|
||||
different between LATEX_HEADER_EXTRA and LATEX_HEADER.
|
||||
|
||||
* org.texi (The Export Dispatcher): Document
|
||||
`org-export-in-background'.
|
||||
|
||||
* org.texi (Footnotes): Export back-ends do not use
|
||||
`org-footnote-normalize' anymore.
|
||||
|
||||
* org.texi: Document variable changes.
|
||||
|
||||
* org.texi (Export settings): Doument p: item in OPTIONS keyword.
|
||||
|
||||
* org.texi (Exporting): Massive rewrite of the first sections.
|
||||
(Selective export): Delete.
|
||||
(The Export Dispatcher): Rewrite.
|
||||
(Export options): Rewrite as "Export settings".
|
||||
|
||||
* org.texi: Small changes to documentation for embedded LaTeX.
|
||||
|
||||
* org.texi (Internal links): Document #+NAME keyword and
|
||||
cross-referencing during export.
|
||||
|
||||
* org.texi (Include files): Remove reference to :prefix1
|
||||
and :prefix. Give more details for :minlevel.
|
||||
|
||||
* org.texi (Macro replacement): Fix macro name. Update
|
||||
documentation about possible locations and escaping mechanism.
|
||||
|
||||
* org.texi (Table of contents): Update documentation. Document
|
||||
lists of listings and lists of tables. Add documentation for
|
||||
optional title and #+TOC: keyword.
|
||||
|
||||
2013-11-12 Rick Frankel <rick@rickster.com>
|
||||
|
||||
* org.texi (results): Add Format section, broken out of Type
|
||||
section to match code.
|
||||
(hlines, colnames): Remove incorrect Emacs Lisp exception. Note
|
||||
that the actual default handling (at least for python and
|
||||
emacs-lisp) does not seem to match the description.
|
||||
|
||||
2013-11-12 Sacha Chua <sacha@sachachua.com> (tiny change)
|
||||
|
||||
* org.texi (The date/time prompt): Update the documentation to
|
||||
reflect the new way `org-read-date-get-relative' handles weekdays.
|
||||
|
||||
2013-11-12 Yasushi Shoji <yashi@atmark-techno.com>
|
||||
|
||||
* org.texi (Resolving idle time): Document
|
||||
`org-clock-x11idle-program-name'.
|
||||
|
||||
2013-10-24 Michael Albinus <michael.albinus@gmx.de>
|
||||
|
||||
* ert.texi (Running Tests Interactively): Adapt examle output.
|
||||
|
5557
doc/misc/org.texi
5557
doc/misc/org.texi
File diff suppressed because it is too large
Load Diff
978
etc/ORG-NEWS
978
etc/ORG-NEWS
@ -1,12 +1,990 @@
|
||||
ORG NEWS -- history of user-visible changes. -*- org -*-
|
||||
|
||||
#+LINK: doc http://orgmode.org/worg/doc.html#%s
|
||||
#+LINK: git http://orgmode.org/w/?p=org-mode.git;a=commit;h=%s
|
||||
|
||||
Copyright (C) 2012-2013 Free Software Foundation, Inc.
|
||||
See the end of the file for license conditions.
|
||||
|
||||
Please send Org bug reports to emacs-orgmode@gnu.org.
|
||||
|
||||
* Version 8.2.3
|
||||
|
||||
** Incompatible changes
|
||||
|
||||
*** Combine org-mac-message.el and org-mac-link-grabber into org-mac-link.el
|
||||
|
||||
Please remove calls to =(require 'org-mac-message)= and =(require
|
||||
'org-mac-link-grabber)= in your =.emacs= initialization file. All you
|
||||
need now is =(require 'org-mac-link)=.
|
||||
|
||||
Additionally, replace any calls to =ogml-grab-link= to
|
||||
=org-mac-grab-link=. For example, replace this line:
|
||||
|
||||
: (define-key org-mode-map (kbd "C-c g") 'omgl-grab-link)
|
||||
|
||||
with this:
|
||||
|
||||
: (define-key org-mode-map (kbd "C-c g") 'org-mac-grab-link)
|
||||
|
||||
*** HTML export: Replace =HTML_HTML5_FANCY= by =:html-html5-fancy= (...)
|
||||
|
||||
Some of the HTML specific export options in Org <8.1 are either nil or
|
||||
t, like =#+HTML_INCLUDE_STYLE=. We replaced these binary options with
|
||||
option keywords like :html-include-style.
|
||||
|
||||
So you need to replace
|
||||
|
||||
: #+HTML_INCLUDE_STYLE: t
|
||||
|
||||
by
|
||||
|
||||
: #+OPTIONS: :html-include-style t
|
||||
|
||||
Options affected by this change: =HTML5_FANCY=, =HTML_INCLUDE_SCRIPTS=
|
||||
and =HTML_INCLUDE_STYLE=.
|
||||
|
||||
*** Add an argument to ~org-export-to-file~ and ~org-export-to-buffer~
|
||||
|
||||
~org-export-to-file~ and ~org-export-to-file~ can run in a different
|
||||
process when provided a non-nil =ASYNC= optional argument, without
|
||||
relying on ~org-export-async-start~ macro.
|
||||
|
||||
Since =ASYNC= is the first of optional arguments, you have to shift
|
||||
the other optional arguments accordingly.
|
||||
|
||||
*** Export back-ends are now structures
|
||||
|
||||
Export back-ends are now structures, and stored as such in the
|
||||
communication channel during an export process. In other words, from
|
||||
now on, ~(plist-get info :back-end)~ will return a structure instead
|
||||
of a symbol.
|
||||
|
||||
Arguments in hooks and in filters are still symbols, though.
|
||||
|
||||
** Important bugfixes
|
||||
|
||||
*** [[doc:org-insert-heading][org-insert-heading]] has been rewritten and bugs are now fixed
|
||||
*** The replacement of disputed keys is now turned of when reading a date
|
||||
|
||||
*** Match string for sparse trees can now contain a slash in a property value
|
||||
|
||||
You can now have searches like SOMEPROP="aaa/bbb". Until now,
|
||||
this would break because the slash would be interpreted as the
|
||||
separator starting a TOTO match string.
|
||||
** New features
|
||||
|
||||
*** =C-c ^ x= will now sort checklist items by their checked status
|
||||
|
||||
See [[doc:org-sort-list][org-sort-list]]: hitting =C-c ^ x= will put checked items at the end
|
||||
of the list.
|
||||
*** Various LaTeX export enhancements
|
||||
|
||||
- Support SVG images
|
||||
- Support for .pgf files
|
||||
- LaTeX Babel blocks can now be exported as =.tikz= files
|
||||
- Allow =latexmk= as an option for [[doc:org-latex-pdf-process][org-latex-pdf-process]]
|
||||
- When using =\usepackage[AUTO]{babel}=, AUTO will automatically be
|
||||
replaced with a value compatible with ~org-export-default-language~
|
||||
or ~LANGUAGE~ keyword.
|
||||
- The dependency on the =latexsym= LaTeX package has been removed, we
|
||||
now use =amssymb= symbols by default instead.
|
||||
|
||||
*** New functions for paragraph motion
|
||||
|
||||
The commands =C-down= and =C-up= now invoke special commands
|
||||
that use knowledge from the org-elements parser to move the cursor
|
||||
in a paragraph-like way.
|
||||
|
||||
*** New entities in =org-entities.el=
|
||||
|
||||
Add support for ell, imath, jmath, varphi, varpi, aleph, gimel, beth,
|
||||
dalet, cdots, S (§), dag, ddag, colon, therefore, because, triangleq,
|
||||
leq, geq, lessgtr, lesseqgtr, ll, lll, gg, ggg, prec, preceq,
|
||||
preccurleyeq, succ, succeq, succurleyeq, setminus, nexist(s), mho,
|
||||
check, frown, diamond. Changes loz, vert, checkmark, smile and tilde.
|
||||
|
||||
*** Anonymous export back-ends
|
||||
|
||||
~org-export-create-backend~ can create anonymous export back-ends,
|
||||
which can then be passed to export functions like
|
||||
~org-export-to-file~, ~org-export-to-buffer~ or ~org-export-as~.
|
||||
|
||||
It allows for quick translation of Org syntax without the overhead of
|
||||
registering a new back-end.
|
||||
|
||||
*** New agenda fortnight view
|
||||
|
||||
The agenda has not, in addition to day, week, month, and year
|
||||
views, also a fortnight view covering 14 days.
|
||||
** New options
|
||||
|
||||
*** New option [[doc:org-bookmark-names-plist][org-bookmark-names-plist]]
|
||||
|
||||
This allows to specify the names of automatic bookmarks.
|
||||
*** New option [[doc:org-agenda-ignore-drawer-properties][org-agenda-ignore-drawer-properties]]
|
||||
|
||||
This allows more flexibility when optimizing the agenda generation.
|
||||
See http://orgmode.org/worg/agenda-optimization.html for details.
|
||||
*** New option: [[doc:org-html-link-use-abs-url][org-html-link-use-abs-url]] to force using absolute URLs
|
||||
|
||||
This is an export/publishing option, and should be used either within
|
||||
the =#+OPTIONS= line(s) or within a [[doc:org-publish-project-alist][org-publish-project-alist]].
|
||||
|
||||
Setting this option to =t= is needed when the HTML output does not
|
||||
allow relative URLs. For example, the =contrib/lisp/ox-rss.el=
|
||||
library produces a RSS feed, and RSS feeds need to use absolute URLs,
|
||||
so a combination of =:html-link-home "..." and :html-link-use-abs-url
|
||||
t= is required---see the configuration example in the comment section
|
||||
of =ox-rss.el=.
|
||||
|
||||
*** New option [[doc:org-babel-ditaa-java-cmd][org-babel-ditaa-java-cmd]]
|
||||
|
||||
This makes java executable configurable for ditaa blocks.
|
||||
|
||||
*** New options [[doc:org-babel-latex-htlatex][org-babel-latex-htlatex]] and [[doc:org-babel-latex-htlatex-packages][org-babel-latex-htlatex-packages]]
|
||||
|
||||
This enables SVG generation from latex code blocks.
|
||||
|
||||
*** New option: [[doc:org-habit-show-done-alwyays-green][org-habit-show-done-alwyays-green]]
|
||||
|
||||
See [[http://lists.gnu.org/archive/html/emacs-orgmode/2013-05/msg00214.html][this message]] from Max Mikhanosha.
|
||||
|
||||
*** New option: [[doc:org-babel-inline-result-wrap][org-babel-inline-result-wrap]]
|
||||
|
||||
If you set this to the following
|
||||
|
||||
: (setq org-babel-inline-result-wrap "$%s$")
|
||||
|
||||
then inline code snippets will be wrapped into the formatting string.
|
||||
|
||||
*** New option: [[doc:org-special-ctrl-o][org-special-ctrl-o]]
|
||||
|
||||
This variable can be used to turn off the special behavior of
|
||||
=C-o= in tables.
|
||||
** New contributed packages
|
||||
|
||||
- =ox-bibtex.el= by Nicolas Goaziou :: an utility to handle BibTeX
|
||||
export to both LaTeX and HTML exports. It uses the [[http://www.lri.fr/~filliatr/bibtex2html/][bibtex2html]]
|
||||
software.
|
||||
|
||||
- =org-screenshot.el= by Max Mikhanosha :: an utility to handle
|
||||
screenshots easily from Org, using the external tool [[http://freecode.com/projects/scrot][scrot]].
|
||||
|
||||
* Version 8.0.1
|
||||
|
||||
** Installation
|
||||
|
||||
Installation instructions have been updated and simplified.
|
||||
|
||||
If you have troubles installing or updating Org, focus on these
|
||||
instructions:
|
||||
|
||||
- when updating via a =.zip/.tar.gz= file, you only need to set the
|
||||
=load-path= in your =.emacs=. Set it before any other Org
|
||||
customization that would call autoloaded Org functions.
|
||||
|
||||
- when updating by pulling Org's Git repository, make sure to create the
|
||||
correct autoloads. You can do this by running =~$ make autoloads= (to
|
||||
only create the autoloads) or by running =~$ make= (to also compile
|
||||
the Emacs lisp files.) =~$ make help= and =~$ make helpall= gives you
|
||||
detailed explanations.
|
||||
|
||||
- when updating through ELPA (either from GNU ELPA or from Org ELPA),
|
||||
you have to install Org's ELPA package in a session where no Org
|
||||
function has been called already.
|
||||
|
||||
When in doubt, run =M-x org-version RET= and see if you have a mixed-up
|
||||
installation.
|
||||
|
||||
See http://orgmode.org/org.html#Installation for details.
|
||||
|
||||
** Incompatible changes
|
||||
|
||||
Org 8.0 is the most disruptive major version of Org.
|
||||
|
||||
If you configured export options, you will have to update some of them.
|
||||
|
||||
If you used =#+ATTR_*= keywords, the syntax of the attributes changed and
|
||||
you will have to update them.
|
||||
|
||||
Below is a list of changes for which you need to take action.
|
||||
|
||||
See http://orgmode.org/worg/org-8.0.html for the most recent version of
|
||||
this list and for detailed instructions on how to migrate.
|
||||
|
||||
**** New export engine
|
||||
|
||||
Org 8.0 comes with a new export engine written by Nicolas Goaziou. This
|
||||
export engine relies on ~org-element.el~ (Org's syntax parser), which was
|
||||
already in Org's core. This new export engine triggered the rewriting of
|
||||
/all/ export back-ends.
|
||||
|
||||
The most visible change is the export dispatcher, accessible through the
|
||||
keybinding =C-c C-e=. By default, this menu only shows some of the
|
||||
built-in export formats, but you can add more formats by loading them
|
||||
directly (e.g., =(require 'ox-texinfo)= or by configuring the option
|
||||
[[doc:org-export-backends][org-export-backends]].
|
||||
|
||||
More contributed back-ends are available from the =contrib/= directory, the
|
||||
corresponding files start with the =ox-= prefix.
|
||||
|
||||
If you customized an export back-end (like HTML or LaTeX), you will need to
|
||||
rename some options so that your customization is not lost. Typically, an
|
||||
option starting with =org-export-html-= is now named =org-html-=. See the
|
||||
manual for details and check [[http://orgmode.org/worg/org-8.0.html][this Worg page]] for directions.
|
||||
|
||||
**** New syntax for #+ATTR_HTML/LaTeX/... options
|
||||
|
||||
: #+ATTR_HTML width="200px"
|
||||
|
||||
should now be written
|
||||
|
||||
: #+ATTR_HTML :width 200px
|
||||
|
||||
Keywords like =#+ATTR_HTML= and =#+ATTR_LaTeX= are defined in their
|
||||
respective back-ends, and the list of supported parameters depends on
|
||||
each backend. See Org's manual for details.
|
||||
|
||||
**** ~org-remember.el~ has been removed
|
||||
|
||||
You cannot use =remember.el= anymore to capture notes.
|
||||
|
||||
Support for remember templates has been obsoleted since long, it is
|
||||
now fully removed.
|
||||
|
||||
Use =M-x org-capture-import-remember-templates RET= to import your
|
||||
remember templates into capture templates.
|
||||
|
||||
**** ~org-jsinfo.el~ has been merged into ~ox-html.el~
|
||||
|
||||
If you were requiring ~ox-jsinfo.el~ in your ~.emacs.el~ file, you
|
||||
will have to remove this requirement from your initialization file.
|
||||
|
||||
**** Note for third-party developers
|
||||
|
||||
The name of the files for export back-end have changed: we now use the
|
||||
prefix =ox-= for those files (like we use the =ob-= prefix for Babel
|
||||
files.) For example ~org-html.el~ is now ~ox-html.el~.
|
||||
|
||||
If your code relies on these files, please update the names in your
|
||||
code.
|
||||
|
||||
**** Packages moved from core to contrib
|
||||
|
||||
Since packages in Org's core are meant to be part of GNU Emacs, we try
|
||||
to be minimalist when it comes to adding files into core. For 8.0, we
|
||||
moved some contributions into the =contrib/= directory.
|
||||
|
||||
The rationale for deciding that these files should live in =contrib/=
|
||||
is either because they rely on third-part softwares that are not
|
||||
included in Emacs, or because they are not targetting a significant
|
||||
user-base.
|
||||
|
||||
- org-colview-xemacs.el
|
||||
- org-mac-message.el
|
||||
- org-mew.el
|
||||
- org-wl.el
|
||||
- ox-freedmind.el
|
||||
- ox-taskjuggler.el
|
||||
|
||||
Note that ~ox-freedmind.el~ has been rewritten by Jambunathan,
|
||||
~org-mew.el~ has been enhanced by Tokuya Kameshima and
|
||||
~ox-taskjuggler.el~ by Nicolas Goaziou and others.
|
||||
|
||||
Also, the Taskjuggler exporter now uses TJ3 by default. John Hendy
|
||||
wrote [[http://orgmode.org/worg/org-tutorials/org-taskjuggler3.html][a tutorial on Worg]] for the TJ3 export.
|
||||
|
||||
** New packages in core
|
||||
|
||||
*** ~ob-makefile.el~ by Eric Schulte and Thomas S. Dye
|
||||
|
||||
=ob-makefile.el= implements Org Babel support for Makefile tangling.
|
||||
|
||||
*** ~ox-man.el~ by Luis Anaya
|
||||
|
||||
=ox-man.el= allows you to export Org files to =man= pages.
|
||||
|
||||
*** ~ox-md.el~ by Nicolas Goaziou
|
||||
|
||||
=ox-md.el= allows you to export Org files to Markdown files, using the
|
||||
vanilla [[http://daringfireball.net/projects/markdown/][Markdown syntax]].
|
||||
|
||||
*** ~ox-texinfo.el~ by Jonathan Leech-Pepin
|
||||
|
||||
=ox-texinfo.el= allows you to export Org files to [[http://www.gnu.org/software/texinfo/][Texinfo]] files.
|
||||
|
||||
** New packages in contrib
|
||||
|
||||
*** ~ob-julia.el~ by G. Jay Kerns
|
||||
|
||||
[[http://julialang.org/][Julia]] is a new programming language.
|
||||
|
||||
=ob-julia.el= provides Org Babel support for evaluating Julia source
|
||||
code.
|
||||
|
||||
*** ~ob-mathomatic.el~ by Luis Anaya
|
||||
|
||||
[[http://www.mathomatic.org/][mathomatic]] a portable, command-line, educational CAS and calculator
|
||||
software, written entirely in the C programming language.
|
||||
|
||||
~ob-mathomatic.el~ provides Org Babel support for evaluating mathomatic
|
||||
entries.
|
||||
|
||||
*** ~ob-tcl.el~ by Luis Anaya
|
||||
|
||||
~ob-tcl.el~ provides Org Babel support for evaluating [[http://www.tcl.tk/][Tcl]] source code.
|
||||
|
||||
*** ~org-bullets.el~ by Evgeni Sabof
|
||||
|
||||
Display bullets instead of stars for headlines.
|
||||
|
||||
Also see [[http://orgmode.org/worg/org-faq.html#sec-8-12][this updated FAQ]] on how to display another character than "*"
|
||||
for starting headlines.
|
||||
|
||||
*** ~org-favtable.el~ by Marc-Oliver Ihm
|
||||
|
||||
~org-favtable.el~ helps you to create and update a table of favorite
|
||||
locations in org, keeping the most frequently visited lines right at
|
||||
the top. This table is called "favtable". See the documentation on
|
||||
[[http://orgmode.org/worg/org-contrib/org-favtable.html][Worg]].
|
||||
|
||||
*** ~ox-confluence.el~ by Sébastien Delafond
|
||||
|
||||
~ox-confluence.el~ lets you convert Org files to [[https://confluence.atlassian.com/display/DOC/Confluence%2BWiki%2BMarkup][Confluence Wiki]] files.
|
||||
|
||||
*** ~ox-deck.el~ and ~ox-s5.el~ by Rick Frankel
|
||||
|
||||
[[http://imakewebthings.com/deck.js/][deck.js]] is a javascript library for displaying HTML ages as
|
||||
presentations. ~ox-deck.el~ exports Org files to HTML presentations
|
||||
using =deck.js=.
|
||||
|
||||
[[http://meyerweb.com/eric/tools/s5/][s5]] is a set of scripts which also allows to display HTML pages as
|
||||
presentations. ~ox-s5.el~ exports Org files to HTML presentations
|
||||
using =s5=.
|
||||
|
||||
*** ~ox-groff.el~ by Luis Anaya and Nicolas Goaziou
|
||||
|
||||
The [[http://www.gnu.org/software/groff/][groff]] (GNU troff) software is a typesetting package which reads
|
||||
plain text mixed with formatting commands and produces formatted
|
||||
output.
|
||||
|
||||
Luis Anaya and Nicolas Goaziou implemented ~ox-groff.el~ to allow
|
||||
conversion from Org files to groff.
|
||||
|
||||
*** ~ox-koma-letter.el~ by Nicolas Goaziou and Alan Schmitt
|
||||
|
||||
This back-end allow to export Org pages to the =KOMA Scrlttr2= format.
|
||||
|
||||
*** ~ox-rss.el~ by Bastien
|
||||
|
||||
This back-end lets you export Org pages to RSS 2.0 feeds. Combined
|
||||
with the HTML publishing feature, this allows you to build a blog
|
||||
entirely with Org.
|
||||
|
||||
** New features
|
||||
|
||||
*** Export
|
||||
|
||||
**** New export generic options
|
||||
|
||||
If you use Org exporter, we advise you to re-read [[http://orgmode.org/org.html#Exporting][the manual section about
|
||||
it]]. It has been updated and includes new options.
|
||||
|
||||
Among the new/updated export options, three are of particular importance:
|
||||
|
||||
- [[doc:org-export-allow-bind-keywords][org-export-allow-bind-keywords]] :: This option replaces the old option
|
||||
=org-export-allow-BIND= and the default value is =nil=, not =confirm=.
|
||||
You will need to explicitely set this to =t= in your initialization
|
||||
file if you want to allow =#+BIND= keywords.
|
||||
|
||||
- [[doc:org-export-with-planning][org-export-with-planning]] :: This new option controls the export of
|
||||
=SCHEDULED:, DEADLINE:, CLOSED:= lines, and planning information is
|
||||
now skipped by default during export. This use to be the job of
|
||||
[[doc:org-export-with-timestamps][org-export-with-timestamps]], but this latter option has been given a
|
||||
new role: it controls the export of /standalone time-stamps/. When
|
||||
set to =nil=, Org will not export active and inactive time-stamps
|
||||
standing on a line by themselves or within a paragraph that only
|
||||
contains time-stamps.
|
||||
|
||||
To check if an option has been introduced or its default value changed in
|
||||
Org 8.0, do =C-h v [option] RET= and check if the documentation says that
|
||||
the variable has been introduced (or changed) in version 24.4 of Emacs.
|
||||
|
||||
**** Enhanced default stylesheet for the HTML exporter
|
||||
|
||||
See the new default value of [[doc:org-html-style-default][org-html-style-default]].
|
||||
|
||||
**** New tags, classes and ids for the HTML exporter
|
||||
|
||||
See the new default value of [[doc:org-html-divs][org-html-divs]].
|
||||
|
||||
**** Support for tikz pictures in LaTeX export
|
||||
**** ~org-man.el~: New export function for "man" links
|
||||
**** ~org-docview.el~: New export function for docview links
|
||||
*** Structure editing
|
||||
|
||||
**** =C-u C-u M-RET= inserts a heading at the end of the parent subtree
|
||||
**** Cycling to the =CONTENTS= view keeps inline tasks folded
|
||||
|
||||
[[doc:org-cycle-hook][org-cycle-hook]] as a new function [[doc:org-cycle-hide-inline-tasks][org-cycle-hide-inline-tasks]] which
|
||||
prevents the display of inline tasks when showing the content of a subtree.
|
||||
|
||||
**** =C-c -= in a region makes a list item for each line
|
||||
|
||||
This is the opposite of the previous behavior, where =C-c -= on a region
|
||||
would create one item for the whole region, and where =C-u C-c -= would
|
||||
create an item for each line. Now =C-c -= on the selected region creates
|
||||
an item per line, and =C-u C-c -= creates a single item for the whole
|
||||
region.
|
||||
|
||||
**** When transposing words, markup characters are now part of the words
|
||||
|
||||
In Emacs, you can transpose words with =M-t=. Transposing =*these*
|
||||
_words__= will preserve markup.
|
||||
|
||||
**** New command [[doc:org-set-property-and-value][org-set-property-and-value]] bound to =C-c C-x P=
|
||||
|
||||
This command allows you to quickly add both the property and its value. It
|
||||
is useful in buffers where there are many properties and where =C-c C-x p=
|
||||
can slow down the flow of editing too much.
|
||||
|
||||
**** New commands [[doc:org-next-block][org-next-block]] and [[doc:org-previous-block][org-previous-block]]
|
||||
|
||||
These commands allow you to go to the previous block (=C-c M-b= or the
|
||||
speedy key =B=) or to the next block (=C-c M-f= or the speedy key =F=.)
|
||||
|
||||
**** New commands [[doc:org-drag-line-forward][org-drag-line-forward]] and [[doc:org-drag-line-backward][org-drag-line-backward]]
|
||||
|
||||
These commands emulate the old behavior of =M-<down>= and =M-<up>= but are
|
||||
now bound to =S-M-<down>= and =S-M-<up>= respectively, since =M-<down>= and
|
||||
=M-<up>= now drag the whole element at point (a paragraph, a table, etc.)
|
||||
forward and backward.
|
||||
|
||||
**** When a list item has a checkbox, inserting a new item uses a checkbox too
|
||||
**** When sorting entries/items, only the description of links is considered
|
||||
|
||||
Now Org will sort this list
|
||||
|
||||
: - [[http://abc.org][B]]
|
||||
: - [[http://def.org][A]]
|
||||
|
||||
like this:
|
||||
|
||||
: - [[http://def.org][A]]
|
||||
: - [[http://abc.org][B]]
|
||||
|
||||
by comparing the descriptions, not the links.
|
||||
Same when sorting headlines instead of list items.
|
||||
**** New option =orgstruct-heading-prefix-regexp=
|
||||
|
||||
For example, setting this option to "^;;; " in Emacs lisp files and using
|
||||
=orgstruct-mode= in those files will allow you to cycle through visibility
|
||||
states as if lines starting with ";;; *..." where headlines.
|
||||
|
||||
In general, you want to set =orgstruct-heading-prefix-regexp= as a file
|
||||
local variable.
|
||||
|
||||
**** New behavior of [[doc:org-clone-subtree-with-time-shift][org-clone-subtree-with-time-shift]]
|
||||
|
||||
The default is now to ask for a time-shift only when there is a time-stamp.
|
||||
When called with a universal prefix argument =C-u=, it will not ask for a
|
||||
time-shift even if there is a time-stamp.
|
||||
|
||||
**** New option [[doc:org-agenda-restriction-lock-highlight-subtree][org-agenda-restriction-lock-highlight-subtree]]
|
||||
|
||||
This defaults to =t= so that the whole subtree is highlighted when you
|
||||
restrict the agenda view to it with =C-c C-x <= (or the speed command =<=).
|
||||
The default setting helps ensuring that you are not adding tasks after the
|
||||
restricted region. If you find this highlighting too intrusive, set this
|
||||
option to =nil=.
|
||||
**** New option [[doc:org-closed-keep-when-no-todo][org-closed-keep-when-no-todo]]
|
||||
|
||||
When switching back from a =DONE= keyword to a =TODO= keyword, Org now
|
||||
removes the =CLOSED= planning information, if any. It also removes this
|
||||
information when going back to a non-TODO state (e.g., with =C-c C-t SPC=).
|
||||
If you want to keep the =CLOSED= planning information when removing the
|
||||
TODO keyword, set [[doc:org-closed-keep-when-no-todo][org-closed-keep-when-no-todo]] to =t=.
|
||||
|
||||
**** New option [[doc:org-image-actual-width][org-image-actual-width]]
|
||||
|
||||
This option allows you to change the width of in-buffer displayed images.
|
||||
The default is to use the actual width of the image, but you can use a
|
||||
fixed value for all images, or fall back on an attribute like
|
||||
|
||||
: #+attr_html: :width 300px
|
||||
*** Scheduled/deadline
|
||||
|
||||
**** Implement "delay" cookies for scheduled items
|
||||
|
||||
If you want to delay the display of a scheduled task in the agenda, you can
|
||||
now use a delay cookie like this: =SCHEDULED: <2004-12-25 Sat -2d>=. The
|
||||
task is still scheduled on the 25th but will appear in your agenda starting
|
||||
from two days later (i.e. from March 27th.)
|
||||
|
||||
Imagine for example that your co-workers are not done in due time and tell
|
||||
you "we need two more days". In that case, you may want to delay the
|
||||
display of the task in your agenda by two days, but you still want the task
|
||||
to appear as scheduled on March 25th.
|
||||
|
||||
In case the task contains a repeater, the delay is considered to affect all
|
||||
occurrences; if you want the delay to only affect the first scheduled
|
||||
occurrence of the task, use =--2d= instead. See [[doc:org-scheduled-delay-days][org-scheduled-delay-days]]
|
||||
and [[doc:org-agenda-skip-scheduled-delay-if-deadline][org-agenda-skip-scheduled-delay-if-deadline]] for details on how to
|
||||
control this globally or per agenda.
|
||||
|
||||
**** Use =C-u C-u C-c C-s= will insert a delay cookie for scheduled tasks
|
||||
|
||||
See the previous section for why delay cookies may be useful.
|
||||
|
||||
**** Use =C-u C-u C-c C-d= will insert a warning delay for deadline tasks
|
||||
|
||||
=C-u C-u C-c C-d= now inserts a warning delay to deadlines.
|
||||
*** Calendar, diary and appts
|
||||
|
||||
**** New variable [[doc:org-read-date-minibuffer-local-map][org-read-date-minibuffer-local-map]]
|
||||
|
||||
By default, this new local map uses "." to go to today's date, like in the
|
||||
normal =M-x calendar RET=. If you want to deactivate this and to reassign
|
||||
the "@" key to =calendar-goto-today=, use this:
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
;; Unbind "." in Org's calendar:
|
||||
(define-key org-read-date-minibuffer-local-map (kbd ".") nil)
|
||||
|
||||
;; Bind "@" to `calendar-goto-today':
|
||||
(define-key org-read-date-minibuffer-local-map
|
||||
(kbd "@")
|
||||
(lambda () (interactive) (org-eval-in-calendar '(calendar-goto-today))))
|
||||
#+END_SRC
|
||||
|
||||
**** In Org's calendar, =!= displays diary entries of the date at point
|
||||
|
||||
This is useful when you want to check if you don't already have an
|
||||
appointment when setting new ones with =C-c .= or =C-c s=. =!= will
|
||||
call =diary-view-entries= and display the diary in a separate buffer.
|
||||
|
||||
**** [[doc:org-diary][org-diary]]: only keep the descriptions of links
|
||||
|
||||
[[doc:org-diary][org-diary]] returns diary information from Org files, but it returns it
|
||||
in a diary buffer, not in an Org mode buffer. When links are displayed,
|
||||
only show their description, not the full links.
|
||||
*** Agenda
|
||||
|
||||
**** New agenda type =agenda*= and entry types =:scheduled* :deadline*=
|
||||
|
||||
When defining agenda custom commands, you can now use =agenda*=: this will
|
||||
list entries that have both a date and a time. This is useful when you
|
||||
want to build a list of appointments.
|
||||
|
||||
You can also set [[doc:org-agenda-entry-types][org-agenda-entry-types]] either globally or locally in
|
||||
each agenda custom command and use =:timestamp*= and/or =:deadline*= there.
|
||||
|
||||
Another place where this is useful is your =.diary= file:
|
||||
|
||||
: %%(org-diary :scheduled*) ~/org/rdv.org
|
||||
|
||||
This will list only entries from =~/org/rdv.org= that are scheduled with a
|
||||
time value (i.e. appointments).
|
||||
|
||||
**** New agenda sorting strategies
|
||||
|
||||
[[doc:org-agenda-sorting-strategy][org-agenda-sorting-strategy]] allows these new sorting strategies:
|
||||
|
||||
| Strategy | Explanations |
|
||||
|----------------+------------------------------------------|
|
||||
| timestamp-up | Sort by any timestamp, early first |
|
||||
| timestamp-down | Sort by any timestamp, late first |
|
||||
| scheduled-up | Sort by scheduled timestamp, early first |
|
||||
| scheduled-down | Sort by scheduled timestamp, late first |
|
||||
| deadline-up | Sort by deadline timestamp, early first |
|
||||
| deadline-down | Sort by deadline timestamp, late first |
|
||||
| ts-up | Sort by active timestamp, early first |
|
||||
| ts-down | Sort by active timestamp, late first |
|
||||
| tsia-up | Sort by inactive timestamp, early first |
|
||||
| tsia-down | Sort by inactive timestamp, late first |
|
||||
|
||||
**** New options to limit the number of agenda entries
|
||||
|
||||
You can now limit the number of entries in an agenda view. This is
|
||||
different from filters: filters only /hide/ the entries in the agenda,
|
||||
while limits are set while generating the list of agenda entries.
|
||||
|
||||
These new options are available:
|
||||
|
||||
- [[doc:org-agenda-max-entries][org-agenda-max-entries]] :: limit by number of entries.
|
||||
- [[doc:org-agenda-max-todos][org-agenda-max-todos]] :: limit by number of TODOs.
|
||||
- [[doc:org-agenda-max-tags][org-agenda-max-tags]] :: limit by number of tagged entries.
|
||||
- [[doc:org-agenda-max-effort][org-agenda-max-effort]] :: limit by effort (minutes).
|
||||
|
||||
For example, if you locally set [[doc:org-agenda-max-todos][org-agenda-max-todos]] to 3 in an agenda
|
||||
view, the agenda will be limited to the first three todos. Other entries
|
||||
without a TODO keyword or beyond the third TODO headline will be ignored.
|
||||
|
||||
When setting a limit (e.g. about an effort's sum), the default behavior is
|
||||
to exclude entries that cannot be checked against (e.g. entries that have
|
||||
no effort property.) To include other entries too, you can set the limit
|
||||
to a negative number. For example =(setq org-agenda-max-tags -3)= will not
|
||||
show the fourth tagged headline (and beyond), but it will also show
|
||||
non-tagged headlines.
|
||||
|
||||
**** =~= in agenda view sets temporary limits
|
||||
|
||||
You can hit =~= in the agenda to temporarily set limits: this will
|
||||
regenerate the agenda as if the limits were set. This is useful for
|
||||
example when you want to only see a list of =N= tasks, or a list of tasks
|
||||
that take only =N= minutes.
|
||||
|
||||
**** "=" in agenda view filters by regular expressions
|
||||
|
||||
You can now filter agenda entries by regular expressions using ~=~. =C-u
|
||||
== will filter entries out. Regexp filters are cumulative. You can set
|
||||
[[doc:org-agenda-regexp-filter-preset][org-agenda-regexp-filter-preset]] to suit your needs in each agenda view.
|
||||
|
||||
**** =|= in agenda view resets all filters
|
||||
|
||||
Since it's common to combine tag filters, category filters, and now regexp
|
||||
filters, there is a new command =|= to reset all filters at once.
|
||||
|
||||
**** Allow writing an agenda to an =.org= file
|
||||
|
||||
You can now write an agenda view to an =.org= file. It copies the
|
||||
headlines and their content (but not subheadings) into the new file.
|
||||
|
||||
This is useful when you want to quickly share an agenda containing the full
|
||||
list of notes.
|
||||
|
||||
**** New commands to drag an agenda line forward (=M-<down>=) or backard (=M-<up>=)
|
||||
|
||||
It sometimes handy to move agenda lines around, just to quickly reorganize
|
||||
your tasks, or maybe before saving the agenda to a file. Now you can use
|
||||
=M-<down>= and =M-<up>= to move the line forward or backward.
|
||||
|
||||
This does not persist after a refresh of the agenda, and this does not
|
||||
change the =.org= files who contribute to the agenda.
|
||||
|
||||
**** Use =%b= for displaying "breadcrumbs" in the agenda view
|
||||
|
||||
[[doc:org-agenda-prefix-format][org-agenda-prefix-format]] now allows to use a =%b= formatter to tell Org
|
||||
to display "breadcrumbs" in the agenda view.
|
||||
|
||||
This is useful when you want to display the task hierarchy in your agenda.
|
||||
|
||||
**** Use =%l= for displaying the headline's level in the agenda view
|
||||
|
||||
[[doc:org-agenda-prefix-format][org-agenda-prefix-format]] allows to use a =%l= formatter to tell Org to
|
||||
display entries with additional spaces corresponding to their level in the
|
||||
outline tree.
|
||||
|
||||
**** [[doc:org-agenda-write][org-agenda-write]] will ask before overwriting an existing file
|
||||
|
||||
=M-x org-agenda-write RET= (or =C-c C-w= from an agenda buffer) used to
|
||||
overwrite preexisting file with the same name without confirmation. It now
|
||||
asks for a confirmation.
|
||||
|
||||
**** New commands =M-m= and =M-*= to toggle (all) mark(s) for bulk action
|
||||
|
||||
- [[doc:org-agenda-bulk-toggle][org-agenda-bulk-toggle]] :: this command is bound to =M-m= and toggles
|
||||
the mark of the entry at point.
|
||||
|
||||
- [[doc:org-agenda-bulk-toggle-all][org-agenda-bulk-toggle-all]] :: this command is bound to =M-*= and
|
||||
toggles all the marks in the current agenda.
|
||||
|
||||
**** New option [[doc:org-agenda-search-view-max-outline-level][org-agenda-search-view-max-outline-level]]
|
||||
|
||||
This option sets the maximum outline level to display in search view.
|
||||
E.g. when this is set to 1, the search view will only show headlines of
|
||||
level 1.
|
||||
|
||||
**** New option [[doc:org-agenda-todo-ignore-time-comparison-use-seconds][org-agenda-todo-ignore-time-comparison-use-seconds]]
|
||||
|
||||
This allows to compare times using seconds instead of days when honoring
|
||||
options like =org-agenda-todo-ignore-*= in the agenda display.
|
||||
|
||||
**** New option [[doc:org-agenda-entry-text-leaders][org-agenda-entry-text-leaders]]
|
||||
|
||||
This allows you to get rid of the ">" character that gets added in front of
|
||||
entries excerpts when hitting =E= in the agenda view.
|
||||
|
||||
**** New formatting string for past deadlines in [[doc:org-agenda-deadline-leaders][org-agenda-deadline-leaders]]
|
||||
|
||||
The default formatting for past deadlines is ="%2d d. ago: "=, which makes
|
||||
it explicit that the deadline is in the past. You can configure this via
|
||||
[[doc:org-agenda-deadline-leaders][org-agenda-deadline-leaders]]. Note that the width of the formatting
|
||||
string is important to keep the agenda alignment clean.
|
||||
|
||||
**** New allowed value =repeated-after-deadline= for [[doc:org-agenda-skip-scheduled-if-deadline-is-shown][org-agenda-skip-scheduled-if-deadline-is-shown]]
|
||||
|
||||
When [[doc:org-agenda-skip-scheduled-if-deadline-is-shown][org-agenda-skip-scheduled-if-deadline-is-shown]] is set to
|
||||
=repeated-after-deadline=, the agenda will skip scheduled items if they are
|
||||
repeated beyond the current dealine.
|
||||
|
||||
**** New option for [[doc:org-agenda-skip-deadline-prewarning-if-scheduled][org-agenda-skip-deadline-prewarning-if-scheduled]]
|
||||
|
||||
This variable may be set to nil, t, the symbol `pre-scheduled', or a number
|
||||
which will then give the number of days before the actual deadline when the
|
||||
prewarnings should resume. The symbol `pre-scheduled' eliminates the
|
||||
deadline prewarning only prior to the scheduled date.
|
||||
|
||||
Read the full docstring for details.
|
||||
|
||||
**** [[doc:org-class][org-class]] now supports holiday strings in the skip-weeks parameter
|
||||
|
||||
For example, this task will now be skipped only on new year's day:
|
||||
|
||||
: * Task
|
||||
: <%%(org-class 2012 1 1 2013 12 12 2 "New Year's Day")>
|
||||
*** Capture
|
||||
|
||||
**** Allow =C-1= as a prefix for [[doc:org-agenda-capture][org-agenda-capture]] and [[doc:org-capture][org-capture]]
|
||||
|
||||
With a =C-1= prefix, the capture mechanism will use the =HH:MM= value at
|
||||
point (if any) or the current =HH:MM= time as the default time for the
|
||||
capture template.
|
||||
|
||||
**** Expand keywords within %(sexp) placeholder in capture templates
|
||||
|
||||
If you use a =%:keyword= construct within a =%(sexp)= construct, Org will
|
||||
expand the keywords before expanding the =%(sexp)=.
|
||||
|
||||
**** Allow to contextualize capture (and agenda) commands by checking the name of the buffer
|
||||
|
||||
[[doc:org-capture-templates-contexts][org-capture-templates-contexts]] and [[doc:org-agenda-custom-commands-contexts][org-agenda-custom-commands-contexts]]
|
||||
allow you to define what capture templates and what agenda commands should
|
||||
be available in various contexts. It is now possible for the context to
|
||||
check against the name of the buffer.
|
||||
*** Tag groups
|
||||
|
||||
Using =#+TAGS: { Tag1 : Tag2 Tag3 }= will define =Tag1= as a /group tag/
|
||||
(note the colon after =Tag1=). If you search for =Tag1=, it will return
|
||||
headlines containing either =Tag1=, =Tag2= or =Tag3= (or any combinaison
|
||||
of those tags.)
|
||||
|
||||
You can use group tags for sparse tree in an Org buffer, for creating
|
||||
agenda views, and for filtering.
|
||||
|
||||
See http://orgmode.org/org.html#Tag-groups for details.
|
||||
|
||||
*** Links
|
||||
|
||||
**** =C-u C-u M-x org-store-link RET= will ignore non-core link functions
|
||||
|
||||
Org knows how to store links from Org buffers, from info files and from
|
||||
other Emacs buffers. Org can be taught how to store links from any buffer
|
||||
through new link protocols (see [[http://orgmode.org/org.html#Adding-hyperlink-types]["Adding hyperlink types"]] in the manual.)
|
||||
|
||||
Sometimes you want Org to ignore added link protocols and store the link
|
||||
as if the protocol was not known.
|
||||
|
||||
You can now do this with =C-u C-u M-x org-store-link RET=.
|
||||
|
||||
**** =C-u C-u C-u M-x org-store-link RET= on an active region will store links for each lines
|
||||
|
||||
Imagine for example that you want to store a link for every message in a
|
||||
Gnus summary buffer. In that case =C-x h C-u C-u C-u M-x org-store-link
|
||||
RET= will store a link for every line (i.e. message) if the region is
|
||||
active.
|
||||
|
||||
**** =C-c C-M-l= will add a default description for links which don't have one
|
||||
|
||||
=C-c C-M-l= inserts all stored links. If a link does not have a
|
||||
description, this command now adds a default one, so that we are not mixing
|
||||
with-description and without-description links when inserting them.
|
||||
|
||||
**** No curly braces to bracket links within internal links
|
||||
|
||||
When storing a link to a headline like
|
||||
|
||||
: * See [[http://orgmode.org][Org website]]
|
||||
|
||||
[[doc:org-store-link][org-store-link]] used to convert the square brackets into curly brackets.
|
||||
It does not anymore, taking the link description or the link path, when
|
||||
there is no description.
|
||||
*** Table
|
||||
|
||||
**** Switching between #+TBLFM lines
|
||||
|
||||
If you have several =#+TBLFM= lines below a table, =C-c C-c= on a line will
|
||||
apply the formulas from this line, and =C-c C-c= on another line will apply
|
||||
those other formulas.
|
||||
|
||||
**** You now use "nan" for empty fields in Calc formulas
|
||||
|
||||
If empty fields are of interest, it is recommended to reread the section
|
||||
[[http://orgmode.org/org.html#Formula-syntax-for-Calc][3.5.2 Formula syntax for Calc]] of the manual because the description for the
|
||||
mode strings has been clarified and new examples have been added towards
|
||||
the end.
|
||||
|
||||
**** Handle localized time-stamps in formulas evaluation
|
||||
|
||||
If your =LOCALE= is set so that Org time-stamps use another language than
|
||||
english, and if you make time computations in Org's table, it now works by
|
||||
internally converting the time-stamps with a temporary =LOCALE=C= before
|
||||
doing computation.
|
||||
|
||||
**** New lookup functions
|
||||
|
||||
There are now three lookup functions:
|
||||
|
||||
- [[doc:org-loopup-first][org-loopup-first]]
|
||||
- [[doc:org-loopup-last][org-loopup-last]]
|
||||
- [[doc:org-loopup-all][org-loopup-all]]
|
||||
|
||||
See [[http://orgmode.org/org.html#Lookup-functions][the manual]] for details.
|
||||
*** Startup keywords
|
||||
|
||||
These new startup keywords are now available:
|
||||
|
||||
| Startup keyword | Option |
|
||||
|----------------------------------+---------------------------------------------|
|
||||
| =#+STARTUP: logdrawer= | =(setq org-log-into-drawer t)= |
|
||||
| =#+STARTUP: nologdrawer= | =(setq org-log-into-drawer nil)= |
|
||||
|----------------------------------+---------------------------------------------|
|
||||
| =#+STARTUP: logstatesreversed= | =(setq org-log-states-order-reversed t)= |
|
||||
| =#+STARTUP: nologstatesreversed= | =(setq org-log-states-order-reversed nil)= |
|
||||
|----------------------------------+---------------------------------------------|
|
||||
| =#+STARTUP: latexpreview= | =(setq org-startup-with-latex-preview t)= |
|
||||
| =#+STARTUP: nolatexpreview= | =(setq org-startup-with-latex-preview nil)= |
|
||||
|
||||
*** Clocking
|
||||
|
||||
**** New option [[doc:org-clock-rounding-minutes][org-clock-rounding-minutes]]
|
||||
|
||||
E.g. if [[doc:org-clock-rounding-minutes][org-clock-rounding-minutes]] is set to 5, time is 14:47 and you
|
||||
clock in: then the clock starts at 14:45. If you clock out within the next
|
||||
5 minutes, the clock line will be removed; if you clock out 8 minutes after
|
||||
your clocked in, the clock out time will be 14:50.
|
||||
|
||||
**** New option [[doc:org-time-clocksum-use-effort-durations][org-time-clocksum-use-effort-durations]]
|
||||
|
||||
When non-nil, =C-c C-x C-d= uses effort durations. E.g., by default, one
|
||||
day is considered to be a 8 hours effort, so a task that has been clocked
|
||||
for 16 hours will be displayed as during 2 days in the clock display or in
|
||||
the clocktable.
|
||||
|
||||
See [[doc:org-effort-durations][org-effort-durations]] on how to set effort durations and
|
||||
[[doc:org-time-clocksum-format][org-time-clocksum-format]] for more on time clock formats.
|
||||
|
||||
**** New option [[doc:org-clock-x11idle-program-name][org-clock-x11idle-program-name]]
|
||||
|
||||
This allows to set the name of the program which prints X11 idle time in
|
||||
milliseconds. The default is to use =x11idle=.
|
||||
|
||||
**** New option [[doc:org-use-last-clock-out-time-as-effective-time][org-use-last-clock-out-time-as-effective-time]]
|
||||
|
||||
When non-nil, use the last clock out time for [[doc:org-todo][org-todo]]. Note that this
|
||||
option has precedence over the combined use of [[doc:org-use-effective-time][org-use-effective-time]] and
|
||||
[[doc:org-extend-today-until][org-extend-today-until]].
|
||||
|
||||
**** =S-<left/right>= on a clocksum column will update the sum by updating the last clock
|
||||
**** =C-u 3 C-S-<up/down>= will update clock timestamps synchronously by 3 units
|
||||
**** New parameter =:wstart= for clocktables to define the week start day
|
||||
**** New parameter =:mstart= to state the starting day of the month
|
||||
**** Allow relative times in clocktable tstart and tend options
|
||||
**** The clocktable summary is now a caption
|
||||
**** =:tstart= and =:tend= and friends allow relative times like "<-1w>" or "<now>"
|
||||
*** Babel
|
||||
|
||||
**** You can now use =C-c C-k= for [[doc:org-edit-src-abort][org-edit-src-abort]]
|
||||
|
||||
This allows you to quickly cancel editing a source block.
|
||||
|
||||
**** =C-u C-u M-x org-babel-tangle RET= tangles by the target file of the block at point
|
||||
|
||||
This is handy if you want to tangle all source code blocks that have the
|
||||
same target than the block at point.
|
||||
|
||||
**** New options for auto-saving the base buffer or the source block editing buffer
|
||||
|
||||
When [[doc:org-edit-src-turn-on-auto-save][org-edit-src-turn-on-auto-save]] is set to =t=, editing a source block
|
||||
in a new window will turn on =auto-save-mode= and save the code in a new
|
||||
file under the same directory than the base Org file.
|
||||
|
||||
When [[doc:org-edit-src-auto-save-idle-delay][org-edit-src-auto-save-idle-delay]] is set to a number of minutes =N=,
|
||||
the base Org buffer will be saved after this number of minutes of idle
|
||||
time.
|
||||
|
||||
**** New =:post= header argument post-processes results
|
||||
|
||||
This header argument may be used to pass the results of the current
|
||||
code block through another code block for post-processing. See the
|
||||
manual for a usage example.
|
||||
|
||||
**** Commented out heading are ignored when collecting blocks for tangling
|
||||
|
||||
If you comment out a heading (with =C-c ;= anywhere on the heading or in
|
||||
the subtree), code blocks from within this heading are now ignored when
|
||||
collecting blocks for tangling.
|
||||
|
||||
**** New option [[doc:org-babel-hash-show-time][org-babel-hash-show-time]] to show a time-stamp in the result hash
|
||||
**** Do not ask for confirmation if cached value is current
|
||||
|
||||
Do not run [[doc:org-babel-confirm-evaluate][org-babel-confirm-evaluate]] if source block has a cache and the
|
||||
cache value is current as there is no evaluation involved in this case.
|
||||
**** =ob-sql.el= and =ob-python.el= have been improved.
|
||||
**** New Babel files only need to =(require 'ob)=
|
||||
|
||||
When writing a new Babel file, you now only need to use =(require 'ob)=
|
||||
instead of requiring each Babel library one by one.
|
||||
*** Faces
|
||||
|
||||
- Org now fontifies radio link targets by default
|
||||
- In the agenda, use [[doc:org-todo-keyword-faces][org-todo-keyword-faces]] to highlight selected TODO keywords
|
||||
- New face [[doc:org-priority][org-priority]], enhanced fontification of priority cookies in agenda
|
||||
- New face [[doc:org-tag-group][org-tag-group]] for group tags
|
||||
|
||||
** Miscellaneous
|
||||
|
||||
- New speedy key =s= pour [[doc:org-narrow-to-subtree][org-narrow-to-subtree]]
|
||||
- Handling of [[doc:org-html-table-row][org-html-table-row]] has been updated (incompatible change)
|
||||
- [[doc:org-export-html-table-tag][org-export-html-table-tag]] is replaced by [[doc:org-html-table-default-attributes][org-html-table-default-attributes]]
|
||||
- Support using =git-annex= with Org attachments
|
||||
- org-protocol: Pass optional value using query in url to capture from protocol
|
||||
- When the refile history is empty, use the current filename as default
|
||||
- When you cannot change the TODO state of a task, Org displays the blocking task
|
||||
- New option [[doc:org-mobile-allpriorities][org-mobile-allpriorities]]
|
||||
- org-bibtex.el now use =visual-line-mode= instead of the deprecated =longlines-mode=
|
||||
- [[doc:org-format-latex-options][org-format-latex-options]] allows to set the foreground/background colors automatically
|
||||
- New option [[doc:org-archive-file-header-format][org-archive-file-header-format]]
|
||||
- New "neg" entity in [[doc:org-entities][org-entities]]
|
||||
- New function [[doc:org-docview-export][org-docview-export]] to export docview links
|
||||
- New =:eps= header argument for ditaa code blocks
|
||||
- New option [[doc:org-gnus-no-server][org-gnus-no-server]] to start Gnus with =gnus-no-server=
|
||||
- Org is now distributed with =htmlize.el= version 1.43
|
||||
- ~org-drill.el~ has been updated to version 2.3.7
|
||||
- ~org-mac-iCal.el~ now supports MacOSX version up to 10.8
|
||||
- Various improvements to ~org-contacts.el~ and =orgpan.el=
|
||||
|
||||
** Outside Org
|
||||
|
||||
*** Spanish translation of the Org guide by David Arroyo Menéndez
|
||||
|
||||
David (and others) translated the Org compact guide in spanish:
|
||||
|
||||
You can read the [[http://orgmode.org/worg/orgguide/orgguide.es.pdf][PDF guide]].
|
||||
|
||||
*** ~poporg.el~ and ~outorg.el~
|
||||
|
||||
Two new libraries (~poporg.el~ by François Pinard and ~outorg.el~ by
|
||||
Thorsten Jolitz) now enable editing of comment-sections from source-code
|
||||
buffers in temporary Org-mode buffers, making the full editing power of
|
||||
Org-mode available. ~outorg.el~ comes together with ~outshine.el~ and
|
||||
~navi-mode.el~, two more libraries by Thorsten Jolitz with the goal to give
|
||||
source-code buffers the /look & feel/ of Org-mode buffers while greatly
|
||||
improving navigation and structure editing. A detailed description can be
|
||||
found here: http://orgmode.org/worg/org-tutorials/org-outside-org.html
|
||||
|
||||
Here are two screencasts demonstrating Thorsten's tools:
|
||||
|
||||
- [[http://youtu.be/nqE6YxlY0rw]["Modern conventions for Emacs Lisp files"]]
|
||||
- [[http://www.youtube.com/watch?v%3DII-xYw5VGFM][Exploring Bernt Hansen's Org-mode tutorial with 'navi-mode']]
|
||||
|
||||
*** MobileOrg for iOS
|
||||
|
||||
MobileOrg for iOS back in the App Store The 1.6.0 release was focused on
|
||||
the new Dropbox API and minor bug fixes but also includes a new ability to
|
||||
launch in Capture mode. Track development and contribute [[https://github.com/MobileOrg/mobileorg/issues][on github]].
|
||||
|
||||
* Version 7.9.3
|
||||
|
||||
** New option [[doc::org-agenda-use-tag-inheritance][org-agenda-use-tag-inheritance]]
|
||||
|
@ -1,5 +1,5 @@
|
||||
% Reference Card for Org Mode
|
||||
\def\orgversionnumber{7.9.3}
|
||||
\def\orgversionnumber{8.2.3}
|
||||
\def\versionyear{2013} % latest update
|
||||
\input emacsver.tex
|
||||
|
||||
|
5267
lisp/org/ChangeLog
5267
lisp/org/ChangeLog
File diff suppressed because it is too large
Load Diff
109
lisp/org/ob-C.el
109
lisp/org/ob-C.el
@ -31,7 +31,6 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-eval)
|
||||
(require 'cc-mode)
|
||||
|
||||
(declare-function org-entry-get "org"
|
||||
@ -45,24 +44,24 @@
|
||||
|
||||
(defvar org-babel-C-compiler "gcc"
|
||||
"Command used to compile a C source code file into an
|
||||
executable.")
|
||||
executable.")
|
||||
|
||||
(defvar org-babel-C++-compiler "g++"
|
||||
"Command used to compile a C++ source code file into an
|
||||
executable.")
|
||||
executable.")
|
||||
|
||||
(defvar org-babel-c-variant nil
|
||||
"Internal variable used to hold which type of C (e.g. C or C++)
|
||||
is currently being evaluated.")
|
||||
|
||||
(defun org-babel-execute:cpp (body params)
|
||||
"Execute BODY according to PARAMS. This function calls
|
||||
`org-babel-execute:C++'."
|
||||
"Execute BODY according to PARAMS.
|
||||
This function calls `org-babel-execute:C++'."
|
||||
(org-babel-execute:C++ body params))
|
||||
|
||||
(defun org-babel-execute:C++ (body params)
|
||||
"Execute a block of C++ code with org-babel. This function is
|
||||
called by `org-babel-execute-src-block'."
|
||||
"Execute a block of C++ code with org-babel.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
(let ((org-babel-c-variant 'cpp)) (org-babel-C-execute body params)))
|
||||
|
||||
(defun org-babel-expand-body:C++ (body params)
|
||||
@ -71,8 +70,8 @@ header arguments (calls `org-babel-C-expand')."
|
||||
(let ((org-babel-c-variant 'cpp)) (org-babel-C-expand body params)))
|
||||
|
||||
(defun org-babel-execute:C (body params)
|
||||
"Execute a block of C code with org-babel. This function is
|
||||
called by `org-babel-execute-src-block'."
|
||||
"Execute a block of C code with org-babel.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
(let ((org-babel-c-variant 'c)) (org-babel-C-execute body params)))
|
||||
|
||||
(defun org-babel-expand-body:c (body params)
|
||||
@ -106,11 +105,11 @@ or `org-babel-execute:C++'."
|
||||
(org-babel-process-file-name tmp-src-file)) ""))))
|
||||
((lambda (results)
|
||||
(org-babel-reassemble-table
|
||||
(if (member "vector" (cdr (assoc :result-params params)))
|
||||
(let ((tmp-file (org-babel-temp-file "c-")))
|
||||
(with-temp-file tmp-file (insert results))
|
||||
(org-babel-import-elisp-from-file tmp-file))
|
||||
(org-babel-read results))
|
||||
(org-babel-result-cond (cdr (assoc :result-params params))
|
||||
(org-babel-read results)
|
||||
(let ((tmp-file (org-babel-temp-file "c-")))
|
||||
(with-temp-file tmp-file (insert results))
|
||||
(org-babel-import-elisp-from-file tmp-file)))
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name
|
||||
@ -147,10 +146,10 @@ it's header arguments."
|
||||
body) "\n") "\n")))
|
||||
|
||||
(defun org-babel-C-ensure-main-wrap (body)
|
||||
"Wrap body in a \"main\" function call if none exists."
|
||||
"Wrap BODY in a \"main\" function call if none exists."
|
||||
(if (string-match "^[ \t]*[intvod]+[ \t\n\r]*main[ \t]*(.*)" body)
|
||||
body
|
||||
(format "int main() {\n%s\nreturn(0);\n}\n" body)))
|
||||
(format "int main() {\n%s\nreturn 0;\n}\n" body)))
|
||||
|
||||
(defun org-babel-prep-session:C (session params)
|
||||
"This function does nothing as C is a compiled language with no
|
||||
@ -164,6 +163,59 @@ support for sessions"
|
||||
|
||||
;; helper functions
|
||||
|
||||
(defun org-babel-C-format-val (type val)
|
||||
"Handle the FORMAT part of TYPE with the data from VAL."
|
||||
(let ((format-data (cadr type)))
|
||||
(if (stringp format-data)
|
||||
(cons "" (format format-data val))
|
||||
(funcall format-data val))))
|
||||
|
||||
(defun org-babel-C-val-to-C-type (val)
|
||||
"Determine the type of VAL.
|
||||
Return a list (TYPE-NAME FORMAT). TYPE-NAME should be the name of the type.
|
||||
FORMAT can be either a format string or a function which is called with VAL."
|
||||
(cond
|
||||
((integerp val) '("int" "%d"))
|
||||
((floatp val) '("double" "%f"))
|
||||
((or (listp val) (vectorp val))
|
||||
(lexical-let ((type (org-babel-C-val-to-C-list-type val)))
|
||||
(list (car type)
|
||||
(lambda (val)
|
||||
(cons
|
||||
(format "[%d]%s"
|
||||
(length val)
|
||||
(car (org-babel-C-format-val type (elt val 0))))
|
||||
(concat "{ "
|
||||
(mapconcat (lambda (v)
|
||||
(cdr (org-babel-C-format-val type v)))
|
||||
val
|
||||
", ")
|
||||
" }"))))))
|
||||
(t ;; treat unknown types as string
|
||||
'("char" (lambda (val)
|
||||
(let ((s (format "%s" val))) ;; convert to string for unknown types
|
||||
(cons (format "[%d]" (1+ (length s)))
|
||||
(concat "\"" s "\""))))))))
|
||||
|
||||
(defun org-babel-C-val-to-C-list-type (val)
|
||||
"Determine the C array type of a VAL."
|
||||
(let (type)
|
||||
(mapc
|
||||
#'(lambda (i)
|
||||
(let* ((tmp-type (org-babel-C-val-to-C-type i))
|
||||
(type-name (car type))
|
||||
(tmp-type-name (car tmp-type)))
|
||||
(when (and type (not (string= type-name tmp-type-name)))
|
||||
(if (and (member type-name '("int" "double" "int32_t"))
|
||||
(member tmp-type-name '("int" "double" "int32_t")))
|
||||
(setq tmp-type '("double" "" "%f"))
|
||||
(error "Only homogeneous lists are supported by C. You can not mix %s and %s"
|
||||
type-name
|
||||
tmp-type-name)))
|
||||
(setq type tmp-type)))
|
||||
val)
|
||||
type))
|
||||
|
||||
(defun org-babel-C-var-to-C (pair)
|
||||
"Convert an elisp val into a string of C code specifying a var
|
||||
of the same value."
|
||||
@ -174,22 +226,17 @@ of the same value."
|
||||
(setq val (symbol-name val))
|
||||
(when (= (length val) 1)
|
||||
(setq val (string-to-char val))))
|
||||
(cond
|
||||
((integerp val)
|
||||
(format "int %S = %S;" var val))
|
||||
((floatp val)
|
||||
(format "double %S = %S;" var val))
|
||||
((or (integerp val))
|
||||
(format "char %S = '%S';" var val))
|
||||
((stringp val)
|
||||
(format "char %S[%d] = \"%s\";"
|
||||
var (+ 1 (length val)) val))
|
||||
(t
|
||||
(format "u32 %S = %S;" var val)))))
|
||||
|
||||
(let* ((type-data (org-babel-C-val-to-C-type val))
|
||||
(type (car type-data))
|
||||
(formated (org-babel-C-format-val type-data val))
|
||||
(suffix (car formated))
|
||||
(data (cdr formated)))
|
||||
(format "%s %s%s = %s;"
|
||||
type
|
||||
var
|
||||
suffix
|
||||
data))))
|
||||
|
||||
(provide 'ob-C)
|
||||
|
||||
|
||||
|
||||
;;; ob-C.el ends here
|
||||
|
@ -28,9 +28,6 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-ref)
|
||||
(require 'ob-comint)
|
||||
(require 'ob-eval)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(declare-function orgtbl-to-tsv "org-table" (table params))
|
||||
@ -96,8 +93,13 @@
|
||||
inside
|
||||
(list "dev.off()"))
|
||||
inside))
|
||||
(append (org-babel-variable-assignments:R params)
|
||||
(list body))) "\n")))
|
||||
(append
|
||||
(when (cdr (assoc :prologue params))
|
||||
(list (cdr (assoc :prologue params))))
|
||||
(org-babel-variable-assignments:R params)
|
||||
(list body)
|
||||
(when (cdr (assoc :epilogue params))
|
||||
(list (cdr (assoc :epilogue params)))))) "\n")))
|
||||
|
||||
(defun org-babel-execute:R (body params)
|
||||
"Execute a block of R code.
|
||||
@ -212,6 +214,9 @@ This function is called by `org-babel-execute-src-block'."
|
||||
(if (org-babel-comint-buffer-livep session)
|
||||
session
|
||||
(save-window-excursion
|
||||
(when (get-buffer session)
|
||||
;; Session buffer exists, but with dead process
|
||||
(set-buffer session))
|
||||
(require 'ess) (R)
|
||||
(rename-buffer
|
||||
(if (bufferp session)
|
||||
@ -234,31 +239,40 @@ current code buffer."
|
||||
(and (member "graphics" (cdr (assq :result-params params)))
|
||||
(cdr (assq :file params))))
|
||||
|
||||
(defvar org-babel-R-graphics-devices
|
||||
'((:bmp "bmp" "filename")
|
||||
(:jpg "jpeg" "filename")
|
||||
(:jpeg "jpeg" "filename")
|
||||
(:tikz "tikz" "file")
|
||||
(:tiff "tiff" "filename")
|
||||
(:png "png" "filename")
|
||||
(:svg "svg" "file")
|
||||
(:pdf "pdf" "file")
|
||||
(:ps "postscript" "file")
|
||||
(:postscript "postscript" "file"))
|
||||
"An alist mapping graphics file types to R functions.
|
||||
|
||||
Each member of this list is a list with three members:
|
||||
1. the file extension of the graphics file, as an elisp :keyword
|
||||
2. the R graphics device function to call to generate such a file
|
||||
3. the name of the argument to this function which specifies the
|
||||
file to write to (typically \"file\" or \"filename\")")
|
||||
|
||||
(defun org-babel-R-construct-graphics-device-call (out-file params)
|
||||
"Construct the call to the graphics device."
|
||||
(let ((devices
|
||||
'((:bmp . "bmp")
|
||||
(:jpg . "jpeg")
|
||||
(:jpeg . "jpeg")
|
||||
(:tex . "tikz")
|
||||
(:tiff . "tiff")
|
||||
(:png . "png")
|
||||
(:svg . "svg")
|
||||
(:pdf . "pdf")
|
||||
(:ps . "postscript")
|
||||
(:postscript . "postscript")))
|
||||
(allowed-args '(:width :height :bg :units :pointsize
|
||||
:antialias :quality :compression :res
|
||||
:type :family :title :fonts :version
|
||||
:paper :encoding :pagecentre :colormodel
|
||||
:useDingbats :horizontal))
|
||||
(device (and (string-match ".+\\.\\([^.]+\\)" out-file)
|
||||
(match-string 1 out-file)))
|
||||
(extra-args (cdr (assq :R-dev-args params))) filearg args)
|
||||
(setq device (or (and device (cdr (assq (intern (concat ":" device))
|
||||
devices))) "png"))
|
||||
(setq filearg
|
||||
(if (member device '("pdf" "postscript" "svg" "tikz")) "file" "filename"))
|
||||
(let* ((allowed-args '(:width :height :bg :units :pointsize
|
||||
:antialias :quality :compression :res
|
||||
:type :family :title :fonts :version
|
||||
:paper :encoding :pagecentre :colormodel
|
||||
:useDingbats :horizontal))
|
||||
(device (and (string-match ".+\\.\\([^.]+\\)" out-file)
|
||||
(match-string 1 out-file)))
|
||||
(device-info (or (assq (intern (concat ":" device))
|
||||
org-babel-R-graphics-devices)
|
||||
(assq :png org-babel-R-graphics-devices)))
|
||||
(extra-args (cdr (assq :R-dev-args params))) filearg args)
|
||||
(setq device (nth 1 device-info))
|
||||
(setq filearg (nth 2 device-info))
|
||||
(setq args (mapconcat
|
||||
(lambda (pair)
|
||||
(if (member (car pair) allowed-args)
|
||||
@ -302,11 +316,10 @@ last statement in BODY, as elisp."
|
||||
(format "{function ()\n{\n%s\n}}()" body)
|
||||
(org-babel-process-file-name tmp-file 'noquote)))
|
||||
(org-babel-R-process-value-result
|
||||
(if (or (member "scalar" result-params)
|
||||
(member "verbatim" result-params))
|
||||
(with-temp-buffer
|
||||
(insert-file-contents tmp-file)
|
||||
(buffer-string))
|
||||
(org-babel-result-cond result-params
|
||||
(with-temp-buffer
|
||||
(insert-file-contents tmp-file)
|
||||
(buffer-string))
|
||||
(org-babel-import-elisp-from-file tmp-file '(16)))
|
||||
column-names-p)))
|
||||
(output (org-babel-eval org-babel-R-command body))))
|
||||
@ -335,11 +348,10 @@ last statement in BODY, as elisp."
|
||||
"FALSE")
|
||||
".Last.value" (org-babel-process-file-name tmp-file 'noquote)))
|
||||
(org-babel-R-process-value-result
|
||||
(if (or (member "scalar" result-params)
|
||||
(member "verbatim" result-params))
|
||||
(with-temp-buffer
|
||||
(insert-file-contents tmp-file)
|
||||
(buffer-string))
|
||||
(org-babel-result-cond result-params
|
||||
(with-temp-buffer
|
||||
(insert-file-contents tmp-file)
|
||||
(buffer-string))
|
||||
(org-babel-import-elisp-from-file tmp-file '(16)))
|
||||
column-names-p)))
|
||||
(output
|
||||
|
94
lisp/org/ob-abc.el
Normal file
94
lisp/org/ob-abc.el
Normal file
@ -0,0 +1,94 @@
|
||||
;;; ob-abc.el --- org-babel functions for template evaluation
|
||||
|
||||
;; Copyright (C) Free Software Foundation
|
||||
|
||||
;; Author: William Waites
|
||||
;; Keywords: literate programming, music
|
||||
;; Homepage: http://www.tardis.ed.ac.uk/wwaites
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
|
||||
;; 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, 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 GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; This file adds support to Org Babel for music in ABC notation.
|
||||
;;; It requires that the abcm2ps program is installed.
|
||||
;;; See http://moinejf.free.fr/
|
||||
|
||||
(require 'ob)
|
||||
|
||||
;; optionally define a file extension for this language
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("abc" . "abc"))
|
||||
|
||||
;; optionally declare default header arguments for this language
|
||||
(defvar org-babel-default-header-args:abc
|
||||
'((:results . "file") (:exports . "results"))
|
||||
"Default arguments to use when evaluating an ABC source block.")
|
||||
|
||||
(defun org-babel-expand-body:abc (body params)
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
|
||||
(mapc
|
||||
(lambda (pair)
|
||||
(let ((name (symbol-name (car pair)))
|
||||
(value (cdr pair)))
|
||||
(setq body
|
||||
(replace-regexp-in-string
|
||||
(concat "\$" (regexp-quote name))
|
||||
(if (stringp value) value (format "%S" value))
|
||||
body))))
|
||||
vars)
|
||||
body))
|
||||
|
||||
(defun org-babel-execute:abc (body params)
|
||||
"Execute a block of ABC code with org-babel. This function is
|
||||
called by `org-babel-execute-src-block'"
|
||||
(message "executing Abc source code block")
|
||||
(let* ((result-params (split-string (or (cdr (assoc :results params)))))
|
||||
(cmdline (cdr (assoc :cmdline params)))
|
||||
(out-file ((lambda (el)
|
||||
(or el
|
||||
(error "abc code block requires :file header argument")))
|
||||
(replace-regexp-in-string "\.pdf$" ".ps" (cdr (assoc :file params)))))
|
||||
(in-file (org-babel-temp-file "abc-"))
|
||||
(render (concat "abcm2ps" " " cmdline
|
||||
" -O " (org-babel-process-file-name out-file)
|
||||
" " (org-babel-process-file-name in-file))))
|
||||
(with-temp-file in-file (insert (org-babel-expand-body:abc body params)))
|
||||
(org-babel-eval render "")
|
||||
;;; handle where abcm2ps changes the file name (to support multiple files
|
||||
(when (or (string= (file-name-extension out-file) "eps")
|
||||
(string= (file-name-extension out-file) "svg"))
|
||||
(rename-file (concat
|
||||
(file-name-sans-extension out-file) "001."
|
||||
(file-name-extension out-file))
|
||||
out-file t))
|
||||
;;; if we were asked for a pdf...
|
||||
(when (string= (file-name-extension (cdr (assoc :file params))) "pdf")
|
||||
(org-babel-eval (concat "ps2pdf" " " out-file " " (cdr (assoc :file params))) ""))
|
||||
;;; indicate that the file has been written
|
||||
nil))
|
||||
|
||||
;; This function should be used to assign any variables in params in
|
||||
;; the context of the session environment.
|
||||
(defun org-babel-prep-session:abc (session params)
|
||||
"Return an error because abc does not support sessions."
|
||||
(error "ABC does not support sessions"))
|
||||
|
||||
(provide 'ob-abc)
|
||||
;;; ob-abc.el ends here
|
@ -32,7 +32,6 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-eval)
|
||||
(require 'org-compat)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
@ -45,7 +44,7 @@
|
||||
(defvar org-babel-awk-command "awk"
|
||||
"Name of the awk executable command.")
|
||||
|
||||
(defun org-babel-expand-body:awk (body params &optional processed-params)
|
||||
(defun org-babel-expand-body:awk (body params)
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(dolist (pair (mapcar #'cdr (org-babel-get-header params :var)))
|
||||
(setf body (replace-regexp-in-string
|
||||
@ -78,10 +77,8 @@ called by `org-babel-execute-src-block'"
|
||||
(org-babel-reassemble-table
|
||||
((lambda (results)
|
||||
(when results
|
||||
(if (or (member "scalar" result-params)
|
||||
(member "verbatim" result-params)
|
||||
(member "output" result-params))
|
||||
results
|
||||
(org-babel-result-cond result-params
|
||||
results
|
||||
(let ((tmp (org-babel-temp-file "awk-results-")))
|
||||
(with-temp-file tmp (insert results))
|
||||
(org-babel-import-elisp-from-file tmp)))))
|
||||
|
@ -31,7 +31,6 @@
|
||||
(unless (featurep 'xemacs)
|
||||
(require 'calc-trail)
|
||||
(require 'calc-store))
|
||||
(eval-when-compile (require 'ob-comint))
|
||||
|
||||
(declare-function calc-store-into "calc-store" (&optional var))
|
||||
(declare-function calc-recall "calc-store" (&optional var))
|
||||
|
@ -79,9 +79,8 @@
|
||||
(insert (org-babel-expand-body:clojure body params))
|
||||
((lambda (result)
|
||||
(let ((result-params (cdr (assoc :result-params params))))
|
||||
(if (or (member "scalar" result-params)
|
||||
(member "verbatim" result-params))
|
||||
result
|
||||
(org-babel-result-cond result-params
|
||||
result
|
||||
(condition-case nil (org-babel-script-escape result)
|
||||
(error result)))))
|
||||
(slime-eval
|
||||
|
@ -30,7 +30,7 @@
|
||||
;; org-babel at large.
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-core)
|
||||
(require 'org-compat)
|
||||
(require 'comint)
|
||||
(eval-when-compile (require 'cl))
|
||||
@ -117,7 +117,7 @@ or user `keyboard-quit' during execution of body."
|
||||
string-buffer))
|
||||
(setq raw (substring string-buffer (match-end 0))))
|
||||
(split-string string-buffer comint-prompt-regexp)))))
|
||||
(def-edebug-spec org-babel-comint-with-output (form body))
|
||||
(def-edebug-spec org-babel-comint-with-output (sexp body))
|
||||
|
||||
(defun org-babel-comint-input-command (buffer cmd)
|
||||
"Pass CMD to BUFFER.
|
||||
|
2778
lisp/org/ob-core.el
Normal file
2778
lisp/org/ob-core.el
Normal file
File diff suppressed because it is too large
Load Diff
@ -34,22 +34,43 @@
|
||||
;; 3) we are adding the "file" and "cmdline" header arguments
|
||||
;;
|
||||
;; 4) there are no variables (at least for now)
|
||||
;;
|
||||
;; 5) it depends on a variable defined in org-exp-blocks (namely
|
||||
;; `org-ditaa-jar-path') so be sure you have org-exp-blocks loaded
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'org-compat)
|
||||
|
||||
(defvar org-ditaa-jar-path) ;; provided by org-exp-blocks
|
||||
|
||||
(defvar org-babel-default-header-args:ditaa
|
||||
'((:results . "file")
|
||||
(:exports . "results")
|
||||
(:java . "-Dfile.encoding=UTF-8"))
|
||||
"Default arguments for evaluating a ditaa source block.")
|
||||
|
||||
(defcustom org-ditaa-jar-path (expand-file-name
|
||||
"ditaa.jar"
|
||||
(file-name-as-directory
|
||||
(expand-file-name
|
||||
"scripts"
|
||||
(file-name-as-directory
|
||||
(expand-file-name
|
||||
"../contrib"
|
||||
(file-name-directory (org-find-library-dir "org")))))))
|
||||
"Path to the ditaa jar executable."
|
||||
:group 'org-babel
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-babel-ditaa-java-cmd "java"
|
||||
"Java executable to use when evaluating ditaa blocks."
|
||||
:group 'org-babel
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-ditaa-eps-jar-path
|
||||
(expand-file-name "DitaaEps.jar" (file-name-directory org-ditaa-jar-path))
|
||||
"Path to the DitaaEps.jar executable."
|
||||
:group 'org-babel
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-ditaa-jar-option "-jar"
|
||||
"Option for the ditaa jar file.
|
||||
Do not leave leading or trailing spaces in this string."
|
||||
@ -69,16 +90,26 @@ This function is called by `org-babel-execute-src-block'."
|
||||
(cmdline (cdr (assoc :cmdline params)))
|
||||
(java (cdr (assoc :java params)))
|
||||
(in-file (org-babel-temp-file "ditaa-"))
|
||||
(cmd (concat "java " java " " org-ditaa-jar-option " "
|
||||
(eps (cdr (assoc :eps params)))
|
||||
(cmd (concat org-babel-ditaa-java-cmd
|
||||
" " java " " org-ditaa-jar-option " "
|
||||
(shell-quote-argument
|
||||
(expand-file-name org-ditaa-jar-path))
|
||||
(expand-file-name
|
||||
(if eps org-ditaa-eps-jar-path org-ditaa-jar-path)))
|
||||
" " cmdline
|
||||
" " (org-babel-process-file-name in-file)
|
||||
" " (org-babel-process-file-name out-file))))
|
||||
" " (org-babel-process-file-name out-file)))
|
||||
(pdf-cmd (when (and (or (string= (file-name-extension out-file) "pdf")
|
||||
(cdr (assoc :pdf params))))
|
||||
(concat
|
||||
"epstopdf"
|
||||
" " (org-babel-process-file-name (concat in-file ".eps"))
|
||||
" -o=" (org-babel-process-file-name out-file)))))
|
||||
(unless (file-exists-p org-ditaa-jar-path)
|
||||
(error "Could not find ditaa.jar at %s" org-ditaa-jar-path))
|
||||
(with-temp-file in-file (insert body))
|
||||
(message cmd) (shell-command cmd)
|
||||
(when pdf-cmd (message pdf-cmd) (shell-command pdf-cmd))
|
||||
nil)) ;; signal that output has already been written to file
|
||||
|
||||
(defun org-babel-prep-session:ditaa (session params)
|
||||
|
@ -39,7 +39,6 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-eval)
|
||||
|
||||
(defvar org-babel-default-header-args:dot
|
||||
'((:results . "file") (:exports . "results"))
|
||||
|
85
lisp/org/ob-ebnf.el
Normal file
85
lisp/org/ob-ebnf.el
Normal file
@ -0,0 +1,85 @@
|
||||
;;; ob-ebnf.el --- org-babel functions for ebnf evaluation
|
||||
|
||||
;; Copyright (C) 2013 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Michael Gauland
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 1.00
|
||||
|
||||
;;; License:
|
||||
|
||||
;; 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, 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 GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; Org-Babel support for using ebnf2ps to generate encapsulated postscript
|
||||
;;; railroad diagrams. It recogises these arguments:
|
||||
;;;
|
||||
;;; :file is required; it must include the extension '.eps.' All the rules
|
||||
;;; in the block will be drawn in the same file. This is done by
|
||||
;;; inserting a '[<file>' comment at the start of the block (see the
|
||||
;;; documentation for ebnf-eps-buffer for more information).
|
||||
;;;
|
||||
;;; :style specifies a value in ebnf-style-database. This provides the
|
||||
;;; ability to customise the output. The style can also specify the
|
||||
;;; grammar syntax (by setting ebnf-syntax); note that only ebnf,
|
||||
;;; iso-ebnf, and yacc are supported by this file.
|
||||
|
||||
;;; Requirements:
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ebnf2ps)
|
||||
|
||||
;; optionally declare default header arguments for this language
|
||||
(defvar org-babel-default-header-args:ebnf '((:style . nil)))
|
||||
|
||||
;; Use ebnf-eps-buffer to produce an encapsulated postscript file.
|
||||
;;
|
||||
(defun org-babel-execute:ebnf (body params)
|
||||
"Execute a block of Ebnf code with org-babel. This function is
|
||||
called by `org-babel-execute-src-block'"
|
||||
(save-excursion
|
||||
(let* ((dest-file (cdr (assoc :file params)))
|
||||
(dest-dir (file-name-directory dest-file))
|
||||
(dest-root (file-name-sans-extension
|
||||
(file-name-nondirectory dest-file)))
|
||||
(dest-ext (file-name-extension dest-file))
|
||||
(style (cdr (assoc :style params)))
|
||||
(current-dir default-directory)
|
||||
(result nil))
|
||||
(with-temp-buffer
|
||||
(when style (ebnf-push-style style))
|
||||
(let ((comment-format
|
||||
(cond ((string= ebnf-syntax 'yacc) "/*%s*/")
|
||||
((string= ebnf-syntax 'ebnf) ";%s")
|
||||
((string= ebnf-syntax 'iso-ebnf) "(*%s*)")
|
||||
(t (setq result
|
||||
(format "EBNF error: format %s not supported."
|
||||
ebnf-syntax))))))
|
||||
(setq ebnf-eps-prefix dest-dir)
|
||||
(insert (format comment-format (format "[%s" dest-root)))
|
||||
(newline)
|
||||
(insert body)
|
||||
(newline)
|
||||
(insert (format comment-format (format "]%s" dest-root)))
|
||||
(ebnf-eps-buffer)
|
||||
(when style (ebnf-pop-style))))
|
||||
result)))
|
||||
|
||||
(provide 'ob-ebnf)
|
||||
;;; ob-ebnf.el ends here
|
@ -27,7 +27,6 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(eval-when-compile (require 'ob-comint))
|
||||
|
||||
(defvar org-babel-default-header-args:emacs-lisp
|
||||
'((:hlines . "yes") (:colnames . "no"))
|
||||
@ -56,11 +55,13 @@
|
||||
"Execute a block of emacs-lisp code with Babel."
|
||||
(save-window-excursion
|
||||
((lambda (result)
|
||||
(if (or (member "scalar" (cdr (assoc :result-params params)))
|
||||
(member "verbatim" (cdr (assoc :result-params params))))
|
||||
(let ((print-level nil)
|
||||
(print-length nil))
|
||||
(format "%S" result))
|
||||
(org-babel-result-cond (cdr (assoc :result-params params))
|
||||
(let ((print-level nil)
|
||||
(print-length nil))
|
||||
(if (or (member "scalar" (cdr (assoc :result-params params)))
|
||||
(member "verbatim" (cdr (assoc :result-params params))))
|
||||
(format "%S" result)
|
||||
(format "%s" result)))
|
||||
(org-babel-reassemble-table
|
||||
result
|
||||
(org-babel-pick-name (cdr (assoc :colname-names params))
|
||||
|
@ -27,6 +27,7 @@
|
||||
;; shell commands.
|
||||
|
||||
;;; Code:
|
||||
(require 'org-macs)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(defvar org-babel-error-buffer-name "*Org-Babel Error Output*")
|
||||
@ -50,8 +51,8 @@ STDERR with `org-babel-eval-error-notify'."
|
||||
(with-temp-buffer
|
||||
(insert body)
|
||||
(setq exit-code
|
||||
(org-babel-shell-command-on-region
|
||||
(point-min) (point-max) cmd t 'replace err-buff))
|
||||
(org-babel--shell-command-on-region
|
||||
(point-min) (point-max) cmd err-buff))
|
||||
(if (or (not (numberp exit-code)) (> exit-code 0))
|
||||
(progn
|
||||
(with-current-buffer err-buff
|
||||
@ -64,79 +65,15 @@ STDERR with `org-babel-eval-error-notify'."
|
||||
(with-temp-buffer (insert-file-contents file)
|
||||
(buffer-string)))
|
||||
|
||||
(defun org-babel-shell-command-on-region (start end command
|
||||
&optional output-buffer replace
|
||||
error-buffer display-error-buffer)
|
||||
(defun org-babel--shell-command-on-region (start end command error-buffer)
|
||||
"Execute COMMAND in an inferior shell with region as input.
|
||||
|
||||
Fixes bugs in the emacs 23.1.1 version of `shell-command-on-region'
|
||||
|
||||
Normally display output (if any) in temp buffer `*Shell Command Output*';
|
||||
Prefix arg means replace the region with it. Return the exit code of
|
||||
COMMAND.
|
||||
|
||||
To specify a coding system for converting non-ASCII characters in
|
||||
the input and output to the shell command, use
|
||||
\\[universal-coding-system-argument] before this command. By
|
||||
default, the input (from the current buffer) is encoded in the
|
||||
same coding system that will be used to save the file,
|
||||
`buffer-file-coding-system'. If the output is going to replace
|
||||
the region, then it is decoded from that same coding system.
|
||||
|
||||
The noninteractive arguments are START, END, COMMAND,
|
||||
OUTPUT-BUFFER, REPLACE, ERROR-BUFFER, and DISPLAY-ERROR-BUFFER.
|
||||
Noninteractive callers can specify coding systems by binding
|
||||
`coding-system-for-read' and `coding-system-for-write'.
|
||||
|
||||
If the command generates output, the output may be displayed
|
||||
in the echo area or in a buffer.
|
||||
If the output is short enough to display in the echo area
|
||||
\(determined by the variable `max-mini-window-height' if
|
||||
`resize-mini-windows' is non-nil), it is shown there. Otherwise
|
||||
it is displayed in the buffer `*Shell Command Output*'. The output
|
||||
is available in that buffer in both cases.
|
||||
|
||||
If there is output and an error, a message about the error
|
||||
appears at the end of the output.
|
||||
|
||||
If there is no output, or if output is inserted in the current buffer,
|
||||
then `*Shell Command Output*' is deleted.
|
||||
|
||||
If the optional fourth argument OUTPUT-BUFFER is non-nil,
|
||||
that says to put the output in some other buffer.
|
||||
If OUTPUT-BUFFER is a buffer or buffer name, put the output there.
|
||||
If OUTPUT-BUFFER is not a buffer and not nil,
|
||||
insert output in the current buffer.
|
||||
In either case, the output is inserted after point (leaving mark after it).
|
||||
|
||||
If REPLACE, the optional fifth argument, is non-nil, that means insert
|
||||
the output in place of text from START to END, putting point and mark
|
||||
around it.
|
||||
|
||||
If optional sixth argument ERROR-BUFFER is non-nil, it is a buffer
|
||||
or buffer name to which to direct the command's standard error output.
|
||||
If it is nil, error output is mingled with regular output.
|
||||
If DISPLAY-ERROR-BUFFER is non-nil, display the error buffer if there
|
||||
were any errors. (This is always t, interactively.)
|
||||
In an interactive call, the variable `shell-command-default-error-buffer'
|
||||
specifies the value of ERROR-BUFFER."
|
||||
(interactive (let (string)
|
||||
(unless (mark)
|
||||
(error "The mark is not set now, so there is no region"))
|
||||
;; Do this before calling region-beginning
|
||||
;; and region-end, in case subprocess output
|
||||
;; relocates them while we are in the minibuffer.
|
||||
(setq string (read-shell-command "Shell command on region: "))
|
||||
;; call-interactively recognizes region-beginning and
|
||||
;; region-end specially, leaving them in the history.
|
||||
(list (region-beginning) (region-end)
|
||||
string
|
||||
current-prefix-arg
|
||||
current-prefix-arg
|
||||
shell-command-default-error-buffer
|
||||
t)))
|
||||
(let ((input-file (org-babel-temp-file "input-"))
|
||||
(error-file (if error-buffer (org-babel-temp-file "scor-") nil))
|
||||
Stripped down version of shell-command-on-region for internal use
|
||||
in Babel only. This lets us work around errors in the original
|
||||
function in various versions of Emacs.
|
||||
"
|
||||
(let ((input-file (org-babel-temp-file "ob-input-"))
|
||||
(error-file (if error-buffer (org-babel-temp-file "ob-error-") nil))
|
||||
;; Unfortunately, `executable-find' does not support file name
|
||||
;; handlers. Therefore, we could use it in the local case
|
||||
;; only.
|
||||
@ -154,96 +91,26 @@ specifies the value of ERROR-BUFFER."
|
||||
;; workaround for now.
|
||||
(unless (file-remote-p default-directory)
|
||||
(delete-file error-file))
|
||||
(if (or replace
|
||||
(and output-buffer
|
||||
(not (or (bufferp output-buffer) (stringp output-buffer)))))
|
||||
;; Replace specified region with output from command.
|
||||
(let ((swap (and replace (< start end))))
|
||||
;; Don't muck with mark unless REPLACE says we should.
|
||||
(goto-char start)
|
||||
(and replace (push-mark (point) 'nomsg))
|
||||
(write-region start end input-file)
|
||||
(delete-region start end)
|
||||
(setq exit-status
|
||||
(process-file shell-file-name input-file
|
||||
(if error-file
|
||||
(list output-buffer error-file)
|
||||
t)
|
||||
nil shell-command-switch command))
|
||||
;; It is rude to delete a buffer which the command is not using.
|
||||
;; (let ((shell-buffer (get-buffer "*Shell Command Output*")))
|
||||
;; (and shell-buffer (not (eq shell-buffer (current-buffer)))
|
||||
;; (kill-buffer shell-buffer)))
|
||||
;; Don't muck with mark unless REPLACE says we should.
|
||||
(and replace swap (exchange-point-and-mark)))
|
||||
;; No prefix argument: put the output in a temp buffer,
|
||||
;; replacing its entire contents.
|
||||
(let ((buffer (get-buffer-create
|
||||
(or output-buffer "*Shell Command Output*"))))
|
||||
(unwind-protect
|
||||
(if (eq buffer (current-buffer))
|
||||
;; If the input is the same buffer as the output,
|
||||
;; delete everything but the specified region,
|
||||
;; then replace that region with the output.
|
||||
(progn (setq buffer-read-only nil)
|
||||
(delete-region (max start end) (point-max))
|
||||
(delete-region (point-min) (min start end))
|
||||
(write-region (point-min) (point-max) input-file)
|
||||
(delete-region (point-min) (point-max))
|
||||
(setq exit-status
|
||||
(process-file shell-file-name input-file
|
||||
(if error-file
|
||||
(list t error-file)
|
||||
t)
|
||||
nil shell-command-switch command)))
|
||||
;; Clear the output buffer, then run the command with
|
||||
;; output there.
|
||||
(let ((directory default-directory))
|
||||
(with-current-buffer buffer
|
||||
(setq buffer-read-only nil)
|
||||
(if (not output-buffer)
|
||||
(setq default-directory directory))
|
||||
(erase-buffer)))
|
||||
(setq exit-status
|
||||
(process-file shell-file-name nil
|
||||
(if error-file
|
||||
(list buffer error-file)
|
||||
buffer)
|
||||
nil shell-command-switch command)))
|
||||
;; Report the output.
|
||||
(with-current-buffer buffer
|
||||
(setq mode-line-process
|
||||
(cond ((null exit-status)
|
||||
" - Error")
|
||||
((stringp exit-status)
|
||||
(format " - Signal [%s]" exit-status))
|
||||
((not (equal 0 exit-status))
|
||||
(format " - Exit [%d]" exit-status)))))
|
||||
(if (with-current-buffer buffer (> (point-max) (point-min)))
|
||||
;; There's some output, display it
|
||||
(display-message-or-buffer buffer)
|
||||
;; No output; error?
|
||||
(let ((output
|
||||
(if (and error-file
|
||||
(< 0 (nth 7 (file-attributes error-file))))
|
||||
"some error output"
|
||||
"no output")))
|
||||
(cond ((null exit-status)
|
||||
(message "(Shell command failed with error)"))
|
||||
((equal 0 exit-status)
|
||||
(message "(Shell command succeeded with %s)"
|
||||
output))
|
||||
((stringp exit-status)
|
||||
(message "(Shell command killed by signal %s)"
|
||||
exit-status))
|
||||
(t
|
||||
(message "(Shell command failed with code %d and %s)"
|
||||
exit-status output))))
|
||||
;; Don't kill: there might be useful info in the undo-log.
|
||||
;; (kill-buffer buffer)
|
||||
))))
|
||||
;; we always call this with 'replace, remove conditional
|
||||
;; Replace specified region with output from command.
|
||||
(let ((swap (< start end)))
|
||||
(goto-char start)
|
||||
(push-mark (point) 'nomsg)
|
||||
(write-region start end input-file)
|
||||
(delete-region start end)
|
||||
(setq exit-status
|
||||
(process-file shell-file-name input-file
|
||||
(if error-file
|
||||
(list t error-file)
|
||||
t)
|
||||
nil shell-command-switch command))
|
||||
(when swap (exchange-point-and-mark)))
|
||||
|
||||
(when (and input-file (file-exists-p input-file))
|
||||
(when (and input-file (file-exists-p input-file)
|
||||
;; bind org-babel--debug-input around the call to keep
|
||||
;; the temporary input files available for inspection
|
||||
(not (when (boundp 'org-babel--debug-input)
|
||||
org-babel--debug-input)))
|
||||
(delete-file input-file))
|
||||
|
||||
(when (and error-file (file-exists-p error-file))
|
||||
@ -258,8 +125,7 @@ specifies the value of ERROR-BUFFER."
|
||||
(format-insert-file error-file nil)
|
||||
;; Put point after the inserted errors.
|
||||
(goto-char (- (point-max) pos-from-end)))
|
||||
(and display-error-buffer
|
||||
(display-buffer (current-buffer)))))
|
||||
(current-buffer)))
|
||||
(delete-file error-file))
|
||||
exit-status))
|
||||
|
||||
|
@ -23,8 +23,7 @@
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'org-exp-blocks)
|
||||
(require 'ob-core)
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
|
||||
@ -35,23 +34,31 @@
|
||||
|
||||
(declare-function org-babel-lob-get-info "ob-lob" ())
|
||||
(declare-function org-babel-eval-wipe-error-buffer "ob-eval" ())
|
||||
(declare-function org-between-regexps-p "org"
|
||||
(start-re end-re &optional lim-up lim-down))
|
||||
(declare-function org-get-indentation "org" (&optional line))
|
||||
(declare-function org-heading-components "org" ())
|
||||
(declare-function org-in-block-p "org" (names))
|
||||
(declare-function org-in-verbatim-emphasis "org" ())
|
||||
(declare-function org-link-search "org" (s &optional type avoid-pos stealth))
|
||||
(declare-function org-fill-template "org" (template alist))
|
||||
(declare-function org-in-verbatim-emphasis "org" ())
|
||||
(declare-function org-in-block-p "org" (names))
|
||||
(declare-function org-between-regexps-p "org" (start-re end-re &optional lim-up lim-down))
|
||||
|
||||
(add-to-list 'org-export-interblocks '(src org-babel-exp-non-block-elements))
|
||||
(org-export-blocks-add-block '(src org-babel-exp-src-block nil))
|
||||
(declare-function org-split-string "org" (string &optional separators))
|
||||
(declare-function org-element-at-point "org-element" (&optional keep-trail))
|
||||
(declare-function org-element-context "org-element" ())
|
||||
(declare-function org-element-property "org-element" (property element))
|
||||
(declare-function org-element-type "org-element" (element))
|
||||
(declare-function org-escape-code-in-string "org-src" (s))
|
||||
|
||||
(defcustom org-export-babel-evaluate t
|
||||
"Switch controlling code evaluation during export.
|
||||
When set to nil no code will be evaluated as part of the export
|
||||
process."
|
||||
process. When set to 'inline-only, only inline code blocks will
|
||||
be executed."
|
||||
:group 'org-babel
|
||||
:version "24.1"
|
||||
:type 'boolean)
|
||||
:type '(choice (const :tag "Never" nil)
|
||||
(const :tag "Only inline code" inline-only)
|
||||
(const :tag "Always" t)))
|
||||
(put 'org-export-babel-evaluate 'safe-local-variable (lambda (x) (eq x nil)))
|
||||
|
||||
(defun org-babel-exp-get-export-buffer ()
|
||||
@ -86,10 +93,10 @@ process."
|
||||
results)))
|
||||
(def-edebug-spec org-babel-exp-in-export-file (form body))
|
||||
|
||||
(defun org-babel-exp-src-block (body &rest headers)
|
||||
(defun org-babel-exp-src-block (&rest headers)
|
||||
"Process source block for export.
|
||||
Depending on the 'export' headers argument in replace the source
|
||||
code block with...
|
||||
Depending on the 'export' headers argument, replace the source
|
||||
code block like this:
|
||||
|
||||
both ---- display the code and the results
|
||||
|
||||
@ -99,11 +106,12 @@ code ---- the default, display the code inside the block but do
|
||||
results - just like none only the block is run on export ensuring
|
||||
that it's results are present in the org-mode buffer
|
||||
|
||||
none ----- do not display either code or results upon export"
|
||||
none ---- do not display either code or results upon export
|
||||
|
||||
Assume point is at the beginning of block's starting line."
|
||||
(interactive)
|
||||
(unless noninteractive (message "org-babel-exp processing..."))
|
||||
(save-excursion
|
||||
(goto-char (match-beginning 0))
|
||||
(let* ((info (org-babel-get-src-block-info 'light))
|
||||
(lang (nth 0 info))
|
||||
(raw-params (nth 2 info)) hash)
|
||||
@ -114,11 +122,11 @@ none ----- do not display either code or results upon export"
|
||||
(org-babel-exp-in-export-file lang
|
||||
(setf (nth 2 info)
|
||||
(org-babel-process-params
|
||||
(org-babel-merge-params
|
||||
org-babel-default-header-args
|
||||
(org-babel-params-from-properties lang)
|
||||
(if (boundp lang-headers) (eval lang-headers) nil)
|
||||
raw-params))))
|
||||
(apply #'org-babel-merge-params
|
||||
org-babel-default-header-args
|
||||
(if (boundp lang-headers) (eval lang-headers) nil)
|
||||
(append (org-babel-params-from-properties lang)
|
||||
(list raw-params))))))
|
||||
(setf hash (org-babel-sha1-hash info)))
|
||||
(org-babel-exp-do-export info 'block hash)))))
|
||||
|
||||
@ -149,66 +157,156 @@ this template."
|
||||
(let ((m (make-marker)))
|
||||
(set-marker m end (current-buffer))
|
||||
(setq end m)))
|
||||
(let ((rx (concat "\\(" org-babel-inline-src-block-regexp
|
||||
(let ((rx (concat "\\(?:" org-babel-inline-src-block-regexp
|
||||
"\\|" org-babel-lob-one-liner-regexp "\\)")))
|
||||
(while (and (< (point) (marker-position end))
|
||||
(re-search-forward rx end t))
|
||||
(if (save-excursion
|
||||
(goto-char (match-beginning 0))
|
||||
(looking-at org-babel-inline-src-block-regexp))
|
||||
(progn
|
||||
(forward-char 1)
|
||||
(let* ((info (save-match-data
|
||||
(org-babel-parse-inline-src-block-match)))
|
||||
(params (nth 2 info)))
|
||||
(save-match-data
|
||||
(goto-char (match-beginning 2))
|
||||
(unless (org-babel-in-example-or-verbatim)
|
||||
;; expand noweb references in the original file
|
||||
(setf (nth 1 info)
|
||||
(if (and (cdr (assoc :noweb params))
|
||||
(string= "yes" (cdr (assoc :noweb params))))
|
||||
(org-babel-expand-noweb-references
|
||||
info (org-babel-exp-get-export-buffer))
|
||||
(nth 1 info)))
|
||||
(let ((code-replacement (save-match-data
|
||||
(org-babel-exp-do-export
|
||||
info 'inline))))
|
||||
(if code-replacement
|
||||
(progn (replace-match code-replacement nil nil nil 1)
|
||||
(delete-char 1))
|
||||
(org-babel-examplize-region (match-beginning 1)
|
||||
(match-end 1))
|
||||
(forward-char 2)))))))
|
||||
(unless (org-babel-in-example-or-verbatim)
|
||||
(let* ((lob-info (org-babel-lob-get-info))
|
||||
(inlinep (match-string 11))
|
||||
(inline-start (match-end 11))
|
||||
(inline-end (match-end 0))
|
||||
(results (save-match-data
|
||||
(org-babel-exp-do-export
|
||||
(list "emacs-lisp" "results"
|
||||
(org-babel-merge-params
|
||||
org-babel-default-header-args
|
||||
org-babel-default-lob-header-args
|
||||
(org-babel-params-from-properties)
|
||||
(org-babel-parse-header-arguments
|
||||
(org-no-properties
|
||||
(concat ":var results="
|
||||
(mapconcat #'identity
|
||||
(butlast lob-info)
|
||||
" ")))))
|
||||
"" nil (car (last lob-info)))
|
||||
'lob)))
|
||||
(rep (org-fill-template
|
||||
org-babel-exp-call-line-template
|
||||
`(("line" . ,(nth 0 lob-info))))))
|
||||
(if inlinep
|
||||
(save-excursion
|
||||
(goto-char inline-start)
|
||||
(delete-region inline-start inline-end)
|
||||
(insert rep))
|
||||
(replace-match rep t t)))))))))
|
||||
(while (re-search-forward rx end t)
|
||||
(save-excursion
|
||||
(let* ((element (save-excursion
|
||||
;; If match is inline, point is at its
|
||||
;; end. Move backward so
|
||||
;; `org-element-context' can get the
|
||||
;; object, not the following one.
|
||||
(backward-char)
|
||||
(save-match-data (org-element-context))))
|
||||
(type (org-element-type element)))
|
||||
(when (memq type '(babel-call inline-babel-call inline-src-block))
|
||||
(let ((beg-el (org-element-property :begin element))
|
||||
(end-el (org-element-property :end element)))
|
||||
(case type
|
||||
(inline-src-block
|
||||
(let* ((info (org-babel-parse-inline-src-block-match))
|
||||
(params (nth 2 info)))
|
||||
(setf (nth 1 info)
|
||||
(if (and (cdr (assoc :noweb params))
|
||||
(string= "yes" (cdr (assoc :noweb params))))
|
||||
(org-babel-expand-noweb-references
|
||||
info (org-babel-exp-get-export-buffer))
|
||||
(nth 1 info)))
|
||||
(goto-char beg-el)
|
||||
(let ((replacement (org-babel-exp-do-export info 'inline)))
|
||||
(if (equal replacement "")
|
||||
;; Replacement code is empty: completely
|
||||
;; remove inline src block, including extra
|
||||
;; white space that might have been created
|
||||
;; when inserting results.
|
||||
(delete-region beg-el
|
||||
(progn (goto-char end-el)
|
||||
(skip-chars-forward " \t")
|
||||
(point)))
|
||||
;; Otherwise: remove inline src block but
|
||||
;; preserve following white spaces. Then
|
||||
;; insert value.
|
||||
(delete-region beg-el
|
||||
(progn (goto-char end-el)
|
||||
(skip-chars-backward " \t")
|
||||
(point)))
|
||||
(insert replacement)))))
|
||||
((babel-call inline-babel-call)
|
||||
(let* ((lob-info (org-babel-lob-get-info))
|
||||
(results
|
||||
(org-babel-exp-do-export
|
||||
(list "emacs-lisp" "results"
|
||||
(apply #'org-babel-merge-params
|
||||
org-babel-default-header-args
|
||||
org-babel-default-lob-header-args
|
||||
(append
|
||||
(org-babel-params-from-properties)
|
||||
(list
|
||||
(org-babel-parse-header-arguments
|
||||
(org-no-properties
|
||||
(concat
|
||||
":var results="
|
||||
(mapconcat 'identity
|
||||
(butlast lob-info 2)
|
||||
" ")))))))
|
||||
"" (nth 3 lob-info) (nth 2 lob-info))
|
||||
'lob))
|
||||
(rep (org-fill-template
|
||||
org-babel-exp-call-line-template
|
||||
`(("line" . ,(nth 0 lob-info))))))
|
||||
;; If replacement is empty, completely remove the
|
||||
;; object/element, including any extra white space
|
||||
;; that might have been created when including
|
||||
;; results.
|
||||
(if (equal rep "")
|
||||
(delete-region
|
||||
beg-el
|
||||
(progn (goto-char end-el)
|
||||
(if (not (eq type 'babel-call))
|
||||
(progn (skip-chars-forward " \t") (point))
|
||||
(skip-chars-forward " \r\t\n")
|
||||
(line-beginning-position))))
|
||||
;; Otherwise, preserve following white
|
||||
;; spaces/newlines and then, insert replacement
|
||||
;; string.
|
||||
(goto-char beg-el)
|
||||
(delete-region beg-el
|
||||
(progn (goto-char end-el)
|
||||
(skip-chars-backward " \r\t\n")
|
||||
(point)))
|
||||
(insert rep)))))))))))))
|
||||
|
||||
(defvar org-src-preserve-indentation) ; From org-src.el
|
||||
(defun org-babel-exp-process-buffer ()
|
||||
"Execute all blocks in visible part of buffer."
|
||||
(interactive)
|
||||
(save-window-excursion
|
||||
(let ((case-fold-search t)
|
||||
(pos (point-min)))
|
||||
(goto-char pos)
|
||||
(while (re-search-forward "^[ \t]*#\\+BEGIN_SRC" nil t)
|
||||
(let ((element (save-match-data (org-element-at-point))))
|
||||
(when (eq (org-element-type element) 'src-block)
|
||||
(let* ((match-start (copy-marker (match-beginning 0)))
|
||||
(begin (copy-marker (org-element-property :begin element)))
|
||||
;; Make sure we don't remove any blank lines after
|
||||
;; the block when replacing it.
|
||||
(block-end (save-excursion
|
||||
(goto-char (org-element-property :end element))
|
||||
(skip-chars-backward " \r\t\n")
|
||||
(copy-marker (line-end-position))))
|
||||
(ind (org-get-indentation))
|
||||
(headers
|
||||
(cons
|
||||
(org-element-property :language element)
|
||||
(let ((params (org-element-property :parameters element)))
|
||||
(and params (org-split-string params "[ \t]+"))))))
|
||||
;; Execute all non-block elements between POS and
|
||||
;; current block.
|
||||
(org-babel-exp-non-block-elements pos begin)
|
||||
;; Take care of matched block: compute replacement
|
||||
;; string. In particular, a nil REPLACEMENT means the
|
||||
;; block should be left as-is while an empty string
|
||||
;; should remove the block.
|
||||
(let ((replacement (progn (goto-char match-start)
|
||||
(org-babel-exp-src-block headers))))
|
||||
(cond ((not replacement) (goto-char block-end))
|
||||
((equal replacement "")
|
||||
(delete-region begin
|
||||
(progn (goto-char block-end)
|
||||
(skip-chars-forward " \r\t\n")
|
||||
(if (eobp) (point)
|
||||
(line-beginning-position)))))
|
||||
(t
|
||||
(goto-char match-start)
|
||||
(delete-region (point) block-end)
|
||||
(insert replacement)
|
||||
(if (org-element-property :preserve-indent element)
|
||||
;; Indent only the code block markers.
|
||||
(save-excursion (skip-chars-backward " \r\t\n")
|
||||
(indent-line-to ind)
|
||||
(goto-char match-start)
|
||||
(indent-line-to ind))
|
||||
;; Indent everything.
|
||||
(indent-rigidly match-start (point) ind)))))
|
||||
(setq pos (line-beginning-position))
|
||||
;; Cleanup markers.
|
||||
(set-marker match-start nil)
|
||||
(set-marker begin nil)
|
||||
(set-marker block-end nil)))))
|
||||
;; Eventually execute all non-block Babel elements between last
|
||||
;; src-block and end of buffer.
|
||||
(org-babel-exp-non-block-elements pos (point-max)))))
|
||||
|
||||
(defun org-babel-in-example-or-verbatim ()
|
||||
"Return true if point is in example or verbatim code.
|
||||
@ -269,9 +367,7 @@ replaced with its value."
|
||||
(org-fill-template
|
||||
org-babel-exp-code-template
|
||||
`(("lang" . ,(nth 0 info))
|
||||
("body" . ,(if (string= (nth 0 info) "org")
|
||||
(replace-regexp-in-string "^" "," (nth 1 info))
|
||||
(nth 1 info)))
|
||||
("body" . ,(org-escape-code-in-string (nth 1 info)))
|
||||
,@(mapcar (lambda (pair)
|
||||
(cons (substring (symbol-name (car pair)) 1)
|
||||
(format "%S" (cdr pair))))
|
||||
@ -285,14 +381,17 @@ Results are prepared in a manner suitable for export by org-mode.
|
||||
This function is called by `org-babel-exp-do-export'. The code
|
||||
block will be evaluated. Optional argument SILENT can be used to
|
||||
inhibit insertion of results into the buffer."
|
||||
(when (and org-export-babel-evaluate
|
||||
(when (and (or (eq org-export-babel-evaluate t)
|
||||
(and (eq type 'inline)
|
||||
(eq org-export-babel-evaluate 'inline-only)))
|
||||
(not (and hash (equal hash (org-babel-current-result-hash)))))
|
||||
(let ((lang (nth 0 info))
|
||||
(body (if (org-babel-noweb-p (nth 2 info) :eval)
|
||||
(org-babel-expand-noweb-references
|
||||
info (org-babel-exp-get-export-buffer))
|
||||
(nth 1 info)))
|
||||
(info (copy-sequence info)))
|
||||
(info (copy-sequence info))
|
||||
(org-babel-current-src-block-location (point-marker)))
|
||||
;; skip code blocks which we can't evaluate
|
||||
(when (fboundp (intern (concat "org-babel-execute:" lang)))
|
||||
(org-babel-eval-wipe-error-buffer)
|
||||
@ -318,10 +417,10 @@ inhibit insertion of results into the buffer."
|
||||
((equal type 'lob)
|
||||
(save-excursion
|
||||
(re-search-backward org-babel-lob-one-liner-regexp nil t)
|
||||
(org-babel-execute-src-block nil info)))))))))
|
||||
(let (org-confirm-babel-evaluate)
|
||||
(org-babel-execute-src-block nil info))))))))))
|
||||
|
||||
|
||||
(provide 'ob-exp)
|
||||
|
||||
|
||||
|
||||
;;; ob-exp.el ends here
|
||||
|
@ -28,11 +28,11 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-eval)
|
||||
(require 'cc-mode)
|
||||
|
||||
(declare-function org-entry-get "org"
|
||||
(pom property &optional inherit literal-nil))
|
||||
(declare-function org-every "org" (pred seq))
|
||||
|
||||
(defvar org-babel-tangle-lang-exts)
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("fortran" . "F90"))
|
||||
@ -62,11 +62,11 @@
|
||||
(org-babel-process-file-name tmp-src-file)) ""))))
|
||||
((lambda (results)
|
||||
(org-babel-reassemble-table
|
||||
(if (member "vector" (cdr (assoc :result-params params)))
|
||||
(let ((tmp-file (org-babel-temp-file "f-")))
|
||||
(with-temp-file tmp-file (insert results))
|
||||
(org-babel-import-elisp-from-file tmp-file))
|
||||
(org-babel-read results))
|
||||
(org-babel-result-cond (cdr (assoc :result-params params))
|
||||
(org-babel-read results)
|
||||
(let ((tmp-file (org-babel-temp-file "f-")))
|
||||
(with-temp-file tmp-file (insert results))
|
||||
(org-babel-import-elisp-from-file tmp-file)))
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name
|
||||
@ -144,6 +144,12 @@ of the same value."
|
||||
((stringp val)
|
||||
(format "character(len=%d), parameter :: %S = '%s'\n"
|
||||
(length val) var val))
|
||||
;; val is a matrix
|
||||
((and (listp val) (org-every #'listp val))
|
||||
(format "real, parameter :: %S(%d,%d) = transpose( reshape( %s , (/ %d, %d /) ) )\n"
|
||||
var (length val) (length (car val))
|
||||
(org-babel-fortran-transform-list val)
|
||||
(length (car val)) (length val)))
|
||||
((listp val)
|
||||
(format "real, parameter :: %S(%d) = %s\n"
|
||||
var (length val) (org-babel-fortran-transform-list val)))
|
||||
|
@ -39,8 +39,6 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-ref)
|
||||
(require 'ob-comint)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(declare-function org-time-string-to-time "org" (s))
|
||||
@ -54,77 +52,117 @@
|
||||
'((:results . "file") (:exports . "results") (:session . nil))
|
||||
"Default arguments to use when evaluating a gnuplot source block.")
|
||||
|
||||
(defvar org-babel-header-args:gnuplot
|
||||
'((title . :any)
|
||||
(lines . :any)
|
||||
(sets . :any)
|
||||
(x-labels . :any)
|
||||
(y-labels . :any)
|
||||
(timefmt . :any)
|
||||
(time-ind . :any)
|
||||
(missing . :any)
|
||||
(term . :any))
|
||||
"Gnuplot specific header args.")
|
||||
|
||||
(defvar org-babel-gnuplot-timestamp-fmt nil)
|
||||
|
||||
(defvar *org-babel-gnuplot-missing* nil)
|
||||
|
||||
(defcustom *org-babel-gnuplot-terms*
|
||||
'((eps . "postscript eps"))
|
||||
"List of file extensions and the associated gnuplot terminal."
|
||||
:group 'org-babel
|
||||
:type '(repeat (cons (symbol :tag "File extension")
|
||||
(string :tag "Gnuplot terminal"))))
|
||||
|
||||
(defun org-babel-gnuplot-process-vars (params)
|
||||
"Extract variables from PARAMS and process the variables.
|
||||
Dumps all vectors into files and returns an association list
|
||||
of variable names and the related value to be used in the gnuplot
|
||||
code."
|
||||
(mapcar
|
||||
(lambda (pair)
|
||||
(cons
|
||||
(car pair) ;; variable name
|
||||
(if (listp (cdr pair)) ;; variable value
|
||||
(org-babel-gnuplot-table-to-data
|
||||
(cdr pair) (org-babel-temp-file "gnuplot-") params)
|
||||
(cdr pair))))
|
||||
(mapcar #'cdr (org-babel-get-header params :var))))
|
||||
(let ((*org-babel-gnuplot-missing* (cdr (assoc :missing params))))
|
||||
(mapcar
|
||||
(lambda (pair)
|
||||
(cons
|
||||
(car pair) ;; variable name
|
||||
(if (listp (cdr pair)) ;; variable value
|
||||
(org-babel-gnuplot-table-to-data
|
||||
(cdr pair) (org-babel-temp-file "gnuplot-") params)
|
||||
(cdr pair))))
|
||||
(mapcar #'cdr (org-babel-get-header params :var)))))
|
||||
|
||||
(defun org-babel-expand-body:gnuplot (body params)
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(save-window-excursion
|
||||
(let* ((vars (org-babel-gnuplot-process-vars params))
|
||||
(out-file (cdr (assoc :file params)))
|
||||
(term (or (cdr (assoc :term params))
|
||||
(when out-file (file-name-extension out-file))))
|
||||
(prologue (cdr (assoc :prologue params)))
|
||||
(epilogue (cdr (assoc :epilogue params)))
|
||||
(term (or (cdr (assoc :term params))
|
||||
(when out-file
|
||||
(let ((ext (file-name-extension out-file)))
|
||||
(or (cdr (assoc (intern (downcase ext))
|
||||
*org-babel-gnuplot-terms*))
|
||||
ext)))))
|
||||
(cmdline (cdr (assoc :cmdline params)))
|
||||
(title (plist-get params :title))
|
||||
(lines (plist-get params :line))
|
||||
(sets (plist-get params :set))
|
||||
(x-labels (plist-get params :xlabels))
|
||||
(y-labels (plist-get params :ylabels))
|
||||
(timefmt (plist-get params :timefmt))
|
||||
(time-ind (or (plist-get params :timeind)
|
||||
(title (cdr (assoc :title params)))
|
||||
(lines (cdr (assoc :line params)))
|
||||
(sets (cdr (assoc :set params)))
|
||||
(x-labels (cdr (assoc :xlabels params)))
|
||||
(y-labels (cdr (assoc :ylabels params)))
|
||||
(timefmt (cdr (assoc :timefmt params)))
|
||||
(time-ind (or (cdr (assoc :timeind params))
|
||||
(when timefmt 1)))
|
||||
(missing (cdr (assoc :missing params)))
|
||||
(add-to-body (lambda (text) (setq body (concat text "\n" body))))
|
||||
output)
|
||||
;; append header argument settings to body
|
||||
(when title (funcall add-to-body (format "set title '%s'" title))) ;; title
|
||||
(when lines (mapc (lambda (el) (funcall add-to-body el)) lines)) ;; line
|
||||
(when title (funcall add-to-body (format "set title '%s'" title)))
|
||||
(when lines (mapc (lambda (el) (funcall add-to-body el)) lines))
|
||||
(when missing
|
||||
(funcall add-to-body (format "set datafile missing '%s'" missing)))
|
||||
(when sets
|
||||
(mapc (lambda (el) (funcall add-to-body (format "set %s" el))) sets))
|
||||
(when x-labels
|
||||
(funcall add-to-body
|
||||
(format "set xtics (%s)"
|
||||
(mapconcat (lambda (pair)
|
||||
(format "\"%s\" %d" (cdr pair) (car pair)))
|
||||
(format "\"%s\" %d"
|
||||
(cdr pair) (car pair)))
|
||||
x-labels ", "))))
|
||||
(when y-labels
|
||||
(funcall add-to-body
|
||||
(format "set ytics (%s)"
|
||||
(mapconcat (lambda (pair)
|
||||
(format "\"%s\" %d" (cdr pair) (car pair)))
|
||||
(format "\"%s\" %d"
|
||||
(cdr pair) (car pair)))
|
||||
y-labels ", "))))
|
||||
(when time-ind
|
||||
(funcall add-to-body "set xdata time")
|
||||
(funcall add-to-body (concat "set timefmt \""
|
||||
(or timefmt
|
||||
"%Y-%m-%d-%H:%M:%S") "\"")))
|
||||
(when out-file (funcall add-to-body (format "set output \"%s\"" out-file)))
|
||||
(when out-file
|
||||
;; set the terminal at the top of the block
|
||||
(funcall add-to-body (format "set output \"%s\"" out-file))
|
||||
;; and close the terminal at the bottom of the block
|
||||
(setq body (concat body "\nset output\n")))
|
||||
(when term (funcall add-to-body (format "set term %s" term)))
|
||||
;; insert variables into code body: this should happen last
|
||||
;; placing the variables at the *top* of the code in case their
|
||||
;; values are used later
|
||||
(funcall add-to-body (mapconcat #'identity
|
||||
(org-babel-variable-assignments:gnuplot params)
|
||||
"\n"))
|
||||
(funcall add-to-body
|
||||
(mapconcat #'identity
|
||||
(org-babel-variable-assignments:gnuplot params)
|
||||
"\n"))
|
||||
;; replace any variable names preceded by '$' with the actual
|
||||
;; value of the variable
|
||||
(mapc (lambda (pair)
|
||||
(setq body (replace-regexp-in-string
|
||||
(format "\\$%s" (car pair)) (cdr pair) body)))
|
||||
vars))
|
||||
vars)
|
||||
(when prologue (funcall add-to-body prologue))
|
||||
(when epilogue (setq body (concat body "\n" epilogue))))
|
||||
body))
|
||||
|
||||
(defun org-babel-execute:gnuplot (body params)
|
||||
@ -201,7 +239,8 @@ then create one. Return the initialized session. The current
|
||||
|
||||
(defun org-babel-gnuplot-quote-timestamp-field (s)
|
||||
"Convert S from timestamp to Unix time and export to gnuplot."
|
||||
(format-time-string org-babel-gnuplot-timestamp-fmt (org-time-string-to-time s)))
|
||||
(format-time-string org-babel-gnuplot-timestamp-fmt
|
||||
(org-time-string-to-time s)))
|
||||
|
||||
(defvar org-table-number-regexp)
|
||||
(defvar org-ts-regexp3)
|
||||
@ -212,7 +251,12 @@ then create one. Return the initialized session. The current
|
||||
(if (string-match org-table-number-regexp s) s
|
||||
(if (string-match org-ts-regexp3 s)
|
||||
(org-babel-gnuplot-quote-timestamp-field s)
|
||||
(concat "\"" (mapconcat 'identity (split-string s "\"") "\"\"") "\""))))
|
||||
(if (zerop (length s))
|
||||
(or *org-babel-gnuplot-missing* s)
|
||||
(if (string-match "[ \"]" "?")
|
||||
(concat "\"" (mapconcat 'identity (split-string s "\"") "\"\"")
|
||||
"\"")
|
||||
s)))))
|
||||
|
||||
(defun org-babel-gnuplot-table-to-data (table data-file params)
|
||||
"Export TABLE to DATA-FILE in a format readable by gnuplot.
|
||||
|
@ -40,7 +40,6 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-comint)
|
||||
(require 'comint)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
@ -53,7 +52,8 @@
|
||||
(defvar org-babel-tangle-lang-exts)
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("haskell" . "hs"))
|
||||
|
||||
(defvar org-babel-default-header-args:haskell '())
|
||||
(defvar org-babel-default-header-args:haskell
|
||||
'((:padlines . "no")))
|
||||
|
||||
(defvar org-babel-haskell-lhs2tex-command "lhs2tex")
|
||||
|
||||
@ -79,11 +79,12 @@
|
||||
(cdr (member org-babel-haskell-eoe
|
||||
(reverse (mapcar #'org-babel-trim raw)))))))
|
||||
(org-babel-reassemble-table
|
||||
(cond
|
||||
((equal result-type 'output)
|
||||
(mapconcat #'identity (reverse (cdr results)) "\n"))
|
||||
((equal result-type 'value)
|
||||
(org-babel-haskell-table-or-string (car results))))
|
||||
((lambda (result)
|
||||
(org-babel-result-cond (cdr (assoc :result-params params))
|
||||
result (org-babel-haskell-table-or-string result)))
|
||||
(case result-type
|
||||
('output (mapconcat #'identity (reverse (cdr results)) "\n"))
|
||||
('value (car results))))
|
||||
(org-babel-pick-name (cdr (assoc :colname-names params))
|
||||
(cdr (assoc :colname-names params)))
|
||||
(org-babel-pick-name (cdr (assoc :rowname-names params))
|
||||
@ -147,8 +148,9 @@ specifying a variable of the same value."
|
||||
(format "%S" var)))
|
||||
|
||||
(defvar org-src-preserve-indentation)
|
||||
(declare-function org-export-as-latex "org-latex"
|
||||
(arg &optional ext-plist to-buffer body-only pub-dir))
|
||||
(declare-function org-export-to-file "ox"
|
||||
(backend file
|
||||
&optional async subtreep visible-only body-only ext-plist))
|
||||
(defun org-babel-haskell-export-to-lhs (&optional arg)
|
||||
"Export to a .lhs file with all haskell code blocks escaped.
|
||||
When called with a prefix argument the resulting
|
||||
@ -192,7 +194,11 @@ constructs (header arguments, no-web syntax etc...) are ignored."
|
||||
(indent-code-rigidly (match-beginning 0) (match-end 0) indentation)))
|
||||
(save-excursion
|
||||
;; export to latex w/org and save as .lhs
|
||||
(find-file tmp-org-file) (funcall 'org-export-as-latex nil)
|
||||
(require 'ox-latex)
|
||||
(find-file tmp-org-file)
|
||||
;; Ensure we do not clutter kill ring with incomplete results.
|
||||
(let (org-export-copy-to-kill-ring)
|
||||
(org-export-to-file 'latex tmp-tex-file))
|
||||
(kill-buffer nil)
|
||||
(delete-file tmp-org-file)
|
||||
(find-file tmp-tex-file)
|
||||
|
@ -33,9 +33,6 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-ref)
|
||||
(require 'ob-comint)
|
||||
(require 'ob-eval)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(defvar org-babel-tangle-lang-exts) ;; Autoloaded
|
||||
@ -98,8 +95,8 @@ in BODY as elisp."
|
||||
(wrapper (format org-babel-io-wrapper-method body)))
|
||||
(with-temp-file src-file (insert wrapper))
|
||||
((lambda (raw)
|
||||
(if (member "code" result-params)
|
||||
raw
|
||||
(org-babel-result-cond result-params
|
||||
raw
|
||||
(org-babel-io-table-or-string raw)))
|
||||
(org-babel-eval
|
||||
(concat org-babel-io-command " " src-file) ""))))))
|
||||
|
@ -28,7 +28,6 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-eval)
|
||||
|
||||
(defvar org-babel-tangle-lang-exts)
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("java" . "java"))
|
||||
@ -58,11 +57,11 @@
|
||||
(make-directory packagename 'parents))
|
||||
((lambda (results)
|
||||
(org-babel-reassemble-table
|
||||
(if (member "vector" (cdr (assoc :result-params params)))
|
||||
(let ((tmp-file (org-babel-temp-file "c-")))
|
||||
(org-babel-result-cond (cdr (assoc :result-params params))
|
||||
(org-babel-read results)
|
||||
(let ((tmp-file (org-babel-temp-file "c-")))
|
||||
(with-temp-file tmp-file (insert results))
|
||||
(org-babel-import-elisp-from-file tmp-file))
|
||||
(org-babel-read results))
|
||||
(org-babel-import-elisp-from-file tmp-file)))
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name
|
||||
|
@ -39,9 +39,6 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-ref)
|
||||
(require 'ob-comint)
|
||||
(require 'ob-eval)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(declare-function run-mozilla "ext:moz" (arg))
|
||||
@ -68,30 +65,32 @@ This function is called by `org-babel-execute-src-block'"
|
||||
(let* ((org-babel-js-cmd (or (cdr (assoc :cmd params)) org-babel-js-cmd))
|
||||
(result-type (cdr (assoc :result-type params)))
|
||||
(full-body (org-babel-expand-body:generic
|
||||
body params (org-babel-variable-assignments:js params))))
|
||||
(org-babel-js-read
|
||||
(if (not (string= (cdr (assoc :session params)) "none"))
|
||||
;; session evaluation
|
||||
(let ((session (org-babel-prep-session:js
|
||||
(cdr (assoc :session params)) params)))
|
||||
(nth 1
|
||||
(org-babel-comint-with-output
|
||||
(session (format "%S" org-babel-js-eoe) t body)
|
||||
(mapc
|
||||
(lambda (line)
|
||||
(insert (org-babel-chomp line)) (comint-send-input nil t))
|
||||
(list body (format "%S" org-babel-js-eoe))))))
|
||||
;; external evaluation
|
||||
(let ((script-file (org-babel-temp-file "js-script-")))
|
||||
(with-temp-file script-file
|
||||
(insert
|
||||
;; return the value or the output
|
||||
(if (string= result-type "value")
|
||||
(format org-babel-js-function-wrapper full-body)
|
||||
full-body)))
|
||||
(org-babel-eval
|
||||
(format "%s %s" org-babel-js-cmd
|
||||
(org-babel-process-file-name script-file)) ""))))))
|
||||
body params (org-babel-variable-assignments:js params)))
|
||||
(result (if (not (string= (cdr (assoc :session params)) "none"))
|
||||
;; session evaluation
|
||||
(let ((session (org-babel-prep-session:js
|
||||
(cdr (assoc :session params)) params)))
|
||||
(nth 1
|
||||
(org-babel-comint-with-output
|
||||
(session (format "%S" org-babel-js-eoe) t body)
|
||||
(mapc
|
||||
(lambda (line)
|
||||
(insert (org-babel-chomp line))
|
||||
(comint-send-input nil t))
|
||||
(list body (format "%S" org-babel-js-eoe))))))
|
||||
;; external evaluation
|
||||
(let ((script-file (org-babel-temp-file "js-script-")))
|
||||
(with-temp-file script-file
|
||||
(insert
|
||||
;; return the value or the output
|
||||
(if (string= result-type "value")
|
||||
(format org-babel-js-function-wrapper full-body)
|
||||
full-body)))
|
||||
(org-babel-eval
|
||||
(format "%s %s" org-babel-js-cmd
|
||||
(org-babel-process-file-name script-file)) "")))))
|
||||
(org-babel-result-cond (cdr (assoc :result-params params))
|
||||
result (org-babel-js-read result))))
|
||||
|
||||
(defun org-babel-js-read (results)
|
||||
"Convert RESULTS into an appropriate elisp value.
|
||||
|
@ -29,7 +29,7 @@
|
||||
;; functions and their associated keys.
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-core)
|
||||
|
||||
(defvar org-babel-key-prefix "\C-c\C-v"
|
||||
"The key prefix for Babel interactive key-bindings.
|
||||
|
@ -35,24 +35,32 @@
|
||||
(declare-function org-create-formula-image "org" (string tofile options buffer))
|
||||
(declare-function org-splice-latex-header "org"
|
||||
(tpl def-pkg pkg snippets-p &optional extra))
|
||||
(declare-function org-export-latex-fix-inputenc "org-latex" ())
|
||||
(declare-function org-latex-guess-inputenc "ox-latex" (header))
|
||||
(declare-function org-latex-compile "ox-latex" (file))
|
||||
|
||||
(defvar org-babel-tangle-lang-exts)
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("latex" . "tex"))
|
||||
|
||||
(defvar org-format-latex-header)
|
||||
(defvar org-format-latex-header-extra)
|
||||
(defvar org-export-latex-packages-alist)
|
||||
(defvar org-export-latex-default-packages-alist)
|
||||
(defvar org-export-pdf-logfiles)
|
||||
(defvar org-latex-to-pdf-process)
|
||||
(defvar org-export-pdf-remove-logfiles)
|
||||
(defvar org-format-latex-options)
|
||||
(defvar org-export-latex-packages-alist)
|
||||
(defvar org-format-latex-header) ; From org.el
|
||||
(defvar org-format-latex-options) ; From org.el
|
||||
(defvar org-latex-default-packages-alist) ; From org.el
|
||||
(defvar org-latex-packages-alist) ; From org.el
|
||||
|
||||
(defvar org-babel-default-header-args:latex
|
||||
'((:results . "latex") (:exports . "results"))
|
||||
"Default arguments to use when evaluating a LaTeX source block.")
|
||||
|
||||
(defcustom org-babel-latex-htlatex nil
|
||||
"The htlatex command to enable conversion of latex to SVG or HTML."
|
||||
:group 'org-babel
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-babel-latex-htlatex-packages
|
||||
'("[usenames]{color}" "{tikz}" "{color}" "{listings}" "{amsmath}")
|
||||
"Packages to use for htlatex export."
|
||||
:group 'org-babel
|
||||
:type '(list string))
|
||||
|
||||
(defun org-babel-expand-body:latex (body params)
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(mapc (lambda (pair) ;; replace variables
|
||||
@ -81,28 +89,32 @@ This function is called by `org-babel-execute-src-block'."
|
||||
(width (and fit (cdr (assoc :pdfwidth params))))
|
||||
(headers (cdr (assoc :headers params)))
|
||||
(in-buffer (not (string= "no" (cdr (assoc :buffer params)))))
|
||||
(org-export-latex-packages-alist
|
||||
(append (cdr (assoc :packages params))
|
||||
org-export-latex-packages-alist)))
|
||||
(org-latex-packages-alist
|
||||
(append (cdr (assoc :packages params)) org-latex-packages-alist)))
|
||||
(cond
|
||||
((and (string-match "\\.png$" out-file) (not imagemagick))
|
||||
(org-create-formula-image
|
||||
body out-file org-format-latex-options in-buffer))
|
||||
((or (string-match "\\.pdf$" out-file) imagemagick)
|
||||
(require 'org-latex)
|
||||
((string-match "\\.tikz$" out-file)
|
||||
(when (file-exists-p out-file) (delete-file out-file))
|
||||
(with-temp-file out-file
|
||||
(insert body)))
|
||||
((or (string-match "\\.pdf$" out-file) imagemagick)
|
||||
(with-temp-file tex-file
|
||||
(require 'ox-latex)
|
||||
(insert
|
||||
(org-splice-latex-header
|
||||
org-format-latex-header
|
||||
(delq
|
||||
nil
|
||||
(mapcar
|
||||
(lambda (el)
|
||||
(unless (and (listp el) (string= "hyperref" (cadr el)))
|
||||
el))
|
||||
org-export-latex-default-packages-alist))
|
||||
org-export-latex-packages-alist
|
||||
org-format-latex-header-extra)
|
||||
(org-latex-guess-inputenc
|
||||
(org-splice-latex-header
|
||||
org-format-latex-header
|
||||
(delq
|
||||
nil
|
||||
(mapcar
|
||||
(lambda (el)
|
||||
(unless (and (listp el) (string= "hyperref" (cadr el)))
|
||||
el))
|
||||
org-latex-default-packages-alist))
|
||||
org-latex-packages-alist
|
||||
nil))
|
||||
(if fit "\n\\usepackage[active, tightpage]{preview}\n" "")
|
||||
(if border (format "\\setlength{\\PreviewBorder}{%s}" border) "")
|
||||
(if height (concat "\n" (format "\\pdfpageheight %s" height)) "")
|
||||
@ -113,14 +125,10 @@ This function is called by `org-babel-execute-src-block'."
|
||||
(mapconcat #'identity headers "\n")
|
||||
headers) "\n")
|
||||
"")
|
||||
(if org-format-latex-header-extra
|
||||
(concat "\n" org-format-latex-header-extra)
|
||||
"")
|
||||
(if fit
|
||||
(concat "\n\\begin{document}\n\\begin{preview}\n" body
|
||||
"\n\\end{preview}\n\\end{document}\n")
|
||||
(concat "\n\\begin{document}\n" body "\n\\end{document}\n")))
|
||||
(org-export-latex-fix-inputenc))
|
||||
(concat "\n\\begin{document}\n" body "\n\\end{document}\n"))))
|
||||
(when (file-exists-p out-file) (delete-file out-file))
|
||||
(let ((transient-pdf-file (org-babel-latex-tex-to-pdf tex-file)))
|
||||
(cond
|
||||
@ -131,13 +139,46 @@ This function is called by `org-babel-execute-src-block'."
|
||||
transient-pdf-file out-file im-in-options im-out-options)
|
||||
(when (file-exists-p transient-pdf-file)
|
||||
(delete-file transient-pdf-file))))))
|
||||
((and (or (string-match "\\.svg$" out-file)
|
||||
(string-match "\\.html$" out-file))
|
||||
org-babel-latex-htlatex)
|
||||
(with-temp-file tex-file
|
||||
(insert (concat
|
||||
"\\documentclass[preview]{standalone}
|
||||
\\def\\pgfsysdriver{pgfsys-tex4ht.def}
|
||||
"
|
||||
(mapconcat (lambda (pkg)
|
||||
(concat "\\usepackage" pkg))
|
||||
org-babel-latex-htlatex-packages
|
||||
"\n")
|
||||
"\\begin{document}"
|
||||
body
|
||||
"\\end{document}")))
|
||||
(when (file-exists-p out-file) (delete-file out-file))
|
||||
(let ((default-directory (file-name-directory tex-file)))
|
||||
(shell-command (format "%s %s" org-babel-latex-htlatex tex-file)))
|
||||
(cond
|
||||
((file-exists-p (concat (file-name-sans-extension tex-file) "-1.svg"))
|
||||
(if (string-match "\\.svg$" out-file)
|
||||
(progn
|
||||
(shell-command "pwd")
|
||||
(shell-command (format "mv %s %s"
|
||||
(concat (file-name-sans-extension tex-file) "-1.svg")
|
||||
out-file)))
|
||||
(error "SVG file produced but HTML file requested.")))
|
||||
((file-exists-p (concat (file-name-sans-extension tex-file) ".html"))
|
||||
(if (string-match "\\.html$" out-file)
|
||||
(shell-command "mv %s %s"
|
||||
(concat (file-name-sans-extension tex-file)
|
||||
".html")
|
||||
out-file)
|
||||
(error "HTML file produced but SVG file requested.")))))
|
||||
((string-match "\\.\\([^\\.]+\\)$" out-file)
|
||||
(error "Can not create %s files, please specify a .png or .pdf file or try the :imagemagick header argument"
|
||||
(match-string 1 out-file))))
|
||||
nil) ;; signal that output has already been written to file
|
||||
body))
|
||||
|
||||
|
||||
(defun convert-pdf (pdffile out-file im-in-options im-out-options)
|
||||
"Generate a file from a pdf file using imagemagick."
|
||||
(let ((cmd (concat "convert " im-in-options " " pdffile " "
|
||||
@ -146,55 +187,14 @@ This function is called by `org-babel-execute-src-block'."
|
||||
(shell-command cmd)))
|
||||
|
||||
(defun org-babel-latex-tex-to-pdf (file)
|
||||
"Generate a pdf file according to the contents FILE.
|
||||
Extracted from `org-export-as-pdf' in org-latex.el."
|
||||
(let* ((wconfig (current-window-configuration))
|
||||
(default-directory (file-name-directory file))
|
||||
(base (file-name-sans-extension file))
|
||||
(pdffile (concat base ".pdf"))
|
||||
(cmds org-latex-to-pdf-process)
|
||||
(outbuf (get-buffer-create "*Org PDF LaTeX Output*"))
|
||||
output-dir cmd)
|
||||
(with-current-buffer outbuf (erase-buffer))
|
||||
(message (concat "Processing LaTeX file " file "..."))
|
||||
(setq output-dir (file-name-directory file))
|
||||
(if (and cmds (symbolp cmds))
|
||||
(funcall cmds (shell-quote-argument file))
|
||||
(while cmds
|
||||
(setq cmd (pop cmds))
|
||||
(while (string-match "%b" cmd)
|
||||
(setq cmd (replace-match
|
||||
(save-match-data
|
||||
(shell-quote-argument base))
|
||||
t t cmd)))
|
||||
(while (string-match "%f" cmd)
|
||||
(setq cmd (replace-match
|
||||
(save-match-data
|
||||
(shell-quote-argument file))
|
||||
t t cmd)))
|
||||
(while (string-match "%o" cmd)
|
||||
(setq cmd (replace-match
|
||||
(save-match-data
|
||||
(shell-quote-argument output-dir))
|
||||
t t cmd)))
|
||||
(shell-command cmd outbuf)))
|
||||
(message (concat "Processing LaTeX file " file "...done"))
|
||||
(if (not (file-exists-p pdffile))
|
||||
(error (concat "PDF file " pdffile " was not produced"))
|
||||
(set-window-configuration wconfig)
|
||||
(when org-export-pdf-remove-logfiles
|
||||
(dolist (ext org-export-pdf-logfiles)
|
||||
(setq file (concat base "." ext))
|
||||
(and (file-exists-p file) (delete-file file))))
|
||||
(message "Exporting to PDF...done")
|
||||
pdffile)))
|
||||
"Generate a pdf file according to the contents FILE."
|
||||
(require 'ox-latex)
|
||||
(org-latex-compile file))
|
||||
|
||||
(defun org-babel-prep-session:latex (session params)
|
||||
"Return an error because LaTeX doesn't support sessions."
|
||||
(error "LaTeX does not support sessions"))
|
||||
|
||||
|
||||
(provide 'ob-latex)
|
||||
|
||||
|
||||
|
||||
;;; ob-latex.el ends here
|
||||
|
@ -30,10 +30,7 @@
|
||||
;; http://lilypond.org/manuals.html
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'ob)
|
||||
(require 'ob-eval)
|
||||
(require 'ob-tangle)
|
||||
(require 'outline)
|
||||
(defalias 'lilypond-mode 'LilyPond-mode)
|
||||
|
||||
@ -155,7 +152,11 @@ specific arguments to =org-babel-tangle="
|
||||
" -dbackend=eps "
|
||||
"-dno-gs-load-fonts "
|
||||
"-dinclude-eps-fonts "
|
||||
"--png "
|
||||
(or (cdr (assoc (file-name-extension out-file)
|
||||
'(("pdf" . "--pdf ")
|
||||
("ps" . "--ps ")
|
||||
("png" . "--png "))))
|
||||
"--png ")
|
||||
"--output="
|
||||
(file-name-sans-extension out-file)
|
||||
" "
|
||||
|
@ -76,8 +76,8 @@ current directory string."
|
||||
(require 'slime)
|
||||
(org-babel-reassemble-table
|
||||
((lambda (result)
|
||||
(if (member "output" (cdr (assoc :result-params params)))
|
||||
(car result)
|
||||
(org-babel-result-cond (cdr (assoc :result-params params))
|
||||
(car result)
|
||||
(condition-case nil
|
||||
(read (org-babel-lisp-vector-to-list (cadr result)))
|
||||
(error (cadr result)))))
|
||||
|
@ -25,7 +25,7 @@
|
||||
;;; Code:
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
(require 'ob)
|
||||
(require 'ob-core)
|
||||
(require 'ob-table)
|
||||
|
||||
(declare-function org-babel-in-example-or-verbatim "ob-exp" nil)
|
||||
@ -35,7 +35,7 @@
|
||||
This is an association list. Populate the library by adding
|
||||
files to `org-babel-lob-files'.")
|
||||
|
||||
(defcustom org-babel-lob-files '()
|
||||
(defcustom org-babel-lob-files nil
|
||||
"Files used to populate the `org-babel-library-of-babel'.
|
||||
To add files to this list use the `org-babel-lob-ingest' command."
|
||||
:group 'org-babel
|
||||
@ -114,29 +114,45 @@ if so then run the appropriate source block from the Library."
|
||||
(or (funcall nonempty 8 19) ""))
|
||||
(funcall nonempty 9 18)))
|
||||
(list (length (if (= (length (match-string 12)) 0)
|
||||
(match-string 2) (match-string 11)))))))))
|
||||
(match-string 2) (match-string 11)))
|
||||
(save-excursion
|
||||
(forward-line -1)
|
||||
(and (looking-at (concat org-babel-src-name-regexp
|
||||
"\\([^\n]*\\)$"))
|
||||
(org-no-properties (match-string 1))))))))))
|
||||
|
||||
(defvar org-babel-default-header-args:emacs-lisp) ; Defined in ob-emacs-lisp.el
|
||||
(defun org-babel-lob-execute (info)
|
||||
"Execute the lob call specified by INFO."
|
||||
(let* ((mkinfo (lambda (p) (list "emacs-lisp" "results" p nil nil (nth 2 info))))
|
||||
(pre-params (org-babel-merge-params
|
||||
org-babel-default-header-args
|
||||
(org-babel-params-from-properties)
|
||||
(org-babel-parse-header-arguments
|
||||
(org-no-properties
|
||||
(concat ":var results="
|
||||
(mapconcat #'identity (butlast info) " "))))))
|
||||
(let* ((mkinfo (lambda (p)
|
||||
(list "emacs-lisp" "results" p nil
|
||||
(nth 3 info) ;; name
|
||||
(nth 2 info))))
|
||||
(pre-params (apply #'org-babel-merge-params
|
||||
org-babel-default-header-args
|
||||
org-babel-default-header-args:emacs-lisp
|
||||
(append
|
||||
(org-babel-params-from-properties)
|
||||
(list
|
||||
(org-babel-parse-header-arguments
|
||||
(org-no-properties
|
||||
(concat
|
||||
":var results="
|
||||
(mapconcat #'identity (butlast info 2)
|
||||
" "))))))))
|
||||
(pre-info (funcall mkinfo pre-params))
|
||||
(cache? (and (cdr (assoc :cache pre-params))
|
||||
(string= "yes" (cdr (assoc :cache pre-params)))))
|
||||
(new-hash (when cache? (org-babel-sha1-hash pre-info)))
|
||||
(old-hash (when cache? (org-babel-current-result-hash))))
|
||||
(if (and cache? (equal new-hash old-hash))
|
||||
(cache-p (and (cdr (assoc :cache pre-params))
|
||||
(string= "yes" (cdr (assoc :cache pre-params)))))
|
||||
(new-hash (when cache-p (org-babel-sha1-hash pre-info)))
|
||||
(old-hash (when cache-p (org-babel-current-result-hash)))
|
||||
(org-babel-current-src-block-location (point-marker)))
|
||||
(if (and cache-p (equal new-hash old-hash))
|
||||
(save-excursion (goto-char (org-babel-where-is-src-block-result))
|
||||
(forward-line 1)
|
||||
(message "%S" (org-babel-read-result)))
|
||||
(prog1 (org-babel-execute-src-block
|
||||
nil (funcall mkinfo (org-babel-process-params pre-params)))
|
||||
(prog1 (let* ((proc-params (org-babel-process-params pre-params))
|
||||
org-confirm-babel-evaluate)
|
||||
(org-babel-execute-src-block nil (funcall mkinfo proc-params)))
|
||||
;; update the hash
|
||||
(when new-hash (org-babel-set-current-result-hash new-hash))))))
|
||||
|
||||
|
47
lisp/org/ob-makefile.el
Normal file
47
lisp/org/ob-makefile.el
Normal file
@ -0,0 +1,47 @@
|
||||
;;; ob-makefile.el --- org-babel functions for makefile evaluation
|
||||
|
||||
;; Copyright (C) 2009-2012 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte and Thomas S. Dye
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; GNU Emacs 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.
|
||||
|
||||
;; GNU Emacs 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 GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This file exists solely for tangling a Makefile from org-mode files.
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
|
||||
(defvar org-babel-default-header-args:makefile '())
|
||||
|
||||
(defun org-babel-execute:makefile (body params)
|
||||
"Execute a block of makefile code.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
body)
|
||||
|
||||
(defun org-babel-prep-session:makefile (session params)
|
||||
"Return an error if the :session header argument is set. Make
|
||||
does not support sessions."
|
||||
(error "Makefile sessions are nonsensical"))
|
||||
|
||||
(provide 'ob-makefile)
|
||||
|
||||
|
||||
|
||||
;;; ob-makefile.el ends here
|
@ -83,16 +83,15 @@ called by `org-babel-execute-src-block'."
|
||||
(mapcar (lambda (line)
|
||||
(unless (or (string-match "batch" line)
|
||||
(string-match "^rat: replaced .*$" line)
|
||||
(string-match "^;;; Loading #P" line)
|
||||
(= 0 (length line)))
|
||||
line))
|
||||
(split-string raw "[\r\n]"))) "\n"))
|
||||
(org-babel-eval cmd "")))))
|
||||
(if (org-babel-maxima-graphical-output-file params)
|
||||
nil
|
||||
(if (or (member "scalar" result-params)
|
||||
(member "verbatim" result-params)
|
||||
(member "output" result-params))
|
||||
result
|
||||
(org-babel-result-cond result-params
|
||||
result
|
||||
(let ((tmp-file (org-babel-temp-file "maxima-res-")))
|
||||
(with-temp-file tmp-file (insert result))
|
||||
(org-babel-import-elisp-from-file tmp-file))))))
|
||||
|
@ -55,7 +55,6 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-eval)
|
||||
|
||||
(defvar org-babel-default-header-args:mscgen
|
||||
'((:results . "file") (:exports . "results"))
|
||||
|
@ -36,11 +36,11 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-comint)
|
||||
(require 'comint)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(declare-function tuareg-run-caml "ext:tuareg" ())
|
||||
(declare-function tuareg-run-ocaml "ext:tuareg" ())
|
||||
(declare-function tuareg-interactive-send-input "ext:tuareg" ())
|
||||
|
||||
(defvar org-babel-tangle-lang-exts)
|
||||
@ -51,6 +51,13 @@
|
||||
(defvar org-babel-ocaml-eoe-indicator "\"org-babel-ocaml-eoe\";;")
|
||||
(defvar org-babel-ocaml-eoe-output "org-babel-ocaml-eoe")
|
||||
|
||||
(defcustom org-babel-ocaml-command "ocaml"
|
||||
"Name of the command for executing Ocaml code."
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:group 'org-babel
|
||||
:type 'string)
|
||||
|
||||
(defun org-babel-execute:ocaml (body params)
|
||||
"Execute a block of Ocaml code with Babel."
|
||||
(let* ((vars (mapcar #'cdr (org-babel-get-header params :var)))
|
||||
@ -63,7 +70,7 @@
|
||||
(session org-babel-ocaml-eoe-output t full-body)
|
||||
(insert
|
||||
(concat
|
||||
(org-babel-chomp full-body)"\n"org-babel-ocaml-eoe-indicator))
|
||||
(org-babel-chomp full-body)";;\n"org-babel-ocaml-eoe-indicator))
|
||||
(tuareg-interactive-send-input)))
|
||||
(clean
|
||||
(car (let ((re (regexp-quote org-babel-ocaml-eoe-output)) out)
|
||||
@ -74,7 +81,14 @@
|
||||
(progn (setq out t) nil))))
|
||||
(mapcar #'org-babel-trim (reverse raw))))))))
|
||||
(org-babel-reassemble-table
|
||||
(org-babel-ocaml-parse-output (org-babel-trim clean))
|
||||
(let ((raw (org-babel-trim clean))
|
||||
(result-params (cdr (assoc :result-params params))))
|
||||
(org-babel-result-cond result-params
|
||||
;; strip type information from output unless verbatim is specified
|
||||
(if (and (not (member "verbatim" result-params))
|
||||
(string-match "= \\(.+\\)$" raw))
|
||||
(match-string 1 raw) raw)
|
||||
(org-babel-ocaml-parse-output raw)))
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name
|
||||
@ -89,8 +103,10 @@
|
||||
(stringp session))
|
||||
session
|
||||
tuareg-interactive-buffer-name)))
|
||||
(save-window-excursion (tuareg-run-caml)
|
||||
(get-buffer tuareg-interactive-buffer-name))))
|
||||
(save-window-excursion (if (fboundp 'tuareg-run-process-if-needed)
|
||||
(tuareg-run-process-if-needed org-babel-ocaml-command)
|
||||
(tuareg-run-caml)))
|
||||
(get-buffer tuareg-interactive-buffer-name)))
|
||||
|
||||
(defun org-babel-variable-assignments:ocaml (params)
|
||||
"Return list of ocaml statements assigning the block's variables."
|
||||
@ -108,7 +124,7 @@
|
||||
(defun org-babel-ocaml-parse-output (output)
|
||||
"Parse OUTPUT.
|
||||
OUTPUT is string output from an ocaml process."
|
||||
(let ((regexp "%s = \\(.+\\)$"))
|
||||
(let ((regexp "[^:]+ : %s = \\(.+\\)$"))
|
||||
(cond
|
||||
((string-match (format regexp "string") output)
|
||||
(org-babel-read (match-string 1 output)))
|
||||
|
@ -30,9 +30,6 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-ref)
|
||||
(require 'ob-comint)
|
||||
(require 'ob-eval)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(declare-function matlab-shell "ext:matlab-mode")
|
||||
@ -154,7 +151,8 @@ create. Return the initialized session."
|
||||
"Create an octave inferior process buffer.
|
||||
If there is not a current inferior-process-buffer in SESSION then
|
||||
create. Return the initialized session."
|
||||
(if matlabp (require 'matlab) (require 'octave-inf))
|
||||
(if matlabp (require 'matlab) (or (require 'octave-inf nil 'noerror)
|
||||
(require 'octave)))
|
||||
(unless (string= session "none")
|
||||
(let ((session (or session
|
||||
(if matlabp "*Inferior Matlab*" "*Inferior Octave*"))))
|
||||
|
@ -29,7 +29,8 @@
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
|
||||
(declare-function org-export-string "org-exp" (string fmt &optional dir))
|
||||
(declare-function org-export-string-as "ox"
|
||||
(string backend &optional body-only ext-plist))
|
||||
|
||||
(defvar org-babel-default-header-args:org
|
||||
'((:results . "raw silent") (:exports . "code"))
|
||||
@ -42,8 +43,9 @@
|
||||
(defun org-babel-expand-body:org (body params)
|
||||
(dolist (var (mapcar #'cdr (org-babel-get-header params :var)))
|
||||
(setq body (replace-regexp-in-string
|
||||
(regexp-quote (format "$%s" (car var))) (cdr var) body
|
||||
nil 'literal)))
|
||||
(regexp-quote (format "$%s" (car var)))
|
||||
(format "%s" (cdr var))
|
||||
body nil 'literal)))
|
||||
body)
|
||||
|
||||
(defun org-babel-execute:org (body params)
|
||||
@ -53,10 +55,10 @@ This function is called by `org-babel-execute-src-block'."
|
||||
(body (org-babel-expand-body:org
|
||||
(replace-regexp-in-string "^," "" body) params)))
|
||||
(cond
|
||||
((member "latex" result-params) (org-export-string
|
||||
(concat "#+Title: \n" body) "latex"))
|
||||
((member "html" result-params) (org-export-string body "html"))
|
||||
((member "ascii" result-params) (org-export-string body "ascii"))
|
||||
((member "latex" result-params)
|
||||
(org-export-string-as (concat "#+Title: \n" body) 'latex t))
|
||||
((member "html" result-params) (org-export-string-as body 'html t))
|
||||
((member "ascii" result-params) (org-export-string-as body 'ascii t))
|
||||
(t body))))
|
||||
|
||||
(defun org-babel-prep-session:org (session params)
|
||||
|
@ -28,7 +28,6 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-eval)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(defvar org-babel-tangle-lang-exts)
|
||||
@ -49,7 +48,7 @@ This function is called by `org-babel-execute-src-block'."
|
||||
body params (org-babel-variable-assignments:perl params)))
|
||||
(session (org-babel-perl-initiate-session session)))
|
||||
(org-babel-reassemble-table
|
||||
(org-babel-perl-evaluate session full-body result-type)
|
||||
(org-babel-perl-evaluate session full-body result-type result-params)
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name
|
||||
@ -63,20 +62,33 @@ This function is called by `org-babel-execute-src-block'."
|
||||
"Return list of perl statements assigning the block's variables."
|
||||
(mapcar
|
||||
(lambda (pair)
|
||||
(format "$%s=%s;"
|
||||
(car pair)
|
||||
(org-babel-perl-var-to-perl (cdr pair))))
|
||||
(org-babel-perl--var-to-perl (cdr pair) (car pair)))
|
||||
(mapcar #'cdr (org-babel-get-header params :var))))
|
||||
|
||||
;; helper functions
|
||||
|
||||
(defun org-babel-perl-var-to-perl (var)
|
||||
(defvar org-babel-perl-var-wrap "q(%s)"
|
||||
"Wrapper for variables inserted into Perl code.")
|
||||
|
||||
(defvar org-babel-perl--lvl)
|
||||
(defun org-babel-perl--var-to-perl (var &optional varn)
|
||||
"Convert an elisp value to a perl variable.
|
||||
The elisp value, VAR, is converted to a string of perl source code
|
||||
specifying a var of the same value."
|
||||
(if (listp var)
|
||||
(concat "[" (mapconcat #'org-babel-perl-var-to-perl var ", ") "]")
|
||||
(format "%S" var)))
|
||||
(if varn
|
||||
(let ((org-babel-perl--lvl 0) (lvar (listp var)) prefix)
|
||||
(concat "my $" (symbol-name varn) "=" (when lvar "\n")
|
||||
(org-babel-perl--var-to-perl var)
|
||||
";\n"))
|
||||
(let ((prefix (make-string (* 2 org-babel-perl--lvl) ?\ )))
|
||||
(concat prefix
|
||||
(if (listp var)
|
||||
(let ((org-babel-perl--lvl (1+ org-babel-perl--lvl)))
|
||||
(concat "[\n"
|
||||
(mapconcat #'org-babel-perl--var-to-perl var "")
|
||||
prefix "]"))
|
||||
(format "q(%s)" var))
|
||||
(unless (zerop org-babel-perl--lvl) ",\n")))))
|
||||
|
||||
(defvar org-babel-perl-buffers '(:default . nil))
|
||||
|
||||
@ -84,32 +96,60 @@ specifying a var of the same value."
|
||||
"Return nil because sessions are not supported by perl."
|
||||
nil)
|
||||
|
||||
(defvar org-babel-perl-wrapper-method
|
||||
"
|
||||
sub main {
|
||||
%s
|
||||
}
|
||||
@r = main;
|
||||
open(o, \">%s\");
|
||||
print o join(\"\\n\", @r), \"\\n\"")
|
||||
(defvar org-babel-perl-wrapper-method "{
|
||||
my $babel_sub = sub {
|
||||
%s
|
||||
};
|
||||
open my $BOH, qq(>%s) or die qq(Perl: Could not open output file.$/);
|
||||
my $rv = &$babel_sub();
|
||||
my $rt = ref $rv;
|
||||
select $BOH;
|
||||
if (qq(ARRAY) eq $rt) {
|
||||
local $\\=$/;
|
||||
local $,=qq(\t);
|
||||
foreach my $rv ( @$rv ) {
|
||||
my $rt = ref $rv;
|
||||
if (qq(ARRAY) eq $rt) {
|
||||
print @$rv;
|
||||
} else {
|
||||
print $rv;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print $rv;
|
||||
}
|
||||
}")
|
||||
|
||||
(defvar org-babel-perl-preface nil)
|
||||
|
||||
(defvar org-babel-perl-pp-wrapper-method
|
||||
nil)
|
||||
|
||||
(defun org-babel-perl-evaluate (session body &optional result-type)
|
||||
(defun org-babel-perl-evaluate (session ibody &optional result-type result-params)
|
||||
"Pass BODY to the Perl process in SESSION.
|
||||
If RESULT-TYPE equals 'output then return a list of the outputs
|
||||
of the statements in BODY, if RESULT-TYPE equals 'value then
|
||||
return the value of the last statement in BODY, as elisp."
|
||||
(when session (error "Sessions are not supported for Perl"))
|
||||
(case result-type
|
||||
(output (org-babel-eval org-babel-perl-command body))
|
||||
(value (let ((tmp-file (org-babel-temp-file "perl-")))
|
||||
(org-babel-eval
|
||||
org-babel-perl-command
|
||||
(format org-babel-perl-wrapper-method body
|
||||
(org-babel-process-file-name tmp-file 'noquote)))
|
||||
(org-babel-eval-read-file tmp-file)))))
|
||||
(let* ((body (concat org-babel-perl-preface ibody))
|
||||
(tmp-file (org-babel-temp-file "perl-"))
|
||||
(tmp-babel-file (org-babel-process-file-name
|
||||
tmp-file 'noquote)))
|
||||
((lambda (results)
|
||||
(when results
|
||||
(org-babel-result-cond result-params
|
||||
(org-babel-eval-read-file tmp-file)
|
||||
(org-babel-import-elisp-from-file tmp-file '(16)))))
|
||||
(case result-type
|
||||
(output
|
||||
(with-temp-file tmp-file
|
||||
(insert
|
||||
(org-babel-eval org-babel-perl-command body))
|
||||
(buffer-string)))
|
||||
(value
|
||||
(org-babel-eval org-babel-perl-command
|
||||
(format org-babel-perl-wrapper-method
|
||||
body tmp-babel-file)))))))
|
||||
|
||||
(provide 'ob-perl)
|
||||
|
||||
|
@ -54,8 +54,6 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-eval)
|
||||
(require 'ob-comint)
|
||||
(require 'comint)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
@ -80,7 +78,7 @@
|
||||
:version "24.1"
|
||||
:type 'string)
|
||||
|
||||
(defun org-babel-expand-body:picolisp (body params &optional processed-params)
|
||||
(defun org-babel-expand-body:picolisp (body params)
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(let ((vars (mapcar #'cdr (org-babel-get-header params :var)))
|
||||
(result-params (cdr (assoc :result-params params)))
|
||||
@ -123,13 +121,8 @@
|
||||
(t full-body))))
|
||||
|
||||
((lambda (result)
|
||||
(if (or (member "verbatim" result-params)
|
||||
(member "scalar" result-params)
|
||||
(member "output" result-params)
|
||||
(member "code" result-params)
|
||||
(member "pp" result-params)
|
||||
(= (length result) 0))
|
||||
result
|
||||
(org-babel-result-cond result-params
|
||||
result
|
||||
(read result)))
|
||||
(if (not (string= session-name "none"))
|
||||
;; session based evaluation
|
||||
|
@ -35,7 +35,6 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-eval)
|
||||
|
||||
(defvar org-babel-default-header-args:plantuml
|
||||
'((:results . "file") (:exports . "results"))
|
||||
|
@ -28,30 +28,50 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-ref)
|
||||
(require 'ob-comint)
|
||||
(require 'ob-eval)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(declare-function org-remove-indentation "org" )
|
||||
(declare-function py-shell "ext:python-mode" (&optional argprompt))
|
||||
(declare-function py-toggle-shells "ext:python-mode" (arg))
|
||||
(declare-function run-python "ext:python" (&optional cmd noshow new))
|
||||
(declare-function run-python "ext:python" (cmd &optional dedicated show))
|
||||
|
||||
(defvar org-babel-tangle-lang-exts)
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("python" . "py"))
|
||||
|
||||
(defvar org-babel-default-header-args:python '())
|
||||
|
||||
(defvar org-babel-python-command "python"
|
||||
"Name of the command for executing Python code.")
|
||||
(defcustom org-babel-python-command "python"
|
||||
"Name of the command for executing Python code."
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:group 'org-babel
|
||||
:type 'string)
|
||||
|
||||
(defvar org-babel-python-mode (if (featurep 'xemacs) 'python-mode 'python)
|
||||
(defcustom org-babel-python-mode
|
||||
(if (or (featurep 'xemacs) (featurep 'python-mode)) 'python-mode 'python)
|
||||
"Preferred python mode for use in running python interactively.
|
||||
This will typically be either 'python or 'python-mode.")
|
||||
This will typically be either 'python or 'python-mode."
|
||||
:group 'org-babel
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:type 'function)
|
||||
|
||||
(defvar org-src-preserve-indentation)
|
||||
|
||||
(defcustom org-babel-python-hline-to "None"
|
||||
"Replace hlines in incoming tables with this when translating to python."
|
||||
:group 'org-babel
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-babel-python-None-to 'hline
|
||||
"Replace 'None' in python tables with this before returning."
|
||||
:group 'org-babel
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:type 'string)
|
||||
|
||||
(defun org-babel-execute:python (body params)
|
||||
"Execute a block of Python code with Babel.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
@ -114,7 +134,7 @@ specifying a variable of the same value."
|
||||
(if (listp var)
|
||||
(concat "[" (mapconcat #'org-babel-python-var-to-python var ", ") "]")
|
||||
(if (equal var 'hline)
|
||||
"None"
|
||||
org-babel-python-hline-to
|
||||
(format
|
||||
(if (and (stringp var) (string-match "[\n\r]" var)) "\"\"%S\"\"" "%S")
|
||||
var))))
|
||||
@ -123,14 +143,34 @@ specifying a variable of the same value."
|
||||
"Convert RESULTS into an appropriate elisp value.
|
||||
If the results look like a list or tuple, then convert them into an
|
||||
Emacs-lisp table, otherwise return the results as a string."
|
||||
(org-babel-script-escape results))
|
||||
((lambda (res)
|
||||
(if (listp res)
|
||||
(mapcar (lambda (el) (if (equal el 'None)
|
||||
org-babel-python-None-to el))
|
||||
res)
|
||||
res))
|
||||
(org-babel-script-escape results)))
|
||||
|
||||
(defvar org-babel-python-buffers '((:default . nil)))
|
||||
(defvar org-babel-python-buffers '((:default . "*Python*")))
|
||||
|
||||
(defun org-babel-python-session-buffer (session)
|
||||
"Return the buffer associated with SESSION."
|
||||
(cdr (assoc session org-babel-python-buffers)))
|
||||
|
||||
(defun org-babel-python-with-earmufs (session)
|
||||
(let ((name (if (stringp session) session (format "%s" session))))
|
||||
(if (and (string= "*" (substring name 0 1))
|
||||
(string= "*" (substring name (- (length name) 1))))
|
||||
name
|
||||
(format "*%s*" name))))
|
||||
|
||||
(defun org-babel-python-without-earmufs (session)
|
||||
(let ((name (if (stringp session) session (format "%s" session))))
|
||||
(if (and (string= "*" (substring name 0 1))
|
||||
(string= "*" (substring name (- (length name) 1))))
|
||||
(substring name 1 (- (length name) 1))
|
||||
name)))
|
||||
|
||||
(defvar py-default-interpreter)
|
||||
(defun org-babel-python-initiate-session-by-key (&optional session)
|
||||
"Initiate a python session.
|
||||
@ -139,13 +179,20 @@ then create. Return the initialized session."
|
||||
(require org-babel-python-mode)
|
||||
(save-window-excursion
|
||||
(let* ((session (if session (intern session) :default))
|
||||
(python-buffer (org-babel-python-session-buffer session)))
|
||||
(python-buffer (org-babel-python-session-buffer session))
|
||||
(cmd (if (member system-type '(cygwin windows-nt ms-dos))
|
||||
(concat org-babel-python-command " -i")
|
||||
org-babel-python-command)))
|
||||
(cond
|
||||
((and (eq 'python org-babel-python-mode)
|
||||
(fboundp 'run-python)) ; python.el
|
||||
(if (version< "24.1" emacs-version)
|
||||
(run-python org-babel-python-command)
|
||||
(run-python)))
|
||||
(if (not (version< "24.1" emacs-version))
|
||||
(run-python cmd)
|
||||
(unless python-buffer
|
||||
(setq python-buffer (org-babel-python-with-earmufs session)))
|
||||
(let ((python-shell-buffer-name
|
||||
(org-babel-python-without-earmufs python-buffer)))
|
||||
(run-python cmd))))
|
||||
((and (eq 'python-mode org-babel-python-mode)
|
||||
(fboundp 'py-shell)) ; python-mode.el
|
||||
;; Make sure that py-which-bufname is initialized, as otherwise
|
||||
@ -160,7 +207,7 @@ then create. Return the initialized session."
|
||||
(concat "Python-" (symbol-name session))))
|
||||
(py-which-bufname bufname))
|
||||
(py-shell)
|
||||
(setq python-buffer (concat "*" bufname "*"))))
|
||||
(setq python-buffer (org-babel-python-with-earmufs bufname))))
|
||||
(t
|
||||
(error "No function available for running an inferior Python")))
|
||||
(setq org-babel-python-buffers
|
||||
@ -206,11 +253,8 @@ If RESULT-TYPE equals 'output then return standard output as a
|
||||
string. If RESULT-TYPE equals 'value then return the value of the
|
||||
last statement in BODY, as elisp."
|
||||
((lambda (raw)
|
||||
(if (or (member "code" result-params)
|
||||
(member "pp" result-params)
|
||||
(and (member "output" result-params)
|
||||
(not (member "table" result-params))))
|
||||
raw
|
||||
(org-babel-result-cond result-params
|
||||
raw
|
||||
(org-babel-python-table-or-string (org-babel-trim raw))))
|
||||
(case result-type
|
||||
(output (org-babel-eval org-babel-python-command
|
||||
@ -259,11 +303,8 @@ last statement in BODY, as elisp."
|
||||
(funcall send-wait))))
|
||||
((lambda (results)
|
||||
(unless (string= (substring org-babel-python-eoe-indicator 1 -1) results)
|
||||
(if (or (member "code" result-params)
|
||||
(member "pp" result-params)
|
||||
(and (member "output" result-params)
|
||||
(not (member "table" result-params))))
|
||||
results
|
||||
(org-babel-result-cond result-params
|
||||
results
|
||||
(org-babel-python-table-or-string results))))
|
||||
(case result-type
|
||||
(output
|
||||
|
@ -40,7 +40,7 @@
|
||||
;; So an example of a simple src block referencing table data in the
|
||||
;; same file would be
|
||||
|
||||
;; #+TBLNAME: sandbox
|
||||
;; #+NAME: sandbox
|
||||
;; | 1 | 2 | 3 |
|
||||
;; | 4 | org-babel | 6 |
|
||||
;;
|
||||
@ -49,7 +49,7 @@
|
||||
;; #+end_src
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-core)
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
|
||||
@ -83,7 +83,10 @@ the variable."
|
||||
(let ((var (match-string 1 assignment))
|
||||
(ref (match-string 2 assignment)))
|
||||
(cons (intern var)
|
||||
(let ((out (org-babel-read ref)))
|
||||
(let ((out (save-excursion
|
||||
(when org-babel-current-src-block-location
|
||||
(goto-char org-babel-current-src-block-location))
|
||||
(org-babel-read ref))))
|
||||
(if (equal out ref)
|
||||
(if (string-match "^\".*\"$" ref)
|
||||
(read ref)
|
||||
|
@ -37,9 +37,6 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-ref)
|
||||
(require 'ob-comint)
|
||||
(require 'ob-eval)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(declare-function run-ruby "ext:inf-ruby" (&optional command name))
|
||||
@ -53,6 +50,22 @@
|
||||
(defvar org-babel-ruby-command "ruby"
|
||||
"Name of command to use for executing ruby code.")
|
||||
|
||||
(defcustom org-babel-ruby-hline-to "nil"
|
||||
"Replace hlines in incoming tables with this when translating to ruby."
|
||||
:group 'org-babel
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-babel-ruby-nil-to 'hline
|
||||
"Replace 'nil' in ruby tables with this before returning."
|
||||
:group 'org-babel
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:type 'string)
|
||||
|
||||
|
||||
|
||||
(defun org-babel-execute:ruby (body params)
|
||||
"Execute a block of Ruby code with Babel.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
@ -71,7 +84,9 @@ This function is called by `org-babel-execute-src-block'."
|
||||
(org-babel-ruby-evaluate
|
||||
session full-body result-type result-params))))
|
||||
(org-babel-reassemble-table
|
||||
result
|
||||
(org-babel-result-cond result-params
|
||||
result
|
||||
(org-babel-ruby-table-or-string result))
|
||||
(org-babel-pick-name (cdr (assoc :colname-names params))
|
||||
(cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name (cdr (assoc :rowname-names params))
|
||||
@ -116,13 +131,21 @@ Convert an elisp value into a string of ruby source code
|
||||
specifying a variable of the same value."
|
||||
(if (listp var)
|
||||
(concat "[" (mapconcat #'org-babel-ruby-var-to-ruby var ", ") "]")
|
||||
(format "%S" var)))
|
||||
(if (equal var 'hline)
|
||||
org-babel-ruby-hline-to
|
||||
(format "%S" var))))
|
||||
|
||||
(defun org-babel-ruby-table-or-string (results)
|
||||
"Convert RESULTS into an appropriate elisp value.
|
||||
If RESULTS look like a table, then convert them into an
|
||||
Emacs-lisp table, otherwise return the results as a string."
|
||||
(org-babel-script-escape results))
|
||||
((lambda (res)
|
||||
(if (listp res)
|
||||
(mapcar (lambda (el) (if (equal el 'nil)
|
||||
org-babel-ruby-nil-to el))
|
||||
res)
|
||||
res))
|
||||
(org-babel-script-escape results)))
|
||||
|
||||
(defun org-babel-ruby-initiate-session (&optional session params)
|
||||
"Initiate a ruby session.
|
||||
@ -206,31 +229,27 @@ return the value of the last statement in BODY, as elisp."
|
||||
(comint-send-input nil t)) 2)
|
||||
"\n") "[\r\n]")) "\n"))
|
||||
(value
|
||||
((lambda (results)
|
||||
(if (or (member "code" result-params) (member "pp" result-params))
|
||||
results
|
||||
(org-babel-ruby-table-or-string results)))
|
||||
(let* ((tmp-file (org-babel-temp-file "ruby-"))
|
||||
(ppp (or (member "code" result-params)
|
||||
(member "pp" result-params))))
|
||||
(org-babel-comint-with-output
|
||||
(buffer org-babel-ruby-eoe-indicator t body)
|
||||
(when ppp (insert "require 'pp';") (comint-send-input nil t))
|
||||
(mapc
|
||||
(lambda (line)
|
||||
(insert (org-babel-chomp line)) (comint-send-input nil t))
|
||||
(append
|
||||
(list body)
|
||||
(if (not ppp)
|
||||
(list (format org-babel-ruby-f-write
|
||||
(org-babel-process-file-name tmp-file 'noquote)))
|
||||
(list
|
||||
"results=_" "require 'pp'" "orig_out = $stdout"
|
||||
(format org-babel-ruby-pp-f-write
|
||||
(org-babel-process-file-name tmp-file 'noquote))))
|
||||
(list org-babel-ruby-eoe-indicator)))
|
||||
(comint-send-input nil t))
|
||||
(org-babel-eval-read-file tmp-file)))))))
|
||||
(let* ((tmp-file (org-babel-temp-file "ruby-"))
|
||||
(ppp (or (member "code" result-params)
|
||||
(member "pp" result-params))))
|
||||
(org-babel-comint-with-output
|
||||
(buffer org-babel-ruby-eoe-indicator t body)
|
||||
(when ppp (insert "require 'pp';") (comint-send-input nil t))
|
||||
(mapc
|
||||
(lambda (line)
|
||||
(insert (org-babel-chomp line)) (comint-send-input nil t))
|
||||
(append
|
||||
(list body)
|
||||
(if (not ppp)
|
||||
(list (format org-babel-ruby-f-write
|
||||
(org-babel-process-file-name tmp-file 'noquote)))
|
||||
(list
|
||||
"results=_" "require 'pp'" "orig_out = $stdout"
|
||||
(format org-babel-ruby-pp-f-write
|
||||
(org-babel-process-file-name tmp-file 'noquote))))
|
||||
(list org-babel-ruby-eoe-indicator)))
|
||||
(comint-send-input nil t))
|
||||
(org-babel-eval-read-file tmp-file))))))
|
||||
|
||||
(defun org-babel-ruby-read-string (string)
|
||||
"Strip \\\"s from around a ruby string."
|
||||
|
@ -39,7 +39,6 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-eval)
|
||||
|
||||
(defvar org-babel-default-header-args:sass '())
|
||||
|
||||
|
@ -31,9 +31,6 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-ref)
|
||||
(require 'ob-comint)
|
||||
(require 'ob-eval)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(defvar org-babel-tangle-lang-exts) ;; Autoloaded
|
||||
@ -104,8 +101,8 @@ in BODY as elisp."
|
||||
(wrapper (format org-babel-scala-wrapper-method body)))
|
||||
(with-temp-file src-file (insert wrapper))
|
||||
((lambda (raw)
|
||||
(if (member "code" result-params)
|
||||
raw
|
||||
(org-babel-result-cond result-params
|
||||
raw
|
||||
(org-babel-scala-table-or-string raw)))
|
||||
(org-babel-eval
|
||||
(concat org-babel-scala-command " " src-file) ""))))))
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
;; Copyright (C) 2010-2013 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Authors: Eric Schulte, Michael Gauland
|
||||
;; Keywords: literate programming, reproducible research, scheme
|
||||
;; Homepage: http://orgmode.org
|
||||
|
||||
@ -33,30 +33,25 @@
|
||||
;; - a working scheme implementation
|
||||
;; (e.g. guile http://www.gnu.org/software/guile/guile.html)
|
||||
;;
|
||||
;; - for session based evaluation cmuscheme.el is required which is
|
||||
;; included in Emacs
|
||||
;; - for session based evaluation geiser is required, which is available from
|
||||
;; ELPA.
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-ref)
|
||||
(require 'ob-comint)
|
||||
(require 'ob-eval)
|
||||
(eval-when-compile (require 'cl))
|
||||
(require 'geiser nil t)
|
||||
(defvar geiser-repl--repl) ; Defined in geiser-repl.el
|
||||
(defvar geiser-impl--implementation) ; Defined in geiser-impl.el
|
||||
(defvar geiser-default-implementation) ; Defined in geiser-impl.el
|
||||
(defvar geiser-active-implementations) ; Defined in geiser-impl.el
|
||||
|
||||
(declare-function run-scheme "ext:cmuscheme" (cmd))
|
||||
(declare-function run-geiser "geiser-repl" (impl))
|
||||
(declare-function geiser-mode "geiser-mode" ())
|
||||
(declare-function geiser-eval-region "geiser-mode" (start end &optional and-go raw nomsg))
|
||||
(declare-function geiser-repl-exit "geiser-repl" (&optional arg))
|
||||
|
||||
(defvar org-babel-default-header-args:scheme '()
|
||||
"Default header arguments for scheme code blocks.")
|
||||
|
||||
(defvar org-babel-scheme-eoe "org-babel-scheme-eoe"
|
||||
"String to indicate that evaluation has completed.")
|
||||
|
||||
(defcustom org-babel-scheme-cmd "guile"
|
||||
"Name of command used to evaluate scheme blocks."
|
||||
:group 'org-babel
|
||||
:version "24.1"
|
||||
:type 'string)
|
||||
|
||||
(defun org-babel-expand-body:scheme (body params)
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
|
||||
@ -68,70 +63,127 @@
|
||||
")\n" body ")")
|
||||
body)))
|
||||
|
||||
(defvar scheme-program-name)
|
||||
|
||||
(defvar org-babel-scheme-repl-map (make-hash-table :test 'equal)
|
||||
"Map of scheme sessions to session names.")
|
||||
|
||||
(defun org-babel-scheme-cleanse-repl-map ()
|
||||
"Remove dead buffers from the REPL map."
|
||||
(maphash
|
||||
(lambda (x y)
|
||||
(when (not (buffer-name y))
|
||||
(remhash x org-babel-scheme-repl-map)))
|
||||
org-babel-scheme-repl-map))
|
||||
|
||||
(defun org-babel-scheme-get-session-buffer (session-name)
|
||||
"Look up the scheme buffer for a session; return nil if it doesn't exist."
|
||||
(org-babel-scheme-cleanse-repl-map) ; Prune dead sessions
|
||||
(gethash session-name org-babel-scheme-repl-map))
|
||||
|
||||
(defun org-babel-scheme-set-session-buffer (session-name buffer)
|
||||
"Record the scheme buffer used for a given session."
|
||||
(puthash session-name buffer org-babel-scheme-repl-map))
|
||||
|
||||
(defun org-babel-scheme-get-buffer-impl (buffer)
|
||||
"Returns the scheme implementation geiser associates with the buffer."
|
||||
(with-current-buffer (set-buffer buffer)
|
||||
geiser-impl--implementation))
|
||||
|
||||
(defun org-babel-scheme-get-repl (impl name)
|
||||
"Switch to a scheme REPL, creating it if it doesn't exist:"
|
||||
(let ((buffer (org-babel-scheme-get-session-buffer name)))
|
||||
(or buffer
|
||||
(progn
|
||||
(run-geiser impl)
|
||||
(if name
|
||||
(progn
|
||||
(rename-buffer name t)
|
||||
(org-babel-scheme-set-session-buffer name (current-buffer))))
|
||||
(current-buffer)))))
|
||||
|
||||
(defun org-babel-scheme-make-session-name (buffer name impl)
|
||||
"Generate a name for the session buffer.
|
||||
|
||||
For a named session, the buffer name will be the session name.
|
||||
|
||||
If the session is unnamed (nil), generate a name.
|
||||
|
||||
If the session is 'none', use nil for the session name, and
|
||||
org-babel-scheme-execute-with-geiser will use a temporary session."
|
||||
(let ((result
|
||||
(cond ((not name)
|
||||
(concat buffer " " (symbol-name impl) " REPL"))
|
||||
((string= name "none") nil)
|
||||
(name))))
|
||||
result))
|
||||
|
||||
(defun org-babel-scheme-execute-with-geiser (code output impl repl)
|
||||
"Execute code in specified REPL. If the REPL doesn't exist, create it
|
||||
using the given scheme implementation.
|
||||
|
||||
Returns the output of executing the code if the output parameter
|
||||
is true; otherwise returns the last value."
|
||||
(let ((result nil))
|
||||
(with-temp-buffer
|
||||
(insert (format ";; -*- geiser-scheme-implementation: %s -*-" impl))
|
||||
(newline)
|
||||
(insert (if output
|
||||
(format "(with-output-to-string (lambda () %s))" code)
|
||||
code))
|
||||
(geiser-mode)
|
||||
(let ((repl-buffer (save-current-buffer
|
||||
(org-babel-scheme-get-repl impl repl))))
|
||||
(when (not (eq impl (org-babel-scheme-get-buffer-impl
|
||||
(current-buffer))))
|
||||
(message "Implementation mismatch: %s (%s) %s (%s)" impl (symbolp impl)
|
||||
(org-babel-scheme-get-buffer-impl (current-buffer))
|
||||
(symbolp (org-babel-scheme-get-buffer-impl
|
||||
(current-buffer)))))
|
||||
(setq geiser-repl--repl repl-buffer)
|
||||
(setq geiser-impl--implementation nil)
|
||||
(geiser-eval-region (point-min) (point-max))
|
||||
(setq result
|
||||
(if (equal (substring (current-message) 0 3) "=> ")
|
||||
(replace-regexp-in-string "^=> " "" (current-message))
|
||||
"\"An error occurred.\""))
|
||||
(when (not repl)
|
||||
(save-current-buffer (set-buffer repl-buffer)
|
||||
(geiser-repl-exit))
|
||||
(set-process-query-on-exit-flag (get-buffer-process repl-buffer) nil)
|
||||
(kill-buffer repl-buffer))
|
||||
(setq result (if (or (string= result "#<void>")
|
||||
(string= result "#<unspecified>"))
|
||||
nil
|
||||
(read result)))))
|
||||
result))
|
||||
|
||||
(defun org-babel-execute:scheme (body params)
|
||||
"Execute a block of Scheme code with org-babel.
|
||||
This function is called by `org-babel-execute-src-block'"
|
||||
(let* ((result-type (cdr (assoc :result-type params)))
|
||||
(org-babel-scheme-cmd (or (cdr (assoc :scheme params))
|
||||
org-babel-scheme-cmd))
|
||||
(full-body (org-babel-expand-body:scheme body params)))
|
||||
(read
|
||||
(if (not (string= (cdr (assoc :session params)) "none"))
|
||||
;; session evaluation
|
||||
(let ((session (org-babel-prep-session:scheme
|
||||
(cdr (assoc :session params)) params)))
|
||||
(org-babel-comint-with-output
|
||||
(session (format "%S" org-babel-scheme-eoe) t body)
|
||||
(mapc
|
||||
(lambda (line)
|
||||
(insert (org-babel-chomp line)) (comint-send-input nil t))
|
||||
(list body (format "%S" org-babel-scheme-eoe)))))
|
||||
;; external evaluation
|
||||
(let ((script-file (org-babel-temp-file "scheme-script-")))
|
||||
(with-temp-file script-file
|
||||
(insert
|
||||
;; return the value or the output
|
||||
(if (string= result-type "value")
|
||||
(format "(display %s)" full-body)
|
||||
full-body)))
|
||||
(org-babel-eval
|
||||
(format "%s %s" org-babel-scheme-cmd
|
||||
(org-babel-process-file-name script-file)) ""))))))
|
||||
|
||||
(defun org-babel-prep-session:scheme (session params)
|
||||
"Prepare SESSION according to the header arguments specified in PARAMS."
|
||||
(let* ((session (org-babel-scheme-initiate-session session))
|
||||
(vars (mapcar #'cdr (org-babel-get-header params :var)))
|
||||
(var-lines
|
||||
(mapcar
|
||||
(lambda (var) (format "%S" (print `(define ,(car var) ',(cdr var)))))
|
||||
vars)))
|
||||
(when session
|
||||
(org-babel-comint-in-buffer session
|
||||
(sit-for .5) (goto-char (point-max))
|
||||
(mapc (lambda (var)
|
||||
(insert var) (comint-send-input nil t)
|
||||
(org-babel-comint-wait-for-output session)
|
||||
(sit-for .1) (goto-char (point-max))) var-lines)))
|
||||
session))
|
||||
|
||||
(defun org-babel-scheme-initiate-session (&optional session)
|
||||
"If there is not a current inferior-process-buffer in SESSION
|
||||
then create. Return the initialized session."
|
||||
(require 'cmuscheme)
|
||||
(unless (string= session "none")
|
||||
(let ((session-buffer (save-window-excursion
|
||||
(run-scheme org-babel-scheme-cmd)
|
||||
(rename-buffer session)
|
||||
(current-buffer))))
|
||||
(if (org-babel-comint-buffer-livep session-buffer)
|
||||
(progn (sit-for .25) session-buffer)
|
||||
(sit-for .5)
|
||||
(org-babel-scheme-initiate-session session)))))
|
||||
(let* ((source-buffer (current-buffer))
|
||||
(source-buffer-name (replace-regexp-in-string ;; zap surrounding *
|
||||
"^ ?\\*\\([^*]+\\)\\*" "\\1"
|
||||
(buffer-name source-buffer))))
|
||||
(save-excursion
|
||||
(org-babel-reassemble-table
|
||||
(let* ((result-type (cdr (assoc :result-type params)))
|
||||
(impl (or (when (cdr (assoc :scheme params))
|
||||
(intern (cdr (assoc :scheme params))))
|
||||
geiser-default-implementation
|
||||
(car geiser-active-implementations)))
|
||||
(session (org-babel-scheme-make-session-name
|
||||
source-buffer-name (cdr (assoc :session params)) impl))
|
||||
(full-body (org-babel-expand-body:scheme body params)))
|
||||
(org-babel-scheme-execute-with-geiser
|
||||
full-body ; code
|
||||
(string= result-type "output") ; output?
|
||||
impl ; implementation
|
||||
(and (not (string= session "none")) session))) ; session
|
||||
(org-babel-pick-name (cdr (assoc :colname-names params))
|
||||
(cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name (cdr (assoc :rowname-names params))
|
||||
(cdr (assoc :rownames params)))))))
|
||||
|
||||
(provide 'ob-scheme)
|
||||
|
||||
|
||||
|
||||
;;; ob-scheme.el ends here
|
||||
|
@ -34,7 +34,6 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-ref)
|
||||
|
||||
(defvar org-babel-screen-location "screen"
|
||||
"The command location for screen.
|
||||
|
@ -27,9 +27,6 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-ref)
|
||||
(require 'ob-comint)
|
||||
(require 'ob-eval)
|
||||
(require 'shell)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
@ -109,7 +106,7 @@ var of the same value."
|
||||
"Convert an elisp value to a string."
|
||||
(let ((echo-var (lambda (v) (if (stringp v) v (format "%S" v)))))
|
||||
(cond
|
||||
((and (listp var) (listp (car var)))
|
||||
((and (listp var) (or (listp (car var)) (equal (car var) 'hline)))
|
||||
(orgtbl-to-generic var (list :sep (or sep "\t") :fmt echo-var)))
|
||||
((listp var)
|
||||
(mapconcat echo-var var "\n"))
|
||||
@ -141,10 +138,8 @@ return the value of the last statement in BODY."
|
||||
((lambda (results)
|
||||
(when results
|
||||
(let ((result-params (cdr (assoc :result-params params))))
|
||||
(if (or (member "scalar" result-params)
|
||||
(member "verbatim" result-params)
|
||||
(member "output" result-params))
|
||||
results
|
||||
(org-babel-result-cond result-params
|
||||
results
|
||||
(let ((tmp-file (org-babel-temp-file "sh-")))
|
||||
(with-temp-file tmp-file (insert results))
|
||||
(org-babel-import-elisp-from-file tmp-file))))))
|
||||
|
@ -36,6 +36,7 @@
|
||||
(require 'ob)
|
||||
|
||||
(declare-function shen-eval-defun "ext:inf-shen" (&optional and-go))
|
||||
(declare-function org-babel-ruby-var-to-ruby "ob-ruby" (var))
|
||||
|
||||
(defvar org-babel-default-header-args:shen '()
|
||||
"Default header arguments for shen code blocks.")
|
||||
@ -66,9 +67,8 @@ This function is called by `org-babel-execute-src-block'"
|
||||
(result-params (cdr (assoc :result-params params)))
|
||||
(full-body (org-babel-expand-body:shen body params)))
|
||||
((lambda (results)
|
||||
(if (or (member 'scalar result-params)
|
||||
(member 'verbatim result-params))
|
||||
results
|
||||
(org-babel-result-cond result-params
|
||||
results
|
||||
(condition-case nil (org-babel-script-escape results)
|
||||
(error results))))
|
||||
(with-temp-buffer
|
||||
|
@ -32,12 +32,24 @@
|
||||
;;
|
||||
;; Also SQL evaluation generally takes place inside of a database.
|
||||
;;
|
||||
;; For now lets just allow a generic ':cmdline' header argument.
|
||||
;; Header args used:
|
||||
;; - engine
|
||||
;; - cmdline
|
||||
;; - dbhost
|
||||
;; - dbuser
|
||||
;; - dbpassword
|
||||
;; - database
|
||||
;; - colnames (default, nil, means "yes")
|
||||
;; - result-params
|
||||
;; - out-file
|
||||
;; The following are used but not really implemented for SQL:
|
||||
;; - colname-names
|
||||
;; - rownames
|
||||
;; - rowname-names
|
||||
;;
|
||||
;; TODO:
|
||||
;;
|
||||
;; - support for sessions
|
||||
;; - add more useful header arguments (user, passwd, database, etc...)
|
||||
;; - support for more engines (currently only supports mysql)
|
||||
;; - what's a reasonable way to drop table data into SQL?
|
||||
;;
|
||||
@ -52,30 +64,49 @@
|
||||
|
||||
(defvar org-babel-default-header-args:sql '())
|
||||
|
||||
(defvar org-babel-header-args:sql
|
||||
'((engine . :any)
|
||||
(out-file . :any)))
|
||||
(defconst org-babel-header-args:sql
|
||||
'((engine . :any)
|
||||
(out-file . :any)
|
||||
(dbhost . :any)
|
||||
(dbuser . :any)
|
||||
(dbpassword . :any)
|
||||
(database . :any))
|
||||
"SQL-specific header arguments.")
|
||||
|
||||
(defun org-babel-expand-body:sql (body params)
|
||||
"Expand BODY according to the values of PARAMS."
|
||||
(org-babel-sql-expand-vars
|
||||
body (mapcar #'cdr (org-babel-get-header params :var))))
|
||||
|
||||
(defun dbstring-mysql (host user password database)
|
||||
"Make MySQL cmd line args for database connection. Pass nil to omit that arg."
|
||||
(combine-and-quote-strings
|
||||
(remq nil
|
||||
(list (when host (concat "-h" host))
|
||||
(when user (concat "-u" user))
|
||||
(when password (concat "-p" password))
|
||||
(when database (concat "-D" database))))))
|
||||
|
||||
(defun org-babel-execute:sql (body params)
|
||||
"Execute a block of Sql code with Babel.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
(let* ((result-params (cdr (assoc :result-params params)))
|
||||
(cmdline (cdr (assoc :cmdline params)))
|
||||
(dbhost (cdr (assoc :dbhost params)))
|
||||
(dbuser (cdr (assoc :dbuser params)))
|
||||
(dbpassword (cdr (assoc :dbpassword params)))
|
||||
(database (cdr (assoc :database params)))
|
||||
(engine (cdr (assoc :engine params)))
|
||||
(colnames-p (not (equal "no" (cdr (assoc :colnames params)))))
|
||||
(in-file (org-babel-temp-file "sql-in-"))
|
||||
(out-file (or (cdr (assoc :out-file params))
|
||||
(org-babel-temp-file "sql-out-")))
|
||||
(header-delim "")
|
||||
(command (case (intern engine)
|
||||
('dbi (format "dbish --batch '%s' < %s | sed '%s' > %s"
|
||||
('dbi (format "dbish --batch %s < %s | sed '%s' > %s"
|
||||
(or cmdline "")
|
||||
(org-babel-process-file-name in-file)
|
||||
"/^+/d;s/^\|//;$d"
|
||||
"/^+/d;s/^\|//;s/(NULL)/ /g;$d"
|
||||
(org-babel-process-file-name out-file)))
|
||||
('monetdb (format "mclient -f tab %s < %s > %s"
|
||||
(or cmdline "")
|
||||
@ -85,7 +116,9 @@ This function is called by `org-babel-execute-src-block'."
|
||||
(or cmdline "")
|
||||
(org-babel-process-file-name in-file)
|
||||
(org-babel-process-file-name out-file)))
|
||||
('mysql (format "mysql %s < %s > %s"
|
||||
('mysql (format "mysql %s %s %s < %s > %s"
|
||||
(dbstring-mysql dbhost dbuser dbpassword database)
|
||||
(if colnames-p "" "-N")
|
||||
(or cmdline "")
|
||||
(org-babel-process-file-name in-file)
|
||||
(org-babel-process-file-name out-file)))
|
||||
@ -102,28 +135,39 @@ This function is called by `org-babel-execute-src-block'."
|
||||
(t ""))
|
||||
(org-babel-expand-body:sql body params)))
|
||||
(message command)
|
||||
(shell-command command)
|
||||
(if (or (member "scalar" result-params)
|
||||
(member "verbatim" result-params)
|
||||
(member "html" result-params)
|
||||
(member "code" result-params)
|
||||
(equal (point-min) (point-max)))
|
||||
(with-temp-buffer
|
||||
(org-babel-eval command "")
|
||||
(org-babel-result-cond result-params
|
||||
(with-temp-buffer
|
||||
(progn (insert-file-contents-literally out-file) (buffer-string)))
|
||||
(with-temp-buffer
|
||||
;; need to figure out what the delimiter is for the header row
|
||||
(with-temp-buffer
|
||||
(insert-file-contents out-file)
|
||||
(goto-char (point-min))
|
||||
(when (re-search-forward "^\\(-+\\)[^-]" nil t)
|
||||
(setq header-delim (match-string-no-properties 1)))
|
||||
(goto-char (point-max))
|
||||
(forward-char -1)
|
||||
(while (looking-at "\n")
|
||||
(delete-char 1)
|
||||
(goto-char (point-max))
|
||||
(forward-char -1))
|
||||
(write-file out-file))
|
||||
(cond
|
||||
((or (eq (intern engine) 'mysql)
|
||||
(eq (intern engine) 'dbi)
|
||||
(eq (intern engine) 'postgresql))
|
||||
;; Add header row delimiter after column-names header in first line
|
||||
(cond
|
||||
(colnames-p
|
||||
(with-temp-buffer
|
||||
(insert-file-contents out-file)
|
||||
(goto-char (point-min))
|
||||
(forward-line 1)
|
||||
(insert "-\n")
|
||||
(setq header-delim "-")
|
||||
(write-file out-file)))))
|
||||
(t
|
||||
;; Need to figure out the delimiter for the header row
|
||||
(with-temp-buffer
|
||||
(insert-file-contents out-file)
|
||||
(goto-char (point-min))
|
||||
(when (re-search-forward "^\\(-+\\)[^-]" nil t)
|
||||
(setq header-delim (match-string-no-properties 1)))
|
||||
(goto-char (point-max))
|
||||
(forward-char -1)
|
||||
(while (looking-at "\n")
|
||||
(delete-char 1)
|
||||
(goto-char (point-max))
|
||||
(forward-char -1))
|
||||
(write-file out-file))))
|
||||
(org-table-import out-file '(16))
|
||||
(org-babel-reassemble-table
|
||||
(mapcar (lambda (x)
|
||||
|
@ -27,8 +27,6 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-eval)
|
||||
(require 'ob-ref)
|
||||
|
||||
(declare-function org-fill-template "org" (template alist))
|
||||
(declare-function org-table-convert-region "org-table"
|
||||
@ -98,23 +96,21 @@ This function is called by `org-babel-execute-src-block'."
|
||||
(cons "db " db)))
|
||||
;; body of the code block
|
||||
(org-babel-expand-body:sqlite body params)))
|
||||
(if (or (member "scalar" result-params)
|
||||
(member "verbatim" result-params)
|
||||
(member "html" result-params)
|
||||
(member "code" result-params)
|
||||
(equal (point-min) (point-max)))
|
||||
(buffer-string)
|
||||
(org-table-convert-region (point-min) (point-max)
|
||||
(if (or (member :csv others)
|
||||
(member :column others)
|
||||
(member :line others)
|
||||
(member :list others)
|
||||
(member :html others) separator)
|
||||
nil
|
||||
'(4)))
|
||||
(org-babel-sqlite-table-or-scalar
|
||||
(org-babel-sqlite-offset-colnames
|
||||
(org-table-to-lisp) headers-p))))))
|
||||
(org-babel-result-cond result-params
|
||||
(buffer-string)
|
||||
(if (equal (point-min) (point-max))
|
||||
""
|
||||
(org-table-convert-region (point-min) (point-max)
|
||||
(if (or (member :csv others)
|
||||
(member :column others)
|
||||
(member :line others)
|
||||
(member :list others)
|
||||
(member :html others) separator)
|
||||
nil
|
||||
'(4)))
|
||||
(org-babel-sqlite-table-or-scalar
|
||||
(org-babel-sqlite-offset-colnames
|
||||
(org-table-to-lisp) headers-p)))))))
|
||||
|
||||
(defun org-babel-sqlite-expand-vars (body vars)
|
||||
"Expand the variables held in VARS in BODY."
|
||||
@ -147,7 +143,7 @@ This function is called by `org-babel-execute-src-block'."
|
||||
(mapcar (lambda (row)
|
||||
(if (equal 'hline row)
|
||||
'hline
|
||||
(mapcar #'org-babel-read row))) result)))
|
||||
(mapcar #'org-babel-string-read row))) result)))
|
||||
|
||||
(defun org-babel-sqlite-offset-colnames (table headers-p)
|
||||
"If HEADERS-P is non-nil then offset the first row as column names."
|
||||
|
@ -50,7 +50,7 @@
|
||||
;; #+TBLFM: $2='(sbe 'fibbd (n $1))
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-core)
|
||||
|
||||
(defun org-babel-table-truncate-at-newline (string)
|
||||
"Replace newline character with ellipses.
|
||||
@ -97,9 +97,11 @@ as shown in the example below.
|
||||
(lambda (el)
|
||||
(if (eq '$ el)
|
||||
(prog1 nil (setq quote t))
|
||||
(prog1 (if quote
|
||||
(format "\"%s\"" el)
|
||||
(org-no-properties el))
|
||||
(prog1
|
||||
(cond
|
||||
(quote (format "\"%s\"" el))
|
||||
((stringp el) (org-no-properties el))
|
||||
(t el))
|
||||
(setq quote nil))))
|
||||
(cdr var)))))
|
||||
variables)))
|
||||
|
@ -26,12 +26,14 @@
|
||||
;; Extract the code from source blocks out into raw source-code files.
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'org-src)
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
|
||||
(declare-function org-edit-special "org" (&optional arg))
|
||||
(declare-function org-link-escape "org" (text &optional table))
|
||||
(declare-function org-store-link "org" (arg))
|
||||
(declare-function org-open-link-from-string "org" (s &optional arg reference-buffer))
|
||||
(declare-function org-heading-components "org" ())
|
||||
(declare-function org-back-to-heading "org" (invisible-ok))
|
||||
(declare-function org-fill-template "org" (template alist))
|
||||
@ -112,7 +114,7 @@ result. The default value is `org-babel-trim'."
|
||||
(defun org-babel-find-file-noselect-refresh (file)
|
||||
"Find file ensuring that the latest changes on disk are
|
||||
represented in the file."
|
||||
(find-file-noselect file)
|
||||
(find-file-noselect file 'nowarn)
|
||||
(with-current-buffer (get-file-buffer file)
|
||||
(revert-buffer t t t)))
|
||||
|
||||
@ -136,69 +138,49 @@ evaluating BODY."
|
||||
,temp-result)))
|
||||
(def-edebug-spec org-babel-with-temp-filebuffer (form body))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-babel-load-file (file)
|
||||
"Load Emacs Lisp source code blocks in the Org-mode FILE.
|
||||
This function exports the source code using
|
||||
`org-babel-tangle' and then loads the resulting file using
|
||||
`load-file'."
|
||||
(interactive "fFile to load: ")
|
||||
(let* ((age (lambda (file)
|
||||
(float-time
|
||||
(time-subtract (current-time)
|
||||
(nth 5 (or (file-attributes (file-truename file))
|
||||
(file-attributes file)))))))
|
||||
(base-name (file-name-sans-extension file))
|
||||
(exported-file (concat base-name ".el")))
|
||||
;; tangle if the org-mode file is newer than the elisp file
|
||||
(unless (and (file-exists-p exported-file)
|
||||
(> (funcall age file) (funcall age exported-file)))
|
||||
(org-babel-tangle-file file exported-file "emacs-lisp"))
|
||||
(load-file exported-file)
|
||||
(message "Loaded %s" exported-file)))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-babel-tangle-file (file &optional target-file lang)
|
||||
"Extract the bodies of source code blocks in FILE.
|
||||
Source code blocks are extracted with `org-babel-tangle'.
|
||||
Optional argument TARGET-FILE can be used to specify a default
|
||||
export file for all source blocks. Optional argument LANG can be
|
||||
used to limit the exported source code blocks by language."
|
||||
used to limit the exported source code blocks by language.
|
||||
Return a list whose CAR is the tangled file name."
|
||||
(interactive "fFile to tangle: \nP")
|
||||
(let ((visited-p (get-file-buffer (expand-file-name file)))
|
||||
to-be-removed)
|
||||
(save-window-excursion
|
||||
(find-file file)
|
||||
(setq to-be-removed (current-buffer))
|
||||
(org-babel-tangle nil target-file lang))
|
||||
(unless visited-p
|
||||
(kill-buffer to-be-removed))))
|
||||
(prog1
|
||||
(save-window-excursion
|
||||
(find-file file)
|
||||
(setq to-be-removed (current-buffer))
|
||||
(org-babel-tangle nil target-file lang))
|
||||
(unless visited-p
|
||||
(kill-buffer to-be-removed)))))
|
||||
|
||||
(defun org-babel-tangle-publish (_ filename pub-dir)
|
||||
"Tangle FILENAME and place the results in PUB-DIR."
|
||||
(mapc (lambda (el) (copy-file el pub-dir t)) (org-babel-tangle-file filename)))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-babel-tangle (&optional only-this-block target-file lang)
|
||||
(defun org-babel-tangle (&optional arg target-file lang)
|
||||
"Write code blocks to source-specific files.
|
||||
Extract the bodies of all source code blocks from the current
|
||||
file into their own source-specific files. Optional argument
|
||||
TARGET-FILE can be used to specify a default export file for all
|
||||
source blocks. Optional argument LANG can be used to limit the
|
||||
exported source code blocks by language."
|
||||
file into their own source-specific files.
|
||||
With one universal prefix argument, only tangle the block at point.
|
||||
When two universal prefix arguments, only tangle blocks for the
|
||||
tangle file of the block at point.
|
||||
Optional argument TARGET-FILE can be used to specify a default
|
||||
export file for all source blocks. Optional argument LANG can be
|
||||
used to limit the exported source code blocks by language."
|
||||
(interactive "P")
|
||||
(run-hooks 'org-babel-pre-tangle-hook)
|
||||
;; possibly restrict the buffer to the current code block
|
||||
;; Possibly Restrict the buffer to the current code block
|
||||
(save-restriction
|
||||
(when only-this-block
|
||||
(unless (org-babel-where-is-src-block-head)
|
||||
(error "Point is not currently inside of a code block"))
|
||||
(save-match-data
|
||||
(unless (or (cdr (assoc :tangle (nth 2 (org-babel-get-src-block-info))))
|
||||
target-file)
|
||||
(setq target-file
|
||||
(read-from-minibuffer "Tangle to: " (buffer-file-name)))))
|
||||
(narrow-to-region (match-beginning 0) (match-end 0)))
|
||||
(when (equal arg '(4))
|
||||
(let ((head (org-babel-where-is-src-block-head)))
|
||||
(if head
|
||||
(goto-char head)
|
||||
(user-error "Point is not in a source code block"))))
|
||||
(save-excursion
|
||||
(let ((block-counter 0)
|
||||
(org-babel-default-header-args
|
||||
@ -206,6 +188,10 @@ exported source code blocks by language."
|
||||
(org-babel-merge-params org-babel-default-header-args
|
||||
(list (cons :tangle target-file)))
|
||||
org-babel-default-header-args))
|
||||
(tangle-file
|
||||
(when (equal arg '(16))
|
||||
(or (cdr (assoc :tangle (nth 2 (org-babel-get-src-block-info 'light))))
|
||||
(user-error "Point is not in a source code block"))))
|
||||
path-collector)
|
||||
(mapc ;; map over all languages
|
||||
(lambda (by-lang)
|
||||
@ -226,6 +212,7 @@ exported source code blocks by language."
|
||||
(let* ((tangle (funcall get-spec :tangle))
|
||||
(she-bang ((lambda (sheb) (when (> (length sheb) 0) sheb))
|
||||
(funcall get-spec :shebang)))
|
||||
(tangle-mode (funcall get-spec :tangle-mode))
|
||||
(base-name (cond
|
||||
((string= "yes" tangle)
|
||||
(file-name-sans-extension
|
||||
@ -243,7 +230,7 @@ exported source code blocks by language."
|
||||
(make-directory (file-name-directory file-name) 'parents))
|
||||
;; delete any old versions of file
|
||||
(when (and (file-exists-p file-name)
|
||||
(not (member file-name path-collector)))
|
||||
(not (member file-name (mapcar #'car path-collector))))
|
||||
(delete-file file-name))
|
||||
;; drop source-block to file
|
||||
(with-temp-buffer
|
||||
@ -261,24 +248,35 @@ exported source code blocks by language."
|
||||
(insert content)
|
||||
(write-region nil nil file-name))))
|
||||
;; if files contain she-bangs, then make the executable
|
||||
(when she-bang (set-file-modes file-name #o755))
|
||||
(when she-bang
|
||||
(unless tangle-mode (setq tangle-mode #o755)))
|
||||
;; update counter
|
||||
(setq block-counter (+ 1 block-counter))
|
||||
(add-to-list 'path-collector file-name)))))
|
||||
(add-to-list 'path-collector
|
||||
(cons file-name tangle-mode)
|
||||
nil
|
||||
(lambda (a b) (equal (car a) (car b))))))))
|
||||
specs)))
|
||||
(org-babel-tangle-collect-blocks lang))
|
||||
(if (equal arg '(4))
|
||||
(org-babel-tangle-single-block 1 t)
|
||||
(org-babel-tangle-collect-blocks lang tangle-file)))
|
||||
(message "Tangled %d code block%s from %s" block-counter
|
||||
(if (= block-counter 1) "" "s")
|
||||
(file-name-nondirectory
|
||||
(buffer-file-name (or (buffer-base-buffer) (current-buffer)))))
|
||||
(buffer-file-name
|
||||
(or (buffer-base-buffer) (current-buffer)))))
|
||||
;; run `org-babel-post-tangle-hook' in all tangled files
|
||||
(when org-babel-post-tangle-hook
|
||||
(mapc
|
||||
(lambda (file)
|
||||
(org-babel-with-temp-filebuffer file
|
||||
(run-hooks 'org-babel-post-tangle-hook)))
|
||||
path-collector))
|
||||
path-collector))))
|
||||
(mapcar #'car path-collector)))
|
||||
;; set permissions on tangled files
|
||||
(mapc (lambda (pair)
|
||||
(when (cdr pair) (set-file-modes (car pair) (cdr pair))))
|
||||
path-collector)
|
||||
(mapcar #'car path-collector)))))
|
||||
|
||||
(defun org-babel-tangle-clean ()
|
||||
"Remove comments inserted by `org-babel-tangle'.
|
||||
@ -298,12 +296,12 @@ references."
|
||||
(defvar org-bracket-link-regexp)
|
||||
(defun org-babel-spec-to-string (spec)
|
||||
"Insert SPEC into the current file.
|
||||
Insert the source-code specified by SPEC into the current
|
||||
source code file. This function uses `comment-region' which
|
||||
assumes that the appropriate major-mode is set. SPEC has the
|
||||
form
|
||||
|
||||
(start-line file link source-name params body comment)"
|
||||
Insert the source-code specified by SPEC into the current source
|
||||
code file. This function uses `comment-region' which assumes
|
||||
that the appropriate major-mode is set. SPEC has the form:
|
||||
|
||||
\(start-line file link source-name params body comment)"
|
||||
(let* ((start-line (nth 0 spec))
|
||||
(file (nth 1 spec))
|
||||
(link (nth 2 spec))
|
||||
@ -335,116 +333,137 @@ form
|
||||
(insert
|
||||
(format
|
||||
"%s\n"
|
||||
(replace-regexp-in-string
|
||||
"^," ""
|
||||
(org-unescape-code-in-string
|
||||
(org-babel-trim body (if org-src-preserve-indentation "[\f\n\r\v]")))))
|
||||
(when link-p
|
||||
(funcall
|
||||
insert-comment
|
||||
(org-fill-template org-babel-tangle-comment-format-end link-data)))))
|
||||
|
||||
(defun org-babel-tangle-collect-blocks (&optional language)
|
||||
(defvar org-comment-string) ;; Defined in org.el
|
||||
(defun org-babel-tangle-collect-blocks (&optional language tangle-file)
|
||||
"Collect source blocks in the current Org-mode file.
|
||||
Return an association list of source-code block specifications of
|
||||
the form used by `org-babel-spec-to-string' grouped by language.
|
||||
Optional argument LANG can be used to limit the collected source
|
||||
code blocks by language."
|
||||
(let ((block-counter 1) (current-heading "") blocks)
|
||||
Optional argument LANGUAGE can be used to limit the collected
|
||||
source code blocks by language. Optional argument TANGLE-FILE
|
||||
can be used to limit the collected code blocks by target file."
|
||||
(let ((block-counter 1) (current-heading "") blocks by-lang)
|
||||
(org-babel-map-src-blocks (buffer-file-name)
|
||||
((lambda (new-heading)
|
||||
(if (not (string= new-heading current-heading))
|
||||
(progn
|
||||
(setq block-counter 1)
|
||||
(setq current-heading new-heading))
|
||||
(setq block-counter (+ 1 block-counter))))
|
||||
(replace-regexp-in-string "[ \t]" "-"
|
||||
(condition-case nil
|
||||
(or (nth 4 (org-heading-components))
|
||||
"(dummy for heading without text)")
|
||||
(error (buffer-file-name)))))
|
||||
(let* ((start-line (save-restriction (widen)
|
||||
(+ 1 (line-number-at-pos (point)))))
|
||||
(file (buffer-file-name))
|
||||
(info (org-babel-get-src-block-info 'light))
|
||||
(src-lang (nth 0 info)))
|
||||
(unless (string= (cdr (assoc :tangle (nth 2 info))) "no")
|
||||
(lambda (new-heading)
|
||||
(if (not (string= new-heading current-heading))
|
||||
(progn
|
||||
(setq block-counter 1)
|
||||
(setq current-heading new-heading))
|
||||
(setq block-counter (+ 1 block-counter))))
|
||||
(replace-regexp-in-string "[ \t]" "-"
|
||||
(condition-case nil
|
||||
(or (nth 4 (org-heading-components))
|
||||
"(dummy for heading without text)")
|
||||
(error (buffer-file-name))))
|
||||
(let* ((info (org-babel-get-src-block-info 'light))
|
||||
(src-lang (nth 0 info))
|
||||
(src-tfile (cdr (assoc :tangle (nth 2 info)))))
|
||||
(unless (or (string-match (concat "^" org-comment-string) current-heading)
|
||||
(string= (cdr (assoc :tangle (nth 2 info))) "no")
|
||||
(and tangle-file (not (equal tangle-file src-tfile))))
|
||||
(unless (and language (not (string= language src-lang)))
|
||||
(let* ((info (org-babel-get-src-block-info))
|
||||
(params (nth 2 info))
|
||||
(extra (nth 3 info))
|
||||
(cref-fmt (or (and (string-match "-l \"\\(.+\\)\"" extra)
|
||||
(match-string 1 extra))
|
||||
org-coderef-label-format))
|
||||
(link ((lambda (link)
|
||||
(and (string-match org-bracket-link-regexp link)
|
||||
(match-string 1 link)))
|
||||
(org-no-properties
|
||||
(org-store-link nil))))
|
||||
(source-name
|
||||
(intern (or (nth 4 info)
|
||||
(format "%s:%d"
|
||||
current-heading block-counter))))
|
||||
(expand-cmd
|
||||
(intern (concat "org-babel-expand-body:" src-lang)))
|
||||
(assignments-cmd
|
||||
(intern (concat "org-babel-variable-assignments:" src-lang)))
|
||||
(body
|
||||
((lambda (body) ;; run the tangle-body-hook
|
||||
(with-temp-buffer
|
||||
(insert body)
|
||||
(when (string-match "-r" extra)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward
|
||||
(replace-regexp-in-string "%s" ".+" cref-fmt) nil t)
|
||||
(replace-match "")))
|
||||
(run-hooks 'org-babel-tangle-body-hook)
|
||||
(buffer-string)))
|
||||
((lambda (body) ;; expand the body in language specific manner
|
||||
(if (assoc :no-expand params)
|
||||
body
|
||||
(if (fboundp expand-cmd)
|
||||
(funcall expand-cmd body params)
|
||||
(org-babel-expand-body:generic
|
||||
body params
|
||||
(and (fboundp assignments-cmd)
|
||||
(funcall assignments-cmd params))))))
|
||||
(if (org-babel-noweb-p params :tangle)
|
||||
(org-babel-expand-noweb-references info)
|
||||
(nth 1 info)))))
|
||||
(comment
|
||||
(when (or (string= "both" (cdr (assoc :comments params)))
|
||||
(string= "org" (cdr (assoc :comments params))))
|
||||
;; from the previous heading or code-block end
|
||||
(funcall
|
||||
org-babel-process-comment-text
|
||||
(buffer-substring
|
||||
(max (condition-case nil
|
||||
(save-excursion
|
||||
(org-back-to-heading t) ; sets match data
|
||||
(match-end 0))
|
||||
(error (point-min)))
|
||||
(save-excursion
|
||||
(if (re-search-backward
|
||||
org-babel-src-block-regexp nil t)
|
||||
(match-end 0)
|
||||
(point-min))))
|
||||
(point)))))
|
||||
by-lang)
|
||||
;; add the spec for this block to blocks under it's language
|
||||
(setq by-lang (cdr (assoc src-lang blocks)))
|
||||
(setq blocks (delq (assoc src-lang blocks) blocks))
|
||||
(setq blocks (cons
|
||||
(cons src-lang
|
||||
(cons (list start-line file link
|
||||
source-name params body comment)
|
||||
by-lang)) blocks)))))))
|
||||
;; ensure blocks in the correct order
|
||||
;; Add the spec for this block to blocks under it's language
|
||||
(setq by-lang (cdr (assoc src-lang blocks)))
|
||||
(setq blocks (delq (assoc src-lang blocks) blocks))
|
||||
(setq blocks (cons
|
||||
(cons src-lang
|
||||
(cons
|
||||
(org-babel-tangle-single-block
|
||||
block-counter)
|
||||
by-lang)) blocks))))))
|
||||
;; Ensure blocks are in the correct order
|
||||
(setq blocks
|
||||
(mapcar
|
||||
(lambda (by-lang) (cons (car by-lang) (reverse (cdr by-lang))))
|
||||
blocks))
|
||||
blocks))
|
||||
|
||||
(defun org-babel-tangle-single-block
|
||||
(block-counter &optional only-this-block)
|
||||
"Collect the tangled source for current block.
|
||||
Return the list of block attributes needed by
|
||||
`org-babel-tangle-collect-blocks'.
|
||||
When ONLY-THIS-BLOCK is non-nil, return the full association
|
||||
list to be used by `org-babel-tangle' directly."
|
||||
(let* ((info (org-babel-get-src-block-info))
|
||||
(start-line
|
||||
(save-restriction (widen)
|
||||
(+ 1 (line-number-at-pos (point)))))
|
||||
(file (buffer-file-name))
|
||||
(src-lang (nth 0 info))
|
||||
(params (nth 2 info))
|
||||
(extra (nth 3 info))
|
||||
(cref-fmt (or (and (string-match "-l \"\\(.+\\)\"" extra)
|
||||
(match-string 1 extra))
|
||||
org-coderef-label-format))
|
||||
(link ((lambda (link)
|
||||
(and (string-match org-bracket-link-regexp link)
|
||||
(match-string 1 link)))
|
||||
(org-no-properties
|
||||
(org-store-link nil))))
|
||||
(source-name
|
||||
(intern (or (nth 4 info)
|
||||
(format "%s:%d"
|
||||
(or (ignore-errors (nth 4 (org-heading-components)))
|
||||
"No heading")
|
||||
block-counter))))
|
||||
(expand-cmd
|
||||
(intern (concat "org-babel-expand-body:" src-lang)))
|
||||
(assignments-cmd
|
||||
(intern (concat "org-babel-variable-assignments:" src-lang)))
|
||||
(body
|
||||
((lambda (body) ;; Run the tangle-body-hook
|
||||
(with-temp-buffer
|
||||
(insert body)
|
||||
(when (string-match "-r" extra)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward
|
||||
(replace-regexp-in-string "%s" ".+" cref-fmt) nil t)
|
||||
(replace-match "")))
|
||||
(run-hooks 'org-babel-tangle-body-hook)
|
||||
(buffer-string)))
|
||||
((lambda (body) ;; Expand the body in language specific manner
|
||||
(if (assoc :no-expand params)
|
||||
body
|
||||
(if (fboundp expand-cmd)
|
||||
(funcall expand-cmd body params)
|
||||
(org-babel-expand-body:generic
|
||||
body params
|
||||
(and (fboundp assignments-cmd)
|
||||
(funcall assignments-cmd params))))))
|
||||
(if (org-babel-noweb-p params :tangle)
|
||||
(org-babel-expand-noweb-references info)
|
||||
(nth 1 info)))))
|
||||
(comment
|
||||
(when (or (string= "both" (cdr (assoc :comments params)))
|
||||
(string= "org" (cdr (assoc :comments params))))
|
||||
;; From the previous heading or code-block end
|
||||
(funcall
|
||||
org-babel-process-comment-text
|
||||
(buffer-substring
|
||||
(max (condition-case nil
|
||||
(save-excursion
|
||||
(org-back-to-heading t) ; Sets match data
|
||||
(match-end 0))
|
||||
(error (point-min)))
|
||||
(save-excursion
|
||||
(if (re-search-backward
|
||||
org-babel-src-block-regexp nil t)
|
||||
(match-end 0)
|
||||
(point-min))))
|
||||
(point)))))
|
||||
(result
|
||||
(list start-line file link source-name params body comment)))
|
||||
(if only-this-block
|
||||
(list (cons src-lang (list result)))
|
||||
result)))
|
||||
|
||||
(defun org-babel-tangle-comment-links ( &optional info)
|
||||
"Return a list of begin and end link comments for the code block at point."
|
||||
(let* ((start-line (org-babel-where-is-src-block-head))
|
||||
@ -489,13 +508,15 @@ which enable the original code blocks to be found."
|
||||
"Jump from a tangled code file to the related Org-mode file."
|
||||
(interactive)
|
||||
(let ((mid (point))
|
||||
start end done
|
||||
start body-start end done
|
||||
target-buffer target-char link path block-name body)
|
||||
(save-window-excursion
|
||||
(save-excursion
|
||||
(while (and (re-search-backward org-bracket-link-analytic-regexp nil t)
|
||||
(not ; ever wider searches until matching block comments
|
||||
(and (setq start (point-at-eol))
|
||||
(setq body-start (save-excursion
|
||||
(forward-line 2) (point-at-bol)))
|
||||
(setq link (match-string 0))
|
||||
(setq path (match-string 3))
|
||||
(setq block-name (match-string 5))
|
||||
@ -516,8 +537,19 @@ which enable the original code blocks to be found."
|
||||
(org-babel-next-src-block
|
||||
(string-to-number (match-string 1 block-name)))
|
||||
(org-babel-goto-named-src-block block-name))
|
||||
;; position at the beginning of the code block body
|
||||
(goto-char (org-babel-where-is-src-block-head))
|
||||
(forward-line 1)
|
||||
;; Use org-edit-special to isolate the code.
|
||||
(org-edit-special)
|
||||
;; Then move forward the correct number of characters in the
|
||||
;; code buffer.
|
||||
(forward-char (- mid body-start))
|
||||
;; And return to the Org-mode buffer with the point in the right
|
||||
;; place.
|
||||
(org-edit-src-exit)
|
||||
(setq target-char (point)))
|
||||
(pop-to-buffer target-buffer)
|
||||
(org-src-switch-to-buffer target-buffer t)
|
||||
(prog1 body (goto-char target-char))))
|
||||
|
||||
(provide 'ob-tangle)
|
||||
|
2566
lisp/org/ob.el
2566
lisp/org/ob.el
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -71,6 +71,15 @@ This variable is obsolete and has no effect anymore, instead add or remove
|
||||
:group 'org-archive
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-archive-file-header-format "\nArchived entries from file %s\n\n"
|
||||
"The header format string for newly created archive files.
|
||||
When nil, no header will be inserted.
|
||||
When a string, a %s formatter will be replaced by the file name."
|
||||
:group 'org-archive
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-archive-subtree-add-inherited-tags 'infile
|
||||
"Non-nil means append inherited tags when archiving a subtree."
|
||||
:group 'org-archive
|
||||
@ -278,9 +287,9 @@ this heading."
|
||||
(let ((org-insert-mode-line-in-empty-file t)
|
||||
(org-inhibit-startup t))
|
||||
(call-interactively 'org-mode)))
|
||||
(when newfile-p
|
||||
(when (and newfile-p org-archive-file-header-format)
|
||||
(goto-char (point-max))
|
||||
(insert (format "\nArchived entries from file %s\n\n"
|
||||
(insert (format org-archive-file-header-format
|
||||
(buffer-file-name this-buffer))))
|
||||
(when datetree-date
|
||||
(require 'org-datetree)
|
||||
|
@ -42,6 +42,8 @@
|
||||
(require 'org-id)
|
||||
(require 'org)
|
||||
|
||||
(declare-function vc-git-root "vc-git" (file))
|
||||
|
||||
(defgroup org-attach nil
|
||||
"Options concerning entry attachments in Org-mode."
|
||||
:tag "Org Attach"
|
||||
@ -54,6 +56,15 @@ where the Org file lives."
|
||||
:group 'org-attach
|
||||
:type 'directory)
|
||||
|
||||
(defcustom org-attach-git-annex-cutoff (* 32 1024)
|
||||
"If non-nil, files larger than this will be annexed instead of stored."
|
||||
:group 'org-attach
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:type '(choice
|
||||
(const :tag "None" nil)
|
||||
(integer :tag "Bytes")))
|
||||
|
||||
(defcustom org-attach-auto-tag "ATTACH"
|
||||
"Tag that will be triggered automatically when an entry has an attachment."
|
||||
:group 'org-attach
|
||||
@ -252,18 +263,32 @@ the ATTACH_DIR property) their own attachment directory."
|
||||
(defun org-attach-commit ()
|
||||
"Commit changes to git if `org-attach-directory' is properly initialized.
|
||||
This checks for the existence of a \".git\" directory in that directory."
|
||||
(let ((dir (expand-file-name org-attach-directory)))
|
||||
(when (file-exists-p (expand-file-name ".git" dir))
|
||||
(let* ((dir (expand-file-name org-attach-directory))
|
||||
(git-dir (vc-git-root dir))
|
||||
(changes 0))
|
||||
(when git-dir
|
||||
(with-temp-buffer
|
||||
(cd dir)
|
||||
(shell-command "git add .")
|
||||
(shell-command "git ls-files --deleted" t)
|
||||
(mapc #'(lambda (file)
|
||||
(unless (string= file "")
|
||||
(shell-command
|
||||
(concat "git rm \"" file "\""))))
|
||||
(split-string (buffer-string) "\n"))
|
||||
(shell-command "git commit -m 'Synchronized attachments'")))))
|
||||
(let ((have-annex
|
||||
(and org-attach-git-annex-cutoff
|
||||
(file-exists-p (expand-file-name "annex" git-dir)))))
|
||||
(dolist (new-or-modified
|
||||
(split-string
|
||||
(shell-command-to-string
|
||||
"git ls-files -zmo --exclude-standard") "\0" t))
|
||||
(if (and have-annex
|
||||
(>= (nth 7 (file-attributes new-or-modified))
|
||||
org-attach-git-annex-cutoff))
|
||||
(call-process "git" nil nil nil "annex" "add" new-or-modified)
|
||||
(call-process "git" nil nil nil "add" new-or-modified))
|
||||
(incf changes)))
|
||||
(dolist (deleted
|
||||
(split-string
|
||||
(shell-command-to-string "git ls-files -z --deleted") "\0" t))
|
||||
(call-process "git" nil nil nil "rm" deleted)
|
||||
(incf changes))
|
||||
(when (> changes 0)
|
||||
(shell-command "git commit -m 'Synchronized attachments'"))))))
|
||||
|
||||
(defun org-attach-tag (&optional off)
|
||||
"Turn the autotag on or (if OFF is set) off."
|
||||
@ -405,14 +430,14 @@ This ignores files starting with a \".\", and files ending in \"~\"."
|
||||
(directory-files dir nil "[^~]\\'"))))
|
||||
|
||||
(defun org-attach-reveal (&optional if-exists)
|
||||
"Show the attachment directory of the current task in dired."
|
||||
"Show the attachment directory of the current task.
|
||||
This will attempt to use an external program to show the directory."
|
||||
(interactive "P")
|
||||
(let ((attach-dir (org-attach-dir (not if-exists))))
|
||||
(and attach-dir (org-open-file attach-dir))))
|
||||
|
||||
(defun org-attach-reveal-in-emacs ()
|
||||
"Show the attachment directory of the current task.
|
||||
This will attempt to use an external program to show the directory."
|
||||
"Show the attachment directory of the current task in dired."
|
||||
(interactive)
|
||||
(let ((attach-dir (org-attach-dir t)))
|
||||
(dired attach-dir)))
|
||||
|
@ -116,8 +116,10 @@
|
||||
(declare-function bbdb-search-name "ext:bbdb-com" (regexp &optional layout))
|
||||
(declare-function bbdb-search-organization "ext:bbdb-com" (regexp &optional layout))
|
||||
|
||||
;; `bbdb-record-note' is part of BBDB v3.x
|
||||
;; `bbdb-record-note' was part of BBDB v3.x
|
||||
(declare-function bbdb-record-note "ext:bbdb" (record label))
|
||||
;; `bbdb-record-xfield' replaces it in recent BBDB v3.x+
|
||||
(declare-function bbdb-record-xfield "ext:bbdb" (record label))
|
||||
|
||||
(declare-function calendar-leap-year-p "calendar" (year))
|
||||
(declare-function diary-ordinal-suffix "diary-lib" (n))
|
||||
@ -306,14 +308,17 @@ The hash table is created on first use.")
|
||||
"Create a hash with anniversaries extracted from BBDB, for fast access.
|
||||
The anniversaries are assumed to be stored `org-bbdb-anniversary-field'."
|
||||
(let ((old-bbdb (fboundp 'bbdb-record-getprop))
|
||||
(record-func (if (fboundp 'bbdb-record-xfield)
|
||||
'bbdb-record-xfield
|
||||
'bbdb-record-note))
|
||||
split tmp annivs)
|
||||
(clrhash org-bbdb-anniv-hash)
|
||||
(dolist (rec (bbdb-records))
|
||||
(when (setq annivs (if old-bbdb
|
||||
(bbdb-record-getprop
|
||||
rec org-bbdb-anniversary-field)
|
||||
(bbdb-record-note
|
||||
rec org-bbdb-anniversary-field)))
|
||||
(funcall record-func
|
||||
rec org-bbdb-anniversary-field)))
|
||||
(setq annivs (if old-bbdb
|
||||
(bbdb-split annivs "\n")
|
||||
;; parameter order is reversed in new bbdb
|
||||
|
@ -2,10 +2,10 @@
|
||||
;;
|
||||
;; Copyright (C) 2007-2013 Free Software Foundation, Inc.
|
||||
;;
|
||||
;; Authors: Bastien Guerry <bzg at altern dot org>
|
||||
;; Authors: Bastien Guerry <bzg@gnu.org>
|
||||
;; Carsten Dominik <carsten dot dominik at gmail dot com>
|
||||
;; Eric Schulte <schulte dot eric at gmail dot com>
|
||||
;; Keywords: org, wp, remember
|
||||
;; Keywords: org, wp, capture
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
@ -31,7 +31,7 @@
|
||||
;; the link that contains the author name, the year and a short title.
|
||||
;;
|
||||
;; It also stores detailed information about the entry so that
|
||||
;; remember templates can access and enter this information easily.
|
||||
;; capture templates can access and enter this information easily.
|
||||
;;
|
||||
;; The available properties for each entry are listed here:
|
||||
;;
|
||||
@ -41,14 +41,14 @@
|
||||
;; :booktitle :month :annote :abstract
|
||||
;; :key :btype
|
||||
;;
|
||||
;; Here is an example of a remember template that use some of this
|
||||
;; Here is an example of a capture template that use some of this
|
||||
;; information (:author :year :title :journal :pages):
|
||||
;;
|
||||
;; (setq org-remember-templates
|
||||
;; (setq org-capure-templates
|
||||
;; '((?b "* READ %?\n\n%a\n\n%:author (%:year): %:title\n \
|
||||
;; In %:journal, %:pages.")))
|
||||
;;
|
||||
;; Let's say you want to remember this BibTeX entry:
|
||||
;; Let's say you want to capture this BibTeX entry:
|
||||
;;
|
||||
;; @Article{dolev83,
|
||||
;; author = {Danny Dolev and Andrew C. Yao},
|
||||
@ -61,7 +61,7 @@
|
||||
;; month = {Mars}
|
||||
;; }
|
||||
;;
|
||||
;; M-x `org-remember' on this entry will produce this buffer:
|
||||
;; M-x `org-capture' on this entry will produce this buffer:
|
||||
;;
|
||||
;; =====================================================================
|
||||
;; * READ <== [point here]
|
||||
@ -94,7 +94,7 @@
|
||||
;;
|
||||
;; The link creation part has been part of Org-mode for a long time.
|
||||
;;
|
||||
;; Creating better remember template information was inspired by a request
|
||||
;; Creating better capture template information was inspired by a request
|
||||
;; of Austin Frank: http://article.gmane.org/gmane.emacs.orgmode/4112
|
||||
;; and then implemented by Bastien Guerry.
|
||||
;;
|
||||
@ -224,7 +224,9 @@
|
||||
For example setting to 'BIB_' would allow interoperability with fireforg."
|
||||
:group 'org-bibtex
|
||||
:version "24.1"
|
||||
:type 'string)
|
||||
:type '(choice
|
||||
(const nil)
|
||||
(string)))
|
||||
|
||||
(defcustom org-bibtex-treat-headline-as-title t
|
||||
"Treat headline text as title if title property is absent.
|
||||
@ -623,6 +625,27 @@ This uses `bibtex-parse-entry'."
|
||||
(save-excursion (bibtex-beginning-of-entry) (bibtex-parse-entry)))
|
||||
org-bibtex-entries)))
|
||||
|
||||
(defun org-bibtex-read-buffer (buffer)
|
||||
"Read all bibtex entries in BUFFER and save to `org-bibtex-entries'.
|
||||
Return the number of saved entries."
|
||||
(interactive "bbuffer: ")
|
||||
(let ((start-length (length org-bibtex-entries)))
|
||||
(with-current-buffer buffer
|
||||
(save-excursion
|
||||
(goto-char (point-max))
|
||||
(while (not (= (point) (point-min)))
|
||||
(backward-char 1)
|
||||
(org-bibtex-read)
|
||||
(bibtex-beginning-of-entry))))
|
||||
(let ((added (- (length org-bibtex-entries) start-length)))
|
||||
(message "parsed %d entries" added)
|
||||
added)))
|
||||
|
||||
(defun org-bibtex-read-file (file)
|
||||
"Read FILE with `org-bibtex-read-buffer'."
|
||||
(interactive "ffile: ")
|
||||
(org-bibtex-read-buffer (find-file-noselect file 'nowarn 'rawfile)))
|
||||
|
||||
(defun org-bibtex-write ()
|
||||
"Insert a heading built from the first element of `org-bibtex-entries'."
|
||||
(interactive)
|
||||
@ -664,6 +687,14 @@ This uses `bibtex-parse-entry'."
|
||||
(org-bibtex-write)
|
||||
(error "Yanked text does not appear to contain a BibTeX entry"))))
|
||||
|
||||
(defun org-bibtex-import-from-file (file)
|
||||
"Read bibtex entries from FILE and insert as Org-mode headlines after point."
|
||||
(interactive "ffile: ")
|
||||
(dotimes (_ (org-bibtex-read-file file))
|
||||
(save-excursion (org-bibtex-write))
|
||||
(re-search-forward org-property-end-re)
|
||||
(open-line 1) (forward-char 1)))
|
||||
|
||||
(defun org-bibtex-export-to-kill-ring ()
|
||||
"Export current headline to kill ring as bibtex entry."
|
||||
(interactive)
|
||||
|
@ -24,14 +24,14 @@
|
||||
;;
|
||||
;;; Commentary:
|
||||
|
||||
;; This file contains an alternative implementation of the same functionality
|
||||
;; that is also provided by org-remember.el. The implementation is more
|
||||
;; This file contains an alternative implementation of the functionality
|
||||
;; that used to be provided by org-remember.el. The implementation is more
|
||||
;; streamlined, can produce more target types (e.g. plain list items or
|
||||
;; table lines). Also, it does not use a temporary buffer for editing
|
||||
;; the captured entry - instead it uses an indirect buffer that visits
|
||||
;; the new entry already in the target buffer (this was an idea by Samuel
|
||||
;; Wales). John Wiegley's excellent `remember.el' is not needed for this
|
||||
;; implementation, even though we borrow heavily from its ideas.
|
||||
;; Wales). John Wiegley's excellent `remember.el' is not needed anymore
|
||||
;; for this implementation, even though we borrow heavily from its ideas.
|
||||
|
||||
;; This implementation heavily draws on ideas by James TD Smith and
|
||||
;; Samuel Wales, and, of cause, uses John Wiegley's remember.el as inspiration.
|
||||
@ -50,7 +50,6 @@
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
(require 'org)
|
||||
(require 'org-mks)
|
||||
|
||||
(declare-function org-datetree-find-date-create "org-datetree"
|
||||
(date &optional keep-restriction))
|
||||
@ -182,6 +181,8 @@ properties are:
|
||||
template only needs information that can be added
|
||||
automatically.
|
||||
|
||||
:jump-to-captured When set, jump to the captured entry when finished.
|
||||
|
||||
:empty-lines Set this to the number of lines the should be inserted
|
||||
before and after the new item. Default 0, only common
|
||||
other value is 1.
|
||||
@ -223,7 +224,9 @@ freely formatted text. Furthermore, the following %-escapes will
|
||||
be replaced with content and expanded in this order:
|
||||
|
||||
%[pathname] Insert the contents of the file given by `pathname'.
|
||||
%(sexp) Evaluate elisp `(sexp)' and replace with the result.
|
||||
%(sexp) Evaluate elisp `(sexp)' and replace it with the results.
|
||||
For convenience, %:keyword (see below) placeholders within
|
||||
the expression will be expanded prior to this.
|
||||
%<...> The result of format-time-string on the ... format specification.
|
||||
%t Time stamp, date only.
|
||||
%T Time stamp with date and time.
|
||||
@ -237,7 +240,7 @@ be replaced with content and expanded in this order:
|
||||
%x Content of the X clipboard.
|
||||
%k Title of currently clocked task.
|
||||
%K Link to currently clocked task.
|
||||
%n User name (taken from `user-full-name').
|
||||
%n User name (taken from the variable `user-full-name').
|
||||
%f File visited by current buffer when org-capture was called.
|
||||
%F Full path of the file or directory visited by current buffer.
|
||||
%:keyword Specific information for certain link types, see below.
|
||||
@ -338,11 +341,15 @@ calendar | %:type %:date"
|
||||
;; Give the most common options as checkboxes
|
||||
:options (((const :format "%v " :prepend) (const t))
|
||||
((const :format "%v " :immediate-finish) (const t))
|
||||
((const :format "%v " :jump-to-captured) (const t))
|
||||
((const :format "%v " :empty-lines) (const 1))
|
||||
((const :format "%v " :empty-lines-before) (const 1))
|
||||
((const :format "%v " :empty-lines-after) (const 1))
|
||||
((const :format "%v " :clock-in) (const t))
|
||||
((const :format "%v " :clock-keep) (const t))
|
||||
((const :format "%v " :clock-resume) (const t))
|
||||
((const :format "%v " :unnarrowed) (const t))
|
||||
((const :format "%v " :table-line-pos) (const t))
|
||||
((const :format "%v " :kill-buffer) (const t))))))))
|
||||
|
||||
(defcustom org-capture-before-finalize-hook nil
|
||||
@ -439,6 +446,7 @@ Turning on this mode runs the normal hook `org-capture-mode-hook'."
|
||||
|
||||
;;;###autoload
|
||||
(defun org-capture-string (string &optional keys)
|
||||
"Capture STRING with the template selected by KEYS."
|
||||
(interactive "sInitial text: \n")
|
||||
(let ((org-capture-initial string)
|
||||
(org-capture-entry (org-capture-select-template keys)))
|
||||
@ -459,6 +467,8 @@ Here are the available contexts definitions:
|
||||
in-mode: command displayed only in matching modes
|
||||
not-in-file: command not displayed in matching files
|
||||
not-in-mode: command not displayed in matching modes
|
||||
in-buffer: command displayed only in matching buffers
|
||||
not-in-buffer: command not displayed in matching buffers
|
||||
[function]: a custom function taking no argument
|
||||
|
||||
If you define several checks, the agenda command will be
|
||||
@ -484,6 +494,8 @@ to avoid duplicates.)"
|
||||
(choice
|
||||
(const :tag "In file" in-file)
|
||||
(const :tag "Not in file" not-in-file)
|
||||
(const :tag "In buffer" in-buffer)
|
||||
(const :tag "Not in buffer" not-in-buffer)
|
||||
(const :tag "In mode" in-mode)
|
||||
(const :tag "Not in mode" not-in-mode))
|
||||
(regexp))
|
||||
@ -491,7 +503,7 @@ to avoid duplicates.)"
|
||||
|
||||
(defcustom org-capture-use-agenda-date nil
|
||||
"Non-nil means use the date at point when capturing from agendas.
|
||||
When nil, you can still capturing using the date at point with \\[org-agenda-capture]]."
|
||||
When nil, you can still capture using the date at point with \\[org-agenda-capture]."
|
||||
:group 'org-capture
|
||||
:version "24.3"
|
||||
:type 'boolean)
|
||||
@ -514,17 +526,19 @@ stored.
|
||||
|
||||
When called with a `C-0' (zero) prefix, insert a template at point.
|
||||
|
||||
Lisp programs can set KEYS to a string associated with a template
|
||||
ELisp programs can set KEYS to a string associated with a template
|
||||
in `org-capture-templates'. In this case, interactive selection
|
||||
will be bypassed.
|
||||
|
||||
If `org-capture-use-agenda-date' is non-nil, capturing from the
|
||||
agenda will use the date at point as the default date."
|
||||
agenda will use the date at point as the default date. Then, a
|
||||
`C-1' prefix will tell the capture process to use the HH:MM time
|
||||
of the day at point (if any) or the current HH:MM time."
|
||||
(interactive "P")
|
||||
(when (and org-capture-use-agenda-date
|
||||
(eq major-mode 'org-agenda-mode))
|
||||
(setq org-overriding-default-time
|
||||
(org-get-cursor-date)))
|
||||
(org-get-cursor-date (equal goto 1))))
|
||||
(cond
|
||||
((equal goto '(4)) (org-capture-goto-target))
|
||||
((equal goto '(16)) (org-capture-goto-last-stored))
|
||||
@ -563,8 +577,9 @@ agenda will use the date at point as the default date."
|
||||
(file-name-nondirectory
|
||||
(buffer-file-name orig-buf)))
|
||||
:annotation annotation
|
||||
:initial initial)
|
||||
(org-capture-put :default-time
|
||||
:initial initial
|
||||
:return-to-wconf (current-window-configuration)
|
||||
:default-time
|
||||
(or org-overriding-default-time
|
||||
(org-current-time)))
|
||||
(org-capture-set-target-location)
|
||||
@ -579,7 +594,8 @@ agenda will use the date at point as the default date."
|
||||
;;insert at point
|
||||
(org-capture-insert-template-here)
|
||||
(condition-case error
|
||||
(org-capture-place-template)
|
||||
(org-capture-place-template
|
||||
(equal (car (org-capture-get :target)) 'function))
|
||||
((error quit)
|
||||
(if (and (buffer-base-buffer (current-buffer))
|
||||
(string-match "\\`CAPTURE-" (buffer-name)))
|
||||
@ -600,7 +616,7 @@ agenda will use the date at point as the default date."
|
||||
(error
|
||||
"Could not start the clock in this capture buffer")))
|
||||
(if (org-capture-get :immediate-finish)
|
||||
(org-capture-finalize nil)))))))))
|
||||
(org-capture-finalize)))))))))
|
||||
|
||||
(defun org-capture-get-template ()
|
||||
"Get the template from a file or a function if necessary."
|
||||
@ -625,6 +641,8 @@ agenda will use the date at point as the default date."
|
||||
With prefix argument STAY-WITH-CAPTURE, jump to the location of the
|
||||
captured item after finalizing."
|
||||
(interactive "P")
|
||||
(when (org-capture-get :jump-to-captured)
|
||||
(setq stay-with-capture t))
|
||||
(unless (and org-capture-mode
|
||||
(buffer-base-buffer (current-buffer)))
|
||||
(error "This does not seem to be a capture buffer for Org-mode"))
|
||||
@ -771,14 +789,14 @@ already gone. Any prefix argument will be passed to the refile command."
|
||||
(let ((pos (point))
|
||||
(base (buffer-base-buffer (current-buffer)))
|
||||
(org-refile-for-capture t))
|
||||
(org-capture-finalize)
|
||||
(save-window-excursion
|
||||
(with-current-buffer (or base (current-buffer))
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(widen)
|
||||
(goto-char pos)
|
||||
(call-interactively 'org-refile)))))))
|
||||
(call-interactively 'org-refile)))))
|
||||
(org-capture-finalize)))
|
||||
|
||||
(defun org-capture-kill ()
|
||||
"Abort the current capture process."
|
||||
@ -893,7 +911,8 @@ Store them in the capture property list."
|
||||
(current-time))))
|
||||
(org-capture-put
|
||||
:default-time
|
||||
(cond ((and (not org-time-was-given)
|
||||
(cond ((and (or (not (boundp 'org-time-was-given))
|
||||
(not org-time-was-given))
|
||||
(not (= (time-to-days prompt-time) (org-today))))
|
||||
;; Use 00:00 when no time is given for another date than today?
|
||||
(apply 'encode-time (append '(0 0 0) (cdddr (decode-time prompt-time)))))
|
||||
@ -964,14 +983,17 @@ it. When it is a variable, retrieve the value. Return whatever we get."
|
||||
(find-file-noselect (expand-file-name file org-directory)))))
|
||||
|
||||
(defun org-capture-steal-local-variables (buffer)
|
||||
"Install Org-mode local variables."
|
||||
"Install Org-mode local variables of BUFFER."
|
||||
(mapc (lambda (v)
|
||||
(ignore-errors (org-set-local (car v) (cdr v))))
|
||||
(buffer-local-variables buffer)))
|
||||
|
||||
(defun org-capture-place-template ()
|
||||
"Insert the template at the target location, and display the buffer."
|
||||
(org-capture-put :return-to-wconf (current-window-configuration))
|
||||
(defun org-capture-place-template (&optional inhibit-wconf-store)
|
||||
"Insert the template at the target location, and display the buffer.
|
||||
When `inhibit-wconf-store', don't store the window configuration, as it
|
||||
may have been stored before."
|
||||
(unless inhibit-wconf-store
|
||||
(org-capture-put :return-to-wconf (current-window-configuration)))
|
||||
(delete-other-windows)
|
||||
(org-switch-to-buffer-other-window
|
||||
(org-capture-get-indirect-buffer (org-capture-get :buffer) "CAPTURE"))
|
||||
@ -1250,8 +1272,11 @@ Of course, if exact position has been required, just put it there."
|
||||
(save-restriction
|
||||
(widen)
|
||||
(goto-char pos)
|
||||
(with-demoted-errors
|
||||
(bookmark-set "org-capture-last-stored"))
|
||||
(let ((bookmark-name (plist-get org-bookmark-names-plist
|
||||
:last-capture)))
|
||||
(when bookmark-name
|
||||
(with-demoted-errors
|
||||
(bookmark-set bookmark-name))))
|
||||
(move-marker org-capture-last-stored-marker (point)))))))
|
||||
|
||||
(defun org-capture-narrow (beg end)
|
||||
@ -1261,7 +1286,7 @@ Of course, if exact position has been required, just put it there."
|
||||
(goto-char beg)))
|
||||
|
||||
(defun org-capture-empty-lines-before (&optional n)
|
||||
"Arrange for the correct number of empty lines before the insertion point.
|
||||
"Set the correct number of empty lines before the insertion point.
|
||||
Point will be after the empty lines, so insertion can directly be done."
|
||||
(setq n (or n (org-capture-get :empty-lines-before)
|
||||
(org-capture-get :empty-lines) 0))
|
||||
@ -1271,7 +1296,7 @@ Point will be after the empty lines, so insertion can directly be done."
|
||||
(if (> n 0) (newline n))))
|
||||
|
||||
(defun org-capture-empty-lines-after (&optional n)
|
||||
"Arrange for the correct number of empty lines after the inserted string.
|
||||
"Set the correct number of empty lines after the inserted string.
|
||||
Point will remain at the first line after the inserted text."
|
||||
(setq n (or n (org-capture-get :empty-lines-after)
|
||||
(org-capture-get :empty-lines) 0))
|
||||
@ -1284,6 +1309,7 @@ Point will remain at the first line after the inserted text."
|
||||
(defvar org-clock-marker) ; Defined in org.el
|
||||
|
||||
(defun org-capture-insert-template-here ()
|
||||
"Insert the capture template at point."
|
||||
(let* ((template (org-capture-get :template))
|
||||
(type (org-capture-get :type))
|
||||
beg end pp)
|
||||
@ -1366,8 +1392,106 @@ Use PREFIX as a prefix for the name of the indirect buffer."
|
||||
(unless (org-kill-is-subtree-p tree)
|
||||
(error "Template is not a valid Org entry or tree")))
|
||||
|
||||
;;; The template code
|
||||
(defun org-mks (table title &optional prompt specials)
|
||||
"Select a member of an alist with multiple keys.
|
||||
TABLE is the alist which should contain entries where the car is a string.
|
||||
There should be two types of entries.
|
||||
|
||||
1. prefix descriptions like (\"a\" \"Description\")
|
||||
This indicates that `a' is a prefix key for multi-letter selection, and
|
||||
that there are entries following with keys like \"ab\", \"ax\"...
|
||||
|
||||
2. Selectable members must have more than two elements, with the first
|
||||
being the string of keys that lead to selecting it, and the second a
|
||||
short description string of the item.
|
||||
|
||||
The command will then make a temporary buffer listing all entries
|
||||
that can be selected with a single key, and all the single key
|
||||
prefixes. When you press the key for a single-letter entry, it is selected.
|
||||
When you press a prefix key, the commands (and maybe further prefixes)
|
||||
under this key will be shown and offered for selection.
|
||||
|
||||
TITLE will be placed over the selection in the temporary buffer,
|
||||
PROMPT will be used when prompting for a key. SPECIAL is an alist with
|
||||
also (\"key\" \"description\") entries. When one of these is selection,
|
||||
only the bare key is returned."
|
||||
(setq prompt (or prompt "Select: "))
|
||||
(let (tbl orig-table dkey ddesc des-keys allowed-keys
|
||||
current prefix rtn re pressed buffer (inhibit-quit t))
|
||||
(save-window-excursion
|
||||
(setq buffer (org-switch-to-buffer-other-window "*Org Select*"))
|
||||
(setq orig-table table)
|
||||
(catch 'exit
|
||||
(while t
|
||||
(erase-buffer)
|
||||
(insert title "\n\n")
|
||||
(setq tbl table
|
||||
des-keys nil
|
||||
allowed-keys nil
|
||||
cursor-type nil)
|
||||
(setq prefix (if current (concat current " ") ""))
|
||||
(while tbl
|
||||
(cond
|
||||
((and (= 2 (length (car tbl))) (= (length (caar tbl)) 1))
|
||||
;; This is a description on this level
|
||||
(setq dkey (caar tbl) ddesc (cadar tbl))
|
||||
(pop tbl)
|
||||
(push dkey des-keys)
|
||||
(push dkey allowed-keys)
|
||||
(insert prefix "[" dkey "]" "..." " " ddesc "..." "\n")
|
||||
;; Skip keys which are below this prefix
|
||||
(setq re (concat "\\`" (regexp-quote dkey)))
|
||||
(let (case-fold-search)
|
||||
(while (and tbl (string-match re (caar tbl))) (pop tbl))))
|
||||
((= 2 (length (car tbl)))
|
||||
;; Not yet a usable description, skip it
|
||||
)
|
||||
(t
|
||||
;; usable entry on this level
|
||||
(insert prefix "[" (caar tbl) "]" " " (nth 1 (car tbl)) "\n")
|
||||
(push (caar tbl) allowed-keys)
|
||||
(pop tbl))))
|
||||
(when specials
|
||||
(insert "-------------------------------------------------------------------------------\n")
|
||||
(let ((sp specials))
|
||||
(while sp
|
||||
(insert (format "[%s] %s\n"
|
||||
(caar sp) (nth 1 (car sp))))
|
||||
(push (caar sp) allowed-keys)
|
||||
(pop sp))))
|
||||
(push "\C-g" allowed-keys)
|
||||
(goto-char (point-min))
|
||||
(if (not (pos-visible-in-window-p (point-max)))
|
||||
(org-fit-window-to-buffer))
|
||||
(message prompt)
|
||||
(setq pressed (char-to-string (read-char-exclusive)))
|
||||
(while (not (member pressed allowed-keys))
|
||||
(message "Invalid key `%s'" pressed) (sit-for 1)
|
||||
(message prompt)
|
||||
(setq pressed (char-to-string (read-char-exclusive))))
|
||||
(when (equal pressed "\C-g")
|
||||
(kill-buffer buffer)
|
||||
(error "Abort"))
|
||||
(when (and (not (assoc pressed table))
|
||||
(not (member pressed des-keys))
|
||||
(assoc pressed specials))
|
||||
(throw 'exit (setq rtn pressed)))
|
||||
(unless (member pressed des-keys)
|
||||
(throw 'exit (setq rtn (rassoc (cdr (assoc pressed table))
|
||||
orig-table))))
|
||||
(setq current (concat current pressed))
|
||||
(setq table (mapcar
|
||||
(lambda (x)
|
||||
(if (and (> (length (car x)) 1)
|
||||
(equal (substring (car x) 0 1) pressed))
|
||||
(cons (substring (car x) 1) (cdr x))
|
||||
nil))
|
||||
table))
|
||||
(setq table (remove nil table)))))
|
||||
(when buffer (kill-buffer buffer))
|
||||
rtn))
|
||||
|
||||
;;; The template code
|
||||
(defun org-capture-select-template (&optional keys)
|
||||
"Select a capture template.
|
||||
Lisp programs can force the template by setting KEYS to a string."
|
||||
@ -1496,10 +1620,8 @@ The template may still contain \"%?\" for cursor positioning."
|
||||
(setq v-i (mapconcat 'identity
|
||||
(org-split-string initial "\n")
|
||||
(concat "\n" lead))))))
|
||||
(replace-match
|
||||
(or (org-add-props (eval (intern (concat "v-" (match-string 1))))
|
||||
'(org-protected t)) "")
|
||||
t t)))
|
||||
(replace-match (or (eval (intern (concat "v-" (match-string 1)))) "")
|
||||
t t)))
|
||||
|
||||
;; From the property list
|
||||
(when plist-p
|
||||
@ -1515,8 +1637,7 @@ The template may still contain \"%?\" for cursor positioning."
|
||||
(let ((org-inhibit-startup t)) (org-mode))
|
||||
;; Interactive template entries
|
||||
(goto-char (point-min))
|
||||
(while (and (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([gGtTuUCLp]\\)?" nil t)
|
||||
(not (get-text-property (1- (point)) 'org-protected)))
|
||||
(while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([gGtTuUCLp]\\)?" nil t)
|
||||
(unless (org-capture-escaped-%)
|
||||
(setq char (if (match-end 3) (match-string-no-properties 3))
|
||||
prompt (if (match-end 2) (match-string-no-properties 2)))
|
||||
@ -1621,9 +1742,29 @@ The template may still contain \"%?\" for cursor positioning."
|
||||
(goto-char (match-beginning 0))
|
||||
(let ((template-start (point)))
|
||||
(forward-char 1)
|
||||
(let ((result (org-eval (read (current-buffer)))))
|
||||
(let* ((sexp (read (current-buffer)))
|
||||
(result (org-eval
|
||||
(org-capture--expand-keyword-in-embedded-elisp sexp))))
|
||||
(delete-region template-start (point))
|
||||
(insert result))))))
|
||||
(when result
|
||||
(if (stringp result)
|
||||
(insert result)
|
||||
(error "Capture template sexp `%s' must evaluate to string or nil"
|
||||
sexp))))))))
|
||||
|
||||
(defun org-capture--expand-keyword-in-embedded-elisp (attr)
|
||||
"Recursively replace capture link keywords in ATTR sexp.
|
||||
Such keywords are prefixed with \"%:\". See
|
||||
`org-capture-template' for more information."
|
||||
(cond ((consp attr)
|
||||
(mapcar 'org-capture--expand-keyword-in-embedded-elisp attr))
|
||||
((symbolp attr)
|
||||
(let* ((attr-symbol (symbol-name attr))
|
||||
(key (and (string-match "%\\(:.*\\)" attr-symbol)
|
||||
(intern (match-string 1 attr-symbol)))))
|
||||
(or (plist-get org-store-link-plist key)
|
||||
attr)))
|
||||
(t attr)))
|
||||
|
||||
(defun org-capture-inside-embedded-elisp-p ()
|
||||
"Return non-nil if point is inside of embedded elisp %(sexp)."
|
||||
@ -1643,7 +1784,7 @@ The template may still contain \"%?\" for cursor positioning."
|
||||
|
||||
;;;###autoload
|
||||
(defun org-capture-import-remember-templates ()
|
||||
"Set org-capture-templates to be similar to `org-remember-templates'."
|
||||
"Set `org-capture-templates' to be similar to `org-remember-templates'."
|
||||
(interactive)
|
||||
(when (and (yes-or-no-p
|
||||
"Import old remember templates into org-capture-templates? ")
|
||||
@ -1660,7 +1801,7 @@ The template may still contain \"%?\" for cursor positioning."
|
||||
(position (or (nth 4 entry) org-remember-default-headline))
|
||||
(type 'entry)
|
||||
(prepend org-reverse-note-order)
|
||||
immediate target)
|
||||
immediate target jump-to-captured)
|
||||
(cond
|
||||
((member position '(top bottom))
|
||||
(setq target (list 'file file)
|
||||
@ -1674,9 +1815,13 @@ The template may still contain \"%?\" for cursor positioning."
|
||||
(setq template (replace-match "" t t template)
|
||||
immediate t))
|
||||
|
||||
(when (string-match "%&" template)
|
||||
(setq jump-to-captured t))
|
||||
|
||||
(append (list key desc type target template)
|
||||
(if prepend '(:prepend t))
|
||||
(if immediate '(:immediate-finish t)))))
|
||||
(if immediate '(:immediate-finish t))
|
||||
(if jump-to-captured '(:jump-to-captured t)))))
|
||||
|
||||
org-remember-templates))))
|
||||
|
||||
|
@ -26,11 +26,11 @@
|
||||
|
||||
;; This file contains the time clocking code for Org-mode
|
||||
|
||||
(require 'org-exp)
|
||||
;;; Code:
|
||||
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
(require 'org)
|
||||
|
||||
(declare-function calendar-absolute-from-iso "cal-iso" (&optional date))
|
||||
(declare-function notifications-notify "notifications" (&rest params))
|
||||
@ -95,6 +95,24 @@ clocking out."
|
||||
(repeat :tag "State list"
|
||||
(string :tag "TODO keyword"))))
|
||||
|
||||
(defcustom org-clock-rounding-minutes 0
|
||||
"Rounding minutes when clocking in or out.
|
||||
The default value is 0 so that no rounding is done.
|
||||
When set to a non-integer value, use the car of
|
||||
`org-time-stamp-rounding-minutes', like for setting a time-stamp.
|
||||
|
||||
E.g. if `org-clock-rounding-minutes' is set to 5, time is 14:47
|
||||
and you clock in: then the clock starts at 14:45. If you clock
|
||||
out within the next 5 minutes, the clock line will be removed;
|
||||
if you clock out 8 minutes after your clocked in, the clock
|
||||
out time will be 14:50."
|
||||
:group 'org-clock
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:type '(choice
|
||||
(integer :tag "Minutes (0 for no rounding)")
|
||||
(symbol :tag "Use `org-time-stamp-rounding-minutes'" 'same-as-time-stamp)))
|
||||
|
||||
(defcustom org-clock-out-remove-zero-time-clocks nil
|
||||
"Non-nil means remove the clock line when the resulting time is zero."
|
||||
:group 'org-clock
|
||||
@ -141,7 +159,7 @@ state to switch it to."
|
||||
This is the string shown in the mode line when a clock is running.
|
||||
The function is called with point at the beginning of the headline."
|
||||
:group 'org-clock
|
||||
:type 'function)
|
||||
:type '(choice (const nil) (function)))
|
||||
|
||||
(defcustom org-clock-string-limit 0
|
||||
"Maximum length of clock strings in the mode line. 0 means no limit."
|
||||
@ -177,7 +195,7 @@ Emacs initialization file."
|
||||
(const :tag "No persistence" nil)))
|
||||
|
||||
(defcustom org-clock-persist-file (convert-standard-filename
|
||||
"~/.emacs.d/org-clock-save.el")
|
||||
(concat user-emacs-directory "org-clock-save.el"))
|
||||
"File to save clock data to."
|
||||
:group 'org-clock
|
||||
:type 'string)
|
||||
@ -193,17 +211,17 @@ Emacs initialization file."
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-clock-sound nil
|
||||
"Sound that will used for notifications.
|
||||
Possible values:
|
||||
"Sound to use for notifications.
|
||||
Possible values are:
|
||||
|
||||
nil no sound played.
|
||||
t standard Emacs beep
|
||||
file name play this sound file. If not possible, fall back to beep"
|
||||
nil No sound played
|
||||
t Standard Emacs beep
|
||||
file name Play this sound file, fall back to beep"
|
||||
:group 'org-clock
|
||||
:type '(choice
|
||||
(const :tag "No sound" nil)
|
||||
(const :tag "Standard beep" t)
|
||||
(file :tag "Play sound file")))
|
||||
(file :tag "Play sound file")))
|
||||
|
||||
(define-obsolete-variable-alias 'org-clock-modeline-total
|
||||
'org-clock-mode-line-total "24.3")
|
||||
@ -226,7 +244,7 @@ auto Automatically, either `all', or `repeat' for repeating tasks"
|
||||
(const :tag "All task time" all)
|
||||
(const :tag "Automatically, `all' or since `repeat'" auto)))
|
||||
|
||||
(defvaralias 'org-task-overrun-text 'org-clock-task-overrun-text)
|
||||
(org-defvaralias 'org-task-overrun-text 'org-clock-task-overrun-text)
|
||||
(defcustom org-clock-task-overrun-text nil
|
||||
"Extra mode line text to indicate that the clock is overrun.
|
||||
The can be nil to indicate that instead of adding text, the clock time
|
||||
@ -245,6 +263,7 @@ The function or program will be called with the notification
|
||||
string as argument."
|
||||
:group 'org-clock
|
||||
:type '(choice
|
||||
(const nil)
|
||||
(string :tag "Program")
|
||||
(function :tag "Function")))
|
||||
|
||||
@ -256,9 +275,11 @@ string as argument."
|
||||
(defcustom org-clocktable-defaults
|
||||
(list
|
||||
:maxlevel 2
|
||||
:lang org-export-default-language
|
||||
:lang (or (org-bound-and-true-p org-export-default-language) "en")
|
||||
:scope 'file
|
||||
:block nil
|
||||
:wstart 1
|
||||
:mstart 1
|
||||
:tstart nil
|
||||
:tend nil
|
||||
:step nil
|
||||
@ -341,13 +362,13 @@ play with them."
|
||||
"Format string for the total time cells."
|
||||
:group 'org-clock
|
||||
:version "24.1"
|
||||
:type 'boolean)
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-clock-file-time-cell-format "*%s*"
|
||||
"Format string for the file time cells."
|
||||
:group 'org-clock
|
||||
:version "24.1"
|
||||
:type 'boolean)
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-clock-clocked-in-display 'mode-line
|
||||
"When clocked in for a task, org-mode can display the current
|
||||
@ -378,6 +399,20 @@ specifications than `frame-title-format', which see."
|
||||
:group 'org-clock
|
||||
:type 'sexp)
|
||||
|
||||
(defcustom org-clock-x11idle-program-name "x11idle"
|
||||
"Name of the program which prints X11 idle time in milliseconds.
|
||||
|
||||
You can find x11idle.c in the contrib/scripts directory of the
|
||||
Org git distribution. Or, you can do:
|
||||
|
||||
sudo apt-get install xprintidle
|
||||
|
||||
if you are using Debian."
|
||||
:group 'org-clock
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:type 'string)
|
||||
|
||||
(defvar org-clock-in-prepare-hook nil
|
||||
"Hook run when preparing the clock.
|
||||
This hook is run before anything happens to the task that
|
||||
@ -403,7 +438,6 @@ to add an effort property.")
|
||||
(defvar org-clock-mode-line-timer nil)
|
||||
(defvar org-clock-idle-timer nil)
|
||||
(defvar org-clock-heading) ; defined in org.el
|
||||
(defvar org-clock-heading-for-remember "")
|
||||
(defvar org-clock-start-time "")
|
||||
|
||||
(defvar org-clock-leftover-time nil
|
||||
@ -481,46 +515,55 @@ of a different task.")
|
||||
"Hook called in task selection just before prompting the user.")
|
||||
|
||||
(defun org-clock-select-task (&optional prompt)
|
||||
"Select a task that recently was associated with clocking."
|
||||
"Select a task that was recently associated with clocking."
|
||||
(interactive)
|
||||
(let (sel-list rpl (i 0) s)
|
||||
(save-window-excursion
|
||||
(org-switch-to-buffer-other-window
|
||||
(get-buffer-create "*Clock Task Select*"))
|
||||
(erase-buffer)
|
||||
(when (marker-buffer org-clock-default-task)
|
||||
(insert (org-add-props "Default Task\n" nil 'face 'bold))
|
||||
(setq s (org-clock-insert-selection-line ?d org-clock-default-task))
|
||||
(push s sel-list))
|
||||
(when (marker-buffer org-clock-interrupted-task)
|
||||
(insert (org-add-props "The task interrupted by starting the last one\n" nil 'face 'bold))
|
||||
(setq s (org-clock-insert-selection-line ?i org-clock-interrupted-task))
|
||||
(push s sel-list))
|
||||
(when (org-clocking-p)
|
||||
(insert (org-add-props "Current Clocking Task\n" nil 'face 'bold))
|
||||
(setq s (org-clock-insert-selection-line ?c org-clock-marker))
|
||||
(push s sel-list))
|
||||
(insert (org-add-props "Recent Tasks\n" nil 'face 'bold))
|
||||
(mapc
|
||||
(lambda (m)
|
||||
(when (marker-buffer m)
|
||||
(setq i (1+ i)
|
||||
s (org-clock-insert-selection-line
|
||||
(if (< i 10)
|
||||
(+ i ?0)
|
||||
(+ i (- ?A 10))) m))
|
||||
(if (fboundp 'int-to-char) (setf (car s) (int-to-char (car s))))
|
||||
(push s sel-list)))
|
||||
org-clock-history)
|
||||
(run-hooks 'org-clock-before-select-task-hook)
|
||||
(org-fit-window-to-buffer)
|
||||
(message (or prompt "Select task for clocking:"))
|
||||
(setq rpl (read-char-exclusive))
|
||||
(cond
|
||||
((eq rpl ?q) nil)
|
||||
((eq rpl ?x) nil)
|
||||
((assoc rpl sel-list) (cdr (assoc rpl sel-list)))
|
||||
(t (error "Invalid task choice %c" rpl))))))
|
||||
(let (och chl sel-list rpl (i 0) s)
|
||||
;; Remove successive dups from the clock history to consider
|
||||
(mapc (lambda (c) (if (not (equal c (car och))) (push c och)))
|
||||
org-clock-history)
|
||||
(setq och (reverse och) chl (length och))
|
||||
(if (zerop chl)
|
||||
(user-error "No recent clock")
|
||||
(save-window-excursion
|
||||
(org-switch-to-buffer-other-window
|
||||
(get-buffer-create "*Clock Task Select*"))
|
||||
(erase-buffer)
|
||||
(when (marker-buffer org-clock-default-task)
|
||||
(insert (org-add-props "Default Task\n" nil 'face 'bold))
|
||||
(setq s (org-clock-insert-selection-line ?d org-clock-default-task))
|
||||
(push s sel-list))
|
||||
(when (marker-buffer org-clock-interrupted-task)
|
||||
(insert (org-add-props "The task interrupted by starting the last one\n" nil 'face 'bold))
|
||||
(setq s (org-clock-insert-selection-line ?i org-clock-interrupted-task))
|
||||
(push s sel-list))
|
||||
(when (org-clocking-p)
|
||||
(insert (org-add-props "Current Clocking Task\n" nil 'face 'bold))
|
||||
(setq s (org-clock-insert-selection-line ?c org-clock-marker))
|
||||
(push s sel-list))
|
||||
(insert (org-add-props "Recent Tasks\n" nil 'face 'bold))
|
||||
(mapc
|
||||
(lambda (m)
|
||||
(when (marker-buffer m)
|
||||
(setq i (1+ i)
|
||||
s (org-clock-insert-selection-line
|
||||
(if (< i 10)
|
||||
(+ i ?0)
|
||||
(+ i (- ?A 10))) m))
|
||||
(if (fboundp 'int-to-char) (setf (car s) (int-to-char (car s))))
|
||||
(push s sel-list)))
|
||||
och)
|
||||
(run-hooks 'org-clock-before-select-task-hook)
|
||||
(goto-char (point-min))
|
||||
;; Set min-height relatively to circumvent a possible but in
|
||||
;; `fit-window-to-buffer'
|
||||
(fit-window-to-buffer nil nil (if (< chl 10) chl (+ 5 chl)))
|
||||
(message (or prompt "Select task for clocking:"))
|
||||
(setq cursor-type nil rpl (read-char-exclusive))
|
||||
(cond
|
||||
((eq rpl ?q) nil)
|
||||
((eq rpl ?x) nil)
|
||||
((assoc rpl sel-list) (cdr (assoc rpl sel-list)))
|
||||
(t (user-error "Invalid task choice %c" rpl)))))))
|
||||
|
||||
(defun org-clock-insert-selection-line (i marker)
|
||||
"Insert a line for the clock selection menu.
|
||||
@ -547,7 +590,7 @@ pointing to it."
|
||||
org-odd-levels-only)
|
||||
(length prefix)))))))
|
||||
(when (and cat task)
|
||||
(insert (format "[%c] %-15s %s\n" i cat task))
|
||||
(insert (format "[%c] %-12s %s\n" i cat task))
|
||||
(cons i marker)))))
|
||||
|
||||
(defvar org-clock-task-overrun nil
|
||||
@ -560,30 +603,33 @@ pointing to it."
|
||||
If an effort estimate was defined for the current item, use
|
||||
01:30/01:50 format (clocked/estimated).
|
||||
If not, show simply the clocked time like 01:50."
|
||||
(let* ((clocked-time (org-clock-get-clocked-time))
|
||||
(h (floor clocked-time 60))
|
||||
(m (- clocked-time (* 60 h))))
|
||||
(let ((clocked-time (org-clock-get-clocked-time)))
|
||||
(if org-clock-effort
|
||||
(let* ((effort-in-minutes
|
||||
(org-duration-string-to-minutes org-clock-effort))
|
||||
(effort-h (floor effort-in-minutes 60))
|
||||
(effort-m (- effort-in-minutes (* effort-h 60)))
|
||||
(work-done-str
|
||||
(org-propertize
|
||||
(format org-time-clocksum-format h m)
|
||||
(org-minutes-to-clocksum-string clocked-time)
|
||||
'face (if (and org-clock-task-overrun (not org-clock-task-overrun-text))
|
||||
'org-mode-line-clock-overrun 'org-mode-line-clock)))
|
||||
(effort-str (format org-time-clocksum-format effort-h effort-m))
|
||||
(effort-str (org-minutes-to-clocksum-string effort-in-minutes))
|
||||
(clockstr (org-propertize
|
||||
(concat " [%s/" effort-str
|
||||
"] (" (replace-regexp-in-string "%" "%%" org-clock-heading) ")")
|
||||
'face 'org-mode-line-clock)))
|
||||
(format clockstr work-done-str))
|
||||
(org-propertize (format
|
||||
(concat "[" org-time-clocksum-format " (%s)]")
|
||||
h m org-clock-heading)
|
||||
(org-propertize (concat "[" (org-minutes-to-clocksum-string clocked-time)
|
||||
(format " (%s)" org-clock-heading) "]")
|
||||
'face 'org-mode-line-clock))))
|
||||
|
||||
(defun org-clock-get-last-clock-out-time ()
|
||||
"Get the last clock-out time for the current subtree."
|
||||
(save-excursion
|
||||
(let ((end (save-excursion (org-end-of-subtree))))
|
||||
(when (re-search-forward (concat org-clock-string
|
||||
".*\\]--\\(\\[[^]]+\\]\\)") end t)
|
||||
(org-time-string-to-time (match-string 1))))))
|
||||
|
||||
(defun org-clock-update-mode-line ()
|
||||
(if org-clock-effort
|
||||
(org-clock-notify-once-if-expired)
|
||||
@ -620,9 +666,12 @@ previous clocking intervals."
|
||||
"Add to or set the effort estimate of the item currently being clocked.
|
||||
VALUE can be a number of minutes, or a string with format hh:mm or mm.
|
||||
When the string starts with a + or a - sign, the current value of the effort
|
||||
property will be changed by that amount.
|
||||
This will update the \"Effort\" property of currently clocked item, and
|
||||
the mode line."
|
||||
property will be changed by that amount. If the effort value is expressed
|
||||
as an `org-effort-durations' (e.g. \"3h\"), the modificied value will be
|
||||
converted to a hh:mm duration.
|
||||
|
||||
This command will update the \"Effort\" property of the currently
|
||||
clocked item, and the value displayed in the mode line."
|
||||
(interactive)
|
||||
(if (org-clock-is-active)
|
||||
(let ((current org-clock-effort) sign)
|
||||
@ -646,7 +695,7 @@ the mode line."
|
||||
(setq value (- current value))
|
||||
(if (equal ?+ sign) (setq value (+ current value)))))
|
||||
(setq value (max 0 value)
|
||||
org-clock-effort (org-minutes-to-hh:mm-string value))
|
||||
org-clock-effort (org-minutes-to-clocksum-string value))
|
||||
(org-entry-put org-clock-marker "Effort" org-clock-effort)
|
||||
(org-clock-update-mode-line)
|
||||
(message "Effort is now %s" org-clock-effort))
|
||||
@ -669,13 +718,14 @@ Notification is shown only once."
|
||||
(setq org-clock-notification-was-shown t)
|
||||
(org-notify
|
||||
(format "Task '%s' should be finished by now. (%s)"
|
||||
org-clock-heading org-clock-effort) t))
|
||||
org-clock-heading org-clock-effort) org-clock-sound))
|
||||
(setq org-clock-notification-was-shown nil)))))
|
||||
|
||||
(defun org-notify (notification &optional play-sound)
|
||||
"Send a NOTIFICATION and maybe PLAY-SOUND."
|
||||
"Send a NOTIFICATION and maybe PLAY-SOUND.
|
||||
If PLAY-SOUND is non-nil, it overrides `org-clock-sound'."
|
||||
(org-show-notification notification)
|
||||
(if play-sound (org-clock-play-sound)))
|
||||
(if play-sound (org-clock-play-sound play-sound)))
|
||||
|
||||
(defun org-show-notification (notification)
|
||||
"Show notification.
|
||||
@ -700,21 +750,23 @@ use libnotify if available, or fall back on a message."
|
||||
;; a fall back option
|
||||
(t (message "%s" notification))))
|
||||
|
||||
(defun org-clock-play-sound ()
|
||||
(defun org-clock-play-sound (&optional clock-sound)
|
||||
"Play sound as configured by `org-clock-sound'.
|
||||
Use alsa's aplay tool if available."
|
||||
(cond
|
||||
((not org-clock-sound))
|
||||
((eq org-clock-sound t) (beep t) (beep t))
|
||||
((stringp org-clock-sound)
|
||||
(let ((file (expand-file-name org-clock-sound)))
|
||||
(if (file-exists-p file)
|
||||
(if (executable-find "aplay")
|
||||
(start-process "org-clock-play-notification" nil
|
||||
"aplay" file)
|
||||
(condition-case nil
|
||||
(play-sound-file file)
|
||||
(error (beep t) (beep t)))))))))
|
||||
Use alsa's aplay tool if available.
|
||||
If CLOCK-SOUND is non-nil, it overrides `org-clock-sound'."
|
||||
(let ((org-clock-sound (or clock-sound org-clock-sound)))
|
||||
(cond
|
||||
((not org-clock-sound))
|
||||
((eq org-clock-sound t) (beep t) (beep t))
|
||||
((stringp org-clock-sound)
|
||||
(let ((file (expand-file-name org-clock-sound)))
|
||||
(if (file-exists-p file)
|
||||
(if (executable-find "aplay")
|
||||
(start-process "org-clock-play-notification" nil
|
||||
"aplay" file)
|
||||
(condition-case nil
|
||||
(play-sound-file file)
|
||||
(error (beep t) (beep t))))))))))
|
||||
|
||||
(defvar org-clock-mode-line-entry nil
|
||||
"Information for the mode line about the running clock.")
|
||||
@ -887,19 +939,23 @@ was started."
|
||||
(with-output-to-temp-buffer "*Org Clock*"
|
||||
(princ "Select a Clock Resolution Command:
|
||||
|
||||
i/q/C-g Ignore this question; the same as keeping all the idle time.
|
||||
i/q Ignore this question; the same as keeping all the idle time.
|
||||
|
||||
k/K Keep X minutes of the idle time (default is all). If this
|
||||
amount is less than the default, you will be clocked out
|
||||
that many minutes after the time that idling began, and then
|
||||
clocked back in at the present time.
|
||||
|
||||
g/G Indicate that you \"got back\" X minutes ago. This is quite
|
||||
different from 'k': it clocks you out from the beginning of
|
||||
the idle period and clock you back in X minutes ago.
|
||||
|
||||
s/S Subtract the idle time from the current clock. This is the
|
||||
same as keeping 0 minutes.
|
||||
|
||||
C Cancel the open timer altogether. It will be as though you
|
||||
never clocked in.
|
||||
|
||||
j/J Jump to the current clock, to make manual adjustments.
|
||||
|
||||
For all these options, using uppercase makes your final state
|
||||
@ -1010,13 +1066,13 @@ If `only-dangling-p' is non-nil, only ask to resolve dangling
|
||||
(defvar org-x11idle-exists-p
|
||||
;; Check that x11idle exists
|
||||
(and (eq window-system 'x)
|
||||
(eq (call-process-shell-command "command" nil nil nil "-v" "x11idle") 0)
|
||||
(eq (call-process-shell-command "command" nil nil nil "-v" org-clock-x11idle-program-name) 0)
|
||||
;; Check that x11idle can retrieve the idle time
|
||||
(eq (call-process-shell-command "x11idle" nil nil nil) 0)))
|
||||
(eq (call-process-shell-command org-clock-x11idle-program-name nil nil nil) 0)))
|
||||
|
||||
(defun org-x11-idle-seconds ()
|
||||
"Return the current X11 idle time in seconds."
|
||||
(/ (string-to-number (shell-command-to-string "x11idle")) 1000))
|
||||
(/ (string-to-number (shell-command-to-string org-clock-x11idle-program-name)) 1000))
|
||||
|
||||
(defun org-user-idle-seconds ()
|
||||
"Return the number of seconds the user has been idle for.
|
||||
@ -1037,7 +1093,7 @@ This is performed after `org-clock-idle-time' minutes, to check
|
||||
if the user really wants to stay clocked in after being idle for
|
||||
so long."
|
||||
(when (and org-clock-idle-time (not org-clock-resolving-clocks)
|
||||
org-clock-marker)
|
||||
org-clock-marker (marker-buffer org-clock-marker))
|
||||
(let* ((org-clock-user-idle-seconds (org-user-idle-seconds))
|
||||
(org-clock-user-idle-start
|
||||
(time-subtract (current-time)
|
||||
@ -1056,16 +1112,7 @@ so long."
|
||||
60.0))))
|
||||
org-clock-user-idle-start)))))
|
||||
|
||||
(defvar org-clock-current-task nil
|
||||
"Task currently clocked in.")
|
||||
(defun org-clock-set-current ()
|
||||
"Set `org-clock-current-task' to the task currently clocked in."
|
||||
(setq org-clock-current-task (nth 4 (org-heading-components))))
|
||||
|
||||
(defun org-clock-delete-current ()
|
||||
"Reset `org-clock-current-task' to nil."
|
||||
(setq org-clock-current-task nil))
|
||||
|
||||
(defvar org-clock-current-task nil "Task currently clocked in.")
|
||||
(defvar org-clock-out-time nil) ; store the time of the last clock-out
|
||||
|
||||
;;;###autoload
|
||||
@ -1156,14 +1203,9 @@ make this the default behavior.)"
|
||||
(goto-char target-pos)
|
||||
(org-back-to-heading t)
|
||||
(or interrupting (move-marker org-clock-interrupted-task nil))
|
||||
(save-excursion
|
||||
(forward-char) ;; make sure the marker is not at the
|
||||
;; beginning of the heading, since the
|
||||
;; user is liking to insert stuff here
|
||||
;; manually
|
||||
(run-hooks 'org-clock-in-prepare-hook)
|
||||
(org-clock-history-push))
|
||||
(org-clock-set-current)
|
||||
(run-hooks 'org-clock-in-prepare-hook)
|
||||
(org-clock-history-push)
|
||||
(setq org-clock-current-task (nth 4 (org-heading-components)))
|
||||
(cond ((functionp org-clock-in-switch-to-state)
|
||||
(looking-at org-complex-heading-regexp)
|
||||
(let ((newstate (funcall org-clock-in-switch-to-state
|
||||
@ -1174,23 +1216,15 @@ make this the default behavior.)"
|
||||
org-clock-in-switch-to-state
|
||||
"\\>"))))
|
||||
(org-todo org-clock-in-switch-to-state)))
|
||||
(setq org-clock-heading-for-remember
|
||||
(and (looking-at org-complex-heading-regexp)
|
||||
(match-end 4)
|
||||
(org-trim (buffer-substring (match-end 1)
|
||||
(match-end 4)))))
|
||||
(setq org-clock-heading
|
||||
(cond ((and org-clock-heading-function
|
||||
(functionp org-clock-heading-function))
|
||||
(funcall org-clock-heading-function))
|
||||
((and (looking-at org-complex-heading-regexp)
|
||||
(match-string 4))
|
||||
((nth 4 (org-heading-components))
|
||||
(replace-regexp-in-string
|
||||
"\\[\\[.*?\\]\\[\\(.*?\\)\\]\\]" "\\1"
|
||||
(match-string 4)))
|
||||
(match-string-no-properties 4)))
|
||||
(t "???")))
|
||||
(setq org-clock-heading (org-propertize org-clock-heading
|
||||
'face nil))
|
||||
(org-clock-find-position org-clock-in-resume)
|
||||
(cond
|
||||
((and org-clock-in-resume
|
||||
@ -1233,11 +1267,12 @@ make this the default behavior.)"
|
||||
(y-or-n-p
|
||||
(format
|
||||
"You stopped another clock %d mins ago; start this one from then? "
|
||||
(/ (- (org-float-time (current-time))
|
||||
(/ (- (org-float-time
|
||||
(org-current-time org-clock-rounding-minutes t))
|
||||
(org-float-time leftover)) 60)))
|
||||
leftover)
|
||||
start-time
|
||||
(current-time)))
|
||||
(org-current-time org-clock-rounding-minutes t)))
|
||||
(setq ts (org-insert-time-stamp org-clock-start-time
|
||||
'with-hm 'inactive))))
|
||||
(move-marker org-clock-marker (point) (buffer-base-buffer))
|
||||
@ -1288,8 +1323,9 @@ for a todo state to switch to, overriding the existing value
|
||||
(if (equal arg '(4))
|
||||
(org-clock-in (org-clock-select-task))
|
||||
(let ((start-time (if (or org-clock-continuously (equal arg '(16)))
|
||||
(or org-clock-out-time (current-time))
|
||||
(current-time))))
|
||||
(or org-clock-out-time
|
||||
(org-current-time org-clock-rounding-minutes t))
|
||||
(org-current-time org-clock-rounding-minutes t))))
|
||||
(if (null org-clock-history)
|
||||
(message "No last clock")
|
||||
(let ((org-clock-in-switch-to-state
|
||||
@ -1461,7 +1497,7 @@ to, overriding the existing value of `org-clock-out-switch-to-state'."
|
||||
org-todo-keywords-1)
|
||||
nil t "DONE")
|
||||
org-clock-out-switch-to-state))
|
||||
(now (current-time))
|
||||
(now (org-current-time org-clock-rounding-minutes))
|
||||
ts te s h m remove)
|
||||
(setq org-clock-out-time now)
|
||||
(save-excursion ; Do not replace this with `with-current-buffer'.
|
||||
@ -1522,11 +1558,20 @@ to, overriding the existing value of `org-clock-out-switch-to-state'."
|
||||
"\\>"))))
|
||||
(org-todo org-clock-out-switch-to-state))))))
|
||||
(force-mode-line-update)
|
||||
(message (concat "Clock stopped at %s after HH:MM = " org-time-clocksum-format "%s") te h m
|
||||
(if remove " => LINE REMOVED" ""))
|
||||
(run-hooks 'org-clock-out-hook)
|
||||
(message (concat "Clock stopped at %s after "
|
||||
(org-minutes-to-clocksum-string (+ (* 60 h) m)) "%s")
|
||||
te (if remove " => LINE REMOVED" ""))
|
||||
(let ((h org-clock-out-hook))
|
||||
;; If a closing note needs to be stored in the drawer
|
||||
;; where clocks are stored, let's temporarily disable
|
||||
;; `org-clock-remove-empty-clock-drawer'
|
||||
(if (and (equal org-clock-into-drawer org-log-into-drawer)
|
||||
(eq org-log-done 'note)
|
||||
org-clock-out-when-done)
|
||||
(setq h (delq 'org-clock-remove-empty-clock-drawer h)))
|
||||
(mapc (lambda (f) (funcall f)) h))
|
||||
(unless (org-clocking-p)
|
||||
(org-clock-delete-current)))))))
|
||||
(setq org-clock-current-task nil)))))))
|
||||
|
||||
(add-hook 'org-clock-out-hook 'org-clock-remove-empty-clock-drawer)
|
||||
|
||||
@ -1545,19 +1590,22 @@ to, overriding the existing value of `org-clock-out-switch-to-state'."
|
||||
(org-remove-empty-drawer-at clock-drawer (point))
|
||||
(forward-line 1))))))
|
||||
|
||||
(defun org-clock-timestamps-up nil
|
||||
"Increase CLOCK timestamps at cursor."
|
||||
(interactive)
|
||||
(org-clock-timestamps-change 'up))
|
||||
(defun org-clock-timestamps-up (&optional n)
|
||||
"Increase CLOCK timestamps at cursor.
|
||||
Optional argument N tells to change by that many units."
|
||||
(interactive "P")
|
||||
(org-clock-timestamps-change 'up n))
|
||||
|
||||
(defun org-clock-timestamps-down nil
|
||||
"Increase CLOCK timestamps at cursor."
|
||||
(interactive)
|
||||
(org-clock-timestamps-change 'down))
|
||||
(defun org-clock-timestamps-down (&optional n)
|
||||
"Increase CLOCK timestamps at cursor.
|
||||
Optional argument N tells to change by that many units."
|
||||
(interactive "P")
|
||||
(org-clock-timestamps-change 'down n))
|
||||
|
||||
(defun org-clock-timestamps-change (updown)
|
||||
(defun org-clock-timestamps-change (updown &optional n)
|
||||
"Change CLOCK timestamps synchronously at cursor.
|
||||
UPDOWN tells whether to change 'up or 'down."
|
||||
UPDOWN tells whether to change 'up or 'down.
|
||||
Optional argument N tells to change by that many units."
|
||||
(setq org-ts-what nil)
|
||||
(when (org-at-timestamp-p t)
|
||||
(let ((tschange (if (eq updown 'up) 'org-timestamp-up
|
||||
@ -1573,9 +1621,9 @@ UPDOWN tells whether to change 'up or 'down."
|
||||
(if (<= begts2 (point)) (setq updatets1 t))
|
||||
(if (not ts2)
|
||||
;; fall back on org-timestamp-up if there is only one
|
||||
(funcall tschange)
|
||||
(funcall tschange n)
|
||||
;; setq this so that (boundp 'org-ts-what is non-nil)
|
||||
(funcall tschange)
|
||||
(funcall tschange n)
|
||||
(let ((ts (if updatets1 ts2 ts1))
|
||||
(begts (if updatets1 begts1 begts2)))
|
||||
(setq tdiff
|
||||
@ -1620,6 +1668,12 @@ UPDOWN tells whether to change 'up or 'down."
|
||||
(message "Clock canceled")
|
||||
(run-hooks 'org-clock-cancel-hook))
|
||||
|
||||
(defcustom org-clock-goto-before-context 2
|
||||
"Number of lines of context to display before currently clocked-in entry.
|
||||
This applies when using `org-clock-goto'."
|
||||
:group 'org-clock
|
||||
:type 'integer)
|
||||
|
||||
;;;###autoload
|
||||
(defun org-clock-goto (&optional select)
|
||||
"Go to the currently clocked-in entry, or to the most recently clocked one.
|
||||
@ -1643,7 +1697,7 @@ With prefix arg SELECT, offer recently clocked tasks for selection."
|
||||
(org-show-entry)
|
||||
(org-back-to-heading t)
|
||||
(org-cycle-hide-drawers 'children)
|
||||
(recenter)
|
||||
(recenter org-clock-goto-before-context)
|
||||
(org-reveal)
|
||||
(if recent
|
||||
(message "No running clock, this is the most recently clocked task"))
|
||||
@ -1669,7 +1723,7 @@ each headline in the time range with point at the headline. Headlines for
|
||||
which HEADLINE-FILTER returns nil are excluded from the clock summation.
|
||||
PROPNAME lets you set a custom text property instead of :org-clock-minutes."
|
||||
(interactive)
|
||||
(org-unmodified
|
||||
(org-with-silent-modifications
|
||||
(let* ((re (concat "^\\(\\*+\\)[ \t]\\|^[ \t]*"
|
||||
org-clock-string
|
||||
"[ \t]*\\(?:\\(\\[.*?\\]\\)-+\\(\\[.*?\\]\\)\\|=>[ \t]+\\([0-9]+\\):\\([0-9]+\\)\\)"))
|
||||
@ -1784,12 +1838,9 @@ Use \\[org-clock-remove-overlays] to remove the subtree times."
|
||||
(when org-remove-highlights-with-change
|
||||
(org-add-hook 'before-change-functions 'org-clock-remove-overlays
|
||||
nil 'local))))
|
||||
(if org-time-clocksum-use-fractional
|
||||
(message (concat "Total file time: " org-time-clocksum-fractional-format
|
||||
" (%d hours and %d minutes)")
|
||||
(/ (+ (* h 60.0) m) 60.0) h m)
|
||||
(message (concat "Total file time: " org-time-clocksum-format
|
||||
" (%d hours and %d minutes)") h m h m))))
|
||||
(message (concat "Total file time: "
|
||||
(org-minutes-to-clocksum-string org-clock-file-total-minutes)
|
||||
" (%d hours and %d minutes)") h m)))
|
||||
|
||||
(defvar org-clock-overlays nil)
|
||||
(make-variable-buffer-local 'org-clock-overlays)
|
||||
@ -1801,9 +1852,6 @@ This creates a new overlay and stores it in `org-clock-overlays', so that it
|
||||
will be easy to remove."
|
||||
(let* ((c 60) (h (floor (/ time 60))) (m (- time (* 60 h)))
|
||||
(l (if level (org-get-valid-level level 0) 0))
|
||||
(fmt (concat "%s " (if org-time-clocksum-use-fractional
|
||||
org-time-clocksum-fractional-format
|
||||
org-time-clocksum-format) "%s"))
|
||||
(off 0)
|
||||
ov tx)
|
||||
(org-move-to-column c)
|
||||
@ -1812,14 +1860,9 @@ will be easy to remove."
|
||||
(setq ov (make-overlay (point-at-bol) (point-at-eol))
|
||||
tx (concat (buffer-substring (point-at-bol) (point))
|
||||
(make-string (+ off (max 0 (- c (current-column)))) ?.)
|
||||
(org-add-props (if org-time-clocksum-use-fractional
|
||||
(format fmt
|
||||
(make-string l ?*)
|
||||
(/ (+ (* h 60.0) m) 60.0)
|
||||
(make-string (- 16 l) ?\ ))
|
||||
(format fmt
|
||||
(make-string l ?*) h m
|
||||
(make-string (- 16 l) ?\ )))
|
||||
(org-add-props (concat (make-string l ?*) " "
|
||||
(org-minutes-to-clocksum-string time)
|
||||
(make-string (- 16 l) ?\ ))
|
||||
(list 'face 'org-clock-overlay))
|
||||
""))
|
||||
(if (not (featurep 'xemacs))
|
||||
@ -1969,20 +2012,27 @@ buffer and update it."
|
||||
((> startday 4)
|
||||
(list 39 startday year)))))))
|
||||
|
||||
(defun org-clock-special-range (key &optional time as-strings)
|
||||
(defun org-clock-special-range (key &optional time as-strings wstart mstart)
|
||||
"Return two times bordering a special time range.
|
||||
Key is a symbol specifying the range and can be one of `today', `yesterday',
|
||||
`thisweek', `lastweek', `thismonth', `lastmonth', `thisyear', `lastyear'.
|
||||
A week starts Monday 0:00 and ends Sunday 24:00.
|
||||
The range is determined relative to TIME. TIME defaults to the current time.
|
||||
By default, a week starts Monday 0:00 and ends Sunday 24:00.
|
||||
The range is determined relative to TIME, which defaults to current time.
|
||||
The return value is a cons cell with two internal times like the ones
|
||||
returned by `current time' or `encode-time'. if AS-STRINGS is non-nil,
|
||||
the returned times will be formatted strings."
|
||||
returned by `current time' or `encode-time'.
|
||||
If AS-STRINGS is non-nil, the returned times will be formatted strings.
|
||||
If WSTART is non-nil, use this number to specify the starting day of a
|
||||
week (monday is 1).
|
||||
If MSTART is non-nil, use this number to specify the starting day of a
|
||||
month (1 is the first day of the month).
|
||||
If you can combine both, the month starting day will have priority."
|
||||
(if (integerp key) (setq key (intern (number-to-string key))))
|
||||
(let* ((tm (decode-time (or time (current-time))))
|
||||
(s 0) (m (nth 1 tm)) (h (nth 2 tm))
|
||||
(d (nth 3 tm)) (month (nth 4 tm)) (y (nth 5 tm))
|
||||
(dow (nth 6 tm))
|
||||
(ws (or wstart 1))
|
||||
(ms (or mstart 1))
|
||||
(skey (symbol-name key))
|
||||
(shift 0)
|
||||
(q (cond ((>= (nth 4 tm) 10) 4)
|
||||
@ -2037,20 +2087,21 @@ the returned times will be formatted strings."
|
||||
((memq key '(day today))
|
||||
(setq d (+ d shift) h 0 m 0 h1 24 m1 0))
|
||||
((memq key '(week thisweek))
|
||||
(setq diff (+ (* -7 shift) (if (= dow 0) 6 (1- dow)))
|
||||
(setq diff (+ (* -7 shift) (if (= dow 0) (- 7 ws) (- dow ws)))
|
||||
m 0 h 0 d (- d diff) d1 (+ 7 d)))
|
||||
((memq key '(month thismonth))
|
||||
(setq d 1 h 0 m 0 d1 1 month (+ month shift) month1 (1+ month) h1 0 m1 0))
|
||||
(setq d (or ms 1) h 0 m 0 d1 (or ms 1)
|
||||
month (+ month shift) month1 (1+ month) h1 0 m1 0))
|
||||
((memq key '(quarter thisq))
|
||||
; compute if this shift remains in this year
|
||||
; if not, compute how many years and quarters we have to shift (via floor*)
|
||||
; and compute the shifted years, months and quarters
|
||||
;; Compute if this shift remains in this year. If not, compute
|
||||
;; how many years and quarters we have to shift (via floor*) and
|
||||
;; compute the shifted years, months and quarters.
|
||||
(cond
|
||||
((< (+ (- q 1) shift) 0) ; shift not in this year
|
||||
(setq interval (* -1 (+ (- q 1) shift)))
|
||||
; set tmp to ((years to shift) (quarters to shift))
|
||||
;; Set tmp to ((years to shift) (quarters to shift)).
|
||||
(setq tmp (org-floor* interval 4))
|
||||
; due to the use of floor, 0 quarters actually means 4
|
||||
;; Due to the use of floor, 0 quarters actually means 4.
|
||||
(if (= 0 (nth 1 tmp))
|
||||
(setq shiftedy (- y (nth 0 tmp))
|
||||
shiftedm 1
|
||||
@ -2080,8 +2131,7 @@ the returned times will be formatted strings."
|
||||
((memq key '(year thisyear))
|
||||
(setq txt (format-time-string "the year %Y" ts)))
|
||||
((memq key '(quarter thisq))
|
||||
(setq txt (concat (org-count-quarter shiftedq) " quarter of " (number-to-string shiftedy))))
|
||||
)
|
||||
(setq txt (concat (org-count-quarter shiftedq) " quarter of " (number-to-string shiftedy)))))
|
||||
(if as-strings
|
||||
(list (format-time-string fm ts) (format-time-string fm te) txt)
|
||||
(list ts te txt))))
|
||||
@ -2186,6 +2236,8 @@ the currently selected interval size."
|
||||
(te (plist-get params :tend))
|
||||
(link (plist-get params :link))
|
||||
(maxlevel (or (plist-get params :maxlevel) 3))
|
||||
(ws (plist-get params :wstart))
|
||||
(ms (plist-get params :mstart))
|
||||
(step (plist-get params :step))
|
||||
(timestamp (plist-get params :timestamp))
|
||||
(formatter (or (plist-get params :formatter)
|
||||
@ -2196,7 +2248,7 @@ the currently selected interval size."
|
||||
;; Check if we need to do steps
|
||||
(when block
|
||||
;; Get the range text for the header
|
||||
(setq cc (org-clock-special-range block nil t)
|
||||
(setq cc (org-clock-special-range block nil t ws ms)
|
||||
ts (car cc) te (nth 1 cc) range-text (nth 2 cc)))
|
||||
(when step
|
||||
;; Write many tables, in steps
|
||||
@ -2276,7 +2328,8 @@ from the dynamic block definition."
|
||||
;; well-defined number of columns...
|
||||
(let* ((hlchars '((1 . "*") (2 . "/")))
|
||||
(lwords (assoc (or (plist-get params :lang)
|
||||
org-export-default-language)
|
||||
(org-bound-and-true-p org-export-default-language)
|
||||
"en")
|
||||
org-clock-clocktable-language-setup))
|
||||
(multifile (plist-get params :multifile))
|
||||
(block (plist-get params :block))
|
||||
@ -2284,10 +2337,14 @@ from the dynamic block definition."
|
||||
(te (plist-get params :tend))
|
||||
(header (plist-get params :header))
|
||||
(narrow (plist-get params :narrow))
|
||||
(ws (or (plist-get params :wstart) 1))
|
||||
(ms (or (plist-get params :mstart) 1))
|
||||
(link (plist-get params :link))
|
||||
(maxlevel (or (plist-get params :maxlevel) 3))
|
||||
(emph (plist-get params :emphasize))
|
||||
(level-p (plist-get params :level))
|
||||
(org-time-clocksum-use-effort-durations
|
||||
(plist-get params :effort-durations))
|
||||
(timestamp (plist-get params :timestamp))
|
||||
(properties (plist-get params :properties))
|
||||
(ntcol (max 1 (or (plist-get params :tcolumns) 100)))
|
||||
@ -2326,7 +2383,7 @@ from the dynamic block definition."
|
||||
|
||||
(when block
|
||||
;; Get the range text for the header
|
||||
(setq range-text (nth 2 (org-clock-special-range block nil t))))
|
||||
(setq range-text (nth 2 (org-clock-special-range block nil t ws ms))))
|
||||
|
||||
;; Compute the total time
|
||||
(setq total-time (apply '+ (mapcar 'cadr tables)))
|
||||
@ -2339,13 +2396,14 @@ from the dynamic block definition."
|
||||
(or header
|
||||
;; Format the standard header
|
||||
(concat
|
||||
"#+CAPTION: "
|
||||
(nth 9 lwords) " ["
|
||||
(substring
|
||||
(format-time-string (cdr org-time-stamp-formats))
|
||||
1 -1)
|
||||
"]"
|
||||
(if block (concat ", for " range-text ".") "")
|
||||
"\n\n")))
|
||||
"\n")))
|
||||
|
||||
;; Insert the narrowing line
|
||||
(when (and narrow (integerp narrow) (not narrow-cut-p))
|
||||
@ -2378,7 +2436,7 @@ from the dynamic block definition."
|
||||
(if properties (make-string (length properties) ?|) "") ; properties columns, maybe
|
||||
(concat (format org-clock-total-time-cell-format (nth 7 lwords)) "| ") ; instead of a headline
|
||||
(format org-clock-total-time-cell-format
|
||||
(org-minutes-to-hh:mm-string (or total-time 0))) ; the time
|
||||
(org-minutes-to-clocksum-string (or total-time 0))) ; the time
|
||||
"|\n") ; close line
|
||||
|
||||
;; Now iterate over the tables and insert the data
|
||||
@ -2402,7 +2460,7 @@ from the dynamic block definition."
|
||||
(if level-p "| " "") ; level column, maybe
|
||||
(if timestamp "| " "") ; timestamp column, maybe
|
||||
(if properties (make-string (length properties) ?|) "") ;properties columns, maybe
|
||||
(org-minutes-to-hh:mm-string (nth 1 tbl))))) ; the time
|
||||
(org-minutes-to-clocksum-string (nth 1 tbl))))) ; the time
|
||||
|
||||
;; Get the list of node entries and iterate over it
|
||||
(setq entries (nth 2 tbl))
|
||||
@ -2435,7 +2493,7 @@ from the dynamic block definition."
|
||||
hlc headline hlc "|" ; headline
|
||||
(make-string (min (1- ntcol) (or (- level 1))) ?|)
|
||||
; empty fields for higher levels
|
||||
hlc (org-minutes-to-hh:mm-string (nth 3 entry)) hlc ; time
|
||||
hlc (org-minutes-to-clocksum-string (nth 3 entry)) hlc ; time
|
||||
"|\n" ; close line
|
||||
)))))
|
||||
;; When exporting subtrees or regions the region might be
|
||||
@ -2508,13 +2566,15 @@ from the dynamic block definition."
|
||||
(let* ((p1 (copy-sequence params))
|
||||
(ts (plist-get p1 :tstart))
|
||||
(te (plist-get p1 :tend))
|
||||
(ws (plist-get p1 :wstart))
|
||||
(ms (plist-get p1 :mstart))
|
||||
(step0 (plist-get p1 :step))
|
||||
(step (cdr (assoc step0 '((day . 86400) (week . 604800)))))
|
||||
(stepskip0 (plist-get p1 :stepskip0))
|
||||
(block (plist-get p1 :block))
|
||||
cc range-text step-time)
|
||||
cc range-text step-time tsb)
|
||||
(when block
|
||||
(setq cc (org-clock-special-range block nil t)
|
||||
(setq cc (org-clock-special-range block nil t ws ms)
|
||||
ts (car cc) te (nth 1 cc) range-text (nth 2 cc)))
|
||||
(cond
|
||||
((numberp ts)
|
||||
@ -2532,17 +2592,21 @@ from the dynamic block definition."
|
||||
(te
|
||||
(setq te (org-float-time
|
||||
(apply 'encode-time (org-parse-time-string te))))))
|
||||
(setq tsb
|
||||
(if (eq step0 'week)
|
||||
(- ts (* 86400 (- (nth 6 (decode-time (seconds-to-time ts))) ws)))
|
||||
ts))
|
||||
(setq p1 (plist-put p1 :header ""))
|
||||
(setq p1 (plist-put p1 :step nil))
|
||||
(setq p1 (plist-put p1 :block nil))
|
||||
(while (< ts te)
|
||||
(while (< tsb te)
|
||||
(or (bolp) (insert "\n"))
|
||||
(setq p1 (plist-put p1 :tstart (format-time-string
|
||||
(org-time-stamp-format nil t)
|
||||
(seconds-to-time ts))))
|
||||
(seconds-to-time (max tsb ts)))))
|
||||
(setq p1 (plist-put p1 :tend (format-time-string
|
||||
(org-time-stamp-format nil t)
|
||||
(seconds-to-time (setq ts (+ ts step))))))
|
||||
(seconds-to-time (min te (setq tsb (+ tsb step)))))))
|
||||
(insert "\n" (if (eq step0 'day) "Daily report: "
|
||||
"Weekly report starting on: ")
|
||||
(plist-get p1 :tstart) "\n")
|
||||
@ -2584,6 +2648,8 @@ TIME: The sum of all time spend in this tree, in minutes. This time
|
||||
(timestamp (plist-get params :timestamp))
|
||||
(ts (plist-get params :tstart))
|
||||
(te (plist-get params :tend))
|
||||
(ws (plist-get params :wstart))
|
||||
(ms (plist-get params :mstart))
|
||||
(block (plist-get params :block))
|
||||
(link (plist-get params :link))
|
||||
(tags (plist-get params :tags))
|
||||
@ -2595,7 +2661,7 @@ TIME: The sum of all time spend in this tree, in minutes. This time
|
||||
|
||||
(setq org-clock-file-total-minutes nil)
|
||||
(when block
|
||||
(setq cc (org-clock-special-range block nil t)
|
||||
(setq cc (org-clock-special-range block nil t ws ms)
|
||||
ts (car cc) te (nth 1 cc) range-text (nth 2 cc)))
|
||||
(when (integerp ts) (setq ts (calendar-gregorian-from-absolute ts)))
|
||||
(when (integerp te) (setq te (calendar-gregorian-from-absolute te)))
|
||||
@ -2605,9 +2671,9 @@ TIME: The sum of all time spend in this tree, in minutes. This time
|
||||
(setq te (format "%4d-%02d-%02d" (nth 2 te) (car te) (nth 1 te))))
|
||||
;; Now the times are strings we can parse.
|
||||
(if ts (setq ts (org-float-time
|
||||
(apply 'encode-time (org-parse-time-string ts)))))
|
||||
(seconds-to-time (org-matcher-time ts)))))
|
||||
(if te (setq te (org-float-time
|
||||
(apply 'encode-time (org-parse-time-string te)))))
|
||||
(seconds-to-time (org-matcher-time te)))))
|
||||
(save-excursion
|
||||
(org-clock-sum ts te
|
||||
(unless (null matcher)
|
||||
@ -2751,9 +2817,7 @@ The details of what will be saved are regulated by the variable
|
||||
(buffer-file-name b)
|
||||
(or (not org-clock-persist-query-save)
|
||||
(y-or-n-p (concat "Save current clock ("
|
||||
(substring-no-properties
|
||||
org-clock-heading)
|
||||
") "))))
|
||||
org-clock-heading ") "))))
|
||||
(insert "(setq resume-clock '(\""
|
||||
(buffer-file-name (org-clocking-buffer))
|
||||
"\" . " (int-to-string (marker-position org-clock-marker))
|
||||
|
@ -36,7 +36,7 @@
|
||||
(declare-function org-clock-sum-today "org-clock" (&optional headline-filter))
|
||||
|
||||
(when (featurep 'xemacs)
|
||||
(error "Do not load this file into XEmacs, use `org-colview-xemacs.el'"))
|
||||
(error "Do not load this file into XEmacs, use `org-colview-xemacs.el' from the contrib/ directory"))
|
||||
|
||||
;;; Column View
|
||||
|
||||
@ -169,8 +169,10 @@ This is the compiled version of the format.")
|
||||
(get-text-property (point-at-bol) 'face))
|
||||
'default))
|
||||
(color (list :foreground (face-attribute ref-face :foreground)))
|
||||
(face (list color 'org-column ref-face))
|
||||
(face1 (list color 'org-agenda-column-dateline ref-face))
|
||||
(font (list :height (face-attribute 'default :height)
|
||||
:family (face-attribute 'default :family)))
|
||||
(face (list color font 'org-column ref-face))
|
||||
(face1 (list color font 'org-agenda-column-dateline ref-face))
|
||||
(cphr (get-text-property (point-at-bol) 'org-complex-heading-regexp))
|
||||
pom property ass width f string ov column val modval s2 title calc)
|
||||
;; Check if the entry is in another buffer.
|
||||
@ -223,7 +225,7 @@ This is the compiled version of the format.")
|
||||
(setq s2 (org-columns-add-ellipses (or modval val) width))
|
||||
(setq string (format f s2))
|
||||
;; Create the overlay
|
||||
(org-unmodified
|
||||
(org-with-silent-modifications
|
||||
(setq ov (org-columns-new-overlay
|
||||
beg (setq beg (1+ beg)) string (if dateline face1 face)))
|
||||
(overlay-put ov 'keymap org-columns-map)
|
||||
@ -332,7 +334,7 @@ for the duration of the command.")
|
||||
(remove-hook 'post-command-hook 'org-columns-hscoll-title 'local))
|
||||
(move-marker org-columns-begin-marker nil)
|
||||
(move-marker org-columns-top-level-marker nil)
|
||||
(org-unmodified
|
||||
(org-with-silent-modifications
|
||||
(mapc 'delete-overlay org-columns-overlays)
|
||||
(setq org-columns-overlays nil)
|
||||
(let ((inhibit-read-only t))
|
||||
@ -384,7 +386,7 @@ CPHR is the complex heading regexp to use for parsing ITEM."
|
||||
(defun org-columns-quit ()
|
||||
"Remove the column overlays and in this way exit column editing."
|
||||
(interactive)
|
||||
(org-unmodified
|
||||
(org-with-silent-modifications
|
||||
(org-columns-remove-overlays)
|
||||
(let ((inhibit-read-only t))
|
||||
(remove-text-properties (point-min) (point-max) '(read-only t))))
|
||||
@ -488,7 +490,7 @@ Where possible, use the standard interface for changing this line."
|
||||
(org-agenda-columns)))
|
||||
(t
|
||||
(let ((inhibit-read-only t))
|
||||
(org-unmodified
|
||||
(org-with-silent-modifications
|
||||
(remove-text-properties
|
||||
(max (point-min) (1- bol)) eol '(read-only t)))
|
||||
(unwind-protect
|
||||
@ -589,9 +591,9 @@ an integer, select that value."
|
||||
(if (= nth -1) (setq nth 9)))
|
||||
(when (equal key "ITEM")
|
||||
(error "Cannot edit item headline from here"))
|
||||
(unless (or allowed (member key '("SCHEDULED" "DEADLINE")))
|
||||
(unless (or allowed (member key '("SCHEDULED" "DEADLINE" "CLOCKSUM")))
|
||||
(error "Allowed values for this property have not been defined"))
|
||||
(if (member key '("SCHEDULED" "DEADLINE"))
|
||||
(if (member key '("SCHEDULED" "DEADLINE" "CLOCKSUM"))
|
||||
(setq nval (if previous 'earlier 'later))
|
||||
(if previous (setq allowed (reverse allowed)))
|
||||
(cond
|
||||
@ -920,7 +922,7 @@ Don't set this, this is meant for dynamic scoping.")
|
||||
|
||||
(defun org-columns-compute-all ()
|
||||
"Compute all columns that have operators defined."
|
||||
(org-unmodified
|
||||
(org-with-silent-modifications
|
||||
(remove-text-properties (point-min) (point-max) '(org-summaries t)))
|
||||
(let ((columns org-columns-current-fmt-compiled)
|
||||
(org-columns-time (time-to-number-of-days (current-time)))
|
||||
@ -996,7 +998,7 @@ Don't set this, this is meant for dynamic scoping.")
|
||||
(if (assoc property sum-alist)
|
||||
(setcdr (assoc property sum-alist) useval)
|
||||
(push (cons property useval) sum-alist)
|
||||
(org-unmodified
|
||||
(org-with-silent-modifications
|
||||
(add-text-properties sumpos (1+ sumpos)
|
||||
(list 'org-summaries sum-alist))))
|
||||
(when (and val (not (equal val (if flag str val))))
|
||||
@ -1058,8 +1060,7 @@ Don't set this, this is meant for dynamic scoping.")
|
||||
((memq fmt '(estimate)) (org-estimate-print n printf))
|
||||
((not (numberp n)) "")
|
||||
((memq fmt '(add_times max_times min_times mean_times))
|
||||
(let* ((h (floor n)) (m (floor (+ 0.5 (* 60 (- n h))))))
|
||||
(format org-time-clocksum-format h m)))
|
||||
(org-hours-to-clocksum-string n))
|
||||
((eq fmt 'checkbox)
|
||||
(cond ((= n (floor n)) "[X]")
|
||||
((> n 1.) "[-]")
|
||||
@ -1305,10 +1306,10 @@ PARAMS is a property list of parameters:
|
||||
(if (eq 'hline x) x (cons "" x)))
|
||||
tbl))
|
||||
(setq tbl (append tbl (list (cons "/" (make-list nfields "<>"))))))
|
||||
(setq pos (point))
|
||||
(when content-lines
|
||||
(while (string-match "^#" (car content-lines))
|
||||
(insert (pop content-lines) "\n")))
|
||||
(setq pos (point))
|
||||
(insert (org-listtable-to-string tbl))
|
||||
(when (plist-get params :width)
|
||||
(insert "\n|" (mapconcat (lambda (x) (format "<%d>" (max 3 x)))
|
||||
@ -1404,7 +1405,7 @@ and tailing newline characters."
|
||||
;; OK, the property is not defined. Use appointment duration?
|
||||
(when (and org-agenda-columns-add-appointments-to-effort-sum
|
||||
(setq d (get-text-property (point) 'duration)))
|
||||
(setq d (org-minutes-to-hh:mm-string d))
|
||||
(setq d (org-minutes-to-clocksum-string d))
|
||||
(put-text-property 0 (length d) 'face 'org-warning d)
|
||||
(push (cons org-effort-property d) p)))
|
||||
(push (cons (org-current-line) p) cache))
|
||||
@ -1510,9 +1511,8 @@ This will add overlays to the date lines, to show the summary for each day."
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(widen)
|
||||
(org-unmodified
|
||||
(remove-text-properties (point-min) (point-max)
|
||||
'(org-summaries t)))
|
||||
(org-with-silent-modifications
|
||||
(remove-text-properties (point-min) (point-max) '(org-summaries t)))
|
||||
(goto-char (point-min))
|
||||
(org-columns-get-format-and-top-level)
|
||||
(while (setq fm (pop fmt))
|
||||
|
@ -113,6 +113,41 @@ any other entries, and any resulting duplicates will be removed entirely."
|
||||
|
||||
;;;; Emacs/XEmacs compatibility
|
||||
|
||||
(eval-and-compile
|
||||
(defun org-defvaralias (new-alias base-variable &optional docstring)
|
||||
"Compatibility function for defvaralias.
|
||||
Don't do the aliasing when `defvaralias' is not bound."
|
||||
(declare (indent 1))
|
||||
(when (fboundp 'defvaralias)
|
||||
(defvaralias new-alias base-variable docstring)))
|
||||
|
||||
(when (and (not (boundp 'user-emacs-directory))
|
||||
(boundp 'user-init-directory))
|
||||
(org-defvaralias 'user-emacs-directory 'user-init-directory)))
|
||||
|
||||
(when (featurep 'xemacs)
|
||||
(defadvice custom-handle-keyword
|
||||
(around org-custom-handle-keyword
|
||||
activate preactivate)
|
||||
"Remove custom keywords not recognized to avoid producing an error."
|
||||
(cond
|
||||
((eq (ad-get-arg 1) :package-version))
|
||||
(t ad-do-it)))
|
||||
(defadvice define-obsolete-variable-alias
|
||||
(around org-define-obsolete-variable-alias
|
||||
(obsolete-name current-name &optional when docstring)
|
||||
activate preactivate)
|
||||
"Declare arguments defined in later versions of Emacs."
|
||||
ad-do-it)
|
||||
(defadvice define-obsolete-function-alias
|
||||
(around org-define-obsolete-function-alias
|
||||
(obsolete-name current-name &optional when docstring)
|
||||
activate preactivate)
|
||||
"Declare arguments defined in later versions of Emacs."
|
||||
ad-do-it)
|
||||
(defvar customize-package-emacs-version-alist nil)
|
||||
(defvar temporary-file-directory (temp-directory)))
|
||||
|
||||
;; Keys
|
||||
(defconst org-xemacs-key-equivalents
|
||||
'(([mouse-1] . [button1])
|
||||
@ -226,7 +261,7 @@ ignored in this case."
|
||||
;; Region compatibility
|
||||
|
||||
(defvar org-ignore-region nil
|
||||
"To temporarily disable the active region.")
|
||||
"Non-nil means temporarily disable the active region.")
|
||||
|
||||
(defun org-region-active-p ()
|
||||
"Is `transient-mark-mode' on and the region active?
|
||||
@ -300,10 +335,11 @@ Works on both Emacs and XEmacs."
|
||||
(org-xemacs-without-invisibility (indent-line-to column))
|
||||
(indent-line-to column)))
|
||||
|
||||
(defun org-move-to-column (column &optional force buffer)
|
||||
(if (featurep 'xemacs)
|
||||
(org-xemacs-without-invisibility (move-to-column column force buffer))
|
||||
(move-to-column column force)))
|
||||
(defun org-move-to-column (column &optional force buffer ignore-invisible)
|
||||
(let ((buffer-invisibility-spec ignore-invisible))
|
||||
(if (featurep 'xemacs)
|
||||
(org-xemacs-without-invisibility (move-to-column column force buffer))
|
||||
(move-to-column column force))))
|
||||
|
||||
(defun org-get-x-clipboard-compat (value)
|
||||
"Get the clipboard value on XEmacs or Emacs 21."
|
||||
@ -378,11 +414,11 @@ TIME defaults to the current time."
|
||||
"Suppress popup windows.
|
||||
Let-bind some variables to nil around BODY to achieve the desired
|
||||
effect, which variables to use depends on the Emacs version."
|
||||
(if (org-version-check "24.2.50" "" :predicate)
|
||||
`(let (pop-up-frames display-buffer-alist)
|
||||
,@body)
|
||||
`(let (pop-up-frames special-display-buffer-names special-display-regexps special-display-function)
|
||||
,@body)))
|
||||
(if (org-version-check "24.2.50" "" :predicate)
|
||||
`(let (pop-up-frames display-buffer-alist)
|
||||
,@body)
|
||||
`(let (pop-up-frames special-display-buffer-names special-display-regexps special-display-function)
|
||||
,@body)))
|
||||
|
||||
(if (fboundp 'string-match-p)
|
||||
(defalias 'org-string-match-p 'string-match-p)
|
||||
@ -484,6 +520,29 @@ With two arguments, return floor and remainder of their quotient."
|
||||
(defun org-release () "N/A")
|
||||
(defun org-git-version () "N/A !!check installation!!"))))))
|
||||
|
||||
(defun org-file-equal-p (f1 f2)
|
||||
"Return t if files F1 and F2 are the same.
|
||||
Implements `file-equal-p' for older emacsen and XEmacs."
|
||||
(if (fboundp 'file-equal-p)
|
||||
(file-equal-p f1 f2)
|
||||
(let (f1-attr f2-attr)
|
||||
(and (setq f1-attr (file-attributes (file-truename f1)))
|
||||
(setq f2-attr (file-attributes (file-truename f2)))
|
||||
(equal f1-attr f2-attr)))))
|
||||
|
||||
;; `buffer-narrowed-p' is available for Emacs >=24.3
|
||||
(defun org-buffer-narrowed-p ()
|
||||
"Compatibility function for `buffer-narrowed-p'."
|
||||
(if (fboundp 'buffer-narrowed-p)
|
||||
(buffer-narrowed-p)
|
||||
(/= (- (point-max) (point-min)) (buffer-size))))
|
||||
|
||||
(defmacro org-with-silent-modifications (&rest body)
|
||||
(if (fboundp 'with-silent-modifications)
|
||||
`(with-silent-modifications ,@body)
|
||||
`(org-unmodified ,@body)))
|
||||
(def-edebug-spec org-with-silent-modifications (body))
|
||||
|
||||
(provide 'org-compat)
|
||||
|
||||
;;; org-compat.el ends here
|
||||
|
@ -139,11 +139,11 @@ See `org-crypt-disable-auto-save'."
|
||||
(message "org-decrypt: Decrypting entry with auto-save-mode enabled. This may cause leakage."))
|
||||
((eq org-crypt-disable-auto-save 'encrypt)
|
||||
(message "org-decrypt: Enabling re-encryption on auto-save.")
|
||||
(add-hook 'auto-save-hook
|
||||
(lambda ()
|
||||
(message "org-crypt: Re-encrypting all decrypted entries due to auto-save.")
|
||||
(org-encrypt-entries))
|
||||
nil t))
|
||||
(org-add-hook 'auto-save-hook
|
||||
(lambda ()
|
||||
(message "org-crypt: Re-encrypting all decrypted entries due to auto-save.")
|
||||
(org-encrypt-entries))
|
||||
nil t))
|
||||
(t nil))))
|
||||
|
||||
(defun org-crypt-key-for-heading ()
|
||||
@ -264,7 +264,7 @@ See `org-crypt-disable-auto-save'."
|
||||
"Add a hook to automatically encrypt entries before a file is saved to disk."
|
||||
(add-hook
|
||||
'org-mode-hook
|
||||
(lambda () (add-hook 'before-save-hook 'org-encrypt-entries nil t))))
|
||||
(lambda () (org-add-hook 'before-save-hook 'org-encrypt-entries nil t))))
|
||||
|
||||
(add-hook 'org-reveal-start-hook 'org-decrypt-entry)
|
||||
|
||||
|
@ -131,7 +131,7 @@
|
||||
;;
|
||||
;; (progn
|
||||
;; (message "-- rebuilding tags tables...")
|
||||
;; (mapc 'org-create-tags tags-table-list))
|
||||
;; (mapc 'org-ctags-create-tags tags-table-list))
|
||||
|
||||
;;; Code:
|
||||
|
||||
@ -156,11 +156,8 @@ Format is: /REGEXP/TAGNAME/FLAGS,TAGTYPE/
|
||||
See the ctags documentation for more information.")
|
||||
|
||||
(defcustom org-ctags-path-to-ctags
|
||||
(case system-type
|
||||
(windows-nt "ctags.exe")
|
||||
(darwin "ctags-exuberant")
|
||||
(t "ctags-exuberant"))
|
||||
"Full path to the ctags executable file."
|
||||
(if (executable-find "ctags-exuberant") "ctags-exuberant" "ctags")
|
||||
"Name of the ctags executable file."
|
||||
:group 'org-ctags
|
||||
:version "24.1"
|
||||
:type 'file)
|
||||
|
@ -72,7 +72,8 @@ tree can be found."
|
||||
(goto-char (prog1 (point) (widen))))))
|
||||
|
||||
(defun org-datetree-find-year-create (year)
|
||||
(let ((re "^\\*+[ \t]+\\([12][0-9]\\{3\\}\\)\\(.*?\\([ \t]:[[:alnum:]:_@#%]+:\\)?\\s-*$\\)")
|
||||
"Find the YEAR datetree or create it."
|
||||
(let ((re "^\\*+[ \t]+\\([12][0-9]\\{3\\}\\)\\(\\s-*?\\([ \t]:[[:alnum:]:_@#%]+:\\)?\\s-*$\\)")
|
||||
match)
|
||||
(goto-char (point-min))
|
||||
(while (and (setq match (re-search-forward re nil t))
|
||||
@ -90,6 +91,7 @@ tree can be found."
|
||||
(org-datetree-insert-line year)))))
|
||||
|
||||
(defun org-datetree-find-month-create (year month)
|
||||
"Find the datetree for YEAR and MONTH or create it."
|
||||
(org-narrow-to-subtree)
|
||||
(let ((re (format "^\\*+[ \t]+%d-\\([01][0-9]\\) \\w+$" year))
|
||||
match)
|
||||
@ -109,6 +111,7 @@ tree can be found."
|
||||
(org-datetree-insert-line year month)))))
|
||||
|
||||
(defun org-datetree-find-day-create (year month day)
|
||||
"Find the datetree for YEAR, MONTH and DAY or create it."
|
||||
(org-narrow-to-subtree)
|
||||
(let ((re (format "^\\*+[ \t]+%d-%02d-\\([0123][0-9]\\) \\w+$" year month))
|
||||
match)
|
||||
|
@ -51,9 +51,22 @@
|
||||
|
||||
(org-autoload "doc-view" '(doc-view-goto-page))
|
||||
|
||||
(org-add-link-type "docview" 'org-docview-open)
|
||||
(org-add-link-type "docview" 'org-docview-open 'org-docview-export)
|
||||
(add-hook 'org-store-link-functions 'org-docview-store-link)
|
||||
|
||||
(defun org-docview-export (link description format)
|
||||
"Export a docview link from Org files."
|
||||
(let* ((path (when (string-match "\\(.+\\)::.+" link)
|
||||
(match-string 1 link)))
|
||||
(desc (or description link)))
|
||||
(when (stringp path)
|
||||
(setq path (org-link-escape (expand-file-name path)))
|
||||
(cond
|
||||
((eq format 'html) (format "<a href=\"%s\">%s</a>" path desc))
|
||||
((eq format 'latex) (format "\href{%s}{%s}" path desc))
|
||||
((eq format 'ascii) (format "%s (%s)" desc path))
|
||||
(t path)))))
|
||||
|
||||
(defun org-docview-open (link)
|
||||
(when (string-match "\\(.*\\)::\\([0-9]+\\)$" link)
|
||||
(let* ((path (match-string 1 link))
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -66,8 +66,8 @@ ASCII replacement Plain ASCII, no extensions. Symbols that cannot be
|
||||
Latin1 replacement Use the special characters available in latin1.
|
||||
utf-8 replacement Use the special characters available in utf-8.
|
||||
|
||||
If you define new entities here that require specific LaTeX packages to be
|
||||
loaded, add these packages to `org-export-latex-packages-alist'."
|
||||
If you define new entities here that require specific LaTeX
|
||||
packages to be loaded, add these packages to `org-latex-packages-alist'."
|
||||
:group 'org-entities
|
||||
:version "24.1"
|
||||
:type '(repeat
|
||||
@ -154,6 +154,9 @@ loaded, add these packages to `org-export-latex-packages-alist'."
|
||||
("real" "\\Re" t "ℜ" "R" "R" "ℜ")
|
||||
("image" "\\Im" t "ℑ" "I" "I" "ℑ")
|
||||
("weierp" "\\wp" t "℘" "P" "P" "℘")
|
||||
("ell" "\\ell" t "ℓ" "ell" "ell" "ℓ")
|
||||
("imath" "\\imath" t "ı" "[dotless i]" "dotless i" "ı")
|
||||
("jmath" "\\jmath" t "ȷ" "[dotless j]" "dotless j" "ȷ")
|
||||
|
||||
"** Greek"
|
||||
("Alpha" "A" nil "Α" "Alpha" "Alpha" "Α")
|
||||
@ -203,6 +206,7 @@ loaded, add these packages to `org-export-latex-packages-alist'."
|
||||
("upsilon" "\\upsilon" t "υ" "upsilon" "upsilon" "υ")
|
||||
("Phi" "\\Phi" t "Φ" "Phi" "Phi" "Φ")
|
||||
("phi" "\\phi" t "φ" "phi" "phi" "φ")
|
||||
("varphi" "\\varphi" t "ϕ" "varphi" "varphi" "ɸ")
|
||||
("Chi" "X" nil "Χ" "Chi" "Chi" "Χ")
|
||||
("chi" "\\chi" t "χ" "chi" "chi" "χ")
|
||||
("acutex" "\\acute x" t "´x" "'x" "'x" "𝑥́")
|
||||
@ -212,10 +216,15 @@ loaded, add these packages to `org-export-latex-packages-alist'."
|
||||
("Omega" "\\Omega" t "Ω" "Omega" "Omega" "Ω")
|
||||
("omega" "\\omega" t "ω" "omega" "omega" "ω")
|
||||
("piv" "\\varpi" t "ϖ" "omega-pi" "omega-pi" "ϖ")
|
||||
("varpi" "\\varpi" t "ϖ" "omega-pi" "omega-pi" "ϖ")
|
||||
("partial" "\\partial" t "∂" "[partial differential]" "[partial differential]" "∂")
|
||||
|
||||
"** Hebrew"
|
||||
("alefsym" "\\aleph" t "ℵ" "aleph" "aleph" "ℵ")
|
||||
("aleph" "\\aleph" t "ℵ" "aleph" "aleph" "ℵ")
|
||||
("gimel" "\\gimel" t "ℷ" "gimel" "gimel" "ℷ")
|
||||
("beth" "\\beth" t "ℶ" "beth" "beth" "ב")
|
||||
("dalet" "\\daleth" t "ℸ" "dalet" "dalet" "ד")
|
||||
|
||||
"** Dead languages"
|
||||
("ETH" "\\DH{}" nil "Ð" "D" "Ð" "Ð")
|
||||
@ -226,6 +235,7 @@ loaded, add these packages to `org-export-latex-packages-alist'."
|
||||
"* Punctuation"
|
||||
"** Dots and Marks"
|
||||
("dots" "\\dots{}" nil "…" "..." "..." "…")
|
||||
("cdots" "\\cdots{}" t "⋯" "..." "..." "⋯")
|
||||
("hellip" "\\dots{}" nil "…" "..." "..." "…")
|
||||
("middot" "\\textperiodcentered{}" nil "·" "." "·" "·")
|
||||
("iexcl" "!`" nil "¡" "!" "¡" "¡")
|
||||
@ -253,20 +263,23 @@ loaded, add these packages to `org-export-latex-packages-alist'."
|
||||
"* Other"
|
||||
"** Misc. (often used)"
|
||||
("circ" "\\^{}" nil "ˆ" "^" "^" "ˆ")
|
||||
("vert" "\\vert{}" t "|" "|" "|" "|")
|
||||
("vert" "\\vert{}" t "|" "|" "|" "|")
|
||||
("brvbar" "\\textbrokenbar{}" nil "¦" "|" "¦" "¦")
|
||||
("S" "\\S" nil "§" "paragraph" "§" "§")
|
||||
("sect" "\\S" nil "§" "paragraph" "§" "§")
|
||||
("amp" "\\&" nil "&" "&" "&" "&")
|
||||
("lt" "\\textless{}" nil "<" "<" "<" "<")
|
||||
("gt" "\\textgreater{}" nil ">" ">" ">" ">")
|
||||
("tilde" "\\~{}" nil "˜" "~" "~" "~")
|
||||
("tilde" "\\textasciitilde{}" nil "~" "~" "~" "~")
|
||||
("slash" "/" nil "/" "/" "/" "/")
|
||||
("plus" "+" nil "+" "+" "+" "+")
|
||||
("under" "\\_" nil "_" "_" "_" "_")
|
||||
("equal" "=" nil "=" "=" "=" "=")
|
||||
("asciicirc" "\\textasciicircum{}" nil "^" "^" "^" "^")
|
||||
("dagger" "\\textdagger{}" nil "†" "[dagger]" "[dagger]" "†")
|
||||
("dag" "\\dag{}" nil "†" "[dagger]" "[dagger]" "†")
|
||||
("Dagger" "\\textdaggerdbl{}" nil "‡" "[doubledagger]" "[doubledagger]" "‡")
|
||||
("ddag" "\\ddag{}" nil "‡" "[doubledagger]" "[doubledagger]" "‡")
|
||||
|
||||
"** Whitespace"
|
||||
("nbsp" "~" nil " " " " " " " ")
|
||||
@ -297,6 +310,7 @@ loaded, add these packages to `org-export-latex-packages-alist'."
|
||||
("plusmn" "\\textpm{}" nil "±" "+-" "±" "±")
|
||||
("times" "\\texttimes{}" nil "×" "*" "×" "×")
|
||||
("frasl" "/" nil "⁄" "/" "/" "⁄")
|
||||
("colon" "\\colon" t ":" ":" ":" ":")
|
||||
("div" "\\textdiv{}" nil "÷" "/" "÷" "÷")
|
||||
("frac12" "\\textonehalf{}" nil "½" "1/2" "½" "½")
|
||||
("frac14" "\\textonequarter{}" nil "¼" "1/4" "¼" "¼")
|
||||
@ -318,6 +332,7 @@ loaded, add these packages to `org-export-latex-packages-alist'."
|
||||
("prop" "\\propto" t "∝" "[proportional to]" "[proportional to]" "∝")
|
||||
("proptp" "\\propto" t "∝" "[proportional to]" "[proportional to]" "∝")
|
||||
("not" "\\textlnot{}" nil "¬" "[angled dash]" "¬" "¬")
|
||||
("neg" "\\neg{}" t "¬" "[angled dash]" "¬" "¬")
|
||||
("land" "\\land" t "∧" "[logical and]" "[logical and]" "∧")
|
||||
("wedge" "\\wedge" t "∧" "[logical and]" "[logical and]" "∧")
|
||||
("lor" "\\lor" t "∨" "[logical or]" "[logical or]" "∨")
|
||||
@ -325,7 +340,9 @@ loaded, add these packages to `org-export-latex-packages-alist'."
|
||||
("cap" "\\cap" t "∩" "[intersection]" "[intersection]" "∩")
|
||||
("cup" "\\cup" t "∪" "[union]" "[union]" "∪")
|
||||
("int" "\\int" t "∫" "[integral]" "[integral]" "∫")
|
||||
("therefore" "\\therefore" t "∴" "[therefore]" "[therefore]" "∴")
|
||||
("there4" "\\therefore" t "∴" "[therefore]" "[therefore]" "∴")
|
||||
("because" "\\because" t "∵" "[because]" "[because]" "∵")
|
||||
("sim" "\\sim" t "∼" "~" "~" "∼")
|
||||
("cong" "\\cong" t "≅" "[approx. equal to]" "[approx. equal to]" "≅")
|
||||
("simeq" "\\simeq" t "≅" "[approx. equal to]" "[approx. equal to]" "≅")
|
||||
@ -334,8 +351,26 @@ loaded, add these packages to `org-export-latex-packages-alist'."
|
||||
("ne" "\\ne" t "≠" "[not equal to]" "[not equal to]" "≠")
|
||||
("neq" "\\neq" t "≠" "[not equal to]" "[not equal to]" "≠")
|
||||
("equiv" "\\equiv" t "≡" "[identical to]" "[identical to]" "≡")
|
||||
|
||||
("triangleq" "\\triangleq" t "≜" "[defined to]" "[defined to]" "≜")
|
||||
("le" "\\le" t "≤" "<=" "<=" "≤")
|
||||
("leq" "\\le" t "≤" "<=" "<=" "≤")
|
||||
("ge" "\\ge" t "≥" ">=" ">=" "≥")
|
||||
("geq" "\\ge" t "≥" ">=" ">=" "≥")
|
||||
("lessgtr" "\\lessgtr" t "≶" "[less than or greater than]" "[less than or greater than]" "≶")
|
||||
("lesseqgtr" "\\lesseqgtr" t "⋚" "[less than or equal or greater than or equal]" "[less than or equal or greater than or equal]" "⋚")
|
||||
("ll" "\\ll" t "≪" "<<" "<<" "≪")
|
||||
("Ll" "\lll" t "⋘" "<<<" "<<<" "⋘")
|
||||
("lll" "\lll" t "⋘" "<<<" "<<<" "⋘")
|
||||
("gg" "\\gg" t "≫" ">>" ">>" "≫")
|
||||
("Gg" "\\ggg" t "⋙" ">>>" ">>>" "⋙")
|
||||
("ggg" "\\ggg" t "⋙" ">>>" ">>>" "⋙")
|
||||
("prec" "\\prec" t "≺" "[precedes]" "[precedes]" "≺")
|
||||
("preceq" "\\preceq" t "≼" "[precedes or equal]" "[precedes or equal]" "≼")
|
||||
("preccurlyeq" "\\preccurlyeq" t "≼" "[precedes or equal]" "[precedes or equal]" "≼")
|
||||
("succ" "\\succ" t "≻" "[succeeds]" "[succeeds]" "≻")
|
||||
("succeq" "\\succeq" t "≽" "[succeeds or equal]" "[succeeds or equal]" "≽")
|
||||
("succcurlyeq" "\\succcurlyeq" t "≽" "[succeeds or equal]" "[succeeds or equal]" "≽")
|
||||
("sub" "\\subset" t "⊂" "[subset of]" "[subset of]" "⊂")
|
||||
("subset" "\\subset" t "⊂" "[subset of]" "[subset of]" "⊂")
|
||||
("sup" "\\supset" t "⊃" "[superset of]" "[superset of]" "⊃")
|
||||
@ -344,9 +379,12 @@ loaded, add these packages to `org-export-latex-packages-alist'."
|
||||
("sube" "\\subseteq" t "⊆" "[subset of or equal to]" "[subset of or equal to]" "⊆")
|
||||
("nsup" "\\not\\supset" t "⊅" "[not a superset of]" "[not a superset of]" "⊅")
|
||||
("supe" "\\supseteq" t "⊇" "[superset of or equal to]" "[superset of or equal to]" "⊇")
|
||||
("setminus" "\\setminus" t "∖" "\" "\" "⧵")
|
||||
("forall" "\\forall" t "∀" "[for all]" "[for all]" "∀")
|
||||
("exist" "\\exists" t "∃" "[there exists]" "[there exists]" "∃")
|
||||
("exists" "\\exists" t "∃" "[there exists]" "[there exists]" "∃")
|
||||
("nexist" "\\nexists" t "∃" "[there does not exists]" "[there does not exists]" "∄")
|
||||
("nexists" "\\nexists" t "∃" "[there does not exists]" "[there does not exists]" "∄")
|
||||
("empty" "\\empty" t "∅" "[empty set]" "[empty set]" "∅")
|
||||
("emptyset" "\\emptyset" t "∅" "[empty set]" "[empty set]" "∅")
|
||||
("isin" "\\in" t "∈" "[element of]" "[element of]" "∈")
|
||||
@ -365,6 +403,8 @@ loaded, add these packages to `org-export-latex-packages-alist'."
|
||||
("rfloor" "\\rfloor" t "⌋" "[right floor]" "[right floor]" "⌋")
|
||||
("lang" "\\langle" t "⟨" "<" "<" "⟨")
|
||||
("rang" "\\rangle" t "⟩" ">" ">" "⟩")
|
||||
("hbar" "\\hbar" t "ℏ" "hbar" "hbar" "ℏ")
|
||||
("mho" "\\mho" t "℧" "mho" "mho" "℧")
|
||||
|
||||
"** Arrows"
|
||||
("larr" "\\leftarrow" t "←" "<-" "<-" "←")
|
||||
@ -435,7 +475,8 @@ loaded, add these packages to `org-export-latex-packages-alist'."
|
||||
("odot" "\\odot" t "o" "[circled dot]" "[circled dot]" "ʘ")
|
||||
("oplus" "\\oplus" t "⊕" "[circled plus]" "[circled plus]" "⊕")
|
||||
("otimes" "\\otimes" t "⊗" "[circled times]" "[circled times]" "⊗")
|
||||
("checkmark" "\\checkmark" t "✓" "[checkmark]" "[checkmark]" "✓")
|
||||
("check" "\\checkmark" t "✓" "[checkmark]" "[checkmark]" "✓")
|
||||
("checkmark" "\\checkmark" t "✓" "[checkmark]" "[checkmark]" "✓")
|
||||
|
||||
"** Miscellaneous (seldom used)"
|
||||
("para" "\\P{}" nil "¶" "[pilcrow]" "¶" "¶")
|
||||
@ -450,7 +491,8 @@ loaded, add these packages to `org-export-latex-packages-alist'."
|
||||
("rlm" "" nil "‏" "" "" "")
|
||||
|
||||
"** Smilies"
|
||||
("smile" "\\smile" t "☺" ":-)" ":-)" "⌣")
|
||||
("smile" "\\smile" t "⌣" ":-)" ":-)" "⌣")
|
||||
("frown" "\\frown" t "⌢" ":-(" ":-(" "⌢")
|
||||
("smiley" "\\smiley{}" nil "☺" ":-)" ":-)" "☺")
|
||||
("blacksmile" "\\blacksmiley{}" nil "☻" ":-)" ":-)" "☻")
|
||||
("sad" "\\frownie{}" nil "☹" ":-(" ":-(" "☹")
|
||||
@ -462,10 +504,11 @@ loaded, add these packages to `org-export-latex-packages-alist'."
|
||||
("spadesuit" "\\spadesuit" t "♠" "[spades]" "[spades]" "♠")
|
||||
("hearts" "\\heartsuit" t "♥" "[hearts]" "[hearts]" "♥")
|
||||
("heartsuit" "\\heartsuit" t "♥" "[hearts]" "[hearts]" "♥")
|
||||
("diams" "\\diamondsuit" t "♦" "[diamonds]" "[diamonds]" "♦")
|
||||
("diamondsuit" "\\diamondsuit" t "♦" "[diamonds]" "[diamonds]" "♦")
|
||||
("Diamond" "\\diamond" t "⋄" "[diamond]" "[diamond]" "⋄")
|
||||
("loz" "\\diamond" t "◊" "[lozenge]" "[lozenge]" "◊")
|
||||
("diams" "\\diamondsuit" t "♦" "[diamonds]" "[diamonds]" "◆")
|
||||
("diamondsuit" "\\diamondsuit" t "♦" "[diamonds]" "[diamonds]" "◆")
|
||||
("diamond" "\\diamondsuit" t "⋄" "[diamond]" "[diamond]" "◆")
|
||||
("Diamond" "\\diamondsuit" t "⋄" "[diamond]" "[diamond]" "◆")
|
||||
("loz" "\\lozenge" t "◊" "[lozenge]" "[lozenge]" "⧫")
|
||||
)
|
||||
"Default entities used in Org-mode to produce special characters.
|
||||
For details see `org-entities-user'.")
|
||||
|
@ -202,7 +202,7 @@ set the properties in the `org-column' face. For example, set
|
||||
|
||||
Under XEmacs, the rules are simpler, because the XEmacs version of
|
||||
column view defines special faces for each outline level. See the file
|
||||
`org-colview-xemacs.el' for details."
|
||||
`org-colview-xemacs.el' in Org's contrib/ directory for details."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-column-title
|
||||
@ -217,12 +217,6 @@ column view defines special faces for each outline level. See the file
|
||||
"Face for column display of entry properties."
|
||||
:group 'org-faces)
|
||||
|
||||
(when (fboundp 'set-face-attribute)
|
||||
;; Make sure that a fixed-width face is used when we have a column table.
|
||||
(set-face-attribute 'org-column nil
|
||||
:height (face-attribute 'default :height)
|
||||
:family (face-attribute 'default :family)))
|
||||
|
||||
(defface org-agenda-column-dateline
|
||||
(org-compatible-face 'org-column
|
||||
'((t nil)))
|
||||
@ -264,7 +258,7 @@ column view defines special faces for each outline level. See the file
|
||||
'((((class color) (background light)) (:foreground "Purple" :underline t))
|
||||
(((class color) (background dark)) (:foreground "Cyan" :underline t))
|
||||
(t (:underline t)))
|
||||
"Face for links."
|
||||
"Face for footnotes."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-ellipsis
|
||||
@ -394,6 +388,14 @@ determines if it is a foreground or a background color."
|
||||
(string :tag "Color")
|
||||
(sexp :tag "Face")))))
|
||||
|
||||
(defface org-priority ;; originally copied from font-lock-string-face
|
||||
(org-compatible-face 'font-lock-keyword-face
|
||||
'((((class color) (min-colors 16) (background light)) (:foreground "RosyBrown"))
|
||||
(((class color) (min-colors 16) (background dark)) (:foreground "LightSalmon"))
|
||||
(t (:italic t))))
|
||||
"Face used for priority cookies."
|
||||
:group 'org-faces)
|
||||
|
||||
(defcustom org-priority-faces nil
|
||||
"Faces for specific Priorities.
|
||||
This is a list of cons cells, with priority character in the car
|
||||
@ -685,25 +687,28 @@ month and 365.24 days for a year)."
|
||||
|
||||
(defface org-agenda-restriction-lock
|
||||
(org-compatible-face nil
|
||||
'((((class color) (min-colors 88) (background light)) (:background "yellow1"))
|
||||
(((class color) (min-colors 88) (background dark)) (:background "skyblue4"))
|
||||
(((class color) (min-colors 16) (background light)) (:background "yellow1"))
|
||||
(((class color) (min-colors 16) (background dark)) (:background "skyblue4"))
|
||||
'((((class color) (min-colors 88) (background light)) (:background "#eeeeee"))
|
||||
(((class color) (min-colors 88) (background dark)) (:background "#1C1C1C"))
|
||||
(((class color) (min-colors 16) (background light)) (:background "#eeeeee"))
|
||||
(((class color) (min-colors 16) (background dark)) (:background "#1C1C1C"))
|
||||
(((class color) (min-colors 8)) (:background "cyan" :foreground "black"))
|
||||
(t (:inverse-video t))))
|
||||
"Face for showing the agenda restriction lock."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-agenda-filter-tags
|
||||
(org-compatible-face 'mode-line
|
||||
nil)
|
||||
(org-compatible-face 'mode-line nil)
|
||||
"Face for tag(s) in the mode-line when filtering the agenda."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-agenda-filter-regexp
|
||||
(org-compatible-face 'mode-line nil)
|
||||
"Face for regexp(s) in the mode-line when filtering the agenda."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-agenda-filter-category
|
||||
(org-compatible-face 'mode-line
|
||||
nil)
|
||||
"Face for tag(s) in the mode-line when filtering the agenda."
|
||||
(org-compatible-face 'mode-line nil)
|
||||
"Face for categories(s) in the mode-line when filtering the agenda."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-time-grid ;; originally copied from font-lock-variable-name-face
|
||||
@ -718,20 +723,17 @@ month and 365.24 days for a year)."
|
||||
"Face used to show the current time in the time grid.")
|
||||
|
||||
(defface org-agenda-diary
|
||||
(org-compatible-face 'default
|
||||
nil)
|
||||
(org-compatible-face 'default nil)
|
||||
"Face used for agenda entries that come from the Emacs diary."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-agenda-calendar-event
|
||||
(org-compatible-face 'default
|
||||
nil)
|
||||
(org-compatible-face 'default nil)
|
||||
"Face used to show events and appointments in the agenda."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-agenda-calendar-sexp
|
||||
(org-compatible-face 'default
|
||||
nil)
|
||||
(org-compatible-face 'default nil)
|
||||
"Face used to show events computed from a S-expression."
|
||||
:group 'org-faces)
|
||||
|
||||
@ -757,7 +759,7 @@ level org-n-level-faces"
|
||||
:version "24.1"
|
||||
:type 'boolean)
|
||||
|
||||
(defface org-latex-and-export-specials
|
||||
(defface org-latex-and-related
|
||||
(let ((font (cond ((assq :inherit custom-face-attributes)
|
||||
'(:inherit underline))
|
||||
(t '(:underline t)))))
|
||||
@ -770,8 +772,24 @@ level org-n-level-faces"
|
||||
(((class color) (background dark))
|
||||
(:foreground "burlywood"))
|
||||
(t (,@font))))
|
||||
"Face used to highlight math latex and other special exporter stuff."
|
||||
:group 'org-faces)
|
||||
"Face used to highlight LaTeX data, entities and sub/superscript."
|
||||
:group 'org-faces
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0"))
|
||||
|
||||
(defface org-macro
|
||||
(org-compatible-face 'org-latex-and-related nil)
|
||||
"Face for macros."
|
||||
:group 'org-faces
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0"))
|
||||
|
||||
(defface org-tag-group
|
||||
(org-compatible-face 'org-tag nil)
|
||||
"Face for group tags."
|
||||
:group 'org-faces
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0"))
|
||||
|
||||
(org-copy-face 'mode-line 'org-mode-line-clock
|
||||
"Face used for clock display in mode line.")
|
||||
|
@ -42,8 +42,6 @@
|
||||
(declare-function org-back-to-heading "org" (&optional invisible-ok))
|
||||
(declare-function org-combine-plists "org" (&rest plists))
|
||||
(declare-function org-end-of-subtree "org" (&optional invisible-ok to-heading))
|
||||
(declare-function org-export-preprocess-string "org-exp"
|
||||
(string &rest parameters))
|
||||
(declare-function org-fill-paragraph "org" (&optional justify))
|
||||
(declare-function org-icompleting-read "org" (&rest args))
|
||||
(declare-function org-id-uuid "org-id" ())
|
||||
@ -87,7 +85,7 @@
|
||||
"Regular expression matching the definition of a footnote.")
|
||||
|
||||
(defconst org-footnote-forbidden-blocks
|
||||
'("ascii" "beamer" "comment" "docbook" "example" "html" "latex" "odt" "src")
|
||||
'("ascii" "beamer" "comment" "example" "html" "latex" "odt" "src")
|
||||
"Names of blocks where footnotes are not allowed.")
|
||||
|
||||
(defgroup org-footnote nil
|
||||
@ -96,15 +94,19 @@
|
||||
:group 'org)
|
||||
|
||||
(defcustom org-footnote-section "Footnotes"
|
||||
"Outline heading containing footnote definitions before export.
|
||||
This can be nil, to place footnotes locally at the end of the current
|
||||
outline node. If can also be the name of a special outline heading
|
||||
under which footnotes should be put.
|
||||
"Outline heading containing footnote definitions.
|
||||
|
||||
This can be nil, to place footnotes locally at the end of the
|
||||
current outline node. If can also be the name of a special
|
||||
outline heading under which footnotes should be put.
|
||||
|
||||
This variable defines the place where Org puts the definition
|
||||
automatically, i.e. when creating the footnote, and when sorting the notes.
|
||||
However, by hand you may place definitions *anywhere*.
|
||||
If this is a string, during export, all subtrees starting with this
|
||||
heading will be removed after extracting footnote definitions."
|
||||
automatically, i.e. when creating the footnote, and when sorting
|
||||
the notes. However, by hand you may place definitions
|
||||
*anywhere*.
|
||||
|
||||
If this is a string, during export, all subtrees starting with
|
||||
this heading will be ignored."
|
||||
:group 'org-footnote
|
||||
:type '(choice
|
||||
(string :tag "Collect footnotes under heading")
|
||||
@ -136,13 +138,13 @@ will be used to define the footnote at the reference position."
|
||||
"Non-nil means define automatically new labels for footnotes.
|
||||
Possible values are:
|
||||
|
||||
nil prompt the user for each label
|
||||
t create unique labels of the form [fn:1], [fn:2], ...
|
||||
confirm like t, but let the user edit the created value. In particular,
|
||||
the label can be removed from the minibuffer, to create
|
||||
nil Prompt the user for each label.
|
||||
t Create unique labels of the form [fn:1], [fn:2], etc.
|
||||
confirm Like t, but let the user edit the created value.
|
||||
The label can be removed from the minibuffer to create
|
||||
an anonymous footnote.
|
||||
random Automatically generate a unique, random label.
|
||||
plain Automatically create plain number labels like [1]"
|
||||
plain Automatically create plain number labels like [1]."
|
||||
:group 'org-footnote
|
||||
:type '(choice
|
||||
(const :tag "Prompt for label" nil)
|
||||
@ -164,6 +166,7 @@ The main values of this variable can be set with in-buffer options:
|
||||
#+STARTUP: nofnadjust"
|
||||
:group 'org-footnote
|
||||
:type '(choice
|
||||
(const :tag "No adjustment" nil)
|
||||
(const :tag "Renumber" renumber)
|
||||
(const :tag "Sort" sort)
|
||||
(const :tag "Renumber and Sort" t)))
|
||||
@ -182,8 +185,6 @@ extracted will be filled again."
|
||||
(not (or (org-in-commented-line)
|
||||
(org-in-indented-comment-line)
|
||||
(org-inside-LaTeX-fragment-p)
|
||||
;; Avoid protected environments (LaTeX export)
|
||||
(get-text-property (point) 'org-protected)
|
||||
;; Avoid literal example.
|
||||
(org-in-verbatim-emphasis)
|
||||
(save-excursion
|
||||
@ -230,13 +231,7 @@ positions, and the definition, when inlined."
|
||||
(org-in-regexp org-bracket-link-regexp))))
|
||||
(and linkp (< (point) (cdr linkp))))))
|
||||
;; Verify point doesn't belong to a LaTeX macro.
|
||||
;; Beware though, when two footnotes are side by
|
||||
;; side, once the first one is changed into LaTeX,
|
||||
;; the second one might then be considered as an
|
||||
;; optional argument of the command. Thus, check
|
||||
;; the `org-protected' property of that command.
|
||||
(or (not (org-inside-latex-macro-p))
|
||||
(get-text-property (1- beg) 'org-protected)))
|
||||
(not (org-inside-latex-macro-p)))
|
||||
(list label beg end
|
||||
;; Definition: ensure this is an inline footnote first.
|
||||
(and (or (not label) (match-string 1))
|
||||
@ -257,11 +252,12 @@ otherwise."
|
||||
(when (save-excursion (beginning-of-line) (org-footnote-in-valid-context-p))
|
||||
(save-excursion
|
||||
(end-of-line)
|
||||
;; Footnotes definitions are separated by new headlines or blank
|
||||
;; lines.
|
||||
(let ((lim (save-excursion (re-search-backward
|
||||
(concat org-outline-regexp-bol
|
||||
"\\|^[ \t]*$") nil t))))
|
||||
;; Footnotes definitions are separated by new headlines, another
|
||||
;; footnote definition or 2 blank lines.
|
||||
(let ((lim (save-excursion
|
||||
(re-search-backward
|
||||
(concat org-outline-regexp-bol
|
||||
"\\|^\\([ \t]*\n\\)\\{2,\\}") nil t))))
|
||||
(when (re-search-backward org-footnote-definition-re lim t)
|
||||
(let ((label (org-match-string-no-properties 1))
|
||||
(beg (match-beginning 0))
|
||||
@ -277,7 +273,7 @@ otherwise."
|
||||
(re-search-forward
|
||||
(concat org-outline-regexp-bol "\\|"
|
||||
org-footnote-definition-re "\\|"
|
||||
"^[ \t]*$") bound 'move))
|
||||
"^\\([ \t]*\n\\)\\{2,\\}") bound 'move))
|
||||
(match-beginning 0)
|
||||
(point)))))
|
||||
(list label beg end
|
||||
@ -602,38 +598,15 @@ With prefix arg SPECIAL, offer additional commands in a menu."
|
||||
(org-footnote-goto-previous-reference (car tmp)))
|
||||
(t (org-footnote-new)))))
|
||||
|
||||
(defvar org-footnote-insert-pos-for-preprocessor 'point-max
|
||||
"See `org-footnote-normalize'.")
|
||||
|
||||
(defvar org-export-footnotes-seen) ; silence byte-compiler
|
||||
(defvar org-export-footnotes-data) ; silence byte-compiler
|
||||
|
||||
;;;###autoload
|
||||
(defun org-footnote-normalize (&optional sort-only export-props)
|
||||
(defun org-footnote-normalize (&optional sort-only)
|
||||
"Collect the footnotes in various formats and normalize them.
|
||||
|
||||
This finds the different sorts of footnotes allowed in Org, and
|
||||
normalizes them to the usual [N] format that is understood by the
|
||||
Org-mode exporters.
|
||||
normalizes them to the usual [N] format.
|
||||
|
||||
When SORT-ONLY is set, only sort the footnote definitions into the
|
||||
referenced sequence.
|
||||
|
||||
If Org is amidst an export process, EXPORT-PROPS will hold the
|
||||
export properties of the buffer.
|
||||
|
||||
When EXPORT-PROPS is non-nil, the default action is to insert
|
||||
normalized footnotes towards the end of the pre-processing
|
||||
buffer. Some exporters (docbook, odt...) expect footnote
|
||||
definitions to be available before any references to them. Such
|
||||
exporters can let bind `org-footnote-insert-pos-for-preprocessor'
|
||||
to symbol `point-min' to achieve the desired behaviour.
|
||||
|
||||
Additional note on `org-footnote-insert-pos-for-preprocessor':
|
||||
1. This variable has not effect when FOR-PREPROCESSOR is nil.
|
||||
2. This variable (potentially) obviates the need for extra scan
|
||||
of pre-processor buffer as witnessed in
|
||||
`org-export-docbook-get-footnotes'."
|
||||
referenced sequence."
|
||||
;; This is based on Paul's function, but rewritten.
|
||||
;;
|
||||
;; Re-create `org-with-limited-levels', but not limited to Org
|
||||
@ -643,17 +616,12 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
|
||||
org-inlinetask-min-level
|
||||
(1- org-inlinetask-min-level)))
|
||||
(nstars (and limit-level
|
||||
(if org-odd-levels-only
|
||||
(and limit-level (1- (* limit-level 2)))
|
||||
(if org-odd-levels-only (1- (* limit-level 2))
|
||||
limit-level)))
|
||||
(org-outline-regexp
|
||||
(concat "\\*" (if nstars (format "\\{1,%d\\} " nstars) "+ ")))
|
||||
;; Determine the highest marker used so far.
|
||||
(ref-table (when export-props org-export-footnotes-seen))
|
||||
(count (if (and export-props ref-table)
|
||||
(apply 'max (mapcar (lambda (e) (nth 1 e)) ref-table))
|
||||
0))
|
||||
ins-point ref)
|
||||
(count 0)
|
||||
ins-point ref ref-table)
|
||||
(save-excursion
|
||||
;; 1. Find every footnote reference, extract the definition, and
|
||||
;; collect that data in REF-TABLE. If SORT-ONLY is nil, also
|
||||
@ -675,15 +643,10 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
|
||||
;; Replace footnote reference with [MARKER]. Maybe fill
|
||||
;; paragraph once done. If SORT-ONLY is non-nil, only move
|
||||
;; to the end of reference found to avoid matching it twice.
|
||||
;; If EXPORT-PROPS isn't nil, also add `org-footnote'
|
||||
;; property to it, so it can be easily recognized by
|
||||
;; exporters.
|
||||
(if sort-only (goto-char (nth 2 ref))
|
||||
(delete-region (nth 1 ref) (nth 2 ref))
|
||||
(goto-char (nth 1 ref))
|
||||
(let ((new-ref (format "[%d]" marker)))
|
||||
(when export-props (org-add-props new-ref '(org-footnote t)))
|
||||
(insert new-ref))
|
||||
(insert (format "[%d]" marker))
|
||||
(and inlinep
|
||||
org-footnote-fill-after-inline-note-extraction
|
||||
(org-fill-paragraph)))
|
||||
@ -691,22 +654,9 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
|
||||
;; type (INLINEP) and position (POS) to REF-TABLE if data
|
||||
;; was unknown.
|
||||
(unless a
|
||||
(let ((def (or (nth 3 ref) ; inline
|
||||
(and export-props
|
||||
(cdr (assoc lbl org-export-footnotes-data)))
|
||||
(let ((def (or (nth 3 ref) ; Inline definition.
|
||||
(nth 3 (org-footnote-get-definition lbl)))))
|
||||
(push (list lbl marker
|
||||
;; When exporting, each definition goes
|
||||
;; through `org-export-preprocess-string' so
|
||||
;; it is ready to insert in the
|
||||
;; backend-specific buffer.
|
||||
(if (and export-props def)
|
||||
(let ((parameters
|
||||
(org-combine-plists
|
||||
export-props
|
||||
'(:todo-keywords t :tags t :priority t))))
|
||||
(apply #'org-export-preprocess-string def parameters))
|
||||
def)
|
||||
(push (list lbl marker def
|
||||
;; Reference beginning position is a marker
|
||||
;; to preserve it during further buffer
|
||||
;; modifications.
|
||||
@ -728,14 +678,7 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
|
||||
(unless (bolp) (newline)))
|
||||
;; No footnote section set: Footnotes will be added at the end
|
||||
;; of the section containing their first reference.
|
||||
;; Nevertheless, in an export situation, set insertion point to
|
||||
;; `point-max' by default.
|
||||
((derived-mode-p 'org-mode)
|
||||
(when export-props
|
||||
(goto-char (point-max))
|
||||
(skip-chars-backward " \r\t\n")
|
||||
(forward-line)
|
||||
(delete-region (point) (point-max))))
|
||||
((derived-mode-p 'org-mode))
|
||||
(t
|
||||
;; Remove any left-over tag in the buffer, if one is set up.
|
||||
(when org-footnote-tag-for-non-org-mode-files
|
||||
@ -753,14 +696,7 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
|
||||
(re-search-backward message-signature-separator nil t))
|
||||
(beginning-of-line)
|
||||
(goto-char (point-max)))))
|
||||
;; During export, `org-footnote-insert-pos-for-preprocessor' has
|
||||
;; precedence over previously found position.
|
||||
(setq ins-point
|
||||
(copy-marker
|
||||
(if (and export-props
|
||||
(eq org-footnote-insert-pos-for-preprocessor 'point-min))
|
||||
(point-min)
|
||||
(point))))
|
||||
(setq ins-point (point-marker))
|
||||
;; 3. Clean-up REF-TABLE.
|
||||
(setq ref-table
|
||||
(delq nil
|
||||
@ -791,26 +727,22 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
|
||||
;; No footnote: exit.
|
||||
((not ref-table))
|
||||
;; Cases when footnotes should be inserted in one place.
|
||||
((or (not (derived-mode-p 'org-mode))
|
||||
org-footnote-section
|
||||
export-props)
|
||||
((or (not (derived-mode-p 'org-mode)) org-footnote-section)
|
||||
;; Insert again the section title, if any. Ensure that title,
|
||||
;; or the subsequent footnotes, will be separated by a blank
|
||||
;; lines from the rest of the document. In an Org buffer,
|
||||
;; separate section with a blank line, unless explicitly
|
||||
;; stated in `org-blank-before-new-entry'.
|
||||
(cond
|
||||
((not (derived-mode-p 'org-mode))
|
||||
(skip-chars-backward " \t\n\r")
|
||||
(delete-region (point) ins-point)
|
||||
(unless (bolp) (newline))
|
||||
(when org-footnote-tag-for-non-org-mode-files
|
||||
(insert "\n" org-footnote-tag-for-non-org-mode-files "\n")))
|
||||
((and org-footnote-section (not export-props))
|
||||
(if (not (derived-mode-p 'org-mode))
|
||||
(progn (skip-chars-backward " \t\n\r")
|
||||
(delete-region (point) ins-point)
|
||||
(unless (bolp) (newline))
|
||||
(when org-footnote-tag-for-non-org-mode-files
|
||||
(insert "\n" org-footnote-tag-for-non-org-mode-files "\n")))
|
||||
(when (and (cdr (assq 'heading org-blank-before-new-entry))
|
||||
(zerop (save-excursion (org-back-over-empty-lines))))
|
||||
(insert "\n"))
|
||||
(insert "* " org-footnote-section "\n")))
|
||||
(insert "* " org-footnote-section "\n"))
|
||||
(set-marker ins-point nil)
|
||||
;; Insert the footnotes, separated by a blank line.
|
||||
(insert
|
||||
@ -820,10 +752,7 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
|
||||
(set-marker (nth 4 x) nil)
|
||||
(format "\n[%s] %s" (nth (if sort-only 0 1) x) (nth 2 x)))
|
||||
ref-table "\n"))
|
||||
(unless (eobp) (insert "\n\n"))
|
||||
;; When exporting, add newly inserted markers along with their
|
||||
;; associated definition to `org-export-footnotes-seen'.
|
||||
(when export-props (setq org-export-footnotes-seen ref-table)))
|
||||
(unless (eobp) (insert "\n\n")))
|
||||
;; Each footnote definition has to be inserted at the end of
|
||||
;; the section where its first reference belongs.
|
||||
(t
|
||||
|
@ -43,8 +43,7 @@
|
||||
(declare-function gnus-summary-last-subject "gnus-sum" nil)
|
||||
;; Customization variables
|
||||
|
||||
(when (fboundp 'defvaralias)
|
||||
(defvaralias 'org-usenet-links-prefer-google 'org-gnus-prefer-web-links))
|
||||
(org-defvaralias 'org-usenet-links-prefer-google 'org-gnus-prefer-web-links)
|
||||
|
||||
(defcustom org-gnus-prefer-web-links nil
|
||||
"If non-nil, `org-store-link' creates web links to Google groups or Gmane.
|
||||
@ -66,6 +65,12 @@ this variable to `t'."
|
||||
:version "24.1"
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-gnus-no-server nil
|
||||
"Should Gnus be started using `gnus-no-server'?"
|
||||
:group 'org-gnus
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:type 'boolean)
|
||||
|
||||
;; Install the link type
|
||||
(org-add-link-type "gnus" 'org-gnus-open)
|
||||
@ -287,7 +292,7 @@ If `org-store-link' was called with a prefix arg the meaning of
|
||||
|
||||
(defun org-gnus-no-new-news ()
|
||||
"Like `M-x gnus' but doesn't check for new news."
|
||||
(if (not (gnus-alive-p)) (gnus)))
|
||||
(if (not (gnus-alive-p)) (if org-gnus-no-server (gnus-no-server) (gnus))))
|
||||
|
||||
(provide 'org-gnus)
|
||||
|
||||
|
@ -85,6 +85,12 @@ today's agenda, even if they are not scheduled."
|
||||
:version "24.1"
|
||||
:type 'character)
|
||||
|
||||
(defcustom org-habit-show-done-always-green nil
|
||||
"Non-nil means DONE days will always be green in the consistency graph.
|
||||
It will be green even if it was done after the deadline."
|
||||
:group 'org-habit
|
||||
:type 'boolean)
|
||||
|
||||
(defface org-habit-clear-face
|
||||
'((((background light)) (:background "#8270f9"))
|
||||
(((background dark)) (:background "blue")))
|
||||
@ -272,8 +278,9 @@ Habits are assigned colors on the following basis:
|
||||
(if donep
|
||||
'(org-habit-ready-face . org-habit-ready-future-face)
|
||||
'(org-habit-alert-face . org-habit-alert-future-face)))
|
||||
(t
|
||||
'(org-habit-overdue-face . org-habit-overdue-future-face)))))
|
||||
((and org-habit-show-done-always-green donep)
|
||||
'(org-habit-ready-face . org-habit-ready-future-face))
|
||||
(t '(org-habit-overdue-face . org-habit-overdue-future-face)))))
|
||||
|
||||
(defun org-habit-build-graph (habit starting current ending)
|
||||
"Build a graph for the given HABIT, from STARTING to ENDING.
|
||||
|
@ -186,7 +186,7 @@ the link."
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-id-locations-file (convert-standard-filename
|
||||
"~/.emacs.d/.org-id-locations")
|
||||
(concat user-emacs-directory ".org-id-locations"))
|
||||
"The file for remembering in which file an ID was defined.
|
||||
This variable is only relevant when `org-id-track-globally' is set."
|
||||
:group 'org-id
|
||||
@ -343,7 +343,7 @@ So a typical ID could look like \"Org:4nd91V40HI\"."
|
||||
(unless (org-uuidgen-p unique)
|
||||
(setq unique (org-id-uuid))))
|
||||
((eq org-id-method 'org)
|
||||
(let* ((etime (org-id-reverse-string (org-id-time-to-b36)))
|
||||
(let* ((etime (org-reverse-string (org-id-time-to-b36)))
|
||||
(postfix (if org-id-include-domain
|
||||
(progn
|
||||
(require 'message)
|
||||
@ -376,9 +376,6 @@ So a typical ID could look like \"Org:4nd91V40HI\"."
|
||||
(substring rnd 18 20)
|
||||
(substring rnd 20 32))))
|
||||
|
||||
(defun org-id-reverse-string (s)
|
||||
(mapconcat 'char-to-string (nreverse (string-to-list s)) ""))
|
||||
|
||||
(defun org-id-int-to-b36-one-digit (i)
|
||||
"Turn an integer between 0 and 61 into a single character 0..9, A..Z, a..z."
|
||||
(cond
|
||||
@ -432,7 +429,7 @@ and time is the usual three-integer representation of time."
|
||||
(if (= 2 (length parts))
|
||||
(setq prefix (car parts) time (nth 1 parts))
|
||||
(setq prefix nil time (nth 0 parts)))
|
||||
(setq time (org-id-reverse-string time))
|
||||
(setq time (org-reverse-string time))
|
||||
(setq time (list (org-id-b36-to-int (substring time 0 4))
|
||||
(org-id-b36-to-int (substring time 4 8))
|
||||
(org-id-b36-to-int (substring time 8 12))))
|
||||
@ -440,6 +437,7 @@ and time is the usual three-integer representation of time."
|
||||
|
||||
;; Storing ID locations (files)
|
||||
|
||||
;;;###autoload
|
||||
(defun org-id-update-id-locations (&optional files silent)
|
||||
"Scan relevant files for IDs.
|
||||
Store the relation between files and corresponding IDs.
|
||||
@ -530,7 +528,9 @@ When CHECK is given, prepare detailed information about duplicate IDs."
|
||||
(org-id-hash-to-alist org-id-locations)
|
||||
org-id-locations)))
|
||||
(with-temp-file org-id-locations-file
|
||||
(print out (current-buffer))))))
|
||||
(let ((print-level nil)
|
||||
(print-length nil))
|
||||
(print out (current-buffer)))))))
|
||||
|
||||
(defun org-id-locations-load ()
|
||||
"Read the data from `org-id-locations-file'."
|
||||
|
@ -88,7 +88,7 @@ This is used locally in each buffer being initialized.")
|
||||
(defvar org-hide-leading-stars-before-indent-mode nil
|
||||
"Used locally.")
|
||||
(defvar org-indent-modified-headline-flag nil
|
||||
"Non-nil means the last deletion operated on an headline.
|
||||
"Non-nil means the last deletion operated on a headline.
|
||||
It is modified by `org-indent-notify-modified-headline'.")
|
||||
|
||||
|
||||
@ -147,8 +147,8 @@ useful to make it ever so slightly different."
|
||||
|
||||
(defsubst org-indent-remove-properties (beg end)
|
||||
"Remove indentations between BEG and END."
|
||||
(with-silent-modifications
|
||||
(remove-text-properties beg end '(line-prefix nil wrap-prefix nil))))
|
||||
(org-with-silent-modifications
|
||||
(remove-text-properties beg end '(line-prefix nil wrap-prefix nil))))
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode org-indent-mode
|
||||
@ -182,11 +182,11 @@ during idle time."
|
||||
(org-set-local 'org-hide-leading-stars-before-indent-mode
|
||||
org-hide-leading-stars)
|
||||
(org-set-local 'org-hide-leading-stars t))
|
||||
(add-hook 'filter-buffer-substring-functions
|
||||
(lambda (fun start end delete)
|
||||
(org-indent-remove-properties-from-string
|
||||
(funcall fun start end delete)))
|
||||
nil t)
|
||||
(org-add-hook 'filter-buffer-substring-functions
|
||||
(lambda (fun start end delete)
|
||||
(org-indent-remove-properties-from-string
|
||||
(funcall fun start end delete)))
|
||||
nil t)
|
||||
(org-add-hook 'after-change-functions 'org-indent-refresh-maybe nil 'local)
|
||||
(org-add-hook 'before-change-functions
|
||||
'org-indent-notify-modified-headline nil 'local)
|
||||
@ -213,8 +213,7 @@ during idle time."
|
||||
(remove-hook 'filter-buffer-substring-functions
|
||||
(lambda (fun start end delete)
|
||||
(org-indent-remove-properties-from-string
|
||||
(funcall fun start end delete)))
|
||||
t)
|
||||
(funcall fun start end delete))))
|
||||
(remove-hook 'after-change-functions 'org-indent-refresh-maybe 'local)
|
||||
(remove-hook 'before-change-functions
|
||||
'org-indent-notify-modified-headline 'local)
|
||||
@ -343,50 +342,50 @@ stopped."
|
||||
;; 2. For each line, set `line-prefix' and `wrap-prefix'
|
||||
;; properties depending on the type of line (headline,
|
||||
;; inline task, item or other).
|
||||
(with-silent-modifications
|
||||
(while (and (<= (point) end) (not (eobp)))
|
||||
(cond
|
||||
;; When in asynchronous mode, check if interrupt is
|
||||
;; required.
|
||||
((and delay (input-pending-p)) (throw 'interrupt (point)))
|
||||
;; In asynchronous mode, take a break of
|
||||
;; `org-indent-agent-resume-delay' every DELAY to avoid
|
||||
;; blocking any other idle timer or process output.
|
||||
((and delay (time-less-p time-limit (current-time)))
|
||||
(setq org-indent-agent-resume-timer
|
||||
(run-with-idle-timer
|
||||
(time-add (current-idle-time)
|
||||
org-indent-agent-resume-delay)
|
||||
nil #'org-indent-initialize-agent))
|
||||
(throw 'interrupt (point)))
|
||||
;; Headline or inline task.
|
||||
((looking-at org-outline-regexp)
|
||||
(let* ((nstars (- (match-end 0) (match-beginning 0) 1))
|
||||
(line (* added-ind-per-lvl (1- nstars)))
|
||||
(wrap (+ line (1+ nstars))))
|
||||
(cond
|
||||
;; Headline: new value for PF.
|
||||
((looking-at limited-re)
|
||||
(org-indent-set-line-properties line wrap t)
|
||||
(setq pf wrap))
|
||||
;; End of inline task: PF-INLINE is now nil.
|
||||
((looking-at "\\*+ end[ \t]*$")
|
||||
(org-indent-set-line-properties line wrap 'inline)
|
||||
(setq pf-inline nil))
|
||||
;; Start of inline task. Determine if it contains
|
||||
;; text, or if it is only one line long. Set
|
||||
;; PF-INLINE accordingly.
|
||||
(t (org-indent-set-line-properties line wrap 'inline)
|
||||
(setq pf-inline (and (org-inlinetask-in-task-p) wrap))))))
|
||||
;; List item: `wrap-prefix' is set where body starts.
|
||||
((org-at-item-p)
|
||||
(let* ((line (or pf-inline pf 0))
|
||||
(wrap (+ (org-list-item-body-column (point)) line)))
|
||||
(org-indent-set-line-properties line wrap nil)))
|
||||
;; Normal line: use PF-INLINE, PF or nil as prefixes.
|
||||
(t (let* ((line (or pf-inline pf 0))
|
||||
(wrap (+ line (org-get-indentation))))
|
||||
(org-indent-set-line-properties line wrap nil))))))))))
|
||||
(org-with-silent-modifications
|
||||
(while (and (<= (point) end) (not (eobp)))
|
||||
(cond
|
||||
;; When in asynchronous mode, check if interrupt is
|
||||
;; required.
|
||||
((and delay (input-pending-p)) (throw 'interrupt (point)))
|
||||
;; In asynchronous mode, take a break of
|
||||
;; `org-indent-agent-resume-delay' every DELAY to avoid
|
||||
;; blocking any other idle timer or process output.
|
||||
((and delay (time-less-p time-limit (current-time)))
|
||||
(setq org-indent-agent-resume-timer
|
||||
(run-with-idle-timer
|
||||
(time-add (current-idle-time)
|
||||
org-indent-agent-resume-delay)
|
||||
nil #'org-indent-initialize-agent))
|
||||
(throw 'interrupt (point)))
|
||||
;; Headline or inline task.
|
||||
((looking-at org-outline-regexp)
|
||||
(let* ((nstars (- (match-end 0) (match-beginning 0) 1))
|
||||
(line (* added-ind-per-lvl (1- nstars)))
|
||||
(wrap (+ line (1+ nstars))))
|
||||
(cond
|
||||
;; Headline: new value for PF.
|
||||
((looking-at limited-re)
|
||||
(org-indent-set-line-properties line wrap t)
|
||||
(setq pf wrap))
|
||||
;; End of inline task: PF-INLINE is now nil.
|
||||
((looking-at "\\*+ end[ \t]*$")
|
||||
(org-indent-set-line-properties line wrap 'inline)
|
||||
(setq pf-inline nil))
|
||||
;; Start of inline task. Determine if it contains
|
||||
;; text, or if it is only one line long. Set
|
||||
;; PF-INLINE accordingly.
|
||||
(t (org-indent-set-line-properties line wrap 'inline)
|
||||
(setq pf-inline (and (org-inlinetask-in-task-p) wrap))))))
|
||||
;; List item: `wrap-prefix' is set where body starts.
|
||||
((org-at-item-p)
|
||||
(let* ((line (or pf-inline pf 0))
|
||||
(wrap (+ (org-list-item-body-column (point)) line)))
|
||||
(org-indent-set-line-properties line wrap nil)))
|
||||
;; Normal line: use PF-INLINE, PF or nil as prefixes.
|
||||
(t (let* ((line (or pf-inline pf 0))
|
||||
(wrap (+ line (org-get-indentation))))
|
||||
(org-indent-set-line-properties line wrap nil))))))))))
|
||||
|
||||
(defun org-indent-notify-modified-headline (beg end)
|
||||
"Set `org-indent-modified-headline-flag' depending on context.
|
||||
@ -413,7 +412,7 @@ range of inserted text. DUMMY is an unused argument.
|
||||
This function is meant to be called by `after-change-functions'."
|
||||
(when org-indent-mode
|
||||
(save-match-data
|
||||
;; If an headline was modified or inserted, set properties until
|
||||
;; If a headline was modified or inserted, set properties until
|
||||
;; next headline.
|
||||
(if (or org-indent-modified-headline-flag
|
||||
(save-excursion
|
||||
|
@ -27,31 +27,25 @@
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; This module implements inline tasks in Org-mode. Inline tasks are
|
||||
;; tasks that have all the properties of normal outline nodes, including
|
||||
;; the ability to store meta data like scheduling dates, TODO state, tags
|
||||
;; and properties. However, these nodes are treated specially by the
|
||||
;; visibility cycling and export commands.
|
||||
;; tasks that have all the properties of normal outline nodes,
|
||||
;; including the ability to store meta data like scheduling dates,
|
||||
;; TODO state, tags and properties. However, these nodes are treated
|
||||
;; specially by the visibility cycling.
|
||||
;;
|
||||
;; Visibility cycling exempts these nodes from cycling. So whenever their
|
||||
;; parent is opened, so are these tasks. This will only work with
|
||||
;; `org-cycle', so if you are also using other commands to show/hide
|
||||
;; entries, you will occasionally find these tasks to behave like
|
||||
;; all other outline nodes, seemingly splitting the text of the parent
|
||||
;; into children.
|
||||
;; Visibility cycling exempts these nodes from cycling. So whenever
|
||||
;; their parent is opened, so are these tasks. This will only work
|
||||
;; with `org-cycle', so if you are also using other commands to
|
||||
;; show/hide entries, you will occasionally find these tasks to behave
|
||||
;; like all other outline nodes, seemingly splitting the text of the
|
||||
;; parent into children.
|
||||
;;
|
||||
;; Export commands do not treat these nodes as part of the sectioning
|
||||
;; structure, but as a special inline text that is either removed, or
|
||||
;; formatted in some special way. This in handled by
|
||||
;; `org-inlinetask-export' and `org-inlinetask-export-templates'
|
||||
;; variables.
|
||||
;; Special fontification of inline tasks, so that they can be
|
||||
;; immediately recognized. From the stars of the headline, only the
|
||||
;; first and the last two will be visible, the others will be hidden
|
||||
;; using the `org-hide' face.
|
||||
;;
|
||||
;; Special fontification of inline tasks, so that they can be immediately
|
||||
;; recognized. From the stars of the headline, only the first and the
|
||||
;; last two will be visible, the others will be hidden using the
|
||||
;; `org-hide' face.
|
||||
;;
|
||||
;; An inline task is identified solely by a minimum outline level, given
|
||||
;; by the variable `org-inlinetask-min-level', default 15.
|
||||
;; An inline task is identified solely by a minimum outline level,
|
||||
;; given by the variable `org-inlinetask-min-level', default 15.
|
||||
;;
|
||||
;; If you need to have a time planning line (DEADLINE etc), drawers,
|
||||
;; for example LOGBOOK of PROPERTIES, or even normal text as part of
|
||||
@ -111,69 +105,6 @@ When nil, the first star is not shown."
|
||||
:tag "Org Inline Tasks"
|
||||
:group 'org-structure)
|
||||
|
||||
(defcustom org-inlinetask-export t
|
||||
"Non-nil means export inline tasks.
|
||||
When nil, they will not be exported."
|
||||
:group 'org-inlinetask
|
||||
:type 'boolean)
|
||||
|
||||
(defvar org-inlinetask-export-templates
|
||||
'((html "<div class=\"inlinetask\"><b>%s%s</b><br />%s</div>"
|
||||
'((unless (eq todo "")
|
||||
(format "<span class=\"%s %s\">%s%s</span> "
|
||||
class todo todo priority))
|
||||
heading content))
|
||||
(odt "%s" '((org-odt-format-inlinetask heading content
|
||||
todo priority tags)))
|
||||
|
||||
(latex "\\begin\{description\}\n\\item[%s%s]~%s\\end\{description\}"
|
||||
'((unless (eq todo "") (format "\\textsc\{%s%s\} " todo priority))
|
||||
heading content))
|
||||
(ascii " -- %s%s%s"
|
||||
'((unless (eq todo "") (format "%s%s " todo priority))
|
||||
heading
|
||||
(unless (eq content "")
|
||||
(format "\n ¦ %s"
|
||||
(mapconcat 'identity (org-split-string content "\n")
|
||||
"\n ¦ ")))))
|
||||
(docbook "<variablelist>
|
||||
<varlistentry>
|
||||
<term>%s%s</term>
|
||||
<listitem><para>%s</para></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>"
|
||||
'((unless (eq todo "") (format "%s%s " todo priority))
|
||||
heading content)))
|
||||
"Templates for inline tasks in various exporters.
|
||||
|
||||
This variable is an alist in the shape of \(BACKEND STRING OBJECTS\).
|
||||
|
||||
BACKEND is the name of the backend for the template \(ascii, html...\).
|
||||
|
||||
STRING is a format control string.
|
||||
|
||||
OBJECTS is a list of elements to be substituted into the format
|
||||
string. They can be of any type, from a string to a form
|
||||
returning a value (thus allowing conditional insertion). A nil
|
||||
object will be substituted as the empty string. Obviously, there
|
||||
must be at least as many objects as %-sequences in the format
|
||||
string.
|
||||
|
||||
Moreover, the following special keywords are provided: `todo',
|
||||
`priority', `heading', `content', `tags'. If some of them are not
|
||||
defined in an inline task, their value is the empty string.
|
||||
|
||||
As an example, valid associations are:
|
||||
|
||||
\(html \"<ul><li>%s <p>%s</p></li></ul>\" \(heading content\)\)
|
||||
|
||||
or, with the additional package \"todonotes\" for LaTeX,
|
||||
|
||||
\(latex \"\\todo[inline]{\\textbf{\\textsf{%s %s}}\\linebreak{} %s}\"
|
||||
'\(\(unless \(eq todo \"\"\)
|
||||
\(format \"\\textsc{%s%s}\" todo priority\)\)
|
||||
heading content\)\)\)")
|
||||
|
||||
(defvar org-odd-levels-only)
|
||||
(defvar org-keyword-time-regexp)
|
||||
(defvar org-drawer-regexp)
|
||||
@ -328,89 +259,6 @@ If the task has an end part, also demote it."
|
||||
(goto-char beg)
|
||||
(org-fixup-indentation diff)))))))
|
||||
|
||||
(defvar org-export-current-backend) ; dynamically bound in org-exp.el
|
||||
(defun org-inlinetask-export-handler ()
|
||||
"Handle headlines with level larger or equal to `org-inlinetask-min-level'.
|
||||
Either remove headline and meta data, or do special formatting."
|
||||
(goto-char (point-min))
|
||||
(let* ((keywords-re (concat "^[ \t]*" org-keyword-time-regexp))
|
||||
(inline-re (concat (org-inlinetask-outline-regexp) ".*")))
|
||||
(while (re-search-forward inline-re nil t)
|
||||
(let ((headline (match-string 0))
|
||||
(beg (point-at-bol))
|
||||
(end (copy-marker (save-excursion
|
||||
(org-inlinetask-goto-end) (point))))
|
||||
content)
|
||||
;; Delete SCHEDULED, DEADLINE...
|
||||
(while (re-search-forward keywords-re end t)
|
||||
(delete-region (point-at-bol) (1+ (point-at-eol))))
|
||||
(goto-char beg)
|
||||
;; Delete drawers
|
||||
(while (re-search-forward org-drawer-regexp end t)
|
||||
(when (save-excursion (re-search-forward org-property-end-re nil t))
|
||||
(delete-region beg (1+ (match-end 0)))))
|
||||
;; Get CONTENT, if any.
|
||||
(goto-char beg)
|
||||
(forward-line 1)
|
||||
(unless (= (point) end)
|
||||
(setq content (buffer-substring (point)
|
||||
(save-excursion (goto-char end)
|
||||
(forward-line -1)
|
||||
(point)))))
|
||||
;; Remove the task.
|
||||
(goto-char beg)
|
||||
(delete-region beg end)
|
||||
(when (and org-inlinetask-export
|
||||
(assq org-export-current-backend
|
||||
org-inlinetask-export-templates))
|
||||
;; Format CONTENT, if appropriate.
|
||||
(setq content
|
||||
(if (not (and content (string-match "\\S-" content)))
|
||||
""
|
||||
;; Ensure CONTENT has minimal indentation, a single
|
||||
;; newline character at its boundaries, and isn't
|
||||
;; protected.
|
||||
(when (string-match "\\`\\([ \t]*\n\\)+" content)
|
||||
(setq content (substring content (match-end 0))))
|
||||
(when (string-match "[ \t\n]+\\'" content)
|
||||
(setq content (substring content 0 (match-beginning 0))))
|
||||
(org-add-props
|
||||
(concat "\n\n" (org-remove-indentation content) "\n\n")
|
||||
'(org-protected nil org-native-text nil))))
|
||||
|
||||
(when (string-match org-complex-heading-regexp headline)
|
||||
(let* ((nil-to-str
|
||||
(function
|
||||
;; Change nil arguments into empty strings.
|
||||
(lambda (el) (or (eval el) ""))))
|
||||
;; Set up keywords provided to templates.
|
||||
(todo (or (match-string 2 headline) ""))
|
||||
(class (or (and (eq "" todo) "")
|
||||
(if (member todo org-done-keywords) "done" "todo")))
|
||||
(priority (or (match-string 3 headline) ""))
|
||||
(heading (or (match-string 4 headline) ""))
|
||||
(tags (or (match-string 5 headline) ""))
|
||||
;; Read `org-inlinetask-export-templates'.
|
||||
(backend-spec (assq org-export-current-backend
|
||||
org-inlinetask-export-templates))
|
||||
(format-str (org-add-props (nth 1 backend-spec)
|
||||
'(org-protected t org-native-text t)))
|
||||
(tokens (cadr (nth 2 backend-spec)))
|
||||
;; Build export string. Ensure it won't break
|
||||
;; surrounding lists by giving it arbitrary high
|
||||
;; indentation.
|
||||
(export-str (org-add-props
|
||||
(eval (append '(format format-str)
|
||||
(mapcar nil-to-str tokens)))
|
||||
'(original-indentation 1000))))
|
||||
;; Ensure task starts a new paragraph.
|
||||
(unless (or (bobp)
|
||||
(save-excursion (forward-line -1)
|
||||
(looking-at "[ \t]*$")))
|
||||
(insert "\n"))
|
||||
(insert export-str)
|
||||
(unless (bolp) (insert "\n")))))))))
|
||||
|
||||
(defun org-inlinetask-get-current-indentation ()
|
||||
"Get the indentation of the last non-while line above this one."
|
||||
(save-excursion
|
||||
@ -467,7 +315,8 @@ Either remove headline and meta data, or do special formatting."
|
||||
((= end start))
|
||||
;; Inlinetask was folded: expand it.
|
||||
((get-char-property (1+ start) 'invisible)
|
||||
(org-show-entry))
|
||||
(outline-flag-region start end nil)
|
||||
(org-cycle-hide-drawers 'children))
|
||||
(t (outline-flag-region start end t)))))
|
||||
|
||||
(defun org-inlinetask-remove-END-maybe ()
|
||||
@ -476,9 +325,6 @@ Either remove headline and meta data, or do special formatting."
|
||||
org-inlinetask-min-level))
|
||||
(replace-match "")))
|
||||
|
||||
(eval-after-load "org-exp"
|
||||
'(add-hook 'org-export-preprocess-before-backend-specifics-hook
|
||||
'org-inlinetask-export-handler))
|
||||
(eval-after-load "org"
|
||||
'(add-hook 'org-font-lock-hook 'org-inlinetask-fontify))
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
;; Copyright (C) 2004-2013 Free Software Foundation, Inc.
|
||||
;;
|
||||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Bastien Guerry <bzg AT gnu DOT org>
|
||||
;; Bastien Guerry <bzg@gnu.org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;;
|
||||
@ -94,6 +94,11 @@
|
||||
(defvar org-ts-regexp)
|
||||
(defvar org-ts-regexp-both)
|
||||
|
||||
(declare-function outline-invisible-p "outline" (&optional pos))
|
||||
(declare-function outline-flag-region "outline" (from to flag))
|
||||
(declare-function outline-next-heading "outline" ())
|
||||
(declare-function outline-previous-heading "outline" ())
|
||||
|
||||
(declare-function org-at-heading-p "org" (&optional ignored))
|
||||
(declare-function org-before-first-heading-p "org" ())
|
||||
(declare-function org-back-to-heading "org" (&optional invisible-ok))
|
||||
@ -107,10 +112,6 @@
|
||||
(declare-function org-icompleting-read "org" (&rest args))
|
||||
(declare-function org-in-block-p "org" (names))
|
||||
(declare-function org-in-regexp "org" (re &optional nlines visually))
|
||||
(declare-function org-inlinetask-goto-beginning "org-inlinetask" ())
|
||||
(declare-function org-inlinetask-goto-end "org-inlinetask" ())
|
||||
(declare-function org-inlinetask-in-task-p "org-inlinetask" ())
|
||||
(declare-function org-inlinetask-outline-regexp "org-inlinetask" ())
|
||||
(declare-function org-level-increment "org" ())
|
||||
(declare-function org-narrow-to-subtree "org" ())
|
||||
(declare-function org-at-heading-p "org" (&optional invisible-ok))
|
||||
@ -118,15 +119,21 @@
|
||||
(declare-function org-remove-if "org" (predicate seq))
|
||||
(declare-function org-reduced-level "org" (L))
|
||||
(declare-function org-show-subtree "org" ())
|
||||
(declare-function org-sort-remove-invisible "org" (S))
|
||||
(declare-function org-time-string-to-seconds "org" (s))
|
||||
(declare-function org-timer-hms-to-secs "org-timer" (hms))
|
||||
(declare-function org-timer-item "org-timer" (&optional arg))
|
||||
(declare-function org-trim "org" (s))
|
||||
(declare-function org-uniquify "org" (list))
|
||||
(declare-function outline-invisible-p "outline" (&optional pos))
|
||||
(declare-function outline-flag-region "outline" (from to flag))
|
||||
(declare-function outline-next-heading "outline" ())
|
||||
(declare-function outline-previous-heading "outline" ())
|
||||
|
||||
(declare-function org-inlinetask-goto-beginning "org-inlinetask" ())
|
||||
(declare-function org-inlinetask-goto-end "org-inlinetask" ())
|
||||
(declare-function org-inlinetask-in-task-p "org-inlinetask" ())
|
||||
(declare-function org-inlinetask-outline-regexp "org-inlinetask" ())
|
||||
|
||||
(declare-function org-export-string-as "ox"
|
||||
(string backend &optional body-only ext-plist))
|
||||
|
||||
|
||||
|
||||
|
||||
@ -154,6 +161,7 @@ plain list item with an implied large level number, all true
|
||||
children and grand children of the outline heading will be
|
||||
exposed in a children' view."
|
||||
:group 'org-plain-lists
|
||||
:group 'org-cycle
|
||||
:type '(choice
|
||||
(const :tag "Never" nil)
|
||||
(const :tag "With cursor in plain list (recommended)" t)
|
||||
@ -209,14 +217,26 @@ Valid values are ?. and ?\). To get both terminators, use t."
|
||||
(const :tag "paren like in \"2)\"" ?\))
|
||||
(const :tag "both" t)))
|
||||
|
||||
(defcustom org-alphabetical-lists nil
|
||||
(define-obsolete-variable-alias 'org-alphabetical-lists
|
||||
'org-list-allow-alphabetical "24.4") ; Since 8.0
|
||||
(defcustom org-list-allow-alphabetical nil
|
||||
"Non-nil means single character alphabetical bullets are allowed.
|
||||
|
||||
Both uppercase and lowercase are handled. Lists with more than
|
||||
26 items will fallback to standard numbering. Alphabetical
|
||||
counters like \"[@c]\" will be recognized."
|
||||
counters like \"[@c]\" will be recognized.
|
||||
|
||||
This variable needs to be set before org.el is loaded. If you
|
||||
need to make a change while Emacs is running, use the customize
|
||||
interface or run the following code after updating it:
|
||||
|
||||
\(when (featurep 'org-element) (load \"org-element\" t t))"
|
||||
:group 'org-plain-lists
|
||||
:version "24.1"
|
||||
:type 'boolean)
|
||||
:type 'boolean
|
||||
:set (lambda (var val)
|
||||
(when (featurep 'org-element) (load "org-element" t t))
|
||||
(set var val)))
|
||||
|
||||
(defcustom org-list-two-spaces-after-bullet-regexp nil
|
||||
"A regular expression matching bullets that should have 2 spaces after them.
|
||||
@ -230,7 +250,9 @@ spaces instead of one after the bullet in each item of the list."
|
||||
(const :tag "never" nil)
|
||||
(regexp)))
|
||||
|
||||
(defcustom org-empty-line-terminates-plain-lists nil
|
||||
(define-obsolete-variable-alias 'org-empty-line-terminates-plain-lists
|
||||
'org-list-empty-line-terminates-plain-lists "24.4") ;; Since 8.0
|
||||
(defcustom org-list-empty-line-terminates-plain-lists nil
|
||||
"Non-nil means an empty line ends all plain list levels.
|
||||
Otherwise, two of them will be necessary."
|
||||
:group 'org-plain-lists
|
||||
@ -282,7 +304,9 @@ This hook runs even if checkbox rule in
|
||||
implement alternative ways of collecting statistics
|
||||
information.")
|
||||
|
||||
(defcustom org-hierarchical-checkbox-statistics t
|
||||
(define-obsolete-variable-alias 'org-hierarchical-checkbox-statistics
|
||||
'org-checkbox-hierarchical-statistics "24.4") ;; Since 8.0
|
||||
(defcustom org-checkbox-hierarchical-statistics t
|
||||
"Non-nil means checkbox statistics counts only the state of direct children.
|
||||
When nil, all boxes below the cookie are counted.
|
||||
This can be set to nil on a per-node basis using a COOKIE_DATA property
|
||||
@ -290,7 +314,9 @@ with the word \"recursive\" in the value."
|
||||
:group 'org-plain-lists
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-description-max-indent 20
|
||||
(org-defvaralias 'org-description-max-indent
|
||||
'org-list-description-max-indent) ;; Since 8.0
|
||||
(defcustom org-list-description-max-indent 20
|
||||
"Maximum indentation for the second line of a description list.
|
||||
When the indentation would be larger than this, it will become
|
||||
5 characters instead."
|
||||
@ -333,7 +359,7 @@ list, obtained by prompting the user."
|
||||
(string :tag "Format"))))
|
||||
|
||||
(defvar org-list-forbidden-blocks '("example" "verse" "src" "ascii" "beamer"
|
||||
"docbook" "html" "latex" "odt")
|
||||
"html" "latex" "odt")
|
||||
"Names of blocks where lists are not allowed.
|
||||
Names must be in lower case.")
|
||||
|
||||
@ -348,10 +374,10 @@ specifically, type `block' is determined by the variable
|
||||
|
||||
;;; Predicates and regexps
|
||||
|
||||
(defconst org-list-end-re (if org-empty-line-terminates-plain-lists "^[ \t]*\n"
|
||||
(defconst org-list-end-re (if org-list-empty-line-terminates-plain-lists "^[ \t]*\n"
|
||||
"^[ \t]*\n[ \t]*\n")
|
||||
"Regex corresponding to the end of a list.
|
||||
It depends on `org-empty-line-terminates-plain-lists'.")
|
||||
It depends on `org-list-empty-line-terminates-plain-lists'.")
|
||||
|
||||
(defconst org-list-full-item-re
|
||||
(concat "^[ \t]*\\(\\(?:[-+*]\\|\\(?:[0-9]+\\|[A-Za-z]\\)[.)]\\)\\(?:[ \t]+\\|$\\)\\)"
|
||||
@ -371,7 +397,7 @@ group 4: description tag")
|
||||
((= org-plain-list-ordered-item-terminator ?\)) ")")
|
||||
((= org-plain-list-ordered-item-terminator ?.) "\\.")
|
||||
(t "[.)]")))
|
||||
(alpha (if org-alphabetical-lists "\\|[A-Za-z]" "")))
|
||||
(alpha (if org-list-allow-alphabetical "\\|[A-Za-z]" "")))
|
||||
(concat "\\([ \t]*\\([-+]\\|\\(\\([0-9]+" alpha "\\)" term
|
||||
"\\)\\)\\|[ \t]+\\*\\)\\([ \t]+\\|$\\)")))
|
||||
|
||||
@ -385,7 +411,7 @@ group 4: description tag")
|
||||
(save-excursion
|
||||
(goto-char (match-end 0))
|
||||
(let ((counter-re (concat "\\(?:\\[@\\(?:start:\\)?"
|
||||
(if org-alphabetical-lists
|
||||
(if org-list-allow-alphabetical
|
||||
"\\([0-9]+\\|[A-Za-z]\\)"
|
||||
"[0-9]+")
|
||||
"\\][ \t]*\\)")))
|
||||
@ -642,8 +668,7 @@ Assume point is at an item."
|
||||
(save-excursion
|
||||
(catch 'exit
|
||||
(while t
|
||||
(let ((ind (+ (or (get-text-property (point) 'original-indentation) 0)
|
||||
(org-get-indentation))))
|
||||
(let ((ind (org-get-indentation)))
|
||||
(cond
|
||||
((<= (point) lim-up)
|
||||
;; At upward limit: if we ended at an item, store it,
|
||||
@ -651,18 +676,10 @@ Assume point is at an item."
|
||||
;; Jump to part 2.
|
||||
(throw 'exit
|
||||
(setq itm-lst
|
||||
(if (or (not (looking-at item-re))
|
||||
(get-text-property (point) 'org-example))
|
||||
(if (not (looking-at item-re))
|
||||
(memq (assq (car beg-cell) itm-lst) itm-lst)
|
||||
(setq beg-cell (cons (point) ind))
|
||||
(cons (funcall assoc-at-point ind) itm-lst)))))
|
||||
;; At a verbatim block, go before its beginning. Move
|
||||
;; from eol to ensure `previous-single-property-change'
|
||||
;; will return a value.
|
||||
((get-text-property (point) 'org-example)
|
||||
(goto-char (previous-single-property-change
|
||||
(point-at-eol) 'org-example nil lim-up))
|
||||
(forward-line -1))
|
||||
;; Looking at a list ending regexp. Dismiss useless
|
||||
;; data recorded above BEG-CELL. Jump to part 2.
|
||||
((looking-at org-list-end-re)
|
||||
@ -711,8 +728,7 @@ Assume point is at an item."
|
||||
;; position of items in END-LST-2.
|
||||
(catch 'exit
|
||||
(while t
|
||||
(let ((ind (+ (or (get-text-property (point) 'original-indentation) 0)
|
||||
(org-get-indentation))))
|
||||
(let ((ind (org-get-indentation)))
|
||||
(cond
|
||||
((>= (point) lim-down)
|
||||
;; At downward limit: this is de facto the end of the
|
||||
@ -720,12 +736,6 @@ Assume point is at an item."
|
||||
;; part 3.
|
||||
(throw 'exit
|
||||
(push (cons 0 (funcall end-before-blank)) end-lst-2)))
|
||||
;; At a verbatim block, move to its end. Point is at bol
|
||||
;; and 'org-example property is set by whole lines:
|
||||
;; `next-single-property-change' always return a value.
|
||||
((get-text-property (point) 'org-example)
|
||||
(goto-char
|
||||
(next-single-property-change (point) 'org-example nil lim-down)))
|
||||
;; Looking at a list ending regexp. Save point as an
|
||||
;; ending position and jump to part 3.
|
||||
((looking-at org-list-end-re)
|
||||
@ -1097,8 +1107,9 @@ It determines the number of whitespaces to append by looking at
|
||||
org-list-two-spaces-after-bullet-regexp bullet))
|
||||
" "
|
||||
" ")))
|
||||
(string-match "\\S-+\\([ \t]*\\)" bullet)
|
||||
(replace-match spaces nil nil bullet 1))))
|
||||
(if (string-match "\\S-+\\([ \t]*\\)" bullet)
|
||||
(replace-match spaces nil nil bullet 1)
|
||||
bullet))))
|
||||
|
||||
(defun org-list-swap-items (beg-A beg-B struct)
|
||||
"Swap item starting at BEG-A with item starting at BEG-B in STRUCT.
|
||||
@ -1208,7 +1219,7 @@ some heuristics to guess the result."
|
||||
(point))))))))
|
||||
(cond
|
||||
;; Trivial cases where there should be none.
|
||||
((or org-empty-line-terminates-plain-lists (not insert-blank-p)) 0)
|
||||
((or org-list-empty-line-terminates-plain-lists (not insert-blank-p)) 0)
|
||||
;; When `org-blank-before-new-entry' says so, it is 1.
|
||||
((eq insert-blank-p t) 1)
|
||||
;; `plain-list-item' is 'auto. Count blank lines separating
|
||||
@ -1613,7 +1624,7 @@ bullets between START and END."
|
||||
|
||||
STRUCT is list structure. PREVS is the alist of previous items,
|
||||
as returned by `org-list-prevs-alist'."
|
||||
(and org-alphabetical-lists
|
||||
(and org-list-allow-alphabetical
|
||||
(catch 'exit
|
||||
(let ((item first) (ascii 64) (case-fold-search nil))
|
||||
;; Pretend that bullets are uppercase and check if alphabet
|
||||
@ -1851,9 +1862,10 @@ Initial position of cursor is restored after the changes."
|
||||
(item-re (org-item-re))
|
||||
(shift-body-ind
|
||||
(function
|
||||
;; Shift the indentation between END and BEG by DELTA.
|
||||
;; Start from the line before END.
|
||||
(lambda (end beg delta)
|
||||
;; Shift the indentation between END and BEG by DELTA. If
|
||||
;; MAX-IND is non-nil, ensure that no line will be indented
|
||||
;; more than that number. Start from the line before END.
|
||||
(lambda (end beg delta max-ind)
|
||||
(goto-char end)
|
||||
(skip-chars-backward " \r\t\n")
|
||||
(beginning-of-line)
|
||||
@ -1867,7 +1879,8 @@ Initial position of cursor is restored after the changes."
|
||||
;; Shift only non-empty lines.
|
||||
((org-looking-at-p "^[ \t]*\\S-")
|
||||
(let ((i (org-get-indentation)))
|
||||
(org-indent-line-to (+ i delta)))))
|
||||
(org-indent-line-to
|
||||
(if max-ind (min (+ i delta) max-ind) (+ i delta))))))
|
||||
(forward-line -1)))))
|
||||
(modify-item
|
||||
(function
|
||||
@ -1903,53 +1916,60 @@ Initial position of cursor is restored after the changes."
|
||||
(indent-to new-ind)))))))
|
||||
;; 1. First get list of items and position endings. We maintain
|
||||
;; two alists: ITM-SHIFT, determining indentation shift needed
|
||||
;; at item, and END-POS, a pseudo-alist where key is ending
|
||||
;; at item, and END-LIST, a pseudo-alist where key is ending
|
||||
;; position and value point.
|
||||
(let (end-list acc-end itm-shift all-ends sliced-struct)
|
||||
(mapc (lambda (e)
|
||||
(let* ((pos (car e))
|
||||
(ind-pos (org-list-get-ind pos struct))
|
||||
(ind-old (org-list-get-ind pos old-struct))
|
||||
(bul-pos (org-list-get-bullet pos struct))
|
||||
(bul-old (org-list-get-bullet pos old-struct))
|
||||
(ind-shift (- (+ ind-pos (length bul-pos))
|
||||
(+ ind-old (length bul-old))))
|
||||
(end-pos (org-list-get-item-end pos old-struct)))
|
||||
(push (cons pos ind-shift) itm-shift)
|
||||
(unless (assq end-pos old-struct)
|
||||
;; To determine real ind of an ending position that
|
||||
;; is not at an item, we have to find the item it
|
||||
;; belongs to: it is the last item (ITEM-UP), whose
|
||||
;; ending is further than the position we're
|
||||
;; interested in.
|
||||
(let ((item-up (assoc-default end-pos acc-end '>)))
|
||||
(push (cons end-pos item-up) end-list)))
|
||||
(push (cons end-pos pos) acc-end)))
|
||||
old-struct)
|
||||
(dolist (e old-struct)
|
||||
(let* ((pos (car e))
|
||||
(ind-pos (org-list-get-ind pos struct))
|
||||
(ind-old (org-list-get-ind pos old-struct))
|
||||
(bul-pos (org-list-get-bullet pos struct))
|
||||
(bul-old (org-list-get-bullet pos old-struct))
|
||||
(ind-shift (- (+ ind-pos (length bul-pos))
|
||||
(+ ind-old (length bul-old))))
|
||||
(end-pos (org-list-get-item-end pos old-struct)))
|
||||
(push (cons pos ind-shift) itm-shift)
|
||||
(unless (assq end-pos old-struct)
|
||||
;; To determine real ind of an ending position that
|
||||
;; is not at an item, we have to find the item it
|
||||
;; belongs to: it is the last item (ITEM-UP), whose
|
||||
;; ending is further than the position we're
|
||||
;; interested in.
|
||||
(let ((item-up (assoc-default end-pos acc-end '>)))
|
||||
(push (cons end-pos item-up) end-list)))
|
||||
(push (cons end-pos pos) acc-end)))
|
||||
;; 2. Slice the items into parts that should be shifted by the
|
||||
;; same amount of indentation. The slices are returned in
|
||||
;; reverse order so changes modifying buffer do not change
|
||||
;; positions they refer to.
|
||||
;; same amount of indentation. Each slice follow the pattern
|
||||
;; (END BEG DELTA MAX-IND-OR-NIL). Slices are returned in
|
||||
;; reverse order.
|
||||
(setq all-ends (sort (append (mapcar 'car itm-shift)
|
||||
(org-uniquify (mapcar 'car end-list)))
|
||||
'<))
|
||||
(while (cdr all-ends)
|
||||
(let* ((up (pop all-ends))
|
||||
(down (car all-ends))
|
||||
(ind (if (assq up struct)
|
||||
(cdr (assq up itm-shift))
|
||||
(cdr (assq (cdr (assq up end-list)) itm-shift)))))
|
||||
(push (list down up ind) sliced-struct)))
|
||||
(itemp (assq up struct))
|
||||
(item (if itemp up (cdr (assq up end-list))))
|
||||
(ind (cdr (assq item itm-shift)))
|
||||
;; If we're not at an item, there's a child of the item
|
||||
;; point belongs to above. Make sure this slice isn't
|
||||
;; moved within that child by specifying a maximum
|
||||
;; indentation.
|
||||
(max-ind (and (not itemp)
|
||||
(+ (org-list-get-ind item struct)
|
||||
(length (org-list-get-bullet item struct))
|
||||
org-list-indent-offset))))
|
||||
(push (list down up ind max-ind) sliced-struct)))
|
||||
;; 3. Shift each slice in buffer, provided delta isn't 0, from
|
||||
;; end to beginning. Take a special action when beginning is
|
||||
;; at item bullet.
|
||||
(mapc (lambda (e)
|
||||
(unless (zerop (nth 2 e)) (apply shift-body-ind e))
|
||||
(let* ((beg (nth 1 e))
|
||||
(cell (assq beg struct)))
|
||||
(unless (or (not cell) (equal cell (assq beg old-struct)))
|
||||
(funcall modify-item beg))))
|
||||
sliced-struct))
|
||||
(dolist (e sliced-struct)
|
||||
(unless (and (zerop (nth 2 e)) (not (nth 3 e)))
|
||||
(apply shift-body-ind e))
|
||||
(let* ((beg (nth 1 e))
|
||||
(cell (assq beg struct)))
|
||||
(unless (or (not cell) (equal cell (assq beg old-struct)))
|
||||
(funcall modify-item beg)))))
|
||||
;; 4. Go back to initial position and clean marker.
|
||||
(goto-char origin)
|
||||
(move-marker origin nil)))
|
||||
@ -2148,7 +2168,7 @@ the item, so this really moves item trees."
|
||||
(prevs (org-list-prevs-alist struct))
|
||||
(next-item (org-list-get-next-item (point-at-bol) struct prevs)))
|
||||
(unless (or next-item org-list-use-circular-motion)
|
||||
(error "Cannot move this item further down"))
|
||||
(user-error "Cannot move this item further down"))
|
||||
(if (not next-item)
|
||||
(setq struct (org-list-send-item item 'begin struct))
|
||||
(setq struct (org-list-swap-items item next-item struct))
|
||||
@ -2169,7 +2189,7 @@ the item, so this really moves item trees."
|
||||
(prevs (org-list-prevs-alist struct))
|
||||
(prev-item (org-list-get-prev-item (point-at-bol) struct prevs)))
|
||||
(unless (or prev-item org-list-use-circular-motion)
|
||||
(error "Cannot move this item further up"))
|
||||
(user-error "Cannot move this item further up"))
|
||||
(if (not prev-item)
|
||||
(setq struct (org-list-send-item item 'end struct))
|
||||
(setq struct (org-list-swap-items prev-item item struct)))
|
||||
@ -2203,9 +2223,8 @@ item is invisible."
|
||||
;; If we're in a description list, ask for the new term.
|
||||
(desc (when (eq (org-list-get-list-type itemp struct prevs)
|
||||
'descriptive)
|
||||
(concat (read-string "Term: ") " :: "))))
|
||||
(setq struct
|
||||
(org-list-insert-item pos struct prevs checkbox desc))
|
||||
" :: ")))
|
||||
(setq struct (org-list-insert-item pos struct prevs checkbox desc))
|
||||
(org-list-write-struct struct (org-list-parents-alist struct))
|
||||
(when checkbox (org-update-checkbox-count-maybe))
|
||||
(looking-at org-list-full-item-re)
|
||||
@ -2214,6 +2233,7 @@ item is invisible."
|
||||
(string-match "[.)]" (match-string 1))))
|
||||
(match-beginning 4)
|
||||
(match-end 0)))
|
||||
(if desc (backward-char 1))
|
||||
t)))))
|
||||
|
||||
(defun org-list-repair ()
|
||||
@ -2429,7 +2449,7 @@ With optional prefix argument ALL, do this for the whole buffer."
|
||||
(let ((cookie-re "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)")
|
||||
(box-re "^[ \t]*\\([-+*]\\|\\([0-9]+\\|[A-Za-z]\\)[.)]\\)[ \t]+\\(?:\\[@\\(?:start:\\)?\\([0-9]+\\|[A-Za-z]\\)\\][ \t]*\\)?\\(\\[[- X]\\]\\)")
|
||||
(recursivep
|
||||
(or (not org-hierarchical-checkbox-statistics)
|
||||
(or (not org-checkbox-hierarchical-statistics)
|
||||
(string-match "\\<recursive\\>"
|
||||
(or (org-entry-get nil "COOKIE_DATA") ""))))
|
||||
(bounds (if all
|
||||
@ -2771,7 +2791,7 @@ Return t at each successful move."
|
||||
(cond
|
||||
((ignore-errors (org-list-indent-item-generic 1 t struct)))
|
||||
((ignore-errors (org-list-indent-item-generic -1 t struct)))
|
||||
(t (error "Cannot move item"))))
|
||||
(t (user-error "Cannot move item"))))
|
||||
t))))
|
||||
|
||||
(defun org-sort-list (&optional with-case sorting-type getkey-func compare-func)
|
||||
@ -2787,13 +2807,14 @@ optional argument WITH-CASE, the sorting considers case as well.
|
||||
|
||||
The command prompts for the sorting type unless it has been given
|
||||
to the function through the SORTING-TYPE argument, which needs to
|
||||
be a character, \(?n ?N ?a ?A ?t ?T ?f ?F). Here is the precise
|
||||
meaning of each character:
|
||||
be a character, \(?n ?N ?a ?A ?t ?T ?f ?F ?x ?X). Here is the
|
||||
detailed meaning of each character:
|
||||
|
||||
n Numerically, by converting the beginning of the item to a number.
|
||||
a Alphabetically. Only the first line of item is checked.
|
||||
t By date/time, either the first active time stamp in the entry, if
|
||||
any, or by the first inactive one. In a timer list, sort the timers.
|
||||
x By \"checked\" status of a check list.
|
||||
|
||||
Capital letters will reverse the sort order.
|
||||
|
||||
@ -2801,7 +2822,10 @@ If the SORTING-TYPE is ?f or ?F, then GETKEY-FUNC specifies
|
||||
a function to be called with point at the beginning of the
|
||||
record. It must return either a string or a number that should
|
||||
serve as the sorting key for that record. It will then use
|
||||
COMPARE-FUNC to compare entries."
|
||||
COMPARE-FUNC to compare entries.
|
||||
|
||||
Sorting is done against the visible part of the headlines, it
|
||||
ignores hidden links."
|
||||
(interactive "P")
|
||||
(let* ((case-func (if with-case 'identity 'downcase))
|
||||
(struct (org-list-struct))
|
||||
@ -2809,13 +2833,16 @@ COMPARE-FUNC to compare entries."
|
||||
(start (org-list-get-list-begin (point-at-bol) struct prevs))
|
||||
(end (org-list-get-list-end (point-at-bol) struct prevs))
|
||||
(sorting-type
|
||||
(progn
|
||||
(message
|
||||
"Sort plain list: [a]lpha [n]umeric [t]ime [f]unc A/N/T/F means reversed:")
|
||||
(read-char-exclusive)))
|
||||
(getkey-func (and (= (downcase sorting-type) ?f)
|
||||
(intern (org-icompleting-read "Sort using function: "
|
||||
obarray 'fboundp t nil nil)))))
|
||||
(or sorting-type
|
||||
(progn
|
||||
(message
|
||||
"Sort plain list: [a]lpha [n]umeric [t]ime [f]unc [x]checked A/N/T/F/X means reversed:")
|
||||
(read-char-exclusive))))
|
||||
(getkey-func
|
||||
(or getkey-func
|
||||
(and (= (downcase sorting-type) ?f)
|
||||
(intern (org-icompleting-read "Sort using function: "
|
||||
obarray 'fboundp t nil nil))))))
|
||||
(message "Sorting items...")
|
||||
(save-restriction
|
||||
(narrow-to-region start end)
|
||||
@ -2826,10 +2853,11 @@ COMPARE-FUNC to compare entries."
|
||||
(sort-func (cond
|
||||
((= dcst ?a) 'string<)
|
||||
((= dcst ?f) compare-func)
|
||||
((= dcst ?t) '<)))
|
||||
((= dcst ?t) '<)
|
||||
((= dcst ?x) 'string<)))
|
||||
(next-record (lambda ()
|
||||
(skip-chars-forward " \r\t\n")
|
||||
(beginning-of-line)))
|
||||
(or (eobp) (beginning-of-line))))
|
||||
(end-record (lambda ()
|
||||
(goto-char (org-list-get-item-end-before-blank
|
||||
(point) struct))))
|
||||
@ -2838,21 +2866,28 @@ COMPARE-FUNC to compare entries."
|
||||
(when (looking-at "[ \t]*[-+*0-9.)]+\\([ \t]+\\[[- X]\\]\\)?[ \t]+")
|
||||
(cond
|
||||
((= dcst ?n)
|
||||
(string-to-number (buffer-substring (match-end 0)
|
||||
(point-at-eol))))
|
||||
(string-to-number
|
||||
(org-sort-remove-invisible
|
||||
(buffer-substring (match-end 0) (point-at-eol)))))
|
||||
((= dcst ?a)
|
||||
(funcall case-func
|
||||
(buffer-substring (match-end 0) (point-at-eol))))
|
||||
(org-sort-remove-invisible
|
||||
(buffer-substring
|
||||
(match-end 0) (point-at-eol)))))
|
||||
((= dcst ?t)
|
||||
(cond
|
||||
;; If it is a timer list, convert timer to seconds
|
||||
((org-at-item-timer-p)
|
||||
(org-timer-hms-to-secs (match-string 1)))
|
||||
((or (re-search-forward org-ts-regexp (point-at-eol) t)
|
||||
(re-search-forward org-ts-regexp-both
|
||||
(point-at-eol) t))
|
||||
((or (save-excursion
|
||||
(re-search-forward org-ts-regexp (point-at-eol) t))
|
||||
(save-excursion (re-search-forward org-ts-regexp-both
|
||||
(point-at-eol) t)))
|
||||
(org-time-string-to-seconds (match-string 0)))
|
||||
(t (org-float-time now))))
|
||||
((= dcst ?x) (or (and (stringp (match-string 1))
|
||||
(match-string 1))
|
||||
""))
|
||||
((= dcst ?f)
|
||||
(if getkey-func
|
||||
(let ((value (funcall getkey-func)))
|
||||
@ -3021,9 +3056,8 @@ for this list."
|
||||
(unless (org-at-item-p) (error "Not at a list item"))
|
||||
(save-excursion
|
||||
(re-search-backward "#\\+ORGLST" nil t)
|
||||
(unless (looking-at "[ \t]*#\\+ORGLST[: \t][ \t]*SEND[ \t]+\\([^ \t\r\n]+\\)[ \t]+\\([^ \t\r\n]+\\)\\([ \t]+.*\\)?")
|
||||
(if maybe
|
||||
(throw 'exit nil)
|
||||
(unless (looking-at "#\\+ORGLST:[ \t]+SEND[ \t]+\\(\\S-+\\)[ \t]+\\(\\S-+\\)")
|
||||
(if maybe (throw 'exit nil)
|
||||
(error "Don't know how to transform this list"))))
|
||||
(let* ((name (match-string 1))
|
||||
(transform (intern (match-string 2)))
|
||||
@ -3037,13 +3071,11 @@ for this list."
|
||||
(re-search-backward "#\\+ORGLST" nil t)
|
||||
(re-search-forward (org-item-beginning-re) bottom-point t)
|
||||
(match-beginning 0)))
|
||||
(list (save-restriction
|
||||
(narrow-to-region top-point bottom-point)
|
||||
(org-list-parse-list)))
|
||||
(plain-list (buffer-substring-no-properties top-point bottom-point))
|
||||
beg txt)
|
||||
(unless (fboundp transform)
|
||||
(error "No such transformation function %s" transform))
|
||||
(let ((txt (funcall transform list)))
|
||||
(let ((txt (funcall transform plain-list)))
|
||||
;; Find the insertion place
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
@ -3200,65 +3232,24 @@ items."
|
||||
|
||||
(defun org-list-to-latex (list &optional params)
|
||||
"Convert LIST into a LaTeX list.
|
||||
LIST is as returned by `org-list-parse-list'. PARAMS is a property list
|
||||
with overruling parameters for `org-list-to-generic'."
|
||||
(org-list-to-generic
|
||||
list
|
||||
(org-combine-plists
|
||||
'(:splice nil :ostart "\\begin{enumerate}\n" :oend "\\end{enumerate}"
|
||||
:ustart "\\begin{itemize}\n" :uend "\\end{itemize}"
|
||||
:dstart "\\begin{description}\n" :dend "\\end{description}"
|
||||
:dtstart "[" :dtend "] "
|
||||
:istart "\\item " :iend "\n"
|
||||
:icount (let ((enum (nth depth '("i" "ii" "iii" "iv"))))
|
||||
(if enum
|
||||
;; LaTeX increments counter just before
|
||||
;; using it, so set it to the desired
|
||||
;; value, minus one.
|
||||
(format "\\setcounter{enum%s}{%s}\n\\item "
|
||||
enum (1- counter))
|
||||
"\\item "))
|
||||
:csep "\n"
|
||||
:cbon "\\texttt{[X]}" :cboff "\\texttt{[ ]}"
|
||||
:cbtrans "\\texttt{[-]}")
|
||||
params)))
|
||||
LIST is as string representing the list to transform, as Org
|
||||
syntax. Return converted list as a string."
|
||||
(require 'ox-latex)
|
||||
(org-export-string-as list 'latex t))
|
||||
|
||||
(defun org-list-to-html (list &optional params)
|
||||
(defun org-list-to-html (list)
|
||||
"Convert LIST into a HTML list.
|
||||
LIST is as returned by `org-list-parse-list'. PARAMS is a property list
|
||||
with overruling parameters for `org-list-to-generic'."
|
||||
(org-list-to-generic
|
||||
list
|
||||
(org-combine-plists
|
||||
'(:splice nil :ostart "<ol>\n" :oend "\n</ol>"
|
||||
:ustart "<ul>\n" :uend "\n</ul>"
|
||||
:dstart "<dl>\n" :dend "\n</dl>"
|
||||
:dtstart "<dt>" :dtend "</dt>\n"
|
||||
:ddstart "<dd>" :ddend "</dd>"
|
||||
:istart "<li>" :iend "</li>"
|
||||
:icount (format "<li value=\"%s\">" counter)
|
||||
:isep "\n" :lsep "\n" :csep "\n"
|
||||
:cbon "<code>[X]</code>" :cboff "<code>[ ]</code>"
|
||||
:cbtrans "<code>[-]</code>")
|
||||
params)))
|
||||
LIST is as string representing the list to transform, as Org
|
||||
syntax. Return converted list as a string."
|
||||
(require 'ox-html)
|
||||
(org-export-string-as list 'html t))
|
||||
|
||||
(defun org-list-to-texinfo (list &optional params)
|
||||
"Convert LIST into a Texinfo list.
|
||||
LIST is as returned by `org-list-parse-list'. PARAMS is a property list
|
||||
with overruling parameters for `org-list-to-generic'."
|
||||
(org-list-to-generic
|
||||
list
|
||||
(org-combine-plists
|
||||
'(:splice nil :ostart "@itemize @minus\n" :oend "@end itemize"
|
||||
:ustart "@enumerate\n" :uend "@end enumerate"
|
||||
:dstart "@table @asis\n" :dend "@end table"
|
||||
:dtstart " " :dtend "\n"
|
||||
:istart "@item\n" :iend "\n"
|
||||
:icount "@item\n"
|
||||
:csep "\n"
|
||||
:cbon "@code{[X]}" :cboff "@code{[ ]}"
|
||||
:cbtrans "@code{[-]}")
|
||||
params)))
|
||||
LIST is as string representing the list to transform, as Org
|
||||
syntax. Return converted list as a string."
|
||||
(require 'ox-texinfo)
|
||||
(org-export-string-as list 'texinfo t))
|
||||
|
||||
(defun org-list-to-subtree (list &optional params)
|
||||
"Convert LIST into an Org subtree.
|
||||
|
191
lisp/org/org-macro.el
Normal file
191
lisp/org/org-macro.el
Normal file
@ -0,0 +1,191 @@
|
||||
;;; org-macro.el --- Macro Replacement Code for Org Mode
|
||||
|
||||
;; Copyright (C) 2013 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Nicolas Goaziou <n.goaziou@gmail.com>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
|
||||
;; GNU Emacs 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.
|
||||
|
||||
;; GNU Emacs 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 GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Macros are expanded with `org-macro-replace-all', which relies
|
||||
;; internally on `org-macro-expand'.
|
||||
|
||||
;; Default templates for expansion are stored in the buffer-local
|
||||
;; variable `org-macro-templates'. This variable is updated by
|
||||
;; `org-macro-initialize-templates', which recursively calls
|
||||
;; `org-macro--collect-macros' in order to read setup files.
|
||||
|
||||
;; Along with macros defined through #+MACRO: keyword, default
|
||||
;; templates include the following hard-coded macros:
|
||||
;; {{{time(format-string)}}}, {{{property(node-property)}}},
|
||||
;; {{{input-file}}} and {{{modification-time(format-string)}}}.
|
||||
|
||||
;; Upon exporting, "ox.el" will also provide {{{author}}}, {{{date}}},
|
||||
;; {{{email}}} and {{{title}}} macros.
|
||||
|
||||
;;; Code:
|
||||
(require 'org-macs)
|
||||
|
||||
(declare-function org-element-at-point "org-element" (&optional keep-trail))
|
||||
(declare-function org-element-context "org-element" (&optional element))
|
||||
(declare-function org-element-property "org-element" (property element))
|
||||
(declare-function org-element-type "org-element" (element))
|
||||
(declare-function org-remove-double-quotes "org" (s))
|
||||
(declare-function org-mode "org" ())
|
||||
(declare-function org-file-contents "org" (file &optional noerror))
|
||||
(declare-function org-with-wide-buffer "org-macs" (&rest body))
|
||||
|
||||
;;; Variables
|
||||
|
||||
(defvar org-macro-templates nil
|
||||
"Alist containing all macro templates in current buffer.
|
||||
Associations are in the shape of (NAME . TEMPLATE) where NAME
|
||||
stands for macro's name and template for its replacement value,
|
||||
both as strings. This is an internal variable. Do not set it
|
||||
directly, use instead:
|
||||
|
||||
#+MACRO: name template")
|
||||
(make-variable-buffer-local 'org-macro-templates)
|
||||
|
||||
|
||||
;;; Functions
|
||||
|
||||
(defun org-macro--collect-macros ()
|
||||
"Collect macro definitions in current buffer and setup files.
|
||||
Return an alist containing all macro templates found."
|
||||
(let* (collect-macros ; For byte-compiler.
|
||||
(collect-macros
|
||||
(lambda (files templates)
|
||||
;; Return an alist of macro templates. FILES is a list of
|
||||
;; setup files names read so far, used to avoid circular
|
||||
;; dependencies. TEMPLATES is the alist collected so far.
|
||||
(let ((case-fold-search t))
|
||||
(org-with-wide-buffer
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward
|
||||
"^[ \t]*#\\+\\(MACRO\\|SETUPFILE\\):" nil t)
|
||||
(let ((element (org-element-at-point)))
|
||||
(when (eq (org-element-type element) 'keyword)
|
||||
(let ((val (org-element-property :value element)))
|
||||
(if (equal (org-element-property :key element) "MACRO")
|
||||
;; Install macro in TEMPLATES.
|
||||
(when (string-match
|
||||
"^\\(.*?\\)\\(?:\\s-+\\(.*\\)\\)?\\s-*$" val)
|
||||
(let* ((name (match-string 1 val))
|
||||
(template (or (match-string 2 val) ""))
|
||||
(old-cell (assoc name templates)))
|
||||
(if old-cell (setcdr old-cell template)
|
||||
(push (cons name template) templates))))
|
||||
;; Enter setup file.
|
||||
(let ((file (expand-file-name
|
||||
(org-remove-double-quotes val))))
|
||||
(unless (member file files)
|
||||
(with-temp-buffer
|
||||
(org-mode)
|
||||
(insert (org-file-contents file 'noerror))
|
||||
(setq templates
|
||||
(funcall collect-macros (cons file files)
|
||||
templates)))))))))))
|
||||
templates))))
|
||||
(funcall collect-macros nil nil)))
|
||||
|
||||
(defun org-macro-initialize-templates ()
|
||||
"Collect macro templates defined in current buffer.
|
||||
Templates are stored in buffer-local variable
|
||||
`org-macro-templates'. In addition to buffer-defined macros, the
|
||||
function installs the following ones: \"property\",
|
||||
\"time\". and, if the buffer is associated to a file,
|
||||
\"input-file\" and \"modification-time\"."
|
||||
(let* ((templates (org-macro--collect-macros))
|
||||
(update-templates
|
||||
(lambda (cell)
|
||||
(let ((old-template (assoc (car cell) templates)))
|
||||
(if old-template (setcdr old-template (cdr cell))
|
||||
(push cell templates))))))
|
||||
;; Install hard-coded macros.
|
||||
(mapc (lambda (cell) (funcall update-templates cell))
|
||||
(list (cons "property" "(eval (org-entry-get nil \"$1\" 'selective))")
|
||||
(cons "time" "(eval (format-time-string \"$1\"))")))
|
||||
(let ((visited-file (buffer-file-name (buffer-base-buffer))))
|
||||
(when (and visited-file (file-exists-p visited-file))
|
||||
(mapc (lambda (cell) (funcall update-templates cell))
|
||||
(list (cons "input-file" (file-name-nondirectory visited-file))
|
||||
(cons "modification-time"
|
||||
(format "(eval (format-time-string \"$1\" '%s))"
|
||||
(prin1-to-string
|
||||
(nth 5 (file-attributes visited-file)))))))))
|
||||
(setq org-macro-templates templates)))
|
||||
|
||||
(defun org-macro-expand (macro templates)
|
||||
"Return expanded MACRO, as a string.
|
||||
MACRO is an object, obtained, for example, with
|
||||
`org-element-context'. TEMPLATES is an alist of templates used
|
||||
for expansion. See `org-macro-templates' for a buffer-local
|
||||
default value. Return nil if no template was found."
|
||||
(let ((template
|
||||
;; Macro names are case-insensitive.
|
||||
(cdr (assoc-string (org-element-property :key macro) templates t))))
|
||||
(when template
|
||||
(let ((value (replace-regexp-in-string
|
||||
"\\$[0-9]+"
|
||||
(lambda (arg)
|
||||
(or (nth (1- (string-to-number (substring arg 1)))
|
||||
(org-element-property :args macro))
|
||||
;; No argument: remove place-holder.
|
||||
""))
|
||||
template nil 'literal)))
|
||||
;; VALUE starts with "(eval": it is a s-exp, `eval' it.
|
||||
(when (string-match "\\`(eval\\>" value)
|
||||
(setq value (eval (read value))))
|
||||
;; Return string.
|
||||
(format "%s" (or value ""))))))
|
||||
|
||||
(defun org-macro-replace-all (templates)
|
||||
"Replace all macros in current buffer by their expansion.
|
||||
TEMPLATES is an alist of templates used for expansion. See
|
||||
`org-macro-templates' for a buffer-local default value."
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(let (record)
|
||||
(while (re-search-forward "{{{[-A-Za-z0-9_]" nil t)
|
||||
(let ((object (org-element-context)))
|
||||
(when (eq (org-element-type object) 'macro)
|
||||
(let* ((value (org-macro-expand object templates))
|
||||
(begin (org-element-property :begin object))
|
||||
(signature (list begin
|
||||
object
|
||||
(org-element-property :args object))))
|
||||
;; Avoid circular dependencies by checking if the same
|
||||
;; macro with the same arguments is expanded at the same
|
||||
;; position twice.
|
||||
(if (member signature record)
|
||||
(error "Circular macro expansion: %s"
|
||||
(org-element-property :key object))
|
||||
(when value
|
||||
(push signature record)
|
||||
(delete-region
|
||||
begin
|
||||
;; Preserve white spaces after the macro.
|
||||
(progn (goto-char (org-element-property :end object))
|
||||
(skip-chars-backward " \t")
|
||||
(point)))
|
||||
;; Leave point before replacement in case of recursive
|
||||
;; expansions.
|
||||
(save-excursion (insert value)))))))))))
|
||||
|
||||
|
||||
(provide 'org-macro)
|
||||
;;; org-macro.el ends here
|
@ -33,7 +33,9 @@
|
||||
|
||||
(eval-and-compile
|
||||
(unless (fboundp 'declare-function)
|
||||
(defmacro declare-function (fn file &optional arglist fileonly)))
|
||||
(defmacro declare-function (fn file &optional arglist fileonly)
|
||||
`(autoload ',fn ,file)))
|
||||
|
||||
(if (>= emacs-major-version 23)
|
||||
(defsubst org-char-to-string(c)
|
||||
"Defsubst to decode UTF-8 character values in emacs 23 and beyond."
|
||||
@ -63,14 +65,6 @@
|
||||
`(interactive-p))))
|
||||
(def-edebug-spec org-called-interactively-p (&optional ("quote" symbolp)))
|
||||
|
||||
(when (and (not (fboundp 'with-silent-modifications))
|
||||
(or (< emacs-major-version 23)
|
||||
(and (= emacs-major-version 23)
|
||||
(< emacs-minor-version 2))))
|
||||
(defmacro with-silent-modifications (&rest body)
|
||||
`(org-unmodified ,@body))
|
||||
(def-edebug-spec with-silent-modifications (body)))
|
||||
|
||||
(defmacro org-bound-and-true-p (var)
|
||||
"Return the value of symbol VAR if it is bound, else nil."
|
||||
`(and (boundp (quote ,var)) ,var))
|
||||
@ -87,16 +81,6 @@
|
||||
Otherwise return nil."
|
||||
(and v (not (equal v "nil")) v))
|
||||
|
||||
(defmacro org-unmodified (&rest body)
|
||||
"Execute body without changing `buffer-modified-p'.
|
||||
Also, do not record undo information."
|
||||
`(set-buffer-modified-p
|
||||
(prog1 (buffer-modified-p)
|
||||
(let ((buffer-undo-list t)
|
||||
(inhibit-modification-hooks t))
|
||||
,@body))))
|
||||
(def-edebug-spec org-unmodified (body))
|
||||
|
||||
(defun org-substitute-posix-classes (re)
|
||||
"Substitute posix classes in regular expression RE."
|
||||
(let ((ss re))
|
||||
@ -126,14 +110,18 @@ Also, do not record undo information."
|
||||
(org-move-to-column ,col)))))
|
||||
(def-edebug-spec org-preserve-lc (body))
|
||||
|
||||
;; Copied from bookmark.el
|
||||
(defmacro org-with-buffer-modified-unmodified (&rest body)
|
||||
;; Use `org-with-silent-modifications' to ignore cosmetic changes and
|
||||
;; `org-unmodified' to ignore real text modifications
|
||||
(defmacro org-unmodified (&rest body)
|
||||
"Run BODY while preserving the buffer's `buffer-modified-p' state."
|
||||
(org-with-gensyms (was-modified)
|
||||
`(let ((,was-modified (buffer-modified-p)))
|
||||
(unwind-protect
|
||||
(progn ,@body)
|
||||
(set-buffer-modified-p ,was-modified)))))
|
||||
(let ((buffer-undo-list t)
|
||||
(inhibit-modification-hooks t))
|
||||
,@body)
|
||||
(set-buffer-modified-p ,was-modified)))))
|
||||
(def-edebug-spec org-unmodified (body))
|
||||
|
||||
(defmacro org-without-partial-completion (&rest body)
|
||||
`(if (and (boundp 'partial-completion-mode)
|
||||
@ -176,46 +164,17 @@ We use a macro so that the test can happen at compilation time."
|
||||
(cons (if (fboundp 'with-no-warnings) 'with-no-warnings 'progn) body))
|
||||
(def-edebug-spec org-no-warnings (body))
|
||||
|
||||
(defmacro org-if-unprotected (&rest body)
|
||||
"Execute BODY if there is no `org-protected' text property at point."
|
||||
`(unless (get-text-property (point) 'org-protected)
|
||||
,@body))
|
||||
(def-edebug-spec org-if-unprotected (body))
|
||||
|
||||
(defmacro org-if-unprotected-1 (&rest body)
|
||||
"Execute BODY if there is no `org-protected' text property at point-1."
|
||||
`(unless (get-text-property (1- (point)) 'org-protected)
|
||||
,@body))
|
||||
(def-edebug-spec org-if-unprotected-1 (body))
|
||||
|
||||
(defmacro org-if-unprotected-at (pos &rest body)
|
||||
"Execute BODY if there is no `org-protected' text property at POS."
|
||||
`(unless (get-text-property ,pos 'org-protected)
|
||||
,@body))
|
||||
(def-edebug-spec org-if-unprotected-at (form body))
|
||||
(put 'org-if-unprotected-at 'lisp-indent-function 1)
|
||||
|
||||
(defun org-re-search-forward-unprotected (&rest args)
|
||||
"Like re-search-forward, but stop only in unprotected places."
|
||||
(catch 'exit
|
||||
(while t
|
||||
(unless (apply 're-search-forward args)
|
||||
(throw 'exit nil))
|
||||
(unless (get-text-property (match-beginning 0) 'org-protected)
|
||||
(throw 'exit (point))))))
|
||||
|
||||
;; FIXME: Normalize argument names
|
||||
(defmacro org-with-remote-undo (_buffer &rest _body)
|
||||
(defmacro org-with-remote-undo (buffer &rest body)
|
||||
"Execute BODY while recording undo information in two buffers."
|
||||
(org-with-gensyms (cline cmd buf1 buf2 undo1 undo2 c1 c2)
|
||||
`(let ((,cline (org-current-line))
|
||||
(,cmd this-command)
|
||||
(,buf1 (current-buffer))
|
||||
(,buf2 ,_buffer)
|
||||
(,buf2 ,buffer)
|
||||
(,undo1 buffer-undo-list)
|
||||
(,undo2 (with-current-buffer ,_buffer buffer-undo-list))
|
||||
(,undo2 (with-current-buffer ,buffer buffer-undo-list))
|
||||
,c1 ,c2)
|
||||
,@_body
|
||||
,@body
|
||||
(when org-agenda-allow-remote-undo
|
||||
(setq ,c1 (org-verify-change-for-undo
|
||||
,undo1 (with-current-buffer ,buf1 buffer-undo-list))
|
||||
@ -427,6 +386,13 @@ the value in cdr."
|
||||
(cons (list (car flat) (cadr flat))
|
||||
(org-make-parameter-alist (cddr flat)))))
|
||||
|
||||
;;;###autoload
|
||||
(defmacro org-load-noerror-mustsuffix (file)
|
||||
"Load FILE with optional arguments NOERROR and MUSTSUFFIX. Drop the MUSTSUFFIX argument for XEmacs, which doesn't recognize it."
|
||||
(if (featurep 'xemacs)
|
||||
`(load ,file 'noerror)
|
||||
`(load ,file 'noerror nil nil 'mustsuffix)))
|
||||
|
||||
(provide 'org-macs)
|
||||
|
||||
;;; org-macs.el ends here
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'org-macs)
|
||||
(require 'org)
|
||||
|
||||
;; Customization variables
|
||||
|
@ -76,6 +76,13 @@ org-agenda-text-search-extra-files
|
||||
:group 'org-mobile
|
||||
:type 'directory)
|
||||
|
||||
(defcustom org-mobile-allpriorities "A B C"
|
||||
"Default set of priority cookies for the index file."
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:type 'string
|
||||
:group 'org-mobile)
|
||||
|
||||
(defcustom org-mobile-use-encryption nil
|
||||
"Non-nil means keep only encrypted files on the WebDAV server.
|
||||
Encryption uses AES-256, with a password given in
|
||||
@ -276,7 +283,7 @@ Also exclude files matching `org-mobile-files-exclude-regexp'."
|
||||
(list f))
|
||||
(t nil)))
|
||||
org-mobile-files)))
|
||||
(files (delete
|
||||
(files (delq
|
||||
nil
|
||||
(mapcar (lambda (f)
|
||||
(unless (and (not (string= org-mobile-files-exclude-regexp ""))
|
||||
@ -300,8 +307,6 @@ Also exclude files matching `org-mobile-files-exclude-regexp'."
|
||||
(push (cons file link-name) rtn)))
|
||||
(nreverse rtn)))
|
||||
|
||||
(defvar org-agenda-filter)
|
||||
|
||||
;;;###autoload
|
||||
(defun org-mobile-push ()
|
||||
"Push the current state of Org affairs to the target directory.
|
||||
@ -314,23 +319,24 @@ create all custom agenda views, for upload to the mobile phone."
|
||||
(org-agenda-tag-filter org-agenda-tag-filter)
|
||||
(org-agenda-redo-command org-agenda-redo-command))
|
||||
(save-excursion
|
||||
(save-window-excursion
|
||||
(run-hooks 'org-mobile-pre-push-hook)
|
||||
(org-mobile-check-setup)
|
||||
(org-mobile-prepare-file-lists)
|
||||
(message "Creating agendas...")
|
||||
(let ((inhibit-redisplay t)
|
||||
(org-agenda-files (mapcar 'car org-mobile-files-alist)))
|
||||
(org-mobile-create-sumo-agenda))
|
||||
(message "Creating agendas...done")
|
||||
(org-save-all-org-buffers) ; to save any IDs created by this process
|
||||
(message "Copying files...")
|
||||
(org-mobile-copy-agenda-files)
|
||||
(message "Writing index file...")
|
||||
(org-mobile-create-index-file)
|
||||
(message "Writing checksums...")
|
||||
(org-mobile-write-checksums)
|
||||
(run-hooks 'org-mobile-post-push-hook)))
|
||||
(save-restriction
|
||||
(save-window-excursion
|
||||
(run-hooks 'org-mobile-pre-push-hook)
|
||||
(org-mobile-check-setup)
|
||||
(org-mobile-prepare-file-lists)
|
||||
(message "Creating agendas...")
|
||||
(let ((inhibit-redisplay t)
|
||||
(org-agenda-files (mapcar 'car org-mobile-files-alist)))
|
||||
(org-mobile-create-sumo-agenda))
|
||||
(message "Creating agendas...done")
|
||||
(org-save-all-org-buffers) ; to save any IDs created by this process
|
||||
(message "Copying files...")
|
||||
(org-mobile-copy-agenda-files)
|
||||
(message "Writing index file...")
|
||||
(org-mobile-create-index-file)
|
||||
(message "Writing checksums...")
|
||||
(org-mobile-write-checksums)
|
||||
(run-hooks 'org-mobile-post-push-hook))))
|
||||
(setq org-agenda-buffer-name org-agenda-curbuf-name
|
||||
org-agenda-this-buffer-name org-agenda-curbuf-name))
|
||||
(redraw-display)
|
||||
@ -463,7 +469,7 @@ agenda view showing the flagged items."
|
||||
(setq tags (append def-tags tags nil))
|
||||
(insert "#+TAGS: " (mapconcat 'identity tags " ") "\n")
|
||||
(insert "#+DRAWERS: " (mapconcat 'identity drawers " ") "\n")
|
||||
(insert "#+ALLPRIORITIES: A B C" "\n")
|
||||
(insert "#+ALLPRIORITIES: " org-mobile-allpriorities "\n")
|
||||
(when (file-exists-p (expand-file-name
|
||||
org-mobile-directory "agendas.org"))
|
||||
(insert "* [[file:agendas.org][Agenda Views]]\n"))
|
||||
@ -1061,10 +1067,13 @@ be returned that indicates what went wrong."
|
||||
(t (error "Heading changed in MobileOrg and on the computer")))))
|
||||
|
||||
((eq what 'addheading)
|
||||
(if (org-on-heading-p) ; if false we are in top-level of file
|
||||
(if (org-at-heading-p) ; if false we are in top-level of file
|
||||
(progn
|
||||
;; Workaround a `org-insert-heading-respect-content' bug
|
||||
;; which prevents correct insertion when point is invisible
|
||||
(org-show-subtree)
|
||||
(end-of-line 1)
|
||||
(org-insert-heading-respect-content t)
|
||||
(org-insert-heading-respect-content '(16) t)
|
||||
(org-demote))
|
||||
(beginning-of-line)
|
||||
(insert "* "))
|
||||
@ -1073,7 +1082,7 @@ be returned that indicates what went wrong."
|
||||
((eq what 'refile)
|
||||
(org-copy-subtree)
|
||||
(org-with-point-at (org-mobile-locate-entry new)
|
||||
(if (org-on-heading-p) ; if false we are in top-level of file
|
||||
(if (org-at-heading-p) ; if false we are in top-level of file
|
||||
(progn
|
||||
(setq level (org-get-valid-level (funcall outline-level) 1))
|
||||
(org-end-of-subtree t t)
|
||||
|
@ -656,11 +656,11 @@ This means, between the beginning of line and the point."
|
||||
["All Clear" (org-mouse-for-each-item
|
||||
(lambda ()
|
||||
(when (save-excursion (org-at-item-checkbox-p))
|
||||
(replace-match "[ ]"))))]
|
||||
(replace-match "[ ] "))))]
|
||||
["All Set" (org-mouse-for-each-item
|
||||
(lambda ()
|
||||
(when (save-excursion (org-at-item-checkbox-p))
|
||||
(replace-match "[X]"))))]
|
||||
(replace-match "[X] "))))]
|
||||
["All Toggle" (org-mouse-for-each-item 'org-toggle-checkbox) t]
|
||||
["All Remove" (org-mouse-for-each-item
|
||||
(lambda ()
|
||||
@ -1056,7 +1056,7 @@ This means, between the beginning of line and the point."
|
||||
["Convert" org-agenda-convert-date
|
||||
(org-agenda-check-type nil 'agenda 'timeline)]
|
||||
"--"
|
||||
["Create iCalendar file" org-export-icalendar-combine-agenda-files t])
|
||||
["Create iCalendar file" org-icalendar-combine-agenda-files t])
|
||||
"--"
|
||||
["Day View" org-agenda-day-view
|
||||
:active (org-agenda-check-type nil 'agenda)
|
||||
|
@ -35,9 +35,8 @@
|
||||
(require 'pcomplete)
|
||||
|
||||
(declare-function org-split-string "org" (string &optional separators))
|
||||
(declare-function org-get-current-options "org-exp" ())
|
||||
(declare-function org-make-org-heading-search-string "org"
|
||||
(&optional string heading))
|
||||
(&optional string))
|
||||
(declare-function org-get-buffer-tags "org" ())
|
||||
(declare-function org-get-tags "org" ())
|
||||
(declare-function org-buffer-property-keys "org"
|
||||
@ -46,7 +45,6 @@
|
||||
|
||||
;;;; Customization variables
|
||||
|
||||
;; Unused. Cf org-completion.
|
||||
(defgroup org-complete nil
|
||||
"Outline-based notes management and organizer."
|
||||
:tag "Org"
|
||||
@ -110,11 +108,11 @@ When completing for #+STARTUP, for example, this function returns
|
||||
(let ((thing (org-thing-at-point)))
|
||||
(cond
|
||||
((string= "file-option" (car thing))
|
||||
(concat (car thing) "/" (downcase (cdr thing))))
|
||||
(concat (car thing)
|
||||
(and (cdr thing) (concat "/" (downcase (cdr thing))))))
|
||||
((string= "block-option" (car thing))
|
||||
(concat (car thing) "/" (downcase (cdr thing))))
|
||||
(t
|
||||
(car thing)))))
|
||||
(t (car thing)))))
|
||||
|
||||
(defun org-parse-arguments ()
|
||||
"Parse whitespace separated arguments in the current region."
|
||||
@ -141,21 +139,86 @@ When completing for #+STARTUP, for example, this function returns
|
||||
(car (org-thing-at-point)))
|
||||
pcomplete-default-completion-function))))
|
||||
|
||||
(defvar org-options-keywords) ; From org.el
|
||||
(defvar org-additional-option-like-keywords) ; From org.el
|
||||
(defvar org-options-keywords) ; From org.el
|
||||
(defvar org-element-block-name-alist) ; From org-element.el
|
||||
(defvar org-element-affiliated-keywords) ; From org-element.el
|
||||
(declare-function org-get-export-keywords "org" ())
|
||||
(defun pcomplete/org-mode/file-option ()
|
||||
"Complete against all valid file options."
|
||||
(require 'org-exp)
|
||||
(require 'org-element)
|
||||
(pcomplete-here
|
||||
(org-pcomplete-case-double
|
||||
(mapcar (lambda (x)
|
||||
(if (= ?: (aref x (1- (length x))))
|
||||
(concat x " ")
|
||||
x))
|
||||
(append org-options-keywords
|
||||
org-additional-option-like-keywords)))
|
||||
(append (mapcar (lambda (keyword) (concat keyword " "))
|
||||
org-options-keywords)
|
||||
(mapcar (lambda (keyword) (concat keyword ": "))
|
||||
org-element-affiliated-keywords)
|
||||
(let (block-names)
|
||||
(dolist (block-info org-element-block-name-alist block-names)
|
||||
(let ((name (car block-info)))
|
||||
(push (format "END_%s" name) block-names)
|
||||
(push (concat "BEGIN_"
|
||||
name
|
||||
;; Since language is compulsory in
|
||||
;; source blocks, add a space.
|
||||
(and (equal name "SRC") " "))
|
||||
block-names)
|
||||
(push (format "ATTR_%s: " name) block-names))))
|
||||
(mapcar (lambda (keyword) (concat keyword ": "))
|
||||
(org-get-export-keywords))))
|
||||
(substring pcomplete-stub 2)))
|
||||
|
||||
(defun pcomplete/org-mode/file-option/author ()
|
||||
"Complete arguments for the #+AUTHOR file option."
|
||||
(pcomplete-here (list user-full-name)))
|
||||
|
||||
(defvar org-time-stamp-formats)
|
||||
(defun pcomplete/org-mode/file-option/date ()
|
||||
"Complete arguments for the #+DATE file option."
|
||||
(pcomplete-here (list (format-time-string (car org-time-stamp-formats)))))
|
||||
|
||||
(defun pcomplete/org-mode/file-option/email ()
|
||||
"Complete arguments for the #+EMAIL file option."
|
||||
(pcomplete-here (list user-mail-address)))
|
||||
|
||||
(defvar org-export-exclude-tags)
|
||||
(defun pcomplete/org-mode/file-option/exclude_tags ()
|
||||
"Complete arguments for the #+EXCLUDE_TAGS file option."
|
||||
(require 'ox)
|
||||
(pcomplete-here
|
||||
(and org-export-exclude-tags
|
||||
(list (mapconcat 'identity org-export-exclude-tags " ")))))
|
||||
|
||||
(defvar org-file-tags)
|
||||
(defun pcomplete/org-mode/file-option/filetags ()
|
||||
"Complete arguments for the #+FILETAGS file option."
|
||||
(pcomplete-here (and org-file-tags (mapconcat 'identity org-file-tags " "))))
|
||||
|
||||
(defvar org-export-default-language)
|
||||
(defun pcomplete/org-mode/file-option/language ()
|
||||
"Complete arguments for the #+LANGUAGE file option."
|
||||
(require 'ox)
|
||||
(pcomplete-here
|
||||
(pcomplete-uniqify-list
|
||||
(list org-export-default-language "en"))))
|
||||
|
||||
(defvar org-default-priority)
|
||||
(defvar org-highest-priority)
|
||||
(defvar org-lowest-priority)
|
||||
(defun pcomplete/org-mode/file-option/priorities ()
|
||||
"Complete arguments for the #+PRIORITIES file option."
|
||||
(pcomplete-here (list (format "%c %c %c"
|
||||
org-highest-priority
|
||||
org-lowest-priority
|
||||
org-default-priority))))
|
||||
|
||||
(defvar org-export-select-tags)
|
||||
(defun pcomplete/org-mode/file-option/select_tags ()
|
||||
"Complete arguments for the #+SELECT_TAGS file option."
|
||||
(require 'ox)
|
||||
(pcomplete-here
|
||||
(and org-export-select-tags
|
||||
(list (mapconcat 'identity org-export-select-tags " ")))))
|
||||
|
||||
(defvar org-startup-options)
|
||||
(defun pcomplete/org-mode/file-option/startup ()
|
||||
"Complete arguments for the #+STARTUP file option."
|
||||
@ -170,37 +233,57 @@ When completing for #+STARTUP, for example, this function returns
|
||||
(setq opts (delete "showstars" opts)))))
|
||||
opts))))
|
||||
|
||||
(defmacro pcomplete/org-mode/file-option/x (option)
|
||||
"Complete arguments for OPTION."
|
||||
`(while
|
||||
(pcomplete-here
|
||||
(pcomplete-uniqify-list
|
||||
(delq nil
|
||||
(mapcar (lambda(o)
|
||||
(when (string-match (concat "^[ \t]*#\\+"
|
||||
,option ":[ \t]+\\(.*\\)[ \t]*$") o)
|
||||
(match-string 1 o)))
|
||||
(split-string (org-get-current-options) "\n")))))))
|
||||
|
||||
(defun pcomplete/org-mode/file-option/options ()
|
||||
"Complete arguments for the #+OPTIONS file option."
|
||||
(pcomplete/org-mode/file-option/x "OPTIONS"))
|
||||
(defvar org-tag-alist)
|
||||
(defun pcomplete/org-mode/file-option/tags ()
|
||||
"Complete arguments for the #+TAGS file option."
|
||||
(pcomplete-here
|
||||
(list
|
||||
(mapconcat (lambda (x)
|
||||
(cond
|
||||
((eq :startgroup (car x)) "{")
|
||||
((eq :endgroup (car x)) "}")
|
||||
((eq :grouptags (car x)) ":")
|
||||
((eq :newline (car x)) "\\n")
|
||||
((cdr x) (format "%s(%c)" (car x) (cdr x)))
|
||||
(t (car x))))
|
||||
org-tag-alist " "))))
|
||||
|
||||
(defun pcomplete/org-mode/file-option/title ()
|
||||
"Complete arguments for the #+TITLE file option."
|
||||
(pcomplete/org-mode/file-option/x "TITLE"))
|
||||
(pcomplete-here
|
||||
(let ((visited-file (buffer-file-name (buffer-base-buffer))))
|
||||
(list (or (and visited-file
|
||||
(file-name-sans-extension
|
||||
(file-name-nondirectory visited-file)))
|
||||
(buffer-name (buffer-base-buffer)))))))
|
||||
|
||||
(defun pcomplete/org-mode/file-option/author ()
|
||||
"Complete arguments for the #+AUTHOR file option."
|
||||
(pcomplete/org-mode/file-option/x "AUTHOR"))
|
||||
|
||||
(defun pcomplete/org-mode/file-option/email ()
|
||||
"Complete arguments for the #+EMAIL file option."
|
||||
(pcomplete/org-mode/file-option/x "EMAIL"))
|
||||
(declare-function org-export-backend-options "org-export" (cl-x))
|
||||
(defun pcomplete/org-mode/file-option/options ()
|
||||
"Complete arguments for the #+OPTIONS file option."
|
||||
(while (pcomplete-here
|
||||
(pcomplete-uniqify-list
|
||||
(append
|
||||
;; Hard-coded OPTION items always available.
|
||||
'("H:" "\\n:" "num:" "timestamp:" "arch:" "author:" "c:"
|
||||
"creator:" "date:" "d:" "email:" "*:" "e:" "::" "f:"
|
||||
"inline:" "tex:" "p:" "pri:" "':" "-:" "stat:" "^:" "toc:"
|
||||
"|:" "tags:" "tasks:" "<:" "todo:")
|
||||
;; OPTION items from registered back-ends.
|
||||
(let (items)
|
||||
(dolist (backend (org-bound-and-true-p
|
||||
org-export--registered-backends))
|
||||
(dolist (option (org-export-backend-options backend))
|
||||
(let ((item (nth 2 option)))
|
||||
(when item (push (concat item ":") items)))))
|
||||
items))))))
|
||||
|
||||
(defun pcomplete/org-mode/file-option/date ()
|
||||
"Complete arguments for the #+DATE file option."
|
||||
(pcomplete/org-mode/file-option/x "DATE"))
|
||||
(defun pcomplete/org-mode/file-option/infojs_opt ()
|
||||
"Complete arguments for the #+INFOJS_OPT file option."
|
||||
(while (pcomplete-here
|
||||
(pcomplete-uniqify-list
|
||||
(mapcar (lambda (item) (format "%s:" (car item)))
|
||||
(org-bound-and-true-p org-html-infojs-opts-table))))))
|
||||
|
||||
(defun pcomplete/org-mode/file-option/bind ()
|
||||
"Complete arguments for the #+BIND file option, which are variable names."
|
||||
@ -243,7 +326,7 @@ This needs more work, to handle headings with lots of spaces in them."
|
||||
(let (tbl)
|
||||
(while (re-search-forward org-todo-line-regexp nil t)
|
||||
(push (org-make-org-heading-search-string
|
||||
(match-string-no-properties 3) t)
|
||||
(match-string-no-properties 3))
|
||||
tbl))
|
||||
(pcomplete-uniqify-list tbl)))
|
||||
(substring pcomplete-stub 1))))
|
||||
@ -291,7 +374,7 @@ This needs more work, to handle headings with lots of spaces in them."
|
||||
(cpllist (mapcar (lambda (x) (concat x ": ")) org-drawers)))
|
||||
(pcomplete-here cpllist
|
||||
(substring pcomplete-stub 1)
|
||||
(unless (or (not (delete
|
||||
(unless (or (not (delq
|
||||
nil
|
||||
(mapcar (lambda(x)
|
||||
(string-match (substring pcomplete-stub 1) x))
|
||||
@ -313,16 +396,16 @@ Complete a language in the first field, the header arguments and switches."
|
||||
'("-n" "-r" "-l"
|
||||
":cache" ":colnames" ":comments" ":dir" ":eval" ":exports"
|
||||
":file" ":hlines" ":no-expand" ":noweb" ":results" ":rownames"
|
||||
":session" ":shebang" ":tangle" ":var"))))
|
||||
":session" ":shebang" ":tangle" ":tangle-mode" ":var"))))
|
||||
|
||||
(defun pcomplete/org-mode/block-option/clocktable ()
|
||||
"Complete keywords in a clocktable line."
|
||||
(while (pcomplete-here '(":maxlevel" ":scope"
|
||||
(while (pcomplete-here '(":maxlevel" ":scope" ":lang"
|
||||
":tstart" ":tend" ":block" ":step"
|
||||
":stepskip0" ":fileskip0"
|
||||
":emphasize" ":link" ":narrow" ":indent"
|
||||
":tcolumns" ":level" ":compact" ":timestamp"
|
||||
":formula" ":formatter"))))
|
||||
":formula" ":formatter" ":wstart" ":mstart"))))
|
||||
|
||||
(defun org-pcomplete-case-double (list)
|
||||
"Return list with both upcase and downcase version of all strings in LIST."
|
||||
|
@ -30,7 +30,6 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'org)
|
||||
(require 'org-exp)
|
||||
(require 'org-table)
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
|
@ -2,7 +2,7 @@
|
||||
;;
|
||||
;; Copyright (C) 2008-2013 Free Software Foundation, Inc.
|
||||
;;
|
||||
;; Authors: Bastien Guerry <bzg AT gnu DOT org>
|
||||
;; Authors: Bastien Guerry <bzg@gnu.org>
|
||||
;; Daniel M German <dmg AT uvic DOT org>
|
||||
;; Sebastian Rose <sebastian_rose AT gmx DOT de>
|
||||
;; Ross Patterson <me AT rpatterson DOT net>
|
||||
@ -91,11 +91,6 @@
|
||||
;; Org-link of which the page title will be the description part. If text
|
||||
;; was select in the browser, that text will be the body of the entry.
|
||||
;;
|
||||
;; * Call `org-protocol-remember' by using the sub-protocol \"remember\".
|
||||
;; This is provided for backward compatibility.
|
||||
;; You may read `org-capture' as `org-remember' throughout this file if
|
||||
;; you still use `org-remember'.
|
||||
;;
|
||||
;; You may use the same bookmark URL for all those standard handlers and just
|
||||
;; adjust the sub-protocol used:
|
||||
;;
|
||||
@ -155,8 +150,7 @@ for `org-protocol-the-protocol' and sub-protocols defined in
|
||||
;;; Variables:
|
||||
|
||||
(defconst org-protocol-protocol-alist-default
|
||||
'(("org-remember" :protocol "remember" :function org-protocol-remember :kill-client t)
|
||||
("org-capture" :protocol "capture" :function org-protocol-capture :kill-client t)
|
||||
'(("org-capture" :protocol "capture" :function org-protocol-capture :kill-client t)
|
||||
("org-store-link" :protocol "store-link" :function org-protocol-store-link)
|
||||
("org-open-source" :protocol "open-source" :function org-protocol-open-source))
|
||||
"Default protocols to use.
|
||||
@ -271,12 +265,14 @@ Here is an example:
|
||||
This is usually a single character string but can also be a
|
||||
string with two characters."
|
||||
:group 'org-protocol
|
||||
:type 'string)
|
||||
:type '(choice (const nil) (string)))
|
||||
|
||||
(defcustom org-protocol-data-separator "/+"
|
||||
(defcustom org-protocol-data-separator "/+\\|\\?"
|
||||
"The default data separator to use.
|
||||
This should be a single regexp string."
|
||||
:group 'org-protocol
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:type 'string)
|
||||
|
||||
;;; Helper functions:
|
||||
@ -297,7 +293,7 @@ nil, assume \"/+\". The results of that splitting are returned
|
||||
as a list. If UNHEXIFY is non-nil, hex-decode each split part.
|
||||
If UNHEXIFY is a function, use that function to decode each split
|
||||
part."
|
||||
(let* ((sep (or separator "/+"))
|
||||
(let* ((sep (or separator "/+\\|\\?"))
|
||||
(split-parts (split-string data sep)))
|
||||
(if unhexify
|
||||
(if (fboundp unhexify)
|
||||
@ -391,32 +387,14 @@ The sub-protocol used to reach this function is set in
|
||||
uri))
|
||||
nil)
|
||||
|
||||
(defun org-protocol-remember (info)
|
||||
"Process an org-protocol://remember:// style url.
|
||||
|
||||
The location for a browser's bookmark has to look like this:
|
||||
|
||||
javascript:location.href='org-protocol://remember://'+ \\
|
||||
encodeURIComponent(location.href)+'/' \\
|
||||
encodeURIComponent(document.title)+'/'+ \\
|
||||
encodeURIComponent(window.getSelection())
|
||||
|
||||
See the docs for `org-protocol-capture' for more information."
|
||||
|
||||
(if (and (boundp 'org-stored-links)
|
||||
(fboundp 'org-capture)
|
||||
(org-protocol-do-capture info 'org-remember))
|
||||
(message "Item remembered."))
|
||||
nil)
|
||||
|
||||
(defun org-protocol-capture (info)
|
||||
"Process an org-protocol://capture:// style url.
|
||||
|
||||
The sub-protocol used to reach this function is set in
|
||||
`org-protocol-protocol-alist'.
|
||||
|
||||
This function detects an URL, title and optional text, separated by '/'
|
||||
The location for a browser's bookmark has to look like this:
|
||||
This function detects an URL, title and optional text, separated
|
||||
by '/'. The location for a browser's bookmark looks like this:
|
||||
|
||||
javascript:location.href='org-protocol://capture://'+ \\
|
||||
encodeURIComponent(location.href)+'/' \\
|
||||
@ -431,14 +409,20 @@ But you may prepend the encoded URL with a character and a slash like so:
|
||||
|
||||
Now template ?b will be used."
|
||||
(if (and (boundp 'org-stored-links)
|
||||
(fboundp 'org-capture)
|
||||
(org-protocol-do-capture info 'org-capture))
|
||||
(org-protocol-do-capture info))
|
||||
(message "Item captured."))
|
||||
nil)
|
||||
|
||||
(defun org-protocol-do-capture (info capture-func)
|
||||
"Support `org-capture' and `org-remember' alike.
|
||||
CAPTURE-FUNC is either the symbol `org-remember' or `org-capture'."
|
||||
(defun org-protocol-convert-query-to-plist (query)
|
||||
"Convert query string that is part of url to property list."
|
||||
(if query
|
||||
(apply 'append (mapcar (lambda (x)
|
||||
(let ((c (split-string x "=")))
|
||||
(list (intern (concat ":" (car c))) (cadr c))))
|
||||
(split-string query "&")))))
|
||||
|
||||
(defun org-protocol-do-capture (info)
|
||||
"Support `org-capture'."
|
||||
(let* ((parts (org-protocol-split-data info t org-protocol-data-separator))
|
||||
(template (or (and (>= 2 (length (car parts))) (pop parts))
|
||||
org-protocol-default-template-key))
|
||||
@ -449,8 +433,8 @@ CAPTURE-FUNC is either the symbol `org-remember' or `org-capture'."
|
||||
(region (or (caddr parts) ""))
|
||||
(orglink (org-make-link-string
|
||||
url (if (string-match "[^[:space:]]" title) title url)))
|
||||
(org-capture-link-is-already-stored t) ;; avoid call to org-store-link
|
||||
remember-annotation-functions)
|
||||
(query (or (org-protocol-convert-query-to-plist (cadddr parts)) ""))
|
||||
(org-capture-link-is-already-stored t)) ;; avoid call to org-store-link
|
||||
(setq org-stored-links
|
||||
(cons (list url title) org-stored-links))
|
||||
(kill-new orglink)
|
||||
@ -458,9 +442,10 @@ CAPTURE-FUNC is either the symbol `org-remember' or `org-capture'."
|
||||
:link url
|
||||
:description title
|
||||
:annotation orglink
|
||||
:initial region)
|
||||
:initial region
|
||||
:query query)
|
||||
(raise-frame)
|
||||
(funcall capture-func nil template)))
|
||||
(funcall 'org-capture nil template)))
|
||||
|
||||
(defun org-protocol-open-source (fname)
|
||||
"Process an org-protocol://open-source:// style url.
|
||||
@ -588,9 +573,9 @@ as filename."
|
||||
|
||||
(defun org-protocol-create-for-org ()
|
||||
"Create a org-protocol project for the current file's Org-mode project.
|
||||
This works, if the file visited is part of a publishing project in
|
||||
`org-publish-project-alist'. This function calls `org-protocol-create' to do
|
||||
most of the work."
|
||||
The visited file needs to be part of a publishing project in
|
||||
`org-publish-project-alist' for this to work. The function
|
||||
delegates most of the work to `org-protocol-create'."
|
||||
(interactive)
|
||||
(require 'org-publish)
|
||||
(let ((all (or (org-publish-get-project-from-filename buffer-file-name))))
|
||||
@ -600,10 +585,11 @@ most of the work."
|
||||
|
||||
(defun org-protocol-create (&optional project-plist)
|
||||
"Create a new org-protocol project interactively.
|
||||
An org-protocol project is an entry in `org-protocol-project-alist'
|
||||
which is used by `org-protocol-open-source'.
|
||||
Optionally use project-plist to initialize the defaults for this project. If
|
||||
project-plist is the CDR of an element in `org-publish-project-alist', reuse
|
||||
An org-protocol project is an entry in
|
||||
`org-protocol-project-alist' which is used by
|
||||
`org-protocol-open-source'. Optionally use PROJECT-PLIST to
|
||||
initialize the defaults for this project. If PROJECT-PLIST is
|
||||
the cdr of an element in `org-publish-project-alist', reuse
|
||||
:base-directory, :html-extension and :base-extension."
|
||||
(interactive)
|
||||
(let ((working-dir (expand-file-name
|
||||
|
@ -3,7 +3,7 @@
|
||||
;; Copyright (C) 2004-2013 Free Software Foundation, Inc.
|
||||
;;
|
||||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Bastien Guerry <bzg AT gnu DOT org>
|
||||
;; Bastien Guerry <bzg@gnu.org>
|
||||
;; Dan Davison <davison at stats dot ox dot ac dot uk>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
@ -64,6 +64,30 @@ there are kept outside the narrowed region."
|
||||
(const :tag "from `lang' element")
|
||||
(const :tag "from `style' element")))))
|
||||
|
||||
(defcustom org-edit-src-turn-on-auto-save nil
|
||||
"Non-nil means turn `auto-save-mode' on when editing a source block.
|
||||
This will save the content of the source code editing buffer into
|
||||
a newly created file, not the base buffer for this source block.
|
||||
|
||||
If you want to regularily save the base buffer instead of the source
|
||||
code editing buffer, see `org-edit-src-auto-save-idle-delay' instead."
|
||||
:group 'org-edit-structure
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-edit-src-auto-save-idle-delay 0
|
||||
"Delay before saving a source code buffer back into its base buffer.
|
||||
When a positive integer N, save after N seconds of idle time.
|
||||
When 0 (the default), don't auto-save.
|
||||
|
||||
If you want to save the source code buffer itself, don't use this.
|
||||
Check `org-edit-src-turn-on-auto-save' instead."
|
||||
:group 'org-edit-structure
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:type 'integer)
|
||||
|
||||
(defcustom org-coderef-label-format "(ref:%s)"
|
||||
"The default coderef format.
|
||||
This format string will be used to search for coderef labels in literal
|
||||
@ -155,7 +179,7 @@ but which mess up the display of a snippet in Org exported files.")
|
||||
(defcustom org-src-lang-modes
|
||||
'(("ocaml" . tuareg) ("elisp" . emacs-lisp) ("ditaa" . artist)
|
||||
("asymptote" . asy) ("dot" . fundamental) ("sqlite" . sql)
|
||||
("calc" . fundamental) ("C" . c) ("cpp" . c++)
|
||||
("calc" . fundamental) ("C" . c) ("cpp" . c++) ("C++" . c++)
|
||||
("screen" . shell-script))
|
||||
"Alist mapping languages to their major mode.
|
||||
The key is the language name, the value is the string that should
|
||||
@ -174,6 +198,7 @@ For example, there is no ocaml-mode in Emacs, but the mode to use is
|
||||
|
||||
(defvar org-src-mode-map (make-sparse-keymap))
|
||||
(define-key org-src-mode-map "\C-c'" 'org-edit-src-exit)
|
||||
(define-key org-src-mode-map "\C-c\C-k" 'org-edit-src-abort)
|
||||
(define-key org-src-mode-map "\C-x\C-s" 'org-edit-src-save)
|
||||
|
||||
(defvar org-edit-src-force-single-line nil)
|
||||
@ -186,11 +211,15 @@ For example, there is no ocaml-mode in Emacs, but the mode to use is
|
||||
(defvar org-edit-src-block-indentation nil)
|
||||
(defvar org-edit-src-saved-temp-window-config nil)
|
||||
|
||||
(defvar org-src-ask-before-returning-to-edit-buffer t
|
||||
(defcustom org-src-ask-before-returning-to-edit-buffer t
|
||||
"If nil, when org-edit-src code is used on a block that already
|
||||
has an active edit buffer, it will switch to that edit buffer
|
||||
immediately; otherwise it will ask whether you want to return to
|
||||
the existing edit buffer.")
|
||||
the existing edit buffer."
|
||||
:group 'org-edit-structure
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:type 'boolean)
|
||||
|
||||
(defvar org-src-babel-info nil)
|
||||
|
||||
@ -202,6 +231,7 @@ This minor mode is turned on in two situations:
|
||||
There is a mode hook, and keybindings for `org-edit-src-exit' and
|
||||
`org-edit-src-save'")
|
||||
|
||||
(defvar org-edit-src-code-timer nil)
|
||||
(defun org-edit-src-code (&optional context code edit-buffer-name)
|
||||
"Edit the source CODE block at point.
|
||||
The code is copied to a separate buffer and the appropriate mode
|
||||
@ -241,8 +271,8 @@ the display of windows containing the Org buffer and the code buffer."
|
||||
end (move-marker end (nth 1 info))
|
||||
msg (if allow-write-back-p
|
||||
(substitute-command-keys
|
||||
"Edit, then exit with C-c ' (C-c and single quote)")
|
||||
"Exit with C-c ' (C-c and single quote)")
|
||||
"Edit, then exit with C-c ' (C-c and single quote) -- C-c C-k to abort")
|
||||
"Exit with C-c ' (C-c and single quote) -- C-c C-k to abort")
|
||||
code (or code (buffer-substring-no-properties beg end))
|
||||
lang (or (cdr (assoc (nth 2 info) org-src-lang-modes))
|
||||
(nth 2 info))
|
||||
@ -336,12 +366,33 @@ the display of windows containing the Org buffer and the code buffer."
|
||||
(org-src-mode)
|
||||
(set-buffer-modified-p nil)
|
||||
(setq buffer-file-name nil)
|
||||
(when org-edit-src-turn-on-auto-save
|
||||
(setq buffer-auto-save-file-name
|
||||
(concat (make-temp-name "org-src-")
|
||||
(format-time-string "-%Y-%d-%m") ".txt")))
|
||||
(and org-edit-src-persistent-message
|
||||
(org-set-local 'header-line-format msg))
|
||||
(let ((edit-prep-func (intern (concat "org-babel-edit-prep:" lang))))
|
||||
(when (fboundp edit-prep-func)
|
||||
(funcall edit-prep-func full-info))))
|
||||
t)))
|
||||
(funcall edit-prep-func full-info)))
|
||||
(or org-edit-src-code-timer
|
||||
(setq org-edit-src-code-timer
|
||||
(unless (zerop org-edit-src-auto-save-idle-delay)
|
||||
(run-with-idle-timer
|
||||
org-edit-src-auto-save-idle-delay t
|
||||
(lambda ()
|
||||
(cond
|
||||
((and (string-match "\*Org Src" (buffer-name))
|
||||
(buffer-modified-p))
|
||||
(org-edit-src-save))
|
||||
((not
|
||||
(delq nil (mapcar
|
||||
(lambda (b)
|
||||
(string-match "\*Org Src" (buffer-name b)))
|
||||
(buffer-list))))
|
||||
(cancel-timer org-edit-src-code-timer)
|
||||
(setq org-edit-src-code-timer)))))))))
|
||||
t)))
|
||||
|
||||
(defun org-edit-src-continue (e)
|
||||
"Continue editing source blocks." ;; Fixme: be more accurate
|
||||
@ -420,7 +471,7 @@ the fragment in the Org-mode buffer."
|
||||
(col (current-column))
|
||||
(case-fold-search t)
|
||||
(msg (substitute-command-keys
|
||||
"Edit, then exit with C-c ' (C-c and single quote)"))
|
||||
"Edit, then exit with C-c ' (C-c and single quote) -- C-c C-k to abort"))
|
||||
(org-mode-p (derived-mode-p 'org-mode))
|
||||
(beg (make-marker))
|
||||
(end (make-marker))
|
||||
@ -520,10 +571,8 @@ the language, a switch telling if the content should be in a single line."
|
||||
("^[ \t]*#\\+begin_latex.*\n" "\n[ \t]*#\\+end_latex" "latex")
|
||||
("^[ \t]*#\\+ascii:" "\n" "fundamental" single-line)
|
||||
("^[ \t]*#\\+begin_ascii.*\n" "\n[ \t]*#\\+end_ascii" "fundamental")
|
||||
("^[ \t]*#\\+docbook:" "\n" "xml" single-line)
|
||||
("^[ \t]*#\\+macro:[ \t]+\\S-+\\( \\|$\\)"
|
||||
"\n" "fundamental" macro-definition)
|
||||
("^[ \t]*#\\+begin_docbook.*\n" "\n[ \t]*#\\+end_docbook" "xml")
|
||||
)))
|
||||
(pos (point))
|
||||
re1 re2 single beg end lang lfmt match-re1 ind entry)
|
||||
@ -699,14 +748,19 @@ with \",*\", \",#+\", \",,*\" and \",,#+\"."
|
||||
(set-buffer-modified-p nil))
|
||||
(org-src-switch-to-buffer (marker-buffer beg) (or context 'exit))
|
||||
(if (eq context 'save) (save-buffer)
|
||||
(with-current-buffer buffer
|
||||
(set-buffer-modified-p nil))
|
||||
(kill-buffer buffer))
|
||||
(goto-char beg)
|
||||
(when allow-write-back-p
|
||||
(delete-region beg (max beg end))
|
||||
(unless (string-match "\\`[ \t]*\\'" code)
|
||||
(insert code))
|
||||
(goto-char beg)
|
||||
(if single (just-one-space)))
|
||||
(let ((buffer-undo-list t))
|
||||
(delete-region beg (max beg end))
|
||||
(unless (string-match "\\`[ \t]*\\'" code)
|
||||
(insert code))
|
||||
;; Make sure the overlay stays in place
|
||||
(when (eq context 'save) (move-overlay ovl beg (point)))
|
||||
(goto-char beg)
|
||||
(if single (just-one-space))))
|
||||
(if (memq t (mapcar (lambda (overlay)
|
||||
(eq (overlay-get overlay 'invisible)
|
||||
'org-hide-block))
|
||||
@ -714,16 +768,26 @@ with \",*\", \",#+\", \",,*\" and \",,#+\"."
|
||||
;; Block is hidden; put point at start of block
|
||||
(beginning-of-line 0)
|
||||
;; Block is visible, put point where it was in the code buffer
|
||||
(org-goto-line (1- (+ (org-current-line) line)))
|
||||
(org-move-to-column (if preserve-indentation col (+ col total-nindent delta))))
|
||||
(when allow-write-back-p
|
||||
(org-goto-line (1- (+ (org-current-line) line)))
|
||||
(org-move-to-column (if preserve-indentation col (+ col total-nindent delta)))))
|
||||
(unless (eq context 'save)
|
||||
(move-marker beg nil)
|
||||
(move-marker end nil)))
|
||||
(when org-edit-src-code-timer
|
||||
(cancel-timer org-edit-src-code-timer)
|
||||
(setq org-edit-src-code-timer nil))
|
||||
(unless (eq context 'save)
|
||||
(when org-edit-src-saved-temp-window-config
|
||||
(set-window-configuration org-edit-src-saved-temp-window-config)
|
||||
(setq org-edit-src-saved-temp-window-config nil))))
|
||||
|
||||
(defun org-edit-src-abort ()
|
||||
"Abort editing of the src code and return to the Org buffer."
|
||||
(interactive)
|
||||
(let (org-edit-src-allow-write-back-p)
|
||||
(org-edit-src-exit 'exit)))
|
||||
|
||||
(defmacro org-src-in-org-buffer (&rest body)
|
||||
`(let ((p (point)) (m (mark)) (ul buffer-undo-list) msg)
|
||||
(save-window-excursion
|
||||
@ -743,9 +807,11 @@ with \",*\", \",#+\", \",,*\" and \",,#+\"."
|
||||
(defun org-edit-src-save ()
|
||||
"Save parent buffer with current state source-code buffer."
|
||||
(interactive)
|
||||
(org-src-in-org-buffer (save-buffer)))
|
||||
(if (string-match "Fixed Width" (buffer-name))
|
||||
(user-error "Use C-c ' to save and exit, C-c C-k to abort editing")
|
||||
(org-src-in-org-buffer (save-buffer))))
|
||||
|
||||
(declare-function org-babel-tangle "ob-tangle" (&optional only-this-block target-file lang))
|
||||
(declare-function org-babel-tangle "ob-tangle" (&optional arg target-file lang))
|
||||
|
||||
(defun org-src-tangle (arg)
|
||||
"Tangle the parent buffer."
|
||||
@ -829,9 +895,9 @@ issued in the language major mode buffer."
|
||||
|
||||
(defun org-src-native-tab-command-maybe ()
|
||||
"Perform language-specific TAB action.
|
||||
Alter code block according to effect of TAB in the language major
|
||||
mode."
|
||||
Alter code block according to what TAB does in the language major mode."
|
||||
(and org-src-tab-acts-natively
|
||||
(org-in-src-block-p)
|
||||
(not (equal this-command 'org-shifttab))
|
||||
(let ((org-src-strip-leading-and-trailing-blank-lines nil))
|
||||
(org-babel-do-key-sequence-in-edit-buffer (kbd "TAB")))))
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -370,6 +370,8 @@ VALUE can be `on', `off', or `pause'."
|
||||
(message "%d minute(s) %d seconds left before next time out"
|
||||
rmins rsecs))))
|
||||
|
||||
(defvar org-clock-sound)
|
||||
|
||||
;;;###autoload
|
||||
(defun org-timer-set-timer (&optional opt)
|
||||
"Prompt for a duration and set a timer.
|
||||
@ -429,7 +431,7 @@ replace any running timer."
|
||||
(run-with-timer
|
||||
secs nil `(lambda ()
|
||||
(setq org-timer-current-timer nil)
|
||||
(org-notify ,(format "%s: time out" hl) t)
|
||||
(org-notify ,(format "%s: time out" hl) ,org-clock-sound)
|
||||
(setq org-timer-timer-is-countdown nil)
|
||||
(org-timer-set-mode-line 'off)
|
||||
(run-hooks 'org-timer-done-hook))))
|
||||
|
@ -5,13 +5,13 @@
|
||||
(defun org-release ()
|
||||
"The release version of org-mode.
|
||||
Inserted by installing org-mode or when a release is made."
|
||||
(let ((org-release "7.9.3f"))
|
||||
(let ((org-release "8.2.3a"))
|
||||
org-release))
|
||||
;;;###autoload
|
||||
(defun org-git-version ()
|
||||
"The Git version of org-mode.
|
||||
Inserted by installing org-mode or when a release is made."
|
||||
(let ((org-git-version "release_7.9.3f-17-g7524ef"))
|
||||
(let ((org-git-version "release_8.2.3a"))
|
||||
org-git-version))
|
||||
;;;###autoload
|
||||
(defvar org-odt-data-dir "/usr/share/emacs/etc/org"
|
||||
|
@ -8,12 +8,12 @@
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; 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.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; 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.
|
||||
@ -43,6 +43,19 @@
|
||||
|
||||
(require 'org)
|
||||
|
||||
(defvar w3m-current-url)
|
||||
(defvar w3m-current-title)
|
||||
|
||||
(add-hook 'org-store-link-functions 'org-w3m-store-link)
|
||||
(defun org-w3m-store-link ()
|
||||
"Store a link to a w3m buffer."
|
||||
(when (eq major-mode 'w3m-mode)
|
||||
(org-store-link-props
|
||||
:type "w3m"
|
||||
:link w3m-current-url
|
||||
:url (url-view-url t)
|
||||
:description (or w3m-current-title w3m-current-url))))
|
||||
|
||||
(defun org-w3m-copy-for-org-mode ()
|
||||
"Copy current buffer content or active region with `org-mode' style links.
|
||||
This will encode `link-title' and `link-location' with
|
||||
|
6007
lisp/org/org.el
6007
lisp/org/org.el
File diff suppressed because it is too large
Load Diff
1973
lisp/org/ox-ascii.el
Normal file
1973
lisp/org/ox-ascii.el
Normal file
File diff suppressed because it is too large
Load Diff
1179
lisp/org/ox-beamer.el
Normal file
1179
lisp/org/ox-beamer.el
Normal file
File diff suppressed because it is too large
Load Diff
3427
lisp/org/ox-html.el
Normal file
3427
lisp/org/ox-html.el
Normal file
File diff suppressed because it is too large
Load Diff
979
lisp/org/ox-icalendar.el
Normal file
979
lisp/org/ox-icalendar.el
Normal file
@ -0,0 +1,979 @@
|
||||
;;; ox-icalendar.el --- iCalendar Back-End for Org Export Engine
|
||||
|
||||
;; Copyright (C) 2004-2012 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Nicolas Goaziou <n dot goaziou at gmail dot com>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
|
||||
;; GNU Emacs 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.
|
||||
|
||||
;; GNU Emacs 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 GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; This library implements an iCalendar back-end for Org generic
|
||||
;; exporter. See Org manual for more information.
|
||||
;;
|
||||
;; It is expected to conform to RFC 5545.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(eval-when-compile (require 'cl))
|
||||
(require 'ox-ascii)
|
||||
(declare-function org-bbdb-anniv-export-ical "org-bbdb" nil)
|
||||
|
||||
|
||||
|
||||
;;; User-Configurable Variables
|
||||
|
||||
(defgroup org-export-icalendar nil
|
||||
"Options specific for iCalendar export back-end."
|
||||
:tag "Org Export iCalendar"
|
||||
:group 'org-export)
|
||||
|
||||
(defcustom org-icalendar-combined-agenda-file "~/org.ics"
|
||||
"The file name for the iCalendar file covering all agenda files.
|
||||
This file is created with the command \\[org-icalendar-combine-agenda-files].
|
||||
The file name should be absolute. It will be overwritten without warning."
|
||||
:group 'org-export-icalendar
|
||||
:type 'file)
|
||||
|
||||
(defcustom org-icalendar-alarm-time 0
|
||||
"Number of minutes for triggering an alarm for exported timed events.
|
||||
|
||||
A zero value (the default) turns off the definition of an alarm trigger
|
||||
for timed events. If non-zero, alarms are created.
|
||||
|
||||
- a single alarm per entry is defined
|
||||
- The alarm will go off N minutes before the event
|
||||
- only a DISPLAY action is defined."
|
||||
:group 'org-export-icalendar
|
||||
:version "24.1"
|
||||
:type 'integer)
|
||||
|
||||
(defcustom org-icalendar-combined-name "OrgMode"
|
||||
"Calendar name for the combined iCalendar representing all agenda files."
|
||||
:group 'org-export-icalendar
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-icalendar-combined-description ""
|
||||
"Calendar description for the combined iCalendar (all agenda files)."
|
||||
:group 'org-export-icalendar
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-icalendar-exclude-tags nil
|
||||
"Tags that exclude a tree from export.
|
||||
This variable allows to specify different exclude tags from other
|
||||
back-ends. It can also be set with the ICAL_EXCLUDE_TAGS
|
||||
keyword."
|
||||
:group 'org-export-icalendar
|
||||
:type '(repeat (string :tag "Tag")))
|
||||
|
||||
(defcustom org-icalendar-use-deadline '(event-if-not-todo todo-due)
|
||||
"Contexts where iCalendar export should use a deadline time stamp.
|
||||
|
||||
This is a list with several symbols in it. Valid symbol are:
|
||||
`event-if-todo' Deadlines in TODO entries become calendar events.
|
||||
`event-if-not-todo' Deadlines in non-TODO entries become calendar events.
|
||||
`todo-due' Use deadlines in TODO entries as due-dates"
|
||||
:group 'org-export-icalendar
|
||||
:type '(set :greedy t
|
||||
(const :tag "Deadlines in non-TODO entries become events"
|
||||
event-if-not-todo)
|
||||
(const :tag "Deadline in TODO entries become events"
|
||||
event-if-todo)
|
||||
(const :tag "Deadlines in TODO entries become due-dates"
|
||||
todo-due)))
|
||||
|
||||
(defcustom org-icalendar-use-scheduled '(todo-start)
|
||||
"Contexts where iCalendar export should use a scheduling time stamp.
|
||||
|
||||
This is a list with several symbols in it. Valid symbol are:
|
||||
`event-if-todo' Scheduling time stamps in TODO entries become an event.
|
||||
`event-if-not-todo' Scheduling time stamps in non-TODO entries become an event.
|
||||
`todo-start' Scheduling time stamps in TODO entries become start date.
|
||||
Some calendar applications show TODO entries only after
|
||||
that date."
|
||||
:group 'org-export-icalendar
|
||||
:type '(set :greedy t
|
||||
(const :tag
|
||||
"SCHEDULED timestamps in non-TODO entries become events"
|
||||
event-if-not-todo)
|
||||
(const :tag "SCHEDULED timestamps in TODO entries become events"
|
||||
event-if-todo)
|
||||
(const :tag "SCHEDULED in TODO entries become start date"
|
||||
todo-start)))
|
||||
|
||||
(defcustom org-icalendar-categories '(local-tags category)
|
||||
"Items that should be entered into the \"categories\" field.
|
||||
|
||||
This is a list of symbols, the following are valid:
|
||||
`category' The Org mode category of the current file or tree
|
||||
`todo-state' The todo state, if any
|
||||
`local-tags' The tags, defined in the current line
|
||||
`all-tags' All tags, including inherited ones."
|
||||
:group 'org-export-icalendar
|
||||
:type '(repeat
|
||||
(choice
|
||||
(const :tag "The file or tree category" category)
|
||||
(const :tag "The TODO state" todo-state)
|
||||
(const :tag "Tags defined in current line" local-tags)
|
||||
(const :tag "All tags, including inherited ones" all-tags))))
|
||||
|
||||
(defcustom org-icalendar-with-timestamps 'active
|
||||
"Non-nil means make an event from plain time stamps.
|
||||
|
||||
It can be set to `active', `inactive', t or nil, in order to make
|
||||
an event from, respectively, only active timestamps, only
|
||||
inactive ones, all of them or none.
|
||||
|
||||
This variable has precedence over `org-export-with-timestamps'.
|
||||
It can also be set with the #+OPTIONS line, e.g. \"<:t\"."
|
||||
:group 'org-export-icalendar
|
||||
:type '(choice
|
||||
(const :tag "All timestamps" t)
|
||||
(const :tag "Only active timestamps" active)
|
||||
(const :tag "Only inactive timestamps" inactive)
|
||||
(const :tag "No timestamp" nil)))
|
||||
|
||||
(defcustom org-icalendar-include-todo nil
|
||||
"Non-nil means create VTODO components from TODO items.
|
||||
|
||||
Valid values are:
|
||||
nil don't include any task.
|
||||
t include tasks that are not in DONE state.
|
||||
`unblocked' include all TODO items that are not blocked.
|
||||
`all' include both done and not done items."
|
||||
:group 'org-export-icalendar
|
||||
:type '(choice
|
||||
(const :tag "None" nil)
|
||||
(const :tag "Unfinished" t)
|
||||
(const :tag "Unblocked" unblocked)
|
||||
(const :tag "All" all)
|
||||
(repeat :tag "Specific TODO keywords"
|
||||
(string :tag "Keyword"))))
|
||||
|
||||
(defcustom org-icalendar-include-bbdb-anniversaries nil
|
||||
"Non-nil means a combined iCalendar file should include anniversaries.
|
||||
The anniversaries are defined in the BBDB database."
|
||||
:group 'org-export-icalendar
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-icalendar-include-sexps t
|
||||
"Non-nil means export to iCalendar files should also cover sexp entries.
|
||||
These are entries like in the diary, but directly in an Org mode
|
||||
file."
|
||||
:group 'org-export-icalendar
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-icalendar-include-body t
|
||||
"Amount of text below headline to be included in iCalendar export.
|
||||
This is a number of characters that should maximally be included.
|
||||
Properties, scheduling and clocking lines will always be removed.
|
||||
The text will be inserted into the DESCRIPTION field."
|
||||
:group 'org-export-icalendar
|
||||
:type '(choice
|
||||
(const :tag "Nothing" nil)
|
||||
(const :tag "Everything" t)
|
||||
(integer :tag "Max characters")))
|
||||
|
||||
(defcustom org-icalendar-store-UID nil
|
||||
"Non-nil means store any created UIDs in properties.
|
||||
|
||||
The iCalendar standard requires that all entries have a unique identifier.
|
||||
Org will create these identifiers as needed. When this variable is non-nil,
|
||||
the created UIDs will be stored in the ID property of the entry. Then the
|
||||
next time this entry is exported, it will be exported with the same UID,
|
||||
superseding the previous form of it. This is essential for
|
||||
synchronization services.
|
||||
|
||||
This variable is not turned on by default because we want to avoid creating
|
||||
a property drawer in every entry if people are only playing with this feature,
|
||||
or if they are only using it locally."
|
||||
:group 'org-export-icalendar
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-icalendar-timezone (getenv "TZ")
|
||||
"The time zone string for iCalendar export.
|
||||
When nil or the empty string, use output
|
||||
from (current-time-zone)."
|
||||
:group 'org-export-icalendar
|
||||
:type '(choice
|
||||
(const :tag "Unspecified" nil)
|
||||
(string :tag "Time zone")))
|
||||
|
||||
(defcustom org-icalendar-date-time-format ":%Y%m%dT%H%M%S"
|
||||
"Format-string for exporting icalendar DATE-TIME.
|
||||
|
||||
See `format-time-string' for a full documentation. The only
|
||||
difference is that `org-icalendar-timezone' is used for %Z.
|
||||
|
||||
Interesting value are:
|
||||
- \":%Y%m%dT%H%M%S\" for local time
|
||||
- \";TZID=%Z:%Y%m%dT%H%M%S\" for local time with explicit timezone
|
||||
- \":%Y%m%dT%H%M%SZ\" for time expressed in Universal Time"
|
||||
:group 'org-export-icalendar
|
||||
:version "24.1"
|
||||
:type '(choice
|
||||
(const :tag "Local time" ":%Y%m%dT%H%M%S")
|
||||
(const :tag "Explicit local time" ";TZID=%Z:%Y%m%dT%H%M%S")
|
||||
(const :tag "Universal time" ":%Y%m%dT%H%M%SZ")
|
||||
(string :tag "Explicit format")))
|
||||
|
||||
(defvar org-icalendar-after-save-hook nil
|
||||
"Hook run after an iCalendar file has been saved.
|
||||
This hook is run with the name of the file as argument. A good
|
||||
way to use this is to tell a desktop calendar application to
|
||||
re-read the iCalendar file.")
|
||||
|
||||
|
||||
|
||||
;;; Define Back-End
|
||||
|
||||
(org-export-define-derived-backend 'icalendar 'ascii
|
||||
:translate-alist '((clock . ignore)
|
||||
(footnote-definition . ignore)
|
||||
(footnote-reference . ignore)
|
||||
(headline . org-icalendar-entry)
|
||||
(inlinetask . ignore)
|
||||
(planning . ignore)
|
||||
(section . ignore)
|
||||
(inner-template . (lambda (c i) c))
|
||||
(template . org-icalendar-template))
|
||||
:options-alist
|
||||
'((:exclude-tags
|
||||
"ICALENDAR_EXCLUDE_TAGS" nil org-icalendar-exclude-tags split)
|
||||
(:with-timestamps nil "<" org-icalendar-with-timestamps)
|
||||
(:with-vtodo nil nil org-icalendar-include-todo)
|
||||
;; The following property will be non-nil when export has been
|
||||
;; started from org-agenda-mode. In this case, any entry without
|
||||
;; a non-nil "ICALENDAR_MARK" property will be ignored.
|
||||
(:icalendar-agenda-view nil nil nil))
|
||||
:filters-alist
|
||||
'((:filter-headline . org-icalendar-clear-blank-lines))
|
||||
:menu-entry
|
||||
'(?c "Export to iCalendar"
|
||||
((?f "Current file" org-icalendar-export-to-ics)
|
||||
(?a "All agenda files"
|
||||
(lambda (a s v b) (org-icalendar-export-agenda-files a)))
|
||||
(?c "Combine all agenda files"
|
||||
(lambda (a s v b) (org-icalendar-combine-agenda-files a))))))
|
||||
|
||||
|
||||
|
||||
;;; Internal Functions
|
||||
|
||||
(defun org-icalendar-create-uid (file &optional bell h-markers)
|
||||
"Set ID property on headlines missing it in FILE.
|
||||
When optional argument BELL is non-nil, inform the user with
|
||||
a message if the file was modified. With optional argument
|
||||
H-MARKERS non-nil, it is a list of markers for the headlines
|
||||
which will be updated."
|
||||
(let ((pt (if h-markers (goto-char (car h-markers)) (point-min)))
|
||||
modified-flag)
|
||||
(org-map-entries
|
||||
(lambda ()
|
||||
(let ((entry (org-element-at-point)))
|
||||
(unless (or (< (point) pt) (org-element-property :ID entry))
|
||||
(org-id-get-create)
|
||||
(setq modified-flag t)
|
||||
(forward-line))
|
||||
(when h-markers (setq org-map-continue-from (pop h-markers)))))
|
||||
nil nil 'comment)
|
||||
(when (and bell modified-flag)
|
||||
(message "ID properties created in file \"%s\"" file)
|
||||
(sit-for 2))))
|
||||
|
||||
(defun org-icalendar-blocked-headline-p (headline info)
|
||||
"Non-nil when HEADLINE is considered to be blocked.
|
||||
|
||||
INFO is a plist used as a communication channel.
|
||||
|
||||
a headline is blocked when either:
|
||||
|
||||
- It has children which are not all in a completed state.
|
||||
|
||||
- It has a parent with the property :ORDERED:, and there are
|
||||
siblings prior to it with incomplete status.
|
||||
|
||||
- Its parent is blocked because it has siblings that should be
|
||||
done first or is a child of a blocked grandparent entry."
|
||||
(or
|
||||
;; Check if any child is not done.
|
||||
(org-element-map headline 'headline
|
||||
(lambda (hl) (eq (org-element-property :todo-type hl) 'todo))
|
||||
info 'first-match)
|
||||
;; Check :ORDERED: node property.
|
||||
(catch 'blockedp
|
||||
(let ((current headline))
|
||||
(mapc (lambda (parent)
|
||||
(cond
|
||||
((not (org-element-property :todo-keyword parent))
|
||||
(throw 'blockedp nil))
|
||||
((org-not-nil (org-element-property :ORDERED parent))
|
||||
(let ((sibling current))
|
||||
(while (setq sibling (org-export-get-previous-element
|
||||
sibling info))
|
||||
(when (eq (org-element-property :todo-type sibling) 'todo)
|
||||
(throw 'blockedp t)))))
|
||||
(t (setq current parent))))
|
||||
(org-export-get-genealogy headline))
|
||||
nil))))
|
||||
|
||||
(defun org-icalendar-use-UTC-date-time-p ()
|
||||
"Non-nil when `org-icalendar-date-time-format' requires UTC time."
|
||||
(char-equal (elt org-icalendar-date-time-format
|
||||
(1- (length org-icalendar-date-time-format))) ?Z))
|
||||
|
||||
(defvar org-agenda-default-appointment-duration) ; From org-agenda.el.
|
||||
(defun org-icalendar-convert-timestamp (timestamp keyword &optional end utc)
|
||||
"Convert TIMESTAMP to iCalendar format.
|
||||
|
||||
TIMESTAMP is a timestamp object. KEYWORD is added in front of
|
||||
it, in order to make a complete line (e.g. \"DTSTART\").
|
||||
|
||||
When optional argument END is non-nil, use end of time range.
|
||||
Also increase the hour by two (if time string contains a time),
|
||||
or the day by one (if it does not contain a time) when no
|
||||
explicit ending time is specified.
|
||||
|
||||
When optional argument UTC is non-nil, time will be expressed in
|
||||
Universal Time, ignoring `org-icalendar-date-time-format'."
|
||||
(let* ((year-start (org-element-property :year-start timestamp))
|
||||
(year-end (org-element-property :year-end timestamp))
|
||||
(month-start (org-element-property :month-start timestamp))
|
||||
(month-end (org-element-property :month-end timestamp))
|
||||
(day-start (org-element-property :day-start timestamp))
|
||||
(day-end (org-element-property :day-end timestamp))
|
||||
(hour-start (org-element-property :hour-start timestamp))
|
||||
(hour-end (org-element-property :hour-end timestamp))
|
||||
(minute-start (org-element-property :minute-start timestamp))
|
||||
(minute-end (org-element-property :minute-end timestamp))
|
||||
(with-time-p minute-start)
|
||||
(equal-bounds-p
|
||||
(equal (list year-start month-start day-start hour-start minute-start)
|
||||
(list year-end month-end day-end hour-end minute-end)))
|
||||
(mi (cond ((not with-time-p) 0)
|
||||
((not end) minute-start)
|
||||
((and org-agenda-default-appointment-duration equal-bounds-p)
|
||||
(+ minute-end org-agenda-default-appointment-duration))
|
||||
(t minute-end)))
|
||||
(h (cond ((not with-time-p) 0)
|
||||
((not end) hour-start)
|
||||
((or (not equal-bounds-p)
|
||||
org-agenda-default-appointment-duration)
|
||||
hour-end)
|
||||
(t (+ hour-end 2))))
|
||||
(d (cond ((not end) day-start)
|
||||
((not with-time-p) (1+ day-end))
|
||||
(t day-end)))
|
||||
(m (if end month-end month-start))
|
||||
(y (if end year-end year-start)))
|
||||
(concat
|
||||
keyword
|
||||
(format-time-string
|
||||
(cond (utc ":%Y%m%dT%H%M%SZ")
|
||||
((not with-time-p) ";VALUE=DATE:%Y%m%d")
|
||||
(t (replace-regexp-in-string "%Z"
|
||||
org-icalendar-timezone
|
||||
org-icalendar-date-time-format
|
||||
t)))
|
||||
;; Convert timestamp into internal time in order to use
|
||||
;; `format-time-string' and fix any mistake (i.e. MI >= 60).
|
||||
(encode-time 0 mi h d m y)
|
||||
(or utc (and with-time-p (org-icalendar-use-UTC-date-time-p)))))))
|
||||
|
||||
(defun org-icalendar-dtstamp ()
|
||||
"Return DTSTAMP property, as a string."
|
||||
(format-time-string "DTSTAMP:%Y%m%dT%H%M%SZ" nil t))
|
||||
|
||||
(defun org-icalendar-get-categories (entry info)
|
||||
"Return categories according to `org-icalendar-categories'.
|
||||
ENTRY is a headline or an inlinetask element. INFO is a plist
|
||||
used as a communication channel."
|
||||
(mapconcat
|
||||
'identity
|
||||
(org-uniquify
|
||||
(let (categories)
|
||||
(mapc (lambda (type)
|
||||
(case type
|
||||
(category
|
||||
(push (org-export-get-category entry info) categories))
|
||||
(todo-state
|
||||
(let ((todo (org-element-property :todo-keyword entry)))
|
||||
(and todo (push todo categories))))
|
||||
(local-tags
|
||||
(setq categories
|
||||
(append (nreverse (org-export-get-tags entry info))
|
||||
categories)))
|
||||
(all-tags
|
||||
(setq categories
|
||||
(append (nreverse (org-export-get-tags entry info nil t))
|
||||
categories)))))
|
||||
org-icalendar-categories)
|
||||
;; Return list of categories, following specified order.
|
||||
(nreverse categories))) ","))
|
||||
|
||||
(defun org-icalendar-transcode-diary-sexp (sexp uid summary)
|
||||
"Transcode a diary sexp into iCalendar format.
|
||||
SEXP is the diary sexp being transcoded, as a string. UID is the
|
||||
unique identifier for the entry. SUMMARY defines a short summary
|
||||
or subject for the event."
|
||||
(when (require 'icalendar nil t)
|
||||
(org-element-normalize-string
|
||||
(with-temp-buffer
|
||||
(let ((sexp (if (not (string-match "\\`<%%" sexp)) sexp
|
||||
(concat (substring sexp 1 -1) " " summary))))
|
||||
(put-text-property 0 1 'uid uid sexp)
|
||||
(insert sexp "\n"))
|
||||
(org-diary-to-ical-string (current-buffer))))))
|
||||
|
||||
(defun org-icalendar-cleanup-string (s)
|
||||
"Cleanup string S according to RFC 5545."
|
||||
(when s
|
||||
;; Protect "\", "," and ";" characters. and replace newline
|
||||
;; characters with literal \n.
|
||||
(replace-regexp-in-string
|
||||
"[ \t]*\n" "\\n"
|
||||
(replace-regexp-in-string "[\\,;]" "\\\&" s)
|
||||
nil t)))
|
||||
|
||||
(defun org-icalendar-fold-string (s)
|
||||
"Fold string S according to RFC 5545."
|
||||
(org-element-normalize-string
|
||||
(mapconcat
|
||||
(lambda (line)
|
||||
;; Limit each line to a maximum of 75 characters. If it is
|
||||
;; longer, fold it by using "\n " as a continuation marker.
|
||||
(let ((len (length line)))
|
||||
(if (<= len 75) line
|
||||
(let ((folded-line (substring line 0 75))
|
||||
(chunk-start 75)
|
||||
chunk-end)
|
||||
;; Since continuation marker takes up one character on the
|
||||
;; line, real contents must be split at 74 chars.
|
||||
(while (< (setq chunk-end (+ chunk-start 74)) len)
|
||||
(setq folded-line
|
||||
(concat folded-line "\n "
|
||||
(substring line chunk-start chunk-end))
|
||||
chunk-start chunk-end))
|
||||
(concat folded-line "\n " (substring line chunk-start))))))
|
||||
(org-split-string s "\n") "\n")))
|
||||
|
||||
|
||||
|
||||
;;; Filters
|
||||
|
||||
(defun org-icalendar-clear-blank-lines (headline back-end info)
|
||||
"Remove trailing blank lines in HEADLINE export.
|
||||
HEADLINE is a string representing a transcoded headline.
|
||||
BACK-END and INFO are ignored."
|
||||
(replace-regexp-in-string "^\\(?:[ \t]*\n\\)*" "" headline))
|
||||
|
||||
|
||||
|
||||
;;; Transcode Functions
|
||||
|
||||
;;;; Headline and Inlinetasks
|
||||
|
||||
;; The main function is `org-icalendar-entry', which extracts
|
||||
;; information from a headline or an inlinetask (summary,
|
||||
;; description...) and then delegates code generation to
|
||||
;; `org-icalendar--vtodo' and `org-icalendar--vevent', depending
|
||||
;; on the component needed.
|
||||
|
||||
;; Obviously, `org-icalendar--valarm' handles alarms, which can
|
||||
;; happen within a VTODO component.
|
||||
|
||||
(defun org-icalendar-entry (entry contents info)
|
||||
"Transcode ENTRY element into iCalendar format.
|
||||
|
||||
ENTRY is either a headline or an inlinetask. CONTENTS is
|
||||
ignored. INFO is a plist used as a communication channel.
|
||||
|
||||
This function is called on every headline, the section below
|
||||
it (minus inlinetasks) being its contents. It tries to create
|
||||
VEVENT and VTODO components out of scheduled date, deadline date,
|
||||
plain timestamps, diary sexps. It also calls itself on every
|
||||
inlinetask within the section."
|
||||
(unless (org-element-property :footnote-section-p entry)
|
||||
(let* ((type (org-element-type entry))
|
||||
;; Determine contents really associated to the entry. For
|
||||
;; a headline, limit them to section, if any. For an
|
||||
;; inlinetask, this is every element within the task.
|
||||
(inside
|
||||
(if (eq type 'inlinetask)
|
||||
(cons 'org-data (cons nil (org-element-contents entry)))
|
||||
(let ((first (car (org-element-contents entry))))
|
||||
(and (eq (org-element-type first) 'section)
|
||||
(cons 'org-data
|
||||
(cons nil (org-element-contents first))))))))
|
||||
(concat
|
||||
(unless (and (plist-get info :icalendar-agenda-view)
|
||||
(not (org-element-property :ICALENDAR-MARK entry)))
|
||||
(let ((todo-type (org-element-property :todo-type entry))
|
||||
(uid (or (org-element-property :ID entry) (org-id-new)))
|
||||
(summary (org-icalendar-cleanup-string
|
||||
(or (org-element-property :SUMMARY entry)
|
||||
(org-export-data
|
||||
(org-element-property :title entry) info))))
|
||||
(loc (org-icalendar-cleanup-string
|
||||
(org-element-property :LOCATION entry)))
|
||||
;; Build description of the entry from associated
|
||||
;; section (headline) or contents (inlinetask).
|
||||
(desc
|
||||
(org-icalendar-cleanup-string
|
||||
(or (org-element-property :DESCRIPTION entry)
|
||||
(let ((contents (org-export-data inside info)))
|
||||
(cond
|
||||
((not (org-string-nw-p contents)) nil)
|
||||
((wholenump org-icalendar-include-body)
|
||||
(let ((contents (org-trim contents)))
|
||||
(substring
|
||||
contents 0 (min (length contents)
|
||||
org-icalendar-include-body))))
|
||||
(org-icalendar-include-body (org-trim contents)))))))
|
||||
(cat (org-icalendar-get-categories entry info)))
|
||||
(concat
|
||||
;; Events: Delegate to `org-icalendar--vevent' to
|
||||
;; generate "VEVENT" component from scheduled, deadline,
|
||||
;; or any timestamp in the entry.
|
||||
(let ((deadline (org-element-property :deadline entry)))
|
||||
(and deadline
|
||||
(memq (if todo-type 'event-if-todo 'event-if-not-todo)
|
||||
org-icalendar-use-deadline)
|
||||
(org-icalendar--vevent
|
||||
entry deadline (concat "DL-" uid)
|
||||
(concat "DL: " summary) loc desc cat)))
|
||||
(let ((scheduled (org-element-property :scheduled entry)))
|
||||
(and scheduled
|
||||
(memq (if todo-type 'event-if-todo 'event-if-not-todo)
|
||||
org-icalendar-use-scheduled)
|
||||
(org-icalendar--vevent
|
||||
entry scheduled (concat "SC-" uid)
|
||||
(concat "S: " summary) loc desc cat)))
|
||||
;; When collecting plain timestamps from a headline and
|
||||
;; its title, skip inlinetasks since collection will
|
||||
;; happen once ENTRY is one of them.
|
||||
(let ((counter 0))
|
||||
(mapconcat
|
||||
'identity
|
||||
(org-element-map (cons (org-element-property :title entry)
|
||||
(org-element-contents inside))
|
||||
'timestamp
|
||||
(lambda (ts)
|
||||
(let ((uid (format "TS%d-%s" (incf counter) uid)))
|
||||
(org-icalendar--vevent entry ts uid summary loc desc cat)))
|
||||
info nil (and (eq type 'headline) 'inlinetask))
|
||||
""))
|
||||
;; Task: First check if it is appropriate to export it.
|
||||
;; If so, call `org-icalendar--vtodo' to transcode it
|
||||
;; into a "VTODO" component.
|
||||
(when (and todo-type
|
||||
(case (plist-get info :with-vtodo)
|
||||
(all t)
|
||||
(unblocked
|
||||
(and (eq type 'headline)
|
||||
(not (org-icalendar-blocked-headline-p
|
||||
entry info))))
|
||||
('t (eq todo-type 'todo))))
|
||||
(org-icalendar--vtodo entry uid summary loc desc cat))
|
||||
;; Diary-sexp: Collect every diary-sexp element within
|
||||
;; ENTRY and its title, and transcode them. If ENTRY is
|
||||
;; a headline, skip inlinetasks: they will be handled
|
||||
;; separately.
|
||||
(when org-icalendar-include-sexps
|
||||
(let ((counter 0))
|
||||
(mapconcat 'identity
|
||||
(org-element-map
|
||||
(cons (org-element-property :title entry)
|
||||
(org-element-contents inside))
|
||||
'diary-sexp
|
||||
(lambda (sexp)
|
||||
(org-icalendar-transcode-diary-sexp
|
||||
(org-element-property :value sexp)
|
||||
(format "DS%d-%s" (incf counter) uid)
|
||||
summary))
|
||||
info nil (and (eq type 'headline) 'inlinetask))
|
||||
""))))))
|
||||
;; If ENTRY is a headline, call current function on every
|
||||
;; inlinetask within it. In agenda export, this is independent
|
||||
;; from the mark (or lack thereof) on the entry.
|
||||
(when (eq type 'headline)
|
||||
(mapconcat 'identity
|
||||
(org-element-map inside 'inlinetask
|
||||
(lambda (task) (org-icalendar-entry task nil info))
|
||||
info) ""))
|
||||
;; Don't forget components from inner entries.
|
||||
contents))))
|
||||
|
||||
(defun org-icalendar--vevent
|
||||
(entry timestamp uid summary location description categories)
|
||||
"Create a VEVENT component.
|
||||
|
||||
ENTRY is either a headline or an inlinetask element. TIMESTAMP
|
||||
is a timestamp object defining the date-time of the event. UID
|
||||
is the unique identifier for the event. SUMMARY defines a short
|
||||
summary or subject for the event. LOCATION defines the intended
|
||||
venue for the event. DESCRIPTION provides the complete
|
||||
description of the event. CATEGORIES defines the categories the
|
||||
event belongs to.
|
||||
|
||||
Return VEVENT component as a string."
|
||||
(org-icalendar-fold-string
|
||||
(if (eq (org-element-property :type timestamp) 'diary)
|
||||
(org-icalendar-transcode-diary-sexp
|
||||
(org-element-property :raw-value timestamp) uid summary)
|
||||
(concat "BEGIN:VEVENT\n"
|
||||
(org-icalendar-dtstamp) "\n"
|
||||
"UID:" uid "\n"
|
||||
(org-icalendar-convert-timestamp timestamp "DTSTART") "\n"
|
||||
(org-icalendar-convert-timestamp timestamp "DTEND" t) "\n"
|
||||
;; RRULE.
|
||||
(when (org-element-property :repeater-type timestamp)
|
||||
(format "RRULE:FREQ=%s;INTERVAL=%d\n"
|
||||
(case (org-element-property :repeater-unit timestamp)
|
||||
(hour "HOURLY") (day "DAILY") (week "WEEKLY")
|
||||
(month "MONTHLY") (year "YEARLY"))
|
||||
(org-element-property :repeater-value timestamp)))
|
||||
"SUMMARY:" summary "\n"
|
||||
(and (org-string-nw-p location) (format "LOCATION:%s\n" location))
|
||||
(and (org-string-nw-p description)
|
||||
(format "DESCRIPTION:%s\n" description))
|
||||
"CATEGORIES:" categories "\n"
|
||||
;; VALARM.
|
||||
(org-icalendar--valarm entry timestamp summary)
|
||||
"END:VEVENT"))))
|
||||
|
||||
(defun org-icalendar--vtodo
|
||||
(entry uid summary location description categories)
|
||||
"Create a VTODO component.
|
||||
|
||||
ENTRY is either a headline or an inlinetask element. UID is the
|
||||
unique identifier for the task. SUMMARY defines a short summary
|
||||
or subject for the task. LOCATION defines the intended venue for
|
||||
the task. DESCRIPTION provides the complete description of the
|
||||
task. CATEGORIES defines the categories the task belongs to.
|
||||
|
||||
Return VTODO component as a string."
|
||||
(let ((start (or (and (memq 'todo-start org-icalendar-use-scheduled)
|
||||
(org-element-property :scheduled entry))
|
||||
;; If we can't use a scheduled time for some
|
||||
;; reason, start task now.
|
||||
(let ((now (decode-time (current-time))))
|
||||
(list 'timestamp
|
||||
(list :type 'active
|
||||
:minute-start (nth 1 now)
|
||||
:hour-start (nth 2 now)
|
||||
:day-start (nth 3 now)
|
||||
:month-start (nth 4 now)
|
||||
:year-start (nth 5 now)))))))
|
||||
(org-icalendar-fold-string
|
||||
(concat "BEGIN:VTODO\n"
|
||||
"UID:TODO-" uid "\n"
|
||||
(org-icalendar-dtstamp) "\n"
|
||||
(org-icalendar-convert-timestamp start "DTSTART") "\n"
|
||||
(and (memq 'todo-due org-icalendar-use-deadline)
|
||||
(org-element-property :deadline entry)
|
||||
(concat (org-icalendar-convert-timestamp
|
||||
(org-element-property :deadline entry) "DUE")
|
||||
"\n"))
|
||||
"SUMMARY:" summary "\n"
|
||||
(and (org-string-nw-p location) (format "LOCATION:%s\n" location))
|
||||
(and (org-string-nw-p description)
|
||||
(format "DESCRIPTION:%s\n" description))
|
||||
"CATEGORIES:" categories "\n"
|
||||
"SEQUENCE:1\n"
|
||||
(format "PRIORITY:%d\n"
|
||||
(let ((pri (or (org-element-property :priority entry)
|
||||
org-default-priority)))
|
||||
(floor (- 9 (* 8. (/ (float (- org-lowest-priority pri))
|
||||
(- org-lowest-priority
|
||||
org-highest-priority)))))))
|
||||
(format "STATUS:%s\n"
|
||||
(if (eq (org-element-property :todo-type entry) 'todo)
|
||||
"NEEDS-ACTION"
|
||||
"COMPLETED"))
|
||||
"END:VTODO"))))
|
||||
|
||||
(defun org-icalendar--valarm (entry timestamp summary)
|
||||
"Create a VALARM component.
|
||||
|
||||
ENTRY is the calendar entry triggering the alarm. TIMESTAMP is
|
||||
the start date-time of the entry. SUMMARY defines a short
|
||||
summary or subject for the task.
|
||||
|
||||
Return VALARM component as a string, or nil if it isn't allowed."
|
||||
;; Create a VALARM entry if the entry is timed. This is not very
|
||||
;; general in that:
|
||||
;; (a) only one alarm per entry is defined,
|
||||
;; (b) only minutes are allowed for the trigger period ahead of the
|
||||
;; start time,
|
||||
;; (c) only a DISPLAY action is defined. [ESF]
|
||||
(let ((alarm-time
|
||||
(let ((warntime
|
||||
(org-element-property :APPT_WARNTIME entry)))
|
||||
(if warntime (string-to-number warntime) 0))))
|
||||
(and (or (> alarm-time 0) (> org-icalendar-alarm-time 0))
|
||||
(org-element-property :hour-start timestamp)
|
||||
(format "BEGIN:VALARM
|
||||
ACTION:DISPLAY
|
||||
DESCRIPTION:%s
|
||||
TRIGGER:-P0DT0H%dM0S
|
||||
END:VALARM\n"
|
||||
summary
|
||||
(if (zerop alarm-time) org-icalendar-alarm-time alarm-time)))))
|
||||
|
||||
|
||||
;;;; Template
|
||||
|
||||
(defun org-icalendar-template (contents info)
|
||||
"Return complete document string after iCalendar conversion.
|
||||
CONTENTS is the transcoded contents string. INFO is a plist used
|
||||
as a communication channel."
|
||||
(org-icalendar--vcalendar
|
||||
;; Name.
|
||||
(if (not (plist-get info :input-file)) (buffer-name (buffer-base-buffer))
|
||||
(file-name-nondirectory
|
||||
(file-name-sans-extension (plist-get info :input-file))))
|
||||
;; Owner.
|
||||
(if (not (plist-get info :with-author)) ""
|
||||
(org-export-data (plist-get info :author) info))
|
||||
;; Timezone.
|
||||
(if (org-string-nw-p org-icalendar-timezone) org-icalendar-timezone
|
||||
(cadr (current-time-zone)))
|
||||
;; Description.
|
||||
(org-export-data (plist-get info :title) info)
|
||||
contents))
|
||||
|
||||
(defun org-icalendar--vcalendar (name owner tz description contents)
|
||||
"Create a VCALENDAR component.
|
||||
NAME, OWNER, TZ, DESCRIPTION and CONTENTS are all strings giving,
|
||||
respectively, the name of the calendar, its owner, the timezone
|
||||
used, a short description and the other components included."
|
||||
(concat (format "BEGIN:VCALENDAR
|
||||
VERSION:2.0
|
||||
X-WR-CALNAME:%s
|
||||
PRODID:-//%s//Emacs with Org mode//EN
|
||||
X-WR-TIMEZONE:%s
|
||||
X-WR-CALDESC:%s
|
||||
CALSCALE:GREGORIAN\n"
|
||||
(org-icalendar-cleanup-string name)
|
||||
(org-icalendar-cleanup-string owner)
|
||||
(org-icalendar-cleanup-string tz)
|
||||
(org-icalendar-cleanup-string description))
|
||||
contents
|
||||
"END:VCALENDAR\n"))
|
||||
|
||||
|
||||
|
||||
;;; Interactive Functions
|
||||
|
||||
;;;###autoload
|
||||
(defun org-icalendar-export-to-ics
|
||||
(&optional async subtreep visible-only body-only)
|
||||
"Export current buffer to an iCalendar file.
|
||||
|
||||
If narrowing is active in the current buffer, only export its
|
||||
narrowed part.
|
||||
|
||||
If a region is active, export that region.
|
||||
|
||||
A non-nil optional argument ASYNC means the process should happen
|
||||
asynchronously. The resulting file should be accessible through
|
||||
the `org-export-stack' interface.
|
||||
|
||||
When optional argument SUBTREEP is non-nil, export the sub-tree
|
||||
at point, extracting information from the headline properties
|
||||
first.
|
||||
|
||||
When optional argument VISIBLE-ONLY is non-nil, don't export
|
||||
contents of hidden elements.
|
||||
|
||||
When optional argument BODY-ONLY is non-nil, only write code
|
||||
between \"BEGIN:VCALENDAR\" and \"END:VCALENDAR\".
|
||||
|
||||
Return ICS file name."
|
||||
(interactive)
|
||||
(let ((file (buffer-file-name (buffer-base-buffer))))
|
||||
(when (and file org-icalendar-store-UID)
|
||||
(org-icalendar-create-uid file 'warn-user)))
|
||||
;; Export part. Since this back-end is backed up by `ascii', ensure
|
||||
;; links will not be collected at the end of sections.
|
||||
(let ((outfile (org-export-output-file-name ".ics" subtreep)))
|
||||
(org-export-to-file 'icalendar outfile
|
||||
async subtreep visible-only body-only '(:ascii-charset utf-8)
|
||||
(lambda (file)
|
||||
(run-hook-with-args 'org-icalendar-after-save-hook file) nil))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-icalendar-export-agenda-files (&optional async)
|
||||
"Export all agenda files to iCalendar files.
|
||||
When optional argument ASYNC is non-nil, export happens in an
|
||||
external process."
|
||||
(interactive)
|
||||
(if async
|
||||
;; Asynchronous export is not interactive, so we will not call
|
||||
;; `org-check-agenda-file'. Instead we remove any non-existent
|
||||
;; agenda file from the list.
|
||||
(let ((files (org-remove-if-not 'file-exists-p (org-agenda-files t))))
|
||||
(org-export-async-start
|
||||
(lambda (results)
|
||||
(mapc (lambda (f) (org-export-add-to-stack f 'icalendar))
|
||||
results))
|
||||
`(let (output-files)
|
||||
(mapc (lambda (file)
|
||||
(with-current-buffer (org-get-agenda-file-buffer file)
|
||||
(push (expand-file-name (org-icalendar-export-to-ics))
|
||||
output-files)))
|
||||
',files)
|
||||
output-files)))
|
||||
(let ((files (org-agenda-files t)))
|
||||
(org-agenda-prepare-buffers files)
|
||||
(unwind-protect
|
||||
(mapc (lambda (file)
|
||||
(catch 'nextfile
|
||||
(org-check-agenda-file file)
|
||||
(with-current-buffer (org-get-agenda-file-buffer file)
|
||||
(org-icalendar-export-to-ics))))
|
||||
files)
|
||||
(org-release-buffers org-agenda-new-buffers)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-icalendar-combine-agenda-files (&optional async)
|
||||
"Combine all agenda files into a single iCalendar file.
|
||||
|
||||
A non-nil optional argument ASYNC means the process should happen
|
||||
asynchronously. The resulting file should be accessible through
|
||||
the `org-export-stack' interface.
|
||||
|
||||
The file is stored under the name chosen in
|
||||
`org-icalendar-combined-agenda-file'."
|
||||
(interactive)
|
||||
(if async
|
||||
(let ((files (org-remove-if-not 'file-exists-p (org-agenda-files t))))
|
||||
(org-export-async-start
|
||||
(lambda (dummy)
|
||||
(org-export-add-to-stack
|
||||
(expand-file-name org-icalendar-combined-agenda-file)
|
||||
'icalendar))
|
||||
`(apply 'org-icalendar--combine-files nil ',files)))
|
||||
(apply 'org-icalendar--combine-files nil (org-agenda-files t))))
|
||||
|
||||
(defun org-icalendar-export-current-agenda (file)
|
||||
"Export current agenda view to an iCalendar FILE.
|
||||
This function assumes major mode for current buffer is
|
||||
`org-agenda-mode'."
|
||||
(let (org-export-babel-evaluate ; Don't evaluate Babel block
|
||||
(org-icalendar-combined-agenda-file file)
|
||||
(marker-list
|
||||
;; Collect the markers pointing to entries in the current
|
||||
;; agenda buffer.
|
||||
(let (markers)
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(while (not (eobp))
|
||||
(let ((m (or (org-get-at-bol 'org-hd-marker)
|
||||
(org-get-at-bol 'org-marker))))
|
||||
(and m (push m markers)))
|
||||
(beginning-of-line 2)))
|
||||
(nreverse markers))))
|
||||
(apply 'org-icalendar--combine-files
|
||||
;; Build restriction alist.
|
||||
(let (restriction)
|
||||
;; Sort markers in each association within RESTRICTION.
|
||||
(mapcar (lambda (x) (setcdr x (sort (copy-sequence (cdr x)) '<)) x)
|
||||
(dolist (m marker-list restriction)
|
||||
(let* ((pos (marker-position m))
|
||||
(file (buffer-file-name
|
||||
(org-base-buffer (marker-buffer m))))
|
||||
(file-markers (assoc file restriction)))
|
||||
;; Add POS in FILE association if one exists
|
||||
;; or create a new association for FILE.
|
||||
(if file-markers (push pos (cdr file-markers))
|
||||
(push (list file pos) restriction))))))
|
||||
(org-agenda-files nil 'ifmode))))
|
||||
|
||||
(defun org-icalendar--combine-files (restriction &rest files)
|
||||
"Combine entries from multiple files into an iCalendar file.
|
||||
RESTRICTION, when non-nil, is an alist where key is a file name
|
||||
and value a list of buffer positions pointing to entries that
|
||||
should appear in the calendar. It only makes sense if the
|
||||
function was called from an agenda buffer. FILES is a list of
|
||||
files to build the calendar from."
|
||||
(org-agenda-prepare-buffers files)
|
||||
(unwind-protect
|
||||
(progn
|
||||
(with-temp-file org-icalendar-combined-agenda-file
|
||||
(insert
|
||||
(org-icalendar--vcalendar
|
||||
;; Name.
|
||||
org-icalendar-combined-name
|
||||
;; Owner.
|
||||
user-full-name
|
||||
;; Timezone.
|
||||
(or (org-string-nw-p org-icalendar-timezone)
|
||||
(cadr (current-time-zone)))
|
||||
;; Description.
|
||||
org-icalendar-combined-description
|
||||
;; Contents.
|
||||
(concat
|
||||
;; Agenda contents.
|
||||
(mapconcat
|
||||
(lambda (file)
|
||||
(catch 'nextfile
|
||||
(org-check-agenda-file file)
|
||||
(with-current-buffer (org-get-agenda-file-buffer file)
|
||||
(let ((marks (cdr (assoc (expand-file-name file)
|
||||
restriction))))
|
||||
;; Create ID if necessary.
|
||||
(when org-icalendar-store-UID
|
||||
(org-icalendar-create-uid file t marks))
|
||||
(unless (and restriction (not marks))
|
||||
;; Add a hook adding :ICALENDAR_MARK: property
|
||||
;; to each entry appearing in agenda view.
|
||||
;; Use `apply-partially' because the function
|
||||
;; still has to accept one argument.
|
||||
(let ((org-export-before-processing-hook
|
||||
(cons (apply-partially
|
||||
(lambda (m-list dummy)
|
||||
(mapc (lambda (m)
|
||||
(org-entry-put
|
||||
m "ICALENDAR-MARK" "t"))
|
||||
m-list))
|
||||
(sort marks '>))
|
||||
org-export-before-processing-hook)))
|
||||
(org-export-as
|
||||
'icalendar nil nil t
|
||||
(list :ascii-charset 'utf-8
|
||||
:icalendar-agenda-view restriction))))))))
|
||||
files "")
|
||||
;; BBDB anniversaries.
|
||||
(when (and org-icalendar-include-bbdb-anniversaries
|
||||
(require 'org-bbdb nil t))
|
||||
(with-temp-buffer
|
||||
(org-bbdb-anniv-export-ical)
|
||||
(buffer-string)))))))
|
||||
(run-hook-with-args 'org-icalendar-after-save-hook
|
||||
org-icalendar-combined-agenda-file))
|
||||
(org-release-buffers org-agenda-new-buffers)))
|
||||
|
||||
|
||||
(provide 'ox-icalendar)
|
||||
|
||||
;; Local variables:
|
||||
;; generated-autoload-file: "org-loaddefs.el"
|
||||
;; End:
|
||||
|
||||
;;; ox-icalendar.el ends here
|
2920
lisp/org/ox-latex.el
Normal file
2920
lisp/org/ox-latex.el
Normal file
File diff suppressed because it is too large
Load Diff
1260
lisp/org/ox-man.el
Normal file
1260
lisp/org/ox-man.el
Normal file
File diff suppressed because it is too large
Load Diff
483
lisp/org/ox-md.el
Normal file
483
lisp/org/ox-md.el
Normal file
@ -0,0 +1,483 @@
|
||||
;;; ox-md.el --- Markdown Back-End for Org Export Engine
|
||||
|
||||
;; Copyright (C) 2012, 2013 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Nicolas Goaziou <n.goaziou@gmail.com>
|
||||
;; Keywords: org, wp, markdown
|
||||
|
||||
;; GNU Emacs 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.
|
||||
|
||||
;; GNU Emacs 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 GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This library implements a Markdown back-end (vanilla flavour) for
|
||||
;; Org exporter, based on `html' back-end. See Org manual for more
|
||||
;; information.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(eval-when-compile (require 'cl))
|
||||
(require 'ox-html)
|
||||
|
||||
|
||||
|
||||
;;; User-Configurable Variables
|
||||
|
||||
(defgroup org-export-md nil
|
||||
"Options specific to Markdown export back-end."
|
||||
:tag "Org Markdown"
|
||||
:group 'org-export
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0"))
|
||||
|
||||
(defcustom org-md-headline-style 'atx
|
||||
"Style used to format headlines.
|
||||
This variable can be set to either `atx' or `setext'."
|
||||
:group 'org-export-md
|
||||
:type '(choice
|
||||
(const :tag "Use \"atx\" style" atx)
|
||||
(const :tag "Use \"Setext\" style" setext)))
|
||||
|
||||
|
||||
|
||||
;;; Define Back-End
|
||||
|
||||
(org-export-define-derived-backend 'md 'html
|
||||
:export-block '("MD" "MARKDOWN")
|
||||
:filters-alist '((:filter-parse-tree . org-md-separate-elements))
|
||||
:menu-entry
|
||||
'(?m "Export to Markdown"
|
||||
((?M "To temporary buffer"
|
||||
(lambda (a s v b) (org-md-export-as-markdown a s v)))
|
||||
(?m "To file" (lambda (a s v b) (org-md-export-to-markdown a s v)))
|
||||
(?o "To file and open"
|
||||
(lambda (a s v b)
|
||||
(if a (org-md-export-to-markdown t s v)
|
||||
(org-open-file (org-md-export-to-markdown nil s v)))))))
|
||||
:translate-alist '((bold . org-md-bold)
|
||||
(code . org-md-verbatim)
|
||||
(comment . (lambda (&rest args) ""))
|
||||
(comment-block . (lambda (&rest args) ""))
|
||||
(example-block . org-md-example-block)
|
||||
(fixed-width . org-md-example-block)
|
||||
(footnote-definition . ignore)
|
||||
(footnote-reference . ignore)
|
||||
(headline . org-md-headline)
|
||||
(horizontal-rule . org-md-horizontal-rule)
|
||||
(inline-src-block . org-md-verbatim)
|
||||
(italic . org-md-italic)
|
||||
(item . org-md-item)
|
||||
(line-break . org-md-line-break)
|
||||
(link . org-md-link)
|
||||
(paragraph . org-md-paragraph)
|
||||
(plain-list . org-md-plain-list)
|
||||
(plain-text . org-md-plain-text)
|
||||
(quote-block . org-md-quote-block)
|
||||
(quote-section . org-md-example-block)
|
||||
(section . org-md-section)
|
||||
(src-block . org-md-example-block)
|
||||
(template . org-md-template)
|
||||
(verbatim . org-md-verbatim)))
|
||||
|
||||
|
||||
|
||||
;;; Filters
|
||||
|
||||
(defun org-md-separate-elements (tree backend info)
|
||||
"Make sure elements are separated by at least one blank line.
|
||||
|
||||
TREE is the parse tree being exported. BACKEND is the export
|
||||
back-end used. INFO is a plist used as a communication channel.
|
||||
|
||||
Assume BACKEND is `md'."
|
||||
(org-element-map tree org-element-all-elements
|
||||
(lambda (elem)
|
||||
(unless (eq (org-element-type elem) 'org-data)
|
||||
(org-element-put-property
|
||||
elem :post-blank
|
||||
(let ((post-blank (org-element-property :post-blank elem)))
|
||||
(if (not post-blank) 1 (max 1 post-blank)))))))
|
||||
;; Return updated tree.
|
||||
tree)
|
||||
|
||||
|
||||
|
||||
;;; Transcode Functions
|
||||
|
||||
;;;; Bold
|
||||
|
||||
(defun org-md-bold (bold contents info)
|
||||
"Transcode BOLD object into Markdown format.
|
||||
CONTENTS is the text within bold markup. INFO is a plist used as
|
||||
a communication channel."
|
||||
(format "**%s**" contents))
|
||||
|
||||
|
||||
;;;; Code and Verbatim
|
||||
|
||||
(defun org-md-verbatim (verbatim contents info)
|
||||
"Transcode VERBATIM object into Markdown format.
|
||||
CONTENTS is nil. INFO is a plist used as a communication
|
||||
channel."
|
||||
(let ((value (org-element-property :value verbatim)))
|
||||
(format (cond ((not (string-match "`" value)) "`%s`")
|
||||
((or (string-match "\\``" value)
|
||||
(string-match "`\\'" value))
|
||||
"`` %s ``")
|
||||
(t "``%s``"))
|
||||
value)))
|
||||
|
||||
|
||||
;;;; Example Block and Src Block
|
||||
|
||||
(defun org-md-example-block (example-block contents info)
|
||||
"Transcode EXAMPLE-BLOCK element into Markdown format.
|
||||
CONTENTS is nil. INFO is a plist used as a communication
|
||||
channel."
|
||||
(replace-regexp-in-string
|
||||
"^" " "
|
||||
(org-remove-indentation
|
||||
(org-element-property :value example-block))))
|
||||
|
||||
|
||||
;;;; Headline
|
||||
|
||||
(defun org-md-headline (headline contents info)
|
||||
"Transcode HEADLINE element into Markdown format.
|
||||
CONTENTS is the headline contents. INFO is a plist used as
|
||||
a communication channel."
|
||||
(unless (org-element-property :footnote-section-p headline)
|
||||
(let* ((level (org-export-get-relative-level headline info))
|
||||
(title (org-export-data (org-element-property :title headline) info))
|
||||
(todo (and (plist-get info :with-todo-keywords)
|
||||
(let ((todo (org-element-property :todo-keyword
|
||||
headline)))
|
||||
(and todo (concat (org-export-data todo info) " ")))))
|
||||
(tags (and (plist-get info :with-tags)
|
||||
(let ((tag-list (org-export-get-tags headline info)))
|
||||
(and tag-list
|
||||
(format " :%s:"
|
||||
(mapconcat 'identity tag-list ":"))))))
|
||||
(priority
|
||||
(and (plist-get info :with-priority)
|
||||
(let ((char (org-element-property :priority headline)))
|
||||
(and char (format "[#%c] " char)))))
|
||||
;; Headline text without tags.
|
||||
(heading (concat todo priority title)))
|
||||
(cond
|
||||
;; Cannot create a headline. Fall-back to a list.
|
||||
((or (org-export-low-level-p headline info)
|
||||
(not (memq org-md-headline-style '(atx setext)))
|
||||
(and (eq org-md-headline-style 'atx) (> level 6))
|
||||
(and (eq org-md-headline-style 'setext) (> level 2)))
|
||||
(let ((bullet
|
||||
(if (not (org-export-numbered-headline-p headline info)) "-"
|
||||
(concat (number-to-string
|
||||
(car (last (org-export-get-headline-number
|
||||
headline info))))
|
||||
"."))))
|
||||
(concat bullet (make-string (- 4 (length bullet)) ? ) heading tags
|
||||
"\n\n"
|
||||
(and contents
|
||||
(replace-regexp-in-string "^" " " contents)))))
|
||||
;; Use "Setext" style.
|
||||
((eq org-md-headline-style 'setext)
|
||||
(concat heading tags "\n"
|
||||
(make-string (length heading) (if (= level 1) ?= ?-))
|
||||
"\n\n"
|
||||
contents))
|
||||
;; Use "atx" style.
|
||||
(t (concat (make-string level ?#) " " heading tags "\n\n" contents))))))
|
||||
|
||||
|
||||
;;;; Horizontal Rule
|
||||
|
||||
(defun org-md-horizontal-rule (horizontal-rule contents info)
|
||||
"Transcode HORIZONTAL-RULE element into Markdown format.
|
||||
CONTENTS is the horizontal rule contents. INFO is a plist used
|
||||
as a communication channel."
|
||||
"---")
|
||||
|
||||
|
||||
;;;; Italic
|
||||
|
||||
(defun org-md-italic (italic contents info)
|
||||
"Transcode ITALIC object into Markdown format.
|
||||
CONTENTS is the text within italic markup. INFO is a plist used
|
||||
as a communication channel."
|
||||
(format "*%s*" contents))
|
||||
|
||||
|
||||
;;;; Item
|
||||
|
||||
(defun org-md-item (item contents info)
|
||||
"Transcode ITEM element into Markdown format.
|
||||
CONTENTS is the item contents. INFO is a plist used as
|
||||
a communication channel."
|
||||
(let* ((type (org-element-property :type (org-export-get-parent item)))
|
||||
(struct (org-element-property :structure item))
|
||||
(bullet (if (not (eq type 'ordered)) "-"
|
||||
(concat (number-to-string
|
||||
(car (last (org-list-get-item-number
|
||||
(org-element-property :begin item)
|
||||
struct
|
||||
(org-list-prevs-alist struct)
|
||||
(org-list-parents-alist struct)))))
|
||||
"."))))
|
||||
(concat bullet
|
||||
(make-string (- 4 (length bullet)) ? )
|
||||
(case (org-element-property :checkbox item)
|
||||
(on "[X] ")
|
||||
(trans "[-] ")
|
||||
(off "[ ] "))
|
||||
(let ((tag (org-element-property :tag item)))
|
||||
(and tag (format "**%s:** "(org-export-data tag info))))
|
||||
(org-trim (replace-regexp-in-string "^" " " contents)))))
|
||||
|
||||
|
||||
;;;; Line Break
|
||||
|
||||
(defun org-md-line-break (line-break contents info)
|
||||
"Transcode LINE-BREAK object into Markdown format.
|
||||
CONTENTS is nil. INFO is a plist used as a communication
|
||||
channel."
|
||||
" \n")
|
||||
|
||||
|
||||
;;;; Link
|
||||
|
||||
(defun org-md-link (link contents info)
|
||||
"Transcode LINE-BREAK object into Markdown format.
|
||||
CONTENTS is the link's description. INFO is a plist used as
|
||||
a communication channel."
|
||||
(let ((--link-org-files-as-html-maybe
|
||||
(function
|
||||
(lambda (raw-path info)
|
||||
;; Treat links to `file.org' as links to `file.html', if
|
||||
;; needed. See `org-html-link-org-files-as-html'.
|
||||
(cond
|
||||
((and org-html-link-org-files-as-html
|
||||
(string= ".org"
|
||||
(downcase (file-name-extension raw-path "."))))
|
||||
(concat (file-name-sans-extension raw-path) "."
|
||||
(plist-get info :html-extension)))
|
||||
(t raw-path)))))
|
||||
(type (org-element-property :type link)))
|
||||
(cond ((member type '("custom-id" "id"))
|
||||
(let ((destination (org-export-resolve-id-link link info)))
|
||||
(if (stringp destination) ; External file.
|
||||
(let ((path (funcall --link-org-files-as-html-maybe
|
||||
destination info)))
|
||||
(if (not contents) (format "<%s>" path)
|
||||
(format "[%s](%s)" contents path)))
|
||||
(concat
|
||||
(and contents (concat contents " "))
|
||||
(format "(%s)"
|
||||
(format (org-export-translate "See section %s" :html info)
|
||||
(mapconcat 'number-to-string
|
||||
(org-export-get-headline-number
|
||||
destination info)
|
||||
".")))))))
|
||||
((org-export-inline-image-p link org-html-inline-image-rules)
|
||||
(let ((path (let ((raw-path (org-element-property :path link)))
|
||||
(if (not (file-name-absolute-p raw-path)) raw-path
|
||||
(expand-file-name raw-path)))))
|
||||
(format "![%s](%s)"
|
||||
(let ((caption (org-export-get-caption
|
||||
(org-export-get-parent-element link))))
|
||||
(when caption (org-export-data caption info)))
|
||||
path)))
|
||||
((string= type "coderef")
|
||||
(let ((ref (org-element-property :path link)))
|
||||
(format (org-export-get-coderef-format ref contents)
|
||||
(org-export-resolve-coderef ref info))))
|
||||
((equal type "radio")
|
||||
(let ((destination (org-export-resolve-radio-link link info)))
|
||||
(org-export-data (org-element-contents destination) info)))
|
||||
((equal type "fuzzy")
|
||||
(let ((destination (org-export-resolve-fuzzy-link link info)))
|
||||
(if (org-string-nw-p contents) contents
|
||||
(when destination
|
||||
(let ((number (org-export-get-ordinal destination info)))
|
||||
(when number
|
||||
(if (atom number) (number-to-string number)
|
||||
(mapconcat 'number-to-string number "."))))))))
|
||||
(t (let* ((raw-path (org-element-property :path link))
|
||||
(path (cond
|
||||
((member type '("http" "https" "ftp"))
|
||||
(concat type ":" raw-path))
|
||||
((equal type "file")
|
||||
;; Treat links to ".org" files as ".html",
|
||||
;; if needed.
|
||||
(setq raw-path
|
||||
(funcall --link-org-files-as-html-maybe
|
||||
raw-path info))
|
||||
;; If file path is absolute, prepend it
|
||||
;; with protocol component - "file://".
|
||||
(if (not (file-name-absolute-p raw-path)) raw-path
|
||||
(concat "file://" (expand-file-name raw-path))))
|
||||
(t raw-path))))
|
||||
(if (not contents) (format "<%s>" path)
|
||||
(format "[%s](%s)" contents path)))))))
|
||||
|
||||
|
||||
;;;; Paragraph
|
||||
|
||||
(defun org-md-paragraph (paragraph contents info)
|
||||
"Transcode PARAGRAPH element into Markdown format.
|
||||
CONTENTS is the paragraph contents. INFO is a plist used as
|
||||
a communication channel."
|
||||
(let ((first-object (car (org-element-contents paragraph))))
|
||||
;; If paragraph starts with a #, protect it.
|
||||
(if (and (stringp first-object) (string-match "\\`#" first-object))
|
||||
(replace-regexp-in-string "\\`#" "\\#" contents nil t)
|
||||
contents)))
|
||||
|
||||
|
||||
;;;; Plain List
|
||||
|
||||
(defun org-md-plain-list (plain-list contents info)
|
||||
"Transcode PLAIN-LIST element into Markdown format.
|
||||
CONTENTS is the plain-list contents. INFO is a plist used as
|
||||
a communication channel."
|
||||
contents)
|
||||
|
||||
|
||||
;;;; Plain Text
|
||||
|
||||
(defun org-md-plain-text (text info)
|
||||
"Transcode a TEXT string into Markdown format.
|
||||
TEXT is the string to transcode. INFO is a plist holding
|
||||
contextual information."
|
||||
(when (plist-get info :with-smart-quotes)
|
||||
(setq text (org-export-activate-smart-quotes text :html info)))
|
||||
;; Protect ambiguous #. This will protect # at the beginning of
|
||||
;; a line, but not at the beginning of a paragraph. See
|
||||
;; `org-md-paragraph'.
|
||||
(setq text (replace-regexp-in-string "\n#" "\n\\\\#" text))
|
||||
;; Protect ambiguous !
|
||||
(setq text (replace-regexp-in-string "\\(!\\)\\[" "\\\\!" text nil nil 1))
|
||||
;; Protect `, *, _ and \
|
||||
(setq text (replace-regexp-in-string "[`*_\\]" "\\\\\\&" text))
|
||||
;; Handle special strings, if required.
|
||||
(when (plist-get info :with-special-strings)
|
||||
(setq text (org-html-convert-special-strings text)))
|
||||
;; Handle break preservation, if required.
|
||||
(when (plist-get info :preserve-breaks)
|
||||
(setq text (replace-regexp-in-string "[ \t]*\n" " \n" text)))
|
||||
;; Return value.
|
||||
text)
|
||||
|
||||
|
||||
;;;; Quote Block
|
||||
|
||||
(defun org-md-quote-block (quote-block contents info)
|
||||
"Transcode QUOTE-BLOCK element into Markdown format.
|
||||
CONTENTS is the quote-block contents. INFO is a plist used as
|
||||
a communication channel."
|
||||
(replace-regexp-in-string
|
||||
"^" "> "
|
||||
(replace-regexp-in-string "\n\\'" "" contents)))
|
||||
|
||||
|
||||
;;;; Section
|
||||
|
||||
(defun org-md-section (section contents info)
|
||||
"Transcode SECTION element into Markdown format.
|
||||
CONTENTS is the section contents. INFO is a plist used as
|
||||
a communication channel."
|
||||
contents)
|
||||
|
||||
|
||||
;;;; Template
|
||||
|
||||
(defun org-md-template (contents info)
|
||||
"Return complete document string after Markdown conversion.
|
||||
CONTENTS is the transcoded contents string. INFO is a plist used
|
||||
as a communication channel."
|
||||
contents)
|
||||
|
||||
|
||||
|
||||
;;; Interactive function
|
||||
|
||||
;;;###autoload
|
||||
(defun org-md-export-as-markdown (&optional async subtreep visible-only)
|
||||
"Export current buffer to a Markdown buffer.
|
||||
|
||||
If narrowing is active in the current buffer, only export its
|
||||
narrowed part.
|
||||
|
||||
If a region is active, export that region.
|
||||
|
||||
A non-nil optional argument ASYNC means the process should happen
|
||||
asynchronously. The resulting buffer should be accessible
|
||||
through the `org-export-stack' interface.
|
||||
|
||||
When optional argument SUBTREEP is non-nil, export the sub-tree
|
||||
at point, extracting information from the headline properties
|
||||
first.
|
||||
|
||||
When optional argument VISIBLE-ONLY is non-nil, don't export
|
||||
contents of hidden elements.
|
||||
|
||||
Export is done in a buffer named \"*Org MD Export*\", which will
|
||||
be displayed when `org-export-show-temporary-export-buffer' is
|
||||
non-nil."
|
||||
(interactive)
|
||||
(org-export-to-buffer 'md "*Org MD Export*"
|
||||
async subtreep visible-only nil nil (lambda () (text-mode))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-md-convert-region-to-md ()
|
||||
"Assume the current region has org-mode syntax, and convert it to Markdown.
|
||||
This can be used in any buffer. For example, you can write an
|
||||
itemized list in org-mode syntax in a Markdown buffer and use
|
||||
this command to convert it."
|
||||
(interactive)
|
||||
(org-export-replace-region-by 'md))
|
||||
|
||||
|
||||
;;;###autoload
|
||||
(defun org-md-export-to-markdown (&optional async subtreep visible-only)
|
||||
"Export current buffer to a Markdown file.
|
||||
|
||||
If narrowing is active in the current buffer, only export its
|
||||
narrowed part.
|
||||
|
||||
If a region is active, export that region.
|
||||
|
||||
A non-nil optional argument ASYNC means the process should happen
|
||||
asynchronously. The resulting file should be accessible through
|
||||
the `org-export-stack' interface.
|
||||
|
||||
When optional argument SUBTREEP is non-nil, export the sub-tree
|
||||
at point, extracting information from the headline properties
|
||||
first.
|
||||
|
||||
When optional argument VISIBLE-ONLY is non-nil, don't export
|
||||
contents of hidden elements.
|
||||
|
||||
Return output file's name."
|
||||
(interactive)
|
||||
(let ((outfile (org-export-output-file-name ".md" subtreep)))
|
||||
(org-export-to-file 'md outfile async subtreep visible-only)))
|
||||
|
||||
|
||||
(provide 'ox-md)
|
||||
|
||||
;; Local variables:
|
||||
;; generated-autoload-file: "org-loaddefs.el"
|
||||
;; End:
|
||||
|
||||
;;; ox-md.el ends here
|
4413
lisp/org/ox-odt.el
Normal file
4413
lisp/org/ox-odt.el
Normal file
File diff suppressed because it is too large
Load Diff
255
lisp/org/ox-org.el
Normal file
255
lisp/org/ox-org.el
Normal file
@ -0,0 +1,255 @@
|
||||
;;; ox-org.el --- Org Back-End for Org Export Engine
|
||||
|
||||
;; Copyright (C) 2013 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Nicolas Goaziou <n.goaziou@gmail.com>
|
||||
;; Keywords: org, wp
|
||||
|
||||
;; GNU Emacs 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.
|
||||
|
||||
;; GNU Emacs 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 GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This library implements an Org back-end for Org exporter.
|
||||
;;
|
||||
;; It introduces two interactive functions, `org-org-export-as-org'
|
||||
;; and `org-org-export-to-org', which export, respectively, to
|
||||
;; a temporary buffer and to a file.
|
||||
;;
|
||||
;; A publishing function is also provided: `org-org-publish-to-org'.
|
||||
|
||||
;;; Code:
|
||||
(require 'ox)
|
||||
(declare-function htmlize-buffer "htmlize" (&optional buffer))
|
||||
|
||||
(defgroup org-export-org nil
|
||||
"Options for exporting Org mode files to Org."
|
||||
:tag "Org Export Org"
|
||||
:group 'org-export
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0"))
|
||||
|
||||
(define-obsolete-variable-alias
|
||||
'org-export-htmlized-org-css-url 'org-org-htmlized-css-url "24.4")
|
||||
(defcustom org-org-htmlized-css-url nil
|
||||
"URL pointing to the CSS defining colors for htmlized Emacs buffers.
|
||||
Normally when creating an htmlized version of an Org buffer,
|
||||
htmlize will create the CSS to define the font colors. However,
|
||||
this does not work when converting in batch mode, and it also can
|
||||
look bad if different people with different fontification setup
|
||||
work on the same website. When this variable is non-nil,
|
||||
creating an htmlized version of an Org buffer using
|
||||
`org-org-export-as-org' will include a link to this URL if the
|
||||
setting of `org-html-htmlize-output-type' is 'css."
|
||||
:group 'org-export-org
|
||||
:type '(choice
|
||||
(const :tag "Don't include external stylesheet link" nil)
|
||||
(string :tag "URL or local href")))
|
||||
|
||||
(org-export-define-backend 'org
|
||||
'((babel-call . org-org-identity)
|
||||
(bold . org-org-identity)
|
||||
(center-block . org-org-identity)
|
||||
(clock . org-org-identity)
|
||||
(code . org-org-identity)
|
||||
(comment . (lambda (&rest args) ""))
|
||||
(comment-block . (lambda (&rest args) ""))
|
||||
(diary-sexp . org-org-identity)
|
||||
(drawer . org-org-identity)
|
||||
(dynamic-block . org-org-identity)
|
||||
(entity . org-org-identity)
|
||||
(example-block . org-org-identity)
|
||||
(fixed-width . org-org-identity)
|
||||
(footnote-definition . org-org-identity)
|
||||
(footnote-reference . org-org-identity)
|
||||
(headline . org-org-headline)
|
||||
(horizontal-rule . org-org-identity)
|
||||
(inline-babel-call . org-org-identity)
|
||||
(inline-src-block . org-org-identity)
|
||||
(inlinetask . org-org-identity)
|
||||
(italic . org-org-identity)
|
||||
(item . org-org-identity)
|
||||
(keyword . org-org-keyword)
|
||||
(latex-environment . org-org-identity)
|
||||
(latex-fragment . org-org-identity)
|
||||
(line-break . org-org-identity)
|
||||
(link . org-org-identity)
|
||||
(node-property . org-org-identity)
|
||||
(paragraph . org-org-identity)
|
||||
(plain-list . org-org-identity)
|
||||
(planning . org-org-identity)
|
||||
(property-drawer . org-org-identity)
|
||||
(quote-block . org-org-identity)
|
||||
(quote-section . org-org-identity)
|
||||
(radio-target . org-org-identity)
|
||||
(section . org-org-identity)
|
||||
(special-block . org-org-identity)
|
||||
(src-block . org-org-identity)
|
||||
(statistics-cookie . org-org-identity)
|
||||
(strike-through . org-org-identity)
|
||||
(subscript . org-org-identity)
|
||||
(superscript . org-org-identity)
|
||||
(table . org-org-identity)
|
||||
(table-cell . org-org-identity)
|
||||
(table-row . org-org-identity)
|
||||
(target . org-org-identity)
|
||||
(timestamp . org-org-identity)
|
||||
(underline . org-org-identity)
|
||||
(verbatim . org-org-identity)
|
||||
(verse-block . org-org-identity))
|
||||
:menu-entry
|
||||
'(?O "Export to Org"
|
||||
((?O "As Org buffer" org-org-export-as-org)
|
||||
(?o "As Org file" org-org-export-to-org)
|
||||
(?v "As Org file and open"
|
||||
(lambda (a s v b)
|
||||
(if a (org-org-export-to-org t s v b)
|
||||
(org-open-file (org-org-export-to-org nil s v b))))))))
|
||||
|
||||
(defun org-org-identity (blob contents info)
|
||||
"Transcode BLOB element or object back into Org syntax.
|
||||
CONTENTS is its contents, as a string or nil. INFO is ignored."
|
||||
(org-export-expand blob contents t))
|
||||
|
||||
(defun org-org-headline (headline contents info)
|
||||
"Transcode HEADLINE element back into Org syntax.
|
||||
CONTENTS is its contents, as a string or nil. INFO is ignored."
|
||||
(unless (plist-get info :with-todo-keywords)
|
||||
(org-element-put-property headline :todo-keyword nil))
|
||||
(unless (plist-get info :with-tags)
|
||||
(org-element-put-property headline :tags nil))
|
||||
(unless (plist-get info :with-priority)
|
||||
(org-element-put-property headline :priority nil))
|
||||
(org-element-put-property headline :level
|
||||
(org-export-get-relative-level headline info))
|
||||
(org-element-headline-interpreter headline contents))
|
||||
|
||||
(defun org-org-keyword (keyword contents info)
|
||||
"Transcode KEYWORD element back into Org syntax.
|
||||
CONTENTS is nil. INFO is ignored. This function ignores
|
||||
keywords targeted at other export back-ends."
|
||||
(unless (member (org-element-property :key keyword)
|
||||
(mapcar
|
||||
(lambda (block-cons)
|
||||
(and (eq (cdr block-cons) 'org-element-export-block-parser)
|
||||
(car block-cons)))
|
||||
org-element-block-name-alist))
|
||||
(org-element-keyword-interpreter keyword nil)))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-org-export-as-org (&optional async subtreep visible-only ext-plist)
|
||||
"Export current buffer to an Org buffer.
|
||||
|
||||
If narrowing is active in the current buffer, only export its
|
||||
narrowed part.
|
||||
|
||||
If a region is active, export that region.
|
||||
|
||||
A non-nil optional argument ASYNC means the process should happen
|
||||
asynchronously. The resulting buffer should be accessible
|
||||
through the `org-export-stack' interface.
|
||||
|
||||
When optional argument SUBTREEP is non-nil, export the sub-tree
|
||||
at point, extracting information from the headline properties
|
||||
first.
|
||||
|
||||
When optional argument VISIBLE-ONLY is non-nil, don't export
|
||||
contents of hidden elements.
|
||||
|
||||
EXT-PLIST, when provided, is a property list with external
|
||||
parameters overriding Org default settings, but still inferior to
|
||||
file-local settings.
|
||||
|
||||
Export is done in a buffer named \"*Org ORG Export*\", which will
|
||||
be displayed when `org-export-show-temporary-export-buffer' is
|
||||
non-nil."
|
||||
(interactive)
|
||||
(org-export-to-buffer 'org "*Org ORG Export*"
|
||||
async subtreep visible-only nil ext-plist (lambda () (org-mode))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-org-export-to-org (&optional async subtreep visible-only ext-plist)
|
||||
"Export current buffer to an org file.
|
||||
|
||||
If narrowing is active in the current buffer, only export its
|
||||
narrowed part.
|
||||
|
||||
If a region is active, export that region.
|
||||
|
||||
A non-nil optional argument ASYNC means the process should happen
|
||||
asynchronously. The resulting file should be accessible through
|
||||
the `org-export-stack' interface.
|
||||
|
||||
When optional argument SUBTREEP is non-nil, export the sub-tree
|
||||
at point, extracting information from the headline properties
|
||||
first.
|
||||
|
||||
When optional argument VISIBLE-ONLY is non-nil, don't export
|
||||
contents of hidden elements.
|
||||
|
||||
EXT-PLIST, when provided, is a property list with external
|
||||
parameters overriding Org default settings, but still inferior to
|
||||
file-local settings.
|
||||
|
||||
Return output file name."
|
||||
(interactive)
|
||||
(let ((outfile (org-export-output-file-name ".org" subtreep)))
|
||||
(org-export-to-file 'org outfile
|
||||
async subtreep visible-only nil ext-plist)))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-org-publish-to-org (plist filename pub-dir)
|
||||
"Publish an org file to org.
|
||||
|
||||
FILENAME is the filename of the Org file to be published. PLIST
|
||||
is the property list for the given project. PUB-DIR is the
|
||||
publishing directory.
|
||||
|
||||
Return output file name."
|
||||
(org-publish-org-to 'org filename ".org" plist pub-dir)
|
||||
(when (plist-get plist :htmlized-source)
|
||||
(require 'htmlize)
|
||||
(require 'ox-html)
|
||||
(let* ((org-inhibit-startup t)
|
||||
(htmlize-output-type 'css)
|
||||
(html-ext (concat "." (or (plist-get plist :html-extension)
|
||||
org-html-extension "html")))
|
||||
(visitingp (find-buffer-visiting filename))
|
||||
(work-buffer (or visitingp (find-file filename)))
|
||||
newbuf)
|
||||
(font-lock-fontify-buffer)
|
||||
(show-all)
|
||||
(org-show-block-all)
|
||||
(setq newbuf (htmlize-buffer))
|
||||
(with-current-buffer newbuf
|
||||
(when org-org-htmlized-css-url
|
||||
(goto-char (point-min))
|
||||
(and (re-search-forward
|
||||
"<style type=\"text/css\">[^\000]*?\n[ \t]*</style>.*" nil t)
|
||||
(replace-match
|
||||
(format
|
||||
"<link rel=\"stylesheet\" type=\"text/css\" href=\"%s\">"
|
||||
org-org-htmlized-css-url) t t)))
|
||||
(write-file (concat pub-dir (file-name-nondirectory filename) html-ext)))
|
||||
(kill-buffer newbuf)
|
||||
(unless visitingp (kill-buffer work-buffer)))
|
||||
(set-buffer-modified-p nil)))
|
||||
|
||||
|
||||
(provide 'ox-org)
|
||||
|
||||
;; Local variables:
|
||||
;; generated-autoload-file: "org-loaddefs.el"
|
||||
;; End:
|
||||
|
||||
;;; ox-org.el ends here
|
1238
lisp/org/ox-publish.el
Normal file
1238
lisp/org/ox-publish.el
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user