2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-create-formula-image): Remove the -E option for dvipng. * org-exp.el (org-default-export-plist): Respect #+BIND. (org-export-confirm-letbind): New function. * org.el (org-paste-subtree): Test the kill ring entry if it is going to be used. (org-copy-subtree): Use `org-forward-same-level'. (org-forward-same-level): Respect the `invisibe-ok' arg for back-to-heading. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-table-map-tables): Make sure cursor is back at table beginning after funcall. * org-agenda.el (org-agenda-bulk-action): Make sure parents are handled before children, and do not error if an entry is not found, probably because it hase been remove when the parent was archived or refiled. * org.el (org-ido-completing-read): Accept straight lists for completion as well as alists. * org-timer.el (org-timer-cancel-timers): Renamed from `org-timer-cancel-timers'. * org.el (org-cycle-internal-local): Fix problem with finding next invisible line. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-list.el (org-list-send-list): Call `org-list-goto-true-beginning' instead of `org-list-find-true-beginning', which does not exist. * org-timer.el (org-timer-reset-timers): Use `mapc'. (org-timer-set-timer): Do not assign to heading. * org-id.el (org-id-open): Quote function name. * org-macs.el (org-unmodified): Turn off recording undo information while running inside the macro. * org-table.el (org-table-export): Also work in file-less buffers. * org.el (org-startup-indented): New option. (org-startup-options): Add new options indent and noindent. (org-unfontify-region): Remove line-prefix and wrap-prefix properties. (org-after-demote-entry-hook, org-after-promote-entry-hook): New hooks. (org-promote, org-demote): Run the new hooks. * org-table.el (org-table-align): Replace leading \n as well. * org-exp.el (org-export-push-to-kill-ring): Remove `line-prefix' and `line-wrap' text properties. * org-compat.el (org-kill-new): New function. * org-agenda.el (org-format-agenda-item): Remove `line-prefix' and `line-wrap' text properties. * org-indent.el: New file. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-provide-todo-statistics): Tweak docstring. * org-id.el (org-id-open): Honor `org-link-frame-setup'. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-as-org): Insert the "-source" string before the extension. * org.el (org-read-date): Make sure the calendar is in the current frame. (org-set-emph-re): Remove the ? from the post-match. (org-emphasis-regexp-components): Add backslash to the postmatch class. (org-set-font-lock-defaults): Write \n instead of \xa, and make it optional so that also lines at the end of the buffers will still be matched as headlines. * org-table.el (org-table-error-on-row-ref-crossing-hline): Variable made obsolete. (org-table-relative-ref-may-cross-hline): New option. (org-table-find-row-type): Honow the new option `org-table-relative-ref-may-cross-hline'. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-table.el (org-table-cut-region, org-table-copy-region): Work on single field if no active region. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-latex.el (org-export-latex-make-header): Only insert title if one is defined. * org.el (org-make-options-regexp): Allow empty values. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-cycle-internal-local): Improved version of finding next visible line. (org-cycle-hide-drawers): Only hide drawers if this is really necessary. (outline-end-of-subtree): Make `outline-end-of-subtree' use the org-version of this function in Org-mode. We use advice to implement this change, so that future changes to this function in outline.el wil be handled properly. (org-forward-same-level, org-backward-same-level): New commands. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-remove-empty-overlays-at) (org-clean-visibility-after-subtree-move): New functons. (org-move-subtree-down): Simplify cleanup of display. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-mac-message.el (org-mac-message-get-links): Improve docstring. Make argument SELECT-OR-FLAGGED optional, default to "s". Fix the return value. (org-mac-message-insert-flagged): Simplify. * org.el (org-refile-get-location): Tamper with refile history o that history contains compete matches instead of the entered string. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-store-link): Never store a link to an inline task. * org-footnote.el (org-footnote-goto-local-insertion-point): Skip inline tasks when positioning footnotes. * org.el (org-refile): Remove the END line when archiving an inline task that does have an END line. * org-archive.el (org-archive-subtree): Remove the END line when archiving an inline task that does have an END line. * org-macs.el (org-with-limited-levels): New macro. (org-get-limited-outline-regexp): New function. * org-exp.el (org-export-format-source-code-or-example): Fix bug that did not enumerate first line. (org-export-mark-radio-links): Skip matches in links. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-activate-plain-links): Make single-match. (org-adapt-indentation): Fix docstring. * org-macs.el (org-unmodified): Turn of modification hooks while running this macro. 2009-08-06 Bastien Guerry <bzg@altern.org> * org.el (org-adapt-indentation): Slightly improve the docstring. (org-occur): Sends an error when the user inputs an empty string. (org-priority): Bugfix: the tag alignement should happen within save-excursion. 2009-08-06 Bastien Guerry <bzg@altern.org> * org.el (org-make-link-regexps): Don't exclude parentheses from `org-plain-link-re' (org-cycle-internal-local): When locally cycling, switch directly from CHILDREN to FOLDED if there is no subtree (org-cycle): Update the docstring to document the new behavior of `org-cycle-internal-local'. 2009-08-06 Nicolas Goaziou <n.goaziou@neuf.fr> (tiny change) * org-clock.el (org-clock-in): Bugfix: recognize timestamps with an abbreviated format for days. 2009-08-06 Bastien Guerry <bzg@altern.org> * org-protocol.el (org-protocol-default-template-key): New option. * org.el (org-refile): Bugfix: save-excursion before reading the refile target, otherwise cursor moves might confuse `org-refile'. * org.el (org-toggle-heading): Bugfix: correctly convert list items before the first headline. * org.el (org-provide-todo-statistics): Allow a list of TODO keywords to compute statistics against headlines containing a keyword from this list. (org-update-parent-todo-statistics): Possibly use the new allowed value of `org-provide-todo-statistics'. 2009-08-06 Bastien Guerry <bzg@altern.org> * org-timer.el: Add autoload cookie. * org.el (org-occur-link-in-agenda-files): New function. * org-timer.el (org-timer-last-timer): New variable. * org-agenda.el (org-agenda-mode-map): New key for org-timer-set-timer called from the agenda. * org.el (org-mode-map): New key for org-timer-set-timer. * org-timer.el (org-timer-reset-timers) (org-timer-show-remaining-time, org-timer-set-timer): New functions. * org-clock.el (org-show-notification): Update the docstring. * org.el (org-provide-todo-statistics): Allow new value 'all-headlines for this option, which includes entries with no TODO keywords in the todo statistics. (org-update-parent-todo-statistics): Possibly use the new 'all-headline value from `org-provide-todo-statistics'. 2009-08-06 Bastien Guerry <bzg@altern.org> * org-clock.el (org-dblock-write:clocktable): Add a new option :timestamp which allows display of timestamps in clock reports. * org.el (org-mode-map): Define new key `C-c C-*': convert a plain list to a subtree, preserving the structure of the list. (org-set-emph-re): Make the last element optional in the regexp. This regexp now matches an emphasized string at the end of a line. * org-list.el (org-list-goto-true-beginning) (org-list-make-subtree, org-list-make-subtrees): New functions. * org.el (org-eval-in-calendar): Select the right frame. (org-save-frame-excursion): Remove this macro. 2009-08-06 Bastien Guerry <bzg@altern.org> * org-list.el (org-list-beginning-re): Bugfix: don't use * when trying to find the beginning of a list. * org-exp.el (org-get-file-contents): Use a new argument: markup. When present, tell org-get-file-contents not to protect org-like lines. * org-id.el (org-id-uuid-program): New option to set the name of the uuidgen program. (org-id-method): Use `org-id-uuid-program'. (org-id-new): Use `org-id-uuid-program'. 2009-08-06 Bastien Guerry <bzg@altern.org> * org-exp.el (org-export-number-lines): Allow whitespace in code references. Allow the -r switch to remove the references in the source code even when the lines are not numbered: the labels can be explicit enough. * org.el (org-fontify-whole-heading-line): New option. (org-set-font-lock-defaults): Use the new option. * org-clock.el (org-show-notification-handler): New option. (org-show-notification): Use the new option. 2009-08-06 Bastien Guerry <bzg@altern.org> * org.el (org-eval-in-calendar): Fix a bug about calendar navigation when `calendar-setup' value is 'calendar-only. 2009-08-06 Bastien Guerry <bzg@altern.org> * org.el (orgstruct++-mode): Fix typo in docstring. (org-insert-link): Clean up: (or (...)) => (...) (org-insert-link): Use TAB for stored links completion. 2009-08-06 Bastien Guerry <bzg@altern.org> * org.el (org-get-refile-targets): Fix bug: don't ignore case when building the list of targets. * org-remember.el (org-remember-delete-empty-lines-at-end): New option. (org-remember-handler): Use the new option. 2009-08-06 James TD Smith <ahktenzero@mohorovi.cc> * org.el (org-tags-sort-function): New option for sorting tags. (org-set-tags): Use the new option to sort tags. * org-plot.el (org-plot/gnuplot): Run with an idle timer to avoid premature deletion of the data when using org-plot in a script. 2009-08-06 Bastien Guerry <bzg@altern.org> * org-clock.el (org-clock-in-prepare-hook): New hook. (org-clock-in): Use this new hook. 2009-08-06 Bastien Guerry <bzg@altern.org> * org.el (org-special-ctrl-a/e): Explicitely bind the value 'reversed for this option to the "true line boundary first" behavior. (org-tags-match-list-sublevels): Document the 'indented value for this variable. * org-latex.el (org-export-latex-first-lines): Fix problem with publishing the region. * org-exp.el (org-export-format-source-code-or-example): Fix bad line numbering when exporting examples in HTML. 2009-08-06 James TD Smith <ahktenzero@mohorovi.cc> * org-colview.el (org-format-time-period): Formats a time in fractional days as days, hours, mins, seconds. (org-columns-display-here): Add special handling for SINCE and SINCE_IA to format for display. * org.el (org-time-since): Add a function to get the time since an org timestamp. (org-entry-properties): Add two new special properties: SINCE and SINCE_IA. These give the time since any active or inactive timestamp in an entry. (org-special-properties): Add SINCE, SINCE_IA. (org-tags-sort-function): Add custom declaration for tags sorting function. (org-set-tags): Sort tags if org-tags-sort-function is set 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-clock.el (org-clock-goto): Find hidden headlines as well. * org.el (org-narrow-to-subtree): Find hidden headlines as well. * org-plot.el (org-plot/add-options-to-plist): Add timeind option. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-publish.el (org-publish-remove-all-timestamps): New function. (org-publish-all): Remove all timestamp files if `org-publish-all' is called with a prefix argument. * org-list.el (org-indent-item): Fix typo. (org-item-indent-positions): Normalize ordered bullet. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-macs.el (org-set-local): Make a local variable, do not make the variable buffer-local! * org-latex.el (org-export-as-latex): Call `org-install-letbind'. * org-exp.el (org-infile-export-plist): Read BIND lines. (org-install-letbind): New function. (org-export-as-org, org-export-preprocess-string): Call `org-install-letbind'. * org-list.el (org-list-demote-modify-bullet): New option. (org-first-list-item-p): Save point. (org-fix-bullet-type): New optional argument FORCE-BULLET. (org-indent-item): Honor `org-list-demote-modify-bullet'. (org-item-indent-positions): Return bullet types along with indentation. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-show-entry): Hide drawers. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-footnote.el (org-footnote-auto-adjust): New option. (org-footnote-auto-adjust-maybe): New function. (org-footnote-new, org-footnote-delete): Call `org-footnote-auto-adjust-maybe'. * org.el (org-startup-options): Add new footnote-related keywords. * org-publish.el (org-publish-timestamp-filename): Additional arguments PUB-DIR and PUB-FUNC, which are included in the hash. (org-publish-needed-p): Additional arguments PUB-DIR PUB-FUNC TRUE-PUB-DIR. Pass them through to `org-publish-timestamp-filename'. (org-publish-update-timestamp): Additional arguments PUB-DIR and PUB-FUNC, which are included in the hash. (org-publish-file): Delay timestamp test until the publishing function is known. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-agenda-bulk-action): Add scheduling and setting the deadline. * org.el (org-read-date-final-answer): New variable. (org-read-date): Store the final answer string, including the date from the calendar, for reuse by agenda bulk commands. * org-publish.el (org-publish-attachment): Fix publishing of attachments. * org-latex.el (org-export-latex-quotation-marks): Fix export of quotation makrs in parenthesis. (org-remove-initial-hash): New function. (org-export-latex-preprocess): Fix bug with infinite loop if environment is not properly closed. * org-table.el (org-table-get-remote-range): Find #+TBLNAME also when indented. * org.el (org-fontify-meta-lines-and-blocks): Make #+TBLNAME highlight also when indented. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-footnote.el (org-footnote-renumber-fn:N): New command. (org-footnote-action): Offer renumbering. * org.el (org-cycle): Honor the `integrate' value of org-cycle-include-plain-lists'. * org-list.el (org-cycle-include-plain-lists): New allowed value `internal'. Improve the docstring. * org.el (org-set-autofill-regexps): Improve the paragraph-start regexp to work better with LaTeX commands. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-latex.el (org-export-latex-inline-image-extensions): Add ps and eps extensions. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-write-agenda): Make sure org-icalendar is loaded. * org.el (org-map-entries): No longer force `org-tags-match-list-sublevels' to t during a todo-only tags search. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-latex.el (org-export-latex-low-levels): Allow user-defined environment. (org-export-latex-subcontent): Handle user-defined environment. * org-agenda.el (org-agenda-view-mode-dispatch): Add more keys to the View dispatcher. * org.el (org-hide-block-toggle): Use `org-make-overlay' instead of `make-overlay'. * org-latex.el (org-export-as-pdf): Protect match data during call to shell-quote-argument. * org-agenda.el (org-agenda-mode-map): Modify bulk action keys. (org-agenda-view-mode-dispatch): New function. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-agenda-mode): Reset list of marks. (org-agenda-mode-map): Define new keys for refile and bulk action. (org-agenda-menu): Add menu itesm for refile and bulk action. (org-agenda-refile): New function. (org-agenda-set-tags): Optional arguments TAG and ONOFF. (org-agenda-marked-entries): New variable. (org-agenda-bulk-select, org-agenda-remove-bulk-action-overlays) (org-agenda-remove-all-bulk-action-marks) (org-agenda-bulk-action): New functions/commands. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-get-file-contents): Protect org-like lines in included files. (org-export-format-source-code-or-example): Remove newlines. * org-latex.el (org-export-latex-links): Check for no-description marking. * org-exp.el (org-export-preprocess-apply-macros): Switch macro argument separator back to comma. (org-export-normalize-links): Mark links without description. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-infile-export-plist): Fix bug in macro processing. * org-agenda.el (org-agenda-clock-out): Update line after clocking out. (org-agenda-highlight-todo): Fix bug with highlighting. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-set-font-lock-defaults): Adapt formatting to capture new alignment strings. * org-table.el (orgtbl-self-insert-command): Add yas/expand to command list. (org-table-align): Check for forced align type. * org.el (org-self-insert-command): Add yas/expand to command list. * org-clock.el (org-clock-in-hook): New hook. (org-clock-in): Run `org-clock-in-hook. (org-clock-out-hook): New hook. (org-clock-out): Run `org-clock-out-hook. (org-clock-cancel-hook): New hook. (org-clock-cancel): Run `org-clock-cancel-hook. (org-clock-goto-hook): New hook. (org-clock-goto): Run `org-clock-goto-hook. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-store-link): Better default description for link to Org-mode headline. * org-exp.el (org-export-generic): Autoload the generic exporter function. (org-export): Implement the `g' key for the generic exporter. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-table.el (orgtbl-setup): Add a binding for `S-iso-lefttab', and for zbacktab'. * org-exp.el (org-infile-export-plist): Get macros also from #+SETUPFILE. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-colview.el (org-columns-capture-view): Protect vertical bars in column values. (org-columns-capture-view): Exclude comment and archived trees. * org-colview-xemacs.el (org-columns-capture-view): Protect vertical bars in column values. (org-columns-capture-view): Exclude comment and archived trees. * org.el (org-quote-vert): New function. * org-latex.el (org-export-latex-verbatim-wrap): New option. * org-exp.el (org-export-format-source-code-or-example): Use `org-export-latex-verbatim-wrap'. * org.el (org-clone-subtree-with-time-shift): Also shift inactive time stamps. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-exp-blocks.el: New file. * org-remember.el (org-remember-templates): Allow the headline element to be a function. (org-remember-apply-template): If the headline is a function, call it to get the true function. * org-clock.el (org-clock-menu): New function. (org-clock-update-mode-line): Update help string. (org-clock-modify-effort-estimate): New function. (org-clock-mark-default-task): New function. * org.el (org-hh:mm-string-to-minutes): Also take just a number of minutes as input. (org-org-menu): Add new clocking stuff. (org-clock-is-active): New function. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-open-non-existing-files): Improve docstring. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-icalendar.el (org-icalendar-include-bbdb-anniversaries): New option. (org-export-icalendar): Call `org-bbdb-anniv-export-ical'. * org-bbdb.el (org-bbdb-anniv-export-ical): New function. * org-list.el (org-get-checkbox-statistics-face): Use the new faces. * org-faces.el (org-checkbox-statistics-todo) (org-checkbox-statistics-done): New faces. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-latex.el (org-export-latex-use-verb): New variable. (org-export-latex-emph-format): Prefer \texttt over \verb when org-export-latex-use-verb is set. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-remember.el (org-remember-handler): Abort remember if the buffer is empty. * org-exp.el (org-export-format-source-code-or-example): Run `org-src-mode-hook'. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-indent-line-function): Fix indentation of +#end lines. 2009-08-06 Tassilo Horn <tassilo@member.fsf.org> * org-gnus.el (org-gnus-store-link): Require message.el in org-gnus-store-link. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-src.el: New file, split out of org.el * org-macs.el (org-replace-match-keep-properties): New function. * org-exp.el (org-export-mark-blockquote-verse-center): Better preprocessing of center and quote and verse blocks. * org-list.el (org-list-end): Respect the stored "original" indentation when determining the end of the list. * org-exp.el (org-export-replace-src-segments-and-examples): Remember indentation correctly. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-clock.el (org-clock-update-mode-line): Apply face org-mode-line-clock. * org-faces.el (org-mode-line-clock): New face. 2009-08-06 Tassilo Horn <tassilo@member.fsf.org> * org-gnus.el (org-gnus-store-link): Fix bug where `org-gnus-store-link' used wrong subject when called in an article buffer. Patch provided by fengli AT gmail DOT com. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-format-source-code-or-example): Remember the original indentation of source code snippets and examples. * org-latex.el (org-export-as-latex): Relocate the table of contents. * org.el (org-ctrl-c-ctrl-c): Update clock lines. * org-agenda.el (org-run-agenda-series): Scope global options also when creating the agenda buffer. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-adapt-indentation): Improve documentation. (org-insert-property-drawer): Respect org-adapt-indentation when inserting the drawer. (org-remove-flyspell-overlays-in): New function. (org-do-emphasis-faces, org-activate-plain-links) (org-activate-code, org-fontify-meta-lines-and-blocks) (org-activate-angle-links, org-activate-footnote-links) (org-activate-bracket-links, org-activate-dates) (org-activate-target-links, org-activate-tags): Remove flyspell overlays. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-edit-src-save): New function. * org-clock.el (org-clock-out-switch-to-state): New option. (org-clock-out): Honor `org-clock-out-switch-to-state'. * org-compat.el (org-compatible-face): Improve macro. * org.el (org-global-properties-fixed): Add default for CLOCK_MODELINE_TOTAL. * org-clock.el (org-clock-sum): Accept lists and strigs as tstart andd tend. (org-clock-sum-current-item): Optional argument TSTART, pass it to org-clock-sum. (org-clock-get-sum-start): New function. * org.el (org-startup-options): New keywords blockhide and blockshow. (org-mode): Add new invisibility spec. (org-set-startup-visibility): Hide block on startup if so desired. (org-hide-block-startup): New option. (org-block-regexp): New constant. (org-hide-block-overlays): New variable. (org-block-map, org-hide-block-toggle-all, org-hide-block-all) (org-show-block-all, org-hide-block-toggle-maybe) (org-hide-block-toggle): New functions. (org-edit-src-exit): Do not quote lines starting with # and no + behind it. (org-auto-repeat-maybe): Add LAST_REPEAT properter for a repeating entry. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-buffer-property-keys): Add Effort property for completion. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-clock.el (org-clock-sum-current-item): Fix positioning bug when retrieving total clocked time in the subtree. * org.el (org-quoting-blocks): New variable. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-table.el (org-table-store-formulas) (org-table-get-stored-formulas, org-table-fix-formulas) (org-table-edit-formulas, orgtbl-ctrl-c-ctrl-c) (orgtbl-gather-send-defs): Allow indented #+TBLFM line. * org.el (org-fontify-meta-lines, org-ctrl-c-ctrl-c): Allow indented #+TBLFM line. * org-footnote.el (org-footnote-goto-local-insertion-point): Allow indented #+TBLFM line. * org-colview.el (org-dblock-write:columnview): Allow indented #+TBLFM line. * org-colview-xemacs.el (org-dblock-write:columnview): Allow indented #+TBLFM line. * org-clock.el (org-dblock-write:clocktable): Allow indented #+TBLFM line. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-format-source-code-or-example): Make editing indented blocks work correctly. * org.el (org-edit-src-nindent): New variable. (org-edit-src-code, org-edit-fixed-width-region) (org-edit-src-find-region-and-lang, org-edit-src-exit): Make editing indented blocks work correctly. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-replace-src-segments-and-examples): FInd indented blocks. (org-export-format-source-code-or-example): Fix indentation of blocks. (org-export-remove-indentation): New function. (org-export-select-backend-specific-text): Allow backend-specific code to be indented. (org-export-mark-blockquote-verse-center): Allow markers to be indented. * org.el (org-fontify-meta-lines): New function. (org-set-font-lock-defaults): Call the new fontification function. * org-faces.el (org-meta-line): New face (org-block): New face. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-treat-insert-todo-heading-as-state-change) (org-treat-S-cursor-todo-selection-as-state-change): New variables. (org-insert-todo-heading): Honor `org-treat-insert-todo-heading-as-state-change'. (org-shiftright, org-shiftleft): Honor `org-treat-S-cursor-todo-selection-as-state-change'. (org-inhibit-logging): New variable. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-remove-subtree-entries-from-agenda): Reduce range for marker position checking. * org-latex.el (org-export-latex-first-lines): Fix bug when exporting a region. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-push-to-kill-ring): Protect using x-set-selection, because that does not always work. * org-agenda.el (org-agenda-list): Apply the new face `org-agenda-date-today'. * org-faces.el (org-agenda-date-today): New face. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-agenda-to-appt): Turn off restriction when creating appointments. * org-latex.el (org-export-latex-low-levels): Fix customization type. * org.el (org-priority, org-shiftup, org-shiftdown): Disable priority commands. * org-agenda.el (org-agenda-priority): Disable priority commands. * org.el (org-enable-priority-commands): New option. * org-colview-xemacs.el (org-columns-compute) (org-columns-number-to-string): Fix problems with empty fields. * org-colview.el (org-columns-compute) (org-columns-number-to-string): Fix problems with empty fields. * org-exp.el (org-export-push-to-kill-ring): New function. (org-export-copy-to-kill-ring): New option. * org-latex.el (org-export-as-latex): Call `org-export-push-to-kill-ring'. * org-exp.el (org-export-show-temporary-export-buffer): New option. * org-latex.el (org-export-as-latex): Use `org-export-show-temporary-export-buffer'. * org-exp.el (org-export-show-temporary-export-buffer): New option. (org-export-push-to-kill-ring): New function. * org-colview.el (org-columns-compile-map): New variable. (org-columns-new, org-columns-compute) (org-columns-number-to-string, org-columns-uncompile-format) (org-columns-compile-format): Implement new operators. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-plist-vars): Add :xml-declaration. * org-list.el (org-update-checkbox-count): Make property dependent. * org.el (org-hierarchical-todo-statistics): New option. (org-update-parent-todo-statistics): Modified to handle recursive statistics. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-publish.el (org-publish): Make this function behave correctly in interactive use when called with a prefix argument. * org.el (org-todo-statistics-hook): New hook. (org-update-parent-todo-statistics): Use new hook. (org-log-into-drawer): New function. (org-add-log-setup): Use the new `org-log-into-drawer' function to determine if we should be logging into a drawer. (org-log-into-drawer): Update docstring. (org-default-properties): Add LOG_INTO_DRAWER as a property. * org-list.el (org-checkbox-statistics-hook): New hook. (org-update-checkbox-count-maybe): Use new hook. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-edit-src-code, org-edit-fixed-width-region): Use a better bufer-generating mechanism. (org-edit-src-find-buffer): New function. * org-icalendar.el (org-print-icalendar-entries): Don't check for archive tag, this is already done by `org-agenda-skip'. data while constructing lost of tags. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-preprocess-apply-macros): Use semicolon as argument separator in macros. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-after-sorting-entries-or-items-hook): New hook. (org-sort-entries-or-items): Run the new hook. (org-after-refile-insert-hook): New hook. (org-refile): Run `org-after-refile-insert-hook'. * org-agenda.el (org-agenda-get-progress): Never take time of day from headline when displaying progress. * org-latex.el (org-export-latex-complex-heading-re): New variable. (org-export-as-latex): Force the correct regexp in the preprocessor buffer. (org-export-latex-set-initial-vars): Set `org-export-latex-complex-heading-re'. * org-agenda.el (org-agenda-start-with-log-mode): New option. (org-agenda-mode): Use `org-agenda-start-with-log-mode'. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-latex.el (org-export-latex-tables-centered): New option. (org-export-latex-tables): Use `org-export-latex-tables-centered'. * org-exp.el (org-export-as-org): New command. (org-export-as-org): New command. * org-publish.el (org-publish-org-to-org): New function. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-yank): Just call `org-yank-generic'. (org-yank-generic): New function, containing the formaer functionality of `org-yank'. * org-latex.el (org-export-latex-not-done-keywords) (org-export-latex-done-keywords): New variables. (org-export-latex-todo-keyword-markup): New option. (org-export-latex-set-initial-vars): Remember the TODO keywords. (org-export-latex-keywords-maybe): Apply the TODO markup. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-infile-export-plist): Add more default macros. (org-export-preprocess-apply-macros): Process macro arguments. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-icalendar.el (org-icalendar-include-todo): New allowedvalue `unblocked'. (org-print-icalendar-entries): Respect the new value of `org-icalendar-include-todo'. * org.el (org-link-try-special-completion) (org-file-complete-link): New functions. (org-insert-link): Add special completion support for some link types. * org-bbdb.el (org-bbdb-complete-link): New function. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-list.el (org-update-checkbox-count): Allow recursive statistics. (org-hierarchical-checkbox-statistics): New option. * org.el (org-cycle): Remove erraneous space character. * org-icalendar.el (org-icalendar-timezone): Initialize from environment. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-autoload): Fix autoloading of ascii export functions. (org-modules): Add org-special-blocks. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-icalendar.el (org-start-icalendar-file): Use the new option. (org-ical-timezone): New option. * org-exp.el (org-export-get-coderef-format): Use the description is present. * org.el (org-sort-entries-or-items): Improve docstring, and make better implementation for time sorting. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-edit-src-persistent-message): New option. (org-edit-src-code, org-edit-fixed-width-region): Use the new option. * org-clock.el (org-clock-insert-selection-line): Fix prefious patch. * org.el (org-edit-src-code, org-edit-fixed-width-region): Use separate buffer instead of indirect buffer to edit source code. (org-edit-src-exit): Make this function work with the new setup. * org-clock.el (org-clock-insert-selection-line): Make sure tasks are properly fontified before shown in the selection menu. * org.el (org-fontify-like-in-org-mode): New function. * org-latex.el (org-export-latex-links): Use the property list to retrieve the default image attributes. * org-exp.el (org-export-plist-vars): Add a new option. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export, org-export-visible): Support ASCII export to buffer (org-export-normalize-links): Do not protect the description if it is explicitly given. * org-list.el (org-reset-checkbox-state-subtree): Moved here from org-checklist.el. (org-reset-checkbox-state-subtree): Call `org-reset-checkbox-state-subtree'. * org-remember.el (org-select-remember-template): For the selection of a valid template. * org-latex.el (org-export-region-as-latex): Supply the force-no-subtree argument. (org-export-as-latex): Provide better limits when exporting the first line. When exporting to string, we still want the first lines. (org-export-latex-first-lines): New argument END, to force the end of the region. (org-export-region-as-latex): Use the property list. (org-export-as-latex): * org-colview-xemacs.el (org-columns-remove-overlays) (org-columns): Fix call to `local-variable-p'. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-latex.el (org-export-latex-after-blockquotes-hook): New hook. (org-export-latex-preprocess): Run the new hook. * org-exp.el (org-export-preprocess-after-blockquote-hook): New hook. (org-export-preprocess-string): Run the new hook. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-macs.el (org-check-external-command): New defsubst. * org.el (org-mode-map): New key for reload. (org-format-latex): Better error message when external programs are not available. * org-agenda.el (org-agenda-mode-map): Bind `org-reload'. * org.el (org-sort-entries-or-items): Explicit sorting function for priorities, needed for XEmacs compatibility. * org-remember.el (org-remember-apply-template): Improve auto-save behavior. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-latex.el (org-export-latex-preprocess): Also protect environments ending in a star. * org-list.el (org-at-item-p): Fix regular expression. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-end-of-subtree): Improve speed. * org-agenda.el (org-agenda-get-timestamps) (org-agenda-get-progress, org-agenda-get-deadlines) (org-agenda-get-scheduled, org-agenda-get-blocks): Optimizations, in particular, wait as long as possible to collect the tags. (org-stuck-projects): Improve docstring. * org.el (org-store-link): No errors when getting custom id before first headline. (org-get-tags-at): Use `org-up-heading-safe' when getting tags. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-prepare-agenda-buffers): Catch a throw to nextfile. * org-protocol.el: Remove dependency on url.el. (org-protocol-unhex-compound, org-protocol-open-source): Remove dependency on url.el. * org-latex.el (org-export-as-pdf): Use `org-latex-to-pdf-process'. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-latex.el (org-latex-to-pdf-process): New option. * org-agenda.el (org-agenda-skip-additional-timestamps-same-entry): New option. (org-agenda-get-timestamps): Honor `org-agenda-skip-additional-timestamps-same-entry'. * org-clock.el (org-clock-goto-may-find-recent-task): New option. (org-clock-goto): Find recent task only if `org-clock-goto-may-find-recent-task' allows it. * org-exp.el (org-export-remove-or-extract-drawers): Handle empty drawers, and drawers that are missing the :END: line. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-clock.el (org-clock-goto): Go to recently clocked task if no clock is running. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-update-parent-todo-statistics): Check for STATISTICS_FROM property. * org-list.el (org-update-checkbox-count): Check for STATISTICS_FROM property. * org.el (org-tab-first-hook) (org-tab-after-check-for-table-hook) (org-tab-after-check-for-cycling-hook): New hooks. (org-cycle-internal-global, org-cycle-internal-local): New functions, split out from `org-cycle'. (org-cycle): Call the new hooks. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-preprocess-string): Reset the list of preferred targets for each run of the preprocessor. * org.el (org-refile-target-verify-function): Improve documentation. (org-get-refile-targets): Respect point being moved by the verification function. * org-latex.el (org-export-latex-timestamp-keyword-markup): New option. (org-export-latex-keywords): Use new option. * org.el (org-rear-nonsticky-at): New defsubst. (org-activate-plain-links, org-activate-angle-links) (org-activate-footnote-links, org-activate-bracket-links) (org-activate-dates, org-activate-target-links) (org-activate-tags): Place the rear-nonsticky properties at the correct location. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-protocol.el (server-edit): Declare `server-edit'. (org-protocol-unhex-string, org-protocol-unhex-compound): New functions. (org-protocol-check-filename-for-protocol): Call `server-edit'. * org.el (org-default-properties): New default properteis for completion. * org-exp.el (org-export-add-subtree-options): Add new properties for subtree export. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-id.el (org-id-get-with-outline-path-completion): Turn off org-refile-target-verify-function for the duration of the command. * org.el (org-link-to-org-use-id): New possible value `create-if-interactive-and-no-custom-id'. (org-store-link): Use custom IDs. (org-link-search): Find custom ID properties from #link. (org-default-properties): Add CUSTOM_ID for property completion. (org-refile-target-verify-function): New option. (org-goto): Turn off org-refile-target-verify-function for the duration of the command. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-preferred-target-alist): New variable. (org-export-define-heading-targets): Find the new CUSTOM_ID property. (org-export-target-internal-links): Target the custom ids when possible. * org-latex.el (org-export-latex-preprocess): Better regexp for matching latex macros with arguments. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-remember.el (org-remember-handler): Allow filing to non-org files. 2009-08-06 Magnus Henoch <magnus.henoch@gmail.com> * org-table.el (org-table-fix-formulas): Do not change references to remote tables. (org-table-get-remote-range): Convert standard coordinates to RC format. * org-latex.el (org-export-latex-keywords): Fix regexp bug. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-compat.el (org-sha1-string): Function removed. * org.el (org-refile-allow-creating-parent-nodes): New option. (org-refile-get-location): New argument NEW-NODES. (org-refile): Call `org-refile-get-location' with the new argument. (org-refile-get-location): Arrange for adding a new child. (org-refile-new-child): New function. * org-clock.el: Fix a number of docstrings. (org-clock-find-position): New argument FIND-UNCLOSED to make the function find an unclosed clock in the entry. (org-clock-in): Call `org-clock-find-position' with the new argument if we might be resuming a clock. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-latex.el (org-export-latex-display-custom-times): New variable. (org-export-latex-timestamp-markup): New option. (org-export-latex-set-initial-vars): Remember the local value of `org-display-custom-times'. (org-export-latex-content): Process time stamps. (org-export-latex-time-stamps): New function. * org-macs.el (org-maybe-intangible): Add intangible property again to invisible text. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-default-export-plist): Handle undefined variables. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-sort-entries-or-items): Match TODO keywrds case-sensitively, when sorting. (org-priority): Do not match TODO keywords with wrong case. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-todo): Honor the NOBLOCKING property. * org-agenda.el (org-agenda-dim-blocked-tasks): Honor the NOBLOCKING property. * org.el (org-scan-tags): Fix bug in tag scanner 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-modules): Mark obsolete packages. * org-html.el: New file, split out from org-exp.el. * org-icalendar.el: New file, split out from org-exp.el. * org-xoxo.el: New file, split out from org-exp.el. * org-ascii.el: New file, split out from org-exp.el. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-compat.el (org-find-library-name): New function. * org.el (org-pre-cycle-hook): New hook. (org-cycle): Call the new hook in appropriate places. (org-reload): Only reload files that have been loaded before. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-set-font-lock-defaults): Enforxe space or line end after todo keyword. (org-todo): When changing TODO state, do matching case-sensitively. (org-map-continue-from): New variable. (org-scan-tags): Respect values in `org-map-continue-from'. (org-reload): Make XEmacs compatible. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-protocol.el (org-protocol-flatten-greedy): New function. (org-protocol-flatten): New function. * org.el (org-open-link-from-string): Pass reference buffer to `org-open-at-point'. (org-open-at-point): New optional argument `reference-buffer'. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-scan-tags): Make tag scan find headline in first line, 2nd attempt. (org-get-refile-targets): Add the naked file name. (org-refile): Store as top-level entry when only file name was given. * org-agenda.el (org-agenda-get-progress): Fix regexp bug. * org.el (org-block-todo-from-children-or-siblings-or-parent): Renamed from org-block-todo-from-children-or-siblings, and enhanced to look for the parent's status as well. * org-agenda.el (org-agenda-log-mode-add-notes): New option. (org-agenda-get-progress): Add first notes line to log entry if so desired. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-agenda-cleanup-fancy-diary-hook): New hook. (org-agenda-cleanup-fancy-diary): Call the new hook. * org-remember.el (org-remember-apply-template): Take the default for the annotation from the :annotation property. * org-mac-message.el (org-mac-message-get-link): Remove the quotes. (org-mac-message-get-link): Return the result. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-refile-get-location): Add file name only if not already included in outline path. * org-faces.el (org-n-level-faces): Fix customization type from number to integer. * org-exp.el (org-export-headline-levels): Fix customization type from number to integer. * org-agenda.el (org-agenda-confirm-kill) (org-agenda-custom-commands-local-options) (org-timeline-show-empty-dates, org-agenda-ndays) (org-agenda-start-on-weekday, org-scheduled-past-days): Fix customization type from number to integer. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-protocol.el: Declare some functions. * org-agenda.el (org-agenda-compare-effort): Honor `org-sort-agenda-noeffort-is-high'. (org-agenda-filter-by-tag, org-agenda-filter-make-matcher) (org-agenda-compare-effort): Implement the "?" operator for finding entries without effort setting. * org.el (org-extract-attributes-from-string): New function. * org-exp.el (org-export-splice-attributes): New function. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-mouse.el: XEmacs compatibility fixes * org.el (org-modules): Add org-inlinetasks.el (org-cycle): Implement limiting level on cycling. (org-move-subtree-down): Fix bug with swapping subtrees at end of buffer. * org-inlinetask.el: New file. * org-protocol.el: New file. * org.el (org-emphasis-regexp-components): Allow braces in emphasis pre and post match. * org-footnote.el (org-footnote-normalize): When only dorting, do not insert inline notes at the end. * org.el (org-require-autoloaded-modules): Add org-docbook.el. * org-docbook.el: New file. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-reftex-citation): New command. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-agenda-cmp-user-defined): New option. (org-sorting-choice, org-agenda-sorting-strategy): Add the new sorting options. (org-entries-lessp): Apply the new sorting option. * org.el (org-block-todo-from-children-or-siblings): Fix bug in blocker code, when an older sibling has children. * org-mac-message.el (org-mac-message-get-link): Improve getting links from multiple selected messages. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-remember.el (org-remember-finalize): Do not set buffer file name to nil. (org-remember-handler): Mark buffer as unmodified. (org-remember-handler): Delete backup file and show message about remaining backup files. (org-remember-auto-remove-backup-files): New option. * org.el (org-store-link): Use buffer name as link description in w3-mode buffers. (org-ido-switchb): Fix argument bug for completion. * org-remember.el (org-remember-apply-template): Set local variable `auto-save-visited-file-name' instead of global one. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-agenda-get-todos): Fix bug with match-data. (org-agenda-get-todos): Mark file tags as inherited. (org-agenda-list): Always search diary lines for a time. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-feed.el: New file. * org-exp.el (org-export-as-html): Close local lists depending on indentation, also when starting a table. * org-remember.el (org-remember-backup-directory) (org-remember-backup-name): New internal variable. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-clock.el (org-clock-out-if-current): Make buffer detection work in indirect buffers as well. * org.el (org-emphasis-regexp-components): Add the exxclamation mark to the post-emphasis characters. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-read-date-minibiffer-septup-hook): New hook. (org-read-date): Run the new hook. * org-mac-message.el (org-mac-flagged-mail): New group. (org-mac-mail-account): New variable. (org-mac-create-flagged-mail, org-mac-insert-flagged-mail): New commands. * org-remember.el (org-remember-backup-directory): New variable. (org-remember-apply-template): Write file to backup directory. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-mouse.el (org-mouse-todo-menu): New function. (org-mouse-todo-keywords): Function removed. (org-mouse-context-menu): Use `org-mouse-todo-menu'. * org-table.el (org-table-beginning-of-field) (org-table-end-of-field): New commands (org-table-previous-field, org-table-beginning-of-field): Better error messages. (orgtbl-setup): Include `M-a' and `M-e'. * org.el (org-backward-sentence, org-forward-sentence): New commands. * org-colview.el (org-colview-initial-truncate-line-value): New variable. (org-columns-remove-overlays): Restore the value of `truncate-lines'. (org-columns): Remember the value of `truncate-lines'. * org-colview-xemacs.el (org-colview-initial-truncate-line-value): New variable. (org-columns-remove-overlays): Restore the value of `truncate-lines'. (org-columns): Remember the value of `truncate-lines'. * org.el (org-columns-skip-arrchived-trees): New option. * org-agenda.el (org-agenda-export-html-style): Define color for org-agenda-done face. (org-search-view, org-agenda-get-todos, org-agenda-get-progress) (org-agenda-get-deadlines, org-agenda-get-scheduled): Use new face. * org.el (org-scan-tags): Use the new face. * org-faces.el (org-agenda-done): New face. * org.el (org-scan-tags): Test the value org `org-tags-match-list-sublevels'. (org-tags-match-list-sublevels): New allowed value: indented. * org-latex.el (org-export-latex-make-header): Apply macros in header. * org-exp.el (org-export-apply-macros-in-string): New function. * org-latex.el (org-export-latex-list-parameters): Fix bug with the definition of a checked box. * org-clock.el (org-clock-find-position): Fix drawer indentations. * org-latex.el (org-export-latex-low-levels): More options for how to process lower levels in LaTeX. (org-export-latex-subcontent): Better treatment for lists as a means of publishing lower levels. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-set-font-lock-defaults): Use new checkbox face. * org-faces.el (org-checkbox): New face. * org-exp.el (org-export-html-preprocess): Only create LaTeX fragement images if there is an export file. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-stuck-projects): Document that the subtree of projects that are not stuck will now be searched for stuck sub-projects. (org-agenda-skip-entry-when-regexp-matches) (org-agenda-skip-entry-when-regexp-matches-in-subtree): New functions. (org-agenda-list-stuck-projects): Use `org-agenda-skip-entry-when-regexp-matches-in-subtree'. * org-latex.el (org-export-latex-preprocess): Improve export of verses. * org-exp.el (org-export-as-html): Implement centering as a div rather than a paragraph. Do a better job with line-end in verse environments. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-open-at-point): Fix tags searches by mouse click. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-latex.el (org-export-latex-preprocess): Implement the centering markup. * org-exp.el (org-export-mark-blockquote-verse-center): Renamed from `org-export-mark-blockquote-and-verse'. (org-export-as-html): Implement the centering markup. * org-latex.el (org-export-latex-tables): Fix vertical lines in tables. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-read-date-history): New variable. (org-read-date): Use new history variable. (org-toggle-heading): Fix bug when used before first headline. (org-store-log-note): Remove drawer if empty while note is aborted. (org-remove-empty-drawer-at): New function. (org-check-after-date): New command. (org-sparse-tree): New sparse tree command "a". * org-exp.el (org-export-as-ascii): Improve export of plain lists. 2009-08-06 Bastien Guerry <bzg@altern.org> * org.el (org-toggle-fixed-width-section): Bug fix: insert a column and a space, not only a column. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-latex.el (org-export-latex-emphasis-alist): Better defaults for verbose emphasis. (org-export-latex-emph-format): New function. (org-export-latex-fontify): Call `org-export-latex-emph-format'. * org-agenda.el (org-agenda-menu): Add new commands to menu. (org-agenda-do-date-later, org-agenda-do-date-earlier) (org-agenda-date-later-minutes, org-agenda-date-earlier-minutes) (org-agenda-date-later-hours, org-agenda-date-earlier-hours): New commands. * org.el (org-timestamp-change): Move end-time along with start time. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-target-internal-links) (org-export-as-html): Protect links specified as #name. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-clone-subtree-with-time-shift): New command. * org-latex.el (org-export-latex-special-chars) (org-export-latex-treat-sub-super-char): Fix subscript export. * org-exp.el (org-create-multibrace-regexp): Do not add backslashes to the class. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-colview.el (org-columns-map): Better functions for moving up and down a row, even if `truncate-line' is nil. * org.el (org-insert-todo-heading): Make sure the keyword is inserted at the correct position. * org-publish.el (org-publish-project-alist) (org-publish-projects, org-publish-org-index): Change default anme for the index of file names to "sitemap.org". * org-latex.el (org-export-latex-tables): Use `org-split-string', for Emacs 21 compatibility. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-agenda-log-mode-items): Improve docstring. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-page-description) (org-export-page-keywords): New variables. (org-export-plist-vars): Add entries for :keywords and :description. (org-infile-export-plist): Parse for new keywords. (org-get-current-options): Add new keywords (org-export-as-html): Publish description and keywords. * org-agenda.el (org-agenda-add-entry-text-descriptive-links): New option. (org-agenda-add-entry-text): Honor `org-agenda-add-entry-text-descriptive-links'. * org-latex.el (org-export-latex-preprocess): Make all external preprocess functions use a PARAMETER arg. * org-exp.el (org-export-preprocess-string) (org-export-select-backend-specific-text) (org-export-format-source-code-or-example) (org-format-org-table-html): Support docbook export. (org-export-preprocess-string): Make all external preprocess functions use a PARAMETER arg. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-html-style-include-scripts): New option. (org-export-plist-vars): Add new option `org-export-html-style-include-scripts'. (org-export-as-html): Honor new option `org-export-html-style-include-scripts'. (org-export-html-scripts, org-export-html-style-default): Fix xml issues with the Safari browser. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-publish.el (org-publish-attachment): Only copy file when the directories differ. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-clock.el (org-clocktable-steps): Use inactive time stamps for clocktable steps. * org.el (org-additional-option-like-keywords): Add two more keywords. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-format-source-code-or-example): Mark temporary buffer unmodified, so that it will be killed even if mode like message mode has decided to assign a file name. * org.el (org-scan-tags): Improve tag inheritance. (org-scan-tags, org-make-tags-matcher): Make tag comparison case-sensitive. (org-scan-tags): Use the internal tags list instead of creating it from scratch. (org-trust-scanner-tags, org-scanner-tags): New variables. (org-scan-tags): Set `org-scanner-tags'. (org-get-tags-at): Take advantage of `org-trust-scanner-tags'. (org-map-entries): Document the possible speedup using scanner tags. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-add-planning-info): Fix bug with looking for keyword only at column 0. * org-agenda.el (org-agenda-custom-commands-local-options): Add option for tags filter preset. (org-prepare-agenda): Store filter preset as a property on the filter variable. (org-finalize-agenda): Call the filter, if there is a preset. (org-agenda-filter-by-tag): Filter again after clearing the filter, when there still is a preset. (org-agenda-filter-make-matcher, org-agenda-set-mode-name): Include the preset filter. (org-agenda-redo): Apply the filter again, also the preset filter. * org-exp.el (org-export-as-html): Use IDs in the correct way. * org.el (org-uuidgen-p): New funtion. * org-agenda.el (org-agenda-fontify-priorities): New default value `cookies'. (org-agenda-fontify-priorities): Renamed from org-fontify-priorities. * org.el (org-set-font-lock-defaults): Call `org-font-lock-add-priority-faces'. (org-font-lock-add-priority-faces): New function. * org-faces.el: (org-set-tag-faces): New option. (org-priority-faces): New variable. * org-exp.el (org-export-as-html): Add a "content" div around the entire content of the body tag. (org-export-html-get-bibliography): New function. (org-export-html-validation-link): New variable. (org-export-as-html): Add validation link to exported page. * org.el (org-match-sparse-tree): Renamed from `org-tags-sparse-tree'. (org-tags-sparse-tree): New alias. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-get-valid-level): Catch the case where the level change is nil. * org-clock.el (org-clock-find-position): Better indentation of new clock drawers. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-agenda-quit): Delete window only when the frame-setup was not `current-window'. * org.el (org-tag-persistent-alist): New option. (org-startup-options): Add keyword `noptag'. (org-fast-todo-selection): Handle :newline correctly. (org-set-tags): Handle :newline correctly. (org-fast-tag-selection): Handle :newline correctly. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-as-ascii): Reverse link buffer before outputting it. (org-export-ascii-push-links): Fix bug with pussing links into the export buffer. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-archive.el (org-archive-subtree): Do not add 1 to level if pasting at top level. * org-bbdb.el: Improve documentation. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-list.el (org-insert-item): Only consider insert empty lines is `org-empty-line-terminates-plain-lists' is not nil. * org.el (org-blank-before-new-entry): Mention the dependence on `org-empty-line-terminates-plain-lists' in the docstring. * org-publish.el (org-publish-get-project-from-filename): New optional argument UP. Only find the top project if UP is set. (org-publish-current-project): Find the top encloding project. * org-agenda.el (org-agenda-before-write-hook) (org-agenda-add-entry-text-maxlines): New options. (org-write-agenda): Run the new hook in the temporary buffer. (org-agenda-add-entry-text): New function. (org-write-agenda): Implement PDF export, using ps2pdf. * org.el (org-global-properties-fixed, org-global-properties): Improve documentation string. * org-exp.el (org-export-ascii-links-to-notes): New option. (org-export-as-ascii): Handle links better. (org-export-ascii-wrap, org-export-ascii-push-links): New functions. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-agenda): Make prefix arg optional. (org-agenda-search-headline-for-time): New option. (org-format-agenda-item): Honor `org-agenda-search-headline-for-time'. * org-table.el (orgtbl-self-insert-command): Cluster undo for 20 characters. * org.el (org-self-insert-cluster-for-undo): New option. (org-self-insert-command): Cluster undo for 20 characters. (org-self-insert-command-undo-counter): New variable. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-as-html): Fix problem with closing colone example. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org-latex.el (org-export-as-latex) (org-export-latex-first-lines): Avoid modification flag when adding or removing text properties. (org-export-latex-fontify): Catch error when org-emph-alist has entries that are not defined for LaTeX export. * org-export-latex.el: renamed to org-latex.el * org-latex.el: renamed from org-export-latex.el * org.el (orgstruct++-mode): New function. (turn-on-orgstruct++): Call `orgstruct++-mode'. (org-context-p): Allow detecting item context after the first line of an item. (orgstruct-make-binding): Detect if item-body context should be seen. (orgstruct-is-++): New variable. (org-add-planning-info): Catch the case when there is no planning info yet and the call does not want to add anything, only maybe tries to remove something. (org-special-ctrl-a/e): All value to be a cons cell with separate settings for `C-a. and `C-e'. (org-beginning-of-line, org-end-of-line): Honor separate values for `C-a' and `C-e'. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-reload): New command. 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com> * org.texi (Publishing action): Improve documentation of file names when publishing to the source directory. (Clean view): Document `org-indent-mode'. (Clocking work time): Add documentation for the new :timetamp option when creating a clock report. (Paragraphs): Fix many typos. (Plain lists): Remove duplicate explanation about the `C-c *' command. (Literal examples): Update to reflect the new behavior of the -n -r -k switches when exporting source code examples. (Structure editing): Add information about `C-c *', converting a plain list into a list of Org items. (Remember): Small rephrasing of the paragraph describing remember.el. Also mentioned that remember.el is part of Emacs 23, not Emacs 22. (Clocking work time): Add documentation about displaying the current clocking time against the effort estimate. Also add a footnote about using `org-clock-in-prepare-hook' to add an effort estimate on the fly, just before clocking it. (Footnotes): Document automatic renumbering and sorting. (Agenda commands): Document new bulk commands. (Plain lists): Document new behavior of `org-cycle-include-plain-lists'. Hyphenation only in TeX. (Clocking work time): Document the key to update effort estimates. (Clocking work time): Document the clock time display. (Structure editing, TODO basics): Document new variables. (Column attributes): Document new colciew operators. (Publishing options): Document :xml-declaration. (Tracking TODO state changes): Document the LOG_INTO_DRAWER property. (Literal examples): Document the new implementation for editing source code. (Publishing action): Mention the new publishing function, to publish an Org source file. (Publishing links): Mention how to link to an Org source file. (Macro replacement): Document new macros. (Handling links): Document type-specific completion when inserting links. (Structure editing, Plain lists): Improve documentation on sorting. (Internal links): Document custom ids for links. (Handling links): Document custom ids for links. (CSS support): Document new class. (Refiling notes): Document the possibility to create new nodes during refiling. (Agenda commands): Document the "?" operator to find tasks without effort setting. (Exporting agenda information): Section moved. (RSS Feeds): New section. (Built-in table editor): Document M-e and M-a navigate inside table field. (Stuck projects): Docment that projects identified as un-stuck will still be searchd for stuck sub-projects. (Paragraphs): Document centering. (Creating timestamps, Agenda commands): Document new behavior when changing time stamps. (Structure editing): Document the new command `org-clone-subtree-with-time-shift'. (Publishing): Refresh this chapter. (Export options, Export options, In-buffer settings): Document the new keywords. (Matching tags and properties): Collect all documentation about tags/property matches here. (Setting tags): Document `org-tag-persistent-alist'. (Weekly/daily agenda): New section. (Orgstruct mode): Describe `orgstruct++-mode'. (Drawers): Mention the LOGBOOK drawer. (Export options, Sectioning structure): Document the #+LEATEX_HEADER in-buffer setting. (Bugs): Section removed. (Hooks): New section. (Add-on packages): Moved here from old location. (Context-sensitive commands): New section. (Setting tags): Document newline option. (Global TODO list, Matching tags and properties): Mention more variables. (Checkboxes): Update to changed command behavior.
This commit is contained in:
parent
8c914fdb18
commit
c8d0cf5ca0
48 changed files with 18955 additions and 6731 deletions
|
@ -1,3 +1,86 @@
|
|||
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
|
||||
|
||||
* org.texi (Publishing action): Improve documentation of file
|
||||
names when publishing to the source directory.
|
||||
(Clean view): Document `org-indent-mode'.
|
||||
(Clocking work time): Add documentation for the
|
||||
new :timetamp option when creating a clock report.
|
||||
(Paragraphs): Fix many typos.
|
||||
(Plain lists): Remove duplicate explanation about the
|
||||
`C-c *' command.
|
||||
(Literal examples): Update to reflect the new behavior
|
||||
of the -n -r -k switches when exporting source code examples.
|
||||
(Structure editing): Add information about `C-c *',
|
||||
converting a plain list into a list of Org items.
|
||||
(Remember): Small rephrasing of the paragraph
|
||||
describing remember.el. Also mentioned that remember.el is part
|
||||
of Emacs 23, not Emacs 22.
|
||||
(Clocking work time): Add documentation about
|
||||
displaying the current clocking time against the effort estimate.
|
||||
Also add a footnote about using `org-clock-in-prepare-hook' to add
|
||||
an effort estimate on the fly, just before clocking it.
|
||||
(Footnotes): Document automatic renumbering and
|
||||
sorting.
|
||||
(Agenda commands): Document new bulk commands.
|
||||
(Plain lists): Document new behavior of
|
||||
`org-cycle-include-plain-lists'.
|
||||
Hyphenation only in TeX.
|
||||
(Clocking work time): Document the key to update effort
|
||||
estimates.
|
||||
(Clocking work time): Document the clock time display.
|
||||
(Structure editing, TODO basics): Document new
|
||||
variables.
|
||||
(Column attributes): Document new colciew operators.
|
||||
(Publishing options): Document :xml-declaration.
|
||||
(Tracking TODO state changes): Document the
|
||||
LOG_INTO_DRAWER property.
|
||||
(Literal examples): Document the new implementation for
|
||||
editing source code.
|
||||
(Publishing action): Mention the new publishing
|
||||
function, to publish an Org source file.
|
||||
(Publishing links): Mention how to link to an Org source file.
|
||||
(Macro replacement): Document new macros.
|
||||
(Handling links): Document type-specific completion
|
||||
when inserting links.
|
||||
(Structure editing, Plain lists): Improve documentation
|
||||
on sorting.
|
||||
(Internal links): Document custom ids for links.
|
||||
(Handling links): Document custom ids for links.
|
||||
(CSS support): Document new class.
|
||||
(Refiling notes): Document the possibility to create new nodes
|
||||
during refiling.
|
||||
(Agenda commands): Document the "?" operator to find
|
||||
tasks without effort setting.
|
||||
(Exporting agenda information): Section moved.
|
||||
(RSS Feeds): New section.
|
||||
(Built-in table editor): Document M-e and M-a navigate
|
||||
inside table field.
|
||||
(Stuck projects): Docment that projects identified as
|
||||
un-stuck will still be searchd for stuck sub-projects.
|
||||
(Paragraphs): Document centering.
|
||||
(Creating timestamps, Agenda commands): Document new
|
||||
behavior when changing time stamps.
|
||||
(Structure editing): Document the new command
|
||||
`org-clone-subtree-with-time-shift'.
|
||||
(Publishing): Refresh this chapter.
|
||||
(Export options, Export options, In-buffer settings):
|
||||
Document the new keywords.
|
||||
(Matching tags and properties): Collect all
|
||||
documentation about tags/property matches here.
|
||||
(Setting tags): Document `org-tag-persistent-alist'.
|
||||
(Weekly/daily agenda): New section.
|
||||
(Orgstruct mode): Describe `orgstruct++-mode'.
|
||||
(Drawers): Mention the LOGBOOK drawer.
|
||||
(Export options, Sectioning structure): Document the
|
||||
#+LEATEX_HEADER in-buffer setting.
|
||||
(Bugs): Section removed.
|
||||
(Hooks): New section.
|
||||
(Add-on packages): Moved here from old location.
|
||||
(Context-sensitive commands): New section.
|
||||
(Setting tags): Document newline option.
|
||||
(Global TODO list, Matching tags and properties):
|
||||
Mention more variables.
|
||||
(Checkboxes): Update to changed command behavior.
|
||||
2009-08-02 Eric Yu <sucode@gmail.com> (tiny change)
|
||||
|
||||
* speedbar.texi (Basic Key Bindings): Fix typo.
|
||||
|
|
4226
doc/misc/org.texi
4226
doc/misc/org.texi
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
|||
% Reference Card for Org Mode
|
||||
\def\orgversionnumber{6.21b}
|
||||
\def\orgversionnumber{6.29c}
|
||||
\def\versionyear{2009} % latest update
|
||||
\def\year{2009} % latest copyright year
|
||||
|
||||
|
@ -276,14 +276,13 @@
|
|||
|
||||
\section{Getting Started}
|
||||
%
|
||||
\vskip -1mm
|
||||
\vskip -2mm
|
||||
\beginexample%
|
||||
(add-to-list 'auto-mode-alist '("\\\\.org\$" . org-mode))
|
||||
(define-key global-map "\\C-cl" 'org-store-link)$^1$
|
||||
(define-key global-map "\\C-ca" 'org-agenda)$^1$
|
||||
\endexample
|
||||
%
|
||||
\metax{For the many customization options try}{M-x org-customize}
|
||||
\metax{To read the on-line documentation try}{M-x org-info}
|
||||
|
||||
\section{Visibility Cycling}
|
||||
|
@ -314,6 +313,8 @@ \section{Structure Editing}
|
|||
\metax{promote/demote current subtree}{M-S-LEFT/RIGHT}
|
||||
|
||||
\metax{move subtree/list item up/down}{M-S-UP/DOWN}
|
||||
\metax{sort subtree/region/plain-list}{C-c \^{}}
|
||||
\metax{clone a subtree}{C-c C-x c}
|
||||
\metax{refile subtree}{C-c C-w}
|
||||
\metax{kill/copy subtree}{C-c C-x C-w/M-w}
|
||||
\metax{yank subtree}{C-c C-x C-y or C-y}
|
||||
|
@ -363,6 +364,7 @@ \section{Tables}
|
|||
\key{re-align the table, move to next field}{TAB}
|
||||
\key{move to previous field}{S-TAB}
|
||||
\key{re-align the table, move to next row}{RET}
|
||||
\key{move to beginning/end of field}{M-a/e}
|
||||
|
||||
{\bf Row and column editing}
|
||||
|
||||
|
@ -418,8 +420,7 @@ \section{Tables}
|
|||
\key{iterate table to stability}{C-u C-u C-c *}
|
||||
\key{rotate calculation mark through \# * ! \^ \_ \$}{C-\#}
|
||||
\key{show line, column, formula reference}{C-c ?}
|
||||
\key{toggle coordinate grid}{C-c \}}
|
||||
\key{toggle formula debugger}{C-c \{}
|
||||
\key{toggle grid / debugger}{C-c \}/\{}
|
||||
|
||||
\newcolumn
|
||||
{\it Formula Editor}
|
||||
|
@ -452,6 +453,7 @@ \section{Links}
|
|||
\key{find next link}{C-c C-x C-n}
|
||||
\key{find previous link}{C-c C-x C-p}
|
||||
\key{edit code snippet of file at point}{C-c '}
|
||||
|
||||
{\bf Internal Links}
|
||||
|
||||
\key{\kbd{<<My Target>>}}{\rm target}
|
||||
|
@ -507,7 +509,7 @@ \section{Completion}
|
|||
macros after ``{\tt \\}'', option keywords after ``{\tt \#-}'', TAGS
|
||||
after ``{\tt :}'', and dictionary words elsewhere.
|
||||
|
||||
\key{Complete word at point}{M-TAB}
|
||||
\key{complete word at point}{M-TAB}
|
||||
|
||||
|
||||
\newcolumn
|
||||
|
@ -520,6 +522,7 @@ \section{TODO Items and Checkboxes}
|
|||
\key{rotate the state of the current item}{C-c C-t}
|
||||
\metax{select next/previous state}{S-LEFT/RIGHT}
|
||||
\metax{select next/previous set}{C-S-LEFT/RIGHT}
|
||||
\key{toggle ORDERED property}{C-c C-x o}
|
||||
\key{view TODO items in a sparse tree}{C-c C-v}
|
||||
\key{view 3rd TODO keyword's sparse tree}{C-3 C-c C-v}
|
||||
|
||||
|
@ -534,7 +537,7 @@ \section{TODO Items and Checkboxes}
|
|||
\key{insert new checkbox item in plain list}{M-S-RET}
|
||||
\key{toggle checkbox(es) in region/entry/at point}{C-c C-x C-b}
|
||||
\key{toggle checkbox at point}{C-c C-c}
|
||||
\metax{checkbox statistics cookies: insert {\tt [/]} or {\tt [\%]}}{}
|
||||
%\metax{checkbox statistics cookies: insert {\tt [/]} or {\tt [\%]}}{}
|
||||
\key{update checkbox statistics (\kbd{C-u} : whole file)}{C-c \#}
|
||||
|
||||
\section{Tags}
|
||||
|
@ -553,11 +556,10 @@ \section{Properties and Column View}
|
|||
\key{capture columns view in dynamic block}{C-c C-x i}
|
||||
|
||||
\key{quit column view}{q}
|
||||
\key{next/previous allowed value}{S-left/right}
|
||||
\key{next/previous allowed value}{n / p}
|
||||
\key{show full value}{v}
|
||||
\key{edit value}{e}
|
||||
\metax{next/previous allowed value}{n/p or S-left/right}
|
||||
\key{edit allowed values list}{a}
|
||||
\key{show value}{v}
|
||||
\key{make column wider/narrower}{> / <}
|
||||
\key{move column left/right}{M-left/right}
|
||||
\key{add new column}{M-S-right}
|
||||
|
@ -568,7 +570,7 @@ \section{Timestamps}
|
|||
|
||||
\key{prompt for date and insert timestamp}{C-c .}
|
||||
\key{like \kbd{C-c} . but insert date and time format}{C-u C-c .}
|
||||
\key{Like \kbd{C-c .} but make stamp inactive}{C-c !} % FIXME
|
||||
\key{like \kbd{C-c .} but make stamp inactive}{C-c !} % FIXME
|
||||
\key{insert DEADLINE timestamp}{C-c C-d}
|
||||
\key{insert SCHEDULED timestamp}{C-c C-s}
|
||||
\key{create sparse tree with all deadlines due}{C-c / d}
|
||||
|
@ -578,13 +580,13 @@ \section{Timestamps}
|
|||
\key{access the calendar for the current date}{C-c >}
|
||||
\key{insert timestamp matching date in calendar}{C-c <}
|
||||
\key{access agenda for current date}{C-c C-o}
|
||||
\key{Select date while prompted}{mouse-1/RET}
|
||||
\key{select date while prompted}{mouse-1/RET}
|
||||
%\key{... select date in calendar}{mouse-1/RET}
|
||||
%\key{... scroll calendar back/forward one month}{< / >}
|
||||
%\key{... forward/backward one day}{S-LEFT/RIGHT}
|
||||
%\key{... forward/backward one week}{S-UP/DOWN}
|
||||
%\key{... forward/backward one month}{M-S-LEFT/RIGT}
|
||||
\key{Toggle custom format display for dates/times}{C-c C-x C-t}
|
||||
\key{toggle custom format display for dates/times}{C-c C-x C-t}
|
||||
|
||||
\newcolumn
|
||||
|
||||
|
@ -631,7 +633,7 @@ \section{Agenda Views}
|
|||
{\bf Change display}
|
||||
|
||||
\key{delete other windows}{o}
|
||||
\key{switch to day/week/month/year view}{d w m y}
|
||||
\key{switch to day/week/month/year view}{d w vm vy}
|
||||
\key{toggle inclusion of diary entries}{D}
|
||||
\key{toggle time grid for daily schedule}{G}
|
||||
\key{toggle display of logbook entries}{l}
|
||||
|
@ -640,7 +642,7 @@ \section{Agenda Views}
|
|||
\key{filter with repect to a tag}{/}
|
||||
\key{save all org-mode buffers}{s}
|
||||
\key{display next/previous day,week,...}{RIGHT/LEFT}
|
||||
\key{goto today}{.}
|
||||
\key{goto today / some date (prompt)}{. / j}
|
||||
|
||||
{\bf Remote editing}
|
||||
|
||||
|
@ -648,24 +650,24 @@ \section{Agenda Views}
|
|||
\key{change state of current TODO item}{t}
|
||||
\key{kill item and source}{C-k}
|
||||
\key{archive the subtree (file/tag/sibling)}{\$ / a / A}
|
||||
\key{refile the subtree}{C-c C-w}
|
||||
\key{show tags of current headline}{T}
|
||||
\key{set tags for current headline/region}{:}
|
||||
\key{set priority of current item}{p}
|
||||
\key{set / compute priority of current item}{p / P}
|
||||
\key{raise/lower priority of current item}{S-UP/DOWN$^3$}
|
||||
\key{display weighted priority of current item}{P}
|
||||
\key{run an attachment command}{C-c C-a}
|
||||
\key{schedule/set deadline for this item}{C-c C-s/d}
|
||||
\key{change timestamp to one day earlier/later}{S-LEFT/RIGHT$^3$}
|
||||
\key{change timestamp to today}{>}
|
||||
\key{insert new entry into diary}{i}
|
||||
|
||||
\newcolumn
|
||||
\key{start/stop/cancel the clock on current item}{I / O / X}
|
||||
\key{jump to running clock entry}{J}
|
||||
\key{mark / unmark / execute bulk action}{m / u / B}
|
||||
|
||||
{\bf Misc}
|
||||
|
||||
\key{Open link in current line}{C-c C-o}
|
||||
\key{open link in current line}{C-c C-o}
|
||||
|
||||
{\bf Calendar commands}
|
||||
|
||||
|
@ -681,18 +683,12 @@ \section{Agenda Views}
|
|||
\key{quit agenda, remove agenda buffer}{q}
|
||||
\key{exit agenda, remove all agenda buffers}{x}
|
||||
|
||||
\section{Calendar and Diary Integration}
|
||||
|
||||
Include Emacs diary entries into Org-mode agenda with:
|
||||
\beginexample%
|
||||
(setq org-agenda-include-diary t)
|
||||
\endexample
|
||||
|
||||
\section{LaTeX and cdlatex-mode}
|
||||
|
||||
\key{preview LaTeX fragment}{C-c C-x C-l}
|
||||
\key{Expand abbreviation (cdlatex-mode)}{TAB}
|
||||
\key{Insert/modify math symbol (cdlatex-mode)}{` / '}
|
||||
\key{expand abbreviation (cdlatex-mode)}{TAB}
|
||||
\key{insert/modify math symbol (cdlatex-mode)}{` / '}
|
||||
\key{insert citation using RefTeX}{C-c C-x [}
|
||||
|
||||
\section{Exporting and Publishing}
|
||||
|
||||
|
@ -703,7 +699,7 @@ \section{Exporting and Publishing}
|
|||
\key{export/publish dispatcher}{C-c C-e}
|
||||
|
||||
\key{export visible part only}{C-c C-e v}
|
||||
\key{insert template of export options}{C-c C-x t}
|
||||
\key{insert template of export options}{C-c C-e t}
|
||||
\key{toggle fixed width for entry or region}{C-c :}
|
||||
|
||||
%{\bf HTML formatting}
|
||||
|
@ -764,7 +760,8 @@ \section{Notes}
|
|||
$^2$ After changing a \kbd{\#+KEYWORD} or \kbd{<<<target>>>} line,
|
||||
press \kbd{C-c C-c} with the cursor still in the line to update.
|
||||
|
||||
$^3$ Keybinding affected by {\tt org-CUA-compatibility}.
|
||||
$^3$ Keybinding affected by {\tt org-support-shift-select} and {\tt
|
||||
org-replace-disputed-keys}.
|
||||
|
||||
\copyrightnotice
|
||||
|
||||
|
|
1811
lisp/org/ChangeLog
1811
lisp/org/ChangeLog
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -6,7 +6,7 @@
|
|||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
@ -32,6 +32,8 @@
|
|||
|
||||
(require 'org)
|
||||
|
||||
(declare-function org-inlinetask-remove-END-maybe "org-inlinetask" ())
|
||||
|
||||
(defcustom org-archive-sibling-heading "Archive"
|
||||
"Name of the local archive sibling that is used to archive entries locally.
|
||||
Locally means: in the tree, under a sibling.
|
||||
|
@ -270,7 +272,7 @@ this heading."
|
|||
;; No specific heading, just go to end of file.
|
||||
(goto-char (point-max)) (insert "\n"))
|
||||
;; Paste
|
||||
(org-paste-subtree (org-get-valid-level level 1))
|
||||
(org-paste-subtree (org-get-valid-level level (and heading 1)))
|
||||
|
||||
;; Mark the entry as done
|
||||
(when (and org-archive-mark-done
|
||||
|
@ -303,12 +305,16 @@ this heading."
|
|||
;; Here we are back in the original buffer. Everything seems to have
|
||||
;; worked. So now cut the tree and finish up.
|
||||
(let (this-command) (org-cut-subtree))
|
||||
(when (featurep 'org-inlinetask)
|
||||
(org-inlinetask-remove-END-maybe))
|
||||
(setq org-markers-to-move nil)
|
||||
(message "Subtree archived %s"
|
||||
(if (eq this-buffer buffer)
|
||||
(concat "under heading: " heading)
|
||||
(concat "in file: " (abbreviate-file-name afile))))))
|
||||
(org-reveal))
|
||||
(org-reveal)
|
||||
(if (looking-at "^[ \t]*$")
|
||||
(outline-next-visible-heading 1)))
|
||||
|
||||
(defun org-archive-to-archive-sibling ()
|
||||
"Archive the current heading by moving it under the archive sibling.
|
||||
|
@ -360,7 +366,9 @@ sibling does not exist, it will be created at the end of the subtree."
|
|||
(hide-subtree)
|
||||
(org-cycle-show-empty-lines 'folded)
|
||||
(goto-char pos)))
|
||||
(org-reveal))
|
||||
(org-reveal)
|
||||
(if (looking-at "^[ \t]*$")
|
||||
(outline-next-visible-heading 1)))
|
||||
|
||||
(defun org-archive-all-done (&optional tag)
|
||||
"Archive sublevels of the current tree without open TODO items.
|
||||
|
|
606
lisp/org/org-ascii.el
Normal file
606
lisp/org/org-ascii.el
Normal file
|
@ -0,0 +1,606 @@
|
|||
;;; org-ascii.el --- ASCII export for Org-mode
|
||||
|
||||
;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
|
||||
;; Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; 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:
|
||||
|
||||
(require 'org-exp)
|
||||
|
||||
(defgroup org-export-ascii nil
|
||||
"Options specific for ASCII export of Org-mode files."
|
||||
:tag "Org Export ASCII"
|
||||
:group 'org-export)
|
||||
|
||||
(defcustom org-export-ascii-underline '(?\$ ?\# ?^ ?\~ ?\= ?\-)
|
||||
"Characters for underlining headings in ASCII export.
|
||||
In the given sequence, these characters will be used for level 1, 2, ..."
|
||||
:group 'org-export-ascii
|
||||
:type '(repeat character))
|
||||
|
||||
(defcustom org-export-ascii-bullets '(?* ?+ ?-)
|
||||
"Bullet characters for headlines converted to lists in ASCII export.
|
||||
The first character is used for the first lest level generated in this
|
||||
way, and so on. If there are more levels than characters given here,
|
||||
the list will be repeated.
|
||||
Note that plain lists will keep the same bullets as the have in the
|
||||
Org-mode file."
|
||||
:group 'org-export-ascii
|
||||
:type '(repeat character))
|
||||
|
||||
(defcustom org-export-ascii-links-to-notes t
|
||||
"Non-nil means, convert links to notes before the next headline.
|
||||
When nil, the link will be exported in place. If the line becomes long
|
||||
in this way, it will be wrapped."
|
||||
:group 'org-export-ascii
|
||||
:type 'boolean)
|
||||
|
||||
;;; ASCII export
|
||||
|
||||
(defvar org-ascii-current-indentation nil) ; For communication
|
||||
|
||||
;;;###autoload
|
||||
(defun org-export-as-ascii-to-buffer (arg)
|
||||
"Call `org-export-as-ascii` with output to a temporary buffer.
|
||||
No file is created. The prefix ARG is passed through to `org-export-as-ascii'."
|
||||
(interactive "P")
|
||||
(org-export-as-ascii arg nil nil "*Org ASCII Export*")
|
||||
(when org-export-show-temporary-export-buffer
|
||||
(switch-to-buffer-other-window "*Org ASCII Export*")))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-replace-region-by-ascii (beg end)
|
||||
"Assume the current region has org-mode syntax, and convert it to plain ASCII.
|
||||
This can be used in any buffer. For example, you could write an
|
||||
itemized list in org-mode syntax in a Mail buffer and then use this
|
||||
command to convert it."
|
||||
(interactive "r")
|
||||
(let (reg ascii buf pop-up-frames)
|
||||
(save-window-excursion
|
||||
(if (org-mode-p)
|
||||
(setq ascii (org-export-region-as-ascii
|
||||
beg end t 'string))
|
||||
(setq reg (buffer-substring beg end)
|
||||
buf (get-buffer-create "*Org tmp*"))
|
||||
(with-current-buffer buf
|
||||
(erase-buffer)
|
||||
(insert reg)
|
||||
(org-mode)
|
||||
(setq ascii (org-export-region-as-ascii
|
||||
(point-min) (point-max) t 'string)))
|
||||
(kill-buffer buf)))
|
||||
(delete-region beg end)
|
||||
(insert ascii)))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-export-region-as-ascii (beg end &optional body-only buffer)
|
||||
"Convert region from BEG to END in org-mode buffer to plain ASCII.
|
||||
If prefix arg BODY-ONLY is set, omit file header, footer, and table of
|
||||
contents, and only produce the region of converted text, useful for
|
||||
cut-and-paste operations.
|
||||
If BUFFER is a buffer or a string, use/create that buffer as a target
|
||||
of the converted ASCII. If BUFFER is the symbol `string', return the
|
||||
produced ASCII as a string and leave not buffer behind. For example,
|
||||
a Lisp program could call this function in the following way:
|
||||
|
||||
(setq ascii (org-export-region-as-ascii beg end t 'string))
|
||||
|
||||
When called interactively, the output buffer is selected, and shown
|
||||
in a window. A non-interactive call will only return the buffer."
|
||||
(interactive "r\nP")
|
||||
(when (interactive-p)
|
||||
(setq buffer "*Org ASCII Export*"))
|
||||
(let ((transient-mark-mode t) (zmacs-regions t)
|
||||
ext-plist rtn)
|
||||
(setq ext-plist (plist-put ext-plist :ignore-subree-p t))
|
||||
(goto-char end)
|
||||
(set-mark (point)) ;; to activate the region
|
||||
(goto-char beg)
|
||||
(setq rtn (org-export-as-ascii
|
||||
nil nil ext-plist
|
||||
buffer body-only))
|
||||
(if (fboundp 'deactivate-mark) (deactivate-mark))
|
||||
(if (and (interactive-p) (bufferp rtn))
|
||||
(switch-to-buffer-other-window rtn)
|
||||
rtn)))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-export-as-ascii (arg &optional hidden ext-plist
|
||||
to-buffer body-only pub-dir)
|
||||
"Export the outline as a pretty ASCII file.
|
||||
If there is an active region, export only the region.
|
||||
The prefix ARG specifies how many levels of the outline should become
|
||||
underlined headlines, default is 3. Lower levels will become bulleted
|
||||
lists. When HIDDEN is non-nil, don't display the ASCII buffer.
|
||||
EXT-PLIST is a property list with external parameters overriding
|
||||
org-mode's default settings, but still inferior to file-local
|
||||
settings. When TO-BUFFER is non-nil, create a buffer with that
|
||||
name and export to that buffer. If TO-BUFFER is the symbol
|
||||
`string', don't leave any buffer behind but just return the
|
||||
resulting ASCII as a string. When BODY-ONLY is set, don't produce
|
||||
the file header and footer. When PUB-DIR is set, use this as the
|
||||
publishing directory."
|
||||
(interactive "P")
|
||||
(setq-default org-todo-line-regexp org-todo-line-regexp)
|
||||
(let* ((opt-plist (org-combine-plists (org-default-export-plist)
|
||||
ext-plist
|
||||
(org-infile-export-plist)))
|
||||
(region-p (org-region-active-p))
|
||||
(rbeg (and region-p (region-beginning)))
|
||||
(rend (and region-p (region-end)))
|
||||
(subtree-p
|
||||
(if (plist-get opt-plist :ignore-subree-p)
|
||||
nil
|
||||
(when region-p
|
||||
(save-excursion
|
||||
(goto-char rbeg)
|
||||
(and (org-at-heading-p)
|
||||
(>= (org-end-of-subtree t t) rend))))))
|
||||
(level-offset (if subtree-p
|
||||
(save-excursion
|
||||
(goto-char rbeg)
|
||||
(+ (funcall outline-level)
|
||||
(if org-odd-levels-only 1 0)))
|
||||
0))
|
||||
(opt-plist (setq org-export-opt-plist
|
||||
(if subtree-p
|
||||
(org-export-add-subtree-options opt-plist rbeg)
|
||||
opt-plist)))
|
||||
(custom-times org-display-custom-times)
|
||||
(org-ascii-current-indentation '(0 . 0))
|
||||
(level 0) line txt
|
||||
(umax nil)
|
||||
(umax-toc nil)
|
||||
(case-fold-search nil)
|
||||
(bfname (buffer-file-name (or (buffer-base-buffer) (current-buffer))))
|
||||
(filename (if to-buffer
|
||||
nil
|
||||
(concat (file-name-as-directory
|
||||
(or pub-dir
|
||||
(org-export-directory :ascii opt-plist)))
|
||||
(file-name-sans-extension
|
||||
(or (and subtree-p
|
||||
(org-entry-get (region-beginning)
|
||||
"EXPORT_FILE_NAME" t))
|
||||
(file-name-nondirectory bfname)))
|
||||
".txt")))
|
||||
(filename (and filename
|
||||
(if (equal (file-truename filename)
|
||||
(file-truename bfname))
|
||||
(concat filename ".txt")
|
||||
filename)))
|
||||
(buffer (if to-buffer
|
||||
(cond
|
||||
((eq to-buffer 'string)
|
||||
(get-buffer-create "*Org ASCII Export*"))
|
||||
(t (get-buffer-create to-buffer)))
|
||||
(find-file-noselect filename)))
|
||||
(org-levels-open (make-vector org-level-max nil))
|
||||
(odd org-odd-levels-only)
|
||||
(date (plist-get opt-plist :date))
|
||||
(author (plist-get opt-plist :author))
|
||||
(title (or (and subtree-p (org-export-get-title-from-subtree))
|
||||
(plist-get opt-plist :title)
|
||||
(and (not
|
||||
(plist-get opt-plist :skip-before-1st-heading))
|
||||
(org-export-grab-title-from-buffer))
|
||||
(file-name-sans-extension
|
||||
(file-name-nondirectory bfname))))
|
||||
(email (plist-get opt-plist :email))
|
||||
(language (plist-get opt-plist :language))
|
||||
(quote-re0 (concat "^[ \t]*" org-quote-string "\\>"))
|
||||
(todo nil)
|
||||
(lang-words nil)
|
||||
(region
|
||||
(buffer-substring
|
||||
(if (org-region-active-p) (region-beginning) (point-min))
|
||||
(if (org-region-active-p) (region-end) (point-max))))
|
||||
(lines (org-split-string
|
||||
(org-export-preprocess-string
|
||||
region
|
||||
:for-ascii t
|
||||
:skip-before-1st-heading
|
||||
(plist-get opt-plist :skip-before-1st-heading)
|
||||
:drawers (plist-get opt-plist :drawers)
|
||||
:tags (plist-get opt-plist :tags)
|
||||
:priority (plist-get opt-plist :priority)
|
||||
:footnotes (plist-get opt-plist :footnotes)
|
||||
:timestamps (plist-get opt-plist :timestamps)
|
||||
:todo-keywords (plist-get opt-plist :todo-keywords)
|
||||
:verbatim-multiline t
|
||||
:select-tags (plist-get opt-plist :select-tags)
|
||||
:exclude-tags (plist-get opt-plist :exclude-tags)
|
||||
:archived-trees
|
||||
(plist-get opt-plist :archived-trees)
|
||||
:add-text (plist-get opt-plist :text))
|
||||
"\n"))
|
||||
thetoc have-headings first-heading-pos
|
||||
table-open table-buffer link-buffer link desc desc0 rpl wrap)
|
||||
(let ((inhibit-read-only t))
|
||||
(org-unmodified
|
||||
(remove-text-properties (point-min) (point-max)
|
||||
'(:org-license-to-kill t))))
|
||||
|
||||
(setq org-min-level (org-get-min-level lines level-offset))
|
||||
(setq org-last-level org-min-level)
|
||||
(org-init-section-numbers)
|
||||
(setq lang-words (or (assoc language org-export-language-setup)
|
||||
(assoc "en" org-export-language-setup)))
|
||||
(set-buffer buffer)
|
||||
(erase-buffer)
|
||||
(fundamental-mode)
|
||||
(org-install-letbind)
|
||||
;; create local variables for all options, to make sure all called
|
||||
;; functions get the correct information
|
||||
(mapc (lambda (x)
|
||||
(set (make-local-variable (nth 2 x))
|
||||
(plist-get opt-plist (car x))))
|
||||
org-export-plist-vars)
|
||||
(org-set-local 'org-odd-levels-only odd)
|
||||
(setq umax (if arg (prefix-numeric-value arg)
|
||||
org-export-headline-levels))
|
||||
(setq umax-toc (if (integerp org-export-with-toc)
|
||||
(min org-export-with-toc umax)
|
||||
umax))
|
||||
|
||||
;; File header
|
||||
(unless body-only
|
||||
(if title (org-insert-centered title ?=))
|
||||
(insert "\n")
|
||||
(if (and (or author email)
|
||||
org-export-author-info)
|
||||
(insert (concat (nth 1 lang-words) ": " (or author "")
|
||||
(if email (concat " <" email ">") "")
|
||||
"\n")))
|
||||
|
||||
(cond
|
||||
((and date (string-match "%" date))
|
||||
(setq date (format-time-string date)))
|
||||
(date)
|
||||
(t (setq date (format-time-string "%Y-%m-%d %T %Z"))))
|
||||
|
||||
(if (and date org-export-time-stamp-file)
|
||||
(insert (concat (nth 2 lang-words) ": " date"\n")))
|
||||
|
||||
(insert "\n\n"))
|
||||
|
||||
(if (and org-export-with-toc (not body-only))
|
||||
(progn
|
||||
(push (concat (nth 3 lang-words) "\n") thetoc)
|
||||
(push (concat (make-string (string-width (nth 3 lang-words)) ?=)
|
||||
"\n") thetoc)
|
||||
(mapc '(lambda (line)
|
||||
(if (string-match org-todo-line-regexp
|
||||
line)
|
||||
;; This is a headline
|
||||
(progn
|
||||
(setq have-headings t)
|
||||
(setq level (- (match-end 1) (match-beginning 1)
|
||||
level-offset)
|
||||
level (org-tr-level level)
|
||||
txt (match-string 3 line)
|
||||
todo
|
||||
(or (and org-export-mark-todo-in-toc
|
||||
(match-beginning 2)
|
||||
(not (member (match-string 2 line)
|
||||
org-done-keywords)))
|
||||
; TODO, not DONE
|
||||
(and org-export-mark-todo-in-toc
|
||||
(= level umax-toc)
|
||||
(org-search-todo-below
|
||||
line lines level))))
|
||||
(setq txt (org-html-expand-for-ascii txt))
|
||||
|
||||
(while (string-match org-bracket-link-regexp txt)
|
||||
(setq txt
|
||||
(replace-match
|
||||
(match-string (if (match-end 2) 3 1) txt)
|
||||
t t txt)))
|
||||
|
||||
(if (and (memq org-export-with-tags '(not-in-toc nil))
|
||||
(string-match
|
||||
(org-re "[ \t]+:[[:alnum:]_@:]+:[ \t]*$")
|
||||
txt))
|
||||
(setq txt (replace-match "" t t txt)))
|
||||
(if (string-match quote-re0 txt)
|
||||
(setq txt (replace-match "" t t txt)))
|
||||
|
||||
(if org-export-with-section-numbers
|
||||
(setq txt (concat (org-section-number level)
|
||||
" " txt)))
|
||||
(if (<= level umax-toc)
|
||||
(progn
|
||||
(push
|
||||
(concat
|
||||
(make-string
|
||||
(* (max 0 (- level org-min-level)) 4) ?\ )
|
||||
(format (if todo "%s (*)\n" "%s\n") txt))
|
||||
thetoc)
|
||||
(setq org-last-level level))
|
||||
))))
|
||||
lines)
|
||||
(setq thetoc (if have-headings (nreverse thetoc) nil))))
|
||||
|
||||
(org-init-section-numbers)
|
||||
(while (setq line (pop lines))
|
||||
(when (and link-buffer (string-match "^\\*+ " line))
|
||||
(org-export-ascii-push-links (nreverse link-buffer))
|
||||
(setq link-buffer nil))
|
||||
(setq wrap nil)
|
||||
;; Remove the quoted HTML tags.
|
||||
(setq line (org-html-expand-for-ascii line))
|
||||
;; Replace links with the description when possible
|
||||
(while (string-match org-bracket-link-regexp line)
|
||||
(setq link (match-string 1 line)
|
||||
desc0 (match-string 3 line)
|
||||
desc (or desc0 (match-string 1 line)))
|
||||
(if (and (> (length link) 8)
|
||||
(equal (substring link 0 8) "coderef:"))
|
||||
(setq line (replace-match
|
||||
(format (org-export-get-coderef-format (substring link 8) desc)
|
||||
(cdr (assoc
|
||||
(substring link 8)
|
||||
org-export-code-refs)))
|
||||
t t line))
|
||||
(setq rpl (concat "["
|
||||
(or (match-string 3 line) (match-string 1 line))
|
||||
"]"))
|
||||
(when (and desc0 (not (equal desc0 link)))
|
||||
(if org-export-ascii-links-to-notes
|
||||
(push (cons desc0 link) link-buffer)
|
||||
(setq rpl (concat rpl " (" link ")")
|
||||
wrap (+ (length line) (- (length (match-string 0 line)))
|
||||
(length desc)))))
|
||||
(setq line (replace-match rpl t t line))))
|
||||
(when custom-times
|
||||
(setq line (org-translate-time line)))
|
||||
(cond
|
||||
((string-match "^\\(\\*+\\)[ \t]+\\(.*\\)" line)
|
||||
;; a Headline
|
||||
(setq first-heading-pos (or first-heading-pos (point)))
|
||||
(setq level (org-tr-level (- (match-end 1) (match-beginning 1)
|
||||
level-offset))
|
||||
txt (match-string 2 line))
|
||||
(org-ascii-level-start level txt umax lines))
|
||||
|
||||
((and org-export-with-tables
|
||||
(string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" line))
|
||||
(if (not table-open)
|
||||
;; New table starts
|
||||
(setq table-open t table-buffer nil))
|
||||
;; Accumulate lines
|
||||
(setq table-buffer (cons line table-buffer))
|
||||
(when (or (not lines)
|
||||
(not (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)"
|
||||
(car lines))))
|
||||
(setq table-open nil
|
||||
table-buffer (nreverse table-buffer))
|
||||
(insert (mapconcat
|
||||
(lambda (x)
|
||||
(org-fix-indentation x org-ascii-current-indentation))
|
||||
(org-format-table-ascii table-buffer)
|
||||
"\n") "\n")))
|
||||
(t
|
||||
(if (string-match "^\\([ \t]*\\)\\([-+*][ \t]+\\)\\(.*?\\)\\( ::\\)" line)
|
||||
(setq line (replace-match "\\1\\3:" t nil line)))
|
||||
(setq line (org-fix-indentation line org-ascii-current-indentation))
|
||||
;; Remove forced line breaks
|
||||
(if (string-match "\\\\\\\\[ \t]*$" line)
|
||||
(setq line (replace-match "" t t line)))
|
||||
(if (and org-export-with-fixed-width
|
||||
(string-match "^\\([ \t]*\\)\\(:\\( \\|$\\)\\)" line))
|
||||
(setq line (replace-match "\\1" nil nil line))
|
||||
(if wrap (setq line (org-export-ascii-wrap line wrap))))
|
||||
(insert line "\n"))))
|
||||
|
||||
(org-export-ascii-push-links (nreverse link-buffer))
|
||||
|
||||
(normal-mode)
|
||||
|
||||
;; insert the table of contents
|
||||
(when thetoc
|
||||
(goto-char (point-min))
|
||||
(if (re-search-forward "^[ \t]*\\[TABLE-OF-CONTENTS\\][ \t]*$" nil t)
|
||||
(progn
|
||||
(goto-char (match-beginning 0))
|
||||
(replace-match ""))
|
||||
(goto-char first-heading-pos))
|
||||
(mapc 'insert thetoc)
|
||||
(or (looking-at "[ \t]*\n[ \t]*\n")
|
||||
(insert "\n\n")))
|
||||
|
||||
;; Convert whitespace place holders
|
||||
(goto-char (point-min))
|
||||
(let (beg end)
|
||||
(while (setq beg (next-single-property-change (point) 'org-whitespace))
|
||||
(setq end (next-single-property-change beg 'org-whitespace))
|
||||
(goto-char beg)
|
||||
(delete-region beg end)
|
||||
(insert (make-string (- end beg) ?\ ))))
|
||||
|
||||
;; remove display and invisible chars
|
||||
(let (beg end)
|
||||
(goto-char (point-min))
|
||||
(while (setq beg (next-single-property-change (point) 'display))
|
||||
(setq end (next-single-property-change beg 'display))
|
||||
(delete-region beg end)
|
||||
(goto-char beg)
|
||||
(insert "=>"))
|
||||
(goto-char (point-min))
|
||||
(while (setq beg (next-single-property-change (point) 'org-cwidth))
|
||||
(setq end (next-single-property-change beg 'org-cwidth))
|
||||
(delete-region beg end)
|
||||
(goto-char beg)))
|
||||
(or to-buffer (save-buffer))
|
||||
(goto-char (point-min))
|
||||
(or (org-export-push-to-kill-ring "ASCII")
|
||||
(message "Exporting... done"))
|
||||
;; Return the buffer or a string, according to how this function was called
|
||||
(if (eq to-buffer 'string)
|
||||
(prog1 (buffer-substring (point-min) (point-max))
|
||||
(kill-buffer (current-buffer)))
|
||||
(current-buffer))))
|
||||
|
||||
(defun org-export-ascii-preprocess (parameters)
|
||||
"Do extra work for ASCII export"
|
||||
;; Put quotes around verbatim text
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward org-verbatim-re nil t)
|
||||
(goto-char (match-end 2))
|
||||
(backward-delete-char 1) (insert "'")
|
||||
(goto-char (match-beginning 2))
|
||||
(delete-char 1) (insert "`")
|
||||
(goto-char (match-end 2)))
|
||||
;; Remove target markers
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "<<<?\\([^<>]*\\)>>>?\\([ \t]*\\)" nil t)
|
||||
(replace-match "\\1\\2")))
|
||||
|
||||
(defun org-html-expand-for-ascii (line)
|
||||
"Handle quoted HTML for ASCII export."
|
||||
(if org-export-html-expand
|
||||
(while (string-match "@<[^<>\n]*>" line)
|
||||
;; We just remove the tags for now.
|
||||
(setq line (replace-match "" nil nil line))))
|
||||
line)
|
||||
|
||||
(defun org-export-ascii-wrap (line where)
|
||||
"Wrap LINE at or before WHERE."
|
||||
(let ((ind (org-get-indentation line))
|
||||
pos)
|
||||
(catch 'found
|
||||
(loop for i from where downto (/ where 2) do
|
||||
(and (equal (aref line i) ?\ )
|
||||
(setq pos i)
|
||||
(throw 'found t))))
|
||||
(if pos
|
||||
(concat (substring line 0 pos) "\n"
|
||||
(make-string ind ?\ )
|
||||
(substring line (1+ pos)))
|
||||
line)))
|
||||
|
||||
(defun org-export-ascii-push-links (link-buffer)
|
||||
"Push out links in the buffer."
|
||||
(when link-buffer
|
||||
;; We still have links to push out.
|
||||
(insert "\n")
|
||||
(let ((ind ""))
|
||||
(save-match-data
|
||||
(if (save-excursion
|
||||
(re-search-backward
|
||||
"^\\(\\([ \t]*\\)\\|\\(\\*+ \\)\\)[^ \t\n]" nil t))
|
||||
(setq ind (or (match-string 2)
|
||||
(make-string (length (match-string 3)) ?\ )))))
|
||||
(mapc (lambda (x) (insert ind "[" (car x) "]: " (cdr x) "\n"))
|
||||
link-buffer))
|
||||
(insert "\n")))
|
||||
|
||||
(defun org-ascii-level-start (level title umax &optional lines)
|
||||
"Insert a new level in ASCII export."
|
||||
(let (char (n (- level umax 1)) (ind 0))
|
||||
(if (> level umax)
|
||||
(progn
|
||||
(insert (make-string (* 2 n) ?\ )
|
||||
(char-to-string (nth (% n (length org-export-ascii-bullets))
|
||||
org-export-ascii-bullets))
|
||||
" " title "\n")
|
||||
;; find the indentation of the next non-empty line
|
||||
(catch 'stop
|
||||
(while lines
|
||||
(if (string-match "^\\* " (car lines)) (throw 'stop nil))
|
||||
(if (string-match "^\\([ \t]*\\)\\S-" (car lines))
|
||||
(throw 'stop (setq ind (org-get-indentation (car lines)))))
|
||||
(pop lines)))
|
||||
(setq org-ascii-current-indentation (cons (* 2 (1+ n)) ind)))
|
||||
(if (or (not (equal (char-before) ?\n))
|
||||
(not (equal (char-before (1- (point))) ?\n)))
|
||||
(insert "\n"))
|
||||
(setq char (nth (- umax level) (reverse org-export-ascii-underline)))
|
||||
(unless org-export-with-tags
|
||||
(if (string-match (org-re "[ \t]+\\(:[[:alnum:]_@:]+:\\)[ \t]*$") title)
|
||||
(setq title (replace-match "" t t title))))
|
||||
(if org-export-with-section-numbers
|
||||
(setq title (concat (org-section-number level) " " title)))
|
||||
(insert title "\n" (make-string (string-width title) char) "\n")
|
||||
(setq org-ascii-current-indentation '(0 . 0)))))
|
||||
|
||||
(defun org-insert-centered (s &optional underline)
|
||||
"Insert the string S centered and underline it with character UNDERLINE."
|
||||
(let ((ind (max (/ (- fill-column (string-width s)) 2) 0)))
|
||||
(insert (make-string ind ?\ ) s "\n")
|
||||
(if underline
|
||||
(insert (make-string ind ?\ )
|
||||
(make-string (string-width s) underline)
|
||||
"\n"))))
|
||||
|
||||
(defvar org-table-colgroup-info nil)
|
||||
(defun org-format-table-ascii (lines)
|
||||
"Format a table for ascii export."
|
||||
(if (stringp lines)
|
||||
(setq lines (org-split-string lines "\n")))
|
||||
(if (not (string-match "^[ \t]*|" (car lines)))
|
||||
;; Table made by table.el - test for spanning
|
||||
lines
|
||||
|
||||
;; A normal org table
|
||||
;; Get rid of hlines at beginning and end
|
||||
(if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines)))
|
||||
(setq lines (nreverse lines))
|
||||
(if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines)))
|
||||
(setq lines (nreverse lines))
|
||||
(when org-export-table-remove-special-lines
|
||||
;; Check if the table has a marking column. If yes remove the
|
||||
;; column and the special lines
|
||||
(setq lines (org-table-clean-before-export lines)))
|
||||
;; Get rid of the vertical lines except for grouping
|
||||
(let ((vl (org-colgroup-info-to-vline-list org-table-colgroup-info))
|
||||
rtn line vl1 start)
|
||||
(while (setq line (pop lines))
|
||||
(if (string-match org-table-hline-regexp line)
|
||||
(and (string-match "|\\(.*\\)|" line)
|
||||
(setq line (replace-match " \\1" t nil line)))
|
||||
(setq start 0 vl1 vl)
|
||||
(while (string-match "|" line start)
|
||||
(setq start (match-end 0))
|
||||
(or (pop vl1) (setq line (replace-match " " t t line)))))
|
||||
(push line rtn))
|
||||
(nreverse rtn))))
|
||||
|
||||
(defun org-colgroup-info-to-vline-list (info)
|
||||
(let (vl new last)
|
||||
(while info
|
||||
(setq last new new (pop info))
|
||||
(if (or (memq last '(:end :startend))
|
||||
(memq new '(:start :startend)))
|
||||
(push t vl)
|
||||
(push nil vl)))
|
||||
(setq vl (nreverse vl))
|
||||
(and vl (setcar vl nil))
|
||||
vl))
|
||||
|
||||
(provide 'org-ascii)
|
||||
|
||||
;; arch-tag: aa96f882-f477-4e13-86f5-70d43e7adf3c
|
||||
|
||||
;;; org-ascii.el ends here
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
;; Author: John Wiegley <johnw@newartisans.com>
|
||||
;; Keywords: org data task
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
@ -26,7 +26,7 @@
|
|||
;; See the Org-mode manual for information on how to use it.
|
||||
;;
|
||||
;; Attachments are managed in a special directory called "data", which
|
||||
;; lives in the directory given by `org-directory'. If this data
|
||||
;; lives in the same directory as the org file itself. If this data
|
||||
;; directory is initialized as a Git repository, then org-attach will
|
||||
;; automatically commit changes when it sees them.
|
||||
;;
|
||||
|
@ -95,7 +95,7 @@ ln create a hard link. Note that this is not supported
|
|||
"Non-nil means, allow attachment directories be inherited."
|
||||
:group 'org-attach
|
||||
:type 'boolean)
|
||||
|
||||
|
||||
|
||||
(defvar org-attach-inherited nil
|
||||
"Indicates if the last access to the attachment directory was inherited.")
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
;; Thomas Baumann <thomas dot baumann at ch dot tum dot de>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
@ -49,25 +49,37 @@
|
|||
;; %%(org-bbdb-anniversaries)
|
||||
;;
|
||||
;;
|
||||
;; The anniversaries are stored in BBDB in the field `anniversary'
|
||||
;; in the format
|
||||
;; To add an anniversary to a BBDB record, press `C-o' in the record.
|
||||
;; You will be prompted for the field name, in this case it must be
|
||||
;; "anniversary". If this is the first time you are using this field,
|
||||
;; you need to confirm that it should be created.
|
||||
;;
|
||||
;; YYYY-MM-DD{ CLASS-OR-FORMAT-STRING}*
|
||||
;; {\nYYYY-MM-DD CLASS-OR-FORMAT-STRING}*
|
||||
;; The format of an anniversary field stored in BBDB is the following
|
||||
;; (items in {} are optional):
|
||||
;;
|
||||
;; YYYY-MM-DD{ CLASS-OR-FORMAT-STRING}
|
||||
;; {\nYYYY-MM-DD CLASS-OR-FORMAT-STRING}...
|
||||
;;
|
||||
;; CLASS-OR-FORMAT-STRING is one of two things:
|
||||
;;
|
||||
;; * an identifier for a class of anniversaries (eg. birthday or
|
||||
;; wedding) from `org-bbdb-anniversary-format-alist'.
|
||||
;; * the (format) string displayed in the diary.
|
||||
;; - an identifier for a class of anniversaries (eg. birthday or
|
||||
;; wedding) from `org-bbdb-anniversary-format-alist' which then
|
||||
;; defines the format tring for this class
|
||||
;; - the (format) string displayed in the diary.
|
||||
;;
|
||||
;; It defaults to the value of `org-bbdb-default-anniversary-format'
|
||||
;; ("birthday" by default).
|
||||
;; You can enter multiple anniversaries for a single BBDB record by
|
||||
;; separating them with a newline character. At the BBDB prompt for
|
||||
;; the field value, type `C-q C-j' to enter a newline between two
|
||||
;; anniversaries.
|
||||
;;
|
||||
;; If you omit the CLASS-OR-FORMAT-STRING entirely, it defaults to the
|
||||
;; value of `org-bbdb-default-anniversary-format' ("birthday" by
|
||||
;; default).
|
||||
;;
|
||||
;; The substitutions in the format string are (in order):
|
||||
;; * the name of the record containing this anniversary
|
||||
;; * the number of years
|
||||
;; * an ordinal suffix (st, nd, rd, th) for the year
|
||||
;; - the name of the record containing this anniversary
|
||||
;; - the number of years
|
||||
;; - an ordinal suffix (st, nd, rd, th) for the year
|
||||
;;
|
||||
;; See the documentation of `org-bbdb-anniversary-format-alist' for
|
||||
;; further options.
|
||||
|
@ -94,12 +106,15 @@
|
|||
(declare-function bbdb-current-record "ext:bbdb-com"
|
||||
(&optional planning-on-modifying))
|
||||
(declare-function bbdb-name "ext:bbdb-com" (string elidep))
|
||||
(declare-function bbdb-completing-read-record "ext:bbdb-com"
|
||||
(prompt &optional omit-records))
|
||||
(declare-function bbdb-record-getprop "ext:bbdb" (record property))
|
||||
(declare-function bbdb-record-name "ext:bbdb" (record))
|
||||
(declare-function bbdb-records "ext:bbdb"
|
||||
(&optional dont-check-disk already-in-db-buffer))
|
||||
(declare-function bbdb-split "ext:bbdb" (string separators))
|
||||
(declare-function bbdb-string-trim "ext:bbdb" (string))
|
||||
|
||||
(declare-function calendar-leap-year-p "calendar" (year))
|
||||
(declare-function diary-ordinal-suffix "diary-lib" (n))
|
||||
|
||||
|
@ -326,6 +341,45 @@ This is used by Org to re-create the anniversary hash table."
|
|||
(when text
|
||||
(mapconcat 'identity text "; "))))
|
||||
|
||||
(defun org-bbdb-complete-link ()
|
||||
"Read a bbdb link with name completion."
|
||||
(require 'bbdb-com)
|
||||
(concat "bbdb:"
|
||||
(bbdb-record-name (car (bbdb-completing-read-record "Name: ")))))
|
||||
|
||||
(defun org-bbdb-anniv-export-ical ()
|
||||
"Extract anniversaries from BBDB and convert them to icalendar format."
|
||||
(require 'bbdb)
|
||||
(require 'diary-lib)
|
||||
(unless (hash-table-p org-bbdb-anniv-hash)
|
||||
(setq org-bbdb-anniv-hash
|
||||
(make-hash-table :test 'equal :size 366)))
|
||||
(when (or org-bbdb-updated-p
|
||||
(= 0 (hash-table-count org-bbdb-anniv-hash)))
|
||||
(org-bbdb-make-anniv-hash))
|
||||
(maphash 'org-bbdb-format-vevent org-bbdb-anniv-hash))
|
||||
|
||||
(defun org-bbdb-format-vevent (key recs)
|
||||
(let (rec categ)
|
||||
(while (setq rec (pop recs))
|
||||
(setq categ (or (nth 2 rec) org-bbdb-default-anniversary-format))
|
||||
(princ (format "BEGIN:VEVENT
|
||||
UID: ANNIV-%4i%02i%02i-%s
|
||||
DTSTART:%4i%02i%02i
|
||||
SUMMARY:%s
|
||||
DESCRIPTION:%s
|
||||
CATEGORIES:%s
|
||||
RRULE:FREQ=YEARLY
|
||||
END:VEVENT\n"
|
||||
(nth 0 rec) (nth 0 key) (nth 1 key)
|
||||
(mapconcat 'identity
|
||||
(org-split-string (nth 1 rec) "[^a-zA-Z0-90]+")
|
||||
"-")
|
||||
(nth 0 rec) (nth 0 key) (nth 1 key)
|
||||
(nth 1 rec)
|
||||
(concat (capitalize categ) " " (nth 1 rec))
|
||||
categ)))))
|
||||
|
||||
(provide 'org-bbdb)
|
||||
|
||||
;; arch-tag: 9e4f275d-d080-48c1-b040-62247f66b5c2
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
;; Author: Bastien Guerry <bzg at altern dot org>
|
||||
;; Carsten Dominik <carsten dot dominik at gmail dot com>
|
||||
;; Keywords: org, wp, remember
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
@ -41,22 +41,28 @@
|
|||
:tag "Org Clock"
|
||||
:group 'org-progress)
|
||||
|
||||
(defcustom org-clock-into-drawer 2
|
||||
(defcustom org-clock-into-drawer org-log-into-drawer
|
||||
"Should clocking info be wrapped into a drawer?
|
||||
When t, clocking info will always be inserted into a :CLOCK: drawer.
|
||||
When t, clocking info will always be inserted into a :LOGBOOK: drawer.
|
||||
If necessary, the drawer will be created.
|
||||
When nil, the drawer will not be created, but used when present.
|
||||
When an integer and the number of clocking entries in an item
|
||||
reaches or exceeds this number, a drawer will be created."
|
||||
reaches or exceeds this number, a drawer will be created.
|
||||
When a string, it names the drawer to be used.
|
||||
|
||||
The default for this variable is the value of `org-log-into-drawer',
|
||||
which see."
|
||||
:group 'org-todo
|
||||
:group 'org-clock
|
||||
:type '(choice
|
||||
(const :tag "Always" t)
|
||||
(const :tag "Only when drawer exists" nil)
|
||||
(integer :tag "When at least N clock entries")))
|
||||
(integer :tag "When at least N clock entries")
|
||||
(const :tag "Into LOGBOOK drawer" "LOGBOOK")
|
||||
(string :tag "Into Drawer named...")))
|
||||
|
||||
(defcustom org-clock-out-when-done t
|
||||
"When non-nil, the clock will be stopped when the relevant entry is marked DONE.
|
||||
"When non-nil, clock will be stopped when the clocked entry is marked DONE.
|
||||
A nil value means, clock will keep running until stopped explicitly with
|
||||
`C-c C-x C-o', or until the clock is started in a different item."
|
||||
:group 'org-clock
|
||||
|
@ -80,11 +86,29 @@ state to switch it to."
|
|||
(string :tag "State")
|
||||
(symbol :tag "Function")))
|
||||
|
||||
(defcustom org-clock-out-switch-to-state nil
|
||||
"Set task to a special todo state after clocking out.
|
||||
The value should be the state to which the entry should be
|
||||
switched. If the value is a function, it must take one
|
||||
parameter (the current TODO state of the item) and return the
|
||||
state to switch it to."
|
||||
:group 'org-clock
|
||||
:group 'org-todo
|
||||
:type '(choice
|
||||
(const :tag "Don't force a state" nil)
|
||||
(string :tag "State")
|
||||
(symbol :tag "Function")))
|
||||
|
||||
(defcustom org-clock-history-length 5
|
||||
"Number of clock tasks to remember in history."
|
||||
:group 'org-clock
|
||||
:type 'integer)
|
||||
|
||||
(defcustom org-clock-goto-may-find-recent-task t
|
||||
"Non-nil means, `org-clock-goto' can go to recent task if no active clock."
|
||||
:group 'org-clock
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-clock-heading-function nil
|
||||
"When non-nil, should be a function to create `org-clock-heading'.
|
||||
This is the string shown in the mode line when a clock is running.
|
||||
|
@ -93,26 +117,28 @@ The function is called with point at the beginning of the headline."
|
|||
:type 'function)
|
||||
|
||||
(defcustom org-clock-string-limit 0
|
||||
"Maximum length of clock strings in the modeline. 0 means no limit"
|
||||
"Maximum length of clock strings in the modeline. 0 means no limit."
|
||||
:group 'org-clock
|
||||
:type 'integer)
|
||||
|
||||
(defcustom org-clock-in-resume nil
|
||||
"If non-nil, when clocking into a task with a clock entry which
|
||||
has not been closed, resume the clock from that point"
|
||||
"If non-nil, resume clock when clocking into task with open clock.
|
||||
When clocking into a task with a clock entry which has not been closed,
|
||||
the clock can be resumed from that point."
|
||||
:group 'org-clock
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-clock-persist nil
|
||||
"When non-nil, save the running clock when emacs is closed, and
|
||||
resume it next time emacs is started.
|
||||
"When non-nil, save the running clock when emacs is closed.
|
||||
The clock is resumed when emacs restarts.
|
||||
When this is t, both the running clock, and the entire clock
|
||||
history are saved. When this is the symbol `clock', only the
|
||||
running clock is saved.
|
||||
|
||||
When Emacs restarts with saved clock information, the file containing the
|
||||
running clock as well as all files mentioned in the clock history will
|
||||
be visited."
|
||||
be visited.
|
||||
All this depends on running `org-clock-persistence-insinuate' in .emacs"
|
||||
:group 'org-clock
|
||||
:type '(choice
|
||||
(const :tag "Just the running clock" clock)
|
||||
|
@ -121,21 +147,75 @@ be visited."
|
|||
|
||||
(defcustom org-clock-persist-file (convert-standard-filename
|
||||
"~/.emacs.d/org-clock-save.el")
|
||||
"File to save clock data to"
|
||||
"File to save clock data to."
|
||||
:group 'org-clock
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-clock-persist-query-save nil
|
||||
"When non-nil, ask before saving the current clock on exit"
|
||||
"When non-nil, ask before saving the current clock on exit."
|
||||
:group 'org-clock
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-clock-persist-query-resume t
|
||||
"When non-nil, ask before resuming any stored clock during
|
||||
load."
|
||||
"When non-nil, ask before resuming any stored clock during load."
|
||||
:group 'org-clock
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-clock-sound nil
|
||||
"Sound that will used for notifications.
|
||||
Possible values:
|
||||
|
||||
nil no sound played.
|
||||
t standard Emacs beep
|
||||
file name play this sound file. If not possible, fall back to beep"
|
||||
:group 'org-clock
|
||||
:type '(choice
|
||||
(const :tag "No sound" nil)
|
||||
(const :tag "Standard beep" t)
|
||||
(file :tag "Play sound file")))
|
||||
|
||||
(defcustom org-clock-modeline-total 'auto
|
||||
"Default setting for the time included for the modeline clock.
|
||||
This can be overruled locally using the CLOCK_MODELINE_TOTAL property.
|
||||
Allowed values are:
|
||||
|
||||
current Only the time in the current instance of the clock
|
||||
today All time clocked inot this task today
|
||||
repeat All time clocked into this task since last repeat
|
||||
all All time ever recorded for this task
|
||||
auto Automtically, either `all', or `repeat' for repeating tasks"
|
||||
:group 'org-clock
|
||||
:type '(choice
|
||||
(const :tag "Current clock" current)
|
||||
(const :tag "Today's task time" today)
|
||||
(const :tag "Since last repeat" repeat)
|
||||
(const :tag "All task time" all)
|
||||
(const :tag "Automatically, `all' or since `repeat'" auto)))
|
||||
|
||||
(defcustom org-show-notification-handler nil
|
||||
"Function or program to send notification with.
|
||||
The function or program will be called with the notification
|
||||
string as argument."
|
||||
:group 'org-clock
|
||||
:type '(choice
|
||||
(string :tag "Program")
|
||||
(function :tag "Function")))
|
||||
|
||||
(defvar org-clock-in-prepare-hook nil
|
||||
"Hook run when preparing the clock.
|
||||
This hook is run before anything happens to the task that
|
||||
you want to clock in. For example, you can use this hook
|
||||
to add an effort property.")
|
||||
(defvar org-clock-in-hook nil
|
||||
"Hook run when starting the clock.")
|
||||
(defvar org-clock-out-hook nil
|
||||
"Hook run when stopping the current clock.")
|
||||
|
||||
(defvar org-clock-cancel-hook nil
|
||||
"Hook run when cancelling the current clock.")
|
||||
(defvar org-clock-goto-hook nil
|
||||
"Hook run when selecting the currently clocked-in entry.")
|
||||
|
||||
;;; The clock for measuring work time.
|
||||
|
||||
(defvar org-mode-line-string "")
|
||||
|
@ -146,6 +226,13 @@ load."
|
|||
(defvar org-clock-heading-for-remember "")
|
||||
(defvar org-clock-start-time "")
|
||||
|
||||
(defvar org-clock-effort ""
|
||||
"Effort estimate of the currently clocking task")
|
||||
|
||||
(defvar org-clock-total-time nil
|
||||
"Holds total time, spent previously on currently clocked item.
|
||||
This does not include the time in the currently running clock.")
|
||||
|
||||
(defvar org-clock-history nil
|
||||
"List of marker pointing to recent clocked tasks.")
|
||||
|
||||
|
@ -159,6 +246,16 @@ of a different task.")
|
|||
|
||||
(defvar org-clock-mode-line-map (make-sparse-keymap))
|
||||
(define-key org-clock-mode-line-map [mode-line mouse-2] 'org-clock-goto)
|
||||
(define-key org-clock-mode-line-map [mode-line mouse-1] 'org-clock-menu)
|
||||
|
||||
(defun org-clock-menu ()
|
||||
(interactive)
|
||||
(popup-menu
|
||||
'("Clock"
|
||||
["Clock out" org-clock-out t]
|
||||
["Change effort estimate" org-clock-modify-effort-estimate t]
|
||||
["Go to clock entry" org-clock-goto t]
|
||||
["Switch task" (lambda () (interactive) (org-clock-in '(4))) :active t :keys "C-u C-c C-x C-i"])))
|
||||
|
||||
(defun org-clock-history-push (&optional pos buffer)
|
||||
"Push a marker to the clock history."
|
||||
|
@ -226,8 +323,11 @@ of a different task.")
|
|||
(t (error "Invalid task choice %c" rpl))))))
|
||||
|
||||
(defun org-clock-insert-selection-line (i marker)
|
||||
"Insert a line for the clock selection menu.
|
||||
And return a cons cell with the selection character integer and the marker
|
||||
pointing to it."
|
||||
(when (marker-buffer marker)
|
||||
(let (file cat task)
|
||||
(let (file cat task heading prefix)
|
||||
(with-current-buffer (org-base-buffer (marker-buffer marker))
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
|
@ -237,29 +337,148 @@ of a different task.")
|
|||
cat (or (org-get-category)
|
||||
(progn (org-refresh-category-properties)
|
||||
(org-get-category)))
|
||||
task (org-get-heading 'notags)))))
|
||||
heading (org-get-heading 'notags)
|
||||
prefix (save-excursion
|
||||
(org-back-to-heading t)
|
||||
(looking-at "\\*+ ")
|
||||
(match-string 0))
|
||||
task (substring
|
||||
(org-fontify-like-in-org-mode
|
||||
(concat prefix heading)
|
||||
org-odd-levels-only)
|
||||
(length prefix))))))
|
||||
(when (and cat task)
|
||||
(insert (format "[%c] %-15s %s\n" i cat task))
|
||||
(cons i marker)))))
|
||||
|
||||
(defun org-clock-get-clock-string ()
|
||||
"Form a clock-string, that will be show in the mode line.
|
||||
If an effort estimate was defined for 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))))
|
||||
(if (and org-clock-effort)
|
||||
(let* ((effort-in-minutes (org-hh:mm-string-to-minutes org-clock-effort))
|
||||
(effort-h (floor effort-in-minutes 60))
|
||||
(effort-m (- effort-in-minutes (* effort-h 60))))
|
||||
(format (concat "-[" org-time-clocksum-format "/" org-time-clocksum-format " (%s)]")
|
||||
h m effort-h effort-m org-clock-heading))
|
||||
(format (concat "-[" org-time-clocksum-format " (%s)]")
|
||||
h m org-clock-heading))))
|
||||
|
||||
(defun org-clock-update-mode-line ()
|
||||
(let* ((delta (- (time-to-seconds (current-time))
|
||||
(time-to-seconds org-clock-start-time)))
|
||||
(h (floor delta 3600))
|
||||
(m (floor (- delta (* 3600 h)) 60)))
|
||||
(setq org-mode-line-string
|
||||
(org-propertize
|
||||
(let ((clock-string (format (concat "-[" org-time-clocksum-format " (%s)]")
|
||||
h m org-clock-heading))
|
||||
(help-text "Org-mode clock is running. Mouse-2 to go there."))
|
||||
(if (and (> org-clock-string-limit 0)
|
||||
(> (length clock-string) org-clock-string-limit))
|
||||
(org-propertize (substring clock-string 0 org-clock-string-limit)
|
||||
'help-echo (concat help-text ": " org-clock-heading))
|
||||
(org-propertize clock-string 'help-echo help-text)))
|
||||
'local-map org-clock-mode-line-map
|
||||
'mouse-face (if (featurep 'xemacs) 'highlight 'mode-line-highlight)))
|
||||
(force-mode-line-update)))
|
||||
(setq org-mode-line-string
|
||||
(org-propertize
|
||||
(let ((clock-string (org-clock-get-clock-string))
|
||||
(help-text "Org-mode clock is running.\nmouse-1 shows a menu\nmouse-2 will jump to task"))
|
||||
(if (and (> org-clock-string-limit 0)
|
||||
(> (length clock-string) org-clock-string-limit))
|
||||
(org-propertize (substring clock-string 0 org-clock-string-limit)
|
||||
'help-echo (concat help-text ": " org-clock-heading))
|
||||
(org-propertize clock-string 'help-echo help-text)))
|
||||
'local-map org-clock-mode-line-map
|
||||
'mouse-face (if (featurep 'xemacs) 'highlight 'mode-line-highlight)
|
||||
'face 'org-mode-line-clock))
|
||||
(if org-clock-effort (org-clock-notify-once-if-expired))
|
||||
(force-mode-line-update))
|
||||
|
||||
(defun org-clock-get-clocked-time ()
|
||||
"Get the clocked time for the current item in minutes.
|
||||
The time returned includes the the time spent on this task in
|
||||
previous clocking intervals."
|
||||
(let ((currently-clocked-time
|
||||
(floor (- (time-to-seconds (current-time))
|
||||
(time-to-seconds org-clock-start-time)) 60)))
|
||||
(+ currently-clocked-time (or org-clock-total-time 0))))
|
||||
|
||||
(defun org-clock-modify-effort-estimate (&optional value)
|
||||
"Add to or set the effort estimate of the item currently being clocked.
|
||||
VALUE can be a number of minutes, or a string with forat hh:mm or mm.
|
||||
WHen the strig 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."
|
||||
(interactive)
|
||||
(when (org-clock-is-active)
|
||||
(let ((current org-clock-effort) sign)
|
||||
(unless value
|
||||
;; Prompt user for a value or a change
|
||||
(setq value
|
||||
(read-string
|
||||
(format "Set effort (hh:mm or mm%s): "
|
||||
(if current
|
||||
(format ", prefix + to add to %s" org-clock-effort)
|
||||
"")))))
|
||||
(when (stringp value)
|
||||
;; A string. See if it is a delta
|
||||
(setq sign (string-to-char value))
|
||||
(if (member sign '(?- ?+))
|
||||
(setq current (org-hh:mm-string-to-minutes (substring current 1)))
|
||||
(setq current 0))
|
||||
(setq value (org-hh:mm-string-to-minutes value))
|
||||
(if (equal ?- sign)
|
||||
(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-entry-put org-clock-marker "Effort" org-clock-effort)
|
||||
(org-clock-update-mode-line))))
|
||||
|
||||
(defvar org-clock-notification-was-shown nil
|
||||
"Shows if we have shown notification already.")
|
||||
|
||||
(defun org-clock-notify-once-if-expired ()
|
||||
"Show notification if we spent more time than we estimated before.
|
||||
Notification is shown only once."
|
||||
(when (marker-buffer org-clock-marker)
|
||||
(let ((effort-in-minutes (org-hh:mm-string-to-minutes org-clock-effort))
|
||||
(clocked-time (org-clock-get-clocked-time)))
|
||||
(if (>= clocked-time effort-in-minutes)
|
||||
(unless org-clock-notification-was-shown
|
||||
(setq org-clock-notification-was-shown t)
|
||||
(org-clock-play-sound)
|
||||
(org-show-notification
|
||||
(format "Task '%s' should be finished by now. (%s)"
|
||||
org-clock-heading org-clock-effort)))
|
||||
(setq org-clock-notification-was-shown nil)))))
|
||||
|
||||
(defun org-show-notification (notification)
|
||||
"Show notification.
|
||||
Use `org-show-notification-handler' if defined,
|
||||
use libnotify if available, or fall back on a message."
|
||||
(cond ((functionp org-show-notification-handler)
|
||||
(funcall org-show-notification-handler notification))
|
||||
((stringp org-show-notification-handler)
|
||||
(start-process "emacs-timer-notification" nil
|
||||
org-show-notification-handler notification))
|
||||
((org-program-exists "notify-send")
|
||||
(start-process "emacs-timer-notification" nil
|
||||
"notify-send" notification))
|
||||
;; Maybe the handler will send a message, so only use message as
|
||||
;; a fall back option
|
||||
(t (message notification))))
|
||||
|
||||
(defun org-clock-play-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)
|
||||
(if (file-exists-p org-clock-sound)
|
||||
(if (org-program-exists "aplay")
|
||||
(start-process "org-clock-play-notification" nil
|
||||
"aplay" org-clock-sound)
|
||||
(condition-case nil
|
||||
(play-sound-file org-clock-sound)
|
||||
(error (beep t) (beep t))))))))
|
||||
|
||||
(defun org-program-exists (program-name)
|
||||
"Checks whenever we can locate program and launch it."
|
||||
(if (eq system-type 'gnu/linux)
|
||||
(= 0 (call-process "which" nil nil nil program-name))))
|
||||
|
||||
(defvar org-clock-mode-line-entry nil
|
||||
"Information for the modeline about the running clock.")
|
||||
|
@ -272,9 +491,10 @@ clock into. When SELECT is `C-u C-u', clock into the current task and mark
|
|||
is as the default task, a special task that will always be offered in
|
||||
the clocking selection, associated with the letter `d'."
|
||||
(interactive "P")
|
||||
(setq org-clock-notification-was-shown nil)
|
||||
(catch 'abort
|
||||
(let ((interrupting (marker-buffer org-clock-marker))
|
||||
ts selected-task target-pos)
|
||||
ts selected-task target-pos (msg-extra ""))
|
||||
(when (equal select '(4))
|
||||
(setq selected-task (org-clock-select-task "Clock-in on task: "))
|
||||
(if selected-task
|
||||
|
@ -290,11 +510,10 @@ the clocking selection, associated with the letter `d'."
|
|||
|
||||
(when (equal select '(16))
|
||||
;; Mark as default clocking task
|
||||
(save-excursion
|
||||
(org-back-to-heading t)
|
||||
(move-marker org-clock-default-task (point))))
|
||||
(org-clock-mark-default-task))
|
||||
|
||||
(setq target-pos (point)) ;; we want to clock in at this location
|
||||
(run-hooks 'org-clock-in-prepare-hook)
|
||||
(save-excursion
|
||||
(when (and selected-task (marker-buffer selected-task))
|
||||
;; There is a selected task, move to the correct buffer
|
||||
|
@ -333,19 +552,22 @@ the clocking selection, associated with the letter `d'."
|
|||
(t "???")))
|
||||
(setq org-clock-heading (org-propertize org-clock-heading
|
||||
'face nil))
|
||||
(org-clock-find-position)
|
||||
(org-clock-find-position org-clock-in-resume)
|
||||
(cond
|
||||
((and org-clock-in-resume
|
||||
(looking-at
|
||||
(concat "^[ \\t]* " org-clock-string
|
||||
(concat "^[ \t]* " org-clock-string
|
||||
" \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}"
|
||||
" +\\sw+ +[012][0-9]:[0-5][0-9]\\)\\][ \t]*$")))
|
||||
" +\\sw+\.? +[012][0-9]:[0-5][0-9]\\)\\][ \t]*$")))
|
||||
(message "Matched %s" (match-string 1))
|
||||
(setq ts (concat "[" (match-string 1) "]"))
|
||||
(goto-char (match-end 1))
|
||||
(setq org-clock-start-time
|
||||
(apply 'encode-time
|
||||
(org-parse-time-string (match-string 1)))))
|
||||
(org-parse-time-string (match-string 1))))
|
||||
(setq org-clock-effort (org-get-effort))
|
||||
(setq org-clock-total-time (org-clock-sum-current-item
|
||||
(org-clock-get-sum-start))))
|
||||
((eq org-clock-in-resume 'auto-restart)
|
||||
;; called from org-clock-load during startup,
|
||||
;; do not interrupt, but warn!
|
||||
|
@ -354,11 +576,21 @@ the clocking selection, associated with the letter `d'."
|
|||
(sit-for 2)
|
||||
(throw 'abort nil))
|
||||
(t
|
||||
(insert "\n") (backward-char 1)
|
||||
(insert-before-markers "\n")
|
||||
(backward-char 1)
|
||||
(org-indent-line-function)
|
||||
(when (and (save-excursion
|
||||
(end-of-line 0)
|
||||
(org-in-item-p)))
|
||||
(beginning-of-line 1)
|
||||
(org-indent-line-to (- (org-get-indentation) 2)))
|
||||
(insert org-clock-string " ")
|
||||
(setq org-clock-effort (org-get-effort))
|
||||
(setq org-clock-total-time (org-clock-sum-current-item
|
||||
(org-clock-get-sum-start)))
|
||||
(setq org-clock-start-time (current-time))
|
||||
(setq ts (org-insert-time-stamp org-clock-start-time 'with-hm 'inactive))))
|
||||
(setq ts (org-insert-time-stamp org-clock-start-time
|
||||
'with-hm 'inactive))))
|
||||
(move-marker org-clock-marker (point) (buffer-base-buffer))
|
||||
(or global-mode-string (setq global-mode-string '("")))
|
||||
(or (memq 'org-mode-line-string global-mode-string)
|
||||
|
@ -367,10 +599,56 @@ the clocking selection, associated with the letter `d'."
|
|||
(org-clock-update-mode-line)
|
||||
(setq org-clock-mode-line-timer
|
||||
(run-with-timer 60 60 'org-clock-update-mode-line))
|
||||
(message "Clock started at %s" ts)))))))
|
||||
(message "Clock starts at %s - %s" ts msg-extra)
|
||||
(run-hooks 'org-clock-in-hook)))))))
|
||||
|
||||
(defun org-clock-find-position ()
|
||||
"Find the location where the next clock line should be inserted."
|
||||
(defun org-clock-mark-default-task ()
|
||||
"Mark current task as default task."
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(org-back-to-heading t)
|
||||
(move-marker org-clock-default-task (point))))
|
||||
|
||||
(defvar msg-extra)
|
||||
(defun org-clock-get-sum-start ()
|
||||
"Return the time from which clock times should be counted.
|
||||
This is for the currently running clock as it is displayed
|
||||
in the mode line. This function looks at the properties
|
||||
LAST_REPEAT and in particular CLOCK_MODELINE_TOTAL and the
|
||||
corresponding variable `org-clock-modeline-total' and then
|
||||
decides which time to use."
|
||||
(let ((cmt (or (org-entry-get nil "CLOCK_MODELINE_TOTAL")
|
||||
(symbol-name org-clock-modeline-total)))
|
||||
(lr (org-entry-get nil "LAST_REPEAT")))
|
||||
(cond
|
||||
((equal cmt "current")
|
||||
(setq msg-extra "showing time in current clock instance")
|
||||
(current-time))
|
||||
((equal cmt "today")
|
||||
(setq msg-extra "showing today's task time.")
|
||||
(let* ((dt (decode-time (current-time))))
|
||||
(setq dt (append (list 0 0 0) (nthcdr 3 dt)))
|
||||
(if org-extend-today-until
|
||||
(setf (nth 2 dt) org-extend-today-until))
|
||||
(apply 'encode-time dt)))
|
||||
((or (equal cmt "all")
|
||||
(and (or (not cmt) (equal cmt "auto"))
|
||||
(not lr)))
|
||||
(setq msg-extra "showing entire task time.")
|
||||
nil)
|
||||
((or (equal cmt "repeat")
|
||||
(and (or (not cmt) (equal cmt "auto"))
|
||||
lr))
|
||||
(setq msg-extra "showing task time since last repeat.")
|
||||
(if (not lr)
|
||||
nil
|
||||
(org-time-string-to-time lr)))
|
||||
(t nil))))
|
||||
|
||||
(defun org-clock-find-position (find-unclosed)
|
||||
"Find the location where the next clock line should be inserted.
|
||||
When FIND-UNCLOSED is non-nil, first check if there is an unclosed clock
|
||||
line and position cursor in that line."
|
||||
(org-back-to-heading t)
|
||||
(catch 'exit
|
||||
(let ((beg (save-excursion
|
||||
|
@ -380,12 +658,25 @@ the clocking selection, associated with the letter `d'."
|
|||
(end (progn (outline-next-heading) (point)))
|
||||
(re (concat "^[ \t]*" org-clock-string))
|
||||
(cnt 0)
|
||||
first last)
|
||||
(drawer (if (stringp org-clock-into-drawer)
|
||||
org-clock-into-drawer "LOGBOOK"))
|
||||
first last ind-last)
|
||||
(goto-char beg)
|
||||
(when (and find-unclosed
|
||||
(re-search-forward
|
||||
(concat "^[ \t]* " org-clock-string
|
||||
" \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}"
|
||||
" +\\sw+ +[012][0-9]:[0-5][0-9]\\)\\][ \t]*$")
|
||||
end t))
|
||||
(beginning-of-line 1)
|
||||
(throw 'exit t))
|
||||
(when (eobp) (newline) (setq end (max (point) end)))
|
||||
(when (re-search-forward "^[ \t]*:CLOCK:" end t)
|
||||
(when (re-search-forward (concat "^[ \t]*:" drawer ":") end t)
|
||||
;; we seem to have a CLOCK drawer, so go there.
|
||||
(beginning-of-line 2)
|
||||
(or org-log-states-order-reversed
|
||||
(and (re-search-forward org-property-end-re nil t)
|
||||
(goto-char (match-beginning 0))))
|
||||
(throw 'exit t))
|
||||
;; Lets count the CLOCK lines
|
||||
(goto-char beg)
|
||||
|
@ -394,20 +685,27 @@ the clocking selection, associated with the letter `d'."
|
|||
last (match-beginning 0)
|
||||
cnt (1+ cnt)))
|
||||
(when (and (integerp org-clock-into-drawer)
|
||||
last
|
||||
(>= (1+ cnt) org-clock-into-drawer))
|
||||
;; Wrap current entries into a new drawer
|
||||
(goto-char last)
|
||||
(setq ind-last (org-get-indentation))
|
||||
(beginning-of-line 2)
|
||||
(if (org-at-item-p) (org-end-of-item))
|
||||
(if (and (>= (org-get-indentation) ind-last)
|
||||
(org-at-item-p))
|
||||
(org-end-of-item))
|
||||
(insert ":END:\n")
|
||||
(beginning-of-line 0)
|
||||
(org-indent-line-function)
|
||||
(org-indent-line-to ind-last)
|
||||
(goto-char first)
|
||||
(insert ":CLOCK:\n")
|
||||
(insert ":" drawer ":\n")
|
||||
(beginning-of-line 0)
|
||||
(org-indent-line-function)
|
||||
(org-flag-drawer t)
|
||||
(beginning-of-line 2)
|
||||
(or org-log-states-order-reversed
|
||||
(and (re-search-forward org-property-end-re nil t)
|
||||
(goto-char (match-beginning 0))))
|
||||
(throw 'exit nil))
|
||||
|
||||
(goto-char beg)
|
||||
|
@ -416,62 +714,84 @@ the clocking selection, associated with the letter `d'."
|
|||
;; Planning info, skip to after it
|
||||
(beginning-of-line 2)
|
||||
(or (bolp) (newline)))
|
||||
(when (eq t org-clock-into-drawer)
|
||||
(insert ":CLOCK:\n:END:\n")
|
||||
(beginning-of-line 0)
|
||||
(when (or (eq org-clock-into-drawer t)
|
||||
(stringp org-clock-into-drawer)
|
||||
(and (integerp org-clock-into-drawer)
|
||||
(< org-clock-into-drawer 2)))
|
||||
(insert ":" drawer ":\n:END:\n")
|
||||
(beginning-of-line -1)
|
||||
(org-indent-line-function)
|
||||
(beginning-of-line 0)
|
||||
(org-flag-drawer t)
|
||||
(beginning-of-line 2)
|
||||
(org-indent-line-function)
|
||||
(beginning-of-line 2)))))
|
||||
(beginning-of-line)
|
||||
(or org-log-states-order-reversed
|
||||
(and (re-search-forward org-property-end-re nil t)
|
||||
(goto-char (match-beginning 0))))))))
|
||||
|
||||
(defun org-clock-out (&optional fail-quietly)
|
||||
"Stop the currently running clock.
|
||||
If there is no running clock, throw an error, unless FAIL-QUIETLY is set."
|
||||
(interactive)
|
||||
(catch 'exit
|
||||
(if (not (marker-buffer org-clock-marker))
|
||||
(if fail-quietly (throw 'exit t) (error "No active clock")))
|
||||
(let (ts te s h m remove)
|
||||
(save-excursion
|
||||
(set-buffer (marker-buffer org-clock-marker))
|
||||
(save-restriction
|
||||
(widen)
|
||||
(goto-char org-clock-marker)
|
||||
(beginning-of-line 1)
|
||||
(if (and (looking-at (concat "[ \t]*" org-keyword-time-regexp))
|
||||
(equal (match-string 1) org-clock-string))
|
||||
(setq ts (match-string 2))
|
||||
(if fail-quietly (throw 'exit nil) (error "Clock start time is gone")))
|
||||
(goto-char (match-end 0))
|
||||
(delete-region (point) (point-at-eol))
|
||||
(insert "--")
|
||||
(setq te (org-insert-time-stamp (current-time) 'with-hm 'inactive))
|
||||
(setq s (- (time-to-seconds (apply 'encode-time (org-parse-time-string te)))
|
||||
(time-to-seconds (apply 'encode-time (org-parse-time-string ts))))
|
||||
h (floor (/ s 3600))
|
||||
s (- s (* 3600 h))
|
||||
m (floor (/ s 60))
|
||||
s (- s (* 60 s)))
|
||||
(insert " => " (format "%2d:%02d" h m))
|
||||
(when (setq remove (and org-clock-out-remove-zero-time-clocks
|
||||
(= (+ h m) 0)))
|
||||
(if (not (marker-buffer org-clock-marker))
|
||||
(if fail-quietly (throw 'exit t) (error "No active clock")))
|
||||
(let (ts te s h m remove)
|
||||
(save-excursion
|
||||
(set-buffer (marker-buffer org-clock-marker))
|
||||
(save-restriction
|
||||
(widen)
|
||||
(goto-char org-clock-marker)
|
||||
(beginning-of-line 1)
|
||||
(if (and (looking-at (concat "[ \t]*" org-keyword-time-regexp))
|
||||
(equal (match-string 1) org-clock-string))
|
||||
(setq ts (match-string 2))
|
||||
(if fail-quietly (throw 'exit nil) (error "Clock start time is gone")))
|
||||
(goto-char (match-end 0))
|
||||
(delete-region (point) (point-at-eol))
|
||||
(and (looking-at "\n") (> (point-max) (1+ (point)))
|
||||
(delete-char 1)))
|
||||
(move-marker org-clock-marker nil)
|
||||
(when org-log-note-clock-out
|
||||
(org-add-log-setup 'clock-out nil nil nil
|
||||
(concat "# Task: " (org-get-heading t) "\n\n")))
|
||||
(when org-clock-mode-line-timer
|
||||
(cancel-timer org-clock-mode-line-timer)
|
||||
(setq org-clock-mode-line-timer nil))
|
||||
(setq global-mode-string
|
||||
(delq 'org-mode-line-string global-mode-string))
|
||||
(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" "")))))))
|
||||
(insert "--")
|
||||
(setq te (org-insert-time-stamp (current-time) 'with-hm 'inactive))
|
||||
(setq s (- (time-to-seconds (apply 'encode-time (org-parse-time-string te)))
|
||||
(time-to-seconds (apply 'encode-time (org-parse-time-string ts))))
|
||||
h (floor (/ s 3600))
|
||||
s (- s (* 3600 h))
|
||||
m (floor (/ s 60))
|
||||
s (- s (* 60 s)))
|
||||
(insert " => " (format "%2d:%02d" h m))
|
||||
(when (setq remove (and org-clock-out-remove-zero-time-clocks
|
||||
(= (+ h m) 0)))
|
||||
(beginning-of-line 1)
|
||||
(delete-region (point) (point-at-eol))
|
||||
(and (looking-at "\n") (> (point-max) (1+ (point)))
|
||||
(delete-char 1)))
|
||||
(move-marker org-clock-marker nil)
|
||||
(when org-log-note-clock-out
|
||||
(org-add-log-setup 'clock-out nil nil nil nil
|
||||
(concat "# Task: " (org-get-heading t) "\n\n")))
|
||||
(when org-clock-mode-line-timer
|
||||
(cancel-timer org-clock-mode-line-timer)
|
||||
(setq org-clock-mode-line-timer nil))
|
||||
(setq global-mode-string
|
||||
(delq 'org-mode-line-string global-mode-string))
|
||||
(when org-clock-out-switch-to-state
|
||||
(save-excursion
|
||||
(org-back-to-heading t)
|
||||
(let ((org-inhibit-logging t))
|
||||
(cond
|
||||
((functionp org-clock-out-switch-to-state)
|
||||
(looking-at org-complex-heading-regexp)
|
||||
(let ((newstate (funcall org-clock-out-switch-to-state
|
||||
(match-string 2))))
|
||||
(if newstate (org-todo newstate))))
|
||||
((and org-clock-out-switch-to-state
|
||||
(not (looking-at (concat outline-regexp "[ \t]*"
|
||||
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))))))
|
||||
|
||||
(defun org-clock-cancel ()
|
||||
"Cancel the running clock be removing the start timestamp."
|
||||
|
@ -485,34 +805,44 @@ If there is no running clock, throw an error, unless FAIL-QUIETLY is set."
|
|||
(setq global-mode-string
|
||||
(delq 'org-mode-line-string global-mode-string))
|
||||
(force-mode-line-update)
|
||||
(message "Clock canceled"))
|
||||
(message "Clock canceled")
|
||||
(run-hooks 'org-clock-cancel-hook))
|
||||
|
||||
(defun org-clock-goto (&optional select)
|
||||
"Go to the currently clocked-in entry.
|
||||
With prefix arg SELECT, offer recently clocked tasks."
|
||||
(interactive "P")
|
||||
(let ((m (if select
|
||||
(org-clock-select-task "Select task to go to: ")
|
||||
org-clock-marker)))
|
||||
(if (not (marker-buffer m))
|
||||
(if select
|
||||
(error "No task selected")
|
||||
(error "No active clock")))
|
||||
"Go to the currently clocked-in entry, or to the most recently clocked one.
|
||||
With prefix arg SELECT, offer recently clocked tasks for selection."
|
||||
(interactive "@P")
|
||||
(let* ((recent nil)
|
||||
(m (cond
|
||||
(select
|
||||
(or (org-clock-select-task "Select task to go to: ")
|
||||
(error "No task selected")))
|
||||
((marker-buffer org-clock-marker) org-clock-marker)
|
||||
((and org-clock-goto-may-find-recent-task
|
||||
(car org-clock-history)
|
||||
(marker-buffer (car org-clock-history)))
|
||||
(setq recent t)
|
||||
(car org-clock-history))
|
||||
(t (error "No active or recent clock task")))))
|
||||
(switch-to-buffer (marker-buffer m))
|
||||
(if (or (< m (point-min)) (> m (point-max))) (widen))
|
||||
(goto-char m)
|
||||
(org-show-entry)
|
||||
(org-back-to-heading)
|
||||
(org-back-to-heading t)
|
||||
(org-cycle-hide-drawers 'children)
|
||||
(recenter)))
|
||||
(recenter)
|
||||
(if recent
|
||||
(message "No running clock, this is the most recently clocked task"))
|
||||
(run-hooks 'org-clock-goto-hook)))
|
||||
|
||||
(defvar org-clock-file-total-minutes nil
|
||||
"Holds the file total time in minutes, after a call to `org-clock-sum'.")
|
||||
(make-variable-buffer-local 'org-clock-file-total-minutes)
|
||||
(make-variable-buffer-local 'org-clock-file-total-minutes)
|
||||
|
||||
(defun org-clock-sum (&optional tstart tend)
|
||||
"Sum the times for each subtree.
|
||||
Puts the resulting times in minutes as a text property on each headline."
|
||||
Puts the resulting times in minutes as a text property on each headline.
|
||||
TSTART and TEND can mark a time range to be considered."
|
||||
(interactive)
|
||||
(let* ((bmp (buffer-modified-p))
|
||||
(re (concat "^\\(\\*+\\)[ \t]\\|^[ \t]*"
|
||||
|
@ -524,6 +854,10 @@ Puts the resulting times in minutes as a text property on each headline."
|
|||
(level 0)
|
||||
ts te dt
|
||||
time)
|
||||
(if (stringp tstart) (setq tstart (org-time-string-to-seconds tstart)))
|
||||
(if (stringp tend) (setq tend (org-time-string-to-seconds tend)))
|
||||
(if (consp tstart) (setq tstart (time-to-seconds tstart)))
|
||||
(if (consp tend) (setq tend (time-to-seconds tend)))
|
||||
(remove-text-properties (point-min) (point-max) '(:org-clock-minutes t))
|
||||
(save-excursion
|
||||
(goto-char (point-max))
|
||||
|
@ -558,6 +892,14 @@ Puts the resulting times in minutes as a text property on each headline."
|
|||
(setq org-clock-file-total-minutes (aref ltimes 0)))
|
||||
(set-buffer-modified-p bmp)))
|
||||
|
||||
(defun org-clock-sum-current-item (&optional tstart)
|
||||
"Returns time, clocked on current item in total"
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(org-narrow-to-subtree)
|
||||
(org-clock-sum tstart)
|
||||
org-clock-file-total-minutes)))
|
||||
|
||||
(defun org-clock-display (&optional total-only)
|
||||
"Show subtree times in the entire buffer.
|
||||
If TOTAL-ONLY is non-nil, only show the total time for the entire file
|
||||
|
@ -633,7 +975,10 @@ This is used to stop the clock after a TODO entry is marked DONE,
|
|||
and is only done if the variable `org-clock-out-when-done' is not nil."
|
||||
(when (and org-clock-out-when-done
|
||||
(member state org-done-keywords)
|
||||
(equal (marker-buffer org-clock-marker) (current-buffer))
|
||||
(equal (or (buffer-base-buffer (marker-buffer org-clock-marker))
|
||||
(marker-buffer org-clock-marker))
|
||||
(or (buffer-base-buffer (current-buffer))
|
||||
(current-buffer)))
|
||||
(< (point) org-clock-marker)
|
||||
(> (save-excursion (outline-next-heading) (point))
|
||||
org-clock-marker))
|
||||
|
@ -801,7 +1146,7 @@ the currently selected interval size."
|
|||
((string-match "\\([0-9]+\\)\\(-\\([wW]?\\)\\([0-9]\\{1,2\\}\\)\\(-\\([0-9]\\{1,2\\}\\)\\)?\\)?" s)
|
||||
;; 1 1 2 3 3 4 4 5 6 6 5 2
|
||||
(setq y (string-to-number (match-string 1 s))
|
||||
wp (and (match-end 3) (match-string 3 s))
|
||||
wp (and (match-end 3) (match-string 3 s))
|
||||
mw (and (match-end 4) (string-to-number (match-string 4 s)))
|
||||
d (and (match-end 6) (string-to-number (match-string 6 s))))
|
||||
(cond
|
||||
|
@ -842,11 +1187,12 @@ the currently selected interval size."
|
|||
(maxlevel (or (plist-get params :maxlevel) 3))
|
||||
(step (plist-get params :step))
|
||||
(emph (plist-get params :emphasize))
|
||||
(timestamp (plist-get params :timestamp))
|
||||
(ts (plist-get params :tstart))
|
||||
(te (plist-get params :tend))
|
||||
(block (plist-get params :block))
|
||||
(link (plist-get params :link))
|
||||
ipos time p level hlc hdl content recalc formula pcol
|
||||
ipos time p level hlc hdl tsp props content recalc formula pcol
|
||||
cc beg end pos tbl tbl1 range-text rm-file-column scope-is-list st)
|
||||
(setq org-clock-file-total-minutes nil)
|
||||
(when step
|
||||
|
@ -951,10 +1297,18 @@ the currently selected interval size."
|
|||
(save-match-data
|
||||
(org-make-org-heading-search-string
|
||||
(match-string 2))))
|
||||
(match-string 2))))
|
||||
(match-string 2)))
|
||||
tsp (when timestamp
|
||||
(setq props (org-entry-properties (point)))
|
||||
(or (cdr (assoc "SCHEDULED" props))
|
||||
(cdr (assoc "TIMESTAMP" props))
|
||||
(cdr (assoc "DEADLINE" props))
|
||||
(cdr (assoc "TIMESTAMP_IA" props)))))
|
||||
(if (and (not multifile) (= level 1)) (push "|-" tbl))
|
||||
(push (concat
|
||||
"| " (int-to-string level) "|" hlc hdl hlc " |"
|
||||
"| " (int-to-string level) "|"
|
||||
(if timestamp (concat tsp "|") "")
|
||||
hlc hdl hlc " |"
|
||||
(make-string (1- level) ?|)
|
||||
hlc (org-minutes-to-hh:mm-string time) hlc
|
||||
" |") tbl))))))
|
||||
|
@ -973,12 +1327,12 @@ the currently selected interval size."
|
|||
(if block (concat ", for " range-text ".") "")
|
||||
"\n\n"))
|
||||
(if scope-is-list "|File" "")
|
||||
"|L|Headline|Time|\n")
|
||||
"|L|" (if timestamp "Timestamp|" "") "Headline|Time|\n")
|
||||
(setq total-time (or total-time org-clock-file-total-minutes))
|
||||
(insert-before-markers
|
||||
"|-\n|"
|
||||
(if scope-is-list "|" "")
|
||||
"|"
|
||||
(if timestamp "|Timestamp|" "|")
|
||||
"*Total time*| *"
|
||||
(org-minutes-to-hh:mm-string (or total-time 0))
|
||||
"*|\n|-\n")
|
||||
|
@ -1009,7 +1363,7 @@ the currently selected interval size."
|
|||
(t (error "invalid formula in clocktable")))
|
||||
;; Should we rescue an old formula?
|
||||
(when (stringp (setq content (plist-get params :content)))
|
||||
(when (string-match "^\\(#\\+TBLFM:.*\\)" content)
|
||||
(when (string-match "^\\([ \t]*#\\+TBLFM:.*\\)" content)
|
||||
(setq recalc t)
|
||||
(insert "\n" (match-string 1 (plist-get params :content)))
|
||||
(beginning-of-line 0))))
|
||||
|
@ -1046,10 +1400,10 @@ the currently selected interval size."
|
|||
(while (< ts te)
|
||||
(or (bolp) (insert "\n"))
|
||||
(setq p1 (plist-put p1 :tstart (format-time-string
|
||||
(car org-time-stamp-formats)
|
||||
(org-time-stamp-format nil t)
|
||||
(seconds-to-time ts))))
|
||||
(setq p1 (plist-put p1 :tend (format-time-string
|
||||
(car org-time-stamp-formats)
|
||||
(org-time-stamp-format nil t)
|
||||
(seconds-to-time (setq ts (+ ts step))))))
|
||||
(insert "\n" (if (eq step0 'day) "Daily report: " "Weekly report starting on: ")
|
||||
(plist-get p1 :tstart) "\n")
|
||||
|
@ -1139,8 +1493,7 @@ The details of what will be saved are regulated by the variable
|
|||
"Was the clock file loaded?")
|
||||
|
||||
(defun org-clock-load ()
|
||||
"Load various clock-related data from disk, optionally resuming
|
||||
a stored clock"
|
||||
"Load clock-related data from disk, maybe resuming a stored clock."
|
||||
(when (and org-clock-persist (not org-clock-loaded))
|
||||
(let ((filename (expand-file-name org-clock-persist-file))
|
||||
(org-clock-in-resume 'auto-restart)
|
||||
|
@ -1186,6 +1539,9 @@ a stored clock"
|
|||
(add-hook 'org-mode-hook 'org-clock-load)
|
||||
(add-hook 'kill-emacs-hook 'org-clock-save))
|
||||
|
||||
;; Suggested bindings
|
||||
(org-defkey org-mode-map "\C-c\C-x\C-e" 'org-clock-modify-effort-estimate)
|
||||
|
||||
(provide 'org-clock)
|
||||
|
||||
;; arch-tag: 7b42c5d4-9b36-48be-97c0-66a869daed4c
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
@ -81,8 +81,24 @@ This is the compiled version of the format.")
|
|||
(org-defkey org-columns-map "\M-b" 'backward-char)
|
||||
(org-defkey org-columns-map "a" 'org-columns-edit-allowed)
|
||||
(org-defkey org-columns-map "s" 'org-columns-edit-attributes)
|
||||
(org-defkey org-columns-map "\M-f" (lambda () (interactive) (goto-char (1+ (point)))))
|
||||
(org-defkey org-columns-map [right] (lambda () (interactive) (goto-char (1+ (point)))))
|
||||
(org-defkey org-columns-map "\M-f"
|
||||
(lambda () (interactive) (goto-char (1+ (point)))))
|
||||
(org-defkey org-columns-map [right]
|
||||
(lambda () (interactive) (goto-char (1+ (point)))))
|
||||
(org-defkey org-columns-map [down]
|
||||
(lambda () (interactive)
|
||||
(let ((col (current-column)))
|
||||
(beginning-of-line 2)
|
||||
(while (and (org-invisible-p2) (not (eobp)))
|
||||
(beginning-of-line 2))
|
||||
(move-to-column col))))
|
||||
(org-defkey org-columns-map [up]
|
||||
(lambda () (interactive)
|
||||
(let ((col (current-column)))
|
||||
(beginning-of-line 0)
|
||||
(while (and (org-invisible-p2) (not (bobp)))
|
||||
(beginning-of-line 0))
|
||||
(move-to-column col))))
|
||||
(org-defkey org-columns-map [(shift right)] 'org-columns-next-allowed-value)
|
||||
(org-defkey org-columns-map "n" 'org-columns-next-allowed-value)
|
||||
(org-defkey org-columns-map [(shift left)] 'org-columns-previous-allowed-value)
|
||||
|
@ -279,6 +295,9 @@ for the duration of the command.")
|
|||
org-columns-previous-hscroll (window-hscroll))
|
||||
(force-mode-line-update)))
|
||||
|
||||
(defvar org-colview-initial-truncate-line-value nil
|
||||
"Remember the value of `truncate-lines' across colview.")
|
||||
|
||||
(defun org-columns-remove-overlays ()
|
||||
"Remove all currently active column overlays."
|
||||
(interactive)
|
||||
|
@ -296,7 +315,9 @@ for the duration of the command.")
|
|||
(let ((inhibit-read-only t))
|
||||
(remove-text-properties (point-min) (point-max) '(read-only t))))
|
||||
(when org-columns-flyspell-was-active
|
||||
(flyspell-mode 1)))))
|
||||
(flyspell-mode 1))
|
||||
(when (local-variable-p 'org-colview-initial-truncate-line-value)
|
||||
(setq truncate-lines org-colview-initial-truncate-line-value)))))
|
||||
|
||||
(defun org-columns-cleanup-item (item fmt)
|
||||
"Remove from ITEM what is a column in the format FMT."
|
||||
|
@ -404,8 +425,9 @@ Where possible, use the standard interface for changing this line."
|
|||
(setq eval '(org-with-point-at pom
|
||||
(org-edit-headline))))
|
||||
((equal key "TODO")
|
||||
(setq eval '(org-with-point-at pom
|
||||
(call-interactively 'org-todo))))
|
||||
(setq eval '(org-with-point-at
|
||||
pom
|
||||
(call-interactively 'org-todo))))
|
||||
((equal key "PRIORITY")
|
||||
(setq eval '(org-with-point-at pom
|
||||
(call-interactively 'org-priority))))
|
||||
|
@ -656,7 +678,10 @@ around it."
|
|||
(narrow-to-region beg end)
|
||||
(org-clock-sum))))
|
||||
(while (re-search-forward (concat "^" outline-regexp) end t)
|
||||
(push (cons (org-current-line) (org-entry-properties)) cache))
|
||||
(if (and org-columns-skip-arrchived-trees
|
||||
(looking-at (concat ".*:" org-archive-tag ":")))
|
||||
(org-end-of-subtree t)
|
||||
(push (cons (org-current-line) (org-entry-properties)) cache)))
|
||||
(when cache
|
||||
(setq maxwidths (org-columns-get-autowidth-alist fmt cache))
|
||||
(org-set-local 'org-columns-current-maxwidths maxwidths)
|
||||
|
@ -664,12 +689,34 @@ around it."
|
|||
(when (org-set-local 'org-columns-flyspell-was-active
|
||||
(org-bound-and-true-p flyspell-mode))
|
||||
(flyspell-mode 0))
|
||||
(unless (local-variable-p 'org-colview-initial-truncate-line-value)
|
||||
(org-set-local 'org-colview-initial-truncate-line-value
|
||||
truncate-lines))
|
||||
(setq truncate-lines t)
|
||||
(mapc (lambda (x)
|
||||
(goto-line (car x))
|
||||
(org-columns-display-here (cdr x)))
|
||||
cache)))))
|
||||
|
||||
(defun org-columns-new (&optional prop title width op fmt &rest rest)
|
||||
(defvar org-columns-compile-map
|
||||
'(("none" none +)
|
||||
(":" add_times +)
|
||||
("+" add_numbers +)
|
||||
("$" currency +)
|
||||
("X" checkbox +)
|
||||
("X/" checkbox-n-of-m +)
|
||||
("X%" checkbox-percent +)
|
||||
("max" max_numbers max)
|
||||
("min" min_numbers min)
|
||||
("mean" mean_numbers (lambda (&rest x) (/ (apply '+ x) (float (length x)))))
|
||||
(":max" max_times max)
|
||||
(":min" min_times min)
|
||||
(":mean" mean_times (lambda (&rest x) (/ (apply '+ x) (float (length x))))))
|
||||
"Operator <-> format,function map.
|
||||
Used to compile/uncompile columns format and completing read in
|
||||
interactive function org-columns-new.")
|
||||
|
||||
(defun org-columns-new (&optional prop title width op fmt fun &rest rest)
|
||||
"Insert a new column, to the left of the current column."
|
||||
(interactive)
|
||||
(let ((editp (and prop (assoc prop org-columns-current-fmt-compiled)))
|
||||
|
@ -682,20 +729,21 @@ around it."
|
|||
(if (string-match "\\S-" width)
|
||||
(setq width (string-to-number width))
|
||||
(setq width nil))
|
||||
(setq fmt (org-ido-completing-read "Summary [none]: "
|
||||
'(("none") ("add_numbers") ("currency") ("add_times") ("checkbox") ("checkbox-n-of-m") ("checkbox-percent"))
|
||||
nil t))
|
||||
(if (string-match "\\S-" fmt)
|
||||
(setq fmt (intern fmt))
|
||||
(setq fmt nil))
|
||||
(setq fmt (org-ido-completing-read
|
||||
"Summary [none]: "
|
||||
(mapcar (lambda (x) (list (symbol-name (cadr x))))
|
||||
org-columns-compile-map)
|
||||
nil t))
|
||||
(setq fmt (intern fmt)
|
||||
fun (cadr (assoc fmt (mapcar 'cdr org-columns-compile-map))))
|
||||
(if (eq fmt 'none) (setq fmt nil))
|
||||
(if editp
|
||||
(progn
|
||||
(setcar editp prop)
|
||||
(setcdr editp (list title width nil fmt)))
|
||||
(setcdr editp (list title width nil fmt nil fun)))
|
||||
(setq cell (nthcdr (1- (current-column))
|
||||
org-columns-current-fmt-compiled))
|
||||
(setcdr cell (cons (list prop title width nil fmt)
|
||||
(setcdr cell (cons (list prop title width nil fmt nil fun)
|
||||
(cdr cell))))
|
||||
(org-columns-store-format)
|
||||
(org-columns-redo)))
|
||||
|
@ -840,12 +888,13 @@ Don't set this, this is meant for dynamic scoping.")
|
|||
(interactive)
|
||||
(let* ((re (concat "^" outline-regexp))
|
||||
(lmax 30) ; Does anyone use deeper levels???
|
||||
(lsum (make-vector lmax 0))
|
||||
(lvals (make-vector lmax nil))
|
||||
(lflag (make-vector lmax nil))
|
||||
(level 0)
|
||||
(ass (assoc property org-columns-current-fmt-compiled))
|
||||
(format (nth 4 ass))
|
||||
(printf (nth 5 ass))
|
||||
(fun (nth 6 ass))
|
||||
(beg org-columns-top-level-marker)
|
||||
last-level val valflag flag end sumpos sum-alist sum str str1 useval)
|
||||
(save-excursion
|
||||
|
@ -863,7 +912,8 @@ Don't set this, this is meant for dynamic scoping.")
|
|||
(cond
|
||||
((< level last-level)
|
||||
;; put the sum of lower levels here as a property
|
||||
(setq sum (aref lsum last-level) ; current sum
|
||||
(setq sum (when (aref lvals last-level)
|
||||
(apply fun (aref lvals last-level)))
|
||||
flag (aref lflag last-level) ; any valid entries from children?
|
||||
str (org-columns-number-to-string sum format printf)
|
||||
str1 (org-add-props (copy-sequence str) nil 'org-computed t 'face 'bold)
|
||||
|
@ -879,19 +929,20 @@ Don't set this, this is meant for dynamic scoping.")
|
|||
(org-entry-put nil property (if flag str val)))
|
||||
;; add current to current level accumulator
|
||||
(when (or flag valflag)
|
||||
(aset lsum level (+ (aref lsum level)
|
||||
(if flag sum (org-column-string-to-number
|
||||
(if flag str val) format))))
|
||||
(push (if flag sum
|
||||
(org-column-string-to-number (if flag str val) format))
|
||||
(aref lvals level))
|
||||
(aset lflag level t))
|
||||
;; clear accumulators for deeper levels
|
||||
(loop for l from (1+ level) to (1- lmax) do
|
||||
(aset lsum l 0)
|
||||
(aset lvals l nil)
|
||||
(aset lflag l nil)))
|
||||
((>= level last-level)
|
||||
;; add what we have here to the accumulator for this level
|
||||
(aset lsum level (+ (aref lsum level)
|
||||
(org-column-string-to-number (or val "0") format)))
|
||||
(and valflag (aset lflag level t)))
|
||||
(when valflag
|
||||
(push (org-column-string-to-number val format)
|
||||
(aref lvals level))
|
||||
(aset lflag level t)))
|
||||
(t (error "This should not happen")))))))
|
||||
|
||||
(defun org-columns-redo ()
|
||||
|
@ -929,7 +980,8 @@ Don't set this, this is meant for dynamic scoping.")
|
|||
(defun org-columns-number-to-string (n fmt &optional printf)
|
||||
"Convert a computed column number to a string value, according to FMT."
|
||||
(cond
|
||||
((eq fmt 'add_times)
|
||||
((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)))
|
||||
((eq fmt 'checkbox)
|
||||
|
@ -963,21 +1015,17 @@ Don't set this, this is meant for dynamic scoping.")
|
|||
|
||||
(defun org-columns-uncompile-format (cfmt)
|
||||
"Turn the compiled columns format back into a string representation."
|
||||
(let ((rtn "") e s prop title op width fmt printf)
|
||||
(let ((rtn "") e s prop title op op-match width fmt printf)
|
||||
(while (setq e (pop cfmt))
|
||||
(setq prop (car e)
|
||||
title (nth 1 e)
|
||||
width (nth 2 e)
|
||||
op (nth 3 e)
|
||||
fmt (nth 4 e)
|
||||
printf (nth 5 e))
|
||||
(cond
|
||||
((eq fmt 'add_times) (setq op ":"))
|
||||
((eq fmt 'checkbox) (setq op "X"))
|
||||
((eq fmt 'checkbox-n-of-m) (setq op "X/"))
|
||||
((eq fmt 'checkbox-percent) (setq op "X%"))
|
||||
((eq fmt 'add_numbers) (setq op "+"))
|
||||
((eq fmt 'currency) (setq op "$")))
|
||||
printf (nth 5 e)
|
||||
fun (nth 6 e))
|
||||
(when (setq op-match (rassoc (list fmt fun) org-columns-compile-map))
|
||||
(setq op (car op-match)))
|
||||
(if (and op printf) (setq op (concat op ";" printf)))
|
||||
(if (equal title prop) (setq title nil))
|
||||
(setq s (concat "%" (if width (number-to-string width))
|
||||
|
@ -996,8 +1044,9 @@ title the title field for the columns
|
|||
width the column width in characters, can be nil for automatic
|
||||
operator the operator if any
|
||||
format the output format for computed results, derived from operator
|
||||
printf a printf format for computed values"
|
||||
(let ((start 0) width prop title op f printf)
|
||||
printf a printf format for computed values
|
||||
fun the lisp function to compute values, derived from operator"
|
||||
(let ((start 0) width prop title op op-match f printf fun)
|
||||
(setq org-columns-current-fmt-compiled nil)
|
||||
(while (string-match
|
||||
(org-re "%\\([0-9]+\\)?\\([[:alnum:]_-]+\\)\\(?:(\\([^)]+\\))\\)?\\(?:{\\([^}]+\\)}\\)?\\s-*")
|
||||
|
@ -1008,20 +1057,16 @@ printf a printf format for computed values"
|
|||
title (or (match-string 3 fmt) prop)
|
||||
op (match-string 4 fmt)
|
||||
f nil
|
||||
printf nil)
|
||||
printf nil
|
||||
fun '+)
|
||||
(if width (setq width (string-to-number width)))
|
||||
(when (and op (string-match ";" op))
|
||||
(setq printf (substring op (match-end 0))
|
||||
op (substring op 0 (match-beginning 0))))
|
||||
(cond
|
||||
((equal op "+") (setq f 'add_numbers))
|
||||
((equal op "$") (setq f 'currency))
|
||||
((equal op ":") (setq f 'add_times))
|
||||
((equal op "X") (setq f 'checkbox))
|
||||
((equal op "X/") (setq f 'checkbox-n-of-m))
|
||||
((equal op "X%") (setq f 'checkbox-percent))
|
||||
)
|
||||
(push (list prop title width op f printf) org-columns-current-fmt-compiled))
|
||||
(when (setq op-match (assoc op org-columns-compile-map))
|
||||
(setq f (cadr op-match)
|
||||
fun (caddr op-match)))
|
||||
(push (list prop title width op f printf fun) org-columns-current-fmt-compiled))
|
||||
(setq org-columns-current-fmt-compiled
|
||||
(nreverse org-columns-current-fmt-compiled))))
|
||||
|
||||
|
@ -1038,25 +1083,36 @@ containing the title row and all other rows. Each row is a list
|
|||
of fields."
|
||||
(save-excursion
|
||||
(let* ((title (mapcar 'cadr org-columns-current-fmt-compiled))
|
||||
(re-comment (concat "\\*+[ \t]+" org-comment-string "\\>"))
|
||||
(re-archive (concat ".*:" org-archive-tag ":"))
|
||||
(n (length title)) row tbl)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "^\\(\\*+\\) " nil t)
|
||||
(when (and (or (null maxlevel)
|
||||
(>= maxlevel
|
||||
(if org-odd-levels-only
|
||||
(/ (1+ (length (match-string 1))) 2)
|
||||
(length (match-string 1)))))
|
||||
(get-char-property (match-beginning 0) 'org-columns-key))
|
||||
(setq row nil)
|
||||
(loop for i from 0 to (1- n) do
|
||||
(push (or (get-char-property (+ (match-beginning 0) i) 'org-columns-value-modified)
|
||||
(get-char-property (+ (match-beginning 0) i) 'org-columns-value)
|
||||
"")
|
||||
row))
|
||||
(setq row (nreverse row))
|
||||
(unless (and skip-empty-rows
|
||||
(eq 1 (length (delete "" (delete-dups row)))))
|
||||
(push row tbl))))
|
||||
(catch 'next
|
||||
(when (and (or (null maxlevel)
|
||||
(>= maxlevel
|
||||
(if org-odd-levels-only
|
||||
(/ (1+ (length (match-string 1))) 2)
|
||||
(length (match-string 1)))))
|
||||
(get-char-property (match-beginning 0) 'org-columns-key))
|
||||
(when (save-excursion
|
||||
(goto-char (point-at-bol))
|
||||
(or (looking-at re-comment)
|
||||
(looking-at re-archive)))
|
||||
(org-end-of-subtree t)
|
||||
(throw 'next t))
|
||||
(setq row nil)
|
||||
(loop for i from 0 to (1- n) do
|
||||
(push
|
||||
(org-quote-vert
|
||||
(or (get-char-property (+ (match-beginning 0) i) 'org-columns-value-modified)
|
||||
(get-char-property (+ (match-beginning 0) i) 'org-columns-value)
|
||||
""))
|
||||
row))
|
||||
(setq row (nreverse row))
|
||||
(unless (and skip-empty-rows
|
||||
(eq 1 (length (delete "" (delete-dups (copy-sequence row))))))
|
||||
(push row tbl)))))
|
||||
(append (list title 'hline) (nreverse tbl)))))
|
||||
|
||||
(defun org-dblock-write:columnview (params)
|
||||
|
@ -1148,7 +1204,7 @@ PARAMS is a property list of parameters:
|
|||
(while (setq line (pop content-lines))
|
||||
(when (string-match "^#" line)
|
||||
(insert "\n" line)
|
||||
(when (string-match "^#\\+TBLFM" line)
|
||||
(when (string-match "^[ \t]*#\\+TBLFM" line)
|
||||
(setq recalc t))))
|
||||
(if recalc
|
||||
(progn (goto-char pos) (org-table-recalculate 'all))
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
@ -31,8 +31,13 @@
|
|||
|
||||
;;; Code:
|
||||
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
|
||||
(require 'org-macs)
|
||||
|
||||
(declare-function find-library-name "find-func" (library))
|
||||
|
||||
(defconst org-xemacs-p (featurep 'xemacs)) ; not used by org.el itself
|
||||
(defconst org-format-transports-properties-p
|
||||
(let ((x "a"))
|
||||
|
@ -43,17 +48,25 @@
|
|||
(defun org-compatible-face (inherits specs)
|
||||
"Make a compatible face specification.
|
||||
If INHERITS is an existing face and if the Emacs version supports it,
|
||||
just inherit the face. If not, use SPECS to define the face.
|
||||
just inherit the face. If INHERITS is set and the Emacs version does
|
||||
not support it, copy the face specification from the inheritance face.
|
||||
If INHERITS is not given and SPECS is, use SPECS to define the face.
|
||||
XEmacs and Emacs 21 do not know about the `min-colors' attribute.
|
||||
For them we convert a (min-colors 8) entry to a `tty' entry and move it
|
||||
to the top of the list. The `min-colors' attribute will be removed from
|
||||
any other entries, and any resulting duplicates will be removed entirely."
|
||||
(when (and inherits (facep inherits) (not specs))
|
||||
(setq specs (or specs
|
||||
(get inherits 'saved-face)
|
||||
(get inherits 'face-defface-spec))))
|
||||
(cond
|
||||
((and inherits (facep inherits)
|
||||
(not (featurep 'xemacs)) (> emacs-major-version 22))
|
||||
;; In Emacs 23, we use inheritance where possible.
|
||||
;; We only do this in Emacs 23, because only there the outline
|
||||
;; faces have been changed to the original org-mode-level-faces.
|
||||
(not (featurep 'xemacs))
|
||||
(>= emacs-major-version 22)
|
||||
;; do not inherit outline faces before Emacs 23
|
||||
(or (>= emacs-major-version 23)
|
||||
(not (string-match "\\`outline-[0-9]+"
|
||||
(symbol-name inherits)))))
|
||||
(list (list t :inherit inherits)))
|
||||
((or (featurep 'xemacs) (< emacs-major-version 22))
|
||||
;; These do not understand the `min-colors' attribute.
|
||||
|
@ -185,6 +198,11 @@ Works on both Emacs and XEmacs."
|
|||
(use-region-p)
|
||||
(and transient-mark-mode mark-active))))) ; Emacs 22 and before
|
||||
|
||||
(defun org-cursor-to-region-beginning ()
|
||||
(when (and (org-region-active-p)
|
||||
(> (point) (region-beginning)))
|
||||
(exchange-point-and-mark)))
|
||||
|
||||
;; Invisibility compatibility
|
||||
|
||||
(defun org-add-to-invisibility-spec (arg)
|
||||
|
@ -290,6 +308,16 @@ that can be added."
|
|||
(org-no-properties (substring string (or from 0) to))
|
||||
(substring-no-properties string from to)))
|
||||
|
||||
(defun org-find-library-name (library)
|
||||
(if (fboundp 'find-library-name)
|
||||
(file-name-directory (find-library-name library))
|
||||
; XEmacs does not have `find-library-name'
|
||||
(flet ((find-library-name-helper (filename ignored-codesys)
|
||||
filename)
|
||||
(find-library-name (library)
|
||||
(find-library library nil 'find-library-name-helper)))
|
||||
(file-name-directory (find-library-name library)))))
|
||||
|
||||
(defun org-count-lines (s)
|
||||
"How many lines in string S?"
|
||||
(let ((start 0) (n 1))
|
||||
|
@ -299,6 +327,11 @@ that can be added."
|
|||
(setq n (1- n)))
|
||||
n))
|
||||
|
||||
(defun org-kill-new (string &rest args)
|
||||
(remove-text-properties 0 (length string) '(line-prefix t wrap-prefix t)
|
||||
string)
|
||||
(apply 'kill-new string args))
|
||||
|
||||
(provide 'org-compat)
|
||||
|
||||
;; arch-tag: a0a0579f-e68c-4bdf-9e55-93768b846bbe
|
||||
|
|
1405
lisp/org/org-docbook.el
Normal file
1405
lisp/org/org-docbook.el
Normal file
File diff suppressed because it is too large
Load diff
440
lisp/org/org-exp-blocks.el
Normal file
440
lisp/org/org-exp-blocks.el
Normal file
|
@ -0,0 +1,440 @@
|
|||
;;; org-exp-blocks.el --- pre-process blocks when exporting org files
|
||||
|
||||
;; Copyright (C) 2009
|
||||
;; Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
|
||||
;; 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 is a utility for pre-processing blocks in org files before
|
||||
;; export using the `org-export-preprocess-hook'. It can be used for
|
||||
;; exporting new types of blocks from org-mode files and also for
|
||||
;; changing the default export behavior of existing org-mode blocks.
|
||||
;; The `org-export-blocks' and `org-export-interblocks' variables can
|
||||
;; be used to control how blocks and the spaces between blocks
|
||||
;; respectively are processed upon export.
|
||||
;;
|
||||
;; The type of a block is defined as the string following =#+begin_=,
|
||||
;; so for example the following block would be of type ditaa. Note
|
||||
;; that both upper or lower case are allowed in =#+BEGIN_= and
|
||||
;; =#+END_=.
|
||||
;;
|
||||
;; #+begin_ditaa blue.png -r -S
|
||||
;; +---------+
|
||||
;; | cBLU |
|
||||
;; | |
|
||||
;; | +----+
|
||||
;; | |cPNK|
|
||||
;; | | |
|
||||
;; +----+----+
|
||||
;; #+end_ditaa
|
||||
;;
|
||||
;;; Currently Implemented Block Types
|
||||
;;
|
||||
;; ditaa :: Convert ascii pictures to actual images using ditaa
|
||||
;; http://ditaa.sourceforge.net/. To use this set
|
||||
;; `org-ditaa-jar-path' to the path to ditaa.jar on your
|
||||
;; system (should be set automatically in most cases) .
|
||||
;;
|
||||
;; dot :: Convert graphs defined using the dot graphing language to
|
||||
;; images using the dot utility. For information on dot see
|
||||
;; http://www.graphviz.org/
|
||||
;;
|
||||
;; comment :: Wrap comments with titles and author information, in
|
||||
;; their own divs with author-specific ids allowing for css
|
||||
;; coloring of comments based on the author.
|
||||
;;
|
||||
;; R :: Implements Sweave type exporting, evaluates blocks of R code,
|
||||
;; and also replaces \R{} chunks in the file with their result
|
||||
;; when passed to R. This require the `R' command which is
|
||||
;; provided by ESS (Emacs Speaks Statistics).
|
||||
;;
|
||||
;;; Adding new blocks
|
||||
;;
|
||||
;; When adding a new block type first define a formatting function
|
||||
;; along the same lines as `org-export-blocks-format-dot' and then use
|
||||
;; `org-export-blocks-add-block' to add your block type to
|
||||
;; `org-export-blocks'.
|
||||
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
(require 'org)
|
||||
|
||||
(defvar comint-last-input-end)
|
||||
(defvar comint-prompt-regexp)
|
||||
(defvar comint-last-input-end)
|
||||
(defvar htmlp)
|
||||
(defvar latexp)
|
||||
(defvar docbookp)
|
||||
(defvar asciip)
|
||||
|
||||
(declare-function comint-send-input "comint" (&optional no-newline artificial))
|
||||
(declare-function R "ess" nil)
|
||||
|
||||
(defun org-export-blocks-set (var value)
|
||||
"Set the value of `org-export-blocks' and install fontification."
|
||||
(set var value)
|
||||
(mapc (lambda (spec)
|
||||
(if (nth 2 spec)
|
||||
(setq org-protecting-blocks
|
||||
(delete (symbol-name (car spec))
|
||||
org-protecting-blocks))
|
||||
(add-to-list 'org-protecting-blocks
|
||||
(symbol-name (car spec)))))
|
||||
value))
|
||||
|
||||
(defcustom org-export-blocks
|
||||
'((comment org-export-blocks-format-comment t)
|
||||
(ditaa org-export-blocks-format-ditaa nil)
|
||||
(dot org-export-blocks-format-dot nil)
|
||||
(r org-export-blocks-format-R nil)
|
||||
(R org-export-blocks-format-R nil))
|
||||
"Use this a-list to associate block types with block exporting
|
||||
functions. The type of a block is determined by the text
|
||||
immediately following the '#+BEGIN_' portion of the block header.
|
||||
Each block export function should accept three argumets..."
|
||||
:group 'org-export-general
|
||||
:type '(repeat
|
||||
(list
|
||||
(symbol :tag "Block name")
|
||||
(function :tag "Block formatter")
|
||||
(boolean :tag "Fontify content as Org syntax")))
|
||||
:set 'org-export-blocks-set)
|
||||
|
||||
(defun org-export-blocks-add-block (block-spec)
|
||||
"Add a new block type to `org-export-blocks'. BLOCK-SPEC
|
||||
should be a three element list the first element of which should
|
||||
indicate the name of the block, the second element should be the
|
||||
formatting function called by `org-export-blocks-preprocess' and
|
||||
the third element a flag indicating whether these types of blocks
|
||||
should be fontified in org-mode buffers (see
|
||||
`org-protecting-blocks'). For example the BLOCK-SPEC for ditaa
|
||||
blocks is as follows...
|
||||
|
||||
(ditaa org-export-blocks-format-ditaa nil)"
|
||||
(unless (member block-spec org-export-blocks)
|
||||
(setq org-export-blocks (cons block-spec org-export-blocks))
|
||||
(org-export-blocks-set 'org-export-blocks org-export-blocks)))
|
||||
|
||||
(defcustom org-export-interblocks
|
||||
'((r org-export-interblocks-format-R)
|
||||
(R org-export-interblocks-format-R))
|
||||
"Use this a-list to associate block types with block exporting
|
||||
functions. The type of a block is determined by the text
|
||||
immediately following the '#+BEGIN_' portion of the block header.
|
||||
Each block export function should accept three argumets..."
|
||||
:group 'org-export-general
|
||||
:type 'alist)
|
||||
|
||||
(defcustom org-export-blocks-witheld
|
||||
'(hidden)
|
||||
"List of block types (see `org-export-blocks') which should not
|
||||
be exported."
|
||||
:group 'org-export-general
|
||||
:type 'list)
|
||||
|
||||
(defvar org-export-blocks-postblock-hooks nil "")
|
||||
|
||||
(defun org-export-blocks-html-quote (body &optional open close)
|
||||
"Protext BODY from org html export. The optional OPEN and
|
||||
CLOSE tags will be inserted around BODY."
|
||||
(concat
|
||||
"\n#+BEGIN_HTML\n"
|
||||
(or open "")
|
||||
body (if (string-match "\n$" body) "" "\n")
|
||||
(or close "")
|
||||
"#+END_HTML\n"))
|
||||
|
||||
(defun org-export-blocks-latex-quote (body &optional open close)
|
||||
"Protext BODY from org latex export. The optional OPEN and
|
||||
CLOSE tags will be inserted around BODY."
|
||||
(concat
|
||||
"\n#+BEGIN_LaTeX\n"
|
||||
(or open "")
|
||||
body (if (string-match "\n$" body) "" "\n")
|
||||
(or close "")
|
||||
"#+END_LaTeX\n"))
|
||||
|
||||
(defun org-export-blocks-preprocess ()
|
||||
"Export all blocks acording to the `org-export-blocks' block
|
||||
exportation alist. Does not export block types specified in
|
||||
specified in BLOCKS which default to the value of
|
||||
`org-export-blocks-witheld'."
|
||||
(interactive)
|
||||
(save-window-excursion
|
||||
(let ((count 0)
|
||||
(blocks org-export-blocks-witheld)
|
||||
(case-fold-search t)
|
||||
(types '())
|
||||
indentation type func start end)
|
||||
(flet ((interblock (start end type)
|
||||
(save-match-data
|
||||
(when (setf func (cadr (assoc type org-export-interblocks)))
|
||||
(funcall func start end)))))
|
||||
(goto-char (point-min))
|
||||
(setf start (point))
|
||||
(while (re-search-forward
|
||||
"^\\([ \t]*\\)#\\+begin_\\(\\S-+\\)[ \t]*\\(.*\\)?[\r\n]\\([^\000]*?\\)[\r\n][ \t]*#\\+end_\\S-+.*" nil t)
|
||||
(save-match-data (setq indentation (length (match-string 1))))
|
||||
(save-match-data (setf type (intern (match-string 2))))
|
||||
(unless (memq type types) (setf types (cons type types)))
|
||||
(setf end (save-match-data (match-beginning 0)))
|
||||
(interblock start end type)
|
||||
(if (setf func (cadr (assoc type org-export-blocks)))
|
||||
(progn
|
||||
(replace-match (save-match-data
|
||||
(if (memq type blocks)
|
||||
""
|
||||
(apply func (save-match-data (org-remove-indentation (match-string 4)))
|
||||
(split-string (match-string 3) " ")))) t t)
|
||||
;; indent the replaced match
|
||||
(indent-region (match-beginning 0) (match-end 0) indentation)
|
||||
))
|
||||
(setf start (save-match-data (match-end 0))))
|
||||
(mapcar (lambda (type)
|
||||
(interblock start (point-max) type))
|
||||
types)))))
|
||||
|
||||
(add-hook 'org-export-preprocess-hook 'org-export-blocks-preprocess)
|
||||
|
||||
;;================================================================================
|
||||
;; type specific functions
|
||||
|
||||
;;--------------------------------------------------------------------------------
|
||||
;; ditaa: create images from ASCII art using the ditaa utility
|
||||
(defvar 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 (or load-file-name buffer-file-name)))))))
|
||||
"Path to the ditaa jar executable")
|
||||
|
||||
(defun org-export-blocks-format-ditaa (body &rest headers)
|
||||
"Pass block BODY to the ditaa utility creating an image.
|
||||
Specify the path at which the image should be saved as the first
|
||||
element of headers, any additional elements of headers will be
|
||||
passed to the ditaa utility as command line arguments."
|
||||
(message "ditaa-formatting...")
|
||||
(let ((out-file (if headers (car headers)))
|
||||
(args (if (cdr headers) (mapconcat 'identity (cdr headers) " ")))
|
||||
(data-file (make-temp-file "org-ditaa")))
|
||||
(unless (file-exists-p org-ditaa-jar-path)
|
||||
(error (format "Could not find ditaa.jar at %s" org-ditaa-jar-path)))
|
||||
(setq body (if (string-match "^\\([^:\\|:[^ ]\\)" body)
|
||||
body
|
||||
(mapconcat (lambda (x) (substring x (if (> (length x) 1) 2 1)))
|
||||
(org-split-string body "\n")
|
||||
"\n")))
|
||||
(cond
|
||||
((or htmlp latexp docbookp)
|
||||
(with-temp-file data-file (insert body))
|
||||
(message (concat "java -jar " org-ditaa-jar-path " " args " " data-file " " out-file))
|
||||
(shell-command (concat "java -jar " org-ditaa-jar-path " " args " " data-file " " out-file))
|
||||
(format "\n[[file:%s]]\n" out-file))
|
||||
(t (concat
|
||||
"\n#+BEGIN_EXAMPLE\n"
|
||||
body (if (string-match "\n$" body) "" "\n")
|
||||
"#+END_EXAMPLE\n")))))
|
||||
|
||||
;;--------------------------------------------------------------------------------
|
||||
;; dot: create graphs using the dot graphing language
|
||||
;; (require the dot executable to be in your path)
|
||||
(defun org-export-blocks-format-dot (body &rest headers)
|
||||
"Pass block BODY to the dot graphing utility creating an image.
|
||||
Specify the path at which the image should be saved as the first
|
||||
element of headers, any additional elements of headers will be
|
||||
passed to the dot utility as command line arguments. Don't
|
||||
forget to specify the output type for the dot command, so if you
|
||||
are exporting to a file with a name like 'image.png' you should
|
||||
include a '-Tpng' argument, and your block should look like the
|
||||
following.
|
||||
|
||||
#+begin_dot models.png -Tpng
|
||||
digraph data_relationships {
|
||||
\"data_requirement\" [shape=Mrecord, label=\"{DataRequirement|description\lformat\l}\"]
|
||||
\"data_product\" [shape=Mrecord, label=\"{DataProduct|name\lversion\lpoc\lformat\l}\"]
|
||||
\"data_requirement\" -> \"data_product\"
|
||||
}
|
||||
#+end_dot"
|
||||
(message "dot-formatting...")
|
||||
(let ((out-file (if headers (car headers)))
|
||||
(args (if (cdr headers) (mapconcat 'identity (cdr headers) " ")))
|
||||
(data-file (make-temp-file "org-ditaa")))
|
||||
(cond
|
||||
((or htmlp latexp docbookp)
|
||||
(with-temp-file data-file (insert body))
|
||||
(message (concat "dot " data-file " " args " -o " out-file))
|
||||
(shell-command (concat "dot " data-file " " args " -o " out-file))
|
||||
(format "\n[[file:%s]]\n" out-file))
|
||||
(t (concat
|
||||
"\n#+BEGIN_EXAMPLE\n"
|
||||
body (if (string-match "\n$" body) "" "\n")
|
||||
"#+END_EXAMPLE\n")))))
|
||||
|
||||
;;--------------------------------------------------------------------------------
|
||||
;; comment: export comments in author-specific css-stylable divs
|
||||
(defun org-export-blocks-format-comment (body &rest headers)
|
||||
"Format comment BODY by OWNER and return it formatted for export.
|
||||
Currently, this only does something for HTML export, for all
|
||||
other backends, it converts the comment into an EXAMPLE segment."
|
||||
(let ((owner (if headers (car headers)))
|
||||
(title (if (cdr headers) (mapconcat 'identity (cdr headers) " "))))
|
||||
(cond
|
||||
(htmlp ;; We are exporting to HTML
|
||||
(concat "#+BEGIN_HTML\n"
|
||||
"<div class=\"org-comment\""
|
||||
(if owner (format " id=\"org-comment-%s\" " owner))
|
||||
">\n"
|
||||
(if owner (concat "<b>" owner "</b> ") "")
|
||||
(if (and title (> (length title) 0)) (concat " -- " title "</br>\n") "</br>\n")
|
||||
"<p>\n"
|
||||
"#+END_HTML\n"
|
||||
body
|
||||
"#+BEGIN_HTML\n"
|
||||
"</p>\n"
|
||||
"</div>\n"
|
||||
"#+END_HTML\n"))
|
||||
(t ;; This is not HTML, so just make it an example.
|
||||
(concat "#+BEGIN_EXAMPLE\n"
|
||||
(if title (concat "Title:" title "\n") "")
|
||||
(if owner (concat "By:" owner "\n") "")
|
||||
body
|
||||
(if (string-match "\n\\'" body) "" "\n")
|
||||
"#+END_EXAMPLE\n")))))
|
||||
|
||||
;;--------------------------------------------------------------------------------
|
||||
;; R: Sweave-type functionality
|
||||
(defvar interblock-R-buffer nil
|
||||
"Holds the buffer for the current R process")
|
||||
|
||||
(defvar count) ; dynamicaly scoped from `org-export-blocks-preprocess'?
|
||||
(defun org-export-blocks-format-R (body &rest headers)
|
||||
"Process R blocks and replace \R{} forms outside the blocks
|
||||
with their values as determined by R."
|
||||
(interactive)
|
||||
(message "R processing...")
|
||||
(let ((image-path (or (and (car headers)
|
||||
(string-match "\\(.?\\)\.\\(EPS\\|eps\\)" (car headers))
|
||||
(match-string 1 (car headers)))
|
||||
(and (> (length (car headers)) 0)
|
||||
(car headers))
|
||||
;; create the default filename
|
||||
(format "Rplot-%03d" count)))
|
||||
(plot (string-match "plot" body))
|
||||
R-proc)
|
||||
(setf count (+ count 1))
|
||||
(interblock-initiate-R-buffer)
|
||||
(setf R-proc (get-buffer-process interblock-R-buffer))
|
||||
;; send strings to the ESS process using `comint-send-string'
|
||||
(setf body (mapconcat (lambda (line)
|
||||
(interblock-R-input-command line) (concat "> " line))
|
||||
(butlast (split-string body "[\r\n]"))
|
||||
"\n"))
|
||||
;; if there is a plot command, then create the images
|
||||
(when plot
|
||||
(interblock-R-input-command (format "dev.copy2eps(file=\"%s.eps\")" image-path)))
|
||||
(concat (cond
|
||||
(htmlp (org-export-blocks-html-quote body
|
||||
(format "<div id=\"R-%d\">\n<pre>\n" count)
|
||||
"</pre>\n</div>\n"))
|
||||
(latexp (org-export-blocks-latex-quote body
|
||||
"\\begin{Schunk}\n\\begin{Sinput}\n"
|
||||
"\\end{Sinput}\n\\end{Schunk}\n"))
|
||||
(t (insert ;; default export
|
||||
"#+begin_R " (mapconcat 'identity headers " ") "\n"
|
||||
body (if (string-match "\n$" body) "" "\n")
|
||||
"#+end_R\n")))
|
||||
(if plot
|
||||
(format "[[file:%s.eps]]\n" image-path)
|
||||
""))))
|
||||
|
||||
(defun org-export-interblocks-format-R (start end)
|
||||
"This is run over parts of the org-file which are between R
|
||||
blocks. It's main use is to expand the \R{stuff} chunks for
|
||||
export."
|
||||
(save-excursion
|
||||
(goto-char start)
|
||||
(interblock-initiate-R-buffer)
|
||||
(let (code replacement)
|
||||
(while (and (< (point) end) (re-search-forward "\\\\R{\\(.*\\)}" end t))
|
||||
(save-match-data (setf code (match-string 1)))
|
||||
(setf replacement (interblock-R-command-to-string code))
|
||||
(setf replacement (cond
|
||||
(htmlp replacement)
|
||||
(latexp replacement)
|
||||
(t replacement)))
|
||||
(setf end (+ end (- (length replacement) (length code))))
|
||||
(replace-match replacement t t)))))
|
||||
|
||||
(defun interblock-initiate-R-buffer ()
|
||||
"If there is not a current R process then create one."
|
||||
(unless (and (buffer-live-p interblock-R-buffer) (get-buffer interblock-R-buffer))
|
||||
(save-excursion
|
||||
(R)
|
||||
(setf interblock-R-buffer (current-buffer))
|
||||
(interblock-R-wait-for-output)
|
||||
(interblock-R-input-command ""))))
|
||||
|
||||
(defun interblock-R-command-to-string (command)
|
||||
"Send a command to R, and return the results as a string."
|
||||
(interblock-R-input-command command)
|
||||
(interblock-R-last-output))
|
||||
|
||||
(defun interblock-R-input-command (command)
|
||||
"Pass COMMAND to the R process running in `interblock-R-buffer'."
|
||||
(save-excursion
|
||||
(save-match-data
|
||||
(set-buffer interblock-R-buffer)
|
||||
(goto-char (process-mark (get-buffer-process (current-buffer))))
|
||||
(insert command)
|
||||
(comint-send-input)
|
||||
(interblock-R-wait-for-output))))
|
||||
|
||||
(defun interblock-R-wait-for-output ()
|
||||
"Wait until output arrives"
|
||||
(save-excursion
|
||||
(save-match-data
|
||||
(set-buffer interblock-R-buffer)
|
||||
(while (progn
|
||||
(goto-char comint-last-input-end)
|
||||
(not (re-search-forward comint-prompt-regexp nil t)))
|
||||
(accept-process-output (get-buffer-process (current-buffer)))))))
|
||||
|
||||
(defun interblock-R-last-output ()
|
||||
"Return the last R output as a string"
|
||||
(save-excursion
|
||||
(save-match-data
|
||||
(set-buffer interblock-R-buffer)
|
||||
(goto-char (process-mark (get-buffer-process (current-buffer))))
|
||||
(forward-line 0)
|
||||
(let ((raw (buffer-substring comint-last-input-end (- (point) 1))))
|
||||
(if (string-match "\n" raw)
|
||||
raw
|
||||
(and (string-match "\\[[[:digit:]+]\\] *\\(.*\\)$" raw)
|
||||
(message raw)
|
||||
(message (match-string 1 raw))
|
||||
(match-string 1 raw)))))))
|
||||
|
||||
(provide 'org-exp-blocks)
|
||||
|
||||
;;; org-exp-blocks.el ends here
|
3490
lisp/org/org-exp.el
3490
lisp/org/org-exp.el
File diff suppressed because it is too large
Load diff
|
@ -6,7 +6,7 @@
|
|||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
@ -258,21 +258,21 @@ column view defines special faces for each outline level. See the file
|
|||
'((((class color) (background light)) (:underline t))
|
||||
(((class color) (background dark)) (:underline t))
|
||||
(t (:underline t)))
|
||||
"Face for links."
|
||||
"Face for link targets."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-date
|
||||
'((((class color) (background light)) (:foreground "Purple" :underline t))
|
||||
(((class color) (background dark)) (:foreground "Cyan" :underline t))
|
||||
(t (:underline t)))
|
||||
"Face for links."
|
||||
"Face for date/time stamps."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-sexp-date
|
||||
'((((class color) (background light)) (:foreground "Purple"))
|
||||
(((class color) (background dark)) (:foreground "Cyan"))
|
||||
(t (:underline t)))
|
||||
"Face for links."
|
||||
"Face for diary-like sexp date specifications."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-tag
|
||||
|
@ -301,6 +301,20 @@ specific tags."
|
|||
"Face used for todo keywords that indicate DONE items."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-agenda-done ;; originally copied from font-lock-type-face
|
||||
(org-compatible-face nil
|
||||
'((((class color) (min-colors 16) (background light)) (:foreground "ForestGreen"))
|
||||
(((class color) (min-colors 16) (background dark)) (:foreground "PaleGreen"))
|
||||
(((class color) (min-colors 8)) (:foreground "green"))
|
||||
(t (:bold nil))))
|
||||
"Face used in agenda, to indicate lines switched to DONE.
|
||||
This face is used to de-emphasize items that where brightly colord in the
|
||||
agenda because they were things to do, or overdue. The DONE state itself
|
||||
is of course immediately visible, but for example a passed deadline is
|
||||
\(by default) very bright read. This face could be simply the default face
|
||||
of the frame, for example."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-headline-done ;; originally copied from font-lock-string-face
|
||||
(org-compatible-face nil
|
||||
'((((class color) (min-colors 16) (background light)) (:foreground "RosyBrown"))
|
||||
|
@ -323,6 +337,18 @@ list of attributes, like (:foreground \"blue\" :weight bold :underline t)."
|
|||
(string :tag "keyword")
|
||||
(sexp :tag "face"))))
|
||||
|
||||
(defcustom org-priority-faces nil
|
||||
"Faces for specific Priorities.
|
||||
This is a list of cons cells, with priority character in the car
|
||||
and faces in the cdr. The face can be a symbol, or a property
|
||||
list of attributes, like (:foreground \"blue\" :weight bold :underline t)."
|
||||
:group 'org-faces
|
||||
:group 'org-todo
|
||||
:type '(repeat
|
||||
(cons
|
||||
(character :tag "Priority")
|
||||
(sexp :tag "face"))))
|
||||
|
||||
(defvar org-tags-special-faces-re nil)
|
||||
(defun org-set-tag-faces (var value)
|
||||
(set var value)
|
||||
|
@ -331,6 +357,22 @@ list of attributes, like (:foreground \"blue\" :weight bold :underline t)."
|
|||
(setq org-tags-special-faces-re
|
||||
(concat ":\\(" (mapconcat 'car value "\\|") "\\):"))))
|
||||
|
||||
(defface org-checkbox
|
||||
(org-compatible-face 'bold
|
||||
'((t (:bold t))))
|
||||
"Face for checkboxes"
|
||||
:group 'org-faces)
|
||||
|
||||
(unless (facep 'org-checkbox-statistics-todo)
|
||||
(copy-face 'org-todo 'org-checkbox-statistics-todo)
|
||||
(set-face-doc-string 'org-checkbox-statistics-todo
|
||||
"Face used for unfinished checkbox statistics."))
|
||||
|
||||
(unless (facep 'org-checkbox-statistics-done)
|
||||
(copy-face 'org-done 'org-checkbox-statistics-done)
|
||||
(set-face-doc-string 'org-checkbox-statistics-done
|
||||
"Face used for finished checkbox statistics."))
|
||||
|
||||
(defcustom org-tag-faces nil
|
||||
"Faces for specific tags.
|
||||
This is a list of cons cells, with tags in the car and faces in the cdr.
|
||||
|
@ -370,7 +412,7 @@ changes."
|
|||
:group 'org-faces)
|
||||
|
||||
(defface org-code
|
||||
(org-compatible-face nil
|
||||
(org-compatible-face 'shadow
|
||||
'((((class color grayscale) (min-colors 88) (background light))
|
||||
(:foreground "grey50"))
|
||||
(((class color grayscale) (min-colors 88) (background dark))
|
||||
|
@ -383,8 +425,28 @@ changes."
|
|||
:group 'org-faces
|
||||
:version "22.1")
|
||||
|
||||
(defface org-meta-line
|
||||
(org-compatible-face 'font-lock-comment-face nil)
|
||||
"Face for meta lines startin with \"#+\"."
|
||||
:group 'org-faces
|
||||
:version "22.1")
|
||||
|
||||
(defface org-block
|
||||
(org-compatible-face 'shadow
|
||||
'((((class color grayscale) (min-colors 88) (background light))
|
||||
(:foreground "grey50"))
|
||||
(((class color grayscale) (min-colors 88) (background dark))
|
||||
(:foreground "grey70"))
|
||||
(((class color) (min-colors 8) (background light))
|
||||
(:foreground "green"))
|
||||
(((class color) (min-colors 8) (background dark))
|
||||
(:foreground "yellow"))))
|
||||
"Face text in #+begin ... #+end blocks."
|
||||
:group 'org-faces
|
||||
:version "22.1")
|
||||
|
||||
(defface org-verbatim
|
||||
(org-compatible-face nil
|
||||
(org-compatible-face 'shadow
|
||||
'((((class color grayscale) (min-colors 88) (background light))
|
||||
(:foreground "grey50" :underline t))
|
||||
(((class color grayscale) (min-colors 88) (background dark))
|
||||
|
@ -429,6 +491,13 @@ changes."
|
|||
(set-face-doc-string 'org-agenda-date
|
||||
"Face used in agenda for normal days."))
|
||||
|
||||
(unless (facep 'org-agenda-date-today)
|
||||
(copy-face 'org-agenda-date 'org-agenda-date-today)
|
||||
(set-face-doc-string 'org-agenda-date-today
|
||||
"Face used in agenda for today.")
|
||||
(when (fboundp 'set-face-attribute)
|
||||
(set-face-attribute 'org-agenda-date-today nil :weight 'bold :italic 't)))
|
||||
|
||||
(unless (facep 'org-agenda-date-weekend)
|
||||
(copy-face 'org-agenda-date 'org-agenda-date-weekend)
|
||||
(set-face-doc-string 'org-agenda-date-weekend
|
||||
|
@ -535,7 +604,7 @@ month and 365.24 days for a year)."
|
|||
"The number of different faces to be used for headlines.
|
||||
Org-mode defines 8 different headline faces, so this can be at most 8.
|
||||
If it is less than 8, the level-1 face gets re-used for level N+1 etc."
|
||||
:type 'number
|
||||
:type 'integer
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-latex-and-export-specials
|
||||
|
@ -554,6 +623,11 @@ If it is less than 8, the level-1 face gets re-used for level N+1 etc."
|
|||
"Face used to highlight math latex and other special exporter stuff."
|
||||
:group 'org-faces)
|
||||
|
||||
(unless (facep 'org-mode-line-clock)
|
||||
(copy-face 'modeline 'org-mode-line-clock)
|
||||
(set-face-doc-string 'org-agenda-date
|
||||
"Face used for clock display in mode line."))
|
||||
|
||||
(provide 'org-faces)
|
||||
|
||||
;; arch-tag: 9dab5f91-c4b9-4d6f-bac3-1f6211ad0a04
|
||||
|
|
665
lisp/org/org-feed.el
Normal file
665
lisp/org/org-feed.el
Normal file
|
@ -0,0 +1,665 @@
|
|||
;;; org-feed.el --- Add RSS feed items to Org files
|
||||
;;
|
||||
;; Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
;;
|
||||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; 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 module allows to create and change entries in an Org-mode
|
||||
;; file triggered by items in an RSS feed. The basic functionality is
|
||||
;; geared toward simply adding new items found in a feed as outline nodes
|
||||
;; to an Org file. Using hooks, arbitrary actions can be triggered for
|
||||
;; new or changed items.
|
||||
;;
|
||||
;; Selecting feeds and target locations
|
||||
;; ------------------------------------
|
||||
;;
|
||||
;; This module is configured through a single variable, `org-feed-alist'.
|
||||
;; Here is an example, using a notes/tasks feed from reQall.com.
|
||||
;;
|
||||
;; (setq org-feed-alist
|
||||
;; '(("ReQall"
|
||||
;; "http://www.reqall.com/user/feeds/rss/a1b2c3....."
|
||||
;; "~/org/feeds.org" "ReQall Entries")
|
||||
;;
|
||||
;; With this setup, the command `M-x org-feed-update-all' will
|
||||
;; collect new entries in the feed at the given URL and create
|
||||
;; entries as subheadings under the "ReQall Entries" heading in the
|
||||
;; file "~/org-feeds.org". Each feed should normally have its own
|
||||
;; heading - however see the `:drawer' parameter.
|
||||
;;
|
||||
;; Besides these standard elements that need to be specified for each
|
||||
;; feed, keyword-value pairs can set additional options. For example,
|
||||
;; to de-select transitional entries with a title containing
|
||||
;;
|
||||
;; "reQall is typing what you said",
|
||||
;;
|
||||
;; you could use the `:filter' argument:
|
||||
;;
|
||||
;; (setq org-feed-alist
|
||||
;; '(("ReQall"
|
||||
;; "http://www.reqall.com/user/feeds/rss/a1b2c3....."
|
||||
;; "~/org/feeds.org" "ReQall Entries"
|
||||
;; :filter my-reqall-filter)))
|
||||
;;
|
||||
;; (defun my-reqall-filter (e)
|
||||
;; (if (string-match "reQall is typing what you said"
|
||||
;; (plist-get e :title))
|
||||
;; nil
|
||||
;; e))
|
||||
;;
|
||||
;; See the docstring for `org-feed-alist' for more details.
|
||||
;;
|
||||
;;
|
||||
;; Keeping track of previously added entries
|
||||
;; -----------------------------------------
|
||||
;;
|
||||
;; Since Org allows you to delete, archive, or move outline nodes,
|
||||
;; org-feed.el needs to keep track of which feed items have been handled
|
||||
;; before, so that they will not be handled again. For this, org-feed.el
|
||||
;; stores information in a special drawer, FEEDSTATUS, under the heading
|
||||
;; that received the input of the feed. You should add FEEDSTATUS
|
||||
;; to your list of drawers in the files that receive feed input:
|
||||
;;
|
||||
;; #+DRAWERS: PROPERTIES LOGBOOK FEEDSTATUS
|
||||
;;
|
||||
;; Acknowledgments
|
||||
;; ----------------
|
||||
;;
|
||||
;; org-feed.el is based on ideas by Brad Bozarth who implemented a
|
||||
;; similar mechanism using shell and awk scripts.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'org)
|
||||
(require 'sha1)
|
||||
|
||||
(declare-function url-retrieve-synchronously "url" (url))
|
||||
(declare-function xml-node-children "xml" (node))
|
||||
(declare-function xml-get-children "xml" (node child-name))
|
||||
(declare-function xml-get-attribute "xml" (node attribute))
|
||||
(declare-function xml-get-attribute-or-nil "xml" (node attribute))
|
||||
|
||||
(defgroup org-feed nil
|
||||
"Options concerning RSS feeds as inputs for Org files."
|
||||
:tag "Org ID"
|
||||
:group 'org)
|
||||
|
||||
(defcustom org-feed-alist nil
|
||||
"Alist specifying RSS feeds that should create inputs for Org.
|
||||
Each entry in this list specified an RSS feed tat should be queried
|
||||
to create inbox items in Org. Each entry is a list with the following items:
|
||||
|
||||
name a custom name for this feed
|
||||
URL the Feed URL
|
||||
file the target Org file where entries should be listed
|
||||
headline the headline under which entries should be listed
|
||||
|
||||
Additional arguments can be given using keyword-value pairs. Many of these
|
||||
specify functions that receive one or a list of \"entries\" as their single
|
||||
argument. An entry is a property list that describes a feed item. The
|
||||
property list has properties for each field in the item, for example `:title'
|
||||
for the `<title>' field and `:pubDate' for the publication date. In addition,
|
||||
it contains the following properties:
|
||||
|
||||
`:item-full-text' the full text in the <item> tag
|
||||
`:guid-permalink' t when the guid property is a permalink
|
||||
|
||||
Here are the keyword-value pair allows in `org-feed-alist'.
|
||||
|
||||
:drawer drawer-name
|
||||
The name of the drawer for storing feed information. The default is
|
||||
\"FEEDSTATUS\". Using different drawers for different feeds allows
|
||||
several feeds to target the same inbox heading.
|
||||
|
||||
:filter filter-function
|
||||
A function to select interesting entries in the feed. It gets a single
|
||||
entry as parameter. It should return the entry if it is relevant, or
|
||||
nil if it is not.
|
||||
|
||||
:template template-string
|
||||
The default action on new items in the feed is to add them as children
|
||||
under the headline for the feed. The template describes how the entry
|
||||
should be formatted. If not given, it defaults to
|
||||
`org-feed-default-template'.
|
||||
|
||||
:formatter formatter-function
|
||||
Instead of relying on a template, you may specify a function to format
|
||||
the outline node to be inserted as a child. This function gets passed
|
||||
a property list describing a single feed item, and it should return a
|
||||
string that is a properly formatted Org outline node of level 1.
|
||||
|
||||
:new-handler function
|
||||
If adding new items as children to the outline is not what you want
|
||||
to do with new items, define a handler function that is called with
|
||||
a list of all new items in the feed, each one represented as a property
|
||||
list. The handler should do what needs to be done, and org-feed will
|
||||
mark all items given to this handler as \"handled\", i.e. they will not
|
||||
be passed to this handler again in future readings of the feed.
|
||||
When the handler is called, point will be at the feed headline.
|
||||
|
||||
:changed-handler function
|
||||
This function gets passed a list of all entries that have been
|
||||
handled before, but are now still in the feed and have *changed*
|
||||
since last handled (as evidenced by a different sha1 hash).
|
||||
When the handler is called, point will be at the feed headline.
|
||||
|
||||
:parse-feed function
|
||||
This function gets passed a buffer, and should return a list of entries,
|
||||
each being a property list containing the `:guid' and `:item-full-text'
|
||||
keys. The default is `org-feed-parse-rss-feed'; `org-feed-parse-atom-feed'
|
||||
is an alternative.
|
||||
|
||||
:parse-entry function
|
||||
This function gets passed an entry as returned by the parse-feed
|
||||
function, and should return the entry with interesting properties added.
|
||||
The default is `org-feed-parse-rss-entry'; `org-feed-parse-atom-entry'
|
||||
is an alternative."
|
||||
:group 'org-feed
|
||||
:type '(repeat
|
||||
(list :value ("" "http://" "" "")
|
||||
(string :tag "Name")
|
||||
(string :tag "Feed URL")
|
||||
(file :tag "File for inbox")
|
||||
(string :tag "Headline for inbox")
|
||||
(repeat :inline t
|
||||
(choice
|
||||
(list :inline t :tag "Filter"
|
||||
(const :filter)
|
||||
(symbol :tag "Filter Function"))
|
||||
(list :inline t :tag "Template"
|
||||
(const :template)
|
||||
(string :tag "Template"))
|
||||
(list :inline t :tag "Formatter"
|
||||
(const :formatter)
|
||||
(symbol :tag "Formatter Function"))
|
||||
(list :inline t :tag "New items handler"
|
||||
(const :new-handler)
|
||||
(symbol :tag "Handler Function"))
|
||||
(list :inline t :tag "Changed items"
|
||||
(const :changed-handler)
|
||||
(symbol :tag "Handler Function"))
|
||||
(list :inline t :tag "Parse Feed"
|
||||
(const :parse-feed)
|
||||
(symbol :tag "Parse Feed Function"))
|
||||
(list :inline t :tag "Parse Entry"
|
||||
(const :parse-entry)
|
||||
(symbol :tag "Parse Entry Function"))
|
||||
)))))
|
||||
|
||||
(defcustom org-feed-drawer "FEEDSTATUS"
|
||||
"The name of the drawer for feed status information.
|
||||
Each feed may also specify its own drawer name using the `:drawer'
|
||||
parameter in `org-feed-alist'.
|
||||
Note that in order to make these drawers behave like drawers, they must
|
||||
be added to the variable `org-drawers' or configured with a #+DRAWERS
|
||||
line."
|
||||
:group 'org-feed
|
||||
:type '(string :tag "Drawer Name"))
|
||||
|
||||
(defcustom org-feed-default-template "\n* %h\n %U\n %description\n %a\n"
|
||||
"Template for the Org node created from RSS feed items.
|
||||
This is just the default, each feed can specify its own.
|
||||
Any fields from the feed item can be interpolated into the template with
|
||||
%name, for example %title, %description, %pubDate etc. In addition, the
|
||||
following special escapes are valid as well:
|
||||
|
||||
%h the title, or the first line of the description
|
||||
%t the date as a stamp, either from <pubDate> (if present), or
|
||||
the current date.
|
||||
%T date and time
|
||||
%u,%U like %t,%T, but inactive time stamps
|
||||
%a A link, from <guid> if that is a permalink, else from <link>"
|
||||
:group 'org-feed
|
||||
:type '(string :tag "Template"))
|
||||
|
||||
(defcustom org-feed-save-after-adding t
|
||||
"Non-nil means, save buffer after adding new feed items."
|
||||
:group 'org-feed
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-feed-retrieve-method 'url-retrieve-synchronously
|
||||
"The method to be used to retrieve a feed URL.
|
||||
This can be `curl' or `wget' to call these external programs, or it can be
|
||||
an Emacs Lisp function that will return a buffer containing the content
|
||||
of the file pointed to by the URL."
|
||||
:group 'org-feed
|
||||
:type '(choice
|
||||
(const :tag "Internally with url.el" url-retrieve-synchronously)
|
||||
(const :tag "Externally with curl" curl)
|
||||
(const :tag "Externally with wget" wget)
|
||||
(function :tag "Function")))
|
||||
|
||||
(defcustom org-feed-before-adding-hook nil
|
||||
"Hook that is run before adding new feed items to a file.
|
||||
You might want to commit the file in its current state to version control,
|
||||
for example."
|
||||
:group 'org-feed
|
||||
:type 'hook)
|
||||
|
||||
(defcustom org-feed-after-adding-hook nil
|
||||
"Hook that is run after new items have been added to a file.
|
||||
Depending on `org-feed-save-after-adding', the buffer will already
|
||||
have been saved."
|
||||
:group 'org-feed
|
||||
:type 'hook)
|
||||
|
||||
(defvar org-feed-buffer "*Org feed*"
|
||||
"The buffer used to retrieve a feed.")
|
||||
|
||||
;;;###autoload
|
||||
(defun org-feed-update-all ()
|
||||
"Get inbox items from all feeds in `org-feed-alist'."
|
||||
(interactive)
|
||||
(let ((nfeeds (length org-feed-alist))
|
||||
(nnew (apply '+ (mapcar 'org-feed-update org-feed-alist))))
|
||||
(message "%s from %d %s"
|
||||
(cond ((= nnew 0) "No new entries")
|
||||
((= nnew 1) "1 new entry")
|
||||
(t (format "%d new entries" nnew)))
|
||||
nfeeds
|
||||
(if (= nfeeds 1) "feed" "feeds"))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-feed-update (feed &optional retrieve-only)
|
||||
"Get inbox items from FEED.
|
||||
FEED can be a string with an association in `org-feed-alist', or
|
||||
it can be a list structured like an entry in `org-feed-alist'."
|
||||
(interactive (list (org-completing-read "Feed name: " org-feed-alist)))
|
||||
(if (stringp feed) (setq feed (assoc feed org-feed-alist)))
|
||||
(unless feed
|
||||
(error "No such feed in `org-feed-alist"))
|
||||
(catch 'exit
|
||||
(let ((name (car feed))
|
||||
(url (nth 1 feed))
|
||||
(file (nth 2 feed))
|
||||
(headline (nth 3 feed))
|
||||
(filter (nth 1 (memq :filter feed)))
|
||||
(formatter (nth 1 (memq :formatter feed)))
|
||||
(new-handler (nth 1 (memq :new-handler feed)))
|
||||
(changed-handler (nth 1 (memq :changed-handler feed)))
|
||||
(template (or (nth 1 (memq :template feed))
|
||||
org-feed-default-template))
|
||||
(drawer (or (nth 1 (memq :drawer feed))
|
||||
org-feed-drawer))
|
||||
(parse-feed (or (nth 1 (memq :parse-feed feed))
|
||||
'org-feed-parse-rss-feed))
|
||||
(parse-entry (or (nth 1 (memq :parse-entry feed))
|
||||
'org-feed-parse-rss-entry))
|
||||
feed-buffer inbox-pos new-formatted
|
||||
entries old-status status new changed guid-alist e guid olds)
|
||||
(setq feed-buffer (org-feed-get-feed url))
|
||||
(unless (and feed-buffer (bufferp (get-buffer feed-buffer)))
|
||||
(error "Cannot get feed %s" name))
|
||||
(when retrieve-only
|
||||
(throw 'exit feed-buffer))
|
||||
(setq entries (funcall parse-feed feed-buffer))
|
||||
(ignore-errors (kill-buffer feed-buffer))
|
||||
(save-excursion
|
||||
(save-window-excursion
|
||||
(setq inbox-pos (org-feed-goto-inbox-internal file headline))
|
||||
(setq old-status (org-feed-read-previous-status inbox-pos drawer))
|
||||
;; Add the "handled" status to the appropriate entries
|
||||
(setq entries (mapcar (lambda (e)
|
||||
(setq e (plist-put e :handled
|
||||
(nth 1 (assoc
|
||||
(plist-get e :guid)
|
||||
old-status)))))
|
||||
entries))
|
||||
;; Find out which entries are new and which are changed
|
||||
(dolist (e entries)
|
||||
(if (not (plist-get e :handled))
|
||||
(push e new)
|
||||
(setq olds (nth 2 (assoc (plist-get e :guid) old-status)))
|
||||
(if (and olds
|
||||
(not (string= (sha1
|
||||
(plist-get e :item-full-text))
|
||||
olds)))
|
||||
(push e changed))))
|
||||
|
||||
;; Parse the relevant entries fully
|
||||
(setq new (mapcar parse-entry new)
|
||||
changed (mapcar parse-entry changed))
|
||||
|
||||
;; Run the filter
|
||||
(when filter
|
||||
(setq new (delq nil (mapcar filter new))
|
||||
changed (delq nil (mapcar filter new))))
|
||||
|
||||
(when (not (or new changed))
|
||||
(message "No new items in feed %s" name)
|
||||
(throw 'exit 0))
|
||||
|
||||
;; Get alist based on guid, to look up entries
|
||||
(setq guid-alist
|
||||
(append
|
||||
(mapcar (lambda (e) (list (plist-get e :guid) e)) new)
|
||||
(mapcar (lambda (e) (list (plist-get e :guid) e)) changed)))
|
||||
|
||||
;; Construct the new status
|
||||
(setq status
|
||||
(mapcar
|
||||
(lambda (e)
|
||||
(setq guid (plist-get e :guid))
|
||||
(list guid
|
||||
;; things count as handled if we handle them now,
|
||||
;; or if they were handled previously
|
||||
(if (assoc guid guid-alist) t (plist-get e :handled))
|
||||
;; A hash, to detect changes
|
||||
(sha1 (plist-get e :item-full-text))))
|
||||
entries))
|
||||
|
||||
;; Handle new items in the feed
|
||||
(when new
|
||||
(if new-handler
|
||||
(progn
|
||||
(goto-char inbox-pos)
|
||||
(funcall new-handler new))
|
||||
;; No custom handler, do the default adding
|
||||
;; Format the new entries into an alist with GUIDs in the car
|
||||
(setq new-formatted
|
||||
(mapcar
|
||||
(lambda (e) (org-feed-format-entry e template formatter))
|
||||
new)))
|
||||
|
||||
;; Insert the new items
|
||||
(org-feed-add-items inbox-pos new-formatted))
|
||||
|
||||
;; Handle changed items in the feed
|
||||
(when (and changed-handler changed)
|
||||
(goto-char inbox-pos)
|
||||
(funcall changed-handler changed))
|
||||
|
||||
;; Write the new status
|
||||
;; We do this only now, in case something goes wrong above, so
|
||||
;; that would would end up with a status that does not reflect
|
||||
;; which items truely have been handled
|
||||
(org-feed-write-status inbox-pos drawer status)
|
||||
|
||||
;; Normalize the visibility of the inbox tree
|
||||
(goto-char inbox-pos)
|
||||
(hide-subtree)
|
||||
(show-children)
|
||||
(org-cycle-hide-drawers 'children)
|
||||
|
||||
;; Hooks and messages
|
||||
(when org-feed-save-after-adding (save-buffer))
|
||||
(message "Added %d new item%s from feed %s to file %s, heading %s"
|
||||
(length new) (if (> (length new) 1) "s" "")
|
||||
name
|
||||
(file-name-nondirectory file) headline)
|
||||
(run-hooks 'org-feed-after-adding-hook)
|
||||
(length new))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-feed-goto-inbox (feed)
|
||||
"Go to the inbox that captures the feed named FEED."
|
||||
(interactive
|
||||
(list (if (= (length org-feed-alist) 1)
|
||||
(car org-feed-alist)
|
||||
(org-completing-read "Feed name: " org-feed-alist))))
|
||||
(if (stringp feed) (setq feed (assoc feed org-feed-alist)))
|
||||
(unless feed
|
||||
(error "No such feed in `org-feed-alist"))
|
||||
(org-feed-goto-inbox-internal (nth 2 feed) (nth 3 feed)))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-feed-show-raw-feed (feed)
|
||||
"Show the raw feed buffer of a feed."
|
||||
(interactive
|
||||
(list (if (= (length org-feed-alist) 1)
|
||||
(car org-feed-alist)
|
||||
(org-completing-read "Feed name: " org-feed-alist))))
|
||||
(if (stringp feed) (setq feed (assoc feed org-feed-alist)))
|
||||
(unless feed
|
||||
(error "No such feed in `org-feed-alist"))
|
||||
(switch-to-buffer
|
||||
(org-feed-update feed 'retrieve-only))
|
||||
(goto-char (point-min)))
|
||||
|
||||
(defun org-feed-goto-inbox-internal (file heading)
|
||||
"Find or create HEADING in FILE.
|
||||
Switch to that buffer, and return the position of that headline."
|
||||
(find-file file)
|
||||
(widen)
|
||||
(goto-char (point-min))
|
||||
(if (re-search-forward
|
||||
(concat "^\\*+[ \t]+" heading "[ \t]*\\(:.*?:[ \t]*\\)?$")
|
||||
nil t)
|
||||
(goto-char (match-beginning 0))
|
||||
(goto-char (point-max))
|
||||
(insert "\n\n* " heading "\n\n")
|
||||
(org-back-to-heading t))
|
||||
(point))
|
||||
|
||||
(defun org-feed-read-previous-status (pos drawer)
|
||||
"Get the alist of old GUIDs from the entry at POS.
|
||||
This will find DRAWER and extract the alist."
|
||||
(save-excursion
|
||||
(goto-char pos)
|
||||
(let ((end (save-excursion (org-end-of-subtree t t))))
|
||||
(if (re-search-forward
|
||||
(concat "^[ \t]*:" drawer ":[ \t]*\n\\([^\000]*?\\)\n[ \t]*:END:")
|
||||
end t)
|
||||
(read (match-string 1))
|
||||
nil))))
|
||||
|
||||
(defun org-feed-write-status (pos drawer status)
|
||||
"Write the feed STATUS to DRAWER in entry at POS."
|
||||
(save-excursion
|
||||
(goto-char pos)
|
||||
(let ((end (save-excursion (org-end-of-subtree t t)))
|
||||
guid)
|
||||
(if (re-search-forward (concat "^[ \t]*:" drawer ":[ \t]*\n")
|
||||
end t)
|
||||
(progn
|
||||
(goto-char (match-end 0))
|
||||
(delete-region (point)
|
||||
(save-excursion
|
||||
(and (re-search-forward "^[ \t]*:END:" nil t)
|
||||
(match-beginning 0)))))
|
||||
(outline-next-heading)
|
||||
(insert " :" drawer ":\n :END:\n")
|
||||
(beginning-of-line 0))
|
||||
(insert (pp-to-string status)))))
|
||||
|
||||
(defun org-feed-add-items (pos entries)
|
||||
"Add the formatted items to the headline as POS."
|
||||
(let (entry level)
|
||||
(save-excursion
|
||||
(goto-char pos)
|
||||
(unless (looking-at org-complex-heading-regexp)
|
||||
(error "Wrong position"))
|
||||
(setq level (org-get-valid-level (length (match-string 1)) 1))
|
||||
(org-end-of-subtree t t)
|
||||
(skip-chars-backward " \t\n")
|
||||
(beginning-of-line 2)
|
||||
(setq pos (point))
|
||||
(while (setq entry (pop entries))
|
||||
(org-paste-subtree level entry 'yank))
|
||||
(org-mark-ring-push pos))))
|
||||
|
||||
(defun org-feed-format-entry (entry template formatter)
|
||||
"Format ENTRY so that it can be inserted into an Org file.
|
||||
ENTRY is a property list. This function adds a `:formatted-for-org' property
|
||||
and returns the full property list.
|
||||
If that property is already present, nothing changes."
|
||||
(if formatter
|
||||
(funcall formatter entry)
|
||||
(let (dlines fmt tmp indent time name
|
||||
v-h v-t v-T v-u v-U v-a)
|
||||
(setq dlines (org-split-string (or (plist-get entry :description) "???")
|
||||
"\n")
|
||||
v-h (or (plist-get entry :title) (car dlines) "???")
|
||||
time (or (if (plist-get entry :pubDate)
|
||||
(org-read-date t t (plist-get entry :pubDate)))
|
||||
(current-time))
|
||||
v-t (format-time-string (org-time-stamp-format nil nil) time)
|
||||
v-T (format-time-string (org-time-stamp-format t nil) time)
|
||||
v-u (format-time-string (org-time-stamp-format nil t) time)
|
||||
v-U (format-time-string (org-time-stamp-format t t) time)
|
||||
v-a (if (setq tmp (or (and (plist-get entry :guid-permalink)
|
||||
(plist-get entry :guid))
|
||||
(plist-get entry :link)))
|
||||
(concat "[[" tmp "]]\n")
|
||||
""))
|
||||
(with-temp-buffer
|
||||
(insert template)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "%\\([a-zA-Z]+\\)" nil t)
|
||||
(setq name (match-string 1))
|
||||
(cond
|
||||
((member name '("h" "t" "T" "u" "U" "a"))
|
||||
(replace-match (symbol-value (intern (concat "v-" name))) t t))
|
||||
((setq tmp (plist-get entry (intern (concat ":" name))))
|
||||
(save-excursion
|
||||
(save-match-data
|
||||
(beginning-of-line 1)
|
||||
(when (looking-at (concat "^\\([ \t]*\\)%" name "[ \t]*$"))
|
||||
(setq tmp (org-feed-make-indented-block
|
||||
tmp (org-get-indentation))))))
|
||||
(replace-match tmp t t))))
|
||||
(buffer-string)))))
|
||||
|
||||
(defun org-feed-make-indented-block (s n)
|
||||
"Add indentaton of N spaces to a multiline string S."
|
||||
(if (not (string-match "\n" s))
|
||||
s
|
||||
(mapconcat 'identity
|
||||
(org-split-string s "\n")
|
||||
(concat "\n" (make-string n ?\ )))))
|
||||
|
||||
(defun org-feed-skip-http-headers (buffer)
|
||||
"Remove HTTP headers from BUFFER, and return it.
|
||||
Assumes headers are indeed present!"
|
||||
(with-current-buffer buffer
|
||||
(widen)
|
||||
(goto-char (point-min))
|
||||
(search-forward "\n\n")
|
||||
(delete-region (point-min) (point))
|
||||
buffer))
|
||||
|
||||
(defun org-feed-get-feed (url)
|
||||
"Get the RSS feed file at URL and return the buffer."
|
||||
(cond
|
||||
((eq org-feed-retrieve-method 'url-retrieve-synchronously)
|
||||
(org-feed-skip-http-headers (url-retrieve-synchronously url)))
|
||||
((eq org-feed-retrieve-method 'curl)
|
||||
(ignore-errors (kill-buffer org-feed-buffer))
|
||||
(call-process "curl" nil org-feed-buffer nil "--silent" url)
|
||||
org-feed-buffer)
|
||||
((eq org-feed-retrieve-method 'wget)
|
||||
(ignore-errors (kill-buffer org-feed-buffer))
|
||||
(call-process "wget" nil org-feed-buffer nil "-q" "-O" "-" url)
|
||||
org-feed-buffer)
|
||||
((functionp org-feed-retrieve-method)
|
||||
(funcall org-feed-retrieve-method url))))
|
||||
|
||||
(defun org-feed-parse-rss-feed (buffer)
|
||||
"Parse BUFFER for RSS feed entries.
|
||||
Returns a list of entries, with each entry a property list,
|
||||
containing the properties `:guid' and `:item-full-text'."
|
||||
(let (entries beg end item guid entry)
|
||||
(with-current-buffer buffer
|
||||
(widen)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "<item>" nil t)
|
||||
(setq beg (point)
|
||||
end (and (re-search-forward "</item>" nil t)
|
||||
(match-beginning 0)))
|
||||
(setq item (buffer-substring beg end)
|
||||
guid (if (string-match "<guid\\>.*?>\\(.*?\\)</guid>" item)
|
||||
(org-match-string-no-properties 1 item)))
|
||||
(setq entry (list :guid guid :item-full-text item))
|
||||
(push entry entries)
|
||||
(widen)
|
||||
(goto-char end))
|
||||
(nreverse entries))))
|
||||
|
||||
(defun org-feed-parse-rss-entry (entry)
|
||||
"Parse the `:item-full-text' field for xml tags and create new properties."
|
||||
(with-temp-buffer
|
||||
(insert (plist-get entry :item-full-text))
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "<\\([a-zA-Z]+\\>\\).*?>\\([^\000]*?\\)</\\1>"
|
||||
nil t)
|
||||
(setq entry (plist-put entry
|
||||
(intern (concat ":" (match-string 1)))
|
||||
(match-string 2))))
|
||||
(goto-char (point-min))
|
||||
(unless (re-search-forward "isPermaLink[ \t]*=[ \t]*\"false\"" nil t)
|
||||
(setq entry (plist-put entry :guid-permalink t))))
|
||||
entry)
|
||||
|
||||
(defun org-feed-parse-atom-feed (buffer)
|
||||
"Parse BUFFER for Atom feed entries.
|
||||
Returns a list of enttries, with each entry a property list,
|
||||
containing the properties `:guid' and `:item-full-text'.
|
||||
|
||||
The `:item-full-text' property actually contains the sexp
|
||||
formatted as a string, not the original XML data."
|
||||
(with-current-buffer buffer
|
||||
(widen)
|
||||
(let ((feed (car (xml-parse-region (point-min) (point-max)))))
|
||||
(mapcar
|
||||
(lambda (entry)
|
||||
(list
|
||||
:guid (car (xml-node-children (car (xml-get-children entry 'id))))
|
||||
:item-full-text (prin1-to-string entry)))
|
||||
(xml-get-children feed 'entry)))))
|
||||
|
||||
(defun org-feed-parse-atom-entry (entry)
|
||||
"Parse the `:item-full-text' as a sexp and create new properties."
|
||||
(let ((xml (car (read-from-string (plist-get entry :item-full-text)))))
|
||||
;; Get first <link href='foo'/>.
|
||||
(setq entry (plist-put entry :link
|
||||
(xml-get-attribute
|
||||
(car (xml-get-children xml 'link))
|
||||
'href)))
|
||||
;; Add <title/> as :title.
|
||||
(setq entry (plist-put entry :title
|
||||
(car (xml-node-children
|
||||
(car (xml-get-children xml 'title))))))
|
||||
(let* ((content (car (xml-get-children xml 'content)))
|
||||
(type (xml-get-attribute-or-nil content 'type)))
|
||||
(when content
|
||||
(cond
|
||||
((string= type "text")
|
||||
;; We like plain text.
|
||||
(setq entry (plist-put entry :description (car (xml-node-children content)))))
|
||||
((string= type "html")
|
||||
;; TODO: convert HTML to Org markup.
|
||||
(setq entry (plist-put entry :description (car (xml-node-children content)))))
|
||||
((string= type "xhtml")
|
||||
;; TODO: convert XHTML to Org markup.
|
||||
(setq entry (plist-put entry :description (prin1-to-string (xml-node-children content)))))
|
||||
(t
|
||||
(setq entry (plist-put entry :description (format "Unknown '%s' content." type)))))))
|
||||
entry))
|
||||
|
||||
(provide 'org-feed)
|
||||
|
||||
;; arch-tag: 0929b557-9bc4-47f4-9633-30a12dbb5ae2
|
||||
|
||||
;;; org-feed.el ends here
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
@ -45,6 +45,7 @@
|
|||
(declare-function org-show-context "org" (&optional key))
|
||||
(declare-function org-back-to-heading "org" (&optional invisible-ok))
|
||||
(declare-function org-end-of-subtree "org" (&optional invisible-ok to-heading))
|
||||
(defvar org-odd-levels-only) ;; defined in org.el
|
||||
|
||||
(defconst org-footnote-re
|
||||
(concat "[^][\n]" ; to make sure it is not at the beginning of a line
|
||||
|
@ -57,7 +58,7 @@
|
|||
"\\]")
|
||||
"Regular expression for matching footnotes.")
|
||||
|
||||
(defconst org-footnote-definition-re
|
||||
(defconst org-footnote-definition-re
|
||||
(org-re "^\\(\\[\\([0-9]+\\|fn:[-_[:word:]]+\\)\\]\\)")
|
||||
"Regular expression matching the definition of a footnote.")
|
||||
|
||||
|
@ -111,6 +112,23 @@ plain Automatically create plain number labels like [1]"
|
|||
(const :tag "Offer automatic [fn:N] for editing" confirm)
|
||||
(const :tag "Create automatic [N]" plain)))
|
||||
|
||||
(defcustom org-footnote-auto-adjust nil
|
||||
"Non-nil means, automatically adjust footnotes after insert/delete.
|
||||
When this is t, after each insertion or deletion of a footnote,
|
||||
simple fn:N footnotes will be renumbered, and all footnotes will be sorted.
|
||||
If you want to have just sorting or just renumbering, set this variable
|
||||
to `sort' or `renumber'.
|
||||
|
||||
The main values of this variable can be set with in-buffer options:
|
||||
|
||||
#+STARTUP: fnadjust
|
||||
#+STARTUP: nofnadjust"
|
||||
:group 'org-footnote
|
||||
:type '(choice
|
||||
(const :tag "Renumber" renumber)
|
||||
(const :tag "Sort" sort)
|
||||
(const :tag "Renumber and Sort" t)))
|
||||
|
||||
(defcustom org-footnote-fill-after-inline-note-extraction nil
|
||||
"Non-nil means, fill paragraphs after extracting footnotes.
|
||||
When extracting inline footnotes, the lengths of lines can change a lot.
|
||||
|
@ -246,10 +264,12 @@ or new, let the user edit the definition of the footnote."
|
|||
(message "New reference to existing note"))
|
||||
(org-footnote-define-inline
|
||||
(insert "[" label ": ]")
|
||||
(backward-char 1))
|
||||
(backward-char 1)
|
||||
(org-footnote-auto-adjust-maybe))
|
||||
(t
|
||||
(insert "[" label "]")
|
||||
(org-footnote-create-definition label)))))
|
||||
(org-footnote-create-definition label)
|
||||
(org-footnote-auto-adjust-maybe)))))
|
||||
|
||||
(defun org-footnote-create-definition (label)
|
||||
"Start the definition of a footnote with label LABEL."
|
||||
|
@ -295,11 +315,16 @@ With prefix arg SPECIAL, offer additional commands in a menu."
|
|||
(let (tmp c)
|
||||
(cond
|
||||
(special
|
||||
(message "Footnotes: [s]ort | convert to [n]umeric | [d]elete")
|
||||
(message "Footnotes: [s]ort | [r]enumber fn:N | [S]=r+s |->[n]umeric | [d]elete")
|
||||
(setq c (read-char-exclusive))
|
||||
(cond
|
||||
((equal c ?s)
|
||||
(org-footnote-normalize 'sort))
|
||||
((equal c ?r)
|
||||
(org-footnote-renumber-fn:N))
|
||||
((equal c ?S)
|
||||
(org-footnote-renumber-fn:N)
|
||||
(org-footnote-normalize 'sort))
|
||||
((equal c ?n)
|
||||
(org-footnote-normalize))
|
||||
((equal c ?d)
|
||||
|
@ -316,14 +341,24 @@ With prefix arg SPECIAL, offer additional commands in a menu."
|
|||
;;;###autoload
|
||||
(defun org-footnote-normalize (&optional sort-only for-preprocessor)
|
||||
"Collect the footnotes in various formats and normalize them.
|
||||
This find the different sorts of footnotes allowed in Org, and
|
||||
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.
|
||||
When SORT-ONLY is set, only sort the footnote definitions into the
|
||||
referenced sequence."
|
||||
;; This is based on Paul's function, but rewritten.
|
||||
(let ((count 0) ref def idef ref-table beg beg1 marker a before
|
||||
ins-point)
|
||||
(let* ((limit-level
|
||||
(and (boundp 'org-inlinetask-min-level)
|
||||
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)))
|
||||
limit-level)))
|
||||
(outline-regexp
|
||||
(concat "\\*" (if nstars (format "\\{1,%d\\} " nstars) "+ ")))
|
||||
(count 0)
|
||||
ref def idef ref-table beg beg1 marker a before ins-point)
|
||||
(save-excursion
|
||||
;; Now find footnote references, and extract the definitions
|
||||
(goto-char (point-min))
|
||||
|
@ -362,8 +397,8 @@ referenced sequence."
|
|||
(and idef
|
||||
org-footnote-fill-after-inline-note-extraction
|
||||
(fill-paragraph)))
|
||||
(if (not a) (push (list ref marker def) ref-table))))
|
||||
|
||||
(if (not a) (push (list ref marker def (if idef t nil)) ref-table))))
|
||||
|
||||
;; First find and remove the footnote section
|
||||
(goto-char (point-min))
|
||||
(cond
|
||||
|
@ -386,7 +421,7 @@ referenced sequence."
|
|||
(insert "* " org-footnote-section "\n")
|
||||
(setq ins-point (point))))))
|
||||
(t
|
||||
(if (re-search-forward
|
||||
(if (re-search-forward
|
||||
(concat "^"
|
||||
(regexp-quote org-footnote-tag-for-non-org-mode-files)
|
||||
"[ \t]*$")
|
||||
|
@ -397,16 +432,17 @@ referenced sequence."
|
|||
(delete-region (point) (point-max))
|
||||
(insert "\n\n" org-footnote-tag-for-non-org-mode-files "\n")
|
||||
(setq ins-point (point))))
|
||||
|
||||
|
||||
;; Insert the footnotes again
|
||||
(goto-char (or ins-point (point-max)))
|
||||
(setq ref-table (reverse ref-table))
|
||||
(when sort-only
|
||||
;; remove anonymous fotnotes from the list
|
||||
;; remove anonymous and inline footnotes from the list
|
||||
(setq ref-table
|
||||
(delq nil (mapcar
|
||||
(lambda (x) (and (car x)
|
||||
(not (equal (car x) "fn:"))
|
||||
(not (nth 3 x))
|
||||
x))
|
||||
ref-table))))
|
||||
;; Make sure each footnote has a description, or an error message.
|
||||
|
@ -451,12 +487,12 @@ ENTRY is (fn-label num-mark definition)."
|
|||
|
||||
(defun org-footnote-goto-local-insertion-point ()
|
||||
"Find insertion point for footnote, just before next outline heading."
|
||||
(outline-next-heading)
|
||||
(org-with-limited-levels (outline-next-heading))
|
||||
(or (bolp) (newline))
|
||||
(beginning-of-line 0)
|
||||
(while (and (not (bobp)) (= (char-after) ?#))
|
||||
(beginning-of-line 0))
|
||||
(if (looking-at "#\\+TBLFM:") (beginning-of-line 2))
|
||||
(if (looking-at "[ \t]*#\\+TBLFM:") (beginning-of-line 2))
|
||||
(end-of-line 1)
|
||||
(skip-chars-backward "\n\r\t "))
|
||||
|
||||
|
@ -493,9 +529,42 @@ and all references of a footnote label."
|
|||
(goto-char (point-max)))
|
||||
(delete-region beg (point))
|
||||
(incf ndef))))
|
||||
(org-footnote-auto-adjust-maybe)
|
||||
(message "%d definition(s) of and %d reference(s) of footnote %s removed"
|
||||
ndef nref label))))
|
||||
|
||||
(defun org-footnote-renumber-fn:N ()
|
||||
"Renumber the simple footnotes like fn:17 into a sequence in the document."
|
||||
(interactive)
|
||||
(let (map i (n 0))
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(widen)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "\\[fn:\\([0-9]+\\)[]:]" nil t)
|
||||
(setq i (string-to-number (match-string 1)))
|
||||
(when (and (string-match "\\S-" (buffer-substring
|
||||
(point-at-bol) (match-beginning 0)))
|
||||
(not (assq i map)))
|
||||
(push (cons i (number-to-string (incf n))) map)))
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "\\(\\[fn:\\)\\([0-9]+\\)\\([]:]\\)" nil t)
|
||||
(replace-match (concat "\\1" (cdr (assq (string-to-number (match-string 2)) map)) "\\3")))))))
|
||||
|
||||
(defun org-footnote-auto-adjust-maybe ()
|
||||
"Renumber and/or sort footnotes according to user settings."
|
||||
(when (memq org-footnote-auto-adjust '(t renumber))
|
||||
(org-footnote-renumber-fn:N))
|
||||
(when (memq org-footnote-auto-adjust '(t sort))
|
||||
(let ((label (nth 1 (org-footnote-at-definition-p))))
|
||||
(org-footnote-normalize 'sort)
|
||||
(when label
|
||||
(goto-char (point-min))
|
||||
(and (re-search-forward (concat "^\\[" (regexp-quote label) "\\]")
|
||||
nil t)
|
||||
(progn (insert " ")
|
||||
(just-one-space)))))))
|
||||
|
||||
(provide 'org-footnote)
|
||||
|
||||
;; arch-tag: 1b5954df-fb5d-4da5-8709-78d944dbfc37
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
;; Tassilo Horn <tassilo at member dot fsf dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
@ -53,6 +53,9 @@ negates this setting for the duration of the command."
|
|||
;; Declare external functions and variables
|
||||
(declare-function gnus-article-show-summary "gnus-art" ())
|
||||
(declare-function gnus-summary-last-subject "gnus-sum" ())
|
||||
(declare-function message-fetch-field "message" (header &optional not-all))
|
||||
(declare-function message-narrow-to-head-1 "message" nil)
|
||||
|
||||
(defvar gnus-other-frame-object)
|
||||
(defvar gnus-group-name)
|
||||
(defvar gnus-article-current)
|
||||
|
@ -125,6 +128,11 @@ If `org-store-link' was called with a prefix arg the meaning of
|
|||
(header (with-current-buffer gnus-article-buffer
|
||||
(gnus-summary-toggle-header 1)
|
||||
(goto-char (point-min))
|
||||
;; mbox files may contain a first line starting with
|
||||
;; "From" followed by a space, which cannot be parsed as
|
||||
;; header line, so we skip it.
|
||||
(when (looking-at "From ")
|
||||
(beginning-of-line 2))
|
||||
(mail-header-extract-no-properties)))
|
||||
(from (mail-header 'from header))
|
||||
(message-id (org-remove-angle-brackets
|
||||
|
@ -134,7 +142,10 @@ If `org-store-link' was called with a prefix arg the meaning of
|
|||
(newsgroups (mail-header 'newsgroups header))
|
||||
(x-no-archive (mail-header 'x-no-archive header))
|
||||
(subject (if (eq major-mode 'gnus-article-mode)
|
||||
(message-fetch-field "subject")
|
||||
(save-restriction
|
||||
(require 'message)
|
||||
(message-narrow-to-head-1)
|
||||
(message-fetch-field "subject"))
|
||||
(gnus-summary-subject-string)))
|
||||
desc link)
|
||||
(org-store-link-props :type "gnus" :from from :subject subject
|
||||
|
|
2084
lisp/org/org-html.el
Normal file
2084
lisp/org/org-html.el
Normal file
File diff suppressed because it is too large
Load diff
581
lisp/org/org-icalendar.el
Normal file
581
lisp/org/org-icalendar.el
Normal file
|
@ -0,0 +1,581 @@
|
|||
;;; org-icalendar.el --- iCalendar export for Org-mode
|
||||
|
||||
;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
|
||||
;; Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; 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:
|
||||
|
||||
(require 'org-exp)
|
||||
|
||||
(declare-function org-bbdb-anniv-export-ical "org-bbdb" nil)
|
||||
|
||||
(defgroup org-export-icalendar nil
|
||||
"Options specific for iCalendar export of Org-mode files."
|
||||
:tag "Org Export iCalendar"
|
||||
:group 'org-export)
|
||||
|
||||
(defcustom org-combined-agenda-icalendar-file "~/org.ics"
|
||||
"The file name for the iCalendar file covering all agenda files.
|
||||
This file is created with the command \\[org-export-icalendar-all-agenda-files].
|
||||
The file name should be absolute, the file will be overwritten without warning."
|
||||
:group 'org-export-icalendar
|
||||
:type 'file)
|
||||
|
||||
(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-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-include-todo nil
|
||||
"Non-nil means, export to iCalendar files should also cover TODO items.
|
||||
Valid values are:
|
||||
nil don't inlcude any TODO items
|
||||
t include all TODO items that are not in a DONE state
|
||||
unblocked include all TODO idems 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)))
|
||||
|
||||
(defcustom org-icalendar-include-bbdb-anniversaries nil
|
||||
"Non-nil means, a combined iCalendar files should include anniversaries.
|
||||
The anniversaries are define 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 100
|
||||
"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,
|
||||
superceding 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 of the empty string, use the abbreviation retrieved from Emacs."
|
||||
:group 'org-export-icalendar
|
||||
:type '(choice
|
||||
(const :tag "Unspecified" nil)
|
||||
(string :tag "Time zone")))
|
||||
|
||||
;;; iCalendar export
|
||||
|
||||
;;;###autoload
|
||||
(defun org-export-icalendar-this-file ()
|
||||
"Export current file as an iCalendar file.
|
||||
The iCalendar file will be located in the same directory as the Org-mode
|
||||
file, but with extension `.ics'."
|
||||
(interactive)
|
||||
(org-export-icalendar nil buffer-file-name))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-export-icalendar-all-agenda-files ()
|
||||
"Export all files in `org-agenda-files' to iCalendar .ics files.
|
||||
Each iCalendar file will be located in the same directory as the Org-mode
|
||||
file, but with extension `.ics'."
|
||||
(interactive)
|
||||
(apply 'org-export-icalendar nil (org-agenda-files t)))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-export-icalendar-combine-agenda-files ()
|
||||
"Export all files in `org-agenda-files' to a single combined iCalendar file.
|
||||
The file is stored under the name `org-combined-agenda-icalendar-file'."
|
||||
(interactive)
|
||||
(apply 'org-export-icalendar t (org-agenda-files t)))
|
||||
|
||||
(defun org-export-icalendar (combine &rest files)
|
||||
"Create iCalendar files for all elements of FILES.
|
||||
If COMBINE is non-nil, combine all calendar entries into a single large
|
||||
file and store it under the name `org-combined-agenda-icalendar-file'."
|
||||
(save-excursion
|
||||
(org-prepare-agenda-buffers files)
|
||||
(let* ((dir (org-export-directory
|
||||
:ical (list :publishing-directory
|
||||
org-export-publishing-directory)))
|
||||
file ical-file ical-buffer category started org-agenda-new-buffers)
|
||||
(and (get-buffer "*ical-tmp*") (kill-buffer "*ical-tmp*"))
|
||||
(when combine
|
||||
(setq ical-file
|
||||
(if (file-name-absolute-p org-combined-agenda-icalendar-file)
|
||||
org-combined-agenda-icalendar-file
|
||||
(expand-file-name org-combined-agenda-icalendar-file dir))
|
||||
ical-buffer (org-get-agenda-file-buffer ical-file))
|
||||
(set-buffer ical-buffer) (erase-buffer))
|
||||
(while (setq file (pop files))
|
||||
(catch 'nextfile
|
||||
(org-check-agenda-file file)
|
||||
(set-buffer (org-get-agenda-file-buffer file))
|
||||
(unless combine
|
||||
(setq ical-file (concat (file-name-as-directory dir)
|
||||
(file-name-sans-extension
|
||||
(file-name-nondirectory buffer-file-name))
|
||||
".ics"))
|
||||
(setq ical-buffer (org-get-agenda-file-buffer ical-file))
|
||||
(with-current-buffer ical-buffer (erase-buffer)))
|
||||
(setq category (or org-category
|
||||
(file-name-sans-extension
|
||||
(file-name-nondirectory buffer-file-name))))
|
||||
(if (symbolp category) (setq category (symbol-name category)))
|
||||
(let ((standard-output ical-buffer))
|
||||
(if combine
|
||||
(and (not started) (setq started t)
|
||||
(org-start-icalendar-file org-icalendar-combined-name))
|
||||
(org-start-icalendar-file category))
|
||||
(org-print-icalendar-entries combine)
|
||||
(when (or (and combine (not files)) (not combine))
|
||||
(when (and combine org-icalendar-include-bbdb-anniversaries)
|
||||
(require 'org-bbdb)
|
||||
(org-bbdb-anniv-export-ical))
|
||||
(org-finish-icalendar-file)
|
||||
(set-buffer ical-buffer)
|
||||
(run-hooks 'org-before-save-iCalendar-file-hook)
|
||||
(save-buffer)
|
||||
(run-hooks 'org-after-save-iCalendar-file-hook)
|
||||
(and (boundp 'org-wait) (numberp org-wait) (sit-for org-wait))
|
||||
))))
|
||||
(org-release-buffers org-agenda-new-buffers))))
|
||||
|
||||
(defvar org-before-save-iCalendar-file-hook nil
|
||||
"Hook run before an iCalendar file has been saved.
|
||||
This can be used to modify the result of the export.")
|
||||
|
||||
(defvar org-after-save-iCalendar-file-hook nil
|
||||
"Hook run after an iCalendar file has been saved.
|
||||
The iCalendar buffer is still current when this hook is run.
|
||||
A good way to use this is to tell a desktop calendar application to re-read
|
||||
the iCalendar file.")
|
||||
|
||||
(defvar org-agenda-default-appointment-duration) ; defined in org-agenda.el
|
||||
(defun org-print-icalendar-entries (&optional combine)
|
||||
"Print iCalendar entries for the current Org-mode file to `standard-output'.
|
||||
When COMBINE is non nil, add the category to each line."
|
||||
(require 'org-agenda)
|
||||
(let ((re1 (concat org-ts-regexp "\\|<%%([^>\n]+>"))
|
||||
(re2 (concat "--?-?\\(" org-ts-regexp "\\)"))
|
||||
(dts (org-ical-ts-to-string
|
||||
(format-time-string (cdr org-time-stamp-formats) (current-time))
|
||||
"DTSTART"))
|
||||
hd ts ts2 state status (inc t) pos b sexp rrule
|
||||
scheduledp deadlinep todo prefix due start
|
||||
tmp pri categories location summary desc uid
|
||||
(sexp-buffer (get-buffer-create "*ical-tmp*")))
|
||||
(org-refresh-category-properties)
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward re1 nil t)
|
||||
(catch :skip
|
||||
(org-agenda-skip)
|
||||
(when (boundp 'org-icalendar-verify-function)
|
||||
(unless (funcall org-icalendar-verify-function)
|
||||
(outline-next-heading)
|
||||
(backward-char 1)
|
||||
(throw :skip nil)))
|
||||
(setq pos (match-beginning 0)
|
||||
ts (match-string 0)
|
||||
inc t
|
||||
hd (condition-case nil
|
||||
(org-icalendar-cleanup-string
|
||||
(org-get-heading))
|
||||
(error (throw :skip nil)))
|
||||
summary (org-icalendar-cleanup-string
|
||||
(org-entry-get nil "SUMMARY"))
|
||||
desc (org-icalendar-cleanup-string
|
||||
(or (org-entry-get nil "DESCRIPTION")
|
||||
(and org-icalendar-include-body (org-get-entry)))
|
||||
t org-icalendar-include-body)
|
||||
location (org-icalendar-cleanup-string
|
||||
(org-entry-get nil "LOCATION" 'selective))
|
||||
uid (if org-icalendar-store-UID
|
||||
(org-id-get-create)
|
||||
(or (org-id-get) (org-id-new)))
|
||||
categories (org-export-get-categories)
|
||||
deadlinep nil scheduledp nil)
|
||||
(if (looking-at re2)
|
||||
(progn
|
||||
(goto-char (match-end 0))
|
||||
(setq ts2 (match-string 1)
|
||||
inc (not (string-match "[0-9]\\{1,2\\}:[0-9][0-9]" ts2))))
|
||||
(setq tmp (buffer-substring (max (point-min)
|
||||
(- pos org-ds-keyword-length))
|
||||
pos)
|
||||
ts2 (if (string-match "[0-9]\\{1,2\\}:[0-9][0-9]-\\([0-9]\\{1,2\\}:[0-9][0-9]\\)" ts)
|
||||
(progn
|
||||
(setq inc nil)
|
||||
(replace-match "\\1" t nil ts))
|
||||
ts)
|
||||
deadlinep (string-match org-deadline-regexp tmp)
|
||||
scheduledp (string-match org-scheduled-regexp tmp)
|
||||
todo (org-get-todo-state)
|
||||
;; donep (org-entry-is-done-p)
|
||||
))
|
||||
(when (and
|
||||
deadlinep
|
||||
(if todo
|
||||
(not (memq 'event-if-todo org-icalendar-use-deadline))
|
||||
(not (memq 'event-if-not-todo org-icalendar-use-deadline))))
|
||||
(throw :skip t))
|
||||
(when (and
|
||||
scheduledp
|
||||
(if todo
|
||||
(not (memq 'event-if-todo org-icalendar-use-scheduled))
|
||||
(not (memq 'event-if-not-todo org-icalendar-use-scheduled))))
|
||||
(throw :skip t))
|
||||
(setq prefix (if deadlinep "DL-" (if scheduledp "SC-" "TS-")))
|
||||
(if (or (string-match org-tr-regexp hd)
|
||||
(string-match org-ts-regexp hd))
|
||||
(setq hd (replace-match "" t t hd)))
|
||||
(if (string-match "\\+\\([0-9]+\\)\\([dwmy]\\)>" ts)
|
||||
(setq rrule
|
||||
(concat "\nRRULE:FREQ="
|
||||
(cdr (assoc
|
||||
(match-string 2 ts)
|
||||
'(("d" . "DAILY")("w" . "WEEKLY")
|
||||
("m" . "MONTHLY")("y" . "YEARLY"))))
|
||||
";INTERVAL=" (match-string 1 ts)))
|
||||
(setq rrule ""))
|
||||
(setq summary (or summary hd))
|
||||
(if (string-match org-bracket-link-regexp summary)
|
||||
(setq summary
|
||||
(replace-match (if (match-end 3)
|
||||
(match-string 3 summary)
|
||||
(match-string 1 summary))
|
||||
t t summary)))
|
||||
(if deadlinep (setq summary (concat "DL: " summary)))
|
||||
(if scheduledp (setq summary (concat "S: " summary)))
|
||||
(if (string-match "\\`<%%" ts)
|
||||
(with-current-buffer sexp-buffer
|
||||
(insert (substring ts 1 -1) " " summary "\n"))
|
||||
(princ (format "BEGIN:VEVENT
|
||||
UID: %s
|
||||
%s
|
||||
%s%s
|
||||
SUMMARY:%s%s%s
|
||||
CATEGORIES:%s
|
||||
END:VEVENT\n"
|
||||
(concat prefix uid)
|
||||
(org-ical-ts-to-string ts "DTSTART")
|
||||
(org-ical-ts-to-string ts2 "DTEND" inc)
|
||||
rrule summary
|
||||
(if (and desc (string-match "\\S-" desc))
|
||||
(concat "\nDESCRIPTION: " desc) "")
|
||||
(if (and location (string-match "\\S-" location))
|
||||
(concat "\nLOCATION: " location) "")
|
||||
categories)))))
|
||||
(when (and org-icalendar-include-sexps
|
||||
(condition-case nil (require 'icalendar) (error nil))
|
||||
(fboundp 'icalendar-export-region))
|
||||
;; Get all the literal sexps
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "^&?%%(" nil t)
|
||||
(catch :skip
|
||||
(org-agenda-skip)
|
||||
(setq b (match-beginning 0))
|
||||
(goto-char (1- (match-end 0)))
|
||||
(forward-sexp 1)
|
||||
(end-of-line 1)
|
||||
(setq sexp (buffer-substring b (point)))
|
||||
(with-current-buffer sexp-buffer
|
||||
(insert sexp "\n"))))
|
||||
(princ (org-diary-to-ical-string sexp-buffer))
|
||||
(kill-buffer sexp-buffer))
|
||||
|
||||
(when org-icalendar-include-todo
|
||||
(setq prefix "TODO-")
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward org-todo-line-regexp nil t)
|
||||
(catch :skip
|
||||
(org-agenda-skip)
|
||||
(when (boundp 'org-icalendar-verify-function)
|
||||
(unless (save-match-data
|
||||
(funcall org-icalendar-verify-function))
|
||||
(outline-next-heading)
|
||||
(backward-char 1)
|
||||
(throw :skip nil)))
|
||||
(setq state (match-string 2))
|
||||
(setq status (if (member state org-done-keywords)
|
||||
"COMPLETED" "NEEDS-ACTION"))
|
||||
(when (and state
|
||||
(cond
|
||||
;; check if the state is one we should use
|
||||
((eq org-icalendar-include-todo 'all)
|
||||
;; all should be included
|
||||
t)
|
||||
((eq org-icalendar-include-todo 'unblocked)
|
||||
;; only undone entries that are not blocked
|
||||
(and (member state org-not-done-keywords)
|
||||
(or (not org-blocker-hook)
|
||||
(save-match-data
|
||||
(run-hook-with-args-until-failure
|
||||
'org-blocker-hook
|
||||
(list :type 'todo-state-change
|
||||
:position (point-at-bol)
|
||||
:from 'todo
|
||||
:to 'done))))))
|
||||
((eq org-icalendar-include-todo t)
|
||||
;; include everything that is not done
|
||||
(member state org-not-done-keywords))))
|
||||
(setq hd (match-string 3)
|
||||
summary (org-icalendar-cleanup-string
|
||||
(org-entry-get nil "SUMMARY"))
|
||||
desc (org-icalendar-cleanup-string
|
||||
(or (org-entry-get nil "DESCRIPTION")
|
||||
(and org-icalendar-include-body (org-get-entry)))
|
||||
t org-icalendar-include-body)
|
||||
location (org-icalendar-cleanup-string
|
||||
(org-entry-get nil "LOCATION" 'selective))
|
||||
due (and (member 'todo-due org-icalendar-use-deadline)
|
||||
(org-entry-get nil "DEADLINE"))
|
||||
start (and (member 'todo-start org-icalendar-use-scheduled)
|
||||
(org-entry-get nil "SCHEDULED"))
|
||||
categories (org-export-get-categories)
|
||||
uid (if org-icalendar-store-UID
|
||||
(org-id-get-create)
|
||||
(or (org-id-get) (org-id-new))))
|
||||
(and due (setq due (org-ical-ts-to-string due "DUE")))
|
||||
(and start (setq start (org-ical-ts-to-string start "DTSTART")))
|
||||
|
||||
(if (string-match org-bracket-link-regexp hd)
|
||||
(setq hd (replace-match (if (match-end 3) (match-string 3 hd)
|
||||
(match-string 1 hd))
|
||||
t t hd)))
|
||||
(if (string-match org-priority-regexp hd)
|
||||
(setq pri (string-to-char (match-string 2 hd))
|
||||
hd (concat (substring hd 0 (match-beginning 1))
|
||||
(substring hd (match-end 1))))
|
||||
(setq pri org-default-priority))
|
||||
(setq pri (floor (- 9 (* 8. (/ (float (- org-lowest-priority pri))
|
||||
(- org-lowest-priority org-highest-priority))))))
|
||||
|
||||
(princ (format "BEGIN:VTODO
|
||||
UID: %s
|
||||
%s
|
||||
SUMMARY:%s%s%s%s
|
||||
CATEGORIES:%s
|
||||
SEQUENCE:1
|
||||
PRIORITY:%d
|
||||
STATUS:%s
|
||||
END:VTODO\n"
|
||||
(concat prefix uid)
|
||||
(or start dts)
|
||||
(or summary hd)
|
||||
(if (and location (string-match "\\S-" location))
|
||||
(concat "\nLOCATION: " location) "")
|
||||
(if (and desc (string-match "\\S-" desc))
|
||||
(concat "\nDESCRIPTION: " desc) "")
|
||||
(if due (concat "\n" due) "")
|
||||
categories
|
||||
pri status)))))))))
|
||||
|
||||
(defun org-export-get-categories ()
|
||||
"Get categories according to `org-icalendar-categories'."
|
||||
(let ((cs org-icalendar-categories) c rtn tmp)
|
||||
(while (setq c (pop cs))
|
||||
(cond
|
||||
((eq c 'category) (push (org-get-category) rtn))
|
||||
((eq c 'todo-state)
|
||||
(setq tmp (org-get-todo-state))
|
||||
(and tmp (push tmp rtn)))
|
||||
((eq c 'local-tags)
|
||||
(setq rtn (append (nreverse (org-get-local-tags-at (point))) rtn)))
|
||||
((eq c 'all-tags)
|
||||
(setq rtn (append (nreverse (org-get-tags-at (point))) rtn)))))
|
||||
(mapconcat 'identity (nreverse rtn) ",")))
|
||||
|
||||
(defun org-icalendar-cleanup-string (s &optional is-body maxlength)
|
||||
"Take out stuff and quote what needs to be quoted.
|
||||
When IS-BODY is non-nil, assume that this is the body of an item, clean up
|
||||
whitespace, newlines, drawers, and timestamps, and cut it down to MAXLENGTH
|
||||
characters."
|
||||
(if (not s)
|
||||
nil
|
||||
(when is-body
|
||||
(let ((re (concat "\\(" org-drawer-regexp "\\)[^\000]*?:END:.*\n?"))
|
||||
(re2 (concat "^[ \t]*" org-keyword-time-regexp ".*\n?")))
|
||||
(while (string-match re s) (setq s (replace-match "" t t s)))
|
||||
(while (string-match re2 s) (setq s (replace-match "" t t s)))))
|
||||
(let ((start 0))
|
||||
(while (string-match "\\([,;]\\)" s start)
|
||||
(setq start (+ (match-beginning 0) 2)
|
||||
s (replace-match "\\\\\\1" nil nil s))))
|
||||
(setq s (org-trim s))
|
||||
(when is-body
|
||||
(while (string-match "[ \t]*\n[ \t]*" s)
|
||||
(setq s (replace-match "\\n" t t s))))
|
||||
(if is-body
|
||||
(if maxlength
|
||||
(if (and (numberp maxlength)
|
||||
(> (length s) maxlength))
|
||||
(setq s (substring s 0 maxlength)))))
|
||||
s))
|
||||
|
||||
(defun org-icalendar-cleanup-string-rfc2455 (s &optional is-body maxlength)
|
||||
"Take out stuff and quote what needs to be quoted.
|
||||
When IS-BODY is non-nil, assume that this is the body of an item, clean up
|
||||
whitespace, newlines, drawers, and timestamps, and cut it down to MAXLENGTH
|
||||
characters.
|
||||
This seems to be more like RFC 2455, but it causes problems, so it is
|
||||
not used right now."
|
||||
(if (not s)
|
||||
nil
|
||||
(if is-body
|
||||
(let ((re (concat "\\(" org-drawer-regexp "\\)[^\000]*?:END:.*\n?"))
|
||||
(re2 (concat "^[ \t]*" org-keyword-time-regexp ".*\n?")))
|
||||
(while (string-match re s) (setq s (replace-match "" t t s)))
|
||||
(while (string-match re2 s) (setq s (replace-match "" t t s)))
|
||||
(setq s (org-trim s))
|
||||
(while (string-match "[ \t]*\n[ \t]*" s)
|
||||
(setq s (replace-match "\\n" t t s)))
|
||||
(if maxlength
|
||||
(if (and (numberp maxlength)
|
||||
(> (length s) maxlength))
|
||||
(setq s (substring s 0 maxlength)))))
|
||||
(setq s (org-trim s)))
|
||||
(while (string-match "\"" s) (setq s (replace-match "''" t t s)))
|
||||
(when (string-match "[;,:]" s) (setq s (concat "\"" s "\"")))
|
||||
s))
|
||||
|
||||
(defun org-start-icalendar-file (name)
|
||||
"Start an iCalendar file by inserting the header."
|
||||
(let ((user user-full-name)
|
||||
(name (or name "unknown"))
|
||||
(timezone (if (> (length org-icalendar-timezone) 0)
|
||||
org-icalendar-timezone
|
||||
(cadr (current-time-zone)))))
|
||||
(princ
|
||||
(format "BEGIN:VCALENDAR
|
||||
VERSION:2.0
|
||||
X-WR-CALNAME:%s
|
||||
PRODID:-//%s//Emacs with Org-mode//EN
|
||||
X-WR-TIMEZONE:%s
|
||||
CALSCALE:GREGORIAN\n" name user timezone))))
|
||||
|
||||
(defun org-finish-icalendar-file ()
|
||||
"Finish an iCalendar file by inserting the END statement."
|
||||
(princ "END:VCALENDAR\n"))
|
||||
|
||||
(defun org-ical-ts-to-string (s keyword &optional inc)
|
||||
"Take a time string S and convert it to iCalendar format.
|
||||
KEYWORD is added in front, to make a complete line like DTSTART....
|
||||
When INC is non-nil, increase the hour by two (if time string contains
|
||||
a time), or the day by one (if it does not contain a time)."
|
||||
(let ((t1 (org-parse-time-string s 'nodefault))
|
||||
t2 fmt have-time time)
|
||||
(if (and (car t1) (nth 1 t1) (nth 2 t1))
|
||||
(setq t2 t1 have-time t)
|
||||
(setq t2 (org-parse-time-string s)))
|
||||
(let ((s (car t2)) (mi (nth 1 t2)) (h (nth 2 t2))
|
||||
(d (nth 3 t2)) (m (nth 4 t2)) (y (nth 5 t2)))
|
||||
(when inc
|
||||
(if have-time
|
||||
(if org-agenda-default-appointment-duration
|
||||
(setq mi (+ org-agenda-default-appointment-duration mi))
|
||||
(setq h (+ 2 h)))
|
||||
(setq d (1+ d))))
|
||||
(setq time (encode-time s mi h d m y)))
|
||||
(setq fmt (if have-time ":%Y%m%dT%H%M%S" ";VALUE=DATE:%Y%m%d"))
|
||||
(concat keyword (format-time-string fmt time))))
|
||||
|
||||
(provide 'org-icalendar)
|
||||
|
||||
;; arch-tag: 2dee2b6e-9211-4aee-8a47-a3c7e5bc30cf
|
||||
|
||||
;;; org-icalendar.el ends here
|
|
@ -5,7 +5,7 @@
|
|||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
@ -79,11 +79,16 @@
|
|||
:tag "Org ID"
|
||||
:group 'org)
|
||||
|
||||
(defcustom org-id-uuid-program "uuidgen"
|
||||
"The uuidgen program."
|
||||
:group 'org-id
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-id-method
|
||||
(condition-case nil
|
||||
(if (string-match "\\`[-0-9a-fA-F]\\{36\\}\\'"
|
||||
(org-trim (shell-command-to-string "uuidgen")))
|
||||
(org-trim (shell-command-to-string
|
||||
org-id-uuid-program)))
|
||||
'uuidgen
|
||||
'org)
|
||||
(error 'org))
|
||||
|
@ -197,7 +202,7 @@ With optional argument FORCE, force the creation of a new ID."
|
|||
"Copy the ID of the entry at point to the kill ring.
|
||||
Create an ID if necessary."
|
||||
(interactive)
|
||||
(kill-new (org-id-get nil 'create)))
|
||||
(org-kill-new (org-id-get nil 'create)))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-id-get (&optional pom create prefix)
|
||||
|
@ -228,6 +233,7 @@ It returns the ID of the entry. If necessary, the ID is created."
|
|||
(let* ((org-refile-targets (or targets '((nil . (:maxlevel . 10)))))
|
||||
(org-refile-use-outline-path
|
||||
(if (caar org-refile-targets) 'file t))
|
||||
(org-refile-target-verify-function nil)
|
||||
(spos (org-refile-get-location "Entry: "))
|
||||
(pom (and spos (move-marker (make-marker) (nth 3 spos)
|
||||
(get-file-buffer (nth 1 spos))))))
|
||||
|
@ -300,7 +306,7 @@ So a typical ID could look like \"Org:4nd91V40HI\"."
|
|||
(if (equal prefix ":") (setq prefix ""))
|
||||
(cond
|
||||
((eq org-id-method 'uuidgen)
|
||||
(setq unique (org-trim (shell-command-to-string "uuidgen"))))
|
||||
(setq unique (org-trim (shell-command-to-string org-id-uuid-program))))
|
||||
((eq org-id-method 'org)
|
||||
(let* ((etime (org-id-reverse-string (org-id-time-to-b36)))
|
||||
(postfix (if org-id-include-domain
|
||||
|
@ -571,11 +577,22 @@ optional argument MARKERP, return the position as a new marker."
|
|||
(defun org-id-open (id)
|
||||
"Go to the entry with id ID."
|
||||
(org-mark-ring-push)
|
||||
(let ((m (org-id-find id 'marker)))
|
||||
(let ((m (org-id-find id 'marker))
|
||||
cmd)
|
||||
(unless m
|
||||
(error "Cannot find entry with ID \"%s\"" id))
|
||||
;; Use a buffer-switching command in analogy to finding files
|
||||
(setq cmd
|
||||
(or
|
||||
(cdr
|
||||
(assq
|
||||
(cdr (assq 'file org-link-frame-setup))
|
||||
'((find-file . switch-to-buffer)
|
||||
(find-file-other-window . switch-to-buffer-other-window)
|
||||
(find-file-other-frame . switch-to-buffer-other-frame))))
|
||||
'switch-to-buffer-other-window))
|
||||
(if (not (equal (current-buffer) (marker-buffer m)))
|
||||
(switch-to-buffer-other-window (marker-buffer m)))
|
||||
(funcall cmd (marker-buffer m)))
|
||||
(goto-char m)
|
||||
(move-marker m nil)
|
||||
(org-show-context)))
|
||||
|
|
283
lisp/org/org-indent.el
Normal file
283
lisp/org/org-indent.el
Normal file
|
@ -0,0 +1,283 @@
|
|||
;;; org-indent.el --- Dynamic indentation for Org-mode
|
||||
;; Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
;;
|
||||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
;; This file 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.
|
||||
|
||||
;; 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; 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 is an implementation of dynamic virtual indentation. It works
|
||||
;; by adding text properties to a buffer to make sure lines are
|
||||
;; indented according to outline structure.
|
||||
|
||||
(require 'org-macs)
|
||||
(require 'org-compat)
|
||||
(require 'org)
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
|
||||
|
||||
(defgroup org-indent nil
|
||||
"Options concerning dynamic virtual outline indentation."
|
||||
:tag "Org Structure"
|
||||
:group 'org)
|
||||
|
||||
(defconst org-indent-max 40
|
||||
"Maximum indentation in characters")
|
||||
(defconst org-indent-max-levels 40
|
||||
"Maximum indentation in characters")
|
||||
|
||||
(defvar org-indent-strings nil
|
||||
"Vector with all indentation strings.
|
||||
It will be set in `org-indent-initialize'.")
|
||||
(defvar org-indent-stars nil
|
||||
"Vector with all indentation star strings.
|
||||
It will be set in `org-indent-initialize'.")
|
||||
(defvar org-hide-leading-stars-before-indent-mode nil
|
||||
"Used locally")
|
||||
|
||||
(defcustom org-indent-boundary-char ?\ ; comment to protect space char
|
||||
"The end of the virtual indentation strings, a single-character string.
|
||||
The default is just a space, but if you wish, you can use \"|\" or so.
|
||||
This can be useful on a terminal window - under a windowing system,
|
||||
it may be prettier to customize the org-indent face."
|
||||
:group 'org-indent
|
||||
:set (lambda (var val)
|
||||
(set var val)
|
||||
(and org-indent-strings (org-indent-initialize)))
|
||||
:type 'character)
|
||||
|
||||
(defcustom org-indent-mode-turns-off-org-adapt-indentation t
|
||||
"Non-nil means, turning on org-indent-mode turns off indentation adaptation.
|
||||
For details see the variable `org-adapt-indentation'."
|
||||
:group 'org-indent
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-indent-mode-turns-on-hiding-stars t
|
||||
"Non-nil means, turning on org-indent-mode turns on `org-hide-leading-stars'."
|
||||
:group 'org-indent
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-indent-indentation-per-level 2
|
||||
"Indentation per level in number of characters."
|
||||
:group 'org-indent
|
||||
:type 'integer)
|
||||
|
||||
(defcustom org-indent-fix-section-after-idle-time 0.2
|
||||
"Seconds of idle time before fixing virtual indentation of section.
|
||||
The hooking-in of virtual indentation is not yet perfect. Occasionally,
|
||||
a change does not trigger to proper change of indentation. For this we
|
||||
have a timer action that fixes indentation in the current section after
|
||||
a short amount idle time. If we ever get the integration to work perfectly,
|
||||
this variable can be set to nil to get rid of the timer."
|
||||
:group 'org-indent
|
||||
:type '(choice
|
||||
(const "Do not install idle timer" nil)
|
||||
(number :tag "Idle time")))
|
||||
|
||||
(defun org-indent-initialize ()
|
||||
"Initialize the indentation strings and set the idle timer."
|
||||
;; We use an idle timer to "repair" the current section, because the
|
||||
;; redisplay seems to have some problems.
|
||||
(unless org-indent-strings
|
||||
(when org-indent-fix-section-after-idle-time
|
||||
(run-with-idle-timer
|
||||
org-indent-fix-section-after-idle-time
|
||||
t 'org-indent-refresh-section)))
|
||||
;; Initialize the indentation and star vectors
|
||||
(setq org-indent-strings (make-vector (1+ org-indent-max) nil))
|
||||
(setq org-indent-stars (make-vector (1+ org-indent-max) nil))
|
||||
(aset org-indent-strings 0 "")
|
||||
(aset org-indent-stars 0 "")
|
||||
(loop for i from 1 to org-indent-max do
|
||||
(aset org-indent-strings i
|
||||
(org-add-props
|
||||
(concat (make-string (1- i) ?\ )
|
||||
(char-to-string org-indent-boundary-char))
|
||||
nil 'face 'org-indent)))
|
||||
(loop for i from 1 to org-indent-max-levels do
|
||||
(aset org-indent-stars i
|
||||
(org-add-props (make-string i ?*)
|
||||
nil 'face 'org-hide))))
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode org-indent-mode
|
||||
"When active, indent text according to outline structure.
|
||||
|
||||
Internally this works by adding `line-prefix' properties to all non-headlines.
|
||||
These properties are updated locally in idle time.
|
||||
FIXME: How to update when broken?"
|
||||
nil " Ind" nil
|
||||
(if (org-bound-and-true-p org-inhibit-startup)
|
||||
(setq org-indent-mode nil)
|
||||
(if org-indent-mode
|
||||
(progn
|
||||
(or org-indent-strings (org-indent-initialize))
|
||||
(when org-indent-mode-turns-off-org-adapt-indentation
|
||||
(org-set-local 'org-adapt-indentation nil))
|
||||
(when org-indent-mode-turns-on-hiding-stars
|
||||
(org-set-local 'org-hide-leading-stars-before-indent-mode
|
||||
org-hide-leading-stars)
|
||||
(org-set-local 'org-hide-leading-stars t))
|
||||
(make-local-variable 'buffer-substring-filters)
|
||||
(add-to-list 'buffer-substring-filters
|
||||
'org-indent-remove-properties-from-string)
|
||||
(org-add-hook 'org-after-demote-entry-hook
|
||||
'org-indent-refresh-section nil 'local)
|
||||
(org-add-hook 'org-after-promote-entry-hook
|
||||
'org-indent-refresh-section nil 'local)
|
||||
(org-add-hook 'org-font-lock-hook
|
||||
'org-indent-refresh-to nil 'local)
|
||||
(and font-lock-mode (org-restart-font-lock))
|
||||
)
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(org-indent-remove-properties (point-min) (point-max))
|
||||
(kill-local-variable 'org-adapt-indentation)
|
||||
(when (boundp 'org-hide-leading-stars-before-indent-mode)
|
||||
(org-set-local 'org-hide-leading-stars
|
||||
org-hide-leading-stars-before-indent-mode))
|
||||
(setq buffer-substring-filters
|
||||
(delq 'org-indent-remove-properties-from-string
|
||||
buffer-substring-filters))
|
||||
(remove-hook 'org-after-promote-entry-hook
|
||||
'org-indent-refresh-section 'local)
|
||||
(remove-hook 'org-after-demote-entry-hook
|
||||
'org-indent-refresh-section 'local)
|
||||
(and font-lock-mode (org-restart-font-lock))
|
||||
(redraw-display))))))
|
||||
|
||||
|
||||
(defface org-indent
|
||||
(org-compatible-face nil nil)
|
||||
"Face for outline indentation.
|
||||
The default is to make it look like whitespace. But you may find it
|
||||
useful to make it evver so slightly different."
|
||||
:group 'org-faces)
|
||||
|
||||
(defun org-indent-indent-buffer ()
|
||||
"Add indentation properties for the whole buffer."
|
||||
(interactive)
|
||||
(when org-indent-mode
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(widen)
|
||||
(org-indent-remove-properties (point-min) (point-max))
|
||||
(org-indent-add-properties (point-min) (point-max))))))
|
||||
|
||||
(defun org-indent-remove-properties (beg end)
|
||||
"Remove indentations between BEG and END."
|
||||
(org-unmodified
|
||||
(remove-text-properties beg end '(line-prefix nil wrap-prefix nil))))
|
||||
|
||||
(defun org-indent-remove-properties-from-string (string)
|
||||
"Remove indentations between BEG and END."
|
||||
(remove-text-properties 0 (length string)
|
||||
'(line-prefix nil wrap-prefix nil) string)
|
||||
string)
|
||||
|
||||
(defvar org-indent-outline-re (concat "^" org-outline-regexp)
|
||||
"Outline heading regexp.")
|
||||
|
||||
(defun org-indent-add-properties (beg end)
|
||||
"Add indentation properties between BEG and END.
|
||||
Assumes that BEG is at the beginning of a line."
|
||||
(when (or t org-indent-mode)
|
||||
(let (ov b e n level exit nstars)
|
||||
(org-unmodified
|
||||
(save-excursion
|
||||
(goto-char beg)
|
||||
(while (not exit)
|
||||
(setq e end)
|
||||
(if (not (re-search-forward org-indent-outline-re nil t))
|
||||
(setq e (point-max) exit t)
|
||||
(setq e (match-beginning 0))
|
||||
(if (>= e end) (setq exit t))
|
||||
(setq level (- (match-end 0) (match-beginning 0) 1))
|
||||
(setq nstars (- (* (1- level) org-indent-indentation-per-level)
|
||||
(1- level)))
|
||||
(add-text-properties
|
||||
(point-at-bol) (point-at-eol)
|
||||
(list 'line-prefix
|
||||
(aref org-indent-stars nstars)
|
||||
'wrap-prefix
|
||||
(aref org-indent-strings
|
||||
(* level org-indent-indentation-per-level)))))
|
||||
(when (and b (> e b))
|
||||
(add-text-properties
|
||||
b e (list 'line-prefix (aref org-indent-strings n)
|
||||
'wrap-prefix (aref org-indent-strings n))))
|
||||
(setq b (1+ (point-at-eol))
|
||||
n (* level org-indent-indentation-per-level))))))))
|
||||
|
||||
(defun org-indent-refresh-section ()
|
||||
"Refresh indentation properties in the current outline section.
|
||||
Point is assumed to be at the beginning of a headline."
|
||||
(interactive)
|
||||
(when org-indent-mode
|
||||
(let (beg end)
|
||||
(save-excursion
|
||||
(when (ignore-errors (org-back-to-heading))
|
||||
(setq beg (point))
|
||||
(setq end (or (save-excursion (or (outline-next-heading) (point)))))
|
||||
(org-indent-remove-properties beg end)
|
||||
(org-indent-add-properties beg end))))))
|
||||
|
||||
(defun org-indent-refresh-to (limit)
|
||||
"Refresh indentation properties in the current outline section.
|
||||
Point is assumed to be at the beginning of a headline."
|
||||
(interactive)
|
||||
(when org-indent-mode
|
||||
(let ((beg (point)) (end limit))
|
||||
(save-excursion
|
||||
(and (ignore-errors (org-back-to-heading t))
|
||||
(setq beg (point))))
|
||||
(org-indent-remove-properties beg end)
|
||||
(org-indent-add-properties beg end)))
|
||||
(goto-char limit))
|
||||
|
||||
(defun org-indent-refresh-subtree ()
|
||||
"Refresh indentation properties in the current outline subtree.
|
||||
Point is assumed to be at the beginning of a headline."
|
||||
(interactive)
|
||||
(when org-indent-mode
|
||||
(save-excursion
|
||||
(let (beg end)
|
||||
(setq beg (point))
|
||||
(setq end (save-excursion (org-end-of-subtree t t)))
|
||||
(org-indent-remove-properties beg end)
|
||||
(org-indent-add-properties beg end)))))
|
||||
|
||||
(defun org-indent-refresh-buffer ()
|
||||
"Refresh indentation properties in the current outline subtree.
|
||||
Point is assumed to be at the beginning of a headline."
|
||||
(interactive)
|
||||
(when org-indent-mode
|
||||
(org-indent-mode -1)
|
||||
(org-indent-mode 1)))
|
||||
|
||||
(provide 'org-indent)
|
||||
|
||||
;;; org-indent.el ends here
|
||||
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
|
199
lisp/org/org-inlinetask.el
Normal file
199
lisp/org/org-inlinetask.el
Normal file
|
@ -0,0 +1,199 @@
|
|||
;;; org-inlinetask.el --- Tasks independent of outline hierarchy
|
||||
;; Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
;;
|
||||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; This file is not yet 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, 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; 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 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.
|
||||
;;
|
||||
;; 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 orther 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.
|
||||
;;
|
||||
;; 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.
|
||||
;;
|
||||
;; Inline tasks are normally assumed to contain at most a time planning
|
||||
;; line (DEADLINE etc) after it, and then any number of drawers, for
|
||||
;; example LOGBOOK of PROPERTIES. No empty lines are allowed.
|
||||
;; If you need to have normal text as part of an inline task, you
|
||||
;; can do so by adding an "END" headline with the same number of stars,
|
||||
;; for example
|
||||
;;
|
||||
;; **************** TODO some small task
|
||||
;; DEADLINE: <2009-03-30 Mon>
|
||||
;; :PROPERTIES:
|
||||
;; :SOMETHING: or other
|
||||
;; :END:
|
||||
;; And here is some extra text
|
||||
;; **************** END
|
||||
;;
|
||||
;; Also, if you want to use refiling and archiving for inline tasks,
|
||||
;; The END line must be present to make things work properly.
|
||||
;;
|
||||
;; This package installs one new comand:
|
||||
;;
|
||||
;; C-c C-x t Insert a new inline task with END line
|
||||
|
||||
|
||||
;;; Code
|
||||
|
||||
(require 'org)
|
||||
|
||||
(defgroup org-inlinetask nil
|
||||
"Options concerning inline tasks in Org mode."
|
||||
:tag "Org Inline Tasks"
|
||||
:group 'org-structure)
|
||||
|
||||
(defcustom org-inlinetask-min-level 15
|
||||
"Minimum level a headline must have before it is treated as an inline task.
|
||||
It is strongly recommended that you set `org-cycle-max-level' not at all,
|
||||
or to a number smaller than this one. In fact, when `org-cycle-max-level' is
|
||||
not set, it will be assumed to be one less than the value of smaller than
|
||||
the value of this variable."
|
||||
:group 'org-inlinetask
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-inlinetask-export 'arrow+content
|
||||
"What should be done with inlinetasks upon export?
|
||||
Possible values:
|
||||
|
||||
nil Remove entirely, headline and \"content\"
|
||||
arrow Insert heading in bold, preceeded by an arrow
|
||||
arrow+content Insert arrow and headline, add content below in an
|
||||
#+begin_example box (ugly, but works for now)
|
||||
|
||||
The \"content\" of an inline task is the material below the planning
|
||||
line and any drawers, up to a lines wit the same number of stars,
|
||||
but containing only the word END."
|
||||
:group 'org-inlinetask
|
||||
:group 'org-export-general
|
||||
:type '(choice
|
||||
(const :tag "Remove entirely" nil)
|
||||
(const :tag "Headline preceeded by arrow" arrow)
|
||||
(const :tag "Arrow, headline, + content" arrow+content)))
|
||||
|
||||
(defvar org-odd-levels-only)
|
||||
(defvar org-keyword-time-regexp)
|
||||
(defvar org-drawer-regexp)
|
||||
(defvar org-complex-heading-regexp)
|
||||
(defvar org-property-end-re)
|
||||
|
||||
(defun org-inlinetask-insert-task ()
|
||||
"Insert an inline task."
|
||||
(interactive)
|
||||
(or (bolp) (newline))
|
||||
(insert (make-string org-inlinetask-min-level ?*) " \n"
|
||||
(make-string org-inlinetask-min-level ?*) " END\n")
|
||||
(end-of-line -1))
|
||||
(define-key org-mode-map "\C-c\C-xt" 'org-inlinetask-insert-task)
|
||||
|
||||
(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* ((nstars (if org-odd-levels-only
|
||||
(1- (* 2 (or org-inlinetask-min-level 200)))
|
||||
(or org-inlinetask-min-level 200)))
|
||||
(re1 (format "^\\(\\*\\{%d,\\}\\) .*\n" nstars))
|
||||
(re2 (concat "^[ \t]*" org-keyword-time-regexp))
|
||||
headline beg end stars content)
|
||||
(while (re-search-forward re1 nil t)
|
||||
(setq headline (match-string 0)
|
||||
stars (match-string 1)
|
||||
content nil)
|
||||
(replace-match "")
|
||||
(while (looking-at re2)
|
||||
(delete-region (point) (1+ (point-at-eol))))
|
||||
(while (looking-at org-drawer-regexp)
|
||||
(setq beg (point))
|
||||
(if (re-search-forward org-property-end-re nil t)
|
||||
(delete-region beg (1+ (match-end 0)))))
|
||||
(setq beg (point))
|
||||
(when (and (re-search-forward "^\\(\\*+\\) " nil t)
|
||||
(= (length (match-string 1)) (length stars))
|
||||
(progn (goto-char (match-end 0))
|
||||
(looking-at "END[ \t]*$")))
|
||||
(setq content (buffer-substring beg (1- (point-at-bol))))
|
||||
(delete-region beg (1+ (match-end 0))))
|
||||
(goto-char beg)
|
||||
(when (and org-inlinetask-export
|
||||
(string-match org-complex-heading-regexp headline))
|
||||
(when (memq org-inlinetask-export '(arrow+content arrow))
|
||||
(insert "\n\n\\Rightarrow\\Rightarrow\\Rightarrow *"
|
||||
(if (match-end 2) (concat (match-string 2 headline) " ") "")
|
||||
(match-string 4 headline) "*\n"))
|
||||
(when (and content (eq org-inlinetask-export 'arrow+content))
|
||||
(insert "#+BEGIN_EXAMPLE\n" content "\n#+END_EXAMPLE\n"))
|
||||
(insert "\n")))))
|
||||
|
||||
(defun org-inlinetask-fontify (limit)
|
||||
"Fontify the inline tasks."
|
||||
(let* ((nstars (if org-odd-levels-only
|
||||
(1- (* 2 (or org-inlinetask-min-level 200)))
|
||||
(or org-inlinetask-min-level 200)))
|
||||
(re (concat "^\\(\\*\\)\\(\\*\\{"
|
||||
(format "%d" (- nstars 3))
|
||||
",\\}\\)\\(\\*\\* .*\\)")))
|
||||
(while (re-search-forward re limit t)
|
||||
(add-text-properties (match-beginning 1) (match-end 1)
|
||||
'(face org-warning font-lock-fontified t))
|
||||
(add-text-properties (match-beginning 2) (match-end 2)
|
||||
'(face org-hide font-lock-fontified t))
|
||||
(add-text-properties (match-beginning 3) (match-end 3)
|
||||
'(face shadow font-lock-fontified t)))))
|
||||
|
||||
(defun org-inlinetask-remove-END-maybe ()
|
||||
"Remove an END line when present."
|
||||
(when (looking-at (format "\\([ \t]*\n\\)*\\*\\{%d,\\}[ \t]+END[ \t]*$"
|
||||
org-inlinetask-min-level))
|
||||
(replace-match "")))
|
||||
|
||||
(eval-after-load "org-exp"
|
||||
'(add-hook 'org-export-preprocess-after-tree-selection-hook
|
||||
'org-inlinetask-export-handler))
|
||||
(eval-after-load "org"
|
||||
'(add-hook 'org-font-lock-hook 'org-inlinetask-fontify))
|
||||
|
||||
(provide 'org-inlinetask)
|
||||
|
||||
;;; org-inlinetask.el ends here
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
;;
|
||||
;; Author: Philip Jackson <emacs@shellarchive.co.uk>
|
||||
;; Keywords: erc, irc, link, org
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
@ -41,6 +41,7 @@
|
|||
;;; Code:
|
||||
|
||||
(require 'org-exp)
|
||||
(require 'org-html)
|
||||
|
||||
(add-to-list 'org-export-inbuffer-options-extra '("INFOJS_OPT" :infojs-opt))
|
||||
(add-hook 'org-export-options-filters 'org-infojs-handle-options)
|
||||
|
@ -110,7 +111,7 @@ means to use the maximum value consistent with other options."
|
|||
<!--/*--><![CDATA[/*><!--*/
|
||||
%MANAGER_OPTIONS
|
||||
org_html_manager.setup(); // activate after the parameters are set
|
||||
/*]]>*/-->
|
||||
/*]]>*///-->
|
||||
</script>"
|
||||
"The template for the export style additions when org-info.js is used.
|
||||
Option settings will replace the %MANAGER-OPTIONS cookie."
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
;;; org-export-latex.el --- LaTeX exporter for org-mode
|
||||
;;; org-latex.el --- LaTeX exporter for org-mode
|
||||
;;
|
||||
;; Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
|
||||
;;
|
||||
;; Emacs Lisp Archive Entry
|
||||
;; Filename: org-export-latex.el
|
||||
;; Version: 6.21b
|
||||
;; Filename: org-latex.el
|
||||
;; Version: 6.29c
|
||||
;; Author: Bastien Guerry <bzg AT altern DOT org>
|
||||
;; Maintainer: Bastien Guerry <bzg AT altern DOT org>
|
||||
;; Maintainer: Carsten Dominik <carsten.dominik AT gmail DOT com>
|
||||
;; Keywords: org, wp, tex
|
||||
;; Description: Converts an org-mode buffer into LaTeX
|
||||
;; URL: http://www.cognition.ens.fr/~guerry/u/org-export-latex.el
|
||||
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
|
@ -30,8 +29,7 @@
|
|||
;;
|
||||
;; This library implements a LaTeX exporter for org-mode.
|
||||
;;
|
||||
;; Put this file into your load-path and the following into your ~/.emacs:
|
||||
;; (require 'org-export-latex)
|
||||
;; It is part of Org and will be autoloaded
|
||||
;;
|
||||
;; The interactive functions are similar to those of the HTML exporter:
|
||||
;;
|
||||
|
@ -58,6 +56,10 @@
|
|||
(defvar org-export-latex-append-header nil)
|
||||
(defvar org-export-latex-options-plist nil)
|
||||
(defvar org-export-latex-todo-keywords-1 nil)
|
||||
(defvar org-export-latex-complex-heading-re nil)
|
||||
(defvar org-export-latex-not-done-keywords nil)
|
||||
(defvar org-export-latex-done-keywords nil)
|
||||
(defvar org-export-latex-display-custom-times nil)
|
||||
(defvar org-export-latex-all-targets-re nil)
|
||||
(defvar org-export-latex-add-level 0)
|
||||
(defvar org-export-latex-sectioning "")
|
||||
|
@ -165,12 +167,14 @@ to represent the section title."
|
|||
("/" "\\emph{%s}" nil)
|
||||
("_" "\\underline{%s}" nil)
|
||||
("+" "\\texttt{%s}" nil)
|
||||
("=" "\\verb=%s=" nil)
|
||||
("~" "\\verb~%s~" t))
|
||||
("=" "\\verb" t)
|
||||
("~" "\\verb" t))
|
||||
"Alist of LaTeX expressions to convert emphasis fontifiers.
|
||||
Each element of the list is a list of three elements.
|
||||
The first element is the character used as a marker for fontification.
|
||||
The second element is a formatting string to wrap fontified text with.
|
||||
If it is \"\\verb\", Org will automatically select a deimiter
|
||||
character that is not in the string.
|
||||
The third element decides whether to protect converted text from other
|
||||
conversions."
|
||||
:group 'org-export-latex
|
||||
|
@ -184,19 +188,58 @@ argument."
|
|||
:group 'org-export-latex
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-export-latex-import-inbuffer-stuff nil
|
||||
"Non-nil means define TeX macros for Org's inbuffer definitions.
|
||||
For example \orgTITLE for #+TITLE."
|
||||
:group 'org-export-latex
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-export-latex-date-format
|
||||
"%d %B %Y"
|
||||
"Format string for \\date{...}."
|
||||
:group 'org-export-latex
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-export-latex-todo-keyword-markup "\\textbf{%s}"
|
||||
"Markup for TODO keywords, as a printf format.
|
||||
This can be a single format for all keywords, a cons cell with separate
|
||||
formats for not-done and done states, or an association list with setup
|
||||
for individual keywords. If a keyword shows up for which there is no
|
||||
markup defined, the first one in the association list will be used."
|
||||
:group 'org-export-latex
|
||||
:type '(choice
|
||||
(string :tag "Default")
|
||||
(cons :tag "Distinguish undone and done"
|
||||
(string :tag "Not-DONE states")
|
||||
(string :tag "DONE states"))
|
||||
(repeat :tag "Per keyword markup"
|
||||
(cons
|
||||
(string :tag "Keyword")
|
||||
(string :tag "Markup")))))
|
||||
|
||||
(defcustom org-export-latex-timestamp-markup "\\textit{%s}"
|
||||
"A printf format string to be applied to time stamps."
|
||||
:group 'org-export-latex
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-export-latex-timestamp-keyword-markup "\\texttt{%s}"
|
||||
"A printf format string to be applied to time stamps."
|
||||
:group 'org-export-latex
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-export-latex-tables-verbatim nil
|
||||
"When non-nil, tables are exported verbatim."
|
||||
:group 'org-export-latex
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-export-latex-tables-centered t
|
||||
"When non-nil, tables are exported in a center environment."
|
||||
:group 'org-export-latex
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-export-latex-tables-column-borders nil
|
||||
"When non-nil, group of columns are surrounded with borders."
|
||||
"When non-nil, grouping columns can cause outer vertical lines in tables.
|
||||
When nil, grouping causes only separation lines between groups."
|
||||
:group 'org-export-latex
|
||||
:type 'boolean)
|
||||
|
||||
|
@ -206,22 +249,35 @@ Each cell is of the forma \( \"option\" . \"package\" \)."
|
|||
:group 'org-export-latex
|
||||
:type 'alist)
|
||||
|
||||
(defcustom org-export-latex-low-levels 'description
|
||||
(defcustom org-export-latex-low-levels 'itemize
|
||||
"How to convert sections below the current level of sectioning.
|
||||
This is specified by the `org-export-headline-levels' option or the
|
||||
value of \"H:\" in Org's #+OPTION line.
|
||||
|
||||
This can be either nil (skip the sections), 'description (convert
|
||||
the sections as descriptive lists) or a string to be used instead
|
||||
of \\section{%s}. In this latter case, the %s stands here for the
|
||||
inserted headline and is mandatory."
|
||||
This can be either nil (skip the sections), `description', `itemize',
|
||||
or `enumerate' (convert the sections as the corresponding list type), or
|
||||
a string to be used instead of \\section{%s}. In this latter case,
|
||||
the %s stands here for the inserted headline and is mandatory.
|
||||
|
||||
It may also be a list of three string to define a user-defined environment
|
||||
that should be used. The first string should be the like
|
||||
\"\\begin{itemize}\", the second should be like \"\\item %s %s\" with up
|
||||
to two occurrences of %s for the title and a lable, respectively. The third
|
||||
string should be like \"\\end{itemize\"."
|
||||
:group 'org-export-latex
|
||||
:type '(choice (const :tag "Ignore" nil)
|
||||
(symbol :tag "Convert as descriptive list" description)
|
||||
(const :tag "Convert as descriptive list" description)
|
||||
(const :tag "Convert as itemized list" itemize)
|
||||
(const :tag "Convert as enumerated list" enumerate)
|
||||
(list :tag "User-defined environment"
|
||||
:value ("\\begin{itemize}" "\\end{itemize}" "\\item %s")
|
||||
(string :tag "Start")
|
||||
(string :tag "End")
|
||||
(string :tag "item"))
|
||||
(string :tag "Use a section string" :value "\\subparagraph{%s}")))
|
||||
|
||||
(defcustom org-export-latex-list-parameters
|
||||
'(:cbon "\\texttt{[ ]}" :cboff "\\texttt{[ ]}")
|
||||
'(:cbon "\\texttt{[X]}" :cboff "\\texttt{[ ]}")
|
||||
"Parameters for the LaTeX list exporter.
|
||||
These parameters will be passed on to `org-list-to-latex', which in turn
|
||||
will pass them (combined with the LaTeX default list parameters) to
|
||||
|
@ -229,6 +285,18 @@ will pass them (combined with the LaTeX default list parameters) to
|
|||
:group 'org-export-latex
|
||||
:type 'plist)
|
||||
|
||||
(defcustom org-export-latex-verbatim-wrap
|
||||
'("\\begin{verbatim}\n" . "\\end{verbatim}\n")
|
||||
"Environment to be wrapped around a fixed-width section in LaTeX export.
|
||||
This is a cons with two strings, to be added before and after the
|
||||
fixed-with text.
|
||||
|
||||
Defaults to \\begin{verbatim} and \\end{verbatim}."
|
||||
:group 'org-export-translation
|
||||
:group 'org-export-latex
|
||||
:type '(cons (string :tag "Open")
|
||||
(string :tag "Close")))
|
||||
|
||||
(defcustom org-export-latex-remove-from-headlines
|
||||
'(:todo nil :priority nil :tags nil)
|
||||
"A plist of keywords to remove from headlines. OBSOLETE.
|
||||
|
@ -248,13 +316,13 @@ and `org-export-with-tags' instead."
|
|||
:type 'string)
|
||||
|
||||
(defcustom org-export-latex-inline-image-extensions
|
||||
'("pdf" "jpeg" "jpg" "png")
|
||||
'("pdf" "jpeg" "jpg" "png" "ps" "eps")
|
||||
"Extensions of image files that can be inlined into LaTeX.
|
||||
Note that this depends on the way the LaTeX file is processed.
|
||||
The default setting (pdf and jpg) assumes that pdflatex is doing the
|
||||
processing. If you are using latex and dvips or something similar,
|
||||
only postscript files can be included."
|
||||
:group 'org-export-html
|
||||
Note that the image extension *actually* allowed depend on the way the
|
||||
LaTeX file is processed. When used with pdflatex, pdf, jpg and png images
|
||||
are OK. When processing through dvi to Postscript, only ps and eps are
|
||||
allowed. The default we use here encompasses both."
|
||||
:group 'org-export-latex
|
||||
:type '(repeat (string :tag "Extension")))
|
||||
|
||||
(defcustom org-export-latex-coding-system nil
|
||||
|
@ -268,12 +336,37 @@ only postscript files can be included."
|
|||
:group 'org-export-latex
|
||||
:group 'org-export)
|
||||
|
||||
(defcustom org-latex-to-pdf-process
|
||||
'("pdflatex -interaction nonstopmode %s"
|
||||
"pdflatex -interaction nonstopmode %s")
|
||||
"Commands to process a LaTeX file to a PDF file.
|
||||
This is a list of strings, each of them will be given to the shell
|
||||
as a command. %s in the command will be replaced by the full file name, %b
|
||||
by the file base name (i.e. without extension).
|
||||
The reason why this is a list is that it usually takes several runs of
|
||||
pdflatex, maybe mixed with a call to bibtex. Org does not have a clever
|
||||
mechanism to detect whihc of these commands have to be run to get to a stable
|
||||
result, and it also does not do any error checking.
|
||||
|
||||
Alternatively, this may be a Lisp function that does the processing, so you
|
||||
could use this to apply the machinery of AUCTeX or the Emacs LaTeX mode.
|
||||
THis function should accept the file name as its single argument."
|
||||
:group 'org-export-latex
|
||||
:type '(choice (repeat :tag "Shell command sequence"
|
||||
(string :tag "Shell command"))
|
||||
(function)))
|
||||
|
||||
(defcustom org-export-pdf-remove-logfiles t
|
||||
"Non-nil means, remove the logfiles produced by PDF production.
|
||||
These are the .aux, .log, .out, and .toc files."
|
||||
:group 'org-export-latex
|
||||
:group 'org-export-pdf
|
||||
:type 'boolean)
|
||||
|
||||
;;; Hooks
|
||||
|
||||
(defvar org-export-latex-after-blockquotes-hook nil
|
||||
"Hook run during LaTeX export, after blockquote, verse, center are done.")
|
||||
|
||||
;;; Autoload functions:
|
||||
|
||||
;;;###autoload
|
||||
|
@ -293,7 +386,8 @@ emacs --batch
|
|||
No file is created. The prefix ARG is passed through to `org-export-as-latex'."
|
||||
(interactive "P")
|
||||
(org-export-as-latex arg nil nil "*Org LaTeX Export*")
|
||||
(switch-to-buffer-other-window "*Org LaTeX Export*"))
|
||||
(when org-export-show-temporary-export-buffer
|
||||
(switch-to-buffer-other-window "*Org LaTeX Export*")))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-replace-region-by-latex (beg end)
|
||||
|
@ -329,23 +423,24 @@ contents, and only produce the region of converted text, useful for
|
|||
cut-and-paste operations.
|
||||
If BUFFER is a buffer or a string, use/create that buffer as a target
|
||||
of the converted LaTeX. If BUFFER is the symbol `string', return the
|
||||
produced LaTeX as a string and leave not buffer behind. For example,
|
||||
produced LaTeX as a string and leave no buffer behind. For example,
|
||||
a Lisp program could call this function in the following way:
|
||||
|
||||
(setq latex (org-export-region-as-latex beg end t 'string))
|
||||
|
||||
When called interactively, the output buffer is selected, and shown
|
||||
in a window. A non-interactive call will only retunr the buffer."
|
||||
in a window. A non-interactive call will only return the buffer."
|
||||
(interactive "r\nP")
|
||||
(when (interactive-p)
|
||||
(setq buffer "*Org LaTeX Export*"))
|
||||
(let ((transient-mark-mode t) (zmacs-regions t)
|
||||
rtn)
|
||||
ext-plist rtn)
|
||||
(setq ext-plist (plist-put ext-plist :ignore-subree-p t))
|
||||
(goto-char end)
|
||||
(set-mark (point)) ;; to activate the region
|
||||
(goto-char beg)
|
||||
(setq rtn (org-export-as-latex
|
||||
nil nil nil
|
||||
nil nil ext-plist
|
||||
buffer body-only))
|
||||
(if (fboundp 'deactivate-mark) (deactivate-mark))
|
||||
(if (and (interactive-p) (bufferp rtn))
|
||||
|
@ -360,8 +455,9 @@ If there is an active region, export only the region. The prefix
|
|||
ARG specifies how many levels of the outline should become
|
||||
headlines. The default is 3. Lower levels will be exported
|
||||
depending on `org-export-latex-low-levels'. The default is to
|
||||
convert them as description lists. When HIDDEN is non-nil, don't
|
||||
display the LaTeX buffer. EXT-PLIST is a property list with
|
||||
convert them as description lists.
|
||||
HIDDEN is obsolete and does nothing.
|
||||
EXT-PLIST is a property list with
|
||||
external parameters overriding org-mode's default settings, but
|
||||
still inferior to file-local settings. When TO-BUFFER is
|
||||
non-nil, create a buffer with that name and export to that
|
||||
|
@ -382,8 +478,9 @@ when PUB-DIR is set, use this as the publishing directory."
|
|||
(error "Need a file name to be able to export")))
|
||||
|
||||
(message "Exporting to LaTeX...")
|
||||
(remove-text-properties (point-min) (point-max)
|
||||
'(:org-license-to-kill nil))
|
||||
(org-unmodified
|
||||
(remove-text-properties (point-min) (point-max)
|
||||
'(:org-license-to-kill nil)))
|
||||
(org-update-radio-target-regexp)
|
||||
(org-export-latex-set-initial-vars ext-plist arg)
|
||||
(let* ((wcf (current-window-configuration))
|
||||
|
@ -392,14 +489,17 @@ when PUB-DIR is set, use this as the publishing directory."
|
|||
(rbeg (and region-p (region-beginning)))
|
||||
(rend (and region-p (region-end)))
|
||||
(subtree-p
|
||||
(when region-p
|
||||
(save-excursion
|
||||
(goto-char rbeg)
|
||||
(and (org-at-heading-p)
|
||||
(>= (org-end-of-subtree t t) rend)))))
|
||||
(opt-plist (if subtree-p
|
||||
(org-export-add-subtree-options opt-plist rbeg)
|
||||
opt-plist))
|
||||
(if (plist-get opt-plist :ignore-subree-p)
|
||||
nil
|
||||
(when region-p
|
||||
(save-excursion
|
||||
(goto-char rbeg)
|
||||
(and (org-at-heading-p)
|
||||
(>= (org-end-of-subtree t t) rend))))))
|
||||
(opt-plist (setq org-export-opt-plist
|
||||
(if subtree-p
|
||||
(org-export-add-subtree-options opt-plist rbeg)
|
||||
opt-plist)))
|
||||
;; Make sure the variable contains the updated values.
|
||||
(org-export-latex-options-plist opt-plist)
|
||||
(title (or (and subtree-p (org-export-get-title-from-subtree))
|
||||
|
@ -434,8 +534,19 @@ when PUB-DIR is set, use this as the publishing directory."
|
|||
(region-p nil)
|
||||
(t (plist-get opt-plist :skip-before-1st-heading))))
|
||||
(text (plist-get opt-plist :text))
|
||||
(org-export-preprocess-hook
|
||||
(cons
|
||||
`(lambda () (org-set-local 'org-complex-heading-regexp
|
||||
,org-export-latex-complex-heading-re))
|
||||
org-export-preprocess-hook))
|
||||
(first-lines (if skip "" (org-export-latex-first-lines
|
||||
opt-plist rbeg)))
|
||||
opt-plist
|
||||
(if subtree-p
|
||||
(save-excursion
|
||||
(goto-char rbeg)
|
||||
(point-at-bol 2))
|
||||
rbeg)
|
||||
(if region-p rend))))
|
||||
(coding-system (and (boundp 'buffer-file-coding-system)
|
||||
buffer-file-coding-system))
|
||||
(coding-system-for-write (or org-export-latex-coding-system
|
||||
|
@ -464,6 +575,7 @@ when PUB-DIR is set, use this as the publishing directory."
|
|||
|
||||
(set-buffer buffer)
|
||||
(erase-buffer)
|
||||
(org-install-letbind)
|
||||
|
||||
(and (fboundp 'set-buffer-file-coding-system)
|
||||
(set-buffer-file-coding-system coding-system-for-write))
|
||||
|
@ -479,7 +591,7 @@ when PUB-DIR is set, use this as the publishing directory."
|
|||
"\n\n"))
|
||||
|
||||
;; insert lines before the first headline
|
||||
(unless (or skip (eq to-buffer 'string))
|
||||
(unless skip
|
||||
(insert first-lines))
|
||||
|
||||
;; export the content of headlines
|
||||
|
@ -496,9 +608,21 @@ when PUB-DIR is set, use this as the publishing directory."
|
|||
|
||||
;; finalization
|
||||
(unless body-only (insert "\n\\end{document}"))
|
||||
|
||||
;; Relocate the table of contents
|
||||
(goto-char (point-min))
|
||||
(when (re-search-forward "\\[TABLE-OF-CONTENTS\\]" nil t)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "\\\\tableofcontents\\>[ \t]*\n?" nil t)
|
||||
(replace-match ""))
|
||||
(goto-char (point-min))
|
||||
(and (re-search-forward "\\[TABLE-OF-CONTENTS\\]" nil t)
|
||||
(replace-match "\\tableofcontents" t t)))
|
||||
|
||||
(or to-buffer (save-buffer))
|
||||
(goto-char (point-min))
|
||||
(message "Exporting to LaTeX...done")
|
||||
(or (org-export-push-to-kill-ring "LaTeX")
|
||||
(message "Exporting to LaTeX...done"))
|
||||
(prog1
|
||||
(if (eq to-buffer 'string)
|
||||
(prog1 (buffer-substring (point-min) (point-max))
|
||||
|
@ -517,13 +641,32 @@ when PUB-DIR is set, use this as the publishing directory."
|
|||
to-buffer body-only pub-dir))
|
||||
(file (buffer-file-name lbuf))
|
||||
(base (file-name-sans-extension (buffer-file-name lbuf)))
|
||||
(pdffile (concat base ".pdf")))
|
||||
(pdffile (concat base ".pdf"))
|
||||
(cmds org-latex-to-pdf-process)
|
||||
(outbuf (get-buffer-create "*Org PDF LaTeX Output*"))
|
||||
(bibtex-p (with-current-buffer lbuf
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(re-search-forward "\\\\bibliography{" nil t))))
|
||||
cmd)
|
||||
(with-current-buffer outbuf (erase-buffer))
|
||||
(and (file-exists-p pdffile) (delete-file pdffile))
|
||||
(message "Processing LaTeX file...")
|
||||
(shell-command (format "pdflatex -interaction nonstopmode %s"
|
||||
(shell-quote-argument file)))
|
||||
(shell-command (format "pdflatex -interaction nonstopmode %s"
|
||||
(shell-quote-argument file)))
|
||||
(if (and cmds (symbolp cmds))
|
||||
(funcall cmds 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 "%s" cmd)
|
||||
(setq cmd (replace-match
|
||||
(save-match-data
|
||||
(shell-quote-argument file))
|
||||
t t cmd)))
|
||||
(shell-command cmd outbuf outbuf)))
|
||||
(message "Processing LaTeX file...done")
|
||||
(if (not (file-exists-p pdffile))
|
||||
(error "PDF file was not produced")
|
||||
|
@ -663,13 +806,46 @@ If NUM, export sections as numerical sections."
|
|||
;; At a level under the hl option: we can drop this subsection
|
||||
((> level org-export-latex-sectioning-depth)
|
||||
(cond ((eq org-export-latex-low-levels 'description)
|
||||
(insert (format "\\begin{description}\n\n\\item[%s]%s\n\n"
|
||||
(if (string-match "% ends low level$"
|
||||
(buffer-substring (point-at-bol 0) (point)))
|
||||
(delete-region (point-at-bol 0) (point))
|
||||
(insert "\\begin{description}\n"))
|
||||
(insert (format "\n\\item[%s]%s~\n\n"
|
||||
heading
|
||||
(if label (format "\\label{%s}" label) "")))
|
||||
(insert (org-export-latex-content content))
|
||||
(cond ((stringp subcontent) (insert subcontent))
|
||||
((listp subcontent) (org-export-latex-sub subcontent)))
|
||||
(insert "\\end{description}\n"))
|
||||
(insert "\\end{description} % ends low level\n"))
|
||||
((memq org-export-latex-low-levels '(itemize enumerate))
|
||||
(if (string-match "% ends low level$"
|
||||
(buffer-substring (point-at-bol 0) (point)))
|
||||
(delete-region (point-at-bol 0) (point))
|
||||
(insert (format "\\begin{%s}\n"
|
||||
(symbol-name org-export-latex-low-levels))))
|
||||
(insert (format "\n\\item %s\\\\\n%s\n"
|
||||
heading
|
||||
(if label (format "\\label{%s}" label) "")))
|
||||
(insert (org-export-latex-content content))
|
||||
(cond ((stringp subcontent) (insert subcontent))
|
||||
((listp subcontent) (org-export-latex-sub subcontent)))
|
||||
(insert (format "\\end{%s} %% ends low level\n"
|
||||
(symbol-name org-export-latex-low-levels))))
|
||||
|
||||
((listp org-export-latex-low-levels)
|
||||
(if (string-match "% ends low level$"
|
||||
(buffer-substring (point-at-bol 0) (point)))
|
||||
(delete-region (point-at-bol 0) (point))
|
||||
(insert (car org-export-latex-low-levels) "\n"))
|
||||
(insert (format (nth 2 org-export-latex-low-levels)
|
||||
heading
|
||||
(if label (format "\\label{%s}" label) "")))
|
||||
(insert (org-export-latex-content content))
|
||||
(cond ((stringp subcontent) (insert subcontent))
|
||||
((listp subcontent) (org-export-latex-sub subcontent)))
|
||||
(insert (nth 1 org-export-latex-low-levels)
|
||||
" %% ends low level\n"))
|
||||
|
||||
((stringp org-export-latex-low-levels)
|
||||
(insert (format org-export-latex-low-levels heading) "\n")
|
||||
(when label (insert (format "\\label{%s}\n" label)))
|
||||
|
@ -683,6 +859,10 @@ If NUM, export sections as numerical sections."
|
|||
EXT-PLIST is an optional additional plist.
|
||||
LEVEL indicates the default depth for export."
|
||||
(setq org-export-latex-todo-keywords-1 org-todo-keywords-1
|
||||
org-export-latex-done-keywords org-done-keywords
|
||||
org-export-latex-not-done-keywords org-not-done-keywords
|
||||
org-export-latex-complex-heading-re org-complex-heading-regexp
|
||||
org-export-latex-display-custom-times org-display-custom-times
|
||||
org-export-latex-all-targets-re
|
||||
(org-make-target-link-regexp (org-all-targets))
|
||||
org-export-latex-options-plist
|
||||
|
@ -726,7 +906,7 @@ OPT-PLIST is the options plist for current buffer."
|
|||
(if (plist-get opt-plist :time-stamp-file)
|
||||
(format-time-string "%% Created %Y-%m-%d %a %H:%M\n"))
|
||||
;; insert LaTeX custom header
|
||||
org-export-latex-header
|
||||
(org-export-apply-macros-in-string org-export-latex-header)
|
||||
"\n"
|
||||
;; insert information on LaTeX packages
|
||||
(when org-export-latex-packages-alist
|
||||
|
@ -737,8 +917,9 @@ OPT-PLIST is the options plist for current buffer."
|
|||
(car p) (cadr p))))
|
||||
org-export-latex-packages-alist "\n"))
|
||||
;; insert additional commands in the header
|
||||
(plist-get opt-plist :latex-header-extra)
|
||||
org-export-latex-append-header
|
||||
(org-export-apply-macros-in-string
|
||||
(plist-get opt-plist :latex-header-extra))
|
||||
(org-export-apply-macros-in-string org-export-latex-append-header)
|
||||
;; insert the title
|
||||
(format
|
||||
"\n\n\\title{%s}\n"
|
||||
|
@ -748,7 +929,7 @@ OPT-PLIST is the options plist for current buffer."
|
|||
;; insert author info
|
||||
(if (plist-get opt-plist :author-info)
|
||||
(format "\\author{%s}\n"
|
||||
(or author user-full-name))
|
||||
(org-export-latex-fontify-headline (or author user-full-name)));????????????????????
|
||||
(format "%%\\author{%s}\n"
|
||||
(or author user-full-name)))
|
||||
;; insert the date
|
||||
|
@ -759,9 +940,10 @@ OPT-PLIST is the options plist for current buffer."
|
|||
;; beginning of the document
|
||||
"\n\\begin{document}\n\n"
|
||||
;; insert the title command
|
||||
(if (string-match "%s" org-export-latex-title-command)
|
||||
(format org-export-latex-title-command title)
|
||||
org-export-latex-title-command)
|
||||
(when (string-match "\\S-" title)
|
||||
(if (string-match "%s" org-export-latex-title-command)
|
||||
(format org-export-latex-title-command title)
|
||||
org-export-latex-title-command))
|
||||
"\n\n"
|
||||
;; table of contents
|
||||
(when (and org-export-with-toc
|
||||
|
@ -772,16 +954,16 @@ OPT-PLIST is the options plist for current buffer."
|
|||
(toc (format "\\setcounter{tocdepth}{%s}\n\\tableofcontents\n\\vspace*{1cm}\n"
|
||||
(plist-get opt-plist :headline-levels))))))))
|
||||
|
||||
(defun org-export-latex-first-lines (opt-plist &optional beg)
|
||||
(defun org-export-latex-first-lines (opt-plist &optional beg end)
|
||||
"Export the first lines before first headline.
|
||||
If BEG is non-nil, the is the beginning of he region."
|
||||
If BEG is non-nil, it is the beginning of the region.
|
||||
If END is non-nil, it is the end of the region."
|
||||
(save-excursion
|
||||
(goto-char (or beg (point-min)))
|
||||
(if (org-at-heading-p) (beginning-of-line 2))
|
||||
(let* ((pt (point))
|
||||
(end (if (re-search-forward "^\\*+ " nil t)
|
||||
(end (if (re-search-forward "^\\*+ " end t)
|
||||
(goto-char (match-beginning 0))
|
||||
(goto-char (point-max)))))
|
||||
(goto-char end))))
|
||||
(prog1
|
||||
(org-export-latex-content
|
||||
(org-export-preprocess-string
|
||||
|
@ -794,8 +976,14 @@ If BEG is non-nil, the is the beginning of he region."
|
|||
:LaTeX-fragments nil
|
||||
:timestamps (plist-get opt-plist :timestamps)
|
||||
:footnotes (plist-get opt-plist :footnotes)))
|
||||
(add-text-properties pt (max pt (1- end))
|
||||
'(:org-license-to-kill t))))))
|
||||
(org-unmodified
|
||||
(add-text-properties pt (max pt (1- end))
|
||||
'(:org-license-to-kill t)))))))
|
||||
|
||||
(defvar org-export-latex-header-defs nil
|
||||
"The header definitions that might be used in the LaTeX body.")
|
||||
(defvar org-export-latex-header-defs-re nil
|
||||
"The header definitions that might be used in the LaTeX body.")
|
||||
|
||||
(defun org-export-latex-content (content &optional exclude-list)
|
||||
"Convert CONTENT string to LaTeX.
|
||||
|
@ -804,6 +992,8 @@ conversion types are: quotation-marks, emphasis, sub-superscript,
|
|||
links, keywords, lists, tables, fixed-width"
|
||||
(with-temp-buffer
|
||||
(insert content)
|
||||
(unless (memq 'timestamps exclude-list)
|
||||
(org-export-latex-time-stamps))
|
||||
(unless (memq 'quotation-marks exclude-list)
|
||||
(org-export-latex-quotation-marks))
|
||||
(unless (memq 'emphasis exclude-list)
|
||||
|
@ -846,12 +1036,21 @@ links, keywords, lists, tables, fixed-width"
|
|||
"Maybe remove keywords depending on rules in REMOVE-LIST."
|
||||
(goto-char (point-min))
|
||||
(let ((re-todo (mapconcat 'identity org-export-latex-todo-keywords-1 "\\|"))
|
||||
(case-fold-search nil))
|
||||
(case-fold-search nil)
|
||||
(todo-markup org-export-latex-todo-keyword-markup)
|
||||
fmt)
|
||||
;; convert TODO keywords
|
||||
(when (re-search-forward (concat "^\\(" re-todo "\\)") nil t)
|
||||
(if (plist-get remove-list :todo)
|
||||
(replace-match "")
|
||||
(replace-match (format "\\textbf{%s}" (match-string 1)) t t)))
|
||||
(setq fmt (cond
|
||||
((stringp todo-markup) todo-markup)
|
||||
((and (consp todo-markup) (stringp (car todo-markup)))
|
||||
(if (member (match-string 1) org-export-latex-done-keywords)
|
||||
(cdr todo-markup) (car todo-markup)))
|
||||
(t (cdr (or (assoc (match-string 1) todo-markup)
|
||||
(car todo-markup))))))
|
||||
(replace-match (format fmt (match-string 1)) t t)))
|
||||
;; convert priority string
|
||||
(when (re-search-forward "\\[\\\\#.\\]" nil t)
|
||||
(if (plist-get remove-list :priority)
|
||||
|
@ -885,6 +1084,18 @@ links, keywords, lists, tables, fixed-width"
|
|||
(org-export-latex-links)
|
||||
(org-trim (buffer-string))))
|
||||
|
||||
(defun org-export-latex-time-stamps ()
|
||||
"Format time stamps."
|
||||
(goto-char (point-min))
|
||||
(let ((org-display-custom-times org-export-latex-display-custom-times))
|
||||
(while (re-search-forward org-ts-regexp-both nil t)
|
||||
(org-if-unprotected-at (1- (point))
|
||||
(replace-match
|
||||
(org-export-latex-protect-string
|
||||
(format org-export-latex-timestamp-markup
|
||||
(substring (org-translate-time (match-string 0)) 1 -1)))
|
||||
t t)))))
|
||||
|
||||
(defun org-export-latex-quotation-marks ()
|
||||
"Export quotation marks depending on language conventions."
|
||||
(let* ((lang (plist-get org-export-latex-options-plist :language))
|
||||
|
@ -892,9 +1103,9 @@ links, keywords, lists, tables, fixed-width"
|
|||
'(("\\(\\s-\\)\"" "«~")
|
||||
("\\(\\S-\\)\"" "~»")
|
||||
("\\(\\s-\\)'" "`"))
|
||||
'(("\\(\\s-\\)\"" "``")
|
||||
'(("\\(\\s-\\|(\\)\"" "``")
|
||||
("\\(\\S-\\)\"" "''")
|
||||
("\\(\\s-\\)'" "`")))))
|
||||
("\\(\\s-\\|(\\)'" "`")))))
|
||||
(mapc (lambda(l) (goto-char (point-min))
|
||||
(while (re-search-forward (car l) nil t)
|
||||
(let ((rpl (concat (match-string 1) (cadr l))))
|
||||
|
@ -951,10 +1162,11 @@ See the `org-export-latex.el' code for a complete conversion table."
|
|||
sub-superscript
|
||||
(match-string 2)
|
||||
(match-string 1)
|
||||
(match-string 3))) "") t t)))))))
|
||||
(match-string 3))) "") t t)
|
||||
(backward-char 1)))))))
|
||||
'(;"^\\([^\n$]*?\\|^\\)\\(\\\\?\\$\\)\\([^\n$]*\\)$"
|
||||
"\\(\\(\\\\?\\$\\)\\)"
|
||||
"\\([a-za-z0-9]+\\|[ \t\n]\\|\\b\\|\\\\\\)\\(_\\|\\^\\)\\([a-za-z0-9]+\\|[ \t\n]\\|[:punct:]\\|{[a-za-z0-9]+}\\|([a-za-z0-9]+)\\)"
|
||||
"\\([a-za-z0-9]+\\|[ \t\n]\\|\\b\\|\\\\\\)\\(_\\|\\^\\)\\({[^{}]+}\\|[a-za-z0-9]+\\|[ \t\n]\\|[:punct:]\\|)\\|{[a-za-z0-9]+}\\|([a-za-z0-9]+)\\)"
|
||||
"\\(.\\|^\\)\\(\\\\\\)\\([ \t\n]\\|[a-zA-Z&#%{}\"]+\\)"
|
||||
"\\(.\\|^\\)\\(&\\)"
|
||||
"\\(.\\|^\\)\\(#\\)"
|
||||
|
@ -993,10 +1205,12 @@ Convert CHAR depending on STRING-BEFORE and STRING-AFTER."
|
|||
(or (eq subsup t)
|
||||
(and (equal subsup '{}) (eq (string-to-char string-after) ?\{)))
|
||||
(string-match "[({]?\\([^)}]+\\)[)}]?" string-after))
|
||||
(format "%s$%s{%s}$" string-before char
|
||||
(if (> (match-end 1) (1+ (match-beginning 1)))
|
||||
(concat "\\mathrm{" (match-string 1 string-after) "}")
|
||||
(match-string 1 string-after))))
|
||||
(org-export-latex-protect-string
|
||||
(format "%s$%s{%s}$" string-before char
|
||||
(if (and (> (match-end 1) (1+ (match-beginning 1)))
|
||||
(not (equal (substring string-after 0 2) "{\\")))
|
||||
(concat "\\mathrm{" (match-string 1 string-after) "}")
|
||||
(match-string 1 string-after)))))
|
||||
((eq subsup t) (concat string-before "$" char string-after "$"))
|
||||
(t (org-export-latex-protect-string
|
||||
(concat string-before "\\" char "{}" string-after)))))
|
||||
|
@ -1033,11 +1247,14 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
|
|||
(defun org-export-latex-keywords ()
|
||||
"Convert special keywords to LaTeX."
|
||||
(goto-char (point-min))
|
||||
(let ((re (concat org-export-latex-special-keyword-regexp
|
||||
".*" ; including the time stamp....
|
||||
)))
|
||||
(while (re-search-forward re nil t)
|
||||
(replace-match (format "\\\\texttt{%s}" (match-string 0)) t))))
|
||||
(while (re-search-forward org-export-latex-special-keyword-regexp nil t)
|
||||
(replace-match (format org-export-latex-timestamp-keyword-markup
|
||||
(match-string 0)) t t)
|
||||
(save-excursion
|
||||
(beginning-of-line 1)
|
||||
(unless (looking-at ".*\\\\newline[ \t]*$")
|
||||
(end-of-line 1)
|
||||
(insert "\\newline")))))
|
||||
|
||||
(defun org-export-latex-fixed-width (opt)
|
||||
"When OPT is non-nil convert fixed-width sections to LaTeX."
|
||||
|
@ -1089,7 +1306,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
|
|||
(string-match "\\<align=\\([^ \t\n\r,]+\\)" attr)
|
||||
(match-string 1 attr))
|
||||
floatp (or caption label))
|
||||
(setq lines (split-string raw-table "\n" t))
|
||||
(setq lines (org-split-string raw-table "\n"))
|
||||
(apply 'delete-region (list beg end))
|
||||
(when org-export-table-remove-special-lines
|
||||
(setq lines (org-table-clean-before-export lines 'maybe-quoted)))
|
||||
|
@ -1104,10 +1321,10 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
|
|||
(lambda (x)
|
||||
(setq gr (pop org-table-colgroup-info))
|
||||
(format "%s%%s%s"
|
||||
(cond ((eq gr ':start)
|
||||
(prog1 (if colgropen "|" "")
|
||||
(cond ((eq gr :start)
|
||||
(prog1 (if colgropen "|" "|")
|
||||
(setq colgropen t)))
|
||||
((eq gr ':startend)
|
||||
((eq gr :startend)
|
||||
(prog1 (if colgropen "|" "|")
|
||||
(setq colgropen nil)))
|
||||
(t ""))
|
||||
|
@ -1132,7 +1349,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
|
|||
(mapcar
|
||||
(lambda(elem)
|
||||
(or (and (string-match "[ \t]*|-+" elem) 'hline)
|
||||
(split-string (org-trim elem) "|" t)))
|
||||
(org-split-string (org-trim elem) "|")))
|
||||
lines))
|
||||
(when insert
|
||||
(insert (org-export-latex-protect-string
|
||||
|
@ -1146,7 +1363,8 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
|
|||
(if label (concat "\\\label{" label "}") "")
|
||||
(or caption "")))
|
||||
(if longtblp "\\\\\n" "\n")
|
||||
(if (not longtblp) "\\begin{center}\n")
|
||||
(if (and org-export-latex-tables-centered (not longtblp))
|
||||
"\\begin{center}\n")
|
||||
(if (not longtblp) (concat "\\begin{tabular}{" align "}\n"))
|
||||
(orgtbl-to-latex
|
||||
lines
|
||||
|
@ -1160,7 +1378,8 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
|
|||
\\endlastfoot" (length org-table-last-alignment))
|
||||
nil)))
|
||||
(if (not longtblp) (concat "\n\\end{tabular}"))
|
||||
(if longtblp "\n" "\n\\end{center}\n")
|
||||
(if longtblp "\n" (if org-export-latex-tables-centered
|
||||
"\n\\end{center}\n" "\n"))
|
||||
(if longtblp
|
||||
"\\end{longtable}"
|
||||
(if floatp "\\end{table}"))))
|
||||
|
@ -1176,6 +1395,9 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
|
|||
(beg (match-beginning 0))
|
||||
(end (match-end 0))
|
||||
rpl)
|
||||
(unless emph
|
||||
(message "`org-export-latex-emphasis-alist' has no entry for formatting triggered by \"%s\""
|
||||
(match-string 3)))
|
||||
(unless (or (get-text-property (1- (point)) 'org-protected)
|
||||
(save-excursion
|
||||
(goto-char (match-beginning 1))
|
||||
|
@ -1184,15 +1406,46 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
|
|||
(string-match
|
||||
"[|\n]" (buffer-substring beg end))))))
|
||||
(setq rpl (concat (match-string 1)
|
||||
(format (org-export-latex-protect-char-in-string
|
||||
'("\\" "{" "}") (cadr emph))
|
||||
(match-string 4))
|
||||
(org-export-latex-emph-format (cadr emph)
|
||||
(match-string 4))
|
||||
(match-string 5)))
|
||||
(if (caddr emph)
|
||||
(setq rpl (org-export-latex-protect-string rpl)))
|
||||
(replace-match rpl t t)))
|
||||
(backward-char)))
|
||||
|
||||
(defvar org-export-latex-use-verb nil)
|
||||
(defun org-export-latex-emph-format (format string)
|
||||
"Format an emphasis string and handle the \\verb special case."
|
||||
(when (equal format "\\verb")
|
||||
(save-match-data
|
||||
(if org-export-latex-use-verb
|
||||
(let ((ll "~,./?;':\"|!@#%^&-_=+abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ<>()[]{}"))
|
||||
(catch 'exit
|
||||
(loop for i from 0 to (1- (length ll)) do
|
||||
(if (not (string-match (regexp-quote (substring ll i (1+ i)))
|
||||
string))
|
||||
(progn
|
||||
(setq format (concat "\\verb" (substring ll i (1+ i))
|
||||
"%s" (substring ll i (1+ i))))
|
||||
(throw 'exit nil))))))
|
||||
(let ((start 0)
|
||||
(trans '(("\\" . "\\backslash")
|
||||
("~" . "\\ensuremath{\\sim}")
|
||||
("^" . "\\ensuremath{\\wedge}")))
|
||||
(rtn "") char)
|
||||
(while (string-match "[\\{}$%&_#~^]" string)
|
||||
(setq char (match-string 0 string))
|
||||
(if (> (match-beginning 0) 0)
|
||||
(setq rtn (concat rtn (substring string
|
||||
0 (match-beginning 0)))))
|
||||
(setq string (substring string (1+ (match-beginning 0))))
|
||||
(setq char (or (cdr (assoc char trans)) (concat "\\" char))
|
||||
rtn (concat rtn char)))
|
||||
(setq string (concat rtn string) format "\\texttt{%s}")))))
|
||||
(setq string (org-export-latex-protect-string
|
||||
(format format string))))
|
||||
|
||||
(defun org-export-latex-links ()
|
||||
;; Make sure to use the LaTeX hyperref and graphicx package
|
||||
;; or send some warnings.
|
||||
|
@ -1212,7 +1465,8 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
|
|||
"file")))
|
||||
(coderefp (equal type "coderef"))
|
||||
(caption (org-find-text-property-in-string 'org-caption raw-path))
|
||||
(attr (org-find-text-property-in-string 'org-attributes raw-path))
|
||||
(attr (or (org-find-text-property-in-string 'org-attributes raw-path)
|
||||
(plist-get org-export-latex-options-plist :latex-image-options)))
|
||||
(label (org-find-text-property-in-string 'org-label raw-path))
|
||||
(floatp (or label caption))
|
||||
imgp radiop
|
||||
|
@ -1231,7 +1485,9 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
|
|||
(expand-file-name
|
||||
raw-path)
|
||||
org-export-latex-inline-image-extensions)
|
||||
(equal desc full-raw-path))
|
||||
(or (get-text-property 0 'org-no-description
|
||||
raw-path)
|
||||
(equal desc full-raw-path)))
|
||||
(setq imgp t)
|
||||
(progn (when (string-match "\\(.+\\)::.+" raw-path)
|
||||
(setq raw-path (match-string 1 raw-path)))
|
||||
|
@ -1247,7 +1503,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
|
|||
(concat
|
||||
(if floatp "\\begin{figure}[htb]\n")
|
||||
(format "\\centerline{\\includegraphics[%s]{%s}}\n"
|
||||
(or attr org-export-latex-image-default-option)
|
||||
attr
|
||||
(if (file-name-absolute-p raw-path)
|
||||
(expand-file-name raw-path)
|
||||
raw-path))
|
||||
|
@ -1264,14 +1520,20 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
|
|||
(org-solidify-link-text raw-path) desc)))
|
||||
((not type)
|
||||
(insert (format "\\hyperref[%s]{%s}"
|
||||
(org-solidify-link-text raw-path) desc)))
|
||||
(org-remove-initial-hash
|
||||
(org-solidify-link-text raw-path)) desc)))
|
||||
(path (insert (format "\\href{%s}{%s}" path desc)))
|
||||
(t (insert "\\texttt{" desc "}")))))))
|
||||
|
||||
(defun org-remove-initial-hash (s)
|
||||
(if (string-match "\\`#" s)
|
||||
(substring s 1)
|
||||
s))
|
||||
(defvar org-latex-entities) ; defined below
|
||||
(defvar org-latex-entities-regexp) ; defined below
|
||||
(defvar org-latex-entities-exceptions) ; defined below
|
||||
|
||||
(defun org-export-latex-preprocess ()
|
||||
(defun org-export-latex-preprocess (parameters)
|
||||
"Clean stuff in the LaTeX export."
|
||||
;; Preserve line breaks
|
||||
(goto-char (point-min))
|
||||
|
@ -1281,13 +1543,16 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
|
|||
|
||||
;; Preserve latex environments
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "^[ \t]*\\\\begin{\\([a-zA-Z]+\\)}" nil t)
|
||||
(while (re-search-forward "^[ \t]*\\\\begin{\\([a-zA-Z]+\\*?\\)}" nil t)
|
||||
(let* ((start (progn (beginning-of-line) (point)))
|
||||
(end (or (and (re-search-forward
|
||||
(concat "^[ \t]*\\\\end{" (match-string 1) "}") nil t)
|
||||
(point-at-eol))
|
||||
(point-max))))
|
||||
(add-text-properties start end '(org-protected t))))
|
||||
(end (and (re-search-forward
|
||||
(concat "^[ \t]*\\\\end{"
|
||||
(regexp-quote (match-string 1))
|
||||
"}") nil t)
|
||||
(point-at-eol))))
|
||||
(if end
|
||||
(add-text-properties start end '(org-protected t))
|
||||
(goto-char (point-at-eol)))))
|
||||
|
||||
;; Preserve math snippets
|
||||
|
||||
|
@ -1316,18 +1581,39 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
|
|||
;; Convert blockquotes
|
||||
(goto-char (point-min))
|
||||
(while (search-forward "ORG-BLOCKQUOTE-START" nil t)
|
||||
(replace-match "\\begin{quote}" t t))
|
||||
(org-replace-match-keep-properties "\\begin{quote}" t t))
|
||||
(goto-char (point-min))
|
||||
(while (search-forward "ORG-BLOCKQUOTE-END" nil t)
|
||||
(replace-match "\\end{quote}" t t))
|
||||
(org-replace-match-keep-properties "\\end{quote}" t t))
|
||||
|
||||
;; Convert verse
|
||||
(goto-char (point-min))
|
||||
(while (search-forward "ORG-VERSE-START" nil t)
|
||||
(replace-match "\\begin{verse}" t t))
|
||||
(org-replace-match-keep-properties "\\begin{verse}" t t)
|
||||
(beginning-of-line 2)
|
||||
(while (and (not (looking-at "[ \t]*ORG-VERSE-END.*")) (not (eobp)))
|
||||
(when (looking-at "\\([ \t]+\\)\\([^ \t\n]\\)")
|
||||
(goto-char (match-end 1))
|
||||
(org-replace-match-keep-properties
|
||||
(org-export-latex-protect-string
|
||||
(concat "\\hspace*{1cm}" (match-string 2))) t t)
|
||||
(beginning-of-line 1))
|
||||
(unless (looking-at ".*?[^ \t\n].*?\\\\\\\\[ \t]*$")
|
||||
(end-of-line 1)
|
||||
(insert "\\\\"))
|
||||
(beginning-of-line 2))
|
||||
(and (looking-at "[ \t]*ORG-VERSE-END.*")
|
||||
(org-replace-match-keep-properties "\\end{verse}" t t)))
|
||||
|
||||
;; Convert center
|
||||
(goto-char (point-min))
|
||||
(while (search-forward "ORG-VERSE-END" nil t)
|
||||
(replace-match "\\end{verse}" t t))
|
||||
(while (search-forward "ORG-CENTER-START" nil t)
|
||||
(org-replace-match-keep-properties "\\begin{center}" t t))
|
||||
(goto-char (point-min))
|
||||
(while (search-forward "ORG-CENTER-END" nil t)
|
||||
(org-replace-match-keep-properties "\\end{center}" t t))
|
||||
|
||||
(run-hooks 'org-export-latex-after-blockquotes-hook)
|
||||
|
||||
;; Convert horizontal rules
|
||||
(goto-char (point-min))
|
||||
|
@ -1336,16 +1622,23 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
|
|||
(replace-match (org-export-latex-protect-string "\\hrule") t t)))
|
||||
|
||||
;; Protect LaTeX commands like \command[...]{...} or \command{...}
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "\\\\[a-zA-Z]+\\(?:\\[.*\\]\\)?{.*}" nil t)
|
||||
(add-text-properties (match-beginning 0) (match-end 0)
|
||||
'(org-protected t)))
|
||||
(let ((re (concat "\\\\[a-zA-Z]+\\(?:"
|
||||
"\\[.*\\]"
|
||||
"\\)?"
|
||||
(org-create-multibrace-regexp "{" "}" 3))))
|
||||
(while (re-search-forward re nil t)
|
||||
(add-text-properties (match-beginning 0) (match-end 0)
|
||||
'(org-protected t))))
|
||||
|
||||
;; Protect LaTeX entities
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward org-latex-entities-regexp nil t)
|
||||
(add-text-properties (match-beginning 0) (match-end 0)
|
||||
'(org-protected t)))
|
||||
(let (a)
|
||||
(while (re-search-forward org-latex-entities-regexp nil t)
|
||||
(if (setq a (assoc (match-string 0) org-latex-entities-exceptions))
|
||||
(replace-match (org-add-props (nth 1 a) nil 'org-protected t)
|
||||
t t)
|
||||
(add-text-properties (match-beginning 0) (match-end 0)
|
||||
'(org-protected t)))))
|
||||
|
||||
;; Replace radio links
|
||||
(goto-char (point-min))
|
||||
|
@ -1525,6 +1818,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
|
|||
"\\medskip"
|
||||
"\\multicolumn"
|
||||
"\\multiput"
|
||||
("\\nbsp" "~")
|
||||
"\\newcommand"
|
||||
"\\newcounter"
|
||||
"\\newenvironment"
|
||||
|
@ -1596,9 +1890,14 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
|
|||
"\\vspace")
|
||||
"A list of LaTeX commands to be protected when performing conversion.")
|
||||
|
||||
(defvar org-latex-entities-exceptions nil)
|
||||
|
||||
(defconst org-latex-entities-regexp
|
||||
(let (names rest)
|
||||
(dolist (x org-latex-entities)
|
||||
(when (consp x)
|
||||
(add-to-list 'org-latex-entities-exceptions x)
|
||||
(setq x (car x)))
|
||||
(if (string-match "[a-z][A-Z]$" x)
|
||||
(push x names)
|
||||
(push x rest)))
|
||||
|
@ -1606,7 +1905,8 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
|
|||
"\\|\\(" (regexp-opt (nreverse rest)) "\\)")))
|
||||
|
||||
(provide 'org-export-latex)
|
||||
(provide 'org-latex)
|
||||
|
||||
;; arch-tag: 23c2b87d-da04-4c2d-ad2d-1eb6487bc3ad
|
||||
|
||||
;;; org-export-latex.el ends here
|
||||
;;; org-latex.el ends here
|
|
@ -7,7 +7,7 @@
|
|||
;; Bastien Guerry <bzg AT altern DOT org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
@ -36,6 +36,8 @@
|
|||
|
||||
(defvar org-blank-before-new-entry)
|
||||
(defvar org-M-RET-may-split-line)
|
||||
(defvar org-complex-heading-regexp)
|
||||
(defvar org-odd-levels-only)
|
||||
|
||||
(declare-function org-invisible-p "org" ())
|
||||
(declare-function org-on-heading-p "org" (&optional invisible-ok))
|
||||
|
@ -48,21 +50,57 @@
|
|||
(declare-function org-get-indentation "org" (&optional line))
|
||||
(declare-function org-timer-item "org-timer" (&optional arg))
|
||||
(declare-function org-combine-plists "org" (&rest plists))
|
||||
(declare-function org-entry-get "org" (pom property &optional inherit))
|
||||
(declare-function org-narrow-to-subtree "org" ())
|
||||
(declare-function org-show-subtree "org" ())
|
||||
|
||||
(defgroup org-plain-lists nil
|
||||
"Options concerning plain lists in Org-mode."
|
||||
:tag "Org Plain lists"
|
||||
:group 'org-structure)
|
||||
|
||||
(defcustom org-cycle-include-plain-lists nil
|
||||
"Non-nil means, include plain lists into visibility cycling.
|
||||
This means that during cycling, plain list items will *temporarily* be
|
||||
interpreted as outline headlines with a level given by 1000+i where i is the
|
||||
indentation of the bullet. In all other operations, plain list items are
|
||||
not seen as headlines. For example, you cannot assign a TODO keyword to
|
||||
such an item."
|
||||
(defcustom org-cycle-include-plain-lists t
|
||||
"When t, make TAB cycle visibility on plain list items.
|
||||
|
||||
Cycling plain lists works only when the cursor is on a plain list
|
||||
item. When the cursor is on an outline heading, plain lists are
|
||||
treated as text. This is the most stable way of handling this,
|
||||
which is why it is the default.
|
||||
|
||||
When this is the symbol `integrate', then during cycling, plain
|
||||
list items will *temporarily* be interpreted as outline headlines
|
||||
with a level given by 1000+i where i is the indentation of the
|
||||
bullet. This setting can lead to strange effects when switching
|
||||
visibility to `children', because the first \"child\" in a
|
||||
subtree decides what children should be listed. If that first
|
||||
\"child\" is a 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
|
||||
:type 'boolean)
|
||||
:type '(choice
|
||||
(const :tag "Never" nil)
|
||||
(const :tag "With cursor in plain list (recommended)" t)
|
||||
(const :tag "As children of outline headings" integrate)))
|
||||
|
||||
(defcustom org-list-demote-modify-bullet nil
|
||||
"Default bullet type installed when demoting an item.
|
||||
This is an association list, for each bullet type, this alist will point
|
||||
to the bulled that should be used when this item is demoted."
|
||||
:group 'org-plain-lists
|
||||
:type '(repeat
|
||||
(cons
|
||||
(choice :tag "If the current bullet is "
|
||||
(const "-")
|
||||
(const "+")
|
||||
(const "*")
|
||||
(const "1.")
|
||||
(const "1)"))
|
||||
(choice :tag "demotion will change it to"
|
||||
(const "-")
|
||||
(const "+")
|
||||
(const "*")
|
||||
(const "1.")
|
||||
(const "1)")))))
|
||||
|
||||
(defcustom org-plain-list-ordered-item-terminator t
|
||||
"The character that makes a line with leading number an ordered list item.
|
||||
|
@ -103,9 +141,15 @@ use \\[org-ctrl-c-ctrl-c] to trigger renumbering."
|
|||
|
||||
(defcustom org-provide-checkbox-statistics t
|
||||
"Non-nil means, update checkbox statistics after insert and toggle.
|
||||
When this is set, checkbox statistics is updated each time you either insert
|
||||
a new checkbox with \\[org-insert-todo-heading] or toggle a checkbox
|
||||
with \\[org-ctrl-c-ctrl-c\\]."
|
||||
When this is set, checkbox statistics is updated each time you
|
||||
either insert a new checkbox with \\[org-insert-todo-heading] or
|
||||
toggle a checkbox with \\[org-ctrl-c-ctrl-c]."
|
||||
:group 'org-plain-lists
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-hierarchical-checkbox-statistics t
|
||||
"Non-nil means, checkbox statistics counts only the state of direct children.
|
||||
When nil, all boxes below the cookie are counted."
|
||||
:group 'org-plain-lists
|
||||
:type 'boolean)
|
||||
|
||||
|
@ -117,7 +161,7 @@ When the indentation would be larger than this, it will become
|
|||
:type 'integer)
|
||||
|
||||
(defvar org-list-beginning-re
|
||||
"^\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) +\\(.*\\)$")
|
||||
"^\\([ \t]*\\)\\([-+]\\|[0-9]+[.)]\\) +\\(.*\\)$")
|
||||
|
||||
(defcustom org-list-radio-list-templates
|
||||
'((latex-mode "% BEGIN RECEIVE ORGLST %n
|
||||
|
@ -159,7 +203,7 @@ list, obtained by prompting the user."
|
|||
(cond
|
||||
((eq llt t) "\\([ \t]*\\([-+]\\|\\([0-9]+[.)]\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)")
|
||||
((= llt ?.) "\\([ \t]*\\([-+]\\|\\([0-9]+\\.\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)")
|
||||
((= llt ?\)) "\\([ \t]*\\([-+]\\|\\([0-9]+))\\)\\|[ \t]+\\*\\)\\( \\|$\\)")
|
||||
((= llt ?\)) "\\([ \t]*\\([-+]\\|\\([0-9]+)\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)")
|
||||
(t (error "Invalid value of `org-plain-list-ordered-item-terminator'")))))))
|
||||
|
||||
(defun org-at-item-bullet-p ()
|
||||
|
@ -208,7 +252,9 @@ Return t when things worked, nil when we are not in an item."
|
|||
descp))))
|
||||
(eow (save-excursion (beginning-of-line 1) (looking-at "[ \t]*")
|
||||
(match-end 0)))
|
||||
(blank-a (cdr (assq 'plain-list-item org-blank-before-new-entry)))
|
||||
(blank-a (if org-empty-line-terminates-plain-lists
|
||||
nil
|
||||
(cdr (assq 'plain-list-item org-blank-before-new-entry))))
|
||||
(blank (if (eq blank-a 'auto) empty-line-p blank-a))
|
||||
pos)
|
||||
(if descp (setq checkbox nil))
|
||||
|
@ -251,6 +297,7 @@ Return t when things worked, nil when we are not in an item."
|
|||
(defun org-toggle-checkbox (&optional toggle-presence)
|
||||
"Toggle the checkbox in the current line.
|
||||
With prefix arg TOGGLE-PRESENCE, add or remove checkboxes.
|
||||
With double prefix, set checkbox to [-].
|
||||
When there is an active region, toggle status or presence of the checkbox
|
||||
in the first line, and make every item in the region have the same
|
||||
status or presence, respectively.
|
||||
|
@ -258,24 +305,27 @@ If the cursor is in a headline, apply this to all checkbox items in the
|
|||
text below the heading."
|
||||
(interactive "P")
|
||||
(catch 'exit
|
||||
(let (beg end status first-present first-status)
|
||||
(let (beg end status first-present first-status blocked)
|
||||
(cond
|
||||
((org-region-active-p)
|
||||
(setq beg (region-beginning) end (region-end)))
|
||||
((org-on-heading-p)
|
||||
(setq beg (point) end (save-excursion (outline-next-heading) (point))))
|
||||
((org-at-item-checkbox-p)
|
||||
(let ((pos (point)))
|
||||
(if toggle-presence
|
||||
(save-excursion
|
||||
(if (equal toggle-presence '(4))
|
||||
(progn
|
||||
(replace-match "")
|
||||
(goto-char (match-beginning 0))
|
||||
(just-one-space))
|
||||
(when (setq blocked (org-checkbox-blocked-p))
|
||||
(error "Checkbox blocked because of unchecked box in line %d"
|
||||
blocked))
|
||||
(replace-match
|
||||
(cond ((member (match-string 0) '("[ ]" "[-]")) "[X]")
|
||||
(cond ((equal toggle-presence '(16)) "[-]")
|
||||
((member (match-string 0) '("[ ]" "[-]")) "[X]")
|
||||
(t "[ ]"))
|
||||
t t))
|
||||
(goto-char pos))
|
||||
t t)))
|
||||
(throw 'exit t))
|
||||
((org-at-item-p)
|
||||
;; add a checkbox
|
||||
|
@ -312,10 +362,53 @@ text below the heading."
|
|||
(beginning-of-line 2)))))
|
||||
(org-update-checkbox-count-maybe))
|
||||
|
||||
(defun org-reset-checkbox-state-subtree ()
|
||||
"Reset all checkboxes in an entry subtree."
|
||||
(interactive "*")
|
||||
(save-restriction
|
||||
(save-excursion
|
||||
(org-narrow-to-subtree)
|
||||
(org-show-subtree)
|
||||
(goto-char (point-min))
|
||||
(let ((end (point-max)))
|
||||
(while (< (point) end)
|
||||
(when (org-at-item-checkbox-p)
|
||||
(replace-match "[ ]" t t))
|
||||
(beginning-of-line 2))))
|
||||
(org-update-checkbox-count-maybe)))
|
||||
|
||||
(defun org-checkbox-blocked-p ()
|
||||
"Is the current checkbox blocked from for being checked now?
|
||||
A checkbox is blocked if all of the following conditions are fulfilled:
|
||||
|
||||
1. The checkbox is not checked already.
|
||||
2. The current entry has the ORDERED property set.
|
||||
3. There is an unchecked checkbox in this entry before the current line."
|
||||
(catch 'exit
|
||||
(save-match-data
|
||||
(save-excursion
|
||||
(unless (org-at-item-checkbox-p) (throw 'exit nil))
|
||||
(when (equal (match-string 0) "[X]")
|
||||
;; the box is already checked!
|
||||
(throw 'exit nil))
|
||||
(let ((end (point-at-bol)))
|
||||
(condition-case nil (org-back-to-heading t)
|
||||
(error (throw 'exit nil)))
|
||||
(unless (org-entry-get nil "ORDERED") (throw 'exit nil))
|
||||
(if (re-search-forward "^[ \t]*[-+*0-9.)] \\[[- ]\\]" end t)
|
||||
(org-current-line)
|
||||
nil))))))
|
||||
|
||||
(defvar org-checkbox-statistics-hook nil
|
||||
"Hook that is run whenever Org thinks checkbox statistics should be updated.
|
||||
This hook runs even if `org-provide-checkbox-statistics' is nil, to it can
|
||||
be used to implement alternative ways of collecting statistics information.")
|
||||
|
||||
(defun org-update-checkbox-count-maybe ()
|
||||
"Update checkbox statistics unless turned off by user."
|
||||
(when org-provide-checkbox-statistics
|
||||
(org-update-checkbox-count)))
|
||||
(org-update-checkbox-count))
|
||||
(run-hooks 'org-checkbox-statistics-hook))
|
||||
|
||||
(defun org-update-checkbox-count (&optional all)
|
||||
"Update the checkbox statistics in the current section.
|
||||
|
@ -335,6 +428,10 @@ the whole buffer."
|
|||
(re-find (concat re "\\|" re-box))
|
||||
beg-cookie end-cookie is-percent c-on c-off lim
|
||||
eline curr-ind next-ind continue-from startsearch
|
||||
(recursive
|
||||
(or (not org-hierarchical-checkbox-statistics)
|
||||
(string-match "\\<recursive\\>"
|
||||
(or (org-entry-get nil "COOKIE_DATA") ""))))
|
||||
(cstat 0)
|
||||
)
|
||||
(when all
|
||||
|
@ -342,8 +439,15 @@ the whole buffer."
|
|||
(outline-next-heading)
|
||||
(setq beg (point) end (point-max)))
|
||||
(goto-char end)
|
||||
;; find each statistic cookie
|
||||
(while (re-search-backward re-find beg t)
|
||||
;; find each statistics cookie
|
||||
(while (and (re-search-backward re-find beg t)
|
||||
(not (save-match-data
|
||||
(and (org-on-heading-p)
|
||||
(string-match "\\<todo\\>"
|
||||
(downcase
|
||||
(or (org-entry-get
|
||||
nil "COOKIE_DATA")
|
||||
"")))))))
|
||||
(setq beg-cookie (match-beginning 1)
|
||||
end-cookie (match-end 1)
|
||||
cstat (+ cstat (if end-cookie 1 0))
|
||||
|
@ -365,17 +469,21 @@ the whole buffer."
|
|||
(org-beginning-of-item)
|
||||
(setq curr-ind (org-get-indentation))
|
||||
(setq next-ind curr-ind)
|
||||
(while (and (bolp) (org-at-item-p) (= curr-ind next-ind))
|
||||
(while (and (bolp) (org-at-item-p)
|
||||
(if recursive
|
||||
(<= curr-ind next-ind)
|
||||
(= curr-ind next-ind)))
|
||||
(save-excursion (end-of-line) (setq eline (point)))
|
||||
(if (re-search-forward re-box eline t)
|
||||
(if (member (match-string 2) '("[ ]" "[-]"))
|
||||
(setq c-off (1+ c-off))
|
||||
(setq c-on (1+ c-on))
|
||||
)
|
||||
)
|
||||
(org-end-of-item)
|
||||
(setq next-ind (org-get-indentation))
|
||||
)))
|
||||
(setq c-on (1+ c-on))))
|
||||
(if (not recursive)
|
||||
(org-end-of-item)
|
||||
(end-of-line)
|
||||
(when (re-search-forward org-list-beginning-re lim t)
|
||||
(beginning-of-line)))
|
||||
(setq next-ind (org-get-indentation)))))
|
||||
(goto-char continue-from)
|
||||
;; update cookie
|
||||
(when end-cookie
|
||||
|
@ -408,11 +516,13 @@ the whole buffer."
|
|||
The face will be `org-done' when all relevant boxes are checked. Otherwise
|
||||
it will be `org-todo'."
|
||||
(if (match-end 1)
|
||||
(if (equal (match-string 1) "100%") 'org-done 'org-todo)
|
||||
(if (equal (match-string 1) "100%")
|
||||
'org-checkbox-statistics-done
|
||||
'org-checkbox-statistics-todo)
|
||||
(if (and (> (match-end 2) (match-beginning 2))
|
||||
(equal (match-string 2) (match-string 3)))
|
||||
'org-done
|
||||
'org-todo)))
|
||||
'org-checkbox-statistics-done
|
||||
'org-checkbox-statistics-todo)))
|
||||
|
||||
(defun org-beginning-of-item ()
|
||||
"Go to the beginning of the current hand-formatted item.
|
||||
|
@ -513,11 +623,12 @@ Error if not at a plain list, or if this is the first item in the list."
|
|||
(error "On first item")))))
|
||||
|
||||
(defun org-first-list-item-p ()
|
||||
"Is this heading the item in a plain list?"
|
||||
"Is this heading the first item in a plain list?"
|
||||
(unless (org-at-item-p)
|
||||
(error "Not at a plain list item"))
|
||||
(org-beginning-of-item)
|
||||
(= (point) (save-excursion (org-beginning-of-item-list))))
|
||||
(save-excursion
|
||||
(org-beginning-of-item)
|
||||
(= (point) (save-excursion (org-beginning-of-item-list)))))
|
||||
|
||||
(defun org-move-item-down ()
|
||||
"Move the plain list item at point down, i.e. swap with following item.
|
||||
|
@ -705,7 +816,7 @@ with something like \"1.\" or \"2)\"."
|
|||
(org-beginning-of-item-list)
|
||||
(setq bobp (bobp))
|
||||
(looking-at "[ \t]*[0-9]+\\([.)]\\)")
|
||||
(setq fmt (concat "%d" (match-string 1)))
|
||||
(setq fmt (concat "%d" (or (match-string 1) ".")))
|
||||
(beginning-of-line 0)
|
||||
;; walk forward and replace these numbers
|
||||
(catch 'exit
|
||||
|
@ -726,7 +837,7 @@ with something like \"1.\" or \"2)\"."
|
|||
(goto-line line)
|
||||
(org-move-to-column col)))
|
||||
|
||||
(defun org-fix-bullet-type ()
|
||||
(defun org-fix-bullet-type (&optional force-bullet)
|
||||
"Make sure all items in this list have the same bullet as the first item.
|
||||
Also, fix the indentation."
|
||||
(interactive)
|
||||
|
@ -740,7 +851,7 @@ Also, fix the indentation."
|
|||
(beginning-of-line 1)
|
||||
;; find out what the bullet type is
|
||||
(looking-at "[ \t]*\\(\\S-+\\)")
|
||||
(setq bullet (concat (match-string 1) " "))
|
||||
(setq bullet (concat (or force-bullet (match-string 1)) " "))
|
||||
(if (and org-list-two-spaces-after-bullet-regexp
|
||||
(string-match org-list-two-spaces-after-bullet-regexp bullet))
|
||||
(setq bullet (concat bullet " ")))
|
||||
|
@ -759,7 +870,7 @@ Also, fix the indentation."
|
|||
(skip-chars-forward " \t")
|
||||
(looking-at "\\S-+ *")
|
||||
(setq oldbullet (match-string 0))
|
||||
(replace-match bullet)
|
||||
(unless (equal bullet oldbullet) (replace-match bullet))
|
||||
(org-shift-item-indentation (- (length bullet) (length oldbullet))))))
|
||||
(goto-line line)
|
||||
(org-move-to-column col)
|
||||
|
@ -807,7 +918,6 @@ I.e. to the first item in this list."
|
|||
(when (org-at-item-p) (setq pos (point-at-bol)))))))
|
||||
(goto-char pos)))
|
||||
|
||||
|
||||
(defun org-end-of-item-list ()
|
||||
"Go to the end of the current item list.
|
||||
I.e. to the text after the last item."
|
||||
|
@ -822,7 +932,9 @@ I.e. to the text after the last item."
|
|||
(catch 'next
|
||||
(beginning-of-line 2)
|
||||
(if (looking-at "[ \t]*$")
|
||||
(throw (if (eobp) 'exit 'next) t))
|
||||
(if (eobp)
|
||||
(progn (setq pos (point)) (throw 'exit t))
|
||||
(throw 'next t)))
|
||||
(skip-chars-forward " \t") (setq ind1 (current-column))
|
||||
(if (or (< ind1 ind)
|
||||
(and (= ind1 ind)
|
||||
|
@ -845,22 +957,25 @@ I.e. to the text after the last item."
|
|||
(defun org-indent-item (arg)
|
||||
"Indent a local list item."
|
||||
(interactive "p")
|
||||
(and (org-region-active-p) (org-cursor-to-region-beginning))
|
||||
(unless (org-at-item-p)
|
||||
(error "Not on an item"))
|
||||
(save-excursion
|
||||
(let (beg end ind ind1 tmp delta ind-down ind-up)
|
||||
(let (beg end ind ind1 ind-bul delta ind-down ind-up firstp)
|
||||
(setq firstp (org-first-list-item-p))
|
||||
(save-excursion
|
||||
(setq end (and (org-region-active-p) (region-end)))
|
||||
(if (memq last-command '(org-shiftmetaright org-shiftmetaleft))
|
||||
(setq beg org-last-indent-begin-marker
|
||||
end org-last-indent-end-marker)
|
||||
(org-beginning-of-item)
|
||||
(setq beg (move-marker org-last-indent-begin-marker (point)))
|
||||
(org-end-of-item)
|
||||
(setq end (move-marker org-last-indent-end-marker (point))))
|
||||
(setq end (move-marker org-last-indent-end-marker (or end (point)))))
|
||||
(goto-char beg)
|
||||
(setq tmp (org-item-indent-positions)
|
||||
ind (car tmp)
|
||||
ind-down (nth 2 tmp)
|
||||
ind-up (nth 1 tmp)
|
||||
(setq ind-bul (org-item-indent-positions)
|
||||
ind (caar ind-bul)
|
||||
ind-down (car (nth 2 ind-bul))
|
||||
ind-up (car (nth 1 ind-bul))
|
||||
delta (if (> arg 0)
|
||||
(if ind-down (- ind-down ind) 2)
|
||||
(if ind-up (- ind-up ind) -2)))
|
||||
|
@ -870,13 +985,16 @@ I.e. to the text after the last item."
|
|||
(skip-chars-forward " \t") (setq ind1 (current-column))
|
||||
(delete-region (point-at-bol) (point))
|
||||
(or (eolp) (org-indent-to-column (+ ind1 delta)))
|
||||
(beginning-of-line 2))))
|
||||
(org-fix-bullet-type)
|
||||
(org-maybe-renumber-ordered-list-safe)
|
||||
(save-excursion
|
||||
(beginning-of-line 0)
|
||||
(condition-case nil (org-beginning-of-item) (error nil))
|
||||
(org-maybe-renumber-ordered-list-safe)))
|
||||
(beginning-of-line 2)))
|
||||
(org-fix-bullet-type
|
||||
(and (> arg 0)
|
||||
(not firstp)
|
||||
(cdr (assoc (cdr (nth 0 ind-bul)) org-list-demote-modify-bullet))))
|
||||
(org-maybe-renumber-ordered-list-safe)
|
||||
(save-excursion
|
||||
(beginning-of-line 0)
|
||||
(condition-case nil (org-beginning-of-item) (error nil))
|
||||
(org-maybe-renumber-ordered-list-safe))))
|
||||
|
||||
(defun org-item-indent-positions ()
|
||||
"Return indentation for plain list items.
|
||||
|
@ -885,13 +1003,15 @@ parent indentation and the indentation a child should have.
|
|||
Assumes cursor in item line."
|
||||
(let* ((bolpos (point-at-bol))
|
||||
(ind (org-get-indentation))
|
||||
ind-down ind-up pos)
|
||||
(bullet (org-get-bullet))
|
||||
ind-down ind-up bullet-up bullet-down pos)
|
||||
(save-excursion
|
||||
(org-beginning-of-item-list)
|
||||
(skip-chars-backward "\n\r \t")
|
||||
(when (org-in-item-p)
|
||||
(org-beginning-of-item)
|
||||
(setq ind-up (org-get-indentation))))
|
||||
(setq ind-up (org-get-indentation))
|
||||
(setq bullet-up (org-get-bullet))))
|
||||
(setq pos (point))
|
||||
(save-excursion
|
||||
(cond
|
||||
|
@ -899,14 +1019,30 @@ Assumes cursor in item line."
|
|||
(error nil))
|
||||
(or (forward-char 1) t)
|
||||
(re-search-forward "^\\([ \t]*\\([-+]\\|\\([0-9]+[.)]\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)" bolpos t))
|
||||
(setq ind-down (org-get-indentation)))
|
||||
(setq ind-down (org-get-indentation)
|
||||
bullet-down (org-get-bullet)))
|
||||
((and (goto-char pos)
|
||||
(org-at-item-p))
|
||||
(goto-char (match-end 0))
|
||||
(skip-chars-forward " \t")
|
||||
(setq ind-down (current-column)))))
|
||||
(list ind ind-up ind-down)))
|
||||
(setq ind-down (current-column)
|
||||
bullet-down (org-get-bullet)))))
|
||||
(if (and bullet-down (string-match "\\`[0-9]+\\(\\.\\|)\\)\\'" bullet-down))
|
||||
(setq bullet-down (concat "1" (match-string 1 bullet-down))))
|
||||
(if (and bullet-up (string-match "\\`[0-9]+\\(\\.\\|)\\)\\'" bullet-up))
|
||||
(setq bullet-up (concat "1" (match-string 1 bullet-up))))
|
||||
(if (and bullet (string-match "\\`[0-9]+\\(\\.\\|)\\)\\'" bullet))
|
||||
(setq bullet (concat "1" (match-string 1 bullet))))
|
||||
(list (cons ind bullet)
|
||||
(cons ind-up bullet-up)
|
||||
(cons ind-down bullet-down))))
|
||||
|
||||
(defun org-get-bullet ()
|
||||
(save-excursion
|
||||
(goto-char (point-at-bol))
|
||||
(and (looking-at
|
||||
"^\\([ \t]*\\([-+]\\|\\([0-9]+[.)]\\)\\)\\|[ \t]+\\(\\*\\)\\)\\( \\|$\\)")
|
||||
(or (match-string 2) (match-string 4)))))
|
||||
|
||||
;;; Send and receive lists
|
||||
|
||||
|
@ -968,16 +1104,54 @@ cdr is the indentation string."
|
|||
(progn (goto-char (point-min)) (point))
|
||||
(cons (match-beginning 0) (match-string 1)))))
|
||||
|
||||
(defun org-list-goto-true-beginning ()
|
||||
"Go to the beginning of the list at point."
|
||||
(beginning-of-line 1)
|
||||
(while (looking-at org-list-beginning-re)
|
||||
(beginning-of-line 0))
|
||||
(progn
|
||||
(re-search-forward org-list-beginning-re nil t)
|
||||
(goto-char (match-beginning 0))))
|
||||
|
||||
(defun org-list-make-subtree ()
|
||||
"Convert the plain list at point into a subtree."
|
||||
(interactive)
|
||||
(org-list-goto-true-beginning)
|
||||
(let ((list (org-list-parse-list t)) nstars)
|
||||
(save-excursion
|
||||
(if (condition-case nil
|
||||
(org-back-to-heading)
|
||||
(error nil))
|
||||
(progn (re-search-forward org-complex-heading-regexp nil t)
|
||||
(setq nstars (length (match-string 1))))
|
||||
(setq nstars 0)))
|
||||
(org-list-make-subtrees list (1+ nstars))))
|
||||
|
||||
(defun org-list-make-subtrees (list level)
|
||||
"Convert LIST into subtrees starting at LEVEL."
|
||||
(if (symbolp (car list))
|
||||
(org-list-make-subtrees (cdr list) level)
|
||||
(mapcar (lambda (item)
|
||||
(if (stringp item)
|
||||
(insert (make-string
|
||||
(if org-odd-levels-only
|
||||
(1- (* 2 level)) level) ?*) " " item "\n")
|
||||
(org-list-make-subtrees item (1+ level))))
|
||||
list)))
|
||||
|
||||
(defun org-list-end (indent)
|
||||
"Return the position of the end of the list.
|
||||
INDENT is the indentation of the list."
|
||||
INDENT is the indentation of the list, as a string."
|
||||
(save-excursion
|
||||
(catch 'exit
|
||||
(while (or (looking-at org-list-beginning-re)
|
||||
(looking-at (concat "^" indent "[ \t]+\\|^$")))
|
||||
(looking-at (concat "^" indent "[ \t]+\\|^$"))
|
||||
(> (or (get-text-property (point) 'original-indentation) -1)
|
||||
(length indent)))
|
||||
(if (eq (point) (point-max))
|
||||
(throw 'exit (point-max)))
|
||||
(forward-line 1))) (point)))
|
||||
(forward-line 1)))
|
||||
(point)))
|
||||
|
||||
(defun org-list-insert-radio-list ()
|
||||
"Insert a radio list template appropriate for this major mode."
|
||||
|
@ -1002,7 +1176,7 @@ this list."
|
|||
(catch 'exit
|
||||
(unless (org-at-item-p) (error "Not at a list"))
|
||||
(save-excursion
|
||||
(goto-char (car (org-list-item-beginning)))
|
||||
(org-list-goto-true-beginning)
|
||||
(beginning-of-line 0)
|
||||
(unless (looking-at "#\\+ORGLST: *SEND +\\([a-zA-Z0-9_]+\\) +\\([^ \t\r\n]+\\)\\( +.*\\)?")
|
||||
(if maybe
|
||||
|
@ -1150,7 +1324,7 @@ with overruling parameters for `org-list-to-generic'."
|
|||
LIST is as returnd by `org-list-parse-list'. PARAMS is a property list
|
||||
with overruling parameters for `org-list-to-generic'."
|
||||
(org-list-to-generic
|
||||
list
|
||||
list
|
||||
(org-combine-plists
|
||||
'(:splicep nil :ostart "@itemize @minus" :oend "@end itemize"
|
||||
:ustart "@enumerate" :uend "@end enumerate"
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
;;; org-mac-message.el --- Support for links to Apple Mail messages from within Org-mode
|
||||
;;; org-mac-message.el --- Links to Apple Mail.app messages from within Org-mode
|
||||
|
||||
;; Copyright (C) 2008, 2009 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: John Wiegley <johnw@gnu.org>
|
||||
;; Version: 6.21b
|
||||
;; Christopher Suckling <suckling at gmail dot com>
|
||||
|
||||
;; Version: 6.29c
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
|
||||
;; This file is part of GNU Emacs.
|
||||
|
@ -22,14 +24,39 @@
|
|||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
;; This file implements links to Apple Mail messages from within Org-mode.
|
||||
;; This file implements links to Apple Mail.app messages from within Org-mode.
|
||||
;; Org-mode does not load this module by default - if you would actually like
|
||||
;; this to happen then configure the variable `org-modules'.
|
||||
|
||||
;; If you would like to create links to all flagged messages in an
|
||||
;; Apple Mail.app account, please customize the variable
|
||||
;; `org-mac-mail-account' and then call one of the following functions:
|
||||
|
||||
;; (org-mac-message-insert-selected) copies a formatted list of links to
|
||||
;; the kill ring.
|
||||
|
||||
;; (org-mac-message-insert-selected) inserts at point links to any
|
||||
;; messages selected in Mail.app.
|
||||
|
||||
;; (org-mac-message-insert-flagged) searches within an org-mode buffer
|
||||
;; for a specific heading, creating it if it doesn't exist. Any
|
||||
;; message:// links within the first level of the heading are deleted
|
||||
;; and replaced with links to flagged messages.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'org)
|
||||
|
||||
(defgroup org-mac-flagged-mail nil
|
||||
"Options concerning linking to flagged Mail.app messages"
|
||||
:tag "Org Mail.app"
|
||||
:group 'org-link)
|
||||
|
||||
(defcustom org-mac-mail-account "customize"
|
||||
"The Mail.app account in which to search for flagged messages"
|
||||
:group 'org-mac-flagged-mail
|
||||
:type 'string)
|
||||
|
||||
(org-add-link-type "message" 'org-mac-message-open)
|
||||
|
||||
;; In mac.c, removed in Emacs 23.
|
||||
|
@ -53,29 +80,138 @@ This will use the command `open' with the message URL."
|
|||
(start-process (concat "open message:" message-id) nil
|
||||
"open" (concat "message://<" (substring message-id 2) ">")))
|
||||
|
||||
(defun org-mac-message-insert-link ()
|
||||
"Insert a link to the messages currently selected in Apple Mail.
|
||||
This will use applescript to get the message-id and the subject of the
|
||||
active mail in AppleMail and make a link out of it."
|
||||
(interactive)
|
||||
(insert (org-mac-message-get-link)))
|
||||
(defun as-get-selected-mail ()
|
||||
"AppleScript to create links to selected messages in Mail.app"
|
||||
(do-applescript
|
||||
(concat
|
||||
"tell application \"Mail\"\n"
|
||||
"set theLinkList to {}\n"
|
||||
"set theSelection to selection\n"
|
||||
"repeat with theMessage in theSelection\n"
|
||||
"set theID to message id of theMessage\n"
|
||||
"set theSubject to subject of theMessage\n"
|
||||
"set theLink to \"message://\" & theID & \"::split::\" & theSubject & \"\n\"\n"
|
||||
"copy theLink to end of theLinkList\n"
|
||||
"end repeat\n"
|
||||
"return theLinkList as string\n"
|
||||
"end tell")))
|
||||
|
||||
(defun org-mac-message-get-link ()
|
||||
"Insert a link to the messages currently selected in Apple Mail.
|
||||
(defun as-get-flagged-mail ()
|
||||
"AppleScript to create links to flagged messages in Mail.app"
|
||||
(do-applescript
|
||||
(concat
|
||||
;; Is Growl installed?
|
||||
"tell application \"System Events\"\n"
|
||||
"set growlHelpers to the name of every process whose creator type contains \"GRRR\"\n"
|
||||
"if (count of growlHelpers) > 0 then\n"
|
||||
"set growlHelperApp to item 1 of growlHelpers\n"
|
||||
"else\n"
|
||||
"set growlHelperApp to \"\"\n"
|
||||
"end if\n"
|
||||
"end tell\n"
|
||||
|
||||
;; Get links
|
||||
"tell application \"Mail\"\n"
|
||||
"set theMailboxes to every mailbox of account \"" org-mac-mail-account "\"\n"
|
||||
"set theLinkList to {}\n"
|
||||
"repeat with aMailbox in theMailboxes\n"
|
||||
"set theSelection to (every message in aMailbox whose flagged status = true)\n"
|
||||
"repeat with theMessage in theSelection\n"
|
||||
"set theID to message id of theMessage\n"
|
||||
"set theSubject to subject of theMessage\n"
|
||||
"set theLink to \"message://\" & theID & \"::split::\" & theSubject & \"\n\"\n"
|
||||
"copy theLink to end of theLinkList\n"
|
||||
|
||||
;; Report progress through Growl
|
||||
;; This "double tell" idiom is described in detail at
|
||||
;; http://macscripter.net/viewtopic.php?id=24570 The
|
||||
;; script compiler needs static knowledge of the
|
||||
;; growlHelperApp. Hmm, since we're compiling
|
||||
;; on-the-fly here, this is likely to be way less
|
||||
;; portable than I'd hoped. It'll work when the name
|
||||
;; is still "GrowlHelperApp", though.
|
||||
"if growlHelperApp is not \"\" then\n"
|
||||
"tell application \"GrowlHelperApp\"\n"
|
||||
"tell application growlHelperApp\n"
|
||||
"set the allNotificationsList to {\"FlaggedMail\"}\n"
|
||||
"set the enabledNotificationsList to allNotificationsList\n"
|
||||
"register as application \"FlaggedMail\" all notifications allNotificationsList default notifications enabledNotificationsList icon of application \"Mail\"\n"
|
||||
"notify with name \"FlaggedMail\" title \"Importing flagged message\" description theSubject application name \"FlaggedMail\"\n"
|
||||
"end tell\n"
|
||||
"end tell\n"
|
||||
"end if\n"
|
||||
"end repeat\n"
|
||||
"end repeat\n"
|
||||
"return theLinkList as string\n"
|
||||
"end tell")))
|
||||
|
||||
(defun org-mac-message-get-links (&optional select-or-flag)
|
||||
"Create links to the messages currently selected or flagged in Mail.app.
|
||||
This will use AppleScript to get the message-id and the subject of the
|
||||
messages in Mail.app and make a link out of it.
|
||||
When SELECT-OR-FLAG is \"s\", get the selected messages (this is also
|
||||
the default). When SELECT-OR-FLAG is \"f\", get the flagged messages.
|
||||
The Org-syntax text will be pushed to the kill ring, and also returned."
|
||||
(interactive "sLink to (s)elected or (f)lagged messages: ")
|
||||
(setq select-or-flag (or select-or-flag "s"))
|
||||
(message "AppleScript: searching mailboxes...")
|
||||
(let* ((as-link-list
|
||||
(if (string= select-or-flag "s")
|
||||
(as-get-selected-mail)
|
||||
(if (string= select-or-flag "f")
|
||||
(as-get-flagged-mail)
|
||||
(error "Please select \"s\" or \"f\""))))
|
||||
(link-list
|
||||
(mapcar
|
||||
(lambda (x) (if (string-match "\\`\"\\(.*\\)\"\\'" x) (setq x (match-string 1 x))) x)
|
||||
(split-string as-link-list "[\r\n]+")))
|
||||
split-link URL description orglink orglink-insert rtn orglink-list)
|
||||
(while link-list
|
||||
(setq split-link (split-string (pop link-list) "::split::"))
|
||||
(setq URL (car split-link))
|
||||
(setq description (cadr split-link))
|
||||
(when (not (string= URL ""))
|
||||
(setq orglink (org-make-link-string URL description))
|
||||
(push orglink orglink-list)))
|
||||
(setq rtn (mapconcat 'identity orglink-list "\n"))
|
||||
(kill-new rtn)
|
||||
rtn))
|
||||
|
||||
(defun org-mac-message-insert-selected ()
|
||||
"Insert a link to the messages currently selected in Mail.app.
|
||||
This will use applescript to get the message-id and the subject of the
|
||||
active mail in AppleMail and make a link out of it."
|
||||
(let ((subject (do-applescript "tell application \"Mail\"
|
||||
set theMessages to selection
|
||||
subject of beginning of theMessages
|
||||
end tell"))
|
||||
(message-id (do-applescript "tell application \"Mail\"
|
||||
set theMessages to selection
|
||||
message id of beginning of theMessages
|
||||
end tell")))
|
||||
(org-make-link-string
|
||||
(concat "message://"
|
||||
(substring message-id 1 (1- (length message-id))))
|
||||
(substring subject 1 (1- (length subject))))))
|
||||
active mail in Mail.app and make a link out of it."
|
||||
(interactive)
|
||||
(insert (org-mac-message-get-links "s")))
|
||||
|
||||
;; The following line is for backward compatibility
|
||||
(defalias 'org-mac-message-insert-link 'org-mac-message-insert-selected)
|
||||
|
||||
(defun org-mac-message-insert-flagged (org-buffer org-heading)
|
||||
"Asks for an org buffer and a heading within it, and replace message links.
|
||||
If heading exists, delete all message:// links within heading's first
|
||||
level. If heading doesn't exist, create it at point-max. Insert
|
||||
list of message:// links to flagged mail after heading."
|
||||
(interactive "bBuffer in which to insert links: \nsHeading after which to insert links: ")
|
||||
(save-excursion
|
||||
(set-buffer org-buffer)
|
||||
(goto-char (point-min))
|
||||
(let ((isearch-forward t)
|
||||
(message-re "\\[\\[\\(message:\\)\\([^]]+\\)\\]\\(\\[\\([^]]+\\)\\]\\)?\\]"))
|
||||
(if (org-goto-local-search-headings org-heading nil t)
|
||||
(if (not (eobp))
|
||||
(progn
|
||||
(save-excursion
|
||||
(while (re-search-forward
|
||||
message-re (save-excursion (outline-next-heading)) t)
|
||||
(delete-region (match-beginning 0) (match-end 0)))
|
||||
(insert "\n" (org-mac-message-get-links "f")))
|
||||
(flush-lines "^$" (point) (outline-next-heading)))
|
||||
(insert "\n" (org-mac-message-get-links "f")))
|
||||
(goto-char (point-max))
|
||||
(insert "\n")
|
||||
(org-insert-heading)
|
||||
(insert org-heading "\n" (org-mac-message-get-links "f"))))))
|
||||
|
||||
(provide 'org-mac-message)
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
@ -33,14 +33,24 @@
|
|||
|
||||
;;; Code:
|
||||
|
||||
(eval-and-compile
|
||||
(unless (fboundp 'declare-function)
|
||||
(defmacro declare-function (fn file &optional arglist fileonly))))
|
||||
|
||||
(declare-function org-add-props "org-compat" (string plist &rest props))
|
||||
|
||||
(defmacro org-bound-and-true-p (var)
|
||||
"Return the value of symbol VAR if it is bound, else nil."
|
||||
`(and (boundp (quote ,var)) ,var))
|
||||
|
||||
(defmacro org-unmodified (&rest body)
|
||||
"Execute body without changing `buffer-modified-p'."
|
||||
"Execute body without changing `buffer-modified-p'.
|
||||
Also, do not record undo information."
|
||||
`(set-buffer-modified-p
|
||||
(prog1 (buffer-modified-p) ,@body)))
|
||||
(prog1 (buffer-modified-p)
|
||||
(let ((buffer-undo-list t)
|
||||
before-change-functions after-change-functions)
|
||||
,@body))))
|
||||
|
||||
(defmacro org-re (s)
|
||||
"Replace posix classes in regular expression."
|
||||
|
@ -73,10 +83,6 @@
|
|||
,@body)
|
||||
(if pc-mode (partial-completion-mode 1)))))
|
||||
|
||||
(eval-and-compile
|
||||
(unless (fboundp 'declare-function)
|
||||
(defmacro declare-function (fn file &optional arglist fileonly))))
|
||||
|
||||
(defmacro org-maybe-intangible (props)
|
||||
"Add '(intangible t) to PROPS if Emacs version is earlier than Emacs 22.
|
||||
In emacs 21, invisible text is not avoided by the command loop, so the
|
||||
|
@ -110,6 +116,11 @@ We use a macro so that the test can happen at compilation time."
|
|||
`(unless (get-text-property (1- (point)) 'org-protected)
|
||||
,@body))
|
||||
|
||||
(defmacro org-if-unprotected-at (pos &rest body)
|
||||
"Execute BODY if there is no `org-protected' text property at point-1."
|
||||
`(unless (get-text-property ,pos 'org-protected)
|
||||
,@body))
|
||||
|
||||
(defmacro org-with-remote-undo (_buffer &rest _body)
|
||||
"Execute BODY while recording undo information in two buffers."
|
||||
`(let ((_cline (org-current-line))
|
||||
|
@ -160,6 +171,18 @@ We use a macro so that the test can happen at compilation time."
|
|||
((assoc key option) (cdr (assoc key option)))
|
||||
(t (cdr (assq 'default option)))))
|
||||
|
||||
(defsubst org-check-external-command (cmd &optional use no-error)
|
||||
"Check if external progam CMD for USE exists, error if not.
|
||||
When the program does exist, return it's path.
|
||||
When it does not exist and NO-ERROR is set, return nil.
|
||||
Otherwise, throw an error. The optional argument USE can describe what this
|
||||
program is needed for, so that the error message can be more informative."
|
||||
(or (executable-find cmd)
|
||||
(if no-error
|
||||
nil
|
||||
(error "Can't find `%s'%s" cmd
|
||||
(if use (format " (%s)" use) "")))))
|
||||
|
||||
(defsubst org-inhibit-invisibility ()
|
||||
"Modified `buffer-invisibility-spec' for Emacs 21.
|
||||
Some ops with invisible text do not work correctly on Emacs 21. For these
|
||||
|
@ -168,7 +191,7 @@ we turn off invisibility temporarily. Use this in a `let' form."
|
|||
|
||||
(defsubst org-set-local (var value)
|
||||
"Make VAR local in current buffer and set it to VALUE."
|
||||
(set (make-variable-buffer-local var) value))
|
||||
(set (make-local-variable var) value))
|
||||
|
||||
(defsubst org-mode-p ()
|
||||
"Check if the current buffer is in Org-mode."
|
||||
|
@ -228,6 +251,31 @@ This is in contrast to merely setting it to 0."
|
|||
(setq plist (cddr plist)))
|
||||
p))
|
||||
|
||||
|
||||
(defun org-replace-match-keep-properties (newtext &optional fixedcase
|
||||
literal string)
|
||||
"Like `replace-match', but add the text properties found original text."
|
||||
(setq newtext (org-add-props newtext (text-properties-at
|
||||
(match-beginning 0) string)))
|
||||
(replace-match newtext fixedcase literal string))
|
||||
|
||||
(defmacro org-with-limited-levels (&rest body)
|
||||
"Execute BODY with limited number of outline levels."
|
||||
`(let* ((outline-regexp (org-get-limited-outline-regexp)))
|
||||
,@body))
|
||||
|
||||
(defvar org-odd-levels-only) ; defined in org.el
|
||||
(defvar org-inlinetask-min-level) ; defined in org-inlinetask.el
|
||||
(defun org-get-limited-outline-regexp ()
|
||||
"Return outline-regexp with limited number of levels.
|
||||
The number of levels is controlled by "
|
||||
(if (or (not (org-mode-p)) (not (featurep 'org-inlinetask)))
|
||||
|
||||
outline-regexp
|
||||
(let* ((limit-level (1- org-inlinetask-min-level))
|
||||
(nstars (if org-odd-levels-only (1- (* limit-level 2)) limit-level)))
|
||||
(format "\\*\\{1,%d\\} " nstars))))
|
||||
|
||||
(provide 'org-macs)
|
||||
|
||||
;; arch-tag: 7e6a73ce-aac9-4fc0-9b30-ce6f89dc6668
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
;; Author: Thomas Baumann <thomas dot baumann at ch dot tum dot de>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
;;
|
||||
;; Author: Piotr Zielinski <piotr dot zielinski at gmail dot com>
|
||||
;; Maintainer: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
@ -422,7 +422,17 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
|
|||
(loop for priority from ?A to org-lowest-priority
|
||||
collect (char-to-string priority)))
|
||||
|
||||
(defun org-mouse-todo-menu (state)
|
||||
"Create the menu with TODO keywords."
|
||||
(append
|
||||
(let ((kwds org-todo-keywords-1))
|
||||
(org-mouse-keyword-menu
|
||||
kwds
|
||||
`(lambda (kwd) (org-todo kwd))
|
||||
(lambda (kwd) (equal state kwd))))))
|
||||
|
||||
(defun org-mouse-tag-menu () ;todo
|
||||
"Create the tags menu"
|
||||
(append
|
||||
(let ((tags (org-get-tags)))
|
||||
(org-mouse-keyword-menu
|
||||
|
@ -441,7 +451,6 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
|
|||
["Set Tags ..." (org-set-tags) t])))
|
||||
|
||||
|
||||
|
||||
(defun org-mouse-set-tags (tags)
|
||||
(save-excursion
|
||||
;; remove existing tags first
|
||||
|
@ -621,9 +630,6 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
|
|||
(set-match-data ',match)
|
||||
(apply ',function rest)))))
|
||||
|
||||
(defun org-mouse-todo-keywords ()
|
||||
(if (boundp 'org-todo-keywords-1) org-todo-keywords-1 org-todo-keywords))
|
||||
|
||||
(defun org-mouse-match-todo-keyword ()
|
||||
(save-excursion
|
||||
(org-back-to-heading)
|
||||
|
@ -691,10 +697,10 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
|
|||
(org-mouse-remove-match-and-spaces))))]
|
||||
)))
|
||||
((and (org-mouse-looking-at "\\b\\w+" "a-zA-Z0-9_")
|
||||
(member (match-string 0) (org-mouse-todo-keywords)))
|
||||
(member (match-string 0) org-todo-keywords-1))
|
||||
(popup-menu
|
||||
`(nil
|
||||
,@(org-mouse-keyword-replace-menu (org-mouse-todo-keywords))
|
||||
,@(org-mouse-todo-menu (match-string 0))
|
||||
"--"
|
||||
["Check TODOs" org-show-todo-tree t]
|
||||
["List all TODO keywords" org-todo-list t]
|
||||
|
@ -718,7 +724,7 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
|
|||
["Open" org-open-at-point t]
|
||||
["Open in Emacs" (org-open-at-point t) t]
|
||||
"--"
|
||||
["Copy link" (kill-new (match-string 0))]
|
||||
["Copy link" (org-kill-new (match-string 0))]
|
||||
["Cut link"
|
||||
(progn
|
||||
(kill-region (match-beginning 0) (match-end 0))
|
||||
|
@ -832,9 +838,7 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
|
|||
"--"
|
||||
,@(org-mouse-tag-menu))
|
||||
("TODO Status"
|
||||
,@(progn (org-mouse-match-todo-keyword)
|
||||
(org-mouse-keyword-replace-menu (org-mouse-todo-keywords)
|
||||
1)))
|
||||
,@(org-mouse-todo-menu (org-get-todo-state)))
|
||||
["Show Tags"
|
||||
(with-current-buffer org-mouse-main-buffer (org-agenda-show-tags))
|
||||
:visible (not org-mouse-direct)]
|
||||
|
@ -1132,8 +1136,8 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
|
|||
(if (featurep 'xemacs) [button3] [mouse-3])
|
||||
'org-mouse-show-context-menu)
|
||||
(define-key org-agenda-keymap [down-mouse-3] 'org-mouse-move-tree-start)
|
||||
(define-key org-agenda-keymap [C-mouse-4] 'org-agenda-earlier)
|
||||
(define-key org-agenda-keymap [C-mouse-5] 'org-agenda-later)
|
||||
(define-key org-agenda-keymap (if (featurep 'xemacs) [(control mouse-4)] [C-mouse-4]) 'org-agenda-earlier)
|
||||
(define-key org-agenda-keymap (if (featurep 'xemacs) [(control mouse-5)] [C-mouse-5]) 'org-agenda-later)
|
||||
(define-key org-agenda-keymap [drag-mouse-3]
|
||||
'(lambda (event) (interactive "e")
|
||||
(case (org-mouse-get-gesture event)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
;; Author: Eric Schulte <schulte dot eric at gmail dot com>
|
||||
;; Keywords: tables, plotting
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
@ -64,6 +64,7 @@ Returns the resulting property list."
|
|||
("file" . :file)
|
||||
("labels" . :labels)
|
||||
("map" . :map)
|
||||
("timeind" . :timeind)
|
||||
("timefmt" . :timefmt)))
|
||||
(multiples '("set" "line"))
|
||||
(regexp ":\\([\"][^\"]+?[\"]\\|[(][^)]+?[)]\\|[^ \t\n\r;,.]*\\)")
|
||||
|
@ -181,9 +182,11 @@ and dependant variables."
|
|||
(setf back-edge "") (setf front-edge "")))))
|
||||
row-vals))
|
||||
|
||||
(defun org-plot/gnuplot-script (data-file num-cols params)
|
||||
(defun org-plot/gnuplot-script (data-file num-cols params &optional preface)
|
||||
"Write a gnuplot script to DATA-FILE respecting the options set in PARAMS.
|
||||
NUM-COLS controls the number of columns plotted in a 2-d plot."
|
||||
NUM-COLS controls the number of columns plotted in a 2-d plot.
|
||||
Optional argument PREFACE returns only option parameters in a
|
||||
manner suitable for prepending to a user-specified script."
|
||||
(let* ((type (plist-get params :plot-type))
|
||||
(with (if (equal type 'grid)
|
||||
'pm3d
|
||||
|
@ -238,7 +241,8 @@ NUM-COLS controls the number of columns plotted in a 2-d plot."
|
|||
(add-to-script (concat "set timefmt \""
|
||||
(or timefmt ;; timefmt passed to gnuplot
|
||||
"%Y-%m-%d-%H:%M:%S") "\"")))
|
||||
(case type ;; plot command
|
||||
(unless preface
|
||||
(case type ;; plot command
|
||||
('2d (dotimes (col num-cols)
|
||||
(unless (and (equal type '2d)
|
||||
(or (and ind (equal (+ 1 col) ind))
|
||||
|
@ -259,8 +263,8 @@ NUM-COLS controls the number of columns plotted in a 2-d plot."
|
|||
('grid
|
||||
(setq plot-lines (list (format "'%s' with %s title ''"
|
||||
data-file with)))))
|
||||
(add-to-script
|
||||
(concat plot-cmd " " (mapconcat 'identity (reverse plot-lines) ",\\\n ")))
|
||||
(add-to-script
|
||||
(concat plot-cmd " " (mapconcat 'identity (reverse plot-lines) ",\\\n "))))
|
||||
script)))
|
||||
|
||||
;;-----------------------------------------------------------------------------
|
||||
|
@ -328,10 +332,13 @@ line directly before or after the table."
|
|||
;; write script
|
||||
(with-temp-buffer
|
||||
(if (plist-get params :script) ;; user script
|
||||
(progn (insert-file-contents (plist-get params :script))
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "$datafile" nil t)
|
||||
(replace-match data-file nil nil)))
|
||||
(progn (insert
|
||||
(org-plot/gnuplot-script data-file num-cols params t))
|
||||
(insert "\n")
|
||||
(insert-file-contents (plist-get params :script))
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "$datafile" nil t)
|
||||
(replace-match data-file nil nil)))
|
||||
(insert
|
||||
(org-plot/gnuplot-script data-file num-cols params)))
|
||||
;; graph table
|
||||
|
@ -339,7 +346,7 @@ line directly before or after the table."
|
|||
(gnuplot-send-buffer-to-gnuplot))
|
||||
;; cleanup
|
||||
(bury-buffer (get-buffer "*gnuplot*"))
|
||||
(delete-file data-file))))
|
||||
(run-with-idle-timer 0.1 nil (lambda () (delete-file data-file))))))
|
||||
|
||||
(provide 'org-plot)
|
||||
|
||||
|
|
636
lisp/org/org-protocol.el
Normal file
636
lisp/org/org-protocol.el
Normal file
|
@ -0,0 +1,636 @@
|
|||
;;; org-protocol.el --- Intercept calls from emacsclient to trigger custom actions.
|
||||
;;
|
||||
;; Copyright (c) 2008, 2009
|
||||
;; Free Software Foundation, Inc.
|
||||
;;
|
||||
;; Author: Bastien Guerry <bzg AT altern DOT org>
|
||||
;; Author: Daniel M German <dmg AT uvic DOT org>
|
||||
;; Author: Sebastian Rose <sebastian_rose AT gmx DOT de>
|
||||
;; Author: Ross Patterson <me AT rpatterson DOT net>
|
||||
;; Maintainer: Sebastian Rose <sebastian_rose AT gmx DOT de>
|
||||
;; Keywords: org, emacsclient, wp
|
||||
;; Version: 6.29c
|
||||
|
||||
;; 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:
|
||||
;;
|
||||
;; Intercept calls from emacsclient to trigger custom actions.
|
||||
;;
|
||||
;; This is done by advising `server-visit-files' to scann the list of filenames
|
||||
;; for `org-protocol-the-protocol' and sub-procols defined in
|
||||
;; `org-protocol-protocol-alist' and `org-protocol-protocol-alist-default'.
|
||||
;;
|
||||
;; Any application that supports calling external programs with an URL
|
||||
;; as argument may be used with this functionality.
|
||||
;;
|
||||
;;
|
||||
;; Usage:
|
||||
;; ------
|
||||
;;
|
||||
;; 1.) Add this to your init file (.emacs probably):
|
||||
;;
|
||||
;; (add-to-list 'load-path "/path/to/org-protocol/")
|
||||
;; (require 'org-protocol)
|
||||
;;
|
||||
;; 3.) Ensure emacs-server is up and running.
|
||||
;; 4.) Try this from the command line (adjust the URL as needed):
|
||||
;;
|
||||
;; $ emacsclient \
|
||||
;; org-protocol://store-link://http:%2F%2Flocalhost%2Findex.html/The%20title
|
||||
;;
|
||||
;; 5.) Optionally add custom sub-protocols and handlers:
|
||||
;;
|
||||
;; (setq org-protocol-protocol-alist
|
||||
;; '(("my-protocol"
|
||||
;; :protocol "my-protocol"
|
||||
;; :function my-protocol-handler-fuction)))
|
||||
;;
|
||||
;; A "sub-protocol" will be found in URLs like this:
|
||||
;;
|
||||
;; org-protocol://sub-protocol://data
|
||||
;;
|
||||
;; If it works, you can now setup other applications for using this feature.
|
||||
;;
|
||||
;;
|
||||
;; As of March 2009 Firefox users follow the steps documented on
|
||||
;; http://kb.mozillazine.org/Register_protocol, Opera setup is described here:
|
||||
;; http://www.opera.com/support/kb/view/535/
|
||||
;;
|
||||
;;
|
||||
;; Documentation
|
||||
;; -------------
|
||||
;;
|
||||
;; org-protocol.el comes with and installs handlers to open sources of published
|
||||
;; online content, store and insert the browser's URLs and cite online content
|
||||
;; by clicking on a bookmark in Firefox, Opera and probably other browsers and
|
||||
;; applications:
|
||||
;;
|
||||
;; * `org-protocol-open-source' uses the sub-protocol \"open-source\" and maps
|
||||
;; URLs to local filenames defined in `org-protocol-project-alist'.
|
||||
;;
|
||||
;; * `org-protocol-store-link' stores an Org-link (if Org-mode is present) and
|
||||
;; pushes the browsers URL to the `kill-ring' for yanking. This handler is
|
||||
;; triggered through the sub-protocol \"store-link\".
|
||||
;;
|
||||
;; * Call `org-protocol-remember' by using the sub-protocol \"remember\". If
|
||||
;; Org-mode is loaded, emacs will popup a remember buffer and fill the
|
||||
;; template with the data provided. I.e. the browser's URL is inserted as an
|
||||
;; 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.
|
||||
;;
|
||||
;; You may use the same bookmark URL for all those standard handlers and just
|
||||
;; adjust the sub-protocol used:
|
||||
;;
|
||||
;; location.href='org-protocol://sub-protocol://'+
|
||||
;; encodeURIComponent(location.href)+'/'+
|
||||
;; encodeURIComponent(document.title)+'/'+
|
||||
;; encodeURIComponent(window.getSelection())
|
||||
;;
|
||||
;; The handler for the sub-protocol \"remember\" detects an optional template
|
||||
;; char that, if present, triggers the use of a special template.
|
||||
;; Example:
|
||||
;;
|
||||
;; location.href='org-protocol://sub-protocol://x/'+ ...
|
||||
;;
|
||||
;; use template ?x.
|
||||
;;
|
||||
;; Note, that using double shlashes is optional from org-protocol.el's point of
|
||||
;; view because emacsclient sqashes the slashes to one.
|
||||
;;
|
||||
;;
|
||||
;; provides: 'org-protocol
|
||||
;;
|
||||
;;; Code:
|
||||
|
||||
(require 'org)
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
|
||||
(declare-function org-publish-initialize-files-alist "org-publish"
|
||||
(&optional refresh))
|
||||
(declare-function org-publish-get-project-from-filename "org-publish"
|
||||
(filename &optional up))
|
||||
(declare-function server-edit "server" ())
|
||||
|
||||
|
||||
(defgroup org-protocol nil
|
||||
"Intercept calls from emacsclient to trigger custom actions.
|
||||
|
||||
This is done by advising `server-visit-files' to scann the list of filenames
|
||||
for `org-protocol-the-protocol' and sub-procols defined in
|
||||
`org-protocol-protocol-alist' and `org-protocol-protocol-alist-default'."
|
||||
:version "22.1"
|
||||
:group 'convenience
|
||||
:group 'org)
|
||||
|
||||
|
||||
;;; Variables:
|
||||
|
||||
(defconst org-protocol-protocol-alist-default
|
||||
'(("org-remember" :protocol "remember" :function org-protocol-remember :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.
|
||||
See `org-protocol-protocol-alist' for a description of this variable.")
|
||||
|
||||
|
||||
(defconst org-protocol-the-protocol "org-protocol"
|
||||
"This is the protocol to detect if org-protocol.el is loaded.
|
||||
`org-protocol-protocol-alist-default' and `org-protocol-protocol-alist' hold the
|
||||
sub-protocols that trigger the required action. You will have to define just one
|
||||
protocol handler OS-wide (MS-Windows) or per application (Linux). That protocol
|
||||
handler should call emacsclient.")
|
||||
|
||||
|
||||
;;; User variables:
|
||||
|
||||
(defcustom org-protocol-reverse-list-of-files t
|
||||
"* The filenames passed on the commandline are passed to the emacs-server in
|
||||
reversed order. Set to `t' (default) to re-reverse the list, i.e. use the
|
||||
sequence on the command line. If nil, the sequence of the filenames is
|
||||
unchanged."
|
||||
:group 'org-protocol
|
||||
:type 'boolean)
|
||||
|
||||
|
||||
(defcustom org-protocol-project-alist nil
|
||||
"* Map URLs to local filenames for `org-protocol-open-source' (open-source).
|
||||
|
||||
Each element of this list must be of the form:
|
||||
|
||||
(module-name :property value property: value ...)
|
||||
|
||||
where module-name is an arbitrary name. All the values are strings.
|
||||
|
||||
Possible properties are:
|
||||
|
||||
:online-suffix - the suffix to strip from the published URLs
|
||||
:working-suffix - the replacement for online-suffix
|
||||
:base-url - the base URL, e.g. http://www.example.com/project/
|
||||
Last slash required.
|
||||
:working-directory - the local working directory. This is, what base-url will
|
||||
be replaced with.
|
||||
|
||||
Example:
|
||||
|
||||
(setq org-protocol-project-alist
|
||||
'((\"http://orgmode.org/worg/\"
|
||||
:online-suffix \".php\"
|
||||
:working-suffix \".org\"
|
||||
:base-url \"http://orgmode.org/worg/\"
|
||||
:working-directory \"/home/user/org/Worg/\")
|
||||
(\"http://localhost/org-notes/\"
|
||||
:online-suffix \".html\"
|
||||
:working-suffix \".org\"
|
||||
:base-url \"http://localhost/org/\"
|
||||
:working-directory \"/home/user/org/\")))
|
||||
|
||||
Consider using the interactive functions `org-protocol-create' and
|
||||
`org-protocol-create-for-org' to help you filling this variable with valid contents."
|
||||
:group 'org-protocol
|
||||
:type 'alist)
|
||||
|
||||
|
||||
(defcustom org-protocol-protocol-alist nil
|
||||
"* Register custom handlers for org-protocol.
|
||||
|
||||
Each element of this list must be of the form:
|
||||
|
||||
(module-name :protocol protocol :function func :kill-client nil)
|
||||
|
||||
protocol - protocol to detect in a filename without trailing colon and slashes.
|
||||
See rfc1738 section 2.1 for more on this.
|
||||
If you define a protocol \"my-protocol\", `org-protocol-check-filename-for-protocol'
|
||||
will search filenames for \"org-protocol:/my-protocol:/\"
|
||||
and trigger your action for every match. `org-protocol' is defined in
|
||||
`org-protocol-the-protocol'. Double and tripple slashes are compressed
|
||||
to one by emacsclient.
|
||||
|
||||
function - function that handles requests with protocol and takes exactly one
|
||||
argument: the filename with all protocols stripped. If the function
|
||||
returns nil, emacsclient and -server do nothing. Any non-nil return
|
||||
value is considered a valid filename and thus passed to the server.
|
||||
|
||||
`org-protocol.el provides some support for handling those filenames,
|
||||
if you stay with the conventions used for the standard handlers in
|
||||
`org-protocol-protocol-alist-default'. See `org-protocol-split-data'.
|
||||
|
||||
kill-client - If t, kill the client immediately, once the sub-protocol is
|
||||
detected. This is neccessary for actions that can be interupted by
|
||||
`C-g' to avoid dangeling emacsclients. Note, that all other command
|
||||
line arguments but the this one will be discarded, greedy handlers
|
||||
still receive the whole list of arguments though.
|
||||
|
||||
Here is an example:
|
||||
|
||||
(setq org-protocol-protocol-alist
|
||||
'((\"my-protocol\"
|
||||
:protocol \"my-protocol\"
|
||||
:function my-protocol-handler-fuction)
|
||||
(\"your-protocol\"
|
||||
:protocol \"your-protocol\"
|
||||
:function your-protocol-handler-fuction)))"
|
||||
:group 'org-protocol
|
||||
:type '(alist))
|
||||
|
||||
(defcustom org-protocol-default-template-key "w"
|
||||
"The default org-remember-templates key to use."
|
||||
:group 'org-protocol
|
||||
:type 'string)
|
||||
|
||||
|
||||
;;; Helper functions:
|
||||
|
||||
(defun org-protocol-sanitize-uri (uri)
|
||||
"emacsclient compresses double and tripple slashes.
|
||||
Slashes are sanitized to double slashes here."
|
||||
(when (string-match "^\\([a-z]+\\):/" uri)
|
||||
(let* ((splitparts (split-string uri "/+")))
|
||||
(setq uri (concat (car splitparts) "//" (mapconcat 'identity (cdr splitparts) "/")))))
|
||||
uri)
|
||||
|
||||
|
||||
(defun org-protocol-split-data(data &optional unhexify separator)
|
||||
"Split, what a org-protocol handler function gets as only argument.
|
||||
data is that one argument. Data is splitted at each occurrence of separator
|
||||
(regexp). If no separator is specified or separator is nil, assume \"/+\".
|
||||
The results of that splitting are return 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 "/+"))
|
||||
(split-parts (split-string data sep)))
|
||||
(if unhexify
|
||||
(if (fboundp unhexify)
|
||||
(mapcar unhexify split-parts)
|
||||
(mapcar 'org-protocol-unhex-string split-parts))
|
||||
split-parts)))
|
||||
|
||||
(defun org-protocol-unhex-string(str)
|
||||
"Unhex hexified unicode strings as returned from the JavaScript function
|
||||
encodeURIComponent. E.g. `%C3%B6' is the german Umlaut `ü'."
|
||||
(setq str (or str ""))
|
||||
(let ((tmp "")
|
||||
(case-fold-search t))
|
||||
(while (string-match "\\(%[0-9a-f][0-9a-f]\\)+" str)
|
||||
(let* ((start (match-beginning 0))
|
||||
(end (match-end 0))
|
||||
(hex (match-string 0 str))
|
||||
(replacement (org-protocol-unhex-compound hex)))
|
||||
(setq tmp (concat tmp (substring str 0 start) replacement))
|
||||
(setq str (substring str end))))
|
||||
(setq tmp (concat tmp str))
|
||||
tmp))
|
||||
|
||||
|
||||
(defun org-protocol-unhex-compound (hex)
|
||||
"Unhexify unicode hex-chars. E.g. `%C3%B6' is the german Umlaut `ü'."
|
||||
(let* ((bytes (remove "" (split-string hex "%")))
|
||||
(ret "")
|
||||
(eat 0)
|
||||
(sum 0))
|
||||
(while bytes
|
||||
(let* ((b (pop bytes))
|
||||
(a (elt b 0))
|
||||
(b (elt b 1))
|
||||
(c1 (if (> a ?9) (+ 10 (- a ?A)) (- a ?0)))
|
||||
(c2 (if (> b ?9) (+ 10 (- b ?A)) (- b ?0)))
|
||||
(val (+ (lsh c1 4) c2))
|
||||
(shift
|
||||
(if (= 0 eat) ;; new byte
|
||||
(if (>= val 252) 6
|
||||
(if (>= val 248) 5
|
||||
(if (>= val 240) 4
|
||||
(if (>= val 224) 3
|
||||
(if (>= val 192) 2 0)))))
|
||||
6))
|
||||
(xor
|
||||
(if (= 0 eat) ;; new byte
|
||||
(if (>= val 252) 252
|
||||
(if (>= val 248) 248
|
||||
(if (>= val 240) 240
|
||||
(if (>= val 224) 224
|
||||
(if (>= val 192) 192 0)))))
|
||||
128)))
|
||||
(if (>= val 192) (setq eat shift))
|
||||
(setq val (logxor val xor))
|
||||
(setq sum (+ (lsh sum shift) val))
|
||||
(if (> eat 0) (setq eat (- eat 1)))
|
||||
(when (= 0 eat)
|
||||
(setq ret (concat ret (char-to-string sum)))
|
||||
(setq sum 0))
|
||||
)) ;; end (while bytes
|
||||
ret ))
|
||||
|
||||
(defun org-protocol-flatten-greedy (param-list &optional strip-path replacement)
|
||||
"Greedy handlers might recieve a list like this from emacsclient:
|
||||
'( (\"/dir/org-protocol:/greedy:/~/path1\" (23 . 12)) (\"/dir/param\")
|
||||
where \"/dir/\" is the absolute path to emacsclients working directory. This
|
||||
function transforms it into a flat list utilizing `org-protocol-flatten' and
|
||||
transforms the elements of that list as follows:
|
||||
|
||||
If strip-path is non-nil, remove the \"/dir/\" prefix from all members of
|
||||
param-list.
|
||||
|
||||
If replacement is string, replace the \"/dir/\" prefix with it.
|
||||
|
||||
The first parameter, the one that contains the protocols, is always changed.
|
||||
Everything up to the end of the protocols is stripped.
|
||||
|
||||
Note, that this function will always behave as if
|
||||
`org-protocol-reverse-list-of-files' was set to t and the returned list will
|
||||
reflect that. I.e. emacsclients first parameter will be the first one in the
|
||||
returned list."
|
||||
(let* ((l (org-protocol-flatten (if org-protocol-reverse-list-of-files
|
||||
param-list
|
||||
(reverse param-list))))
|
||||
(trigger (car l))
|
||||
(len 0)
|
||||
dir
|
||||
ret)
|
||||
(when (string-match "^\\(.*\\)\\(org-protocol:/+[a-zA-z0-9][-_a-zA-z0-9]*:/+\\)\\(.*\\)" trigger)
|
||||
(setq dir (match-string 1 trigger))
|
||||
(setq len (length dir))
|
||||
(setcar l (concat dir (match-string 3 trigger))))
|
||||
(if strip-path
|
||||
(progn
|
||||
(dolist (e l ret)
|
||||
(setq ret
|
||||
(append ret
|
||||
(list
|
||||
(if (stringp e)
|
||||
(if (stringp replacement)
|
||||
(setq e (concat replacement (substring e len)))
|
||||
(setq e (substring e len)))
|
||||
e)))))
|
||||
ret)
|
||||
l)))
|
||||
|
||||
|
||||
(defun org-protocol-flatten (l)
|
||||
"Greedy handlers might recieve a list like this from emacsclient:
|
||||
'( (\"/dir/org-protocol:/greedy:/~/path1\" (23 . 12)) (\"/dir/param\")
|
||||
where \"/dir/\" is the absolute path to emacsclients working directory. This
|
||||
function transforms it into a flat list."
|
||||
(if (null l) ()
|
||||
(if (listp l)
|
||||
(append (org-protocol-flatten (car l)) (org-protocol-flatten (cdr l)))
|
||||
(list l))))
|
||||
|
||||
;;; Standard protocol handlers:
|
||||
|
||||
(defun org-protocol-store-link (fname)
|
||||
"Process an org-protocol://store-link:// style url
|
||||
and store a browser URL as an org link. Also pushes the links URL to the
|
||||
`kill-ring'.
|
||||
|
||||
The location for a browser's bookmark has to look like this:
|
||||
|
||||
javascript:location.href='org-protocol://store-link://'+ \\
|
||||
encodeURIComponent(location.href)
|
||||
encodeURIComponent(document.title)+'/'+ \\
|
||||
|
||||
Don't use `escape()'! Use `encodeURIComponent()' instead. The title of the page
|
||||
could contain slashes and the location definitely will.
|
||||
|
||||
The sub-protocol used to reach this function is set in
|
||||
`org-protocol-protocol-alist'."
|
||||
(let* ((splitparts (org-protocol-split-data fname t))
|
||||
(uri (org-protocol-sanitize-uri (car splitparts)))
|
||||
(title (cadr splitparts))
|
||||
orglink)
|
||||
(if (boundp 'org-stored-links)
|
||||
(setq org-stored-links (cons (list uri title) org-stored-links)))
|
||||
(kill-new uri)
|
||||
(message "`%s' to insert new org-link, `%s' to insert `%s'"
|
||||
(substitute-command-keys"\\[org-insert-link]")
|
||||
(substitute-command-keys"\\[yank]")
|
||||
uri))
|
||||
nil)
|
||||
|
||||
|
||||
(defun org-protocol-remember (info)
|
||||
"Process an org-protocol://remember:// style url.
|
||||
|
||||
The sub-protocol used to reach this function is set in
|
||||
`org-protocol-protocol-alist'.
|
||||
|
||||
This function detects an URL, title and optinal text, separated by '/'
|
||||
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())
|
||||
|
||||
By default, it uses the character `org-protocol-default-template-key',
|
||||
which should be associated with a template in `org-remember-templates'.
|
||||
But you may prepend the encoded URL with a character and a slash like so:
|
||||
|
||||
javascript:location.href='org-protocol://org-store-link://b/'+ ...
|
||||
|
||||
Now template ?b will be used."
|
||||
|
||||
(if (and (boundp 'org-stored-links)
|
||||
(fboundp 'org-remember))
|
||||
(let* ((parts (org-protocol-split-data info t))
|
||||
(template (or (and (= 1 (length (car parts))) (pop parts))
|
||||
org-protocol-default-template-key))
|
||||
(url (org-protocol-sanitize-uri (car parts)))
|
||||
(type (if (string-match "^\\([a-z]+\\):" url)
|
||||
(match-string 1 url)))
|
||||
(title (cadr parts))
|
||||
(region (caddr parts))
|
||||
(orglink (org-make-link-string url title))
|
||||
remember-annotation-functions)
|
||||
(setq org-stored-links
|
||||
(cons (list url title) org-stored-links))
|
||||
(kill-new orglink)
|
||||
(org-store-link-props :type type
|
||||
:link url
|
||||
:description title
|
||||
:initial region)
|
||||
(raise-frame)
|
||||
(org-remember nil (string-to-char template)))
|
||||
|
||||
(message "Org-mode not loaded."))
|
||||
nil)
|
||||
|
||||
|
||||
(defun org-protocol-open-source (fname)
|
||||
"Process an org-protocol://open-source:// style url.
|
||||
|
||||
Change a filename by mapping URLs to local filenames as set
|
||||
in `org-protocol-project-alist'.
|
||||
|
||||
The location for a browser's bookmark should look like this:
|
||||
|
||||
javascript:location.href='org-protocol://open-source://'+ \\
|
||||
encodeURIComponent(location.href)"
|
||||
|
||||
;; As we enter this function for a match on our protocol, the return value
|
||||
;; defaults to nil.
|
||||
(let ((result nil)
|
||||
(f (org-protocol-unhex-string fname)))
|
||||
(catch 'result
|
||||
(dolist (prolist org-protocol-project-alist)
|
||||
(let* ((base-url (plist-get (cdr prolist) :base-url))
|
||||
(wsearch (regexp-quote base-url)))
|
||||
|
||||
(when (string-match wsearch f)
|
||||
(let* ((wdir (plist-get (cdr prolist) :working-directory))
|
||||
(strip-suffix (plist-get (cdr prolist) :online-suffix))
|
||||
(add-suffix (plist-get (cdr prolist) :working-suffix))
|
||||
(start-pos (+ (string-match wsearch f) (length base-url)))
|
||||
(end-pos (string-match
|
||||
(concat (regexp-quote strip-suffix) "\\([?#].*\\)?$") f))
|
||||
(the-file (concat wdir (substring f start-pos end-pos) add-suffix)))
|
||||
(if (file-readable-p the-file)
|
||||
(throw 'result the-file))
|
||||
(if (file-exists-p the-file)
|
||||
(message "%s: permission denied!" the-file)
|
||||
(message "%s: no such file or directory." the-file))))))
|
||||
result)))
|
||||
|
||||
|
||||
;;; Core functions:
|
||||
|
||||
(defun org-protocol-check-filename-for-protocol (fname restoffiles client)
|
||||
"Detect if `org-protocol-the-protocol' and a known sub-protocol is used in fname.
|
||||
Sub-protocols are registered in `org-protocol-protocol-alist' and
|
||||
`org-protocol-protocol-alist-default'.
|
||||
This is, how the matching is done:
|
||||
|
||||
(string-match \"protocol:/+sub-protocol:/+\" ...)
|
||||
|
||||
protocol and sub-protocol are regexp-quoted.
|
||||
|
||||
If a matching protcol is found, the protcol is stripped from fname and the
|
||||
result is passed to the protocols function as the only parameter. If the
|
||||
function returns nil, the filename is removed from the list of filenames
|
||||
passed from emacsclient to the server.
|
||||
If the function returns a non nil value, that value is passed to the server
|
||||
as filename."
|
||||
(let ((sub-protocols (append org-protocol-protocol-alist org-protocol-protocol-alist-default)))
|
||||
(catch 'fname
|
||||
(let ((the-protocol (concat (regexp-quote org-protocol-the-protocol) ":/+")))
|
||||
(when (string-match the-protocol fname)
|
||||
(dolist (prolist sub-protocols)
|
||||
(let ((proto (concat the-protocol (regexp-quote (plist-get (cdr prolist) :protocol)) ":/+")))
|
||||
(when (string-match proto fname)
|
||||
(let* ((func (plist-get (cdr prolist) :function))
|
||||
(greedy (plist-get (cdr prolist) :greedy))
|
||||
(splitted (split-string fname proto))
|
||||
(result (if greedy restoffiles (cadr splitted))))
|
||||
(when (plist-get (cdr prolist) :kill-client)
|
||||
(message "Greedy org-protocol handler. Killing client.")
|
||||
(server-edit))
|
||||
(when (fboundp func)
|
||||
(unless greedy
|
||||
(throw 'fname (funcall func result)))
|
||||
(funcall func result)
|
||||
(throw 'fname t))))))))
|
||||
;; (message "fname: %s" fname)
|
||||
fname)))
|
||||
|
||||
|
||||
(defadvice server-visit-files (before org-protocol-detect-protocol-server activate)
|
||||
"Advice server-visit-flist to call `org-protocol-modify-filename-for-protocol'."
|
||||
(let ((flist (if org-protocol-reverse-list-of-files
|
||||
(reverse (ad-get-arg 0))
|
||||
(ad-get-arg 0)))
|
||||
(client (ad-get-arg 1)))
|
||||
(catch 'greedy
|
||||
(dolist (var flist)
|
||||
(let ((fname (expand-file-name (car var)))) ;; `\' to `/' on windows. FIXME: could this be done any better?
|
||||
(setq fname (org-protocol-check-filename-for-protocol fname (member var flist) client))
|
||||
(if (eq fname t) ;; greedy? We need the `t' return value.
|
||||
(progn
|
||||
(ad-set-arg 0 nil)
|
||||
(throw 'greedy t))
|
||||
(if (stringp fname) ;; probably filename
|
||||
(setcar var fname)
|
||||
(ad-set-arg 0 (delq var (ad-get-arg 0))))))
|
||||
))))
|
||||
|
||||
;;; Org specific functions:
|
||||
|
||||
(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 functions calls `org-protocol-create' to do
|
||||
most of the work."
|
||||
(interactive)
|
||||
(require 'org-publish)
|
||||
(org-publish-initialize-files-alist)
|
||||
(let ((all (or (org-publish-get-project-from-filename buffer-file-name))))
|
||||
(if all (org-protocol-create (cdr all))
|
||||
(message "Not in an org-project. Did mean %s?"
|
||||
(substitute-command-keys"\\[org-protocol-create]")))))
|
||||
|
||||
|
||||
(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 worglet. 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(or (plist-get project-plist :base-directory) default-directory)))
|
||||
(base-url "http://orgmode.org/worg/")
|
||||
(strip-suffix (or (plist-get project-plist :html-extension) ".html"))
|
||||
(working-suffix (if (plist-get project-plist :base-extension)
|
||||
(concat "." (plist-get project-plist :base-extension))
|
||||
".org"))
|
||||
|
||||
(worglet-buffer nil)
|
||||
|
||||
(insert-default-directory t)
|
||||
(minibuffer-allow-text-properties nil))
|
||||
|
||||
(setq base-url (read-string "Base URL of published content: " base-url nil base-url t))
|
||||
(if (not (string-match "\\/$" base-url))
|
||||
(setq base-url (concat base-url "/")))
|
||||
|
||||
(setq working-dir
|
||||
(expand-file-name
|
||||
(read-directory-name "Local working directory: " working-dir working-dir t)))
|
||||
(if (not (string-match "\\/$" working-dir))
|
||||
(setq working-dir (concat working-dir "/")))
|
||||
|
||||
(setq strip-suffix
|
||||
(read-string
|
||||
(concat "Extension to strip from published URLs ("strip-suffix"): ")
|
||||
strip-suffix nil strip-suffix t))
|
||||
|
||||
(setq working-suffix
|
||||
(read-string
|
||||
(concat "Extension of editable files ("working-suffix"): ")
|
||||
working-suffix nil working-suffix t))
|
||||
|
||||
(when (yes-or-no-p "Save the new worglet to your init file? ")
|
||||
(setq org-protocol-project-alist
|
||||
(cons `(,base-url . (:base-url ,base-url
|
||||
:working-directory ,working-dir
|
||||
:online-suffix ,strip-suffix
|
||||
:working-suffix ,working-suffix))
|
||||
org-protocol-project-alist))
|
||||
(customize-save-variable 'org-protocol-project-alist org-protocol-project-alist))))
|
||||
|
||||
(provide 'org-protocol)
|
||||
;;; org-protocol.el ends here
|
|
@ -2,9 +2,9 @@
|
|||
;; Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: David O'Toole <dto@gnu.org>
|
||||
;; Maintainer: Bastien Guerry <bzg AT altern DOT org>
|
||||
;; Maintainer: Carsten Dominik <carsten DOT dominik AT gmail DOT com>
|
||||
;; Keywords: hypermedia, outlines, wp
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
@ -28,120 +28,14 @@
|
|||
;;
|
||||
;; org-publish.el can do the following:
|
||||
;;
|
||||
;; + Publish all one's org-files to HTML or LaTeX
|
||||
;; + Publish all one's org-files to HTML or PDF
|
||||
;; + Upload HTML, images, attachments and other files to a web server
|
||||
;; + Exclude selected private pages from publishing
|
||||
;; + Publish a clickable index of pages
|
||||
;; + Manage local timestamps for publishing only changed files
|
||||
;; + Accept plugin functions to extend range of publishable content
|
||||
;;
|
||||
;; Special thanks to the org-mode maintainer Carsten Dominik for his
|
||||
;; ideas, enthusiasm, and cooperation.
|
||||
|
||||
;;; Installation:
|
||||
|
||||
;; Put org-publish.el in your load path, byte-compile it, and then add
|
||||
;; the following lines to your emacs initialization file:
|
||||
|
||||
;; (autoload 'org-publish "org-publish" nil t)
|
||||
;; (autoload 'org-publish "org-publish-all" nil t)
|
||||
;; (autoload 'org-publish "org-publish-current-file" nil t)
|
||||
;; (autoload 'org-publish "org-publish-current-project" nil t)
|
||||
|
||||
;; NOTE: When org-publish.el is included with org.el, those forms are
|
||||
;; already in the file org-install.el, and hence don't need to be put
|
||||
;; in your emacs initialization file in this case.
|
||||
|
||||
;;; Usage:
|
||||
;;
|
||||
;; The program's main configuration variable is
|
||||
;; `org-publish-project-alist'. See below for example configurations
|
||||
;; with commentary.
|
||||
|
||||
;; The main interactive functions are:
|
||||
;;
|
||||
;; M-x org-publish
|
||||
;; M-x org-publish-all
|
||||
;; M-x org-publish-current-file
|
||||
;; M-x org-publish-current-project
|
||||
|
||||
;;;; Simple example configuration:
|
||||
|
||||
;; (setq org-publish-project-alist
|
||||
;; (list
|
||||
;; '("org" . (:base-directory "~/org/"
|
||||
;; :base-extension "org"
|
||||
;; :publishing-directory "~/public_html"
|
||||
;; :with-section-numbers nil
|
||||
;; :table-of-contents nil
|
||||
;; :recursive t
|
||||
;; :style "<link rel="stylesheet" href=\"../other/mystyle.css\" type=\"text/css\">")))
|
||||
|
||||
;;;; More complex example configuration:
|
||||
|
||||
;; Imagine your *.org files are kept in ~/org, your images in
|
||||
;; ~/images, and stylesheets in ~/other. Now imagine you want to
|
||||
;; publish the files through an ssh connection to a remote host, via
|
||||
;; Tramp-mode. To maintain relative links from *.org files to /images
|
||||
;; and /other, we should replicate the same directory structure in
|
||||
;; your web server account's designated html root (in this case,
|
||||
;; assumed to be ~/html)
|
||||
|
||||
;; Once you've done created the proper directories, you can adapt the
|
||||
;; following example configuration to your specific paths, run M-x
|
||||
;; org-publish-all, and it should publish the files to the correct
|
||||
;; directories on the web server, transforming the *.org files into
|
||||
;; HTML, and leaving other files alone.
|
||||
|
||||
;; (setq org-publish-project-alist
|
||||
;; (list
|
||||
;; '("orgfiles" :base-directory "~/org/"
|
||||
;; :base-extension "org"
|
||||
;; :publishing-directory "/ssh:user@host:~/html/notebook/"
|
||||
;; :publishing-function org-publish-org-to-html
|
||||
;; :exclude "PrivatePage.org" ;; regexp
|
||||
;; :headline-levels 3
|
||||
;; :with-section-numbers nil
|
||||
;; :table-of-contents nil
|
||||
;; :style "<link rel="stylesheet" href=\"../other/mystyle.css\" type=\"text/css\">"
|
||||
;; :auto-preamble t
|
||||
;; :auto-postamble nil)
|
||||
;; ("images" :base-directory "~/images/"
|
||||
;; :base-extension "jpg\\|gif\\|png"
|
||||
;; :publishing-directory "/ssh:user@host:~/html/images/"
|
||||
;; :publishing-function org-publish-attachment)
|
||||
;; ("other" :base-directory "~/other/"
|
||||
;; :base-extension "css"
|
||||
;; :publishing-directory "/ssh:user@host:~/html/other/"
|
||||
;; :publishing-function org-publish-attachment)
|
||||
;; ("website" :components ("orgfiles" "images" "other"))))
|
||||
|
||||
;; For more information, see the documentation for the variable
|
||||
;; `org-publish-project-alist'.
|
||||
|
||||
;; Of course, you don't have to publish to remote directories from
|
||||
;; within emacs. You can always just publish to local folders, and
|
||||
;; then use the synchronization/upload tool of your choice.
|
||||
|
||||
;;; List of user-visible changes since version 1.27
|
||||
|
||||
;; 1.78: Allow list-valued :publishing-function
|
||||
;; 1.77: Added :preparation-function, this allows you to use GNU Make etc.
|
||||
;; 1.65: Remove old "composite projects". They're redundant.
|
||||
;; 1.64: Allow meta-projects with :components
|
||||
;; 1.57: Timestamps flag is now called "org-publish-use-timestamps-flag"
|
||||
;; 1.52: Properly set default for :index-filename
|
||||
;; 1.48: Composite projects allowed.
|
||||
;; :include keyword allowed.
|
||||
;; 1.43: Index no longer includes itself in the index.
|
||||
;; 1.42: Fix "function definition is void" error
|
||||
;; when :publishing-function not set in org-publish-current-file.
|
||||
;; 1.41: Fixed bug where index isn't published on first try.
|
||||
;; 1.37: Added interactive function "org-publish". Prompts for particular
|
||||
;; project name to publish.
|
||||
;; 1.34: Added force-publish option to all interactive functions.
|
||||
;; 1.32: Fixed "index.org has changed on disk" error during index publishing.
|
||||
;; 1.30: Fixed startup error caused by (require 'em-unix)
|
||||
;; Documentation for publishing is in the manual.
|
||||
|
||||
;;; Code:
|
||||
|
||||
|
@ -256,7 +150,7 @@ index of files or summary page for a given project.
|
|||
:auto-index Whether to publish an index during
|
||||
`org-publish-current-project' or `org-publish-all'.
|
||||
:index-filename Filename for output of index. Defaults
|
||||
to 'index.org' (which becomes 'index.html').
|
||||
to 'sitemap.org' (which becomes 'sitemap.html').
|
||||
:index-title Title of index page. Defaults to name of file.
|
||||
:index-function Plugin function to use for generation of index.
|
||||
Defaults to `org-publish-org-index', which
|
||||
|
@ -282,30 +176,41 @@ When nil, do no timestamp checking and always publish all files."
|
|||
:group 'org-publish
|
||||
:type 'directory)
|
||||
|
||||
(defcustom org-publish-list-skipped-files t
|
||||
"Non-nil means, show message about files *not* published."
|
||||
:group 'org-publish
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-publish-before-export-hook nil
|
||||
"Hook run before export on the Org file.
|
||||
If the functions in this hook modify the original Org buffer, the
|
||||
modified buffer will be used for export, but the buffer will be
|
||||
restored and saved back to its initial state after export."
|
||||
The hook may modify the file in arbitrary ways before publishing happens.
|
||||
The orgiginal version of the buffer will be restored after publishing."
|
||||
:group 'org-publish
|
||||
:type 'hook)
|
||||
|
||||
(defcustom org-publish-after-export-hook nil
|
||||
"Hook run after export on the exported buffer.
|
||||
If functions in this hook modify the buffer, it will be saved."
|
||||
Any changes made by this hook will be saved."
|
||||
:group 'org-publish
|
||||
:type 'hook)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; Timestamp-related functions
|
||||
|
||||
(defun org-publish-timestamp-filename (filename)
|
||||
(defun org-publish-timestamp-filename (filename &optional pub-dir pub-func)
|
||||
"Return path to timestamp file for filename FILENAME."
|
||||
(setq filename (concat filename "::" (or pub-dir "") "::"
|
||||
(format "%s" (or pub-func ""))))
|
||||
(concat (file-name-as-directory org-publish-timestamp-directory)
|
||||
"X" (if (fboundp 'sha1) (sha1 filename) (md5 filename))))
|
||||
|
||||
(defun org-publish-needed-p (filename)
|
||||
"Return `t' if FILENAME should be published."
|
||||
(defun org-publish-needed-p (filename &optional pub-dir pub-func true-pub-dir)
|
||||
"Return `t' if FILENAME should be published in PUB-DIR using PUB-FUNC.
|
||||
TRUE-PUB-DIR is there the file will truely end up. Currently we are not using
|
||||
this - maybe it can eventually be used to check if the file is present at
|
||||
the target location, and how old it is. Right ow we cannot do this, because
|
||||
we do not know under what file name the file will be stored - the publishing
|
||||
function can still decide about that independently."
|
||||
(let ((rtn
|
||||
(if org-publish-use-timestamps-flag
|
||||
(if (file-exists-p org-publish-timestamp-directory)
|
||||
|
@ -315,20 +220,23 @@ If functions in this hook modify the buffer, it will be saved."
|
|||
org-publish-timestamp-directory)
|
||||
;; there is a timestamp, check if FILENAME is newer
|
||||
(file-newer-than-file-p
|
||||
filename (org-publish-timestamp-filename filename)))
|
||||
filename (org-publish-timestamp-filename
|
||||
filename pub-dir pub-func)))
|
||||
(make-directory org-publish-timestamp-directory)
|
||||
t)
|
||||
;; don't use timestamps, always return t
|
||||
t)))
|
||||
(if rtn
|
||||
(message "Publishing file %s" filename)
|
||||
(message "Skipping unmodified file %s" filename))
|
||||
(message "Publishing file %s using `%s'" filename pub-func)
|
||||
(when org-publish-list-skipped-files
|
||||
(message "Skipping unmodified file %s" filename)))
|
||||
rtn))
|
||||
|
||||
(defun org-publish-update-timestamp (filename)
|
||||
(defun org-publish-update-timestamp (filename &optional pub-dir pub-func)
|
||||
"Update publishing timestamp for file FILENAME.
|
||||
If there is no timestamp, create one."
|
||||
(let ((timestamp-file (org-publish-timestamp-filename filename))
|
||||
(let ((timestamp-file (org-publish-timestamp-filename
|
||||
filename pub-dir pub-func))
|
||||
newly-created-timestamp)
|
||||
(if (not (file-exists-p timestamp-file))
|
||||
;; create timestamp file if needed
|
||||
|
@ -340,7 +248,16 @@ If there is no timestamp, create one."
|
|||
(if (and (fboundp 'set-file-times)
|
||||
(not newly-created-timestamp))
|
||||
(set-file-times timestamp-file)
|
||||
(call-process "touch" nil 0 nil timestamp-file))))
|
||||
(call-process "touch" nil 0 nil (expand-file-name timestamp-file)))))
|
||||
|
||||
(defun org-publish-remove-all-timestamps ()
|
||||
"Remove all files in the timstamp directory."
|
||||
(let ((dir org-publish-timestamp-directory)
|
||||
files)
|
||||
(when (and (file-exists-p dir)
|
||||
(file-directory-p dir))
|
||||
(mapc 'delete-file (directory-files dir 'full "[^.]\\'")))))
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; Mapping files to project names
|
||||
|
@ -454,7 +371,9 @@ matching filenames."
|
|||
(include-list (plist-get project-plist :include))
|
||||
(recurse (plist-get project-plist :recursive))
|
||||
(extension (or (plist-get project-plist :base-extension) "org"))
|
||||
(match (concat "^[^\\.].*\\.\\(" extension "\\)$")))
|
||||
(match (if (eq extension 'any)
|
||||
"^[^\\.]"
|
||||
(concat "^[^\\.].*\\.\\(" extension "\\)$"))))
|
||||
(setq org-publish-temp-files nil)
|
||||
(org-publish-get-base-files-1 base-dir recurse match
|
||||
;; FIXME distinguish exclude regexp
|
||||
|
@ -467,13 +386,14 @@ matching filenames."
|
|||
include-list)
|
||||
org-publish-temp-files))
|
||||
|
||||
(defun org-publish-get-project-from-filename (filename)
|
||||
(defun org-publish-get-project-from-filename (filename &optional up)
|
||||
"Return the project FILENAME belongs."
|
||||
(let* ((project-name (cdr (assoc (expand-file-name filename)
|
||||
org-publish-files-alist))))
|
||||
(dolist (prj org-publish-project-alist)
|
||||
(if (member project-name (plist-get (cdr prj) :components))
|
||||
(setq project-name (car prj))))
|
||||
(when up
|
||||
(dolist (prj org-publish-project-alist)
|
||||
(if (member project-name (plist-get (cdr prj) :components))
|
||||
(setq project-name (car prj)))))
|
||||
(assoc project-name org-publish-project-alist)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
@ -534,54 +454,67 @@ See `org-publish-org-to' to the list of arguments."
|
|||
See `org-publish-org-to' to the list of arguments."
|
||||
(org-publish-org-to "html" plist filename pub-dir))
|
||||
|
||||
(defun org-publish-org-to-org (plist filename pub-dir)
|
||||
"Publish an org file to HTML.
|
||||
See `org-publish-org-to' to the list of arguments."
|
||||
(org-publish-org-to "org" plist filename pub-dir))
|
||||
|
||||
(defun org-publish-attachment (plist filename pub-dir)
|
||||
"Publish a file with no transformation of any kind.
|
||||
See `org-publish-org-to' to the list of arguments."
|
||||
;; make sure eshell/cp code is loaded
|
||||
(unless (file-directory-p pub-dir)
|
||||
(make-directory pub-dir t))
|
||||
(copy-file filename pub-dir t))
|
||||
(or (equal (expand-file-name (file-name-directory filename))
|
||||
(file-name-as-directory (expand-file-name pub-dir)))
|
||||
(copy-file filename
|
||||
(expand-file-name (file-name-nondirectory filename) pub-dir)
|
||||
t)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; Publishing files, sets of files, and indices
|
||||
|
||||
(defun org-publish-file (filename &optional project)
|
||||
"Publish file FILENAME from PROJECT."
|
||||
(when (org-publish-needed-p filename)
|
||||
(let* ((project
|
||||
(or project
|
||||
(or (org-publish-get-project-from-filename filename)
|
||||
(if (y-or-n-p
|
||||
(format "%s is not in a project. Re-read the list of projects files? "
|
||||
(abbreviate-file-name filename)))
|
||||
;; If requested, re-initialize the list of projects files
|
||||
(progn (org-publish-initialize-files-alist t)
|
||||
(or (org-publish-get-project-from-filename filename)
|
||||
(error "File %s not part of any known project"
|
||||
(abbreviate-file-name filename))))
|
||||
(error "Can't publish file outside of a project")))))
|
||||
(project-plist (cdr project))
|
||||
(ftname (file-truename filename))
|
||||
(publishing-function
|
||||
(or (plist-get project-plist :publishing-function)
|
||||
'org-publish-org-to-html))
|
||||
(base-dir (file-name-as-directory
|
||||
(file-truename (plist-get project-plist :base-directory))))
|
||||
(pub-dir (file-name-as-directory
|
||||
(file-truename (plist-get project-plist :publishing-directory))))
|
||||
tmp-pub-dir)
|
||||
(setq tmp-pub-dir
|
||||
(file-name-directory
|
||||
(concat pub-dir
|
||||
(and (string-match (regexp-quote base-dir) ftname)
|
||||
(substring ftname (match-end 0))))))
|
||||
(if (listp publishing-function)
|
||||
;; allow chain of publishing functions
|
||||
(mapc (lambda (f)
|
||||
(funcall f project-plist filename tmp-pub-dir))
|
||||
publishing-function)
|
||||
(funcall publishing-function project-plist filename tmp-pub-dir)))
|
||||
(org-publish-update-timestamp filename)))
|
||||
(let* ((project
|
||||
(or project
|
||||
(or (org-publish-get-project-from-filename filename)
|
||||
(if (y-or-n-p
|
||||
(format "%s is not in a project. Re-read the list of projects files? "
|
||||
(abbreviate-file-name filename)))
|
||||
;; If requested, re-initialize the list of projects files
|
||||
(progn (org-publish-initialize-files-alist t)
|
||||
(or (org-publish-get-project-from-filename filename)
|
||||
(error "File %s not part of any known project"
|
||||
(abbreviate-file-name filename))))
|
||||
(error "Can't publish file outside of a project")))))
|
||||
(project-plist (cdr project))
|
||||
(ftname (file-truename filename))
|
||||
(publishing-function
|
||||
(or (plist-get project-plist :publishing-function)
|
||||
'org-publish-org-to-html))
|
||||
(base-dir (file-name-as-directory
|
||||
(file-truename (plist-get project-plist :base-directory))))
|
||||
(pub-dir (file-name-as-directory
|
||||
(file-truename (plist-get project-plist :publishing-directory))))
|
||||
tmp-pub-dir)
|
||||
(setq tmp-pub-dir
|
||||
(file-name-directory
|
||||
(concat pub-dir
|
||||
(and (string-match (regexp-quote base-dir) ftname)
|
||||
(substring ftname (match-end 0))))))
|
||||
(if (listp publishing-function)
|
||||
;; allow chain of publishing functions
|
||||
(mapc (lambda (f)
|
||||
(when (org-publish-needed-p filename pub-dir f tmp-pub-dir)
|
||||
(funcall f project-plist filename tmp-pub-dir)
|
||||
(org-publish-update-timestamp filename pub-dir f)))
|
||||
publishing-function)
|
||||
(when (org-publish-needed-p filename pub-dir publishing-function
|
||||
tmp-pub-dir)
|
||||
(funcall publishing-function project-plist filename tmp-pub-dir)
|
||||
(org-publish-update-timestamp
|
||||
filename pub-dir publishing-function)))))
|
||||
|
||||
(defun org-publish-projects (projects)
|
||||
"Publish all files belonging to the PROJECTS alist.
|
||||
|
@ -593,7 +526,7 @@ If :auto-index is set, publish the index too."
|
|||
(exclude-regexp (plist-get project-plist :exclude))
|
||||
(index-p (plist-get project-plist :auto-index))
|
||||
(index-filename (or (plist-get project-plist :index-filename)
|
||||
"index.org"))
|
||||
"sitemap.org"))
|
||||
(index-function (or (plist-get project-plist :index-function)
|
||||
'org-publish-org-index))
|
||||
(preparation-function (plist-get project-plist :preparation-function))
|
||||
|
@ -609,7 +542,7 @@ If :auto-index is set, publish the index too."
|
|||
(defun org-publish-org-index (project &optional index-filename)
|
||||
"Create an index of pages in set defined by PROJECT.
|
||||
Optionally set the filename of the index with INDEX-FILENAME.
|
||||
Default for INDEX-FILENAME is 'index.org'."
|
||||
Default for INDEX-FILENAME is 'sitemap.org'."
|
||||
(let* ((project-plist (cdr project))
|
||||
(dir (file-name-as-directory
|
||||
(plist-get project-plist :base-directory)))
|
||||
|
@ -617,7 +550,7 @@ Default for INDEX-FILENAME is 'index.org'."
|
|||
(indent-str (make-string 2 ?\ ))
|
||||
(exclude-regexp (plist-get project-plist :exclude))
|
||||
(files (nreverse (org-publish-get-base-files project exclude-regexp)))
|
||||
(index-filename (concat dir (or index-filename "index.org")))
|
||||
(index-filename (concat dir (or index-filename "sitemap.org")))
|
||||
(index-title (or (plist-get project-plist :index-title)
|
||||
(concat "Index for project " (car project))))
|
||||
(index-style (or (plist-get project-plist :index-style)
|
||||
|
@ -697,24 +630,27 @@ Default for INDEX-FILENAME is 'index.org'."
|
|||
;;;###autoload
|
||||
(defun org-publish (project &optional force)
|
||||
"Publish PROJECT."
|
||||
(interactive "P")
|
||||
(interactive
|
||||
(list
|
||||
(assoc (org-ido-completing-read
|
||||
"Publish project: "
|
||||
org-publish-project-alist nil t)
|
||||
org-publish-project-alist)
|
||||
current-prefix-arg))
|
||||
(setq org-publish-initial-buffer (current-buffer))
|
||||
(save-window-excursion
|
||||
(let* ((force current-prefix-arg)
|
||||
(org-publish-use-timestamps-flag
|
||||
(let* ((org-publish-use-timestamps-flag
|
||||
(if force nil org-publish-use-timestamps-flag)))
|
||||
(org-publish-projects
|
||||
(list (or project
|
||||
(assoc (org-ido-completing-read
|
||||
"Publish project: "
|
||||
org-publish-project-alist nil t)
|
||||
org-publish-project-alist)))))))
|
||||
(org-publish-projects (list project)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-publish-all (&optional force)
|
||||
"Publish all projects.
|
||||
With prefix argument, force publish all files."
|
||||
With prefix argument, remove all files in the timestamp
|
||||
directory and force publishing all files."
|
||||
(interactive "P")
|
||||
(when force
|
||||
(org-publish-remove-all-timestamps))
|
||||
(org-publish-initialize-files-alist)
|
||||
(save-window-excursion
|
||||
(let ((org-publish-use-timestamps-flag
|
||||
|
@ -740,7 +676,7 @@ the project."
|
|||
(interactive "P")
|
||||
(org-publish-initialize-files-alist)
|
||||
(save-window-excursion
|
||||
(let ((project (org-publish-get-project-from-filename (buffer-file-name)))
|
||||
(let ((project (org-publish-get-project-from-filename (buffer-file-name) 'up))
|
||||
(org-publish-use-timestamps-flag
|
||||
(if force nil org-publish-use-timestamps-flag)))
|
||||
(if (not project)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
@ -186,9 +186,10 @@ calendar | %:type %:date"
|
|||
(const :tag "Use `org-default-notes-file'" nil))
|
||||
(choice :tag "Destin. headline"
|
||||
(string :tag "Specify")
|
||||
(function :tag "Function")
|
||||
(const :tag "Use `org-remember-default-headline'" nil)
|
||||
(const :tag "Level 1 at beginning of file" top)
|
||||
(const :tag "Level 1 at end of file" bottom))
|
||||
(const :tag "At beginning of file" top)
|
||||
(const :tag "At end of file" bottom))
|
||||
(choice :tag "Context"
|
||||
(const :tag "Use in all contexts" nil)
|
||||
(const :tag "Use in all contexts" t)
|
||||
|
@ -196,6 +197,11 @@ calendar | %:type %:date"
|
|||
(symbol :tag "Major mode"))
|
||||
(function :tag "Perform a check against function")))))
|
||||
|
||||
(defcustom org-remember-delete-empty-lines-at-end t
|
||||
"Non-nil means clean up final empty lines in remember buffer."
|
||||
:group 'org-remember
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-remember-before-finalize-hook nil
|
||||
"Hook that is run right before a remember process is finalized.
|
||||
The remember buffer is still current when this hook runs."
|
||||
|
@ -228,6 +234,27 @@ user each time a remember buffer with a running clock is filed away. "
|
|||
(const :tag "Always" t)
|
||||
(const :tag "Query user" query)))
|
||||
|
||||
(defcustom org-remember-backup-directory nil
|
||||
"Directory where to store all remember buffers, for backup purposes.
|
||||
After a remember buffer has been stored successfully, the backup file
|
||||
will be removed. However, if you forget to finish the remember process,
|
||||
the file will remain there.
|
||||
See also `org-remember-auto-remove-backup-files'."
|
||||
:group 'org-remember
|
||||
:type '(choice
|
||||
(const :tag "No backups" nil)
|
||||
(directory :tag "Directory")))
|
||||
|
||||
(defcustom org-remember-auto-remove-backup-files t
|
||||
"Non-nil means, remove remember backup files after successfully storage.
|
||||
When remember is finished successfully, with storing the note at the
|
||||
desired target, remove the backup files related to this remember process
|
||||
and show a message about remaining backup files, from previous, unfinished
|
||||
remember sessions.
|
||||
Backup files will only be made at all, when `org-remember-backup-directory'
|
||||
is set."
|
||||
:group 'org-remember
|
||||
:type 'boolean)
|
||||
|
||||
(defvar annotation) ; from remember.el, dynamically scoped in `remember-mode'
|
||||
(defvar initial) ; from remember.el, dynamically scoped in `remember-mode'
|
||||
|
@ -297,6 +324,7 @@ RET at beg-of-buf -> Append to file as level 2 headline
|
|||
(append (list (nth 1 x) (car x)) (cddr x))
|
||||
(append (list (car x) "") (cdr x))))
|
||||
(delq nil pre-selected-templates2)))
|
||||
msg
|
||||
(char (or use-char
|
||||
(cond
|
||||
((= (length templates) 1)
|
||||
|
@ -307,22 +335,32 @@ RET at beg-of-buf -> Append to file as level 2 headline
|
|||
(string-to-char org-force-remember-template-char)
|
||||
org-force-remember-template-char))
|
||||
(t
|
||||
(message "Select template: %s"
|
||||
(mapconcat
|
||||
(lambda (x)
|
||||
(cond
|
||||
((not (string-match "\\S-" (nth 1 x)))
|
||||
(format "[%c]" (car x)))
|
||||
((equal (downcase (car x))
|
||||
(downcase (aref (nth 1 x) 0)))
|
||||
(format "[%c]%s" (car x)
|
||||
(substring (nth 1 x) 1)))
|
||||
(t (format "[%c]%s" (car x) (nth 1 x)))))
|
||||
templates " "))
|
||||
(let ((inhibit-quit t) (char0 (read-char-exclusive)))
|
||||
(setq msg (format
|
||||
"Select template: %s"
|
||||
(mapconcat
|
||||
(lambda (x)
|
||||
(cond
|
||||
((not (string-match "\\S-" (nth 1 x)))
|
||||
(format "[%c]" (car x)))
|
||||
((equal (downcase (car x))
|
||||
(downcase (aref (nth 1 x) 0)))
|
||||
(format "[%c]%s" (car x)
|
||||
(substring (nth 1 x) 1)))
|
||||
(t (format "[%c]%s" (car x) (nth 1 x)))))
|
||||
templates " ")))
|
||||
(let ((inhibit-quit t) char0)
|
||||
(while (not char0)
|
||||
(message msg)
|
||||
(setq char0 (read-char-exclusive))
|
||||
(when (and (not (assoc char0 templates))
|
||||
(not (equal char0 ?\C-g)))
|
||||
(message "No such template \"%c\"" char0)
|
||||
(ding) (sit-for 1)
|
||||
(setq char0 nil)))
|
||||
(when (equal char0 ?\C-g)
|
||||
(jump-to-register remember-register)
|
||||
(kill-buffer remember-buffer))
|
||||
(kill-buffer remember-buffer)
|
||||
(error "Abort"))
|
||||
char0))))))
|
||||
(cddr (assoc char templates)))))
|
||||
|
||||
|
@ -365,11 +403,16 @@ to be run from that hook to function properly."
|
|||
(v-T (format-time-string (cdr org-time-stamp-formats) ct))
|
||||
(v-u (concat "[" (substring v-t 1 -1) "]"))
|
||||
(v-U (concat "[" (substring v-T 1 -1) "]"))
|
||||
;; `initial' and `annotation' are bound in `remember'
|
||||
(v-i (if (boundp 'initial) initial))
|
||||
(v-a (if (and (boundp 'annotation) annotation)
|
||||
(if (equal annotation "[[]]") "" annotation)
|
||||
""))
|
||||
;; `initial' and `annotation' are bound in `remember'.
|
||||
;; But if the property list has them, we prefer those values
|
||||
(v-i (or (plist-get org-store-link-plist :initial)
|
||||
(and (boundp 'initial) initial)
|
||||
""))
|
||||
(v-a (or (plist-get org-store-link-plist :annotation)
|
||||
(and (boundp 'annotation) annotation)
|
||||
""))
|
||||
;; Is the link empty? Then we do not want it...
|
||||
(v-a (if (equal v-a "[[]]") "" v-a))
|
||||
(clipboards (remove nil (list v-i
|
||||
(org-get-x-clipboard 'PRIMARY)
|
||||
(org-get-x-clipboard 'CLIPBOARD)
|
||||
|
@ -394,13 +437,16 @@ to be run from that hook to function properly."
|
|||
|
||||
(when (functionp file)
|
||||
(setq file (funcall file)))
|
||||
(when (functionp headline)
|
||||
(setq headline (funcall headline)))
|
||||
(when (and file (not (file-name-absolute-p file)))
|
||||
(setq file (expand-file-name file org-directory)))
|
||||
|
||||
|
||||
(setq org-store-link-plist
|
||||
(append (list :annotation v-a :initial v-i)
|
||||
org-store-link-plist))
|
||||
(plist-put org-store-link-plist :annotation v-a)
|
||||
org-store-link-plist
|
||||
(plist-put org-store-link-plist :initial v-i))
|
||||
|
||||
(unless tpl (setq tpl "") (message "No template") (ding) (sit-for 1))
|
||||
(erase-buffer)
|
||||
(insert (substitute-command-keys
|
||||
|
@ -551,7 +597,7 @@ to be run from that hook to function properly."
|
|||
nil nil (list org-end-time-was-given)))
|
||||
(t
|
||||
(let (org-completion-use-ido)
|
||||
(insert (org-completing-read
|
||||
(insert (org-completing-read-no-ido
|
||||
(concat (if prompt prompt "Enter string")
|
||||
(if default (concat " [" default "]"))
|
||||
": ")
|
||||
|
@ -566,6 +612,17 @@ to be run from that hook to function properly."
|
|||
(re-search-forward "%&" nil t))
|
||||
(replace-match "")
|
||||
(org-set-local 'org-jump-to-target-location t))
|
||||
(when org-remember-backup-directory
|
||||
(unless (file-directory-p org-remember-backup-directory)
|
||||
(make-directory org-remember-backup-directory))
|
||||
(org-set-local 'auto-save-file-name-transforms nil)
|
||||
(setq buffer-file-name
|
||||
(expand-file-name
|
||||
(format-time-string "remember-%Y-%m-%d-%H-%M-%S")
|
||||
org-remember-backup-directory))
|
||||
(save-buffer)
|
||||
(org-set-local 'auto-save-visited-file-name t)
|
||||
(auto-save-mode 1))
|
||||
(when (save-excursion
|
||||
(goto-char (point-min))
|
||||
(re-search-forward "%!" nil t))
|
||||
|
@ -612,8 +669,7 @@ from that hook."
|
|||
(y-or-n-p "The clock is running in this buffer. Clock out now? "))))
|
||||
(let (org-log-note-clock-out) (org-clock-out))))
|
||||
(when buffer-file-name
|
||||
(save-buffer)
|
||||
(setq buffer-file-name nil))
|
||||
(do-auto-save))
|
||||
(remember-finalize))
|
||||
|
||||
(defun org-remember-kill ()
|
||||
|
@ -695,6 +751,8 @@ The user is queried for the template."
|
|||
(goto-char (match-beginning 0))
|
||||
(error "Target headline not found: %s" heading))))
|
||||
|
||||
;; FIXME (bzg): let's clean up of final empty lines happen only once
|
||||
;; (see the org-remember-delete-empty-lines-at-end option below)
|
||||
;;;###autoload
|
||||
(defun org-remember-handler ()
|
||||
"Store stuff from remember.el into an org file.
|
||||
|
@ -738,14 +796,33 @@ See also the variable `org-reverse-note-order'."
|
|||
(goto-char (point-min))
|
||||
(while (looking-at "^[ \t]*\n\\|^##.*\n")
|
||||
(replace-match ""))
|
||||
(goto-char (point-max))
|
||||
(beginning-of-line 1)
|
||||
(while (looking-at "[ \t]*$\\|##.*")
|
||||
(delete-region (1- (point)) (point-max))
|
||||
(beginning-of-line 1))
|
||||
(when org-remember-delete-empty-lines-at-end
|
||||
(goto-char (point-max))
|
||||
(beginning-of-line 1)
|
||||
(while (and (looking-at "[ \t]*$\\|##.*") (> (point) 1))
|
||||
(delete-region (1- (point)) (point-max))
|
||||
(beginning-of-line 1)))
|
||||
(catch 'quit
|
||||
(if org-note-abort (throw 'quit nil))
|
||||
(if org-note-abort (throw 'quit t))
|
||||
(let* ((visitp (org-bound-and-true-p org-jump-to-target-location))
|
||||
(backup-file
|
||||
(and buffer-file-name
|
||||
(equal (file-name-directory buffer-file-name)
|
||||
(file-name-as-directory
|
||||
(expand-file-name org-remember-backup-directory)))
|
||||
(string-match "^remember-[0-9]\\{4\\}"
|
||||
(file-name-nondirectory buffer-file-name))
|
||||
buffer-file-name))
|
||||
|
||||
(dummy
|
||||
(unless (string-match "\\S-" (buffer-string))
|
||||
(message "Nothing to remember")
|
||||
(and backup-file
|
||||
(ignore-errors
|
||||
(delete-file backup-file)
|
||||
(delete-file (concat backup-file "~"))))
|
||||
(set-buffer-modified-p nil)
|
||||
(throw 'quit t)))
|
||||
(previousp (and (member current-prefix-arg '((16) 0))
|
||||
org-remember-previous-location))
|
||||
(clockp (equal current-prefix-arg 2))
|
||||
|
@ -763,7 +840,7 @@ See also the variable `org-reverse-note-order'."
|
|||
(org-startup-folded nil)
|
||||
(org-startup-align-all-tables nil)
|
||||
(org-goto-start-pos 1)
|
||||
spos exitcmd level reversed txt)
|
||||
spos exitcmd level reversed txt text-before-node-creation)
|
||||
(when (equal current-prefix-arg '(4))
|
||||
(setq visitp t))
|
||||
(when previousp
|
||||
|
@ -779,27 +856,32 @@ See also the variable `org-reverse-note-order'."
|
|||
(setq current-prefix-arg nil)
|
||||
;; Modify text so that it becomes a nice subtree which can be inserted
|
||||
;; into an org tree.
|
||||
(goto-char (point-min))
|
||||
(if (re-search-forward "[ \t\n]+\\'" nil t)
|
||||
;; remove empty lines at end
|
||||
(replace-match ""))
|
||||
(when org-remember-delete-empty-lines-at-end
|
||||
(goto-char (point-min))
|
||||
(if (re-search-forward "[ \t\n]+\\'" nil t)
|
||||
;; remove empty lines at end
|
||||
(replace-match "")))
|
||||
(goto-char (point-min))
|
||||
(unless (looking-at org-outline-regexp)
|
||||
;; add a headline
|
||||
(setq text-before-node-creation (buffer-string))
|
||||
(insert (concat "* " (current-time-string)
|
||||
" (" (remember-buffer-desc) ")\n"))
|
||||
(backward-char 1)
|
||||
(when org-adapt-indentation
|
||||
(while (re-search-forward "^" nil t)
|
||||
(insert " "))))
|
||||
(goto-char (point-min))
|
||||
(if (re-search-forward "\n[ \t]*\n[ \t\n]*\\'" nil t)
|
||||
(replace-match "\n\n")
|
||||
(if (re-search-forward "[ \t\n]*\\'")
|
||||
(replace-match "\n")))
|
||||
;; Delete final empty lines
|
||||
(when org-remember-delete-empty-lines-at-end
|
||||
(goto-char (point-min))
|
||||
(if (re-search-forward "\n[ \t]*\n[ \t\n]*\\'" nil t)
|
||||
(replace-match "\n\n")
|
||||
(if (re-search-forward "[ \t\n]*\\'")
|
||||
(replace-match "\n"))))
|
||||
(goto-char (point-min))
|
||||
(setq txt (buffer-string))
|
||||
(org-save-markers-in-region (point-min) (point-max))
|
||||
(set-buffer-modified-p nil)
|
||||
(when (and (eq org-remember-interactive-interface 'refile)
|
||||
(not fastp))
|
||||
(org-refile nil (or visiting (find-file-noselect file)))
|
||||
|
@ -811,20 +893,26 @@ See also the variable `org-reverse-note-order'."
|
|||
(throw 'quit t))
|
||||
;; Find the file
|
||||
(with-current-buffer (or visiting (find-file-noselect file))
|
||||
(unless (org-mode-p)
|
||||
(error "Target files for remember notes must be in Org-mode"))
|
||||
(unless (or (org-mode-p) (member heading '(top bottom)))
|
||||
(error "Target files for notes must be in Org-mode if not filing to top/bottom"))
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(widen)
|
||||
(and (goto-char (point-min))
|
||||
(not (re-search-forward "^\\* " nil t))
|
||||
(insert "\n* " (or (and (stringp heading) heading)
|
||||
"Notes") "\n"))
|
||||
(setq reversed (org-notes-order-reversed-p))
|
||||
|
||||
;; Find the default location
|
||||
(when heading
|
||||
(cond
|
||||
((not (org-mode-p))
|
||||
(if (eq heading 'top)
|
||||
(goto-char (point-min))
|
||||
(goto-char (point-max))
|
||||
(or (bolp) (newline)))
|
||||
(insert text-before-node-creation)
|
||||
(when remember-save-after-remembering
|
||||
(save-buffer)
|
||||
(if (not visiting) (kill-buffer (current-buffer))))
|
||||
(throw 'quit t))
|
||||
((eq heading 'top)
|
||||
(goto-char (point-min))
|
||||
(or (looking-at org-outline-regexp)
|
||||
|
@ -951,7 +1039,21 @@ See also the variable `org-reverse-note-order'."
|
|||
(if (and (not visiting)
|
||||
(not (equal (marker-buffer org-clock-marker)
|
||||
(current-buffer))))
|
||||
(kill-buffer (current-buffer)))))))))
|
||||
(kill-buffer (current-buffer))))
|
||||
(when org-remember-auto-remove-backup-files
|
||||
(when backup-file
|
||||
(ignore-errors
|
||||
(delete-file backup-file)
|
||||
(delete-file (concat backup-file "~"))))
|
||||
(when org-remember-backup-directory
|
||||
(let ((n (length
|
||||
(directory-files
|
||||
org-remember-backup-directory nil
|
||||
"^remember-.*[0-9]$"))))
|
||||
(when (> n 0)
|
||||
(message
|
||||
"%d backup files (unfinished remember calls) in %s"
|
||||
n org-remember-backup-directory))))))))))
|
||||
|
||||
t) ;; return t to indicate that we took care of this note.
|
||||
|
||||
|
@ -995,3 +1097,4 @@ See also the variable `org-reverse-note-order'."
|
|||
;; arch-tag: 497f30d0-4bc3-4097-8622-2d27ac5f2698
|
||||
|
||||
;;; org-remember.el ends here
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
@ -36,11 +36,8 @@
|
|||
|
||||
;; Declare external functions and variables
|
||||
(declare-function rmail-show-message "rmail" (&optional n no-summary))
|
||||
(declare-function rmail-get-header "rmail" (name &optional msgnum))
|
||||
(declare-function rmail-what-message "rmail" ())
|
||||
(defvar rmail-current-message)
|
||||
(defvar rmail-buffer)
|
||||
(defvar rmail-view-buffer)
|
||||
|
||||
;; Install the link type
|
||||
(org-add-link-type "rmail" 'org-rmail-open)
|
||||
|
@ -49,35 +46,29 @@
|
|||
;; Implementation
|
||||
(defun org-rmail-store-link ()
|
||||
"Store a link to an Rmail folder or message."
|
||||
(when (memq major-mode '(rmail-mode rmail-summary-mode))
|
||||
(let (message-id from to subject desc link)
|
||||
(if (fboundp 'rmail-get-header) ; Emacs 23
|
||||
(setq message-id (rmail-get-header "message-id")
|
||||
from (rmail-get-header "from")
|
||||
to (rmail-get-header "to")
|
||||
subject (rmail-get-header "subject"))
|
||||
(save-window-excursion ; Emacs 22
|
||||
(save-restriction
|
||||
(when (eq major-mode 'rmail-summary-mode)
|
||||
(rmail-show-message rmail-current-message))
|
||||
(with-no-warnings ; don't warn when compiling Emacs 23
|
||||
(rmail-narrow-to-non-pruned-header))
|
||||
(setq message-id (mail-fetch-field "message-id")
|
||||
from (mail-fetch-field "from")
|
||||
to (mail-fetch-field "to")
|
||||
subject (mail-fetch-field "subject"))
|
||||
(rmail-show-message rmail-current-message))))
|
||||
(org-store-link-props
|
||||
:type "rmail" :from from :to to
|
||||
:subject subject :message-id message-id)
|
||||
(setq message-id (org-remove-angle-brackets message-id))
|
||||
(setq desc (org-email-link-description))
|
||||
(setq link (org-make-link "rmail:"
|
||||
(with-current-buffer rmail-buffer
|
||||
buffer-file-name)
|
||||
"#" message-id))
|
||||
(org-add-link-props :link link :description desc)
|
||||
link)))
|
||||
(when (or (eq major-mode 'rmail-mode)
|
||||
(eq major-mode 'rmail-summary-mode))
|
||||
(save-window-excursion
|
||||
(save-restriction
|
||||
(when (eq major-mode 'rmail-summary-mode)
|
||||
(rmail-show-message rmail-current-message))
|
||||
(when (fboundp 'rmail-narrow-to-non-pruned-header)
|
||||
(rmail-narrow-to-non-pruned-header))
|
||||
(let* ((folder buffer-file-name)
|
||||
(message-id (mail-fetch-field "message-id"))
|
||||
(from (mail-fetch-field "from"))
|
||||
(to (mail-fetch-field "to"))
|
||||
(subject (mail-fetch-field "subject"))
|
||||
desc link)
|
||||
(org-store-link-props
|
||||
:type "rmail" :from from :to to
|
||||
:subject subject :message-id message-id)
|
||||
(setq message-id (org-remove-angle-brackets message-id))
|
||||
(setq desc (org-email-link-description))
|
||||
(setq link (org-make-link "rmail:" folder "#" message-id))
|
||||
(org-add-link-props :link link :description desc)
|
||||
(rmail-show-message rmail-current-message)
|
||||
link)))))
|
||||
|
||||
(defun org-rmail-open (path)
|
||||
"Follow an Rmail message link to the specified PATH."
|
||||
|
@ -92,27 +83,19 @@
|
|||
"Follow an Rmail link to FOLDER and ARTICLE."
|
||||
(require 'rmail)
|
||||
(setq article (org-add-angle-brackets article))
|
||||
(let (message-number buff)
|
||||
(let (message-number)
|
||||
(save-excursion
|
||||
(save-window-excursion
|
||||
(rmail (if (string= folder "RMAIL") rmail-file-name folder))
|
||||
(setq buff (current-buffer)
|
||||
message-number
|
||||
(with-current-buffer
|
||||
(if (and (fboundp 'rmail-buffers-swapped-p)
|
||||
(rmail-buffers-swapped-p))
|
||||
rmail-view-buffer
|
||||
(current-buffer))
|
||||
(save-restriction
|
||||
(widen)
|
||||
(goto-char (point-max))
|
||||
(if (re-search-backward
|
||||
(concat "^Message-ID:\\s-+" (regexp-quote
|
||||
(or article "")))
|
||||
nil t)
|
||||
;; This is an rmail "debugging" function. :(
|
||||
(with-current-buffer buff
|
||||
(rmail-what-message))))))))
|
||||
(setq message-number
|
||||
(save-restriction
|
||||
(widen)
|
||||
(goto-char (point-max))
|
||||
(if (re-search-backward
|
||||
(concat "^Message-ID:\\s-+" (regexp-quote
|
||||
(or article "")))
|
||||
nil t)
|
||||
(rmail-what-message))))))
|
||||
(if message-number
|
||||
(progn
|
||||
(rmail (if (string= folder "RMAIL") rmail-file-name folder))
|
||||
|
|
471
lisp/org/org-src.el
Normal file
471
lisp/org/org-src.el
Normal file
|
@ -0,0 +1,471 @@
|
|||
;;; org-src.el --- Source code examples in Org
|
||||
;;
|
||||
;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
|
||||
;; Free Software Foundation, Inc.
|
||||
;;
|
||||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Bastien Guerry <bzg AT altern DOT org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; 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 contains the code dealing with source code examples in Org-mode.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'org-macs)
|
||||
(require 'org-compat)
|
||||
|
||||
(declare-function org-do-remove-indentation "org" (&optional n))
|
||||
(declare-function org-get-indentation "org" (&optional line))
|
||||
|
||||
(defcustom org-edit-src-region-extra nil
|
||||
"Additional regexps to identify regions for editing with `org-edit-src-code'.
|
||||
For examples see the function `org-edit-src-find-region-and-lang'.
|
||||
The regular expression identifying the begin marker should end with a newline,
|
||||
and the regexp marking the end line should start with a newline, to make sure
|
||||
there are kept outside the narrowed region."
|
||||
:group 'org-edit-structure
|
||||
:type '(repeat
|
||||
(list
|
||||
(regexp :tag "begin regexp")
|
||||
(regexp :tag "end regexp")
|
||||
(choice :tag "language"
|
||||
(string :tag "specify")
|
||||
(integer :tag "from match group")
|
||||
(const :tag "from `lang' element")
|
||||
(const :tag "from `style' element")))))
|
||||
|
||||
(defcustom org-coderef-label-format "(ref:%s)"
|
||||
"The default coderef format.
|
||||
This format string will be used to search for coderef labels in literal
|
||||
examples (EXAMPLE and SRC blocks). The format can be overwritten in
|
||||
an individual literal example with the -f option, like
|
||||
|
||||
#+BEGIN_SRC pascal +n -r -l \"((%s))\"
|
||||
...
|
||||
#+END_SRC
|
||||
|
||||
If you want to use this for HTML export, make sure that the format does
|
||||
not introduce special font-locking, and avoid the HTML special
|
||||
characters `<', `>', and `&'. The reason for this restriction is that
|
||||
the labels are searched for only after htmlize has done its job."
|
||||
:group 'org-edit-structure ; FIXME this is not in the right group
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-edit-fixed-width-region-mode 'artist-mode
|
||||
"The mode that should be used to edit fixed-width regions.
|
||||
These are the regions where each line starts with a colon."
|
||||
:group 'org-edit-structure
|
||||
:type '(choice
|
||||
(const artist-mode)
|
||||
(const picture-mode)
|
||||
(const fundamental-mode)
|
||||
(function :tag "Other (specify)")))
|
||||
|
||||
(defcustom org-edit-src-content-indentation 2
|
||||
"Indentation for the content is a source code block.
|
||||
This should be the number of spaces added to the indentation of the #+begin
|
||||
line in order to compute the indentation of the block content after
|
||||
editing it with \\[org-edit-src-code]."
|
||||
:group 'org-edit-structure
|
||||
:type 'integer)
|
||||
|
||||
(defcustom org-edit-src-persistent-message t
|
||||
"Non-nil means show persistent exit help message while editing src examples.
|
||||
The message is shown in the header-line, which will be created in the
|
||||
first line of the window showing the editing buffer.
|
||||
When nil, the message will only be shown intermittently in the echo area."
|
||||
:group 'org-edit-structure
|
||||
:type 'boolean)
|
||||
|
||||
|
||||
(defvar org-src-mode-hook nil
|
||||
"Hook run after Org switched a source code snippet to its Emacs mode.
|
||||
This hook will run
|
||||
|
||||
- when editing a source code snippet with \"C-c '\".
|
||||
- When formatting a source code snippet for export with htmlize.
|
||||
|
||||
You may want to use this hook for example to turn off `outline-minor-mode'
|
||||
or similar things which you want to have when editing a source code file,
|
||||
but which mess up the display of a snippet in Org exported files.")
|
||||
|
||||
;;; Editing source examples
|
||||
|
||||
(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-x\C-s" 'org-edit-src-save)
|
||||
(defvar org-edit-src-force-single-line nil)
|
||||
(defvar org-edit-src-from-org-mode nil)
|
||||
(defvar org-edit-src-picture nil)
|
||||
(defvar org-edit-src-beg-marker nil)
|
||||
(defvar org-edit-src-end-marker nil)
|
||||
(defvar org-edit-src-overlay nil)
|
||||
(defvar org-edit-src-nindent nil)
|
||||
|
||||
(define-minor-mode org-src-mode
|
||||
"Minor mode for language major mode buffers generated by org.
|
||||
This minor mode is turned on in two situations:
|
||||
- when editing a source code snippet with \"C-c '\".
|
||||
- When formatting a source code snippet for export with htmlize.
|
||||
There is a mode hook, and keybindings for `org-edit-src-exit' and
|
||||
`org-edit-src-save'")
|
||||
|
||||
(defun org-edit-src-code ()
|
||||
"Edit the source code example at point.
|
||||
The example is copied to a separate buffer, and that buffer is switched
|
||||
to the correct language mode. When done, exit with \\[org-edit-src-exit].
|
||||
This will remove the original code in the Org buffer, and replace it with
|
||||
the edited version."
|
||||
(interactive)
|
||||
(let ((line (org-current-line))
|
||||
(case-fold-search t)
|
||||
(msg (substitute-command-keys
|
||||
"Edit, then exit with C-c ' (C-c and single quote)"))
|
||||
(info (org-edit-src-find-region-and-lang))
|
||||
(org-mode-p (eq major-mode 'org-mode))
|
||||
(beg (make-marker))
|
||||
(end (make-marker))
|
||||
nindent ovl lang lang-f single lfmt code begline buffer)
|
||||
(if (not info)
|
||||
nil
|
||||
(setq beg (move-marker beg (nth 0 info))
|
||||
end (move-marker end (nth 1 info))
|
||||
code (buffer-substring-no-properties beg end)
|
||||
lang (nth 2 info)
|
||||
single (nth 3 info)
|
||||
lfmt (nth 4 info)
|
||||
nindent (nth 5 info)
|
||||
lang-f (intern (concat lang "-mode"))
|
||||
begline (save-excursion (goto-char beg) (org-current-line)))
|
||||
(unless (functionp lang-f)
|
||||
(error "No such language mode: %s" lang-f))
|
||||
(goto-line line)
|
||||
(if (and (setq buffer (org-edit-src-find-buffer beg end))
|
||||
(y-or-n-p "Return to existing edit buffer? [n] will revert changes: "))
|
||||
(switch-to-buffer buffer)
|
||||
(when buffer
|
||||
(with-current-buffer buffer
|
||||
(if (boundp 'org-edit-src-overlay)
|
||||
(org-delete-overlay org-edit-src-overlay)))
|
||||
(kill-buffer buffer))
|
||||
(setq buffer (generate-new-buffer "*Org Edit Src Example*"))
|
||||
(setq ovl (org-make-overlay beg end))
|
||||
(org-overlay-put ovl 'face 'secondary-selection)
|
||||
(org-overlay-put ovl 'edit-buffer buffer)
|
||||
(org-overlay-put ovl 'help-echo "Click with mouse-1 to switch to buffer editing this segment")
|
||||
(org-overlay-put ovl 'face 'secondary-selection)
|
||||
(org-overlay-put ovl
|
||||
'keymap
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(define-key map [mouse-1] 'org-edit-src-continue)
|
||||
map))
|
||||
(org-overlay-put ovl :read-only "Leave me alone")
|
||||
(switch-to-buffer buffer)
|
||||
(insert code)
|
||||
(remove-text-properties (point-min) (point-max)
|
||||
'(display nil invisible nil intangible nil))
|
||||
(org-do-remove-indentation)
|
||||
(let ((org-inhibit-startup t))
|
||||
(funcall lang-f)
|
||||
(org-src-mode))
|
||||
(set (make-local-variable 'org-edit-src-force-single-line) single)
|
||||
(set (make-local-variable 'org-edit-src-from-org-mode) org-mode-p)
|
||||
(when lfmt
|
||||
(set (make-local-variable 'org-coderef-label-format) lfmt))
|
||||
(when org-mode-p
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "^," nil t)
|
||||
(replace-match "")))
|
||||
(goto-line (1+ (- line begline)))
|
||||
(org-set-local 'org-edit-src-beg-marker beg)
|
||||
(org-set-local 'org-edit-src-end-marker end)
|
||||
(org-set-local 'org-edit-src-overlay ovl)
|
||||
(org-set-local 'org-edit-src-nindent nindent)
|
||||
(and org-edit-src-persistent-message
|
||||
(org-set-local 'header-line-format msg)))
|
||||
(message "%s" msg)
|
||||
t)))
|
||||
|
||||
(defun org-edit-src-continue (e)
|
||||
(interactive "e")
|
||||
(mouse-set-point e)
|
||||
(let ((buf (get-char-property (point) 'edit-buffer)))
|
||||
(if buf (switch-to-buffer buf)
|
||||
(error "Something is wrong here"))))
|
||||
|
||||
(defun org-edit-src-find-buffer (beg end)
|
||||
"Find a source editing buffer that is already editing the region BEG to END."
|
||||
(catch 'exit
|
||||
(mapc
|
||||
(lambda (b)
|
||||
(with-current-buffer b
|
||||
(if (and (string-match "\\`*Org Edit " (buffer-name))
|
||||
(local-variable-p 'org-edit-src-beg-marker (current-buffer))
|
||||
(local-variable-p 'org-edit-src-end-marker (current-buffer))
|
||||
(equal beg org-edit-src-beg-marker)
|
||||
(equal end org-edit-src-end-marker))
|
||||
(throw 'exit (current-buffer)))))
|
||||
(buffer-list))
|
||||
nil))
|
||||
|
||||
(defun org-edit-fixed-width-region ()
|
||||
"Edit the fixed-width ascii drawing at point.
|
||||
This must be a region where each line starts with a colon followed by
|
||||
a space character.
|
||||
An new buffer is created and the fixed-width region is copied into it,
|
||||
and the buffer is switched into `artist-mode' for editing. When done,
|
||||
exit with \\[org-edit-src-exit]. The edited text will then replace
|
||||
the fragment in the Org-mode buffer."
|
||||
(interactive)
|
||||
(let ((line (org-current-line))
|
||||
(case-fold-search t)
|
||||
(msg (substitute-command-keys
|
||||
"Edit, then exit with C-c ' (C-c and single quote)"))
|
||||
(org-mode-p (eq major-mode 'org-mode))
|
||||
(beg (make-marker))
|
||||
(end (make-marker))
|
||||
nindent ovl beg1 end1 code begline buffer)
|
||||
(beginning-of-line 1)
|
||||
(if (looking-at "[ \t]*[^:\n \t]")
|
||||
nil
|
||||
(if (looking-at "[ \t]*\\(\n\\|\\'\\)")
|
||||
(setq beg1 (point) end1 beg1)
|
||||
(save-excursion
|
||||
(if (re-search-backward "^[ \t]*[^: \t]" nil 'move)
|
||||
(setq beg1 (point-at-bol 2))
|
||||
(setq beg1 (point))))
|
||||
(save-excursion
|
||||
(if (re-search-forward "^[ \t]*[^: \t]" nil 'move)
|
||||
(setq end1 (1- (match-beginning 0)))
|
||||
(setq end1 (point))))
|
||||
(goto-line line))
|
||||
(setq beg (move-marker beg beg1)
|
||||
end (move-marker end end1)
|
||||
code (buffer-substring-no-properties beg end)
|
||||
begline (save-excursion (goto-char beg) (org-current-line)))
|
||||
(if (and (setq buffer (org-edit-src-find-buffer beg end))
|
||||
(y-or-n-p "Return to existing edit buffer? [n] will revert changes: "))
|
||||
(switch-to-buffer buffer)
|
||||
(when buffer
|
||||
(with-current-buffer buffer
|
||||
(if (boundp 'org-edit-src-overlay)
|
||||
(org-delete-overlay org-edit-src-overlay)))
|
||||
(kill-buffer buffer))
|
||||
(setq buffer (generate-new-buffer "*Org Edit Src Example*"))
|
||||
(setq ovl (org-make-overlay beg end))
|
||||
(org-overlay-put ovl 'face 'secondary-selection)
|
||||
(org-overlay-put ovl 'edit-buffer buffer)
|
||||
(org-overlay-put ovl 'help-echo "Click with mouse-1 to switch to buffer editing this segment")
|
||||
(org-overlay-put ovl 'face 'secondary-selection)
|
||||
(org-overlay-put ovl
|
||||
'keymap
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(define-key map [mouse-1] 'org-edit-src-continue)
|
||||
map))
|
||||
(org-overlay-put ovl :read-only "Leave me alone")
|
||||
(switch-to-buffer buffer)
|
||||
(insert code)
|
||||
(remove-text-properties (point-min) (point-max)
|
||||
'(display nil invisible nil intangible nil))
|
||||
(setq nindent (org-do-remove-indentation))
|
||||
(cond
|
||||
((eq org-edit-fixed-width-region-mode 'artist-mode)
|
||||
(fundamental-mode)
|
||||
(artist-mode 1))
|
||||
(t (funcall org-edit-fixed-width-region-mode)))
|
||||
(set (make-local-variable 'org-edit-src-force-single-line) nil)
|
||||
(set (make-local-variable 'org-edit-src-from-org-mode) org-mode-p)
|
||||
(set (make-local-variable 'org-edit-src-picture) t)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "^[ \t]*: ?" nil t)
|
||||
(replace-match ""))
|
||||
(goto-line (1+ (- line begline)))
|
||||
(org-src-mode)
|
||||
(org-set-local 'org-edit-src-beg-marker beg)
|
||||
(org-set-local 'org-edit-src-end-marker end)
|
||||
(org-set-local 'org-edit-src-overlay ovl)
|
||||
(org-set-local 'org-edit-src-nindent nindent)
|
||||
(and org-edit-src-persistent-message
|
||||
(org-set-local 'header-line-format msg)))
|
||||
(message "%s" msg)
|
||||
t)))
|
||||
|
||||
(defun org-edit-src-find-region-and-lang ()
|
||||
"Find the region and language for a local edit.
|
||||
Return a list with beginning and end of the region, a string representing
|
||||
the language, a switch telling of the content should be in a single line."
|
||||
(let ((re-list
|
||||
(append
|
||||
org-edit-src-region-extra
|
||||
'(
|
||||
("<src\\>[^<]*>[ \t]*\n?" "\n?[ \t]*</src>" lang)
|
||||
("<literal\\>[^<]*>[ \t]*\n?" "\n?[ \t]*</literal>" style)
|
||||
("<example>[ \t]*\n?" "\n?[ \t]*</example>" "fundamental")
|
||||
("<lisp>[ \t]*\n?" "\n?[ \t]*</lisp>" "emacs-lisp")
|
||||
("<perl>[ \t]*\n?" "\n?[ \t]*</perl>" "perl")
|
||||
("<python>[ \t]*\n?" "\n?[ \t]*</python>" "python")
|
||||
("<ruby>[ \t]*\n?" "\n?[ \t]*</ruby>" "ruby")
|
||||
("^[ \t]*#\\+begin_src\\( \\([^ \t\n]+\\)\\)?.*\n" "\n[ \t]*#\\+end_src" 2)
|
||||
("^[ \t]*#\\+begin_example.*\n" "\n[ \t]*#\\+end_example" "fundamental")
|
||||
("^[ \t]*#\\+html:" "\n" "html" single-line)
|
||||
("^[ \t]*#\\+begin_html.*\n" "\n[ \t]*#\\+end_html" "html")
|
||||
("^[ \t]*#\\+latex:" "\n" "latex" 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]*#\\+begin_docbook.*\n" "\n[ \t]*#\\+end_docbook" "xml")
|
||||
)))
|
||||
(pos (point))
|
||||
re1 re2 single beg end lang lfmt match-re1 ind entry)
|
||||
(catch 'exit
|
||||
(while (setq entry (pop re-list))
|
||||
(setq re1 (car entry) re2 (nth 1 entry) lang (nth 2 entry)
|
||||
single (nth 3 entry))
|
||||
(save-excursion
|
||||
(if (or (looking-at re1)
|
||||
(re-search-backward re1 nil t))
|
||||
(progn
|
||||
(setq match-re1 (match-string 0))
|
||||
(setq beg (match-end 0)
|
||||
lang (org-edit-src-get-lang lang)
|
||||
lfmt (org-edit-src-get-label-format match-re1)
|
||||
ind (org-edit-src-get-indentation (match-beginning 0)))
|
||||
(if (and (re-search-forward re2 nil t)
|
||||
(>= (match-end 0) pos))
|
||||
(throw 'exit (list beg (match-beginning 0)
|
||||
lang single lfmt ind))))
|
||||
(if (or (looking-at re2)
|
||||
(re-search-forward re2 nil t))
|
||||
(progn
|
||||
(setq end (match-beginning 0))
|
||||
(if (and (re-search-backward re1 nil t)
|
||||
(<= (match-beginning 0) pos))
|
||||
(progn
|
||||
(setq lfmt (org-edit-src-get-label-format
|
||||
(match-string 0))
|
||||
ind (org-edit-src-get-indentation
|
||||
(match-beginning 0)))
|
||||
(throw 'exit
|
||||
(list (match-end 0) end
|
||||
(org-edit-src-get-lang lang)
|
||||
single lfmt ind))))))))))))
|
||||
|
||||
(defun org-edit-src-get-lang (lang)
|
||||
"Extract the src language."
|
||||
(let ((m (match-string 0)))
|
||||
(cond
|
||||
((stringp lang) lang)
|
||||
((integerp lang) (match-string lang))
|
||||
((and (eq lang 'lang)
|
||||
(string-match "\\<lang=\"\\([^ \t\n\"]+\\)\"" m))
|
||||
(match-string 1 m))
|
||||
((and (eq lang 'style)
|
||||
(string-match "\\<style=\"\\([^ \t\n\"]+\\)\"" m))
|
||||
(match-string 1 m))
|
||||
(t "fundamental"))))
|
||||
|
||||
(defun org-edit-src-get-label-format (s)
|
||||
"Extract the label format."
|
||||
(save-match-data
|
||||
(if (string-match "-l[ \t]+\\\\?\"\\([^\t\r\n\"]+\\)\\\\?\"" s)
|
||||
(match-string 1 s))))
|
||||
|
||||
(defun org-edit-src-get-indentation (pos)
|
||||
"Extract the label format."
|
||||
(save-match-data
|
||||
(goto-char pos)
|
||||
(org-get-indentation)))
|
||||
|
||||
(defun org-edit-src-exit ()
|
||||
"Exit special edit and protect problematic lines."
|
||||
(interactive)
|
||||
(unless (string-match "\\`*Org Edit " (buffer-name (current-buffer)))
|
||||
(error "This is not an sub-editing buffer, something is wrong..."))
|
||||
(let ((beg org-edit-src-beg-marker)
|
||||
(end org-edit-src-end-marker)
|
||||
(ovl org-edit-src-overlay)
|
||||
(buffer (current-buffer))
|
||||
(nindent org-edit-src-nindent)
|
||||
code line)
|
||||
(untabify (point-min) (point-max))
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(if (looking-at "[ \t\n]*\n") (replace-match ""))
|
||||
(if (re-search-forward "\n[ \t\n]*\\'" nil t) (replace-match "")))
|
||||
(setq line (if (org-bound-and-true-p org-edit-src-force-single-line)
|
||||
1
|
||||
(org-current-line)))
|
||||
(when (org-bound-and-true-p org-edit-src-force-single-line)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "\n" nil t)
|
||||
(replace-match " "))
|
||||
(goto-char (point-min))
|
||||
(if (looking-at "\\s-*") (replace-match " "))
|
||||
(if (re-search-forward "\\s-+\\'" nil t)
|
||||
(replace-match "")))
|
||||
(when (org-bound-and-true-p org-edit-src-from-org-mode)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward
|
||||
(if (org-mode-p) "^\\(.\\)" "^\\([*]\\|[ \t]*#\\+\\)") nil t)
|
||||
(replace-match ",\\1")))
|
||||
(when (org-bound-and-true-p org-edit-src-picture)
|
||||
(untabify (point-min) (point-max))
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "^" nil t)
|
||||
(replace-match ": ")))
|
||||
(when nindent
|
||||
(setq nindent (make-string (+ org-edit-src-content-indentation nindent)
|
||||
?\ ))
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "^" nil t)
|
||||
(replace-match nindent)))
|
||||
(setq code (buffer-string))
|
||||
(switch-to-buffer (marker-buffer beg))
|
||||
(kill-buffer buffer)
|
||||
(goto-char beg)
|
||||
(org-delete-overlay ovl)
|
||||
(delete-region beg end)
|
||||
(insert code)
|
||||
(goto-char beg)
|
||||
(goto-line (1- (+ (org-current-line) line)))
|
||||
(move-marker beg nil)
|
||||
(move-marker end nil)))
|
||||
|
||||
(defun org-edit-src-save ()
|
||||
"Save parent buffer with current state source-code buffer."
|
||||
(interactive)
|
||||
(let ((p (point)) (m (mark)) msg)
|
||||
(org-edit-src-exit)
|
||||
(save-buffer)
|
||||
(setq msg (current-message))
|
||||
(org-edit-src-code)
|
||||
(push-mark m 'nomessage)
|
||||
(goto-char (min p (point-max)))
|
||||
(message (or msg ""))))
|
||||
|
||||
(provide 'org-src)
|
||||
|
||||
;; arch-tag: 6a1fc84f-dec7-47be-a416-64be56bea5d8
|
||||
|
||||
;;; org-src.el ends here
|
|
@ -6,7 +6,7 @@
|
|||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
@ -247,13 +247,29 @@ Automatically means, when TAB or RET or C-c C-c are pressed in the line."
|
|||
:type 'boolean)
|
||||
|
||||
(defcustom org-table-error-on-row-ref-crossing-hline t
|
||||
"Non-nil means, a relative row reference that tries to cross a hline errors.
|
||||
When nil, the reference will silently be to the field just next to the hline.
|
||||
Coming from below, it will be the field below the hline, coming from
|
||||
above, it will be the field above the hline."
|
||||
"OBSOLETE VARIABLE, please see `org-table-relative-ref-may-cross-hline'."
|
||||
:group 'org-table
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-table-relative-ref-may-cross-hline t
|
||||
"Non-nil means, reltive formula references may cross hlines.
|
||||
Here are the allowed values:
|
||||
|
||||
nil Relative references may not cross hlines. They will reference the
|
||||
field next to the hline instead. Coming from below, the reference
|
||||
will be to the field below the hline. Coming from above, it will be
|
||||
to the field above.
|
||||
t Relative references may cros hlines.
|
||||
error An attempt to cross a hline will throw an error.
|
||||
|
||||
It is probably good to never set this variable to nil, for the sake of
|
||||
portability of tables."
|
||||
:group 'org-table-calculation
|
||||
:type '(choice
|
||||
(const :tag "Allow to cross" t)
|
||||
(const :tag "Stick to hline" nil)
|
||||
(const :tag "Error on attempt to cross" error)))
|
||||
|
||||
(defgroup org-table-import-export nil
|
||||
"Options concerning table import and export in Org-mode."
|
||||
:tag "Org Table Import Export"
|
||||
|
@ -471,8 +487,9 @@ property, locally or anywhere up in the hierarchy."
|
|||
(error "Abort")))
|
||||
(if (file-directory-p file)
|
||||
(error "This is a directory path, not a file"))
|
||||
(if (equal (file-truename file)
|
||||
(file-truename (buffer-file-name)))
|
||||
(if (and (buffer-file-name)
|
||||
(equal (file-truename file)
|
||||
(file-truename (buffer-file-name))))
|
||||
(error "Please specify a file name that is different from current"))
|
||||
(unless format
|
||||
(setq deffmt-readable org-table-export-default-format)
|
||||
|
@ -573,7 +590,7 @@ When nil, simply write \"#ERROR\" in corrupted fields.")
|
|||
(make-string sp2 ?\ ) "%%%s%ds" (make-string sp1 ?\ ) "|"))
|
||||
(hfmt1 (concat
|
||||
(make-string sp2 ?-) "%s" (make-string sp1 ?-) "+"))
|
||||
emptystrings links dates emph narrow fmax f1 len c e)
|
||||
emptystrings links dates emph narrow falign falign1 fmax f1 len c e)
|
||||
(untabify beg end)
|
||||
(remove-text-properties beg end '(org-cwidth t org-dwidth t display t))
|
||||
;; Check if we have links or dates
|
||||
|
@ -594,7 +611,9 @@ When nil, simply write \"#ERROR\" in corrupted fields.")
|
|||
;; Check if we are narrowing any columns
|
||||
(goto-char beg)
|
||||
(setq narrow (and org-format-transports-properties-p
|
||||
(re-search-forward "<[0-9]+>" end t)))
|
||||
(re-search-forward "<[rl]?[0-9]+>" end t)))
|
||||
(goto-char beg)
|
||||
(setq falign (re-search-forward "<[rl][0-9]*>" end t))
|
||||
;; Get the rows
|
||||
(setq lines (org-split-string
|
||||
(buffer-substring beg end) "\n"))
|
||||
|
@ -629,12 +648,14 @@ When nil, simply write \"#ERROR\" in corrupted fields.")
|
|||
(while (< (setq i (1+ i)) maxfields) ;; Loop over all columns
|
||||
(setq column (mapcar (lambda (x) (or (nth i x) "")) fields))
|
||||
;; Check if there is an explicit width specified
|
||||
(when narrow
|
||||
(setq c column fmax nil)
|
||||
(when (or narrow falign)
|
||||
(setq c column fmax nil falign1 nil)
|
||||
(while c
|
||||
(setq e (pop c))
|
||||
(if (and (stringp e) (string-match "^<\\([0-9]+\\)>$" e))
|
||||
(setq fmax (string-to-number (match-string 1 e)) c nil)))
|
||||
(when (and (stringp e) (string-match "^<\\([rl]\\)?\\([0-9]+\\)?>$" e))
|
||||
(if (match-end 1) (setq falign1 (match-string 1 e)))
|
||||
(if (match-end 2)
|
||||
(setq fmax (string-to-number (match-string 2 e)) c nil))))
|
||||
;; Find fields that are wider than fmax, and shorten them
|
||||
(when fmax
|
||||
(loop for xx in column do
|
||||
|
@ -654,14 +675,16 @@ When nil, simply write \"#ERROR\" in corrupted fields.")
|
|||
;; Get the maximum width for each column
|
||||
(push (apply 'max 1 (mapcar 'org-string-width column)) lengths)
|
||||
;; Get the fraction of numbers, to decide about alignment of the column
|
||||
(setq cnt 0 frac 0.0)
|
||||
(loop for x in column do
|
||||
(if (equal x "")
|
||||
nil
|
||||
(setq frac ( / (+ (* frac cnt)
|
||||
(if (string-match org-table-number-regexp x) 1 0))
|
||||
(setq cnt (1+ cnt))))))
|
||||
(push (>= frac org-table-number-fraction) typenums))
|
||||
(if falign1
|
||||
(push (equal (downcase falign1) "r") typenums)
|
||||
(setq cnt 0 frac 0.0)
|
||||
(loop for x in column do
|
||||
(if (equal x "")
|
||||
nil
|
||||
(setq frac ( / (+ (* frac cnt)
|
||||
(if (string-match org-table-number-regexp x) 1 0))
|
||||
(setq cnt (1+ cnt))))))
|
||||
(push (>= frac org-table-number-fraction) typenums)))
|
||||
(setq lengths (nreverse lengths) typenums (nreverse typenums))
|
||||
|
||||
;; Store the alignment of this table, for later editing of single fields
|
||||
|
@ -699,6 +722,16 @@ When nil, simply write \"#ERROR\" in corrupted fields.")
|
|||
;; Replace the old one
|
||||
(delete-region beg end)
|
||||
(move-marker end nil)
|
||||
(if (equal (char-before) ?\n)
|
||||
;; This hack is for org-indent, to force redisplay of the
|
||||
;; line prefix of the first line. Apparently the redisplay
|
||||
;; is tied to the newline, which is, I think, a bug.
|
||||
;; To force this redisplay, we remove and re-insert the
|
||||
;; newline, so that the redisplay engine thinks it belongs
|
||||
;; to the changed text.
|
||||
(progn
|
||||
(backward-delete-char 1)
|
||||
(insert "\n")))
|
||||
(move-marker org-table-aligned-begin-marker (point))
|
||||
(insert new)
|
||||
(move-marker org-table-aligned-end-marker (point))
|
||||
|
@ -827,13 +860,48 @@ Before doing so, re-align the table if necessary."
|
|||
(org-table-align))
|
||||
(if (org-at-table-hline-p)
|
||||
(end-of-line 1))
|
||||
(re-search-backward "|" (org-table-begin))
|
||||
(re-search-backward "|" (org-table-begin))
|
||||
(condition-case nil
|
||||
(progn
|
||||
(re-search-backward "|" (org-table-begin))
|
||||
(re-search-backward "|" (org-table-begin)))
|
||||
(error (error "Cannot move to previous table field")))
|
||||
(while (looking-at "|\\(-\\|[ \t]*$\\)")
|
||||
(re-search-backward "|" (org-table-begin)))
|
||||
(if (looking-at "| ?")
|
||||
(goto-char (match-end 0))))
|
||||
|
||||
(defun org-table-beginning-of-field (&optional n)
|
||||
"Move to the end of the current table field.
|
||||
If already at or after the end, move to the end of the next table field.
|
||||
With numeric argument N, move N-1 fields forward first."
|
||||
(interactive "p")
|
||||
(let ((pos (point)))
|
||||
(while (> n 1)
|
||||
(setq n (1- n))
|
||||
(org-table-previous-field))
|
||||
(if (not (re-search-backward "|" (point-at-bol 0) t))
|
||||
(error "No more table fields before the current")
|
||||
(goto-char (match-end 0))
|
||||
(and (looking-at " ") (forward-char 1)))
|
||||
(if (>= (point) pos) (org-table-beginning-of-field 2))))
|
||||
|
||||
(defun org-table-end-of-field (&optional n)
|
||||
"Move to the beginning of the current table field.
|
||||
If already at or before the beginning, move to the beginning of the
|
||||
previous field.
|
||||
With numeric argument N, move N-1 fields backward first."
|
||||
(interactive "p")
|
||||
(let ((pos (point)))
|
||||
(while (> n 1)
|
||||
(setq n (1- n))
|
||||
(org-table-next-field))
|
||||
(when (re-search-forward "|" (point-at-eol 1) t)
|
||||
(backward-char 1)
|
||||
(skip-chars-backward " ")
|
||||
(if (and (equal (char-before (point)) ?|) (looking-at " "))
|
||||
(forward-char 1)))
|
||||
(if (<= (point) pos) (org-table-end-of-field 2))))
|
||||
|
||||
(defun org-table-next-row ()
|
||||
"Go to the next row (same column) in the current table.
|
||||
Before doing so, re-align the table if necessary."
|
||||
|
@ -1362,15 +1430,21 @@ should be done in reverse order."
|
|||
|
||||
|
||||
(defun org-table-cut-region (beg end)
|
||||
"Copy region in table to the clipboard and blank all relevant fields."
|
||||
(interactive "r")
|
||||
"Copy region in table to the clipboard and blank all relevant fields.
|
||||
If there is no active region, use just the field at point."
|
||||
(interactive (list
|
||||
(if (org-region-active-p) (region-beginning) (point))
|
||||
(if (org-region-active-p) (region-end) (point))))
|
||||
(org-table-copy-region beg end 'cut))
|
||||
|
||||
(defun org-table-copy-region (beg end &optional cut)
|
||||
"Copy rectangular region in table to clipboard.
|
||||
A special clipboard is used which can only be accessed
|
||||
with `org-table-paste-rectangle'."
|
||||
(interactive "rP")
|
||||
(interactive (list
|
||||
(if (org-region-active-p) (region-beginning) (point))
|
||||
(if (org-region-active-p) (region-end) (point))
|
||||
current-prefix-arg))
|
||||
(let* (l01 c01 l02 c02 l1 c1 l2 c2 ic1 ic2
|
||||
region cols
|
||||
(rpl (if cut " " nil)))
|
||||
|
@ -1778,11 +1852,12 @@ When NAMED is non-nil, look for a named equation."
|
|||
(setq alist (sort alist 'org-table-formula-less-p))
|
||||
(save-excursion
|
||||
(goto-char (org-table-end))
|
||||
(if (looking-at "\\([ \t]*\n\\)*#\\+TBLFM:\\(.*\n?\\)")
|
||||
(if (looking-at "\\([ \t]*\n\\)*[ \t]*#\\+TBLFM:\\(.*\n?\\)")
|
||||
(progn
|
||||
;; don't overwrite TBLFM, we might use text properties to store stuff
|
||||
(goto-char (match-beginning 2))
|
||||
(delete-region (match-beginning 2) (match-end 0)))
|
||||
(org-indent-line-function)
|
||||
(insert "#+TBLFM:"))
|
||||
(insert " "
|
||||
(mapconcat (lambda (x)
|
||||
|
@ -1811,7 +1886,7 @@ When NAMED is non-nil, look for a named equation."
|
|||
(let (scol eq eq-alist strings string seen)
|
||||
(save-excursion
|
||||
(goto-char (org-table-end))
|
||||
(when (looking-at "\\([ \t]*\n\\)*#\\+TBLFM: *\\(.*\\)")
|
||||
(when (looking-at "\\([ \t]*\n\\)*[ \t]*#\\+TBLFM: *\\(.*\\)")
|
||||
(setq strings (org-split-string (match-string 2) " *:: *"))
|
||||
(while (setq string (pop strings))
|
||||
(when (string-match "\\`\\(@[0-9]+\\$[0-9]+\\|\\$\\([a-zA-Z0-9]+\\)\\) *= *\\(.*[^ \t]\\)" string)
|
||||
|
@ -1836,7 +1911,7 @@ KEY is \"@\" or \"$\". REPLACE is an alist of numbers to replace.
|
|||
For all numbers larger than LIMIT, shift them by DELTA."
|
||||
(save-excursion
|
||||
(goto-char (org-table-end))
|
||||
(when (looking-at "#\\+TBLFM:")
|
||||
(when (looking-at "[ \t]*#\\+TBLFM:")
|
||||
(let ((re (concat key "\\([0-9]+\\)"))
|
||||
(re2
|
||||
(when remove
|
||||
|
@ -1847,14 +1922,17 @@ For all numbers larger than LIMIT, shift them by DELTA."
|
|||
s n a)
|
||||
(when remove
|
||||
(while (re-search-forward re2 (point-at-eol) t)
|
||||
(replace-match "")))
|
||||
(unless (save-match-data (org-in-regexp "remote([^)]+?)"))
|
||||
(replace-match ""))))
|
||||
(while (re-search-forward re (point-at-eol) t)
|
||||
(setq s (match-string 1) n (string-to-number s))
|
||||
(cond
|
||||
((setq a (assoc s replace))
|
||||
(replace-match (concat key (cdr a)) t t))
|
||||
((and limit (> n limit))
|
||||
(replace-match (concat key (int-to-string (+ n delta))) t t))))))))
|
||||
(unless (save-match-data (org-in-regexp "remote([^)]+?)"))
|
||||
(setq s (match-string 1) n (string-to-number s))
|
||||
(cond
|
||||
((setq a (assoc s replace))
|
||||
(replace-match (concat key (cdr a)) t t))
|
||||
((and limit (> n limit))
|
||||
(replace-match (concat key (int-to-string (+ n delta)))
|
||||
t t)))))))))
|
||||
|
||||
(defun org-table-get-specials ()
|
||||
"Get the column names and local parameters for this table."
|
||||
|
@ -2353,9 +2431,13 @@ and TABLE is a vector with line types."
|
|||
(>= i 0) (< i l)
|
||||
(not (eq (aref table i) type))
|
||||
(if (and relative (eq (aref table i) 'hline))
|
||||
(if org-table-error-on-row-ref-crossing-hline
|
||||
(error "Row descriptor %s used in line %d crosses hline" desc cline)
|
||||
(progn (setq i (- i (if backwards -1 1)) n 1) nil))
|
||||
(cond
|
||||
((eq org-table-relative-ref-may-cross-hline t) t)
|
||||
((eq org-table-relative-ref-may-cross-hline 'error)
|
||||
(error "Row descriptor %s used in line %d crosses hline" desc cline))
|
||||
(t (setq i (- i (if backwards -1 1))
|
||||
n 1)
|
||||
nil))
|
||||
t)))
|
||||
(setq n (1- n)))
|
||||
(if (or (< i 0) (>= i l))
|
||||
|
@ -2620,7 +2702,7 @@ Parameters get priority."
|
|||
(defun org-table-edit-formulas ()
|
||||
"Edit the formulas of the current table in a separate buffer."
|
||||
(interactive)
|
||||
(when (save-excursion (beginning-of-line 1) (looking-at "#\\+TBLFM"))
|
||||
(when (save-excursion (beginning-of-line 1) (looking-at "[ \t]*#\\+TBLFM"))
|
||||
(beginning-of-line 0))
|
||||
(unless (org-at-table-p) (error "Not at a table"))
|
||||
(org-table-get-specials)
|
||||
|
@ -3387,6 +3469,8 @@ to execute outside of tables."
|
|||
'("\C-c`" org-table-edit-field)
|
||||
'("\C-c*" org-table-recalculate)
|
||||
'("\C-c^" org-table-sort-lines)
|
||||
'("\M-a" org-table-beginning-of-field)
|
||||
'("\M-e" org-table-end-of-field)
|
||||
'([(control ?#)] org-table-rotate-recalc-marks)))
|
||||
elt key fun cmd)
|
||||
(while (setq elt (pop bindings))
|
||||
|
@ -3411,6 +3495,16 @@ to execute outside of tables."
|
|||
(orgtbl-make-binding 'org-table-previous-field 104
|
||||
[(shift tab)] [(tab)] "\C-i"))
|
||||
|
||||
(org-defkey orgtbl-mode-map [S-iso-lefttab]
|
||||
(orgtbl-make-binding 'org-table-previous-field 107
|
||||
[S-iso-lefttab] [backtab] [(shift tab)]
|
||||
[(tab)] "\C-i"))
|
||||
|
||||
(org-defkey orgtbl-mode-map [backtab]
|
||||
(orgtbl-make-binding 'org-table-previous-field 108
|
||||
[backtab] [S-iso-lefttab] [(shift tab)]
|
||||
[(tab)] "\C-i"))
|
||||
|
||||
(org-defkey orgtbl-mode-map "\M-\C-m"
|
||||
(orgtbl-make-binding 'org-table-wrap-region 105
|
||||
"\M-\C-m" [(meta return)]))
|
||||
|
@ -3491,15 +3585,15 @@ to execute outside of tables."
|
|||
|
||||
(defun orgtbl-ctrl-c-ctrl-c (arg)
|
||||
"If the cursor is inside a table, realign the table.
|
||||
It it is a table to be sent away to a receiver, do it.
|
||||
If it is a table to be sent away to a receiver, do it.
|
||||
With prefix arg, also recompute table."
|
||||
(interactive "P")
|
||||
(let ((pos (point)) action)
|
||||
(save-excursion
|
||||
(beginning-of-line 1)
|
||||
(setq action (cond ((looking-at "#\\+ORGTBL:.*\n[ \t]*|") (match-end 0))
|
||||
(setq action (cond ((looking-at "[ \t]*#\\+ORGTBL:.*\n[ \t]*|") (match-end 0))
|
||||
((looking-at "[ \t]*|") pos)
|
||||
((looking-at "#\\+TBLFM:") 'recalc))))
|
||||
((looking-at "[ \t]*#\\+TBLFM:") 'recalc))))
|
||||
(cond
|
||||
((integerp action)
|
||||
(goto-char action)
|
||||
|
@ -3557,7 +3651,8 @@ overwritten, and the table is not marked as requiring realignment."
|
|||
orgtbl-hijacker-command-102
|
||||
orgtbl-hijacker-command-103
|
||||
orgtbl-hijacker-command-104
|
||||
orgtbl-hijacker-command-105))
|
||||
orgtbl-hijacker-command-105
|
||||
yas/expand))
|
||||
(org-table-blank-field))
|
||||
t)
|
||||
(eq N 1)
|
||||
|
@ -3568,14 +3663,27 @@ overwritten, and the table is not marked as requiring realignment."
|
|||
(goto-char (match-beginning 0))
|
||||
(self-insert-command N))
|
||||
(setq org-table-may-need-update t)
|
||||
(let (orgtbl-mode a)
|
||||
(call-interactively
|
||||
(or (key-binding
|
||||
(or (and (listp function-key-map)
|
||||
(setq a (assoc last-input-event function-key-map))
|
||||
(cdr a))
|
||||
(vector last-input-event)))
|
||||
'self-insert-command)))))
|
||||
(let* (orgtbl-mode
|
||||
a
|
||||
(cmd (or (key-binding
|
||||
(or (and (listp function-key-map)
|
||||
(setq a (assoc last-input-event function-key-map))
|
||||
(cdr a))
|
||||
(vector last-input-event)))
|
||||
'self-insert-command)))
|
||||
(call-interactively cmd)
|
||||
(if (and org-self-insert-cluster-for-undo
|
||||
(eq cmd 'self-insert-command))
|
||||
(if (not (eq last-command 'orgtbl-self-insert-command))
|
||||
(setq org-self-insert-command-undo-counter 1)
|
||||
(if (>= org-self-insert-command-undo-counter 20)
|
||||
(setq org-self-insert-command-undo-counter 1)
|
||||
(and (> org-self-insert-command-undo-counter 0)
|
||||
buffer-undo-list
|
||||
(not (cadr buffer-undo-list)) ; remove nil entry
|
||||
(setcdr buffer-undo-list (cddr buffer-undo-list)))
|
||||
(setq org-self-insert-command-undo-counter
|
||||
(1+ org-self-insert-command-undo-counter))))))))
|
||||
|
||||
(defvar orgtbl-exp-regexp "^\\([-+]?[0-9][0-9.]*\\)[eE]\\([-+]?[0-9]+\\)$"
|
||||
"Regular expression matching exponentials as produced by calc.")
|
||||
|
@ -3612,7 +3720,7 @@ a radio table."
|
|||
(goto-char (org-table-begin))
|
||||
(let (rtn)
|
||||
(beginning-of-line 0)
|
||||
(while (looking-at "#\\+ORGTBL[: \t][ \t]*SEND +\\([a-zA-Z0-9_]+\\) +\\([^ \t\r\n]+\\)\\( +.*\\)?")
|
||||
(while (looking-at "[ \t]*#\\+ORGTBL[: \t][ \t]*SEND +\\([a-zA-Z0-9_]+\\) +\\([^ \t\r\n]+\\)\\( +.*\\)?")
|
||||
(let ((name (org-no-properties (match-string 1)))
|
||||
(transform (intern (match-string 2)))
|
||||
(params (if (match-end 3)
|
||||
|
@ -4106,17 +4214,20 @@ list of the fields in the rectangle ."
|
|||
org-table-last-column-widths org-table-last-alignment
|
||||
org-table-last-column-widths tbeg
|
||||
buffer loc)
|
||||
(setq form (org-table-convert-refs-to-rc form))
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(widen)
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(if (re-search-forward
|
||||
(concat "^#\\+TBLNAME:[ \t]*" (regexp-quote name-or-id) "[ \t]*$")
|
||||
(concat "^#[ \t]*\\+TBLNAME:[ \t]*" (regexp-quote name-or-id) "[ \t]*$")
|
||||
nil t)
|
||||
(setq buffer (current-buffer) loc (match-beginning 0))
|
||||
(setq id-loc (org-id-find name-or-id 'marker)
|
||||
buffer (marker-buffer id-loc)
|
||||
(setq id-loc (org-id-find name-or-id 'marker))
|
||||
(unless (and id-loc (markerp id-loc))
|
||||
(error "Can't find remote table \"%s\"" name-or-id))
|
||||
(setq buffer (marker-buffer id-loc)
|
||||
loc (marker-position id-loc))
|
||||
(move-marker id-loc nil)))
|
||||
(switch-to-buffer buffer)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
@ -29,6 +29,9 @@
|
|||
|
||||
(require 'org)
|
||||
|
||||
(declare-function org-show-notification "org-clock" (parameters))
|
||||
(declare-function org-agenda-error "org-agenda" ())
|
||||
|
||||
(defvar org-timer-start-time nil
|
||||
"t=0 for the running timer.")
|
||||
|
||||
|
@ -253,6 +256,74 @@ VALUE can be `on', `off', or `pause'."
|
|||
(concat " <" (substring (org-timer-value-string) 0 -1) ">"))
|
||||
(force-mode-line-update)))
|
||||
|
||||
(defvar org-timer-timer1 nil)
|
||||
(defvar org-timer-timer2 nil)
|
||||
(defvar org-timer-timer3 nil)
|
||||
(defvar org-timer-last-timer nil)
|
||||
|
||||
(defun org-timer-cancel-timers ()
|
||||
"Reset all timers."
|
||||
(interactive)
|
||||
(mapc (lambda(timer)
|
||||
(when (eval timer)
|
||||
(cancel-timer timer)
|
||||
(setq timer nil)))
|
||||
'(org-timer-timer1
|
||||
org-timer-timer2
|
||||
org-timer-timer3))
|
||||
(message "All timers reset"))
|
||||
|
||||
(defun org-timer-show-remaining-time ()
|
||||
"Display the remaining time before the timer ends."
|
||||
(interactive)
|
||||
(require 'time)
|
||||
(if (and (not org-timer-timer1)
|
||||
(not org-timer-timer2)
|
||||
(not org-timer-timer3))
|
||||
(message "No timer set")
|
||||
(let* ((rtime (decode-time
|
||||
(time-subtract (timer--time org-timer-last-timer)
|
||||
(current-time))))
|
||||
(rsecs (nth 0 rtime))
|
||||
(rmins (nth 1 rtime)))
|
||||
(message "%d minutes %d secondes left before next time out"
|
||||
rmins rsecs))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-timer-set-timer (minutes)
|
||||
"Set a timer."
|
||||
(interactive "sTime out in (min)? ")
|
||||
(if (not (string-match "[0-9]+" minutes))
|
||||
(org-timer-show-remaining-time)
|
||||
(let* ((mins (string-to-number (match-string 0 minutes)))
|
||||
(secs (* mins 60))
|
||||
(hl (cond
|
||||
((string-match "Org Agenda" (buffer-name))
|
||||
(let* ((marker (or (get-text-property (point) 'org-marker)
|
||||
(org-agenda-error)))
|
||||
(hdmarker (or (get-text-property (point) 'org-hd-marker)
|
||||
marker))
|
||||
(pos (marker-position marker)))
|
||||
(with-current-buffer (marker-buffer marker)
|
||||
(widen)
|
||||
(goto-char pos)
|
||||
(org-show-entry)
|
||||
(org-get-heading))))
|
||||
((eq major-mode 'org-mode)
|
||||
(org-get-heading))
|
||||
(t (error "Not in an Org buffer"))))
|
||||
timer-set)
|
||||
(mapcar (lambda(timer)
|
||||
(if (not (or (eval timer) timer-set))
|
||||
(setq timer-set t
|
||||
timer
|
||||
(run-with-timer secs nil 'org-show-notification
|
||||
(format "%s: time out" hl))
|
||||
org-timer-last-timer timer)))
|
||||
'(org-timer-timer1
|
||||
org-timer-timer2
|
||||
org-timer-timer3)))))
|
||||
|
||||
(provide 'org-timer)
|
||||
|
||||
;; arch-tag: 97538f8c-3871-4509-8f23-1e7b3ff3d107
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
@ -71,8 +71,9 @@
|
|||
:message-id message-id)
|
||||
(setq message-id (org-remove-angle-brackets message-id))
|
||||
(setq folder (abbreviate-file-name folder))
|
||||
(if (string-match (concat "^" (regexp-quote vm-folder-directory))
|
||||
folder)
|
||||
(if (and vm-folder-directory
|
||||
(string-match (concat "^" (regexp-quote vm-folder-directory))
|
||||
folder))
|
||||
(setq folder (replace-match "" t t folder)))
|
||||
(setq desc (org-email-link-description))
|
||||
(setq link (org-make-link "vm:" folder "#" message-id))
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
;; Author: Andy Stewart <lazycat dot manatee at gmail dot com>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
@ -93,7 +93,7 @@ so that it can be yanked into an Org-mode buffer with links working correctly."
|
|||
(setq return-content
|
||||
(concat return-content
|
||||
(buffer-substring (point) transform-end))))
|
||||
(kill-new return-content)
|
||||
(org-kill-new return-content)
|
||||
(message "Transforming links...done, use C-y to insert text into Org-mode file")
|
||||
(message "Copy with link transformation complete."))))
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.21b
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
|
124
lisp/org/org-xoxo.el
Normal file
124
lisp/org/org-xoxo.el
Normal file
|
@ -0,0 +1,124 @@
|
|||
;;; org-xoxo.el --- XOXO export for Org-mode
|
||||
|
||||
;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
|
||||
;; Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.29c
|
||||
;;
|
||||
;; 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:
|
||||
|
||||
(require 'org-exp)
|
||||
|
||||
;;; XOXO export
|
||||
|
||||
(defun org-export-as-xoxo-insert-into (buffer &rest output)
|
||||
(with-current-buffer buffer
|
||||
(apply 'insert output)))
|
||||
(put 'org-export-as-xoxo-insert-into 'lisp-indent-function 1)
|
||||
|
||||
;;;###autoload
|
||||
(defun org-export-as-xoxo (&optional buffer)
|
||||
"Export the org buffer as XOXO.
|
||||
The XOXO buffer is named *xoxo-<source buffer name>*"
|
||||
(interactive (list (current-buffer)))
|
||||
;; A quickie abstraction
|
||||
|
||||
;; Output everything as XOXO
|
||||
(with-current-buffer (get-buffer buffer)
|
||||
(let* ((pos (point))
|
||||
(opt-plist (org-combine-plists (org-default-export-plist)
|
||||
(org-infile-export-plist)))
|
||||
(filename (concat (file-name-as-directory
|
||||
(org-export-directory :xoxo opt-plist))
|
||||
(file-name-sans-extension
|
||||
(file-name-nondirectory buffer-file-name))
|
||||
".html"))
|
||||
(out (find-file-noselect filename))
|
||||
(last-level 1)
|
||||
(hanging-li nil))
|
||||
(goto-char (point-min)) ;; CD: beginning-of-buffer is not allowed.
|
||||
;; Check the output buffer is empty.
|
||||
(with-current-buffer out (erase-buffer))
|
||||
;; Kick off the output
|
||||
(org-export-as-xoxo-insert-into out "<ol class='xoxo'>\n")
|
||||
(while (re-search-forward "^\\(\\*+\\)[ \t]+\\(.+\\)" (point-max) 't)
|
||||
(let* ((hd (match-string-no-properties 1))
|
||||
(level (length hd))
|
||||
(text (concat
|
||||
(match-string-no-properties 2)
|
||||
(save-excursion
|
||||
(goto-char (match-end 0))
|
||||
(let ((str ""))
|
||||
(catch 'loop
|
||||
(while 't
|
||||
(forward-line)
|
||||
(if (looking-at "^[ \t]\\(.*\\)")
|
||||
(setq str (concat str (match-string-no-properties 1)))
|
||||
(throw 'loop str)))))))))
|
||||
|
||||
;; Handle level rendering
|
||||
(cond
|
||||
((> level last-level)
|
||||
(org-export-as-xoxo-insert-into out "\n<ol>\n"))
|
||||
|
||||
((< level last-level)
|
||||
(dotimes (- (- last-level level) 1)
|
||||
(if hanging-li
|
||||
(org-export-as-xoxo-insert-into out "</li>\n"))
|
||||
(org-export-as-xoxo-insert-into out "</ol>\n"))
|
||||
(when hanging-li
|
||||
(org-export-as-xoxo-insert-into out "</li>\n")
|
||||
(setq hanging-li nil)))
|
||||
|
||||
((equal level last-level)
|
||||
(if hanging-li
|
||||
(org-export-as-xoxo-insert-into out "</li>\n")))
|
||||
)
|
||||
|
||||
(setq last-level level)
|
||||
|
||||
;; And output the new li
|
||||
(setq hanging-li 't)
|
||||
(if (equal ?+ (elt text 0))
|
||||
(org-export-as-xoxo-insert-into out "<li class='" (substring text 1) "'>")
|
||||
(org-export-as-xoxo-insert-into out "<li>" text))))
|
||||
|
||||
;; Finally finish off the ol
|
||||
(dotimes (- last-level 1)
|
||||
(if hanging-li
|
||||
(org-export-as-xoxo-insert-into out "</li>\n"))
|
||||
(org-export-as-xoxo-insert-into out "</ol>\n"))
|
||||
|
||||
(goto-char pos)
|
||||
;; Finish the buffer off and clean it up.
|
||||
(switch-to-buffer-other-window out)
|
||||
(indent-region (point-min) (point-max) nil)
|
||||
(save-buffer)
|
||||
(goto-char (point-min))
|
||||
)))
|
||||
|
||||
(provide 'org-xoxo)
|
||||
|
||||
;; arch-tag: 16e6a31f-f4f5-46f1-af18-48dc89faa702
|
||||
|
||||
|
||||
;;; org-xoxo.el ends here
|
4010
lisp/org/org.el
4010
lisp/org/org.el
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue