From 8bfe682a6f3ffbab914af9037379cb1515720c28 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Fri, 13 Nov 2009 08:39:29 +0000 Subject: [PATCH] 2009-11-13 Carsten Dominik * org.el (org-clone-subtree-with-time-shift): Make it work at the end of the buffer. * org-mobile.el (org-mobile-write-checksums): Specify coding system. (org-mobile-timestamp-buffer): Keep local variable/mode line at beginning of buffer. * org-latex.el (org-latex-entities-regexp): Fix typo in regexp. * org.el (org-block-todo-from-children-or-siblings-or-parent) (org-block-todo-from-checkboxes): Do not block changes to a nil TODO state. 2009-11-13 James TD Smith * org-habit.el (org-habit-parse-todo): Indicate which habit is wrongly set up in the error messages. * org-colview.el (org-columns-display-here): Don't try to calculate values if the underlying property is not set. (org-columns-string-to-number): Convert age strings back into fractional days. (org-agenda-colview-summarize): Handle extended summary types properly. * org-colview-xemacs.el (org-columns-display-here): Don't try to calculate values if the underlying property is not set. (org-columns-string-to-number): Convert age strings back into fractional days. (org-agenda-colview-summarize): Handle extended summary types properly. 2009-11-13 Carsten Dominik * org-exp.el (org-export-format-drawer-function): New variable. (org-export-format-drawer): New function. (org-export-preprocess-string): Pass the backend as a parameter to `org-export-remove-or-extract-drawers'. (org-export-remove-or-extract-drawers): New parameter BACKEND. * org-protocol.el (org-protocol-char-to-string): New defsubst. 2009-11-13 Carsten Dominik * org-agenda.el (org-agenda-diary-entry-in-org-file): Add error message when no block is selected. * org-latex.el (org-export-latex-links): Check for protectedness in the last matched character, not after the match. * org-datetree.el (org-datetree-find-date-create): Respect restriction when KEEP-RESTRICTION is set. (org-datetree-file-entry-under): New function. (org-datetree-cleanup): New command. 2009-11-13 Dan Davison * org-src.el (org-edit-src-code): New optional argument context allows calling functions to avoid altering the saved window configuration. (org-edit-src-exit): Do not restore window configuration when this function is used in the context of saving the edit buffer. 2009-11-13 Carsten Dominik * org-clock.el (org-clock-out, org-clock-cancel): Revert to instances to switching to with-current-buffer, because these seem to cause problems - no idea why. * org-agenda.el (org-agenda-add-entry-to-org-agenda-diary-file): Require diary-lib for (diary-date-display-form). 2009-11-13 Carsten Dominik * org.el (org-log-reschedule, org-log-redeadline): New options. (org-log-note-headings): Add templates for rescheduling and deadline changing. (org-startup-options): Add in-buffer settings for logging changing schedule and deadline time stamps. (org-deadline, org-schedule): Check for existing date and arrange for logging if the user requests it. (org-add-log-note): Prepare proper note buffers for rescheduling and deadline changes. 2009-11-13 Carsten Dominik * org-agenda.el (org-agenda-diary-entry-in-org-file) (org-agenda-add-entry-to-org-agenda-diary-file) (org-agenda-insert-diary-make-new-entry): New functions. (org-agenda-diary-entry): Call `org-agenda-diary-entry-in-org-file' when appropriate. * org.el (org-calendar-insert-diary-entry-key): New option. (org-agenda-diary-file): New option. ("calendar"): Install our insertion function in the calendar. * org-remember.el (org-datetree): Require. (org-remember-templates): Add new positioning option. (org-remember-reference-date): New variable. (org-remember-apply-template): Store the reference date in a local variable. (org-remember-handler): Implement date tree positioning of entries. * org-datetree.el: New file. * org-latex.el (org-export-latex-preprocess): Protect targets in verbatim emphasis. * org-html.el (org-export-as-html): Protect targets in verbatim emphasis. * org-docbook.el (org-export-as-docbook): Protect targets in verbatim emphasis. 2009-11-13 Carsten Dominik * org-clock.el (org-show-notification): Handle messages that contain a percent character. * org-remember.el (org-remember-apply-template): Turn of partial completion. * org-mobile.el (org-mobile-before-process-capture-hook): New hook. (org-mobile-pull): Run `org-mobile-before-process-capture-hook'. * org.el (org-indent-mode): Define variable already in org.el. (org-unfontify-region): Remove line-prefix and wrap-prefix properties only if org-indent-mode is active. 2009-11-13 Carsten Dominik * org-icalendar.el (org-print-icalendar-entries): Save match data around call to verify function. (org-print-icalendar-entries): Add a call to the verification function. * org.el (org-speedbar-set-agenda-restriction): Remove unnecessary save-restrivtion' form. 2009-11-13 Dan Davison * org-exp.el (org-export-format-source-code-or-example): restrict scope of preserve-indentp to the let binding. (org-src): require org-src, since org-src-preserve-indentation is used. 2009-11-13 Carsten Dominik * org-timer.el (org-timer-set-timer): Set variables org-timer-timer[123] correctly. * org-mobile.el (org-mobile-files-alist): Make it work when `agenda-archives' is included in `org-agenda-text-search-extra-files'. (org-mobile-push): Restore agenda after mobile push. 2009-11-13 John Wiegley * org-clock.el (org-resolve-clocks-if-idle): Another fix to the way the amount of idle time is presented in the minibuffer. 2009-11-13 Carsten Dominik * org-icalendar.el (org-print-icalendar-entries): Use org-icalendar-verify-function only if non-nil. * org.el (org-refile): Refile to clock only if the prefix arg is 2. (org-sparse-tree): Fix docstring to be in line with prompt. (org-update-parent-todo-statistics): Call `org-after-todo-statistics-hook' on each level. 2009-11-13 Carsten Dominik * org-remember.el (org-remember-apply-template): Make sure the buffer exists. 2009-11-13 Carsten Dominik * org.el (org-tab-ind-state): New variable. (org-cycle-level): New function. (org-cycle-level-after-item/entry-creation): New option. (org-flag-subtree): New function. (org-hide-archived-subtrees): Call `org-flag-subtree'. (org-set-effort): Indexed access. * org-list.el (org-cycle-item-indentation): New function. * org.el (org-refile): Make prefix argument 2 refile to current clock. (org-priority): Interpret action `remove' as call to remove the priority cookie. * org-remember.el (org-remember-apply-template): Don't depend on buffer name being like file name. 2009-11-13 Carsten Dominik * org-clock.el (org-clock-play-sound): Expand file in org-clock-sound, to allow ~ for home. * org-remember.el (org-remember-handler): Set text-before-node-creation even if this already looks like a node, because the string might be needed on non-org-mode target files. * org-agenda.el (org-agenda-open-link): Make this work in agenda clocktables. (org-agenda-switch-to): Follow a link at point if org-return-follows-link' is set and there is nothing else to do in this line. 2009-11-13 James TD Smith * org-colview-xemacs.el: Add in changes from org-colview.el 2009-11-13 Dan Davison * org-exp-blocks.el: Modify split separator regexp to avoid empty strings. 2009-11-13 James TD Smith * org-colview.el (org-columns-new): Make this work with the new operators. (org-columns-store-format): Make this work with the new operators. 2009-11-13 Carsten Dominik * org-src.el (org-src-preserve-indentation): Document that this variable is also used during export. * org-exp.el (org-export-format-source-code-or-example): Preserve indentation if a block has a -i option, or if `org-src-preserve-indentation' is set. * org-exp-blocks.el (org-export-blocks-preprocess): Preserve indentation if a block has a -i option, or if `org-src-preserve-indentation' is set. 2009-11-13 Carsten Dominik * org.el (org-mode-map): Define the new archiving keys. (org-speed-commands-default): Define an archiving key in the speed command map. (org-org-menu): Improve the menu structure concerning archiving. * org-archive.el (org-archive-subtree-default-with-confirmation): New command. * org-agenda.el (org-agenda-mode-map): Define the new archiving keys. (org-agenda-menu): Add the new archiving commands to the menu. (org-agenda-archive-default) (org-agenda-archive-default-with-confirmation): New commands. (org-agenda-archive, org-agenda-archive-to-archive-sibling): Just call `org-agenda-archive-with'. (org-agenda-archive-with): New function. * org-table.el (org-table-convert-region): Inert spaces around "|" to avoid line beginnings like "|-1" which will be mistaken as hlines. 2009-11-13 Carsten Dominik * org.el (org-offer-links-in-entry): Return nil if there are no links, t if a link has been selected. (org-open-at-point): Open attachment directory when called in the headline and there are no links in the entry body. (org-speed-commands-default): Add "o" for open-at-point as a speed command. * org-attach.el (org-attach-reveal): Optional prefix arg IF-EXISTS, which avoids creating the attachment directory if it does not yet exist. * org-agenda.el (org-agenda, org-run-agenda-series): Evaluate MATCH. 2009-11-13 Carsten Dominik * org.el ("abbrev"): Work with abbrev tables only after they have been loaded. * org-list.el (org-list-send-list): Fix bug related to match data. * org-latex.el (org-export-latex-fontify): Apply verbatim emphasis. (org-export-latex-make-header): Insert \obeylines if line breaks should be preserved. * org-exp.el (org-export-protect-verbatim): Add an `org-verbatim-emph' property to such text. 2009-11-13 Carsten Dominik * org-icalendar.el (org-icalendar-use-plain-timestamp): New option. (org-print-icalendar-entries): Skip entries where the timestamp is not a deadline and not scheduled, if the user requests that. * org-latex.el (org-export-latex-quotation-marks): Allow a bracket before an opening quote. * org-archive.el (org-archive-subtree): Keep archive after archiving something. * org-id.el (org-id-update-id-locations): Add archive files if that is required by `org-id-extra-files'. 2009-11-13 Carsten Dominik * org-src.el (org-src-window-setup): New option. (org-src-switch-to-buffer): New function. (org-edit-src-exit): Add optional argument CONTEXT and use it to restore window configuration. (org-edit-src-code, org-edit-src-continue, org-edit-src-exit): Call `org-src-switch-to-buffer'. * org.el (org-default-properties): Add STYLE property. (org-files-list): Use the function call to get the files. (org-additional-option-like-keywords): Add SETUPFILE to completion list. 2009-11-13 Carsten Dominik * org-table.el (org-table-convert-region): Correctly interpret quoting in csv import. * org.el (org-icompleting-read): Make iswitchb completion work with lists and tables. * org-agenda.el (org-agenda-add-entry-text): Never add entry text while pushing the mobile agenda. 2009-11-13 John Wiegley * org-clock.el (org-clock-auto-clock-resolution): Now takes three values: nil, t and `when-no-clock-is-running'. (org-clock-in): Use `org-clock-auto-clock-resolution' to determine whether or not to resolve Org buffers on clock in. 2009-11-13 James TD Smith * org-colview.el (org-format-time-period): Function to format times in fractional days for display. (org-columns-display-here): Add support for showing a calculated value in place of the property. (org-columns): Set `org-columns-time' to the current time so time difference calculations will work. (org-columns-time): Use to store the current time when column view is displayed, so all time differences will use the same reference point. (org-columns-compile-map): There is now an extra position in each entry specifying the function to use to calculate the displayed value for the non-calculated properties in the column, (org-columns-compute-all): Set `org-columns-time' to the current time so time difference calculations will work. (org-columns-compute): Handle column operators where the values used are calculated from the underlying property. (org-columns-number-to-string): Handle the 'age' column format (org-columns-string-to-number): Correct the function name (was org-column...). Add support for the 'age' column format. (org-columns-compile-format): Support the additional parameter in org-columns-compile-map. 2009-11-13 Bastien Guerry * org.el (org-mode-hook): Turn `org-mode-hook' into a customizable variable. 2009-11-13 Carsten Dominik * org-clock.el (org-clock-has-been-used): New variable. (org-clock-in): Set `org-clock-has-been-used'. (org-clock-save): Save only if clock data has been used or created during this session. 2009-11-13 Carsten Dominik * org-clock.el (org-clock-persist): New value, to store only the clock history. (org-clock-save): Don't save the clock if only the history should be stored. (org-clock-load): Turn off John Wiegley's auto resolving mechanism when restoring a saved clock. 2009-11-13 John Wiegley * org-clock.el (org-clock-display, org-clock-put-overlay): Use `org-time-clock-use-fractional'. * org.el (org-time-clocksum-use-fractional) (org-time-clocksum-fractional-format): Two new customizable variables which allow the user to select fractional times (1.25 instead of 1:25) in the `org-clock-display' report. 2009-11-13 Carsten Dominik * org-ascii.el (org-export-ascii-table-keep-all-vertical-lines): New option. * org.el (org-tag-alist): Fix customization type. 2009-11-13 Carsten Dominik * org-mobile.el (org-mobile-update-checksum-for-capture-file): Make sure the regexp search can fail without throwing an error. (org-mobile-apply): Save the inbox buffer after removing successfully applied changes. 2009-11-13 John Wiegley * org-clock.el (org-resolve-clocks-if-idle): Fix to the way idle time is reported after the user comes back (but before they resolve time). * org.el (org-get-repeat): Change so that this function can be called with either `org-scheduled-string' or `org-deadline-string'. * org-clock.el (org-clock-auto-clock-resolution): Renamed `org-clock-disable-clock-resolution', since negatives don't sound good in customization variables. (org-clock-in): Don't use the auto-resolution logic if the user is clocking into a different task while an active clock is running. This then allows the default behavior of clocking out of the open task and then into the new task. * org.el (org-modules): Made this variable more consistent, since it was referring to Org, OrgMode and Org-mode, whereas the docs for the variable always refer to Org-mode. 2009-11-13 James TD Smith * org.el (org-repeat-re): The changed org-repeat-re no longer matched simple +2d type repeaters. Fix it so it does. 2009-11-13 Carsten Dominik * org-latex.el (org-export-latex-preprocess): Protect the vspace macro in the VERSE environment. 2009-11-13 John Wiegley * org-habit.el (org-habit-get-priority): A new function that determines the relative priority of a habit, based on how long past its scheduled date it is, and how near the deadline is. * org-agenda.el (org-agenda-get-scheduled): Set habit priority using `org-habit-get-priority'. * org-habit.el (org-habit-build-graph): Start displaying colors from the first scheduled date, if that date is earlier than the first completion date. * org-habit.el: Changed all "color" variables to faces, and made them appropriate for light and dark backgrounds. * org-habit.el (org-habit-duration-to-days): Made this function more general. (org-habit-parse-todo): Parse the new ".+N/N" style repeater. * org-agenda.el (org-agenda-get-deadlines): Removed all mention of habits, since they don't use DEADLINE anymore. * org.el (org-repeat-re, org-display-custom-time) (org-timestamp-change): Extended to support the new ".+N/N" syntax, used for habits. * org-clock.el (org-clock-resolve-clock): Fixed an incorrect variable reference. * org-agenda.el (org-agenda-set-mode-name): Show Habit in the modeline when habits are being displayed (if that module is being loaded). 2009-11-13 James TD Smith * org-clock.el (org-x11-idle-seconds): Add a method to get the X11 idle time using the xscreensaver extension. (org-user-idle-seconds): Use X11 idle time if available. 2009-11-13 Carsten Dominik * org-agenda.el (org-agenda-next-line): New command. (org-agenda-previous-line): New commands. (org-agenda-show-and-scroll-up, org-agenda-show-scroll-down): New commands. (org-agenda-follow-mode): Do the follow immediately if the mode is turned on here. (previous-line, next-line): Replace keys with the corresponding org functions. (org-agenda-mode-map): Bind backspace and delete to the scrolling command. * org.el (org-icompleting-read): Turn off partial completion mode for the duration of this completion round. * org-latex.el (org-export-latex-fontify-headline): Protect TeX macros in author lines and similar stuff. * org.el (org-file-tags): Fix docstring. (org-get-buffer-tags): Add the #+FILETAGS tags. ("ecb"): Maks ecb show context after jumping into an Org file. 2009-11-13 John Wiegley * org-agenda.el (org-finalize-agenda): Draw habit consistency graphs after everything else in the buffer has been setup. 2009-11-13 Carsten Dominik * org-mobile.el (org-mobile-apply): Count success and failure. * org.el (org-indent-line-function): Fix regexp replace problem. 2009-11-13 John Wiegley * org-clock.el (org-clock-disable-clock-resolution): New customization variable that disable automatic clock resolution on clock in. (org-clock-in): If `org-clock-disable-clock-resolution' is set, do not automatically resolve anything. This is does not affect idle-time resolution, however, if `org-clock-idle-time' is set. 2009-11-13 John Wiegley * org-habit.el: New file, which implements code to build a "habit consistency graph". * org-agenda.el (org-agenda-get-deadlines) (org-agenda-get-scheduled): Display consistency graphs when outputting habits into the agenda. The graphs are always relative to the current time. (org-format-agenda-item): Added new parameter `habitp', which indicates whether we are formatting a habit or not. Do not display "extra" leading information if habitp is true. * org.el (org-repeat-re): Improved regexp to include .+ and ++ leaders for repeat strings. (org-get-repeat): Now takes a string parameter `tagline', so the caller can obtain the SCHEDULED repeat, or the DEADLINE repeat. 2009-11-13 John Wiegley * org-agenda.el (org-agenda-auto-exclude-function): New customization variable for allowing the user to create an "auto exclusion" filter for doing context-aware auto tag filtering. (org-agenda-filter-by-tag): Changes to support the use of `org-agenda-auto-exclude-function'. See the new manual addition,. 2009-11-13 John Wiegley * org.el (org-files-list): Don't attempt to return a file name for Org buffers which have no associated file. * org-agenda.el (org-agenda-do-action): Fixed a typo. 2009-11-13 Carsten Dominik * org-mobile.el (org-mobile-locate-entry): Interpret files relative to org-directory. (org-mobile-inbox-for-pull): Document the best location for this file. (org-mobile-check-setup): Verify `org-directory'. (org-mobile-create-index-file): Sort the files to be listed in index.org. 2009-11-13 James TD Smith * org.el (org-fast-tag-selection): Add a way to display a description for a tag group. This is done by adding a string to either the startgroup or endgroup cell. 2009-11-13 Carsten Dominik * org-clock.el (org-clock-resolve, org-resolve-clocks) (org-emacs-idle-seconds): Use `org-float-time' instead of `time-to-seconds' 2009-11-13 Carsten Dominik * org-agenda.el (org-agenda-sorting-strategy): Fix customization type. * org.el (org-pre-cycle-hook): Document that `empty' can also be the value of ARG when doing local cycling. 2009-11-13 John Wiegley * org-clock.el (org-clock-resolve-clock): If keeping or subtracting time results in a clock out at a time in the past, and if the resolution occurred due to idleness or invoking `M-x org-resolve-clocks', remember that past moment in time. On the next clock in, the user will be prompted to see if they want to back-date their new clock to then. (org-clock-resolve): Do not jump the user to the location of a dangling clock if the resolution is occuring due to an idle timeout. In that case there is typically only one dangling clock, the active one, and there is no value gained by shuffling their windows around to show it to them. Being prompted to resolve an idle clock should be as inobtrusive as possible. (org-resolve-clocks-if-idle): New function that resolves only the currently active clock if the user has exceeded the time returned by `org-user-idle-seconds', based on the value of `org-clock-idle-time'. (org-clock-in): If, after resolving clocks, (org-clock-out): Cancel the `org-clock-idle-timer' on clock out. * org-clock.el (org-clock-resolve-clock): New function that resolves a clock to a specific time, closing or resuming as need be, and possibly even starting a new clock. (org-clock-resolve): New function used by `org-resolve-clocks' that sets up for the call to `org-clock-resolve-clock'. It determines the time to resolve to based on a single-character selection from the user to either keep time, subtract away time or cancel the clock. (org-resolve-clocks): New user command which resolves dangling clocks -- that is, open but not active -- anywhere in the file list returned by `org-files-list'. (org-clock-in): Automatically resolve dangling clocks whenever a user clocks in. (org-clock-cancel): If the user cancels the solely clock in a LOGBOOK, remove the empty drawer. * org-clock.el (org-clock-idle-time): New user customizable option for detecting whether the user has left a clock idle. Note: it is only used in this commit to test whether it's worthwhile to check OS X to get the Mac user's current idle time. If the Emacs idle time is less than the value, the user hasn't been away long enough to be worth checking (a more expensive test than just getting Emacs idle time). (org-user-idle-seconds, org-mac-idle-seconds) (org-emacs-idle-seconds): This three functions, in conjunction with the user customization variable `org-clock-idle-time', return the number of seconds (as a floating point) that the user has been away from their Emacs (or, if running on OS X, their computer). * org-clock.el (org-find-open-clocks): New function that returns a list of all open clocks in the given FILE. Note that each clock it returns is a cons cell of the format (MARKER . START-TIME). This "clock" value is used by several of the new clock module utility functions. (org-is-active-clock): New inline function which tests whether the given clock value is the same as the currently active clock. Returns non-nil if this is the case. (org-with-clock-position): New macro that evaluates FORMS with point in the buffer and at the position of the given clock. Changes to the current clock are global. (org-with-clock): New macro that evaluates FORMS with point in the buffer and at the position of the given clock. However, changes to the current clock are local and have no effect on the user's active clock. This allows, for example, far any clock to be cancelled without cancelling the active clock. (org-clock-clock-in): New inline function that switches the active clock to the given clock. If either the argument RESUME, or the global `org-clock-in-resume', are non-nil, it will resume a clock that was previously left open. (org-clock-clock-out): New inline function that clocks out the given clock value without affecting the currently active clock. (org-clock-clock-cancel): New inline function that cancels the given clock value without affecting the currently active clock. * org-clock.el (org-clock-in): Before creating `org-clock-mode-line-timer', check to make sure an older timer is not currently running. (org-clock-out): Accept new third parameter `at-time', which permits a clock to be clocked out at a specific time. Note that no attempt is made to verify that the clock out time is later than the clock in time. * org.el (org-files-list): New utility function for returning a list of all open org-mode buffers, plus all files used to build the agenda buffer. Note that not all the files will necessarily be visited by a buffer at time of call. (org-entry-beginning-position): Like the function `line-beginning-position', this inline function returns the beginning position of the current heading/entry. (org-entry-end-position): Like the function `line-end-position', this inline function returns the end position of the current heading/entry. 2009-11-13 Carsten Dominik * org-agenda.el (org-agenda-list): Mark the all-todo items line as a header line. 2009-11-13 Carsten Dominik * org-exp.el (org-inlinetask-remove-END-maybe): Declare function. 2009-11-13 Carsten Dominik * org-agenda.el (org-agenda-filter-make-matcher): Allow to filter entries that have no tags. (org-agenda-search-view): New customize group. (org-agenda-search-view-search-words-only): New option. (org-search-view): Implement substring search. 2009-11-13 Carsten Dominik * org.el (org-outline-level): Add doc string. 2009-11-13 Carsten Dominik * org-inlinetask.el (org-inlinetask-export): Re-introduce variable. (org-inlinetask-export-handler): Only export inline task if the user option calls for it. 2009-11-13 Carsten Dominik * org-exp.el (org-export-handle-export-tags): Remove inlinetask END if present. 2009-11-13 Carsten Dominik * org-latex.el (org-export-latex-tables): Don't format in protected regions. 2009-11-13 Carsten Dominik * org-src.el (org-edit-src-code) (org-edit-src-find-region-and-lang, org-edit-src-exit): Handle macro editing. * org-agenda.el (org-prefix-category-max-length): New variable. (org-format-agenda-item): Use `org-prefix-category-max-length'. (org-compile-prefix-format): Set `org-prefix-category-max-length'. 2009-11-13 Carsten Dominik * org-mobile.el (org-mobile-create-index-file): Improve the listing of tags and todo keywords. * org-latex.el (org-export-latex-format-image): New function. (org-export-latex-links): Use `org-export-latex-format-image'. 2009-11-13 Carsten Dominik * org-inlinetask.el (org-inlinetask-get-current-indentation) (org-inlinetask-remove-terminator): New functions. (org-inlinetask-export-handler): Terminate the description list. * org-exp.el (org-export-select-backend-specific-text): Remove the region markers. * org-inlinetask.el (org-inlinetask-export-handler): fix bug for tasks without content. * org-clock.el: Make sure the clock-in target position does not move to a different node by widening the buffer. * org-html.el (org-export-html-format-image): Wrap image into figure div only when there is a caption. * org-archive.el (org-archive-mark-done): Change default value to nil. 2009-11-13 Carsten Dominik * org.el (org-context): Call `bobp', not `eobp'. * org-clock.el (org-clock-cancel): Remove quotes from marker variables. * org.el (org-read-date-prefer-future): New allowed value `time'. (org-read-date-analyze): Shift day to tomorrow depending on time entered and value of `org-read-date-prefer-future'. --- doc/misc/ChangeLog | 50 ++ lisp/org/ChangeLog | 773 ++++++++++++++++++++++++ lisp/org/org-agenda.el | 821 ++++++++++++++++--------- lisp/org/org-archive.el | 24 +- lisp/org/org-ascii.el | 39 +- lisp/org/org-attach.el | 12 +- lisp/org/org-bbdb.el | 4 +- lisp/org/org-bibtex.el | 8 +- lisp/org/org-clock.el | 459 ++++++++++++-- lisp/org/org-colview.el | 294 ++++++--- lisp/org/org-compat.el | 2 +- lisp/org/org-crypt.el | 18 +- lisp/org/org-datetree.el | 199 ++++++ lisp/org/org-docbook.el | 12 +- lisp/org/org-exp-blocks.el | 180 +----- lisp/org/org-exp.el | 125 ++-- lisp/org/org-faces.el | 2 +- lisp/org/org-feed.el | 8 +- lisp/org/org-footnote.el | 11 +- lisp/org/org-freemind.el | 1137 +++++++++++++++++++++++++++++++++++ lisp/org/org-gnus.el | 2 +- lisp/org/org-habit.el | 343 +++++++++++ lisp/org/org-html.el | 44 +- lisp/org/org-icalendar.el | 36 +- lisp/org/org-id.el | 59 +- lisp/org/org-indent.el | 4 +- lisp/org/org-info.el | 2 +- lisp/org/org-inlinetask.el | 87 ++- lisp/org/org-irc.el | 2 +- lisp/org/org-jsinfo.el | 2 +- lisp/org/org-latex.el | 357 ++++++----- lisp/org/org-list.el | 64 +- lisp/org/org-mac-message.el | 2 +- lisp/org/org-macs.el | 6 +- lisp/org/org-mew.el | 2 +- lisp/org/org-mhe.el | 2 +- lisp/org/org-mobile.el | 714 +++++++++++++++++----- lisp/org/org-mouse.el | 18 +- lisp/org/org-plot.el | 4 +- lisp/org/org-protocol.el | 25 +- lisp/org/org-publish.el | 4 +- lisp/org/org-remember.el | 33 +- lisp/org/org-rmail.el | 2 +- lisp/org/org-src.el | 207 +++++-- lisp/org/org-table.el | 51 +- lisp/org/org-timer.el | 18 +- lisp/org/org-vm.el | 2 +- lisp/org/org-w3m.el | 6 +- lisp/org/org-wl.el | 2 +- lisp/org/org-xoxo.el | 2 +- lisp/org/org.el | 845 +++++++++++++++++++------- 51 files changed, 5732 insertions(+), 1393 deletions(-) create mode 100644 lisp/org/org-datetree.el create mode 100644 lisp/org/org-freemind.el create mode 100644 lisp/org/org-habit.el diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog index 267623af4d..a50cd36d4c 100644 --- a/doc/misc/ChangeLog +++ b/doc/misc/ChangeLog @@ -1,3 +1,53 @@ +2009-11-13 Carsten Dominik + + * org.texi: Removed @Ie, @ie, @Eg, @eg macros. + +2009-11-13 James TD Smith + + * org.texi (Column attributes): Add the new age summary operators. + Also, mention the fact you can only use one summary operator per + property. + +2009-11-13 John Wiegley + + * org.texi (Tracking your habits): Added a new section in the + manual about how to track habits. + (Resolving idle time): Added a section on how idle and + dangling clocks are resolved. + +2009-11-13 Carsten Dominik + + * org.texi (Agenda commands): Document the new `i' command. + (Inserting deadline/schedule): Document logging changes + of scheduling and deadline times stamps. + (In-buffer settings): Document the in-buffer keywords for logging + changes of scheduling and deadline times stamps. + (Structure editing, Plain lists): Document indentation + cycling in empty entries with TAB. + (Archiving): Document the default archiving command. + (Moving subtrees): Document the new keys for archiving. + (Internal archiving): Fix incorrect key. + (Agenda commands): Document the TODO set switching commands. + (Agenda commands): Document the new archiving keys. + (Clocking work time): Better description on how to save + and restore a clock. + (Resolving idle time): Mention the x11idle program to get true + idleness also under X11. + (Resolving idle time): Use @kbd instead of @key for normal + letters, because this is how he rest of the manual does this. + (Pushing to MobileOrg): Mention that `org-directory' + should be set. + (Agenda commands): Document that SPC is a filter for + any tag. + (Search view): Renamed from "Keyword search". + (Capure): New chapter. + (Markup): New chapter. + (Links in HTML export, Images in HTML export): Extend + the section titles. + (Images in HTML export): Document the align option. + (Text areas in HTML export): Extend the section title. + (Images in LaTeX export): Explain image placement in LaTeX. + 2009-11-10 Glenn Morris * sc.texi (Hints to MUA Authors): MUA should do any decoding. diff --git a/lisp/org/ChangeLog b/lisp/org/ChangeLog index ef82bd2076..6a4e5d7235 100644 --- a/lisp/org/ChangeLog +++ b/lisp/org/ChangeLog @@ -1,3 +1,776 @@ +2009-11-13 Carsten Dominik + + * org.el (org-clone-subtree-with-time-shift): Make it work at the + end of the buffer. + + * org-mobile.el (org-mobile-write-checksums): Specify coding + system. + (org-mobile-timestamp-buffer): Keep local variable/mode line at + beginning of buffer. + + * org-latex.el (org-latex-entities-regexp): Fix typo in regexp. + + * org.el (org-block-todo-from-children-or-siblings-or-parent) + (org-block-todo-from-checkboxes): Do not block changes to a nil + TODO state. + +2009-11-13 James TD Smith + + * org-habit.el (org-habit-parse-todo): Indicate which habit is + wrongly set up in the error messages. + + * org-colview.el (org-columns-display-here): Don't try to + calculate values if the underlying property is not set. + (org-columns-string-to-number): Convert age strings back into + fractional days. + (org-agenda-colview-summarize): Handle extended summary types + properly. + + * org-colview-xemacs.el (org-columns-display-here): Don't try to + calculate values if the underlying property is not set. + (org-columns-string-to-number): Convert age strings back into + fractional days. + (org-agenda-colview-summarize): Handle extended summary types + properly. + +2009-11-13 Carsten Dominik + + * org-exp.el (org-export-format-drawer-function): New variable. + (org-export-format-drawer): New function. + (org-export-preprocess-string): Pass the backend as a parameter to + `org-export-remove-or-extract-drawers'. + (org-export-remove-or-extract-drawers): New parameter BACKEND. + + * org-protocol.el (org-protocol-char-to-string): New defsubst. + +2009-11-13 Carsten Dominik + + * org-agenda.el (org-agenda-diary-entry-in-org-file): Add error + message when no block is selected. + + * org-latex.el (org-export-latex-links): Check for protectedness + in the last matched character, not after the match. + + * org-datetree.el (org-datetree-find-date-create): Respect + restriction when KEEP-RESTRICTION is set. + (org-datetree-file-entry-under): New function. + (org-datetree-cleanup): New command. + +2009-11-13 Dan Davison + + * org-src.el (org-edit-src-code): New optional argument context + allows calling functions to avoid altering the saved window + configuration. + (org-edit-src-exit): Do not restore window configuration when this + function is used in the context of saving the edit buffer. + +2009-11-13 Carsten Dominik + + * org-clock.el (org-clock-out, org-clock-cancel): Revert to + instances to switching to with-current-buffer, because these seem + to cause problems - no idea why. + + * org-agenda.el (org-agenda-add-entry-to-org-agenda-diary-file): + Require diary-lib for (diary-date-display-form). + +2009-11-13 Carsten Dominik + + * org.el (org-log-reschedule, org-log-redeadline): New options. + (org-log-note-headings): Add templates for rescheduling and + deadline changing. + (org-startup-options): Add in-buffer settings for logging changing + schedule and deadline time stamps. + (org-deadline, org-schedule): Check for existing date and arrange + for logging if the user requests it. + (org-add-log-note): Prepare proper note buffers for rescheduling + and deadline changes. + +2009-11-13 Carsten Dominik + + * org-agenda.el (org-agenda-diary-entry-in-org-file) + (org-agenda-add-entry-to-org-agenda-diary-file) + (org-agenda-insert-diary-make-new-entry): New functions. + (org-agenda-diary-entry): Call + `org-agenda-diary-entry-in-org-file' when appropriate. + + * org.el (org-calendar-insert-diary-entry-key): New option. + (org-agenda-diary-file): New option. + ("calendar"): Install our insertion function in the calendar. + + * org-remember.el (org-datetree): Require. + (org-remember-templates): Add new positioning option. + (org-remember-reference-date): New variable. + (org-remember-apply-template): Store the reference date in a local + variable. + (org-remember-handler): Implement date tree positioning of entries. + + * org-datetree.el: New file. + + * org-latex.el (org-export-latex-preprocess): Protect targets in + verbatim emphasis. + + * org-html.el (org-export-as-html): Protect targets in verbatim + emphasis. + + * org-docbook.el (org-export-as-docbook): Protect targets in + verbatim emphasis. + +2009-11-13 Carsten Dominik + + * org-clock.el (org-show-notification): Handle messages that + contain a percent character. + + * org-remember.el (org-remember-apply-template): Turn of partial + completion. + + * org-mobile.el (org-mobile-before-process-capture-hook): New hook. + (org-mobile-pull): Run `org-mobile-before-process-capture-hook'. + + * org.el (org-indent-mode): Define variable already in org.el. + (org-unfontify-region): Remove line-prefix and wrap-prefix + properties only if org-indent-mode is active. + +2009-11-13 Carsten Dominik + + * org-icalendar.el (org-print-icalendar-entries): Save match data + around call to verify function. + (org-print-icalendar-entries): Add a call to the verification + function. + + * org.el (org-speedbar-set-agenda-restriction): Remove unnecessary + save-restrivtion' form. + +2009-11-13 Dan Davison + + * org-exp.el (org-export-format-source-code-or-example): restrict + scope of preserve-indentp to the let binding. + (org-src): require org-src, since org-src-preserve-indentation is used. + +2009-11-13 Carsten Dominik + + * org-timer.el (org-timer-set-timer): Set variables + org-timer-timer[123] correctly. + + + * org-mobile.el (org-mobile-files-alist): Make it work when + `agenda-archives' is included in + `org-agenda-text-search-extra-files'. + (org-mobile-push): Restore agenda after mobile push. + +2009-11-13 John Wiegley + + * org-clock.el (org-resolve-clocks-if-idle): Another fix to the + way the amount of idle time is presented in the minibuffer. + +2009-11-13 Carsten Dominik + + * org-icalendar.el (org-print-icalendar-entries): Use + org-icalendar-verify-function only if non-nil. + + * org.el (org-refile): Refile to clock only if the prefix arg is + 2. + (org-sparse-tree): Fix docstring to be in line with prompt. + (org-update-parent-todo-statistics): Call + `org-after-todo-statistics-hook' on each level. + +2009-11-13 Carsten Dominik + + * org-remember.el (org-remember-apply-template): Make sure the + buffer exists. + +2009-11-13 Carsten Dominik + + * org.el (org-tab-ind-state): New variable. + (org-cycle-level): New function. + (org-cycle-level-after-item/entry-creation): New option. + (org-flag-subtree): New function. + (org-hide-archived-subtrees): Call `org-flag-subtree'. + (org-set-effort): Indexed access. + + * org-list.el (org-cycle-item-indentation): New function. + + * org.el (org-refile): Make prefix argument 2 refile to current + clock. + (org-priority): Interpret action `remove' as call to remove the + priority cookie. + + * org-remember.el (org-remember-apply-template): Don't depend on + buffer name being like file name. + +2009-11-13 Carsten Dominik + + * org-clock.el (org-clock-play-sound): Expand file in + org-clock-sound, to allow ~ for home. + + * org-remember.el (org-remember-handler): Set + text-before-node-creation even if this already looks like a node, + because the string might be needed on non-org-mode target files. + + * org-agenda.el (org-agenda-open-link): Make this work in agenda + clocktables. + (org-agenda-switch-to): Follow a link at point if + org-return-follows-link' is set and there is nothing else to do in + this line. + +2009-11-13 James TD Smith + + * org-colview-xemacs.el: Add in changes from org-colview.el + +2009-11-13 Dan Davison + + * org-exp-blocks.el: Modify split separator regexp to avoid empty + strings. + +2009-11-13 James TD Smith + + * org-colview.el (org-columns-new): Make this work with the new + operators. + (org-columns-store-format): Make this work with the new operators. + +2009-11-13 Carsten Dominik + + * org-src.el (org-src-preserve-indentation): Document that this + variable is also used during export. + + * org-exp.el (org-export-format-source-code-or-example): Preserve + indentation if a block has a -i option, or if + `org-src-preserve-indentation' is set. + + * org-exp-blocks.el (org-export-blocks-preprocess): Preserve + indentation if a block has a -i option, or if + `org-src-preserve-indentation' is set. + +2009-11-13 Carsten Dominik + + * org.el (org-mode-map): Define the new archiving keys. + (org-speed-commands-default): Define an archiving key in the speed + command map. + (org-org-menu): Improve the menu structure concerning archiving. + + * org-archive.el (org-archive-subtree-default-with-confirmation): + New command. + + * org-agenda.el (org-agenda-mode-map): Define the new archiving keys. + (org-agenda-menu): Add the new archiving commands to the menu. + (org-agenda-archive-default) + (org-agenda-archive-default-with-confirmation): New commands. + (org-agenda-archive, org-agenda-archive-to-archive-sibling): Just + call `org-agenda-archive-with'. + (org-agenda-archive-with): New function. + + * org-table.el (org-table-convert-region): Inert spaces around "|" + to avoid line beginnings like "|-1" which will be mistaken as + hlines. + +2009-11-13 Carsten Dominik + + * org.el (org-offer-links-in-entry): Return nil if there are no + links, t if a link has been selected. + (org-open-at-point): Open attachment directory when called in the + headline and there are no links in the entry body. + (org-speed-commands-default): Add "o" for open-at-point as a speed + command. + + * org-attach.el (org-attach-reveal): Optional prefix arg + IF-EXISTS, which avoids creating the attachment directory if it + does not yet exist. + + * org-agenda.el (org-agenda, org-run-agenda-series): Evaluate + MATCH. + +2009-11-13 Carsten Dominik + + * org.el ("abbrev"): Work with abbrev tables only after they have + been loaded. + + * org-list.el (org-list-send-list): Fix bug related to match + data. + + * org-latex.el (org-export-latex-fontify): Apply verbatim + emphasis. + (org-export-latex-make-header): Insert \obeylines if line breaks + should be preserved. + + * org-exp.el (org-export-protect-verbatim): Add an + `org-verbatim-emph' property to such text. + +2009-11-13 Carsten Dominik + + * org-icalendar.el (org-icalendar-use-plain-timestamp): New option. + (org-print-icalendar-entries): Skip entries where the timestamp is + not a deadline and not scheduled, if the user requests that. + + * org-latex.el (org-export-latex-quotation-marks): Allow a bracket + before an opening quote. + + * org-archive.el (org-archive-subtree): Keep archive after + archiving something. + + * org-id.el (org-id-update-id-locations): Add archive files if + that is required by `org-id-extra-files'. + +2009-11-13 Carsten Dominik + + * org-src.el (org-src-window-setup): New option. + (org-src-switch-to-buffer): New function. + (org-edit-src-exit): Add optional argument CONTEXT and use it to + restore window configuration. + (org-edit-src-code, org-edit-src-continue, org-edit-src-exit): + Call `org-src-switch-to-buffer'. + + * org.el (org-default-properties): Add STYLE property. + (org-files-list): Use the function call to get the files. + (org-additional-option-like-keywords): Add SETUPFILE to completion + list. + +2009-11-13 Carsten Dominik + + * org-table.el (org-table-convert-region): Correctly interpret + quoting in csv import. + + * org.el (org-icompleting-read): Make iswitchb completion work + with lists and tables. + + * org-agenda.el (org-agenda-add-entry-text): Never add entry text + while pushing the mobile agenda. + +2009-11-13 John Wiegley + + * org-clock.el + (org-clock-auto-clock-resolution): Now takes three values: nil, t + and `when-no-clock-is-running'. + (org-clock-in): Use `org-clock-auto-clock-resolution' to determine + whether or not to resolve Org buffers on clock in. + +2009-11-13 James TD Smith + + * org-colview.el (org-format-time-period): Function to format + times in fractional days for display. + (org-columns-display-here): Add support for showing a calculated + value in place of the property. + (org-columns): Set `org-columns-time' to the current time so time + difference calculations will work. + (org-columns-time): Use to store the current time when column view + is displayed, so all time differences will use the same reference + point. + (org-columns-compile-map): There is now an extra position in each + entry specifying the function to use to calculate the displayed + value for the non-calculated properties in the column, + (org-columns-compute-all): Set `org-columns-time' to the current + time so time difference calculations will work. + (org-columns-compute): Handle column operators where the values + used are calculated from the underlying property. + (org-columns-number-to-string): Handle the 'age' column format + (org-columns-string-to-number): Correct the function name (was + org-column...). Add support for the 'age' column format. + (org-columns-compile-format): Support the additional parameter in + org-columns-compile-map. + +2009-11-13 Bastien Guerry + + * org.el (org-mode-hook): Turn `org-mode-hook' into a customizable + variable. + +2009-11-13 Carsten Dominik + + * org-clock.el (org-clock-has-been-used): New variable. + (org-clock-in): Set `org-clock-has-been-used'. + (org-clock-save): Save only if clock data has been used or created + during this session. + +2009-11-13 Carsten Dominik + + * org-clock.el (org-clock-persist): New value, to store only the + clock history. + (org-clock-save): Don't save the clock if only the history should + be stored. + (org-clock-load): Turn off John Wiegley's auto resolving mechanism + when restoring a saved clock. + +2009-11-13 John Wiegley + + * org-clock.el (org-clock-display, org-clock-put-overlay): Use + `org-time-clock-use-fractional'. + + * org.el (org-time-clocksum-use-fractional) + (org-time-clocksum-fractional-format): Two new customizable + variables which allow the user to select fractional times (1.25 + instead of 1:25) in the `org-clock-display' report. + +2009-11-13 Carsten Dominik + + * org-ascii.el (org-export-ascii-table-keep-all-vertical-lines): + New option. + + * org.el (org-tag-alist): Fix customization type. + +2009-11-13 Carsten Dominik + + * org-mobile.el (org-mobile-update-checksum-for-capture-file): + Make sure the regexp search can fail without throwing an error. + (org-mobile-apply): Save the inbox buffer after removing + successfully applied changes. + +2009-11-13 John Wiegley + + * org-clock.el (org-resolve-clocks-if-idle): Fix to the way idle + time is reported after the user comes back (but before they + resolve time). + + * org.el (org-get-repeat): Change so that this function can be + called with either `org-scheduled-string' or + `org-deadline-string'. + + * org-clock.el (org-clock-auto-clock-resolution): Renamed + `org-clock-disable-clock-resolution', since negatives don't sound + good in customization variables. + (org-clock-in): Don't use the auto-resolution logic if the user is + clocking into a different task while an active clock is running. + This then allows the default behavior of clocking out of the open + task and then into the new task. + + * org.el (org-modules): Made this variable more consistent, since + it was referring to Org, OrgMode and Org-mode, whereas the docs + for the variable always refer to Org-mode. + +2009-11-13 James TD Smith + + * org.el (org-repeat-re): The changed org-repeat-re no longer + matched simple +2d type repeaters. Fix it so it does. + +2009-11-13 Carsten Dominik + + * org-latex.el (org-export-latex-preprocess): Protect the vspace + macro in the VERSE environment. + +2009-11-13 John Wiegley + + * org-habit.el (org-habit-get-priority): A new function that + determines the relative priority of a habit, based on how long + past its scheduled date it is, and how near the deadline is. + + * org-agenda.el (org-agenda-get-scheduled): Set habit priority + using `org-habit-get-priority'. + + * org-habit.el (org-habit-build-graph): Start displaying colors + from the first scheduled date, if that date is earlier than the + first completion date. + + * org-habit.el: Changed all "color" variables to faces, and made + them appropriate for light and dark backgrounds. + + * org-habit.el (org-habit-duration-to-days): Made this function + more general. + (org-habit-parse-todo): Parse the new ".+N/N" style repeater. + + * org-agenda.el (org-agenda-get-deadlines): Removed all mention of + habits, since they don't use DEADLINE anymore. + + * org.el (org-repeat-re, org-display-custom-time) + (org-timestamp-change): Extended to support the new ".+N/N" + syntax, used for habits. + + * org-clock.el (org-clock-resolve-clock): Fixed an incorrect + variable reference. + + * org-agenda.el (org-agenda-set-mode-name): Show Habit in the + modeline when habits are being displayed (if that module is being + loaded). + +2009-11-13 James TD Smith + + * org-clock.el (org-x11-idle-seconds): Add a method to get the X11 + idle time using the xscreensaver extension. + (org-user-idle-seconds): Use X11 idle time if available. + +2009-11-13 Carsten Dominik + + * org-agenda.el (org-agenda-next-line): New command. + (org-agenda-previous-line): New commands. + (org-agenda-show-and-scroll-up, org-agenda-show-scroll-down): New + commands. + (org-agenda-follow-mode): Do the follow immediately if the mode is + turned on here. + (previous-line, next-line): Replace keys with the corresponding + org functions. + (org-agenda-mode-map): Bind backspace and delete to the scrolling + command. + + * org.el (org-icompleting-read): Turn off partial completion mode + for the duration of this completion round. + + * org-latex.el (org-export-latex-fontify-headline): Protect TeX + macros in author lines and similar stuff. + + * org.el (org-file-tags): Fix docstring. + (org-get-buffer-tags): Add the #+FILETAGS tags. + ("ecb"): Maks ecb show context after jumping into an Org file. + +2009-11-13 John Wiegley + + * org-agenda.el (org-finalize-agenda): Draw habit consistency + graphs after everything else in the buffer has been setup. + +2009-11-13 Carsten Dominik + + * org-mobile.el (org-mobile-apply): Count success and failure. + + * org.el (org-indent-line-function): Fix regexp replace problem. + +2009-11-13 John Wiegley + + * org-clock.el (org-clock-disable-clock-resolution): New + customization variable that disable automatic clock resolution on + clock in. + (org-clock-in): If `org-clock-disable-clock-resolution' is set, do + not automatically resolve anything. This is does not affect + idle-time resolution, however, if `org-clock-idle-time' is set. + +2009-11-13 John Wiegley + + * org-habit.el: New file, which implements code to build a "habit + consistency graph". + + * org-agenda.el (org-agenda-get-deadlines) + (org-agenda-get-scheduled): Display consistency graphs when + outputting habits into the agenda. The graphs are always relative + to the current time. + (org-format-agenda-item): Added new parameter `habitp', which + indicates whether we are formatting a habit or not. Do not + display "extra" leading information if habitp is true. + + * org.el (org-repeat-re): Improved regexp to include .+ and ++ + leaders for repeat strings. + (org-get-repeat): Now takes a string parameter `tagline', so the + caller can obtain the SCHEDULED repeat, or the DEADLINE repeat. + +2009-11-13 John Wiegley + + * org-agenda.el (org-agenda-auto-exclude-function): New + customization variable for allowing the user to create an "auto + exclusion" filter for doing context-aware auto tag filtering. + (org-agenda-filter-by-tag): Changes to support the use of + `org-agenda-auto-exclude-function'. See the new manual addition,. + +2009-11-13 John Wiegley + + * org.el (org-files-list): Don't attempt to return a file name for + Org buffers which have no associated file. + + * org-agenda.el (org-agenda-do-action): Fixed a typo. + +2009-11-13 Carsten Dominik + + * org-mobile.el (org-mobile-locate-entry): Interpret files + relative to org-directory. + (org-mobile-inbox-for-pull): Document the best location for this + file. + (org-mobile-check-setup): Verify `org-directory'. + (org-mobile-create-index-file): Sort the files to be listed in + index.org. + +2009-11-13 James TD Smith + + * org.el (org-fast-tag-selection): Add a way to display a + description for a tag group. This is done by adding a string to + either the startgroup or endgroup cell. + +2009-11-13 Carsten Dominik + + * org-clock.el (org-clock-resolve, org-resolve-clocks) + (org-emacs-idle-seconds): Use `org-float-time' instead of + `time-to-seconds' + +2009-11-13 Carsten Dominik + + * org-agenda.el (org-agenda-sorting-strategy): Fix customization + type. + + * org.el (org-pre-cycle-hook): Document that `empty' can also be + the value of ARG when doing local cycling. + +2009-11-13 John Wiegley + + * org-clock.el (org-clock-resolve-clock): If keeping or + subtracting time results in a clock out at a time in the past, and + if the resolution occurred due to idleness or invoking `M-x + org-resolve-clocks', remember that past moment in time. On the + next clock in, the user will be prompted to see if they want to + back-date their new clock to then. + (org-clock-resolve): Do not jump the user to the location of a + dangling clock if the resolution is occuring due to an idle + timeout. In that case there is typically only one dangling clock, + the active one, and there is no value gained by shuffling their + windows around to show it to them. Being prompted to resolve an + idle clock should be as inobtrusive as possible. + (org-resolve-clocks-if-idle): New function that resolves only the + currently active clock if the user has exceeded the time returned + by `org-user-idle-seconds', based on the value of + `org-clock-idle-time'. + (org-clock-in): If, after resolving clocks, + (org-clock-out): Cancel the `org-clock-idle-timer' on clock out. + + * org-clock.el (org-clock-resolve-clock): New function that + resolves a clock to a specific time, closing or resuming as need + be, and possibly even starting a new clock. + (org-clock-resolve): New function used by `org-resolve-clocks' + that sets up for the call to `org-clock-resolve-clock'. It + determines the time to resolve to based on a single-character + selection from the user to either keep time, subtract away time or + cancel the clock. + (org-resolve-clocks): New user command which resolves dangling + clocks -- that is, open but not active -- anywhere in the file + list returned by `org-files-list'. + (org-clock-in): Automatically resolve dangling clocks whenever a + user clocks in. + (org-clock-cancel): If the user cancels the solely clock in a + LOGBOOK, remove the empty drawer. + + * org-clock.el (org-clock-idle-time): New user customizable option + for detecting whether the user has left a clock idle. Note: it is + only used in this commit to test whether it's worthwhile to check + OS X to get the Mac user's current idle time. If the Emacs idle + time is less than the value, the user hasn't been away long enough + to be worth checking (a more expensive test than just getting + Emacs idle time). + (org-user-idle-seconds, org-mac-idle-seconds) + (org-emacs-idle-seconds): This three functions, in conjunction + with the user customization variable `org-clock-idle-time', return + the number of seconds (as a floating point) that the user has been + away from their Emacs (or, if running on OS X, their computer). + + * org-clock.el (org-find-open-clocks): New function that returns a + list of all open clocks in the given FILE. Note that each clock + it returns is a cons cell of the format (MARKER . START-TIME). + This "clock" value is used by several of the new clock module + utility functions. + (org-is-active-clock): New inline function which tests whether the + given clock value is the same as the currently active clock. + Returns non-nil if this is the case. + (org-with-clock-position): New macro that evaluates FORMS with + point in the buffer and at the position of the given clock. + Changes to the current clock are global. + (org-with-clock): New macro that evaluates FORMS with point in the + buffer and at the position of the given clock. However, changes + to the current clock are local and have no effect on the user's + active clock. This allows, for example, far any clock to be + cancelled without cancelling the active clock. + (org-clock-clock-in): New inline function that switches the active + clock to the given clock. If either the argument RESUME, or the + global `org-clock-in-resume', are non-nil, it will resume a clock + that was previously left open. + (org-clock-clock-out): New inline function that clocks out the + given clock value without affecting the currently active clock. + (org-clock-clock-cancel): New inline function that cancels the + given clock value without affecting the currently active clock. + + * org-clock.el (org-clock-in): Before creating + `org-clock-mode-line-timer', check to make sure an older timer is + not currently running. + (org-clock-out): Accept new third parameter `at-time', which + permits a clock to be clocked out at a specific time. Note that + no attempt is made to verify that the clock out time is later than + the clock in time. + + * org.el (org-files-list): New utility function for returning a + list of all open org-mode buffers, plus all files used to build + the agenda buffer. Note that not all the files will necessarily + be visited by a buffer at time of call. + (org-entry-beginning-position): Like the function + `line-beginning-position', this inline function returns the + beginning position of the current heading/entry. + (org-entry-end-position): Like the function `line-end-position', + this inline function returns the end position of the current + heading/entry. + +2009-11-13 Carsten Dominik + + * org-agenda.el (org-agenda-list): Mark the all-todo items line as + a header line. + +2009-11-13 Carsten Dominik + + * org-exp.el (org-inlinetask-remove-END-maybe): Declare function. + +2009-11-13 Carsten Dominik + + * org-agenda.el (org-agenda-filter-make-matcher): Allow to filter + entries that have no tags. + (org-agenda-search-view): New customize group. + (org-agenda-search-view-search-words-only): New option. + (org-search-view): Implement substring search. + +2009-11-13 Carsten Dominik + + * org.el (org-outline-level): Add doc string. + +2009-11-13 Carsten Dominik + + * org-inlinetask.el (org-inlinetask-export): Re-introduce + variable. + (org-inlinetask-export-handler): Only export inline task if the + user option calls for it. + +2009-11-13 Carsten Dominik + + * org-exp.el (org-export-handle-export-tags): Remove inlinetask + END if present. + +2009-11-13 Carsten Dominik + + * org-latex.el (org-export-latex-tables): Don't format in + protected regions. + +2009-11-13 Carsten Dominik + + * org-src.el (org-edit-src-code) + (org-edit-src-find-region-and-lang, org-edit-src-exit): Handle + macro editing. + + * org-agenda.el (org-prefix-category-max-length): New variable. + (org-format-agenda-item): Use `org-prefix-category-max-length'. + (org-compile-prefix-format): Set `org-prefix-category-max-length'. + +2009-11-13 Carsten Dominik + + * org-mobile.el (org-mobile-create-index-file): Improve the + listing of tags and todo keywords. + + * org-latex.el (org-export-latex-format-image): New function. + (org-export-latex-links): Use `org-export-latex-format-image'. + +2009-11-13 Carsten Dominik + + * org-inlinetask.el (org-inlinetask-get-current-indentation) + (org-inlinetask-remove-terminator): New functions. + (org-inlinetask-export-handler): Terminate the description list. + + * org-exp.el (org-export-select-backend-specific-text): Remove the + region markers. + + * org-inlinetask.el (org-inlinetask-export-handler): fix bug for + tasks without content. + + * org-clock.el: Make sure the clock-in target position does not + move to a different node by widening the buffer. + + * org-html.el (org-export-html-format-image): Wrap image into + figure div only when there is a caption. + + * org-archive.el (org-archive-mark-done): Change default value to + nil. + +2009-11-13 Carsten Dominik + + * org.el (org-context): Call `bobp', not `eobp'. + + * org-clock.el (org-clock-cancel): Remove quotes from marker + variables. + + * org.el (org-read-date-prefer-future): New allowed value `time'. + (org-read-date-analyze): Shift day to tomorrow depending on time + entered and value of `org-read-date-prefer-future'. + 2009-11-05 Stefan Monnier * org.el (org-version, org-get-refile-targets, org-refile) diff --git a/lisp/org/org-agenda.el b/lisp/org/org-agenda.el index d7d5b8778e..544e933f5d 100644 --- a/lisp/org/org-agenda.el +++ b/lisp/org/org-agenda.el @@ -6,7 +6,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; @@ -52,9 +52,19 @@ (declare-function calendar-julian-date-string "cal-julian" (&optional date)) (declare-function calendar-mayan-date-string "cal-mayan" (&optional date)) (declare-function calendar-persian-date-string "cal-persia" (&optional date)) +(declare-function org-datetree-find-date-create "org-datetree" (date)) (declare-function org-columns-quit "org-colview" ()) +(declare-function diary-date-display-form "diary-lib" (&optional type)) +(declare-function org-mobile-write-agenda-for-mobile "org-mobile" (file)) +(declare-function org-habit-insert-consistency-graphs + "org-habit" (&optional line)) +(declare-function org-is-habit-p "org-habit" (&optional pom)) +(declare-function org-habit-parse-todo "org-habit" (&optional pom)) +(declare-function org-habit-get-priority "org-habit" (habit)) (defvar calendar-mode-map) (defvar org-mobile-force-id-on-agenda-items) ; defined in org-mobile.el +(defvar org-habit-show-habits) +(defvar org-habit-show-habits-only-for-today) ;; Defined somewhere in this file, but used before definition. (defvar org-agenda-buffer-name) @@ -200,6 +210,7 @@ you can \"misuse\" it to also add other text to the header. However, (const priority-up) (const priority-down) (const todo-state-up) (const todo-state-down) (const effort-up) (const effort-down) + (const habit-up) (const habit-down) (const user-defined-up) (const user-defined-down)) "Sorting choices.") @@ -481,6 +492,10 @@ this one will be used." "Options concerning the general tags/property/todo match agenda view." :tag "Org Agenda Match View" :group 'org-agenda) +(defgroup org-agenda-search-view nil + "Options concerning the general tags/property/todo match agenda view." + :tag "Org Agenda Match View" + :group 'org-agenda) (defvar org-agenda-archives-mode nil "Non-nil means, the agenda will include archived items. @@ -607,7 +622,7 @@ have turned on `org-enforce-todo-dependencies', `org-enforce-todo-checkbox-dependencies', or any other blocking mechanism, this will create useful feedback in the agenda. -Instead ot t, this variable can also have the value `invisible'. +Instead of t, this variable can also have the value `invisible'. Then blocked tasks will be invisible and only become visible when they become unblocked. An exemption to this behavior is when a task is blocked because of unchecked checkboxes below it. Since checkboxes do @@ -620,7 +635,7 @@ will only be dimmed." :type '(choice (const :tag "Do not dim" nil) (const :tag "Dim to a grey face" t) - (const :tag "Make invisibe" invisible))) + (const :tag "Make invisible" invisible))) (defcustom org-timeline-show-empty-dates 3 "Non-nil means, `org-timeline' also shows dates without an entry. @@ -662,7 +677,7 @@ Needs to be set before org.el is loaded." :type 'boolean) (defcustom org-agenda-entry-text-maxlines 5 - "Number of text lines to be added when `E' is presed in the agenda. + "Number of text lines to be added when `E' is pressed in the agenda. Note that this variable only used during agenda display. Add add entry text when exporting the agenda, configure the variable @@ -870,6 +885,16 @@ current display in the agenda." :group 'org-agenda-daily/weekly :type 'plist) +(defcustom org-agenda-search-view-search-words-only nil + "Non-nil means, the search string is interpreted as individual words +The search then looks for each word separately in each entry and +selects entries that have matches for all words. +When nil, matching as loose words will only take place if the first +word is preceded by + or -. If that is not the case, the search +string will just be matched as a substring in the entry, but with +each space character allowing for any whitespace, including newlines." + :group 'org-agenda-search-view + :type 'boolean) (defgroup org-agenda-time-grid nil "Options concerning the time grid in the Org-mode Agenda." @@ -935,9 +960,9 @@ a grid line." :group 'org-agenda) (defcustom org-agenda-sorting-strategy - '((agenda time-up priority-down category-keep) - (todo priority-down category-keep) - (tags priority-down category-keep) + '((agenda habit-down time-up priority-down category-keep) + (todo priority-down category-keep) + (tags priority-down category-keep) (search category-keep)) "Sorting structure for the agenda items of a single day. This is a list of symbols which will be used in sequence to determine @@ -960,6 +985,8 @@ effort-up Sort numerically by estimated effort, high effort last. effort-down Sort numerically by estimated effort, high effort first. user-defined-up Sort according to `org-agenda-cmp-user-defined', high last. user-defined-down Sort according to `org-agenda-cmp-user-defined', high first. +habit-up Put entries that are habits first +habit-down Put entries that are habits last The different possibilities will be tried in sequence, and testing stops if one comparison returns a \"not-equal\". For example, the default @@ -976,7 +1003,7 @@ categories by priority. Instead of a single list, this can also be a set of list for specific contents, with a context symbol in the car of the list, any of -`agenda', `todo', `tags' for the corresponding agenda views. +`agenda', `todo', `tags', `search' for the corresponding agenda views. Custom commands can bind this variable in the options section." :group 'org-agenda-sorting @@ -988,6 +1015,8 @@ Custom commands can bind this variable in the options section." (cons (const :tag "Strategy for TODO lists" todo) (repeat ,org-sorting-choice)) (cons (const :tag "Strategy for Tags matches" tags) + (repeat ,org-sorting-choice)) + (cons (const :tag "Strategy for search matches" search) (repeat ,org-sorting-choice))))) (defcustom org-agenda-cmp-user-defined nil @@ -1060,7 +1089,7 @@ If there is punctuation or whitespace character just before the final format letter, this character will be appended to the field value if the value is not empty. For example, the format \"%-12:c\" leads to \"Diary: \" if the category is \"Diary\". If the category were be -empty, no additional colon would be interted. +empty, no additional colon would be inserted. The default value of this option is \" %-12:c%?-12t% s\", meaning: - Indent the line with two space characters @@ -1259,6 +1288,15 @@ estimate." :group 'org-agenda-column-view :type 'boolean) +(defcustom org-agenda-auto-exclude-function nil + "A function called with a tag to decide if it is filtered on '/ RET'. +The sole argument to the function, which is called once for each +possible tag, is a string giving the name of the tag. The +function should return either nil if the tag should be included +as normal, or \"-\" to exclude the tag." + :group 'org-agenda + :type 'function) + (eval-when-compile (require 'cl)) (require 'org) @@ -1276,6 +1314,8 @@ works you probably want to add it to `org-agenda-custom-commands' for good." (defvar org-agenda-mode-map (make-sparse-keymap) "Keymap for `org-agenda-mode'.") +(if (fboundp 'defvaralias) + (defvaralias 'org-agenda-keymap 'org-agenda-mode-map)) (defvar org-agenda-menu) ; defined later in this file. (defvar org-agenda-restrict) ; defined later in this file. @@ -1353,12 +1393,16 @@ The following commands are available: (org-defkey org-agenda-mode-map "U" 'org-agenda-bulk-remove-all-marks) (org-defkey org-agenda-mode-map "B" 'org-agenda-bulk-action) (org-defkey org-agenda-mode-map "\C-c\C-x!" 'org-reload) -(org-defkey org-agenda-mode-map "\C-c$" 'org-agenda-archive) +(org-defkey org-agenda-mode-map "\C-c\C-x\C-a" 'org-agenda-archive-default) +(org-defkey org-agenda-mode-map "\C-c\C-xa" 'org-agenda-toggle-archive-tag) +(org-defkey org-agenda-mode-map "\C-c\C-xA" 'org-agenda-archive-to-archive-sibling) (org-defkey org-agenda-mode-map "\C-c\C-x\C-s" 'org-agenda-archive) +(org-defkey org-agenda-mode-map "\C-c$" 'org-agenda-archive) (org-defkey org-agenda-mode-map "$" 'org-agenda-archive) -(org-defkey org-agenda-mode-map "A" 'org-agenda-archive-to-archive-sibling) (org-defkey org-agenda-mode-map "\C-c\C-o" 'org-agenda-open-link) -(org-defkey org-agenda-mode-map " " 'org-agenda-show) +(org-defkey org-agenda-mode-map " " 'org-agenda-show-and-scroll-up) +(org-defkey org-agenda-mode-map [backspace] 'org-agenda-show-scroll-down) +(org-defkey org-agenda-mode-map "\d" 'org-agenda-show-scroll-down) (org-defkey org-agenda-mode-map [(control shift right)] 'org-agenda-todo-nextset) (org-defkey org-agenda-mode-map [(control shift left)] 'org-agenda-todo-previousset) (org-defkey org-agenda-mode-map "\C-c\C-xb" 'org-agenda-tree-to-indirect-buffer) @@ -1366,7 +1410,7 @@ The following commands are available: (org-defkey org-agenda-mode-map "L" 'org-agenda-recenter) (org-defkey org-agenda-mode-map "\C-c\C-t" 'org-agenda-todo) (org-defkey org-agenda-mode-map "t" 'org-agenda-todo) -(org-defkey org-agenda-mode-map "a" 'org-agenda-toggle-archive-tag) +(org-defkey org-agenda-mode-map "a" 'org-agenda-archive-default-with-confirmation) (org-defkey org-agenda-mode-map ":" 'org-agenda-set-tags) (org-defkey org-agenda-mode-map "\C-c\C-q" 'org-agenda-set-tags) (org-defkey org-agenda-mode-map "." 'org-agenda-goto-today) @@ -1411,8 +1455,12 @@ The following commands are available: (org-defkey org-agenda-mode-map "s" 'org-save-all-org-buffers) (org-defkey org-agenda-mode-map "P" 'org-agenda-show-priority) (org-defkey org-agenda-mode-map "T" 'org-agenda-show-tags) -(org-defkey org-agenda-mode-map "n" 'next-line) -(org-defkey org-agenda-mode-map "p" 'previous-line) +(org-defkey org-agenda-mode-map "n" 'org-agenda-next-line) +(org-defkey org-agenda-mode-map "p" 'org-agenda-previous-line) +(substitute-key-definition 'next-line 'org-agenda-next-line + org-agenda-mode-map global-map) +(substitute-key-definition 'previous-line 'org-agenda-previous-line + org-agenda-mode-map global-map) (org-defkey org-agenda-mode-map "\C-c\C-a" 'org-attach) (org-defkey org-agenda-mode-map "\C-c\C-n" 'org-agenda-next-date-line) (org-defkey org-agenda-mode-map "\C-c\C-p" 'org-agenda-previous-date-line) @@ -1455,15 +1503,12 @@ The following commands are available: (org-defkey org-agenda-mode-map "\C-c\C-x\C-mg" 'org-mobile-pull) (org-defkey org-agenda-mode-map "\C-c\C-x\C-mp" 'org-mobile-push) -(defvar org-agenda-keymap (copy-keymap org-agenda-mode-map) - "Local keymap for agenda entries from Org-mode.") - -(org-defkey org-agenda-keymap +(org-defkey org-agenda-mode-map (if (featurep 'xemacs) [(button2)] [(mouse-2)]) 'org-agenda-goto-mouse) -(org-defkey org-agenda-keymap +(org-defkey org-agenda-mode-map (if (featurep 'xemacs) [(button3)] [(mouse-3)]) 'org-agenda-show-mouse) (when org-agenda-mouse-1-follows-link - (org-defkey org-agenda-keymap [follow-link] 'mouse-face)) + (org-defkey org-agenda-mode-map [follow-link] 'mouse-face)) (easy-menu-define org-agenda-menu org-agenda-mode-map "Agenda menu" '("Agenda" ("Agenda Files") @@ -1535,6 +1580,8 @@ The following commands are available: ["Previous TODO set" org-agenda-todo-previousset t] ["Add note" org-agenda-add-note t]) ("Archive/Refile/Delete" + ["Archive default" org-agenda-archive-default t] + ["Archive default" org-agenda-archive-default-with-confirmation t] ["Toggle ARCHIVE tag" org-agenda-toggle-archive-tag t] ["Move to archive sibling" org-agenda-archive-to-archive-sibling t] ["Archive subtree" org-agenda-archive t] @@ -1684,7 +1731,7 @@ M Like `m', but select only TODO entries, no ordinary headlines. L Create a timeline for the current buffer. e Export views to associated files. s Search entries for keywords. -/ Multi occur accros all agenda files and also files listed +/ Multi occur across all agenda files and also files listed in `org-agenda-text-search-extra-files'. < Restrict agenda commands to buffer, subtree, or region. Press several times to get the desired effect. @@ -1727,7 +1774,7 @@ Pressing `<' twice means to restrict to the current subtree or region entry key type match lprops ans) ;; Turn off restriction unless there is an overriding one, (unless org-agenda-overriding-restriction - (unless (org-bound-and-true-p org-agenda-keep-restriced-file-list) + (unless (org-bound-and-true-p org-agenda-keep-restricted-file-list) ;; There is a request to keep the file list in place (put 'org-agenda-files 'org-restrict nil)) (setq org-agenda-restrict nil) @@ -1741,7 +1788,7 @@ Pressing `<' twice means to restrict to the current subtree or region (setq ans (org-agenda-get-restriction-and-command prefix-descriptions) keys (car ans) restriction (cdr ans))) - ;; Estabish the restriction, if any + ;; Establish the restriction, if any (when (and (not org-agenda-overriding-restriction) restriction) (put 'org-agenda-files 'org-restrict (list bfn)) (cond @@ -1763,7 +1810,8 @@ Pressing `<' twice means to restrict to the current subtree or region ((setq entry (assoc keys org-agenda-custom-commands)) (if (or (symbolp (nth 2 entry)) (functionp (nth 2 entry))) (progn - (setq type (nth 2 entry) match (nth 3 entry) lprops (nth 4 entry)) + (setq type (nth 2 entry) match (eval (nth 3 entry)) + lprops (nth 4 entry)) (put 'org-agenda-redo-command 'org-lprops lprops) (cond ((eq type 'agenda) @@ -2006,7 +2054,7 @@ s Search for keywords C Configure custom agenda commands match ;; The byte compiler incorrectly complains about this. Keep it! cmd type lprops) (while (setq cmd (pop cmds)) - (setq type (car cmd) match (nth 1 cmd) lprops (nth 2 cmd)) + (setq type (car cmd) match (eval (nth 1 cmd)) lprops (nth 2 cmd)) (cond ((eq type 'agenda) (org-let2 gprops lprops @@ -2057,10 +2105,13 @@ before running the agenda command." (set-buffer org-agenda-buffer-name) (princ (org-encode-for-stdout (buffer-string))))) +;(defun org-encode-for-stdout (string) +; (if (fboundp 'encode-coding-string) +; (encode-coding-string string buffer-file-coding-system) +; string)) + (defun org-encode-for-stdout (string) - (if (fboundp 'encode-coding-string) - (encode-coding-string string buffer-file-coding-system) - string)) + string) (defvar org-agenda-info nil) @@ -2212,7 +2263,7 @@ so the export commands can easily use it." (put-text-property (point-at-bol) (point-at-eol) 'org-agenda-title-append org-agenda-title-append)))) - +(defvar org-mobile-creating-agendas) (defun org-write-agenda (file &optional open nosettings) "Write the current buffer (an agenda view) as a file. Depending on the extension of the file name, plain text (.txt), @@ -2220,7 +2271,7 @@ HTML (.html or .htm) or Postscript (.ps) is produced. If the extension is .ics, run icalendar export over all files used to construct the agenda and limit the export to entries listed in the agenda now. -With prefic argument OPEN, open the new file immediately. +With prefix argument OPEN, open the new file immediately. If NOSETTINGS is given, do not scope the settings of `org-agenda-exporter-settings' into the export commands. This is used when the settings have already been scoped and we do not wish to overrule other, @@ -2235,7 +2286,7 @@ higher priority settings." '(save-excursion (save-window-excursion (org-agenda-mark-filtered-text) - (let ((bs (copy-sequence (buffer-string))) beg app) + (let ((bs (copy-sequence (buffer-string))) beg) (org-agenda-unmark-filtered-text) (with-temp-buffer (insert bs) @@ -2247,6 +2298,8 @@ higher priority settings." (point-max)))) (run-hooks 'org-agenda-before-write-hook) (cond + ((org-bound-and-true-p org-mobile-creating-agendas) + (org-mobile-write-agenda-for-mobile file)) ((string-match "\\.html?\\'" file) (set-buffer (htmlize-buffer (current-buffer))) @@ -2275,63 +2328,6 @@ higher priority settings." (concat (file-name-sans-extension file) ".ps")) (expand-file-name file)) (message "PDF written to %s" file)) - ((string-match "\\.org\\'" file) - (let ((all (buffer-string)) in-date id pl prefix line) - (with-temp-file file - (org-mode) - (insert all) - (goto-char (point-min)) - (while (not (eobp)) - (cond - ((looking-at "[ \t]*$")) ; keep empty lines - ((looking-at "=+$") - ;; remove underlining - (delete-region (point) (point-at-eol))) - ((get-text-property (point) 'org-agenda-structural-header) - (setq in-date nil) - (setq app (get-text-property (point) - 'org-agenda-title-append)) - (setq short (get-text-property (point) - 'short-heading)) - (when (and short (looking-at ".+")) - (replace-match short) - (beginning-of-line 1)) - (when app - (end-of-line 1) - (insert app) - (beginning-of-line 1)) - (insert "* ")) - ((get-text-property (point) 'org-agenda-date-header) - (setq in-date t) - (insert "** ")) - ((setq m (or (get-text-property (point) 'org-hd-marker) - (get-text-property (point) 'org-marker))) - (if (setq pl (get-text-property (point) 'prefix-length)) - (progn - (setq prefix (org-trim (buffer-substring - (point) (+ (point) pl))) - line (org-trim (buffer-substring - (+ (point) pl) - (point-at-eol)))) - (delete-region (point-at-bol) (point-at-eol)) - (insert line "" prefix) - (beginning-of-line 1)) - (and (looking-at "[ \t]+") (replace-match ""))) - (insert (if in-date "*** " "** ")) - (end-of-line 1) - (insert "\n") - (insert (org-agenda-get-some-entry-text - m 10 " " 'planning) - "\n") - (when (setq id - (if (org-bound-and-true-p - org-mobile-force-id-on-agenda-items) - (org-id-get m 'create) - (org-entry-get m "ID"))) - (insert " :PROPERTIES:\n :ORIGINAL_ID: " id - "\n :END:\n")))) - (beginning-of-line 2))) - (message "Agenda written to Org file %s" file))) ((string-match "\\.ics\\'" file) (require 'org-icalendar) (let ((org-agenda-marker-table @@ -2386,7 +2382,8 @@ VALUE defaults to t." This will add a maximum of `org-agenda-add-entry-text-maxlines' lines of the entry text following headings shown in the agenda. Drawers will be excluded, also the line with scheduling/deadline info." - (when (> org-agenda-add-entry-text-maxlines 0) + (when (and (> org-agenda-add-entry-text-maxlines 0) + (not (org-bound-and-true-p org-mobile-creating-agendas))) (let (m txt) (goto-char (point-min)) (while (not (eobp)) @@ -2402,7 +2399,7 @@ Drawers will be excluded, also the line with scheduling/deadline info." "Extract entry text from MARKER, at most N-LINES lines. This will ignore drawers etc, just get the text. If INDENT is given, prefix every line with this string. If KEEP is -given, it is a list of symbols, defining stuff that hould not be +given, it is a list of symbols, defining stuff that should not be removed from the entry content. Currently only `planning' is allowed here." (let (txt drawer-re kwd-time-re ind) (save-excursion @@ -2626,6 +2623,8 @@ bind it in the options section.") (when org-agenda-entry-text-mode (org-agenda-entry-text-hide) (org-agenda-entry-text-show)) + (if (functionp 'org-habit-insert-consistency-graphs) + (org-habit-insert-consistency-graphs)) (run-hooks 'org-finalize-agenda-hook) (setq org-agenda-type (org-get-at-bol 'org-agenda-type)) (when (get 'org-agenda-filter :preset-filter) @@ -2783,7 +2782,7 @@ no longer in use." ;;; Entry text mode (defun org-agenda-entry-text-show-here () - "Add some text from te entry as context to the current line." + "Add some text from the entry as context to the current line." (let (m txt o) (setq m (org-get-at-bol 'org-hd-marker)) (unless (marker-buffer m) @@ -3054,6 +3053,7 @@ given in `org-agenda-start-on-weekday'." (add-text-properties (point-min) (1- (point)) (list 'face 'org-agenda-structure 'short-heading "All TODO items")) + (org-agenda-mark-header-line (point-min)) (insert (org-finalize-agenda-entries rtnall) "\n"))) (unless org-agenda-compact-blocks (let* ((d1 (car day-numbers)) @@ -3193,10 +3193,19 @@ user should get a chance to edit this string, with cursor at position EDIT-AT. The search string is broken into \"words\" by splitting at whitespace. -The individual words are then interpreted as a boolean expression with -logical AND. Words prefixed with a minus must not occur in the entry. -Words without a prefix or prefixed with a plus must occur in the entry. -Matching is case-insensitive and the words are enclosed by word delimiters. +Depending on the variable `org-agenda-search-view-search-words-only' +and on whether the first character in the search string is \"+\" or \"-\", +The string is then interpreted either as a substring with variable amounts +of whitespace, or as a list or individual words that should be matched. + +The default is a substring match, where each space in the search string +can expand to an arbitrary amount of whitespace, including newlines. + +If matching individual words, these words are then interpreted as a +boolean expression with logical AND. Words prefixed with a minus must +not occur in the entry. Words without a prefix or prefixed with a plus +must occur in the entry. Matching is case-insensitive and the words +are enclosed by word delimiters. Words enclosed by curly braces are interpreted as regular expressions that must or must not match in the entry. @@ -3218,10 +3227,9 @@ in `org-agenda-text-search-extra-files'." 'org-todo-regexp org-todo-regexp 'org-complex-heading-regexp org-complex-heading-regexp 'mouse-face 'highlight - 'keymap org-agenda-keymap 'help-echo (format "mouse-2 or RET jump to location"))) regexp rtn rtnall files file pos - marker category tags c neg re + marker category tags c neg re as-words ee txt beg end words regexps+ regexps- hdl-only buffer beg1 str) (unless (and (not edit-at) (stringp string) @@ -3244,19 +3252,25 @@ in `org-agenda-text-search-extra-files'." (when (equal (string-to-char words) ?!) (setq todo-only t words (substring words 1))) + (if (or org-agenda-search-view-search-words-only + (member (string-to-char string) '(?- ?+))) + (setq as-words t)) (setq words (org-split-string words)) - (mapc (lambda (w) - (setq c (string-to-char w)) - (if (equal c ?-) - (setq neg t w (substring w 1)) - (if (equal c ?+) - (setq neg nil w (substring w 1)) - (setq neg nil))) - (if (string-match "\\`{.*}\\'" w) - (setq re (substring w 1 -1)) - (setq re (concat "\\<" (regexp-quote (downcase w)) "\\>"))) - (if neg (push re regexps-) (push re regexps+))) - words) + (if as-words + (mapc (lambda (w) + (setq c (string-to-char w)) + (if (equal c ?-) + (setq neg t w (substring w 1)) + (if (equal c ?+) + (setq neg nil w (substring w 1)) + (setq neg nil))) + (if (string-match "\\`{.*}\\'" w) + (setq re (substring w 1 -1)) + (setq re (concat "\\<" (regexp-quote (downcase w)) "\\>"))) + (if neg (push re regexps-) (push re regexps+))) + words) + (push (mapconcat (lambda (w) (regexp-quote w)) words "\\s-+") + regexps+)) (setq regexps+ (sort regexps+ (lambda (a b) (> (length a) (length b))))) (if (not regexps+) (setq regexp (concat "^" org-outline-regexp)) @@ -3760,7 +3774,6 @@ date. It also removes lines that contain only whitespace." "Add text properties to string, allowing org-mode to act on it." (org-add-props string nil 'mouse-face 'highlight - 'keymap org-agenda-keymap 'help-echo (if buffer-file-name (format "mouse-2 or RET jump to diary file %s" (abbreviate-file-name buffer-file-name)) @@ -3913,7 +3926,6 @@ the documentation of `org-diary'." 'org-todo-regexp org-todo-regexp 'org-complex-heading-regexp org-complex-heading-regexp 'mouse-face 'highlight - 'keymap org-agenda-keymap 'help-echo (format "mouse-2 or RET jump to org file %s" (abbreviate-file-name buffer-file-name)))) @@ -3984,7 +3996,6 @@ the documentation of `org-diary'." 'org-todo-regexp org-todo-regexp 'org-complex-heading-regexp org-complex-heading-regexp 'mouse-face 'highlight - 'keymap org-agenda-keymap 'help-echo (format "mouse-2 or RET jump to org file %s" (abbreviate-file-name buffer-file-name)))) @@ -4078,7 +4089,6 @@ the documentation of `org-diary'." (require 'diary-lib) (let* ((props (list 'face nil 'mouse-face 'highlight - 'keymap org-agenda-keymap 'help-echo (format "mouse-2 or RET jump to org file %s" (abbreviate-file-name buffer-file-name)))) @@ -4123,7 +4133,6 @@ the documentation of `org-diary'." 'org-not-done-regexp org-not-done-regexp 'org-todo-regexp org-todo-regexp 'org-complex-heading-regexp org-complex-heading-regexp - 'keymap org-agenda-keymap 'help-echo (format "mouse-2 or RET jump to org file %s" (abbreviate-file-name buffer-file-name)))) @@ -4217,7 +4226,6 @@ the documentation of `org-diary'." 'org-not-done-regexp org-not-done-regexp 'org-todo-regexp org-todo-regexp 'org-complex-heading-regexp org-complex-heading-regexp - 'keymap org-agenda-keymap 'help-echo (format "mouse-2 or RET jump to org file %s" (abbreviate-file-name buffer-file-name)))) @@ -4243,9 +4251,9 @@ the documentation of `org-diary'." ;; When to show a deadline in the calendar: ;; If the expiration is within wdays warning time. ;; Past-due deadlines are only shown on the current date - (if (or (and (<= diff wdays) - (and todayp (not org-agenda-only-exact-dates))) - (= diff 0)) + (if (and (or (and (<= diff wdays) + (and todayp (not org-agenda-only-exact-dates))) + (= diff 0))) (save-excursion (setq todo-state (org-get-todo-state)) (setq donep (member todo-state org-done-keywords)) @@ -4311,7 +4319,6 @@ FRACTION is what fraction of the head-warning time has passed." 'org-complex-heading-regexp org-complex-heading-regexp 'done-face 'org-agenda-done 'mouse-face 'highlight - 'keymap org-agenda-keymap 'help-echo (format "mouse-2 or RET jump to org file %s" (abbreviate-file-name buffer-file-name)))) @@ -4321,11 +4328,11 @@ FRACTION is what fraction of the head-warning time has passed." mm (deadline-position-alist (mapcar (lambda (a) (and (setq mm (get-text-property - 0 'org-hd-marker a)) - (cons (marker-position mm) a))) + 0 'org-hd-marker a)) + (cons (marker-position mm) a))) deadline-results)) d2 diff pos pos1 category tags donep - ee txt head pastschedp todo-state face timestr s) + ee txt head pastschedp todo-state face timestr s habitp) (goto-char (point-min)) (while (re-search-forward regexp nil t) (catch :skip @@ -4340,60 +4347,73 @@ FRACTION is what fraction of the head-warning time has passed." (setq pastschedp (and todayp (< diff 0))) ;; When to show a scheduled item in the calendar: ;; If it is on or past the date. - (if (or (and (< diff 0) - (< (abs diff) org-scheduled-past-days) - (and todayp (not org-agenda-only-exact-dates))) - (= diff 0)) - (save-excursion - (setq todo-state (org-get-todo-state)) - (setq donep (member todo-state org-done-keywords)) - (if (and donep - (or org-agenda-skip-scheduled-if-done - (not (= diff 0)))) - (setq txt nil) - (setq category (org-get-category)) - (if (not (re-search-backward "^\\*+[ \t]+" nil t)) - (setq txt org-agenda-no-heading-message) - (goto-char (match-end 0)) - (setq pos1 (match-beginning 0)) + (when (or (and (< diff 0) + (< (abs diff) org-scheduled-past-days) + (and todayp (not org-agenda-only-exact-dates))) + (= diff 0)) + (save-excursion + (setq todo-state (org-get-todo-state)) + (setq donep (member todo-state org-done-keywords)) + (setq habitp (and (functionp 'org-is-habit-p) + (org-is-habit-p))) + (if (and donep + (or habitp org-agenda-skip-scheduled-if-done + (not (= diff 0)))) + (setq txt nil) + (setq category (org-get-category)) + (if (not (re-search-backward "^\\*+[ \t]+" nil t)) + (setq txt org-agenda-no-heading-message) + (goto-char (match-end 0)) + (setq pos1 (match-beginning 0)) + (if habitp + (if (or (not org-habit-show-habits) + (and (not todayp) + org-habit-show-habits-only-for-today)) + (throw :skip nil)) (if (and (or (eq t org-agenda-skip-scheduled-if-deadline-is-shown) (and org-agenda-skip-scheduled-if-deadline-is-shown pastschedp)) (setq mm (assoc pos1 deadline-position-alist))) - (throw :skip nil)) - (setq tags (org-get-tags-at)) - (setq head (buffer-substring-no-properties - (point) - (progn (skip-chars-forward "^\r\n") (point)))) - (if (string-match " \\([012]?[0-9]:[0-9][0-9]\\)" s) - (setq timestr - (concat (substring s (match-beginning 1)) " ")) - (setq timestr 'time)) - (setq txt (org-format-agenda-item - (if (= diff 0) - (car org-agenda-scheduled-leaders) - (format (nth 1 org-agenda-scheduled-leaders) - (- 1 diff))) - head category tags - (if (not (= diff 0)) nil timestr))))) - (when txt - (setq face - (cond - (pastschedp 'org-scheduled-previously) - (todayp 'org-scheduled-today) - (t 'org-scheduled))) - (org-add-props txt props - 'undone-face face - 'face (if donep 'org-agenda-done face) - 'org-marker (org-agenda-new-marker pos) - 'org-hd-marker (org-agenda-new-marker pos1) - 'type (if pastschedp "past-scheduled" "scheduled") - 'date (if pastschedp d2 date) - 'priority (+ 94 (- 5 diff) (org-get-priority txt)) - 'org-category category - 'todo-state todo-state) - (push txt ee)))))) + (throw :skip nil))) + (setq tags (org-get-tags-at)) + (setq head (buffer-substring-no-properties + (point) + (progn (skip-chars-forward "^\r\n") (point)))) + (if (string-match " \\([012]?[0-9]:[0-9][0-9]\\)" s) + (setq timestr + (concat (substring s (match-beginning 1)) " ")) + (setq timestr 'time)) + (setq txt (org-format-agenda-item + (if (= diff 0) + (car org-agenda-scheduled-leaders) + (format (nth 1 org-agenda-scheduled-leaders) + (- 1 diff))) + head category tags + (if (not (= diff 0)) nil timestr) + nil nil habitp)))) + (when txt + (setq face + (cond + ((and (not habitp) pastschedp) + 'org-scheduled-previously) + (todayp 'org-scheduled-today) + (t 'org-scheduled)) + habitp (and habitp (org-habit-parse-todo))) + (org-add-props txt props + 'undone-face face + 'face (if donep 'org-agenda-done face) + 'org-marker (org-agenda-new-marker pos) + 'org-hd-marker (org-agenda-new-marker pos1) + 'type (if pastschedp "past-scheduled" "scheduled") + 'date (if pastschedp d2 date) + 'priority (if habitp + (org-habit-get-priority habitp) + (+ 94 (- 5 diff) (org-get-priority txt))) + 'org-category category + 'org-habit-p habitp + 'todo-state todo-state) + (push txt ee)))))) (nreverse ee))) (defun org-agenda-get-blocks () @@ -4403,7 +4423,6 @@ FRACTION is what fraction of the head-warning time has passed." 'org-todo-regexp org-todo-regexp 'org-complex-heading-regexp org-complex-heading-regexp 'mouse-face 'highlight - 'keymap org-agenda-keymap 'help-echo (format "mouse-2 or RET jump to org file %s" (abbreviate-file-name buffer-file-name)))) @@ -4468,9 +4487,11 @@ The flag is set if the currently compiled format contains a `%T'.") The flag is set if the currently compiled format contains a `%e'.") (defvar org-prefix-category-length nil "Used by `org-compile-prefix-format' to remember the category field widh.") +(defvar org-prefix-category-max-length nil + "Used by `org-compile-prefix-format' to remember the category field widh.") (defun org-format-agenda-item (extra txt &optional category tags dotime - noprefix remove-re) + noprefix remove-re habitp) "Format TXT to be inserted into the agenda buffer. In particular, it adds the prefix and corresponding text properties. EXTRA must be a string and replaces the `%s' specifier in the prefix format. @@ -4503,7 +4524,7 @@ Any match of REMOVE-RE will be removed from TXT." (and org-agenda-search-headline-for-time txt)))) (time-of-day (and dotime (org-get-time-of-day ts))) stamp plain s0 s1 s2 t1 t2 rtn srp l - duration) + duration thecategory) (and (org-mode-p) buffer-file-name (add-to-list 'org-agenda-contributing-files buffer-file-name)) (when (and dotime time-of-day) @@ -4583,24 +4604,29 @@ Any match of REMOVE-RE will be removed from TXT." (setq time (cond (s2 (concat s1 "-" s2)) (s1 (concat s1 "......")) (t "")) - extra (or extra "") - category (if (symbolp category) (symbol-name category) category)) - (when (string-match org-bracket-link-regexp category) - (setq l (if (match-end 3) - (- (match-end 3) (match-beginning 3)) - (- (match-end 1) (match-beginning 1)))) - (when (< l (or org-prefix-category-length 0)) - (setq category (copy-sequence category)) - (org-add-props category nil - 'extra-space (make-string - (- org-prefix-category-length l 1) ?\ )))) + extra (or (and (not habitp) extra) "") + category (if (symbolp category) (symbol-name category) category) + thecategory (copy-sequence category)) + (if (string-match org-bracket-link-regexp category) + (progn + (setq l (if (match-end 3) + (- (match-end 3) (match-beginning 3)) + (- (match-end 1) (match-beginning 1)))) + (when (< l (or org-prefix-category-length 0)) + (setq category (copy-sequence category)) + (org-add-props category nil + 'extra-space (make-string + (- org-prefix-category-length l 1) ?\ )))) + (if (and org-prefix-category-max-length + (>= (length category) org-prefix-category-max-length)) + (setq category (substring category 0 (1- org-prefix-category-max-length))))) ;; Evaluate the compiled format (setq rtn (concat (eval org-prefix-format-compiled) txt))) ;; And finally add the text properties (remove-text-properties 0 (length rtn) '(line-prefix t wrap-prefix t) rtn) (org-add-props rtn nil - 'org-category (downcase category) + 'org-category (if thecategory (downcase thecategory) category) 'tags (mapcar 'org-downcase-keep-props tags) 'org-highest-priority org-highest-priority 'org-lowest-priority org-lowest-priority @@ -4701,10 +4727,15 @@ The resulting form is returned and stored in the variable (if (equal var 'time) (setq org-prefix-has-time t)) (if (equal var 'tag) (setq org-prefix-has-tag t)) (if (equal var 'effort) (setq org-prefix-has-effort t)) - (if (equal var 'category) - (setq org-prefix-category-length - (abs (string-to-number (match-string 2 s))))) (setq f (concat "%" (match-string 2 s) "s")) + (when (equal var 'category) + (setq org-prefix-category-length + (floor (abs (string-to-number (match-string 2 s))))) + (setq org-prefix-category-max-length + (let ((x (match-string 2 s))) + (save-match-data + (if (string-match "\\.[0-9]+" x) + (string-to-number (substring (match-string 0 x) 1))))))) (if opt (setq varform `(if (equal "" ,var) @@ -4856,6 +4887,14 @@ HH:MM." ((< tb ta) +1) (t nil)))) +(defsubst org-cmp-habit-p (a b) + "Compare the todo states of strings A and B." + (let ((ha (get-text-property 1 'org-habit-p a)) + (hb (get-text-property 1 'org-habit-p b))) + (cond ((and ha (not hb)) -1) + ((and (not ha) hb) +1) + (t nil)))) + (defun org-entries-lessp (a b) "Predicate for sorting agenda entries." ;; The following variables will be used when the form is evaluated. @@ -4873,6 +4912,8 @@ HH:MM." (tag-down (if tag-up (- tag-up) nil)) (todo-state-up (org-cmp-todo-state a b)) (todo-state-down (if todo-state-up (- todo-state-up) nil)) + (habit-up (org-cmp-habit-p a b)) + (habit-down (if habit-up (- habit-up) nil)) user-defined-up user-defined-down) (if (and org-agenda-cmp-user-defined (functionp org-agenda-cmp-user-defined)) @@ -4886,7 +4927,7 @@ HH:MM." ;;; Agenda restriction lock (defvar org-agenda-restriction-lock-overlay (org-make-overlay 1 1) - "Overlay to mark the headline to which arenda commands are restricted.") + "Overlay to mark the headline to which agenda commands are restricted.") (org-overlay-put org-agenda-restriction-lock-overlay 'face 'org-agenda-restriction-lock) (org-overlay-put org-agenda-restriction-lock-overlay @@ -5044,22 +5085,26 @@ used to narrow the search - the interactive user can also press `-' or `+' to switch to narrowing." (interactive "P") (let* ((alist org-tag-alist-for-agenda) - (tag-chars (mapconcat - (lambda (x) (if (cdr x) (char-to-string (cdr x)) "")) - alist "")) - (efforts (org-split-string - (or (cdr (assoc (concat org-effort-property "_ALL") - org-global-properties)) - "0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00 8:00" ""))) - (effort-op org-agenda-filter-effort-default-operator) - (effort-prompt "") - (inhibit-read-only t) - (current org-agenda-filter) - char a n tag) + (tag-chars (mapconcat + (lambda (x) (if (and (not (symbolp (car x))) + (cdr x)) + (char-to-string (cdr x)) + "")) + alist "")) + (efforts (org-split-string + (or (cdr (assoc (concat org-effort-property "_ALL") + org-global-properties)) + "0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00 8:00" ""))) + (effort-op org-agenda-filter-effort-default-operator) + (effort-prompt "") + (inhibit-read-only t) + (current org-agenda-filter) + char a n tag) (unless char (message - "%s by tag [%s ], [TAB], [/]:off, [+-]:narrow, [>==?]" x) (setq f1 (org-agenda-filter-effort-form x)) (setq f1 (list 'member (downcase (substring x 1)) 'tags))) @@ -5489,6 +5545,8 @@ so that the date SD will be in that range." (interactive) (setq org-agenda-follow-mode (not org-agenda-follow-mode)) (org-agenda-set-mode-name) + (if (and org-agenda-follow-mode (org-get-at-bol 'org-marker)) + (org-agenda-show)) (message "Follow mode is %s" (if org-agenda-follow-mode "on" "off"))) @@ -5584,8 +5642,10 @@ When called with a prefix argument, include all archive files as well." (if org-agenda-entry-text-mode " ETxt" "") (if org-agenda-include-diary " Diary" "") (if org-agenda-use-time-grid " Grid" "") + (if (and (boundp 'org-habit-show-habits) + org-habit-show-habits) " Habit" "") (if (consp org-agenda-show-log) " LogAll" - (if org-agenda-show-log " Log" "")) + (if org-agenda-show-log " Log" "")) (if (or org-agenda-filter (get 'org-agenda-filter :preset-filter)) (concat " {" (mapconcat @@ -5606,9 +5666,20 @@ When called with a prefix argument, include all archive files as well." (setq org-agenda-type (or (get-text-property (point) 'org-agenda-type) (get-text-property (max (point-min) (1- (point))) - 'org-agenda-type))) - (if (and org-agenda-follow-mode - (org-get-at-bol 'org-marker)) + 'org-agenda-type)))) + +(defun org-agenda-next-line () + "Move cursor to the next line, and show if follow-mode is active." + (interactive) + (call-interactively 'next-line) + (if (and org-agenda-follow-mode (org-get-at-bol 'org-marker)) + (org-agenda-show))) +(defun org-agenda-previous-line () + "Move cursor to the previous line, and show if follow-mode is active." + + (interactive) + (call-interactively 'previous-line) + (if (and org-agenda-follow-mode (org-get-at-bol 'org-marker)) (org-agenda-show))) (defun org-agenda-show-priority () @@ -5684,25 +5755,30 @@ Point is in the buffer where the item originated.") (with-current-buffer buffer (delete-region dbeg dend)) (message "Agenda item and source killed")))) +(defvar org-archive-default-command) +(defun org-agenda-archive-default () + "Archive the entry or subtree belonging to the current agenda entry." + (interactive) + (require 'org-archive) + (org-agenda-archive-with org-archive-default-command)) + +(defun org-agenda-archive-default-with-confirmation () + "Archive the entry or subtree belonging to the current agenda entry." + (interactive) + (require 'org-archive) + (org-agenda-archive-with org-archive-default-command 'confirm)) + (defun org-agenda-archive () "Archive the entry or subtree belonging to the current agenda entry." (interactive) - (or (eq major-mode 'org-agenda-mode) (error "Not in agenda")) - (let* ((marker (or (org-get-at-bol 'org-marker) - (org-agenda-error))) - (buffer (marker-buffer marker)) - (pos (marker-position marker))) - (org-with-remote-undo buffer - (with-current-buffer buffer - (if (org-mode-p) - (save-excursion - (goto-char pos) - (org-remove-subtree-entries-from-agenda) - (org-back-to-heading t) - (org-archive-subtree)) - (error "Archiving works only in Org-mode files")))))) + (org-agenda-archive-with 'org-archive-subtree)) (defun org-agenda-archive-to-archive-sibling () + "Move the entry to the archive sibling." + (interactive) + (org-agenda-archive-with 'org-archive-to-archive-sibling)) + +(defun org-agenda-archive-with (cmd &optional confirm) "Move the entry to the archive sibling." (interactive) (or (eq major-mode 'org-agenda-mode) (error "Not in agenda")) @@ -5713,11 +5789,14 @@ Point is in the buffer where the item originated.") (org-with-remote-undo buffer (with-current-buffer buffer (if (org-mode-p) - (save-excursion - (goto-char pos) - (org-remove-subtree-entries-from-agenda) - (org-back-to-heading t) - (org-archive-to-archive-sibling)) + (if (and confirm + (not (y-or-n-p "Archive this subtree or entry? "))) + (error "Abort") + (save-excursion + (goto-char pos) + (org-remove-subtree-entries-from-agenda) + (org-back-to-heading t) + (funcall cmd))) (error "Archiving works only in Org-mode files")))))) (defun org-remove-subtree-entries-from-agenda (&optional buf beg end) @@ -5768,7 +5847,7 @@ If this information is not given, the function uses the tree at point." (defun org-agenda-open-link (&optional arg) "Follow the link in the current line, if any. -This looks for a link in the displayed lin in the agenda. It also looks +This looks for a link in the displayed line in the agenda. It also looks at the text of the entry itself." (interactive "P") (let* ((marker (or (org-get-at-bol 'org-hd-marker) @@ -5777,14 +5856,21 @@ at the text of the entry itself." (prefix (buffer-substring (point-at-bol) (+ (point-at-bol) - (org-get-at-bol 'prefix-length))))) - (unless buffer (error "Don't know where to look for links")) - (with-current-buffer buffer - (save-excursion - (save-restriction - (widen) - (goto-char marker) - (org-offer-links-in-entry arg prefix)))))) + (or (org-get-at-bol 'prefix-length) 0))))) + (cond + (buffer + (with-current-buffer buffer + (save-excursion + (save-restriction + (widen) + (goto-char marker) + (org-offer-links-in-entry arg prefix))))) + ((or (org-in-regexp (concat "\\(" org-bracket-link-regexp "\\)")) + (save-excursion + (beginning-of-line 1) + (looking-at (concat ".*?\\(" org-bracket-link-regexp "\\)")))) + (org-open-link-from-string (match-string 1))) + (t (error "No link to open here"))))) (defun org-agenda-copy-local-variable (var) "Get a variable from a referenced buffer and install it here." @@ -5796,19 +5882,23 @@ at the text of the entry itself." (defun org-agenda-switch-to (&optional delete-other-windows) "Go to the Org-mode file which contains the item at point." (interactive) - (let* ((marker (or (org-get-at-bol 'org-marker) - (org-agenda-error))) - (buffer (marker-buffer marker)) - (pos (marker-position marker))) - (switch-to-buffer buffer) - (and delete-other-windows (delete-other-windows)) - (widen) - (goto-char pos) - (when (org-mode-p) - (org-show-context 'agenda) - (save-excursion - (and (outline-next-heading) - (org-flag-heading nil)))))) ; show the next heading + (if (and org-return-follows-link + (not (org-get-at-bol 'org-marker)) + (org-in-regexp org-bracket-link-regexp)) + (org-open-link-from-string (match-string 0)) + (let* ((marker (or (org-get-at-bol 'org-marker) + (org-agenda-error))) + (buffer (marker-buffer marker)) + (pos (marker-position marker))) + (switch-to-buffer buffer) + (and delete-other-windows (delete-other-windows)) + (widen) + (goto-char pos) + (when (org-mode-p) + (org-show-context 'agenda) + (save-excursion + (and (outline-next-heading) + (org-flag-heading nil))))))) ; show the next heading (defun org-agenda-goto-mouse (ev) "Go to the Org-mode file which contains the item at the mouse click." @@ -5828,9 +5918,34 @@ if it was hidden in the outline." (org-agenda-goto t)) (select-window win))) +(defvar org-agenda-show-window nil) +(defun org-agenda-show-and-scroll-up () + "Display the Org-mode file which contains the item at point. +When called repeatedly, scroll the window that is displaying the buffer." + (interactive) + (let ((win (selected-window))) + (if (and (window-live-p org-agenda-show-window) + (eq this-command last-command)) + (progn + (select-window org-agenda-show-window) + (ignore-errors (scroll-up))) + (org-agenda-goto t) + (show-subtree) + (setq org-agenda-show-window (selected-window))) + (select-window win))) + +(defun org-agenda-show-scroll-down () + "Scroll down the window showing the agenda." + (interactive) + (let ((win (selected-window))) + (when (window-live-p org-agenda-show-window) + (select-window org-agenda-show-window) + (ignore-errors (scroll-down)) + (select-window win)))) + (defun org-agenda-show-1 (&optional more) "Display the Org-mode file which contains the item at point. -The prefix arg causes further revieling: +The prefix arg selects the amount of information to display: 0 hide the subtree 1 just show the entry according to defaults. @@ -6473,7 +6588,7 @@ The cursor may be at a date in the calendar, or in the Org agenda." (if current-buffer (eval form) (if (not (marker-buffer org-agenda-action-marker)) - (error "No entry has bee selected for agenda action") + (error "No entry has been selected for agenda action") (with-current-buffer (marker-buffer org-agenda-action-marker) (save-excursion (save-restriction @@ -6531,47 +6646,173 @@ The cursor may be at a date in the calendar, or in the Org agenda." (org-with-remote-undo (marker-buffer org-clock-marker) (org-clock-cancel))) +(defun org-agenda-diary-entry-in-org-file () + "Make a diary entry in the file `org-agenda-diary-file'." + (let (d1 d2 char (text "")) + (if (equal (buffer-name) "*Calendar*") + (setq d1 (calendar-cursor-to-date t) + d2 (car calendar-mark-ring)) + (setq d1 (calendar-gregorian-from-absolute + (get-text-property (point) 'day)) + d2 (and (mark) (get-text-property (mark) 'day) + (calendar-gregorian-from-absolute + (get-text-property (mark) 'day))))) + (message "Diary entry: [d]ay [a]nniversary [b]lock [j]ump to date tree") + (setq char (read-char-exclusive)) + (cond + ((equal char ?d) + (setq text (read-string "Day entry: ")) + (org-agenda-add-entry-to-org-agenda-diary-file 'day text d1)) + ((equal char ?a) + (setq d1 (list (car d1) (nth 1 d1) + (read-number (format "Reference year [%d]: " (nth 2 d1)) + (nth 2 d1)))) + (setq text (read-string "Anniversary (use %d to show years): ")) + (org-agenda-add-entry-to-org-agenda-diary-file 'anniversary text d1)) + ((equal char ?b) + (setq text (read-string "Block entry: ")) + (unless (and d1 d2 (not (equal d1 d2))) + (error "No block of days selected")) + (org-agenda-add-entry-to-org-agenda-diary-file 'block text d1 d2)) + ((equal char ?j) + (org-switch-to-buffer-other-window + (find-file-noselect org-agenda-diary-file)) + (org-datetree-find-date-create d1) + (org-reveal t)) + (t (error "Invalid selection character `%c'" char))))) + +(defun org-agenda-add-entry-to-org-agenda-diary-file (type text &optional d1 d2) + "Add a diary entry with TYPE to `org-agenda-diary-file'. +If TEXT is not empty, it will become the headline of the new entry, and +the resulting entry will not be shown. When TEXT is empty, switch to +`org-agenda-diary-file' and let the user finish the entry there." + (let ((cw (current-window-configuration))) + (org-switch-to-buffer-other-window + (find-file-noselect org-agenda-diary-file)) + (widen) + (goto-char (point-min)) + (cond + ((eq type 'anniversary) + (or (re-search-forward "^*[ \t]+Anniversaries" nil t) + (progn + (or (org-on-heading-p t) + (progn + (outline-next-heading) + (insert "* Anniversaries\n\n") + (beginning-of-line -1))))) + (outline-next-heading) + (org-back-over-empty-lines) + (backward-char 1) + (insert "\n") + (require 'diary-lib) + (let ((calendar-date-display-form + (if (if (boundp 'calendar-date-style) + (eq calendar-date-style 'european) + european-calendar-style) ; Emacs 22 + '(day " " month " " year) + '(month " " day " " year)))) + + (insert (format "%%%%(diary-anniversary %s) %s" + (calendar-date-string d1 nil t) text)))) + ((eq type 'day) + (require 'org-datetree) + (org-datetree-find-date-create d1) + (org-agenda-insert-diary-make-new-entry text) + (org-insert-time-stamp (org-time-from-absolute + (calendar-absolute-from-gregorian d1))) + (end-of-line 0)) + ((eq type 'block) + (if (> (calendar-absolute-from-gregorian d1) + (calendar-absolute-from-gregorian d2)) + (setq d1 (prog1 d2 (setq d2 d1)))) + (require 'org-datetree) + (org-datetree-find-date-create d1) + (org-agenda-insert-diary-make-new-entry text) + (org-insert-time-stamp (org-time-from-absolute + (calendar-absolute-from-gregorian d1))) + (insert "--") + (org-insert-time-stamp (org-time-from-absolute + (calendar-absolute-from-gregorian d2))) + (end-of-line 0))) + (if (string-match "\\S-" text) + (progn + (set-window-configuration cw) + (message "%s entry added to %s" + (capitalize (symbol-name type)) + (abbreviate-file-name org-agenda-diary-file))) + (org-reveal t) + (message "Please finish entry here")))) + +(defun org-agenda-insert-diary-make-new-entry (text) + "Make new entry as last child of current entry. +Add TEXT as headline, and position the cursor in the second line so that +a timestamp can be added there." + (let ((org-show-following-heading t) + (org-show-siblings t) + (org-show-hierarchy-above t) + (org-show-entry-below t) + col) + (outline-next-heading) + (org-back-over-empty-lines) + (or (looking-at "[ \t]*$") + (progn (insert "\n") (backward-char 1))) + (org-insert-heading) + (org-do-demote) + (setq col (current-column)) + (insert text "\n") + (if org-adapt-indentation (org-indent-to-column col)) + (let ((org-show-following-heading t) + (org-show-siblings t) + (org-show-hierarchy-above t) + (org-show-entry-below t)) + (org-show-context)))) + (defun org-agenda-diary-entry () "Make a diary entry, like the `i' command from the calendar. -All the standard commands work: block, weekly etc." +All the standard commands work: block, weekly etc. +When `org-agenda-diary-file' points to a file, +`org-agenda-diary-entry-in-org-file' is called instead to create +entries in that Org-mode file." (interactive) (org-agenda-check-type t 'agenda 'timeline) - (require 'diary-lib) - (let* ((char (progn - (message "Diary entry: [d]ay [w]eekly [m]onthly [y]early [a]nniversary [b]lock [c]yclic") - (read-char-exclusive))) - (cmd (cdr (assoc char - '((?d . insert-diary-entry) - (?w . insert-weekly-diary-entry) - (?m . insert-monthly-diary-entry) - (?y . insert-yearly-diary-entry) - (?a . insert-anniversary-diary-entry) - (?b . insert-block-diary-entry) - (?c . insert-cyclic-diary-entry))))) - (oldf (symbol-function 'calendar-cursor-to-date)) -; (buf (get-file-buffer (substitute-in-file-name diary-file))) - (point (point)) - (mark (or (mark t) (point)))) - (unless cmd - (error "No command associated with <%c>" char)) - (unless (and (get-text-property point 'day) - (or (not (equal ?b char)) - (get-text-property mark 'day))) - (error "Don't know which date to use for diary entry")) - ;; We implement this by hacking the `calendar-cursor-to-date' function - ;; and the `calendar-mark-ring' variable. Saves a lot of code. - (let ((calendar-mark-ring - (list (calendar-gregorian-from-absolute - (or (get-text-property mark 'day) - (get-text-property point 'day)))))) - (unwind-protect - (progn - (fset 'calendar-cursor-to-date - (lambda (&optional error dummy) - (calendar-gregorian-from-absolute - (get-text-property point 'day)))) + (if (not (eq org-agenda-diary-file 'diary-file)) + (org-agenda-diary-entry-in-org-file) + (require 'diary-lib) + (let* ((char (progn + (message "Diary entry: [d]ay [w]eekly [m]onthly [y]early [a]nniversary [b]lock [c]yclic") + (read-char-exclusive))) + (cmd (cdr (assoc char + '((?d . insert-diary-entry) + (?w . insert-weekly-diary-entry) + (?m . insert-monthly-diary-entry) + (?y . insert-yearly-diary-entry) + (?a . insert-anniversary-diary-entry) + (?b . insert-block-diary-entry) + (?c . insert-cyclic-diary-entry))))) + (oldf (symbol-function 'calendar-cursor-to-date)) + ;; (buf (get-file-buffer (substitute-in-file-name diary-file))) + (point (point)) + (mark (or (mark t) (point)))) + (unless cmd + (error "No command associated with <%c>" char)) + (unless (and (get-text-property point 'day) + (or (not (equal ?b char)) + (get-text-property mark 'day))) + (error "Don't know which date to use for diary entry")) + ;; We implement this by hacking the `calendar-cursor-to-date' function + ;; and the `calendar-mark-ring' variable. Saves a lot of code. + (let ((calendar-mark-ring + (list (calendar-gregorian-from-absolute + (or (get-text-property mark 'day) + (get-text-property point 'day)))))) + (unwind-protect + (progn + (fset 'calendar-cursor-to-date + (lambda (&optional error dummy) + (calendar-gregorian-from-absolute + (get-text-property point 'day)))) (call-interactively cmd)) - (fset 'calendar-cursor-to-date oldf))))) + (fset 'calendar-cursor-to-date oldf)))))) (defun org-agenda-execute-calendar-command (cmd) "Execute a calendar command from the agenda, with the date associated to @@ -6870,7 +7111,7 @@ tag and (if present) the flagging note." (message "Flagging note pushed to kill ring. Press [?] again to remove tag and note")))) (defun org-agenda-remove-flag (marker) - "Remove the FLAGGED tag and any flaging note in the entry." + "Remove the FLAGGED tag and any flagging note in the entry." (let (newhead) (org-with-point-at marker (org-toggle-tag "FLAGGED" 'off) diff --git a/lisp/org/org-archive.el b/lisp/org/org-archive.el index 88bc82f158..3cc438c853 100644 --- a/lisp/org/org-archive.el +++ b/lisp/org/org-archive.el @@ -6,7 +6,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; @@ -35,8 +35,7 @@ (declare-function org-inlinetask-remove-END-maybe "org-inlinetask" ()) (defcustom org-archive-default-command 'org-archive-subtree - "The default archiving command. -Currently this is only used by org-mobile.el." + "The default archiving command." :group 'org-archive :type '(choice (const org-archive-subtree) @@ -50,7 +49,7 @@ See `org-archive-to-archive-sibling' for more information." :group 'org-archive :type 'string) -(defcustom org-archive-mark-done t +(defcustom org-archive-mark-done nil "Non-nil means, mark entries as DONE when they are moved to the archive file. This can be a string to set the keyword to use. When t, Org-mode will use the first keyword in its list that means done." @@ -304,12 +303,7 @@ this heading." ;; Save and kill the buffer, if it is not the same buffer. (when (not (eq this-buffer buffer)) - (save-buffer) - ;; Check if it is OK to kill the buffer - (unless - (or visiting - (equal (marker-buffer org-clock-marker) (current-buffer))) - (kill-buffer buffer))) + (save-buffer)) )) ;; Here we are back in the original buffer. Everything seems to have ;; worked. So now cut the tree and finish up. @@ -447,7 +441,15 @@ the children that do not contain any open TODO items." "Archive the current subtree with the default command. This command is set with the variable `org-archive-default-command'." (interactive) - (call-interactively 'org-archive-default-command)) + (call-interactively org-archive-default-command)) + +(defun org-archive-subtree-default-with-confirmation () + "Archive the current subtree with the default command. +This command is set with the variable `org-archive-default-command'." + (interactive) + (if (y-or-n-p "Archive this subtree or entry? ") + (call-interactively org-archive-default-command) + (error "Abort"))) (provide 'org-archive) diff --git a/lisp/org/org-ascii.el b/lisp/org/org-ascii.el index f66f441d01..c4a2cedf2c 100644 --- a/lisp/org/org-ascii.el +++ b/lisp/org/org-ascii.el @@ -6,7 +6,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; @@ -58,6 +58,13 @@ in this way, it will be wrapped." :group 'org-export-ascii :type 'boolean) +(defcustom org-export-ascii-table-keep-all-vertical-lines nil + "Non-nil means, keep all vertical lines in ASCII tables. +When nil, vertical lines will be removed except for those needed +for column grouping." + :group 'org-export-ascii + :type 'boolean) + ;;; Hooks (defvar org-export-ascii-final-hook nil @@ -120,7 +127,7 @@ in a window. A non-interactive call will only return the buffer." (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)) + (setq ext-plist (plist-put ext-plist :ignore-subtree-p t)) (goto-char end) (set-mark (point)) ;; to activate the region (goto-char beg) @@ -157,7 +164,7 @@ publishing directory." (rbeg (and region-p (region-beginning))) (rend (and region-p (region-end))) (subtree-p - (if (plist-get opt-plist :ignore-subree-p) + (if (plist-get opt-plist :ignore-subtree-p) nil (when region-p (save-excursion @@ -585,18 +592,20 @@ publishing directory." ;; 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)))) + (if org-export-ascii-table-keep-all-vertical-lines + lines + (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) diff --git a/lisp/org/org-attach.el b/lisp/org/org-attach.el index a51a097fd3..12c9133031 100644 --- a/lisp/org/org-attach.el +++ b/lisp/org/org-attach.el @@ -4,7 +4,7 @@ ;; Author: John Wiegley ;; Keywords: org data task -;; Version: 6.31a +;; Version: 6.33 ;; This file is part of GNU Emacs. ;; @@ -209,7 +209,7 @@ the directory and (if necessary) the corresponding ID will be created." attach-dir)))) (defun org-attach-check-absolute-path (dir) - "Check if we have enough information to root the atachment directory. + "Check if we have enough information to root the attachment directory. When DIR is given, check also if it is already absolute. Otherwise, assume that it will be relative, and check if `org-attach-directory' is absolute, or if at least the current buffer has a file name. @@ -365,11 +365,11 @@ This ignores files starting with a \".\", and files ending in \"~\"." (mapcar (lambda (x) (if (string-match "^\\." x) nil x)) (directory-files dir nil "[^~]\\'")))) -(defun org-attach-reveal () +(defun org-attach-reveal (&optional if-exists) "Show the attachment directory of the current task in dired." - (interactive) - (let ((attach-dir (org-attach-dir t))) - (org-open-file attach-dir))) + (interactive "P") + (let ((attach-dir (org-attach-dir (not if-exists)))) + (and attach-dir (org-open-file attach-dir)))) (defun org-attach-reveal-in-emacs () "Show the attachment directory of the current task. diff --git a/lisp/org/org-bbdb.el b/lisp/org/org-bbdb.el index 47d1eed6fd..6d9a7788a5 100644 --- a/lisp/org/org-bbdb.el +++ b/lisp/org/org-bbdb.el @@ -7,7 +7,7 @@ ;; Thomas Baumann ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; @@ -64,7 +64,7 @@ ;; ;; - 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 +;; defines the format string for this class ;; - the (format) string displayed in the diary. ;; ;; You can enter multiple anniversaries for a single BBDB record by diff --git a/lisp/org/org-bibtex.el b/lisp/org/org-bibtex.el index 3b34e7dd8c..44299e5e03 100644 --- a/lisp/org/org-bibtex.el +++ b/lisp/org/org-bibtex.el @@ -5,7 +5,7 @@ ;; Author: Bastien Guerry ;; Carsten Dominik ;; Keywords: org, wp, remember -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; @@ -78,7 +78,7 @@ ;; ;; Creating better remember template information was inspired by a request ;; of Austin Frank: http://article.gmane.org/gmane.emacs.orgmode/4112 -;; and then imlemented by Bastien Guerry. +;; and then implemented by Bastien Guerry. ;; ;; Org-mode loads this module by default - if this is not what you want, ;; configure the variable `org-modules'. @@ -189,8 +189,8 @@ ;; Restore the window configuration because we just use the web link (set-window-configuration org-window-config-before-follow-link) (with-current-buffer b - (goto-char p) - (bibtex-url))) + (goto-char p) + (bibtex-url))) (recenter 0)) ; Move entry start to beginning of window ;; return t to indicate that the search is done. t)) diff --git a/lisp/org/org-clock.el b/lisp/org/org-clock.el index 6cd39b1ea7..ddb0424ef4 100644 --- a/lisp/org/org-clock.el +++ b/lisp/org/org-clock.el @@ -6,7 +6,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; @@ -142,6 +142,7 @@ All this depends on running `org-clock-persistence-insinuate' in .emacs" :group 'org-clock :type '(choice (const :tag "Just the running clock" clock) + (const :tag "Just the history" history) (const :tag "Clock and history" t) (const :tag "No persistence" nil))) @@ -180,10 +181,10 @@ 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 +today All time clocked into 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" +auto Automatically, either `all', or `repeat' for repeating tasks" :group 'org-clock :type '(choice (const :tag "Current clock" current) @@ -206,6 +207,20 @@ string as argument." :group 'org-clock :type 'plist) +(defcustom org-clock-idle-time nil + "When non-nil, resolve open clocks if the user is idle more than X minutes." + :group 'org-clock + :type '(choice + (const :tag "Never" nil) + (integer :tag "After N minutes"))) + +(defcustom org-clock-auto-clock-resolution 'when-no-clock-is-running + "When to automatically resolve open clocks found in Org buffers." + :group 'org-clock + :type '(choice + (const :tag "Never" nil) + (const :tag "Always" t) + (const :tag "When no clock is running" when-no-clock-is-running))) (defvar org-clock-in-prepare-hook nil "Hook run when preparing the clock. @@ -221,6 +236,8 @@ to add an effort property.") "Hook run when cancelling the current clock.") (defvar org-clock-goto-hook nil "Hook run when selecting the currently clocked-in entry.") +(defvar org-clock-has-been-used nil + "Has the clock been used during the current Emacs session?") ;;; The clock for measuring work time. @@ -228,10 +245,14 @@ to add an effort property.") (put 'org-mode-line-string 'risky-local-variable t) (defvar org-clock-mode-line-timer nil) -(defvar org-clock-heading "") +(defvar org-clock-idle-timer nil) +(defvar org-clock-heading) ; defined in org.el (defvar org-clock-heading-for-remember "") (defvar org-clock-start-time "") +(defvar org-clock-left-over-time nil + "If non-nil, user cancelled a clock; this is when leftover time started.") + (defvar org-clock-effort "" "Effort estimate of the currently clocking task") @@ -402,8 +423,8 @@ previous clocking intervals." (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 +VALUE can be a number of minutes, or a string with format hh:mm or mm. +When the string starts with a + or a - sign, the current value of the effort property will be changed by that amount. This will update the \"Effort\" property of currently clocked item, and the mode line." @@ -470,7 +491,7 @@ use libnotify if available, or fall back on a message." "notify-send" notification)) ;; Maybe the handler will send a message, so only use message as ;; a fall back option - (t (message notification)))) + (t (message "%s" notification)))) (defun org-clock-play-sound () "Play sound as configured by `org-clock-sound'. @@ -479,13 +500,14 @@ Use alsa's aplay tool if available." ((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)))))))) + (let ((file (expand-file-name org-clock-sound))) + (if (file-exists-p file) + (if (org-program-exists "aplay") + (start-process "org-clock-play-notification" nil + "aplay" file) + (condition-case nil + (play-sound-file file) + (error (beep t) (beep t))))))))) (defun org-program-exists (program-name) "Checks whenever we can locate program and launch it." @@ -495,6 +517,303 @@ Use alsa's aplay tool if available." (defvar org-clock-mode-line-entry nil "Information for the modeline about the running clock.") +(defun org-find-open-clocks (file) + "Search through the given file and find all open clocks." + (let ((buf (or (get-file-buffer file) + (find-file-noselect file))) + clocks) + (with-current-buffer buf + (save-excursion + (goto-char (point-min)) + (while (re-search-forward "CLOCK: \\(\\[.*?\\]\\)$" nil t) + (push (cons (copy-marker (1- (match-end 1)) t) + (org-time-string-to-time (match-string 1))) clocks)))) + clocks)) + +(defsubst org-is-active-clock (clock) + "Return t if CLOCK is the currently active clock." + (and (org-clock-is-active) + (= org-clock-marker (car clock)))) + +(defmacro org-with-clock-position (clock &rest forms) + "Evaluate FORMS with CLOCK as the current active clock." + `(with-current-buffer (marker-buffer (car ,clock)) + (save-excursion + (save-restriction + (widen) + (goto-char (car ,clock)) + (beginning-of-line) + ,@forms)))) + +(put 'org-with-clock-position 'lisp-indent-function 1) + +(defmacro org-with-clock (clock &rest forms) + "Evaluate FORMS with CLOCK as the current active clock. +This macro also protects the current active clock from being altered." + `(org-with-clock-position ,clock + (let ((org-clock-start-time (cdr ,clock)) + (org-clock-total-time) + (org-clock-history) + (org-clock-effort) + (org-clock-marker (car ,clock)) + (org-clock-hd-marker (save-excursion + (outline-back-to-heading t) + (point-marker)))) + ,@forms))) + +(put 'org-with-clock 'lisp-indent-function 1) + +(defsubst org-clock-clock-in (clock &optional resume) + "Clock in to the clock located by CLOCK. +If necessary, clock-out of the currently active clock." + (org-with-clock-position clock + (let ((org-clock-in-resume (or resume org-clock-in-resume))) + (org-clock-in)))) + +(defsubst org-clock-clock-out (clock &optional fail-quietly at-time) + "Clock out of the clock located by CLOCK." + (let ((temp (copy-marker (car clock) + (marker-insertion-type (car clock))))) + (if (org-is-active-clock clock) + (org-clock-out fail-quietly at-time) + (org-with-clock clock + (org-clock-out fail-quietly at-time))) + (setcar clock temp))) + +(defsubst org-clock-clock-cancel (clock) + "Cancel the clock located by CLOCK." + (let ((temp (copy-marker (car clock) + (marker-insertion-type (car clock))))) + (if (org-is-active-clock clock) + (org-clock-cancel) + (org-with-clock clock + (org-clock-cancel))) + (setcar clock temp))) + +(defvar org-clock-clocking-in nil) +(defvar org-clock-resolving-clocks nil) +(defvar org-clock-resolving-clocks-due-to-idleness nil) + +(defun org-clock-resolve-clock (clock resolve-to &optional close-p + restart-p fail-quietly) + "Resolve `CLOCK' given the time `RESOLVE-TO', and the present. +`CLOCK' is a cons cell of the form (MARKER START-TIME). +This routine can do one of many things: + + if `RESOLVE-TO' is nil + if `CLOSE-P' is non-nil, give an error + if this clock is the active clock, cancel it + else delete the clock line (as if it never happened) + if `RESTART-P' is non-nil, start a new clock + + else if `RESOLVE-TO' is the symbol `now' + if `RESTART-P' is non-nil, give an error + if `CLOSE-P' is non-nil, clock out the entry and + if this clock is the active clock, stop it + else if this clock is the active clock, do nothing + else if there is no active clock, resume this clock + else ask to cancel the active clock, and if so, + resume this clock after cancelling it + + else if `RESOLVE-TO' is some date in the future + give an error about `RESOLVE-TO' being invalid + + else if `RESOLVE-TO' is some date in the past + if `RESTART-P' is non-nil, give an error + if `CLOSE-P' is non-nil, enter a closing time and + if this clock is the active clock, stop it + else if this clock is the active clock, enter a + closing time, stop the current clock, then + start a new clock for the same item + else just enter a closing time for this clock + and then start a new clock for the same item" + (let ((org-clock-resolving-clocks t)) + (cond + ((null resolve-to) + (org-clock-clock-cancel clock) + (if (and restart-p (not org-clock-clocking-in)) + (org-clock-clock-in clock))) + + ((eq resolve-to 'now) + (if restart-p + (error "RESTART-P is not valid here")) + (if (or close-p org-clock-clocking-in) + (org-clock-clock-out clock fail-quietly) + (unless (org-is-active-clock clock) + (org-clock-clock-in clock t)))) + + ((not (time-less-p resolve-to (current-time))) + (error "RESOLVE-TO must refer to a time in the past")) + + (t + (if restart-p + (error "RESTART-P is not valid here")) + (org-clock-clock-out clock fail-quietly resolve-to) + (unless org-clock-clocking-in + (if close-p + (setq org-clock-left-over-time resolve-to) + (org-clock-clock-in clock))))))) + +(defun org-clock-resolve (clock &optional prompt-fn last-valid fail-quietly) + "Resolve an open org-mode clock. +An open clock was found, with `dangling' possibly being non-nil. +If this function was invoked with a prefix argument, non-dangling +open clocks are ignored. The given clock requires some sort of +user intervention to resolve it, either because a clock was left +dangling or due to an idle timeout. The clock resolution can +either be: + + (a) deleted, the user doesn't care about the clock + (b) restarted from the current time (if no other clock is open) + (c) closed, giving the clock X minutes + (d) closed and then restarted + (e) resumed, as if the user had never left + +The format of clock is (CONS MARKER START-TIME), where MARKER +identifies the buffer and position the clock is open at (and +thus, the heading it's under), and START-TIME is when the clock +was started." + (assert clock) + (let* ((ch + (save-window-excursion + (save-excursion + (unless org-clock-resolving-clocks-due-to-idleness + (org-with-clock clock + (org-clock-goto)) + (with-current-buffer (marker-buffer (car clock)) + (goto-char (car clock)) + (if org-clock-into-drawer + (ignore-errors + (outline-flag-region (save-excursion + (outline-back-to-heading t) + (search-forward ":LOGBOOK:") + (goto-char (match-beginning 0))) + (save-excursion + (outline-back-to-heading t) + (search-forward ":LOGBOOK:") + (search-forward ":END:") + (goto-char (match-end 0))) + nil))))) + (let (char-pressed) + (while (null char-pressed) + (setq char-pressed + (read-char (concat (funcall prompt-fn clock) + " [(kK)eep (sS)ubtract (C)ancel]? ") + nil 45))) + char-pressed)))) + (default (floor (/ (org-float-time + (time-subtract (current-time) last-valid)) 60))) + (keep (and (memq ch '(?k ?K)) + (read-number "Keep how many minutes? " default))) + (subtractp (memq ch '(?s ?S))) + (barely-started-p (< (- (org-float-time last-valid) + (org-float-time (cdr clock))) 45)) + (start-over (and subtractp barely-started-p))) + (if (or (null ch) + (not (memq ch '(?k ?K ?s ?S ?C)))) + (message "") + (org-clock-resolve-clock + clock (cond + ((or (eq ch ?C) + ;; If the time on the clock was less than a minute before + ;; the user went away, and they've ask to subtract all the + ;; time... + start-over) + nil) + (subtractp + last-valid) + ((= keep default) + 'now) + (t + (time-add last-valid (seconds-to-time (* 60 keep))))) + (memq ch '(?K ?S)) + (and start-over + (not (memq ch '(?K ?S ?C)))) + fail-quietly)))) + +(defun org-resolve-clocks (&optional also-non-dangling-p prompt-fn last-valid) + "Resolve all currently open org-mode clocks. +If `also-non-dangling-p' is non-nil, also ask to resolve +non-dangling (i.e., currently open and valid) clocks." + (interactive "P") + (unless org-clock-resolving-clocks + (let ((org-clock-resolving-clocks t)) + (dolist (file (org-files-list)) + (let ((clocks (org-find-open-clocks file))) + (dolist (clock clocks) + (let ((dangling (or (not (org-clock-is-active)) + (/= (car clock) org-clock-marker)))) + (unless (and (not dangling) (not also-non-dangling-p)) + (org-clock-resolve + clock + (or prompt-fn + (function + (lambda (clock) + (format + "Dangling clock started %d mins ago" + (floor + (/ (- (org-float-time (current-time)) + (org-float-time (cdr clock))) 60)))))) + (or last-valid + (cdr clock))))))))))) + +(defun org-emacs-idle-seconds () + "Return the current Emacs idle time in seconds, or nil if not idle." + (let ((idle-time (current-idle-time))) + (if idle-time + (org-float-time idle-time) + 0))) + +(defun org-mac-idle-seconds () + "Return the current Mac idle time in seconds" + (string-to-number (shell-command-to-string "ioreg -c IOHIDSystem | perl -ane 'if (/Idle/) {$idle=(pop @F)/1000000000; print $idle; last}'"))) + +(defun org-x11-idle-seconds () + "Return the current X11 idle time in seconds" + (/ (string-to-number (shell-command-to-string "x11idle")) 1000)) + +(defun org-user-idle-seconds () + "Return the number of seconds the user has been idle for. +This routine returns a floating point number." + (if (or (eq system-type 'darwin) (eq window-system 'x)) + (let ((emacs-idle (org-emacs-idle-seconds))) + ;; If Emacs has been idle for longer than the user's + ;; `org-clock-idle-time' value, check whether the whole system has + ;; really been idle for that long. + (if (> emacs-idle (* 60 org-clock-idle-time)) + (min emacs-idle (if (eq system-type 'darwin) + (org-mac-idle-seconds) + (org-x11-idle-seconds))) + emacs-idle)) + (org-emacs-idle-seconds))) + +(defvar org-clock-user-idle-seconds) + +(defun org-resolve-clocks-if-idle () + "Resolve all currently open org-mode clocks. +This is performed after `org-clock-idle-time' minutes, to check +if the user really wants to stay clocked in after being idle for +so long." + (when (and org-clock-idle-time (not org-clock-resolving-clocks) + org-clock-marker) + (let ((org-clock-user-idle-seconds (org-user-idle-seconds)) + (org-clock-user-idle-start + (time-subtract (current-time) + (seconds-to-time org-clock-user-idle-seconds))) + (org-clock-resolving-clocks-due-to-idleness t)) + (if (> org-clock-user-idle-seconds (* 60 org-clock-idle-time)) + (org-clock-resolve + (cons org-clock-marker + org-clock-start-time) + (function + (lambda (clock) + (format "Clocked in & idle for %.1f mins" + (/ (org-float-time + (time-subtract (current-time) + org-clock-user-idle-start)) + 60.0)))) + org-clock-user-idle-start))))) + (defun org-clock-in (&optional select) "Start the clock on the current item. If necessary, clock-out of the currently active clock. @@ -505,8 +824,19 @@ 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 (msg-extra "")) + (let ((interrupting (and (not org-clock-resolving-clocks-due-to-idleness) + (marker-buffer org-clock-marker))) + ts selected-task target-pos (msg-extra "") + (left-over (and (not org-clock-resolving-clocks) + org-clock-left-over-time))) + (when (and org-clock-auto-clock-resolution + (or (not interrupting) + (eq t org-clock-auto-clock-resolution)) + (not org-clock-clocking-in) + (not org-clock-resolving-clocks)) + (setq org-clock-left-over-time nil) + (let ((org-clock-clocking-in t)) + (org-resolve-clocks))) ; check if any clocks are dangling (when (equal select '(4)) (setq selected-task (org-clock-select-task "Clock-in on task: ")) (if selected-task @@ -519,12 +849,16 @@ the clocking selection, associated with the letter `d'." (marker-position org-clock-marker) (marker-buffer org-clock-marker)) (org-clock-out t)) - + (when (equal select '(16)) ;; Mark as default clocking task (org-clock-mark-default-task)) - - (setq target-pos (point)) ;; we want to clock in at this location + + ;; Clock in at which position? + (setq target-pos + (if (and (eobp) (not (org-on-heading-p))) + (point-at-bol 0) + (point))) (run-hooks 'org-clock-in-prepare-hook) (save-excursion (when (and selected-task (marker-buffer selected-task)) @@ -600,20 +934,37 @@ the clocking selection, associated with the letter `d'." (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 org-clock-start-time + (or (and left-over + (y-or-n-p + (format + "You stopped another clock %d mins ago; start this one from then? " + (/ (- (org-float-time (current-time)) + (org-float-time left-over)) 60))) + left-over) + (current-time))) (setq ts (org-insert-time-stamp org-clock-start-time 'with-hm 'inactive)))) (move-marker org-clock-marker (point) (buffer-base-buffer)) (move-marker org-clock-hd-marker (save-excursion (org-back-to-heading t) (point)) (buffer-base-buffer)) + (setq org-clock-has-been-used t) (or global-mode-string (setq global-mode-string '(""))) (or (memq 'org-mode-line-string global-mode-string) (setq global-mode-string (append global-mode-string '(org-mode-line-string)))) (org-clock-update-mode-line) + (when org-clock-mode-line-timer + (cancel-timer org-clock-mode-line-timer) + (setq org-clock-mode-line-timer nil)) (setq org-clock-mode-line-timer (run-with-timer 60 60 'org-clock-update-mode-line)) + (when org-clock-idle-timer + (cancel-timer org-clock-idle-timer) + (setq org-clock-idle-timer nil)) + (setq org-clock-idle-timer + (run-with-timer 60 60 'org-resolve-clocks-if-idle)) (message "Clock starts at %s - %s" ts msg-extra) (run-hooks 'org-clock-in-hook))))))) @@ -744,7 +1095,7 @@ line and position cursor in that line." (and (re-search-forward org-property-end-re nil t) (goto-char (match-beginning 0)))))))) -(defun org-clock-out (&optional fail-quietly) +(defun org-clock-out (&optional fail-quietly at-time) "Stop the currently running clock. If there is no running clock, throw an error, unless FAIL-QUIETLY is set." (interactive) @@ -752,7 +1103,8 @@ If there is no running clock, throw an error, unless FAIL-QUIETLY is set." (if (not (marker-buffer org-clock-marker)) (if fail-quietly (throw 'exit t) (error "No active clock"))) (let (ts te s h m remove) - (with-current-buffer (marker-buffer org-clock-marker) + (save-excursion + (set-buffer (marker-buffer org-clock-marker)) (save-restriction (widen) (goto-char org-clock-marker) @@ -764,7 +1116,8 @@ If there is no running clock, throw an error, unless FAIL-QUIETLY is set." (goto-char (match-end 0)) (delete-region (point) (point-at-eol)) (insert "--") - (setq te (org-insert-time-stamp (current-time) 'with-hm 'inactive)) + (setq te (org-insert-time-stamp (or at-time (current-time)) + 'with-hm 'inactive)) (setq s (- (org-float-time (apply 'encode-time (org-parse-time-string te))) (org-float-time (apply 'encode-time (org-parse-time-string ts)))) h (floor (/ s 3600)) @@ -786,6 +1139,9 @@ If there is no running clock, throw an error, unless FAIL-QUIETLY is set." (when org-clock-mode-line-timer (cancel-timer org-clock-mode-line-timer) (setq org-clock-mode-line-timer nil)) + (when org-clock-idle-timer + (cancel-timer org-clock-idle-timer) + (setq org-clock-idle-timer nil)) (setq global-mode-string (delq 'org-mode-line-string global-mode-string)) (when org-clock-out-switch-to-state @@ -813,11 +1169,14 @@ If there is no running clock, throw an error, unless FAIL-QUIETLY is set." (interactive) (if (not (marker-buffer org-clock-marker)) (error "No active clock")) - (with-current-buffer (marker-buffer org-clock-marker) + (save-excursion + (set-buffer (marker-buffer org-clock-marker)) (goto-char org-clock-marker) - (delete-region (1- (point-at-bol)) (point-at-eol))) - (move-marker 'org-clock-marker nil) - (move-marker 'org-clock-hd-marker nil) + (delete-region (1- (point-at-bol)) (point-at-eol)) + ;; Just in case, remove any empty LOGBOOK left over + (org-remove-empty-drawer-at "LOGBOOK" (point))) + (move-marker org-clock-marker nil) + (move-marker org-clock-hd-marker nil) (setq global-mode-string (delq 'org-mode-line-string global-mode-string)) (force-mode-line-update) @@ -940,7 +1299,12 @@ in the echo area." (when org-remove-highlights-with-change (org-add-hook 'before-change-functions 'org-clock-remove-overlays nil 'local)))) - (message (concat "Total file time: " org-time-clocksum-format " (%d hours and %d minutes)") h m h m))) + (if org-time-clocksum-use-fractional + (message (concat "Total file time: " org-time-clocksum-fractional-format + " (%d hours and %d minutes)") + (/ (+ (* h 60.0) m) 60.0) h m) + (message (concat "Total file time: " org-time-clocksum-format + " (%d hours and %d minutes)") h m h m)))) (defvar org-clock-overlays nil) (make-variable-buffer-local 'org-clock-overlays) @@ -952,7 +1316,9 @@ This creates a new overlay and stores it in `org-clock-overlays', so that it will be easy to remove." (let* ((c 60) (h (floor (/ time 60))) (m (- time (* 60 h))) (l (if level (org-get-valid-level level 0) 0)) - (fmt (concat "%s " org-time-clocksum-format "%s")) + (fmt (concat "%s " (if org-time-clocksum-use-fractional + org-time-clocksum-fractional-format + org-time-clocksum-format) "%s")) (off 0) ov tx) (org-move-to-column c) @@ -961,9 +1327,14 @@ will be easy to remove." (setq ov (org-make-overlay (1- (point)) (point-at-eol)) tx (concat (buffer-substring (1- (point)) (point)) (make-string (+ off (max 0 (- c (current-column)))) ?.) - (org-add-props (format fmt - (make-string l ?*) h m - (make-string (- 16 l) ?\ )) + (org-add-props (if org-time-clocksum-use-fractional + (format fmt + (make-string l ?*) + (/ (+ (* h 60.0) m) 60.0) + (make-string (- 16 l) ?\ )) + (format fmt + (make-string l ?*) h m + (make-string (- 16 l) ?\ ))) (list 'face 'org-clock-overlay)) "")) (if (not (featurep 'xemacs)) @@ -1462,11 +1833,17 @@ This function is made for clock tables." tot)))) 0)))) +(defvar org-clock-loaded nil + "Was the clock file loaded?") + (defun org-clock-save () "Persist various clock-related data to disk. The details of what will be saved are regulated by the variable `org-clock-persist'." - (when org-clock-persist + (when (and org-clock-persist + (or org-clock-loaded + org-clock-has-been-used + (not (file-exists-p org-clock-persist-file)))) (let (b) (with-current-buffer (find-file (expand-file-name org-clock-persist-file)) (progn @@ -1475,7 +1852,8 @@ The details of what will be saved are regulated by the variable (insert (format ";; org-persist.el - %s at %s\n" system-name (format-time-string (cdr org-time-stamp-formats)))) - (if (and (setq b (marker-buffer org-clock-marker)) + (if (and (memq org-clock-persist '(t clock)) + (setq b (marker-buffer org-clock-marker)) (setq b (or (buffer-base-buffer b) b)) (buffer-live-p b) (buffer-file-name b) @@ -1489,7 +1867,8 @@ The details of what will be saved are regulated by the variable "))\n")) ;; Store clocked task history. Tasks are stored reversed to make ;; reading simpler - (when (and org-clock-history (eq org-clock-persist t)) + (when (and (memq org-clock-persist '(t history)) + org-clock-history) (insert "(setq stored-clock-history '(" (mapconcat @@ -1505,9 +1884,6 @@ The details of what will be saved are regulated by the variable (save-buffer) (kill-buffer (current-buffer))))))) -(defvar org-clock-loaded nil - "Was the clock file loaded?") - (defun org-clock-load () "Load clock-related data from disk, maybe resuming a stored clock." (when (and org-clock-persist (not org-clock-loaded)) @@ -1545,9 +1921,10 @@ The details of what will be saved are regulated by the variable (when (file-exists-p (car resume-clock)) (with-current-buffer (find-file (car resume-clock)) (goto-char (cdr resume-clock)) - (org-clock-in) - (if (org-invisible-p) - (org-show-context))))))))) + (let ((org-clock-auto-clock-resolution nil)) + (org-clock-in) + (if (org-invisible-p) + (org-show-context)))))))))) ;;;###autoload (defun org-clock-persistence-insinuate () diff --git a/lisp/org/org-colview.el b/lisp/org/org-colview.el index 3dbb9140d0..dfe006b805 100644 --- a/lisp/org/org-colview.el +++ b/lisp/org/org-colview.el @@ -6,7 +6,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; @@ -34,6 +34,7 @@ (require 'org) (declare-function org-agenda-redo "org-agenda" ()) +(declare-function org-agenda-show "org-agenda" (&optional full-entry)) ;;; Column View @@ -91,14 +92,22 @@ This is the compiled version of the format.") (beginning-of-line 2) (while (and (org-invisible-p2) (not (eobp))) (beginning-of-line 2)) - (move-to-column col)))) + (move-to-column col) + (if (and (eq major-mode 'org-agenda-mode) + (org-bound-and-true-p org-agenda-follow-mode) + (org-get-at-bol 'org-marker)) + (org-agenda-show))))) (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)))) + (move-to-column col) + (if (and (eq major-mode 'org-agenda-mode) + (org-bound-and-true-p org-agenda-follow-mode) + (org-get-at-bol 'org-marker)) + (org-agenda-show))))) (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) @@ -111,8 +120,8 @@ This is the compiled version of the format.") (org-defkey org-columns-map [(shift meta left)] 'org-columns-delete) (dotimes (i 10) (org-defkey org-columns-map (number-to-string i) - `(lambda () (interactive) - (org-columns-next-allowed-value nil ,i)))) + `(lambda () (interactive) + (org-columns-next-allowed-value nil ,i)))) (easy-menu-define org-columns-menu org-columns-map "Org Column Menu" '("Column" @@ -165,7 +174,7 @@ This is the compiled version of the format.") (face1 (list color 'org-agenda-column-dateline ref-face)) (pl (or (get-text-property (point-at-bol) 'prefix-length) 0)) (cphr (get-text-property (point-at-bol) 'org-complex-heading-regexp)) - pom property ass width f string ov column val modval s2 title) + pom property ass width f string ov column val modval s2 title calc) ;; Check if the entry is in another buffer. (unless props (if (eq major-mode 'org-agenda-mode) @@ -189,19 +198,26 @@ This is the compiled version of the format.") (nth 2 column) (length property)) f (format "%%-%d.%ds | " width width) + calc (nth 7 column) val (or (cdr ass) "") - modval (or (and org-columns-modify-value-for-display-function - (functionp - org-columns-modify-value-for-display-function) - (funcall - org-columns-modify-value-for-display-function - title val)) - (if (equal property "ITEM") - (if (org-mode-p) - (org-columns-cleanup-item - val org-columns-current-fmt-compiled) - (org-agenda-columns-cleanup-item - val pl cphr org-columns-current-fmt-compiled))))) + modval (cond ((and org-columns-modify-value-for-display-function + (functionp + org-columns-modify-value-for-display-function)) + (funcall org-columns-modify-value-for-display-function + title val)) + ((equal property "ITEM") + (if (org-mode-p) + (org-columns-cleanup-item + val org-columns-current-fmt-compiled) + (org-agenda-columns-cleanup-item + val pl cphr org-columns-current-fmt-compiled))) + ((and calc (functionp calc) + (not (string= val "")) + (not (get-text-property 0 'org-computed val))) + (org-columns-number-to-string + (funcall calc (org-columns-string-to-number + val (nth 4 column))) + (nth 4 column))))) (setq s2 (org-columns-add-ellipses (or modval val) width)) (setq string (format f s2)) ;; Create the overlay @@ -220,18 +236,18 @@ This is the compiled version of the format.") (save-excursion (goto-char beg) (org-unmodified (insert " ")))))) ;; FIXME: add props and remove later? - ;; Make the rest of the line disappear. - (org-unmodified - (setq ov (org-columns-new-overlay beg (point-at-eol))) - (org-overlay-put ov 'invisible t) - (org-overlay-put ov 'keymap org-columns-map) - (org-overlay-put ov 'intangible t) - (push ov org-columns-overlays) - (setq ov (org-make-overlay (1- (point-at-eol)) (1+ (point-at-eol)))) - (org-overlay-put ov 'keymap org-columns-map) - (push ov org-columns-overlays) - (let ((inhibit-read-only t)) - (put-text-property (max (point-min) (1- (point-at-bol))) + ;; Make the rest of the line disappear. + (org-unmodified + (setq ov (org-columns-new-overlay beg (point-at-eol))) + (org-overlay-put ov 'invisible t) + (org-overlay-put ov 'keymap org-columns-map) + (org-overlay-put ov 'intangible t) + (push ov org-columns-overlays) + (setq ov (org-make-overlay (1- (point-at-eol)) (1+ (point-at-eol)))) + (org-overlay-put ov 'keymap org-columns-map) + (push ov org-columns-overlays) + (let ((inhibit-read-only t)) + (put-text-property (max (point-min) (1- (point-at-bol))) (min (point-max) (1+ (point-at-eol))) 'read-only "Type `e' to edit property"))))) @@ -257,6 +273,7 @@ for the duration of the command.") (defvar header-line-format) (defvar org-columns-previous-hscroll 0) + (defun org-columns-display-here-title () "Overlay the newline before the current line with the table title." (interactive) @@ -347,6 +364,7 @@ for the duration of the command.") s) (defvar org-agenda-columns-remove-prefix-from-item) + (defun org-agenda-columns-cleanup-item (item pl cphr fmt) "Cleanup the time property for agenda column view. See also the variable `org-agenda-columns-remove-prefix-from-item'." @@ -366,6 +384,7 @@ See also the variable `org-agenda-columns-remove-prefix-from-item'." (message "Value is: %s" (or value "")))) (defvar org-agenda-columns-active) ;; defined in org-agenda.el + (defun org-columns-quit () "Remove the column overlays and in this way exit column editing." (interactive) @@ -417,6 +436,7 @@ Where possible, use the standard interface for changing this line." (<= (overlay-start x) eol) x)) org-columns-overlays))) + (org-columns-time (time-to-number-of-days (current-time))) nval eval allowed) (cond ((equal key "CLOCKSUM") @@ -661,7 +681,8 @@ around it." (org-verify-version 'columns) (org-columns-remove-overlays) (move-marker org-columns-begin-marker (point)) - (let (beg end fmt cache maxwidths) + (let ((org-columns-time (time-to-number-of-days (current-time))) + beg end fmt cache maxwidths) (setq fmt (org-columns-get-format-and-top-level)) (save-excursion (goto-char org-columns-top-level-marker) @@ -678,7 +699,7 @@ around it." (narrow-to-region beg end) (org-clock-sum)))) (while (re-search-forward (concat "^" outline-regexp) end t) - (if (and org-columns-skip-arrchived-trees + (if (and org-columns-skip-archived-trees (looking-at (concat ".*:" org-archive-tag ":"))) (org-end-of-subtree t) (push (cons (org-current-line) (org-entry-properties)) cache))) @@ -698,23 +719,43 @@ around it." (org-columns-display-here (cdr x))) cache))))) +(eval-when-compile (defvar org-columns-time)) + (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. + '(("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))))) + ("@min" min_age min (lambda (x) (- org-columns-time x))) + ("@max" max_age max (lambda (x) (- org-columns-time x))) + ("@mean" mean_age + (lambda (&rest x) (/ (apply '+ x) (float (length x)))) + (lambda (x) (- org-columns-time x)))) + "Operator <-> format,function,calc map. Used to compile/uncompile columns format and completing read in -interactive function org-columns-new.") +interactive function org-columns-new. + +operator string used in #+COLUMNS definition describing the + summary type +format symbol describing summary type selected interactively in + org-columns-new and internally in + org-columns-number-to-string and + org-columns-string-to-number +function called with a list of values as argument to calculate + the summary value +calc function called on every element before summarizing. This is + optional and should only be specified if needed") (defun org-columns-new (&optional prop title width op fmt fun &rest rest) "Insert a new column, to the left of the current column." @@ -735,7 +776,7 @@ interactive function org-columns-new.") org-columns-compile-map) nil t)) (setq fmt (intern fmt) - fun (cadr (assoc fmt (mapcar 'cdr org-columns-compile-map)))) + fun (cdr (assoc fmt (mapcar 'cdr org-columns-compile-map)))) (if (eq fmt 'none) (setq fmt nil)) (if editp (progn @@ -743,7 +784,8 @@ interactive function org-columns-new.") (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 nil fun) + (setcdr cell (cons (list prop title width nil fmt nil + (car fun) (cadr fun)) (cdr cell)))) (org-columns-store-format) (org-columns-redo))) @@ -860,7 +902,9 @@ Don't set this, this is meant for dynamic scoping.") "Compute all columns that have operators defined." (org-unmodified (remove-text-properties (point-min) (point-max) '(org-summaries t))) - (let ((columns org-columns-current-fmt-compiled) col) + (let ((columns org-columns-current-fmt-compiled) + (org-columns-time (time-to-number-of-days (current-time))) + col) (while (setq col (pop columns)) (when (nth 3 col) (save-excursion @@ -895,6 +939,7 @@ Don't set this, this is meant for dynamic scoping.") (format (nth 4 ass)) (printf (nth 5 ass)) (fun (nth 6 ass)) + (calc (or (nth 7 ass) 'identity)) (beg org-columns-top-level-marker) last-level val valflag flag end sumpos sum-alist sum str str1 useval) (save-excursion @@ -927,10 +972,12 @@ Don't set this, this is meant for dynamic scoping.") (list 'org-summaries sum-alist)))) (when (and val (not (equal val (if flag str val)))) (org-entry-put nil property (if flag str val))) - ;; add current to current level accumulator + ;; add current to current level accumulator (when (or flag valflag) - (push (if flag sum - (org-column-string-to-number (if flag str val) format)) + (push (if flag + sum + (funcall calc (org-columns-string-to-number + (if flag str val) format))) (aref lvals level)) (aset lflag level t)) ;; clear accumulators for deeper levels @@ -940,8 +987,8 @@ Don't set this, this is meant for dynamic scoping.") ((>= level last-level) ;; add what we have here to the accumulator for this level (when valflag - (push (org-column-string-to-number val format) - (aref lvals level)) + (push (funcall calc (org-columns-string-to-number val format)) + (aref lvals level)) (aset lflag level t))) (t (error "This should not happen"))))))) @@ -967,7 +1014,6 @@ Don't set this, this is meant for dynamic scoping.") (if (eq major-mode 'org-agenda-mode) (error "This command is only allowed in Org-mode buffers"))) - (defun org-string-to-number (s) "Convert string to number, and interpret hh:mm:ss." (if (not (string-match ":" s)) @@ -994,6 +1040,8 @@ Don't set this, this is meant for dynamic scoping.") (printf (format printf n)) ((eq fmt 'currency) (format "%.2f" n)) + ((memq fmt '(min_age max_age mean_age)) + (org-format-time-period n)) (t (number-to-string n)))) (defun org-nofm-to-completion (n m &optional percent) @@ -1001,21 +1049,33 @@ Don't set this, this is meant for dynamic scoping.") (format "[%d/%d]" n m) (format "[%d%%]"(floor (+ 0.5 (* 100. (/ (* 1.0 n) m))))))) -(defun org-column-string-to-number (s fmt) +(defun org-columns-string-to-number (s fmt) "Convert a column value to a number that can be used for column computing." - (cond - ((string-match ":" s) - (let ((l (nreverse (org-split-string s ":"))) (sum 0.0)) - (while l - (setq sum (+ (string-to-number (pop l)) (/ sum 60)))) - sum)) - ((memq fmt '(checkbox checkbox-n-of-m checkbox-percent)) - (if (equal s "[X]") 1. 0.000001)) - (t (string-to-number s)))) + (if s + (cond + ((memq fmt '(min_age max_age mean_age)) + (cond ((string= s "") org-columns-time) + ((string-match + "\\([0-9]+\\)d \\([0-9]+\\)h \\([0-9]+\\)m \\([0-9]+\\)s" + s) + (+ (* 60 (+ (* 60 (+ (* 24 (string-to-number (match-string 1 s))) + (string-to-number (match-string 2 s)))) + (string-to-number (match-string 3 s)))) + (string-to-number (match-string 4 s)))) + (t (time-to-number-of-days (apply 'encode-time + (org-parse-time-string s t)))))) + ((string-match ":" s) + (let ((l (nreverse (org-split-string s ":"))) (sum 0.0)) + (while l + (setq sum (+ (string-to-number (pop l)) (/ sum 60)))) + sum)) + ((memq fmt '(checkbox checkbox-n-of-m checkbox-percent)) + (if (equal s "[X]") 1. 0.000001)) + (t (string-to-number s))))) (defun org-columns-uncompile-format (cfmt) "Turn the compiled columns format back into a string representation." - (let ((rtn "") e s prop title op op-match width fmt printf fun) + (let ((rtn "") e s prop title op op-match width fmt printf fun calc) (while (setq e (pop cfmt)) (setq prop (car e) title (nth 1 e) @@ -1023,8 +1083,9 @@ Don't set this, this is meant for dynamic scoping.") op (nth 3 e) fmt (nth 4 e) printf (nth 5 e) - fun (nth 6 e)) - (when (setq op-match (rassoc (list fmt fun) org-columns-compile-map)) + fun (nth 6 e) + calc (nth 7 e)) + (when (setq op-match (rassoc (list fmt fun calc) 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)) @@ -1045,8 +1106,10 @@ 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 -fun the lisp function to compute values, derived from operator" - (let ((start 0) width prop title op op-match f printf fun) +fun the lisp function to compute summary values, derived from operator +calc function to get values from base elements +" + (let ((start 0) width prop title op op-match f printf fun calc) (setq org-columns-current-fmt-compiled nil) (while (string-match (org-re "%\\([0-9]+\\)?\\([[:alnum:]_-]+\\)\\(?:(\\([^)]+\\))\\)?\\(?:{\\([^}]+\\)}\\)?\\s-*") @@ -1058,15 +1121,18 @@ fun the lisp function to compute values, derived from operator" op (match-string 4 fmt) f nil printf nil - fun '+) + fun '+ + calc nil) (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)))) (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)) + fun (caddr op-match) + calc (cadddr op-match))) + (push (list prop title width op f printf fun calc) + org-columns-current-fmt-compiled)) (setq org-columns-current-fmt-compiled (nreverse org-columns-current-fmt-compiled)))) @@ -1121,18 +1187,18 @@ PARAMS is a property list of parameters: :width enforce same column widths with specifiers. :id the :ID: property of the entry where the columns view - should be built. When the symbol `local', call locally. - When `global' call column view with the cursor at the beginning - of the buffer (usually this means that the whole buffer switches - to column view). When \"file:path/to/file.org\", invoke column - view at the start of that file. Otherwise, the ID is located - using `org-id-find'. + should be built. When the symbol `local', call locally. + When `global' call column view with the cursor at the beginning + of the buffer (usually this means that the whole buffer switches + to column view). When \"file:path/to/file.org\", invoke column + view at the start of that file. Otherwise, the ID is located + using `org-id-find'. :hlines When t, insert a hline before each item. When a number, insert - a hline before each level <= that number. + a hline before each level <= that number. :vlines When t, make each column a colgroup to enforce vertical lines. :maxlevel When set to a number, don't capture headlines below this level. :skip-empty-rows - When t, skip rows where all specifiers other than ITEM are empty." + When t, skip rows where all specifiers other than ITEM are empty." (let ((pos (move-marker (make-marker) (point))) (hlines (plist-get params :hlines)) (vlines (plist-get params :vlines)) @@ -1253,7 +1319,8 @@ and tailing newline characters." (org-verify-version 'columns) (org-columns-remove-overlays) (move-marker org-columns-begin-marker (point)) - (let (fmt cache maxwidths m p a d) + (let ((org-columns-time (time-to-number-of-days (current-time))) + cache maxwidths m p a d fmt) (cond ((and (boundp 'org-agenda-overriding-columns-format) org-agenda-overriding-columns-format) @@ -1313,10 +1380,11 @@ and tailing newline characters." "Summarize the summarizable columns in column view in the agenda. This will add overlays to the date lines, to show the summary for each day." (let* ((fmt (mapcar (lambda (x) - (list (car x) (if (equal (car x) "CLOCKSUM") - 'add_times (nth 4 x)))) + (if (equal (car x) "CLOCKSUM") + (list "CLOCKSUM" (nth 2 x) nil 'add_times nil '+ 'identity) + (cdr x))) org-columns-current-fmt-compiled)) - line c c1 stype props lsum entries prop v) + line c c1 stype calc sumfunc props lsum entries prop v) (catch 'exit (when (delq nil (mapcar 'cadr fmt)) ;; OK, at least one summation column, it makes sense to try this @@ -1339,24 +1407,40 @@ This will add overlays to the date lines, to show the summary for each day." (setq props (mapcar (lambda (f) - (setq prop (car f) stype (nth 1 f)) + (setq prop (car f) + stype (nth 3 f) + sumfunc (nth 5 f) + calc (or (nth 6 f) 'identity)) (cond ((equal prop "ITEM") (cons prop (buffer-substring (point-at-bol) (point-at-eol)))) ((not stype) (cons prop "")) - (t - ;; do the summary - (setq lsum 0) - (mapc (lambda (x) - (setq v (cdr (assoc prop x))) - (if v (setq lsum (+ lsum - (org-column-string-to-number - v stype))))) - entries) - (setq lsum (org-columns-number-to-string lsum stype)) - (put-text-property - 0 (length lsum) 'face 'bold lsum) + (t ;; do the summary + (setq lsum nil) + (dolist (x entries) + (setq v (cdr (assoc prop x))) + (if v + (push + (funcall + (if (not (get-text-property 0 'org-computed v)) + calc + 'identity) + (org-columns-string-to-number + v stype)) + lsum))) + (setq lsum (remove nil lsum)) + (setq lsum + (cond ((> (length lsum) 1) + (org-columns-number-to-string + (apply sumfunc lsum) stype)) + ((eq (length lsum) 1) + (org-columns-number-to-string + (car lsum) stype)) + (t ""))) + (put-text-property 0 (length lsum) 'face 'bold lsum) + (unless (eq calc 'identity) + (put-text-property 0 (length lsum) 'org-computed t lsum)) (cons prop lsum)))) fmt)) (org-columns-display-here props 'dateline) @@ -1390,6 +1474,18 @@ This will add overlays to the date lines, to show the summary for each day." (equal (nth 4 a) (nth 4 fm))) (org-columns-compute (car fm))))))))))) +(defun org-format-time-period (interval) + "Convert time in fractional days to days/hours/minutes/seconds" + (if (numberp interval) + (let* ((days (floor interval)) + (frac-hours (* 24 (- interval days))) + (hours (floor frac-hours)) + (minutes (floor (* 60 (- frac-hours hours)))) + (seconds (floor (* 60 (- (* 60 (- frac-hours hours)) minutes))))) + (format "%dd %02dh %02dm %02ds" days hours minutes seconds)) + "")) + + (provide 'org-colview) ;; arch-tag: 61f5128d-747c-4983-9479-e3871fa3d73c diff --git a/lisp/org/org-compat.el b/lisp/org/org-compat.el index 1f6d3e9e5a..4e2c7d1a77 100644 --- a/lisp/org/org-compat.el +++ b/lisp/org/org-compat.el @@ -6,7 +6,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; diff --git a/lisp/org/org-crypt.el b/lisp/org/org-crypt.el index eda11a2c81..e445571406 100644 --- a/lisp/org/org-crypt.el +++ b/lisp/org/org-crypt.el @@ -4,7 +4,7 @@ ;; Emacs Lisp Archive Entry ;; Filename: org-crypt.el -;; Version: 6.31a +;; Version: 6.33 ;; Keywords: org-mode ;; Author: John Wiegley ;; Maintainer: Peter Jones @@ -94,7 +94,7 @@ heading. This can also be overridden in the CRYPTKEY property." "Returns the encryption key for the current heading." (save-excursion (org-back-to-heading t) - (or (org-entry-get nil "CRYPTKEY" 'selective) + (or (org-entry-get nil "CRYPTKEY" 'selective) org-crypt-key (and (boundp 'epa-file-encrypt-to) epa-file-encrypt-to) (error "No crypt key set")))) @@ -116,7 +116,7 @@ heading. This can also be overridden in the CRYPTKEY property." (org-back-over-empty-lines) (setq end (point) encrypted-text - (epg-encrypt-string + (epg-encrypt-string epg-context (buffer-substring-no-properties beg end) (epg-list-keys epg-context crypt-key))) @@ -136,12 +136,12 @@ heading. This can also be overridden in the CRYPTKEY property." (forward-line) (when (looking-at "-----BEGIN PGP MESSAGE-----") (let* ((beg (point)) - (end (save-excursion + (end (save-excursion (search-forward "-----END PGP MESSAGE-----") (forward-line) (point))) (epg-context (epg-make-context nil t t)) - (decrypted-text + (decrypted-text (decode-coding-string (epg-decrypt-string epg-context @@ -159,17 +159,17 @@ heading. This can also be overridden in the CRYPTKEY property." (defun org-decrypt-entries () (interactive) - (org-scan-tags + (org-scan-tags 'org-decrypt-entry (cdr (org-make-tags-matcher org-crypt-tag-matcher)))) (defun org-crypt-use-before-save-magic () "Adds a hook that will automatically encrypt entries before a file is saved to disk." - (add-hook - 'org-mode-hook + (add-hook + 'org-mode-hook (lambda () (add-hook 'before-save-hook 'org-encrypt-entries nil t)))) - + (provide 'org-crypt) ;; arch-tag: 8202ed2c-221e-4001-9e4b-54674a7e846e diff --git a/lisp/org/org-datetree.el b/lisp/org/org-datetree.el new file mode 100644 index 0000000000..ce6c562472 --- /dev/null +++ b/lisp/org/org-datetree.el @@ -0,0 +1,199 @@ +;;; org-datetree.el --- Create date entries in a tree + +;; Copyright (C) 2009 Free Software Foundation, Inc. + +;; Author: Carsten Dominik +;; Keywords: outlines, hypermedia, calendar, wp +;; Homepage: http://orgmode.org +;; Version: 6.33 +;; +;; 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 . +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Commentary: + +;; This file contains code to create entries in a tree where the top-level +;; nodes represent years, the level 2 nodes represent the months, and the +;; level 1 entries days. + +;;; Code: + +(require 'org) + +(defvar org-datetree-base-level 1 + "The level at which years should be placed in the date tree. +This is normally one, but if the buffer has an entry with a DATE_TREE +property, the date tree will become a subtree under that entry, so the +base level will be properly adjusted.") + +(defun org-datetree-find-date-create (date &optional keep-restriction) + "Find or create an entry for DATE. +If KEEP-RESTRICTION is non-nil, do not widen the buffer. +When it is nit, the buffer will be widened to make sure an existing date +tree can be found." + (let ((year (nth 2 date)) + (month (car date)) + (day (nth 1 date))) + (org-set-local 'org-datetree-base-level 1) + (or keep-restriction (widen)) + (goto-char (point-min)) + (save-restriction + (when (re-search-forward "^[ \t]*:DATE_TREE:[ \t]+\\S-" nil t) + (org-back-to-heading t) + (org-set-local 'org-datetree-base-level + (org-get-valid-level (funcall outline-level) 1)) + (org-narrow-to-subtree)) + (goto-char (point-min)) + (org-datetree-find-year-create year) + (org-datetree-find-month-create year month) + (org-datetree-find-day-create year month day) + (goto-char (prog1 (point) (widen)))))) + +(defun org-datetree-find-year-create (year) + (let ((re "^\\*+[ \t]+\\([12][0-9][0-9][0-9]\\)[ \t\n]") + match) + (goto-char (point-min)) + (while (and (setq match (re-search-forward re nil t)) + (goto-char (match-beginning 1)) + (< (string-to-number (match-string 1)) year))) + (cond + ((not match) + (goto-char (point-max)) + (or (bolp) (newline)) + (org-datetree-insert-line year)) + ((= (string-to-number (match-string 1)) year) + (goto-char (point-at-bol))) + (t + (beginning-of-line 1) + (org-datetree-insert-line year))))) + +(defun org-datetree-find-month-create (year month) + (org-narrow-to-subtree) + (let ((re (format "^\\*+[ \t]+%d-\\([01][0-9]\\)[ \t\n]" year)) + match) + (goto-char (point-min)) + (while (and (setq match (re-search-forward re nil t)) + (goto-char (match-beginning 1)) + (< (string-to-number (match-string 1)) month))) + (cond + ((not match) + (goto-char (point-max)) + (or (bolp) (newline)) + (org-datetree-insert-line year month)) + ((= (string-to-number (match-string 1)) month) + (goto-char (point-at-bol))) + (t + (beginning-of-line 1) + (org-datetree-insert-line year month))))) + +(defun org-datetree-find-day-create (year month day) + (org-narrow-to-subtree) + (let ((re (format "^\\*+[ \t]+%d-%02d-\\([01][0-9]\\)[ \t\n]" year month)) + match) + (goto-char (point-min)) + (while (and (setq match (re-search-forward re nil t)) + (goto-char (match-beginning 1)) + (< (string-to-number (match-string 1)) day))) + (cond + ((not match) + (goto-char (point-max)) + (or (bolp) (newline)) + (org-datetree-insert-line year month day)) + ((= (string-to-number (match-string 1)) day) + (goto-char (point-at-bol))) + (t + (beginning-of-line 1) + (org-datetree-insert-line year month day))))) + +(defun org-datetree-insert-line (year &optional month day) + (let ((pos (point))) + (skip-chars-backward " \t\n") + (delete-region (point) pos) + (insert "\n" (make-string org-datetree-base-level ?*) " \n") + (backward-char 1) + (if month (org-do-demote)) + (if day (org-do-demote)) + (insert (format "%d" year)) + (when month + (insert (format "-%02d" month)) + (if day + (insert (format "-%02d %s" + day (format-time-string + "%A" (encode-time 0 0 0 day month year)))) + (insert (format " %s" + (format-time-string + "%B" (encode-time 0 0 0 1 month year)))))) + (beginning-of-line 1))) + +(defun org-datetree-file-entry-under (txt date) + "Insert a node TXT into the date tree under DATE." + (org-datetree-find-date-create date) + (let ((level (org-get-valid-level (funcall outline-level) 1))) + (org-end-of-subtree t t) + (org-back-over-empty-lines) + (org-paste-subtree level txt))) + +(defun org-datetree-cleanup () + "Make sure all entries in the current tree are under the correct date. +It may be useful to restrict the buffer to the applicable portion +before running this command, even though the command tries to be smart." + (interactive) + (goto-char (point-min)) + (let ((dre (concat "\\<" org-deadline-string "\\>[ \t]*\\'")) + (sre (concat "\\<" org-scheduled-string "\\>[ \t]*\\'")) + dct ts tmp date year month day pos hdl-pos) + (while (re-search-forward org-ts-regexp nil t) + (catch 'next + (setq ts (match-string 0)) + (setq tmp (buffer-substring + (max (point-at-bol) (- (match-beginning 0) + org-ds-keyword-length)) + (match-beginning 0))) + (if (or (string-match "-\\'" tmp) + (string-match dre tmp) + (string-match sre tmp)) + (throw 'next nil)) + (setq dct (decode-time (org-time-string-to-time (match-string 0))) + date (list (nth 4 dct) (nth 3 dct) (nth 5 dct)) + year (nth 2 date) + month (car date) + day (nth 1 date) + pos (point)) + (org-back-to-heading t) + (setq hdl-pos (point)) + (unless (org-up-heading-safe) + ;; No parent, we are not in a date tree + (goto-char pos) + (throw 'next nil)) + (unless (looking-at "\\*+[ \t]+[0-9]+-[0-1][0-9]-[0-3][0-9]") + ;; Parent looks wrong, we are not in a date tree + (goto-char pos) + (throw 'next nil)) + (when (looking-at (format "\\*+[ \t]+%d-%02d-%02d" year month day)) + ;; At correct date already, do nothing + (progn (goto-char pos) (throw 'next nil))) + ;; OK, we need to refile this entry + (goto-char hdl-pos) + (org-cut-subtree) + (save-excursion + (save-restriction + (org-datetree-file-entry-under (current-kill 0) date))))))) + +(provide 'org-datetree) + +;; arch-tag: 1daea962-fd08-448b-9f98-6e8b511b3601 + +;;; org-datetree.el ends here diff --git a/lisp/org/org-docbook.el b/lisp/org/org-docbook.el index 11f3799919..33d66dc24d 100644 --- a/lisp/org/org-docbook.el +++ b/lisp/org/org-docbook.el @@ -4,7 +4,7 @@ ;; ;; Emacs Lisp Archive Entry ;; Filename: org-docbook.el -;; Version: 6.31a +;; Version: 6.33 ;; Author: Baoqiu Cui ;; Maintainer: Baoqiu Cui ;; Keywords: org, wp, docbook @@ -119,7 +119,7 @@ entities, you can set this variable to: ]> \" -If you want to process DocBook documents without internet +If you want to process DocBook documents without an Internet connection, it is suggested that you download the required entity file(s) and use system identifier(s) (external files) in the DOCTYPE declaration." @@ -410,7 +410,7 @@ publishing directory." (rbeg (and region-p (region-beginning))) (rend (and region-p (region-end))) (subtree-p - (if (plist-get opt-plist :ignore-subree-p) + (if (plist-get opt-plist :ignore-subtree-p) nil (when region-p (save-excursion @@ -736,8 +736,12 @@ publishing directory." ;; Make targets to anchors. Note that currently FOP does not ;; seem to support tags when generating PDF output, ;; but this can be used in DocBook --> HTML conversion. - (while (string-match "<<]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line) + (setq start 0) + (while (string-match + "<<]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line start) (cond + ((get-text-property (match-beginning 1) 'org-protected line) + (setq start (match-end 1))) ((match-end 2) (setq line (replace-match (format "@" diff --git a/lisp/org/org-exp-blocks.el b/lisp/org/org-exp-blocks.el index 4dac201a30..71e1608f9b 100644 --- a/lisp/org/org-exp-blocks.el +++ b/lisp/org/org-exp-blocks.el @@ -60,11 +60,6 @@ ;; 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 @@ -76,17 +71,11 @@ (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 "ext:ess" nil) - (defun org-export-blocks-set (var value) "Set the value of `org-export-blocks' and install fontification." (set var value) @@ -102,9 +91,7 @@ (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)) + (dot org-export-blocks-format-dot 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. @@ -133,8 +120,7 @@ blocks is as follows... (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. @@ -172,43 +158,40 @@ CLOSE tags will be inserted around BODY." "#+END_LaTeX\n")) (defun org-export-blocks-preprocess () - "Export all blocks acording to the `org-export-blocks' block + "Export all blocks according 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) + (let ((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))))) + indentation type func start body headers preserve-indent) + (flet ((interblock (start end) + (mapcar (lambda (pair) (funcall (second pair) start end)) + org-export-interblocks))) (goto-char (point-min)) - (setf start (point)) + (setq 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))) + (setq indentation (length (match-string 1))) + (setq type (intern (downcase (match-string 2)))) + (setq headers (save-match-data (org-split-string (match-string 3) "[ \t]+"))) + (setq body (match-string 4)) + (setq preserve-indent (or org-src-preserve-indentation (member "-i" headers))) + (unless preserve-indent + (setq body (save-match-data (org-remove-indentation body)))) + (unless (memq type types) (setq types (cons type types))) + (save-match-data (interblock start (match-beginning 0))) + (if (setq 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 block - (indent-code-rigidly (match-beginning 0) (match-end 0) indentation))) - (setf start (save-match-data (match-end 0)))) - (mapcar (lambda (type) - (interblock start (point-max) type)) - types))))) + (if (memq type org-export-blocks-witheld) "" + (apply func body headers))) t t) + (unless preserve-indent + (indent-code-rigidly (match-beginning 0) (match-end 0) indentation)))) + (setq start (match-end 0))) + (interblock start (point-max)))))) (add-hook 'org-export-preprocess-hook 'org-export-blocks-preprocess) @@ -321,119 +304,6 @@ other backends, it converts the comment into an EXAMPLE segment." (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 "
\n
\n" count)
-						  "
\n
\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. Its 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) ;; arch-tag: 1c365fe9-8808-4f72-bb15-0b00f36d8024 diff --git a/lisp/org/org-exp.el b/lisp/org/org-exp.el index 04b973d691..5282824a53 100644 --- a/lisp/org/org-exp.el +++ b/lisp/org/org-exp.el @@ -6,7 +6,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; @@ -30,6 +30,7 @@ (require 'org-macs) (require 'org-agenda) (require 'org-exp-blocks) +(require 'org-src) (eval-when-compile (require 'cl)) @@ -40,6 +41,7 @@ (declare-function org-infojs-options-inbuffer-template "org-jsinfo" ()) (declare-function org-export-htmlize-region-for-paste "org-html" (beg end)) (declare-function htmlize-buffer "ext:htmlize" (&optional buffer)) +(declare-function org-inlinetask-remove-END-maybe "org-inlinetask" ()) (autoload 'org-export-generic "org-export-generic" "Export using the generic exporter" t) (defgroup org-export nil "Options for exporting org-listings." @@ -848,6 +850,8 @@ value of `org-export-run-in-background'." \[D] export as DocBook \[V] export as DocBook, process to PDF, and open the resulting PDF document +\[m] export as Freemind mind map + \[x] export as XOXO \[g] export using Wes Hardaker's generic exporter @@ -870,6 +874,7 @@ value of `org-export-run-in-background'." (?g org-export-generic t) (?D org-export-as-docbook t) (?V org-export-as-docbook-pdf-and-open t) + (?m org-export-as-freemind t) (?l org-export-as-latex t) (?p org-export-as-pdf t) (?d org-export-as-pdf-and-open t) @@ -1305,8 +1310,8 @@ on this string to produce the exported version." (setq target-alist (org-export-define-heading-targets target-alist)) ;; Get rid of drawers - (org-export-remove-or-extract-drawers drawers - (plist-get parameters :drawers)) + (org-export-remove-or-extract-drawers + drawers (plist-get parameters :drawers) backend) ;; Get the correct stuff before the first headline (when (plist-get parameters :skip-before-1st-heading) @@ -1530,33 +1535,61 @@ the current file." (unless desc (insert "][" link)) (add-text-properties pos (point) props)))))) -(defun org-export-remove-or-extract-drawers (all-drawers exp-drawers) - "Remove drawers, or extract the content. +(defvar org-export-format-drawer-function nil + "Function to be called to format the contents of a drawer. +The function must accept three parameters: + BACKEND one of the symbols html, docbook, latex, ascii, xoxo + NAME the drawer name, like \"PROPERTIES\" + CONTENT the content of the drawer. +The function should return the text to be inserted into the buffer. +If this is nil, `org-export-format-drawer' is used as a default.") + +(defun org-export-remove-or-extract-drawers (all-drawers exp-drawers backend) + "Remove drawers, or extract and format the content. ALL-DRAWERS is a list of all drawer names valid in the current buffer. EXP-DRAWERS can be t to keep all drawer contents, or a list of drawers -whose content to keep." - (unless (eq t exp-drawers) - (goto-char (point-min)) - (let ((re (concat "^[ \t]*:\\(" - (mapconcat - 'identity - (org-delete-all exp-drawers - (copy-sequence all-drawers)) - "\\|") - "\\):[ \t]*$")) - beg eol) - (while (re-search-forward re nil t) - (org-if-unprotected - (setq beg (match-beginning 0) - eol (match-end 0)) - (if (re-search-forward "^\\([ \t]*:END:[ \t]*\n?\\)\\|^\\*+[ \t]" - nil t) - (if (match-end 1) - ;; terminated in this entry - (progn - (delete-region beg (match-end 1)) - (goto-char beg)) - (goto-char eol)))))))) +whose content to keep. Any drawers that are in ALL-DRAWERS but not in +EXP-DRAWERS will be removed. +BACKEND is the current export backend." + (goto-char (point-min)) + (let ((re (concat "^[ \t]*:\\(" + (mapconcat 'identity all-drawers "\\|") + "\\):[ \t]*$")) + name beg beg-content eol content) + (while (re-search-forward re nil t) + (org-if-unprotected + (setq name (match-string 1)) + (setq beg (match-beginning 0) + beg-content (1+ (point-at-eol)) + eol (point-at-eol)) + (if (not (and (re-search-forward + "^\\([ \t]*:END:[ \t]*\n?\\)\\|^\\*+[ \t]" nil t) + (match-end 1))) + (goto-char eol) + (goto-char (match-beginning 0)) + (and (looking-at ".*\n?") (replace-match "")) + (setq content (buffer-substring beg-content (point))) + (delete-region beg (point)) + (when (or (eq exp-drawers t) + (member name exp-drawers)) + (setq content (funcall (or org-export-format-drawer-function + 'org-export-format-drawer) + name content backend)) + (insert content))))))) + +(defun org-export-format-drawer (name content backend) + "Format the content of a drawer as a colon example." + (if (string-match "[ \t]+\\'" content) + (setq content (substring content (match-beginning 0)))) + (while (string-match "\\`[ \t]*\n" content) + (setq content (substring content (match-end 0)))) + (setq content (org-remove-indentation content)) + (setq content (concat ": " (mapconcat 'identity + (org-split-string content "\n") + "\n: ") + "\n")) + (setq content (concat " : " (upcase name) "\n" content)) + (org-add-props content nil 'org-protected t)) (defun org-export-handle-export-tags (select-tags exclude-tags) "Modify the buffer, honoring SELECT-TAGS and EXCLUDE-TAGS. @@ -1603,8 +1636,10 @@ removed as well." (when (org-at-heading-p) (org-back-to-heading t) (setq beg (point)) - (org-end-of-subtree t) - (delete-region beg (point))))) + (org-end-of-subtree t t) + (delete-region beg (point)) + (when (featurep 'org-inlinetask) + (org-inlinetask-remove-END-maybe))))) ;; Remove everything that is now still marked for deletion (goto-char (point-min)) (while (setq beg (text-property-any (point-min) (point-max) :org-delete t)) @@ -1682,9 +1717,10 @@ from the buffer." "Mark verbatim snippets with the protection property." (goto-char (point-min)) (while (re-search-forward org-verbatim-re nil t) - (add-text-properties (match-beginning 4) (match-end 4) - '(org-protected t)) - (goto-char (1+ (match-end 4))))) + (org-if-unprotected + (add-text-properties (match-beginning 4) (match-end 4) + '(org-protected t org-verbatim-emph t)) + (goto-char (1+ (match-end 4)))))) (defun org-export-protect-colon-examples () "Protect lines starting with a colon." @@ -1728,7 +1764,12 @@ from the buffer." (setq end (match-end 0) end-content (match-beginning 0)) (if (eq (car fmt) backend) ;; yes, keep this - (add-text-properties beg-content end-content '(org-protected t)) + (progn + (add-text-properties beg-content end-content '(org-protected t)) + (delete-region (match-beginning 0) (match-end 0)) + (save-excursion + (goto-char beg) + (delete-region (point) (1+ (point-at-eol))))) ;; No, this is for a different backend, kill it (delete-region beg end))))))) @@ -2252,19 +2293,21 @@ in the list) and remove property and value from the list in LISTVAR." (backend lang code &optional opts indent) "Format CODE from language LANG and return it formatted for export. If LANG is nil, do not add any fontification. -OPTS contains formatting optons, like `-n' for triggering numbering lines, -and `+n' for continuing previous numering. +OPTS contains formatting options, like `-n' for triggering numbering lines, +and `+n' for continuing previous numbering. Code formatting according to language currently only works for HTML. Numbering lines works for all three major backends (html, latex, and ascii). INDENT was the original indentation of the block." (save-match-data - (let (num cont rtn rpllbl keepp textareap cols rows fmt) + (let (num cont rtn rpllbl keepp textareap preserve-indentp cols rows fmt) (setq opts (or opts "") num (string-match "[-+]n\\>" opts) cont (string-match "\\+n\\>" opts) rpllbl (string-match "-r\\>" opts) keepp (string-match "-k\\>" opts) textareap (string-match "-t\\>" opts) + preserve-indentp (or org-src-preserve-indentation + (string-match "-i\\>" opts)) cols (if (string-match "-w[ \t]+\\([0-9]+\\)" opts) (string-to-number (match-string 1 opts)) 80) @@ -2277,7 +2320,7 @@ INDENT was the original indentation of the block." ;; we cannot use numbering or highlighting. (setq num nil cont nil lang nil)) (if keepp (setq rpllbl 'keep)) - (setq rtn (org-remove-indentation code)) + (setq rtn (if preserve-indentp code (org-remove-indentation code))) (when (string-match "^," rtn) (setq rtn (with-temp-buffer (insert rtn) @@ -2736,8 +2779,9 @@ Does include HTML export options as well as TODO and CATEGORY stuff." ((not org-log-done) "nologdone")) (or (mapconcat (lambda (x) (cond - ((equal '(:startgroup) x) "{") - ((equal '(:endgroup) x) "}") + ((equal :startgroup (car x)) "{") + ((equal :endgroup (car x)) "}") + ((equal :newline (car x)) "") ((cdr x) (format "%s(%c)" (car x) (cdr x))) (t (car x)))) (or org-tag-alist (org-get-buffer-tags)) " ") "") @@ -2889,3 +2933,4 @@ The depends on the variable `org-export-copy-to-kill'." ;; arch-tag: 65985fe9-095c-49c7-a7b6-cb4ee15c0a95 ;;; org-exp.el ends here + diff --git a/lisp/org/org-faces.el b/lisp/org/org-faces.el index adf04644b4..ac70649ec5 100644 --- a/lisp/org/org-faces.el +++ b/lisp/org/org-faces.el @@ -6,7 +6,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; diff --git a/lisp/org/org-feed.el b/lisp/org/org-feed.el index d8cf2e00d9..a63da894a4 100644 --- a/lisp/org/org-feed.el +++ b/lisp/org/org-feed.el @@ -5,7 +5,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; @@ -83,7 +83,7 @@ ;; ;; #+DRAWERS: PROPERTIES LOGBOOK FEEDSTATUS ;; -;; Acknowledgments +;; Acknowledgements ;; ---------------- ;; ;; org-feed.el is based on ideas by Brad Bozarth who implemented a @@ -542,7 +542,7 @@ If that property is already present, nothing changes." (buffer-string))))) (defun org-feed-make-indented-block (s n) - "Add indentaton of N spaces to a multiline string S." + "Add indentation of N spaces to a multiline string S." (if (not (string-match "\n" s)) s (mapconcat 'identity @@ -613,7 +613,7 @@ containing the properties `:guid' and `:item-full-text'." (defun org-feed-parse-atom-feed (buffer) "Parse BUFFER for Atom feed entries. -Returns a list of enttries, with each entry a property list, +Returns a list of entries, with each entry a property list, containing the properties `:guid' and `:item-full-text'. The `:item-full-text' property actually contains the sexp diff --git a/lisp/org/org-footnote.el b/lisp/org/org-footnote.el index 6e520a418a..bfd54721fe 100644 --- a/lisp/org/org-footnote.el +++ b/lisp/org/org-footnote.el @@ -5,7 +5,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; @@ -46,6 +46,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)) +(declare-function org-in-verbatim-emphasis "org" ()) (defvar org-odd-levels-only) ;; defined in org.el (defconst org-footnote-re @@ -75,7 +76,7 @@ If this is a string, during export, all subtrees starting with this heading will be removed after extracting footnote definitions." :group 'org-footnotes :type '(choice - (string :tag "Collect fotnotes under heading") + (string :tag "Collect footnotes under heading") (const :tag "Define footnotes locally" nil))) (defcustom org-footnote-tag-for-non-org-mode-files "Footnotes:" @@ -108,7 +109,7 @@ confirm like t, but let the user edit the created value. In particular, plain Automatically create plain number labels like [1]" :group 'org-footnote :type '(choice - (const :tag "Frompt for label" nil) + (const :tag "Prompt for label" nil) (const :tag "Create automatic [fn:N]" t) (const :tag "Offer automatic [fn:N] for editing" confirm) (const :tag "Create automatic [N]" plain))) @@ -310,7 +311,7 @@ or new, let the user edit the definition of the footnote." (defun org-footnote-action (&optional special) "Do the right thing for footnotes. When at a footnote reference, jump to the definition. When at a definition, -jump to the refernces. When neither at definition or reference, +jump to the references. When neither at definition or reference, create a new footnote, interactively. With prefix arg SPECIAL, offer additional commands in a menu." (interactive "P") @@ -365,7 +366,7 @@ referenced sequence." ;; Now find footnote references, and extract the definitions (goto-char (point-min)) (while (re-search-forward org-footnote-re nil t) - (unless (org-in-commented-line) + (unless (or (org-in-commented-line) (org-in-verbatim-emphasis)) (org-if-unprotected (setq def (match-string 4) idef def diff --git a/lisp/org/org-freemind.el b/lisp/org/org-freemind.el new file mode 100644 index 0000000000..76d17b0ebc --- /dev/null +++ b/lisp/org/org-freemind.el @@ -0,0 +1,1137 @@ +;;; org-freemind.el --- Export Org files to freemind + +;; Copyright (C) 2009 Free Software Foundation, Inc. + +;; Author: Lennart Borgman (lennart O borgman A gmail O com) +;; Keywords: outlines, hypermedia, calendar, wp +;; Homepage: http://orgmode.org +;; Version: 6.33 +;; +;; 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 . + +;; -------------------------------------------------------------------- +;; Features that might be required by this library: +;; +;; `backquote', `bytecomp', `cl', `easymenu', `font-lock', +;; `noutline', `org', `org-compat', `org-faces', `org-footnote', +;; `org-list', `org-macs', `org-src', `outline', `syntax', +;; `time-date', `xml'. +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Commentary: +;; +;; This file tries to implement some functions useful for +;; transformation between org-mode and FreeMind files. +;; +;; Here are the commands you can use: +;; +;; M-x `org-freemind-from-org-mode' +;; M-x `org-freemind-from-org-mode-node' +;; M-x `org-freemind-from-org-sparse-tree' +;; +;; M-x `org-freemind-to-org-mode' +;; +;; M-x `org-freemind-show' +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Change log: +;; +;; 2009-02-15: Added check for next level=current+1 +;; 2009-02-21: Fixed bug in `org-freemind-to-org-mode'. +;; 2009-10-25: Added support for `org-odd-levels-only'. +;; Added y/n question before showing in FreeMind. +;; 2009-11-04: Added support for #+BEGIN_HTML. +;; +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation; either version 2, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program; see the file COPYING. If not, write to +;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth +;; Floor, Boston, MA 02110-1301, USA. +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Code: + +(require 'xml) +(require 'org) +(require 'org-exp) +(eval-when-compile (require 'cl)) + +;; Fix-me: I am not sure these are useful: +;; +;; (defcustom org-freemind-main-fgcolor "black" +;; "Color of main node's text." +;; :type 'color +;; :group 'freemind) + +;; (defcustom org-freemind-main-color "black" +;; "Background color of main node." +;; :type 'color +;; :group 'freemind) + +;; (defcustom org-freemind-child-fgcolor "black" +;; "Color of child nodes' text." +;; :type 'color +;; :group 'freemind) + +;; (defcustom org-freemind-child-color "black" +;; "Background color of child nodes." +;; :type 'color +;; :group 'freemind) + +(defvar org-freemind-node-style nil "Internal use.") + +(defcustom org-freemind-node-styles nil + "Styles to apply to node. +NOT READY YET." + :type '(repeat + (list :tag "Node styles for file" + (regexp :tag "File name") + (repeat + (list :tag "Node" + (regexp :tag "Node name regexp") + (set :tag "Node properties" + (list :format "%v" (const :format "" node-style) + (choice :tag "Style" + :value bubble + (const bubble) + (const fork))) + (list :format "%v" (const :format "" color) + (color :tag "Color" :value "red")) + (list :format "%v" (const :format "" background-color) + (color :tag "Background color" :value "yellow")) + (list :format "%v" (const :format "" edge-color) + (color :tag "Edge color" :value "green")) + (list :format "%v" (const :format "" edge-style) + (choice :tag "Edge style" :value bezier + (const :tag "Linear" linear) + (const :tag "Bezier" bezier) + (const :tag "Sharp Linear" sharp-linear) + (const :tag "Sharp Bezier" sharp-bezier))) + (list :format "%v" (const :format "" edge-width) + (choice :tag "Edge width" :value thin + (const :tag "Parent" parent) + (const :tag "Thin" thin) + (const 1) + (const 2) + (const 4) + (const 8))) + (list :format "%v" (const :format "" italic) + (const :tag "Italic font" t)) + (list :format "%v" (const :format "" bold) + (const :tag "Bold font" t)) + (list :format "%v" (const :format "" font-name) + (string :tag "Font name" :value "SansSerif")) + (list :format "%v" (const :format "" font-size) + (integer :tag "Font size" :value 12))))))) + :group 'freemind) + +;;;###autoload +(defun org-export-as-freemind (arg &optional hidden ext-plist + to-buffer body-only pub-dir) + (interactive "P") + (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-subtree-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))) + (bfname (buffer-file-name (or (buffer-base-buffer) (current-buffer)))) + (filename (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))) + ".mm"))) + (when (file-exists-p filename) + (delete-file filename)) + (cond + (subtree-p + (org-freemind-from-org-mode-node (line-number-at-pos rbeg) + filename)) + (t (org-freemind-from-org-mode bfname filename))))) + +;;;###autoload +(defun org-freemind-show (mm-file) + "Show file MM-FILE in Freemind." + (interactive + (list + (save-match-data + (let ((name (read-file-name "FreeMind file: " + nil nil nil + (if (buffer-file-name) + (file-name-nondirectory (buffer-file-name)) + "") + ;; Fix-me: Is this an Emacs bug? + ;; This predicate function is never + ;; called. + (lambda (fn) + (string-match "^mm$" (file-name-extension fn)))))) + (setq name (expand-file-name name)) + name)))) + (org-open-file mm-file)) + +(defconst org-freemind-org-nfix "--org-mode: ") + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Format converters + +(defun org-freemind-escape-str-from-org (org-str) + "Do some html-escaping of ORG-STR and return the result. +The characters \"&<> will be escaped." + (let ((chars (append org-str nil)) + (fm-str "")) + (dolist (cc chars) + (setq fm-str + (concat fm-str + (if (< cc 256) + (cond + ((= cc ?\") """) + ((= cc ?\&) "&") + ((= cc ?\<) "<") + ((= cc ?\>) ">") + (t (char-to-string cc))) + ;; Formatting as &#number; is maybe needed + ;; according to a bug report from kazuo + ;; fujimoto, but I have now instead added a xml + ;; processing instruction saying that the mm + ;; file is utf-8: + ;; + ;; (format "&#x%x;" (- cc ;; ?\x800)) + (char-to-string cc) + )))) + fm-str)) + +;;(org-freemind-unescape-str-to-org "mA≌B<C<=") +;;(org-freemind-unescape-str-to-org "<<") +(defun org-freemind-unescape-str-to-org (fm-str) + "Do some html-unescaping of FM-STR and return the result. +This is the opposite of `org-freemind-escape-str-from-org' but it +will also unescape &#nn;." + (let ((org-str fm-str)) + (setq org-str (replace-regexp-in-string """ "\"" org-str)) + (setq org-str (replace-regexp-in-string "&" "&" org-str)) + (setq org-str (replace-regexp-in-string "<" "<" org-str)) + (setq org-str (replace-regexp-in-string ">" ">" org-str)) + (setq org-str (replace-regexp-in-string + "&#x\\([a-f0-9]\\{2,4\\}\\);" + (lambda (m) + (char-to-string + (+ (string-to-number (match-string 1 m) 16) + 0 ;?\x800 ;; What is this for? Encoding? + ))) + org-str)))) + +;; (org-freemind-test-escape) +(defun org-freemind-test-escape () + (let* ((str1 "a quote: \", an amp: &, lt: <; over 256: öåäÖÅÄ") + (str2 (org-freemind-escape-str-from-org str1)) + (str3 (org-freemind-unescape-str-to-org str2)) + ) + (unless (string= str1 str3) + (error "str3=%s" str3)) + )) + +(defun org-freemind-convert-links-from-org (org-str) + "Convert org links in ORG-STR to freemind links and return the result." + (let ((fm-str (replace-regexp-in-string + (rx (not (any "[\"")) + (submatch + "http" + (opt ?\s) + "://" + (1+ + (any "-%.?@a-zA-Z0-9()_/:~=&#")))) + "[[\\1][\\1]]" + org-str))) + (replace-regexp-in-string (rx "[[" + (submatch (*? nonl)) + "][" + (submatch (*? nonl)) + "]]") + "\\2" + fm-str))) + +;;(org-freemind-convert-links-to-org "link-text") +(defun org-freemind-convert-links-to-org (fm-str) + "Convert freemind links in FM-STR to org links and return the result." + (let ((org-str (replace-regexp-in-string + (rx ""))) + space) + "href=\"" + (submatch (0+ (not (any "\"")))) + "\"" + (0+ (not (any ">"))) + ">" + (submatch (0+ (not (any "<")))) + "") + "[[\\1][\\2]]" + fm-str))) + org-str)) + +;; Fix-me: +;;(defun org-freemind-convert-drawers-from-org (text) +;; ) + +;; (org-freemind-test-links) +;; (defun org-freemind-test-links () +;; (let* ((str1 "[[http://www.somewhere/][link-text]") +;; (str2 (org-freemind-convert-links-from-org str1)) +;; (str3 (org-freemind-convert-links-to-org str2)) +;; ) +;; (unless (string= str1 str3) +;; (error "str3=%s" str3)) +;; )) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Org => FreeMind + +(defun org-freemind-convert-text-p (text) + "Convert TEXT to html with

paragraphs." + (setq text (org-freemind-escape-str-from-org text)) + (setq text (replace-regexp-in-string (rx "\n" (0+ blank) "\n") "

\n" text)) + ;;(setq text (replace-regexp-in-string (rx bol (1+ blank) eol) "" text)) + ;;(setq text (replace-regexp-in-string (rx bol (1+ blank)) "
" text)) + (setq text (replace-regexp-in-string "\n" "
" text)) + (concat "

" + (org-freemind-convert-links-from-org text) + "

\n")) + +(defun org-freemind-org-text-to-freemind-subnode/note (node-name start end drawers-regexp) + "Convert text part of org node to freemind subnode or note. +Convert the text part of the org node named NODE-NAME. The text +is in the current buffer between START and END. Drawers matching +DRAWERS-REGEXP are converted to freemind notes." + ;; fix-me: doc + (let ((text (buffer-substring-no-properties start end)) + (node-res "") + (note-res "")) + (save-match-data + ;;(setq text (org-freemind-escape-str-from-org text)) + ;; First see if there is something that should be moved to the + ;; note part: + (let (drawers) + (while (string-match drawers-regexp text) + (setq drawers (cons (match-string 0 text) drawers)) + (setq text + (concat (substring text 0 (match-beginning 0)) + (substring text (match-end 0)))) + ) + (when drawers + (dolist (drawer drawers) + (let ((lines (split-string drawer "\n"))) + (dolist (line lines) + (setq note-res (concat + note-res + org-freemind-org-nfix line "
\n"))) + )))) + + (when (> (length note-res) 0) + (setq note-res (concat + "\n" + "\n" + "\n" + "\n" + note-res + "\n" + "\n" + "\n")) + ) + + ;; There is always an LF char: + (when (> (length text) 1) + (setq node-res (concat + "\n" + "\n" + "\n" + "\n" + "\n" + "\n")) + (let ((begin-html-mark (regexp-quote "#+BEGIN_HTML")) + (end-html-mark (regexp-quote "#+END_HTML")) + head + end-pos + end-pos-match + ) + ;; Take care of #+BEGIN_HTML - #+END_HTML + (while (string-match begin-html-mark text) + (setq head (substring text 0 (match-beginning 0))) + (setq end-pos-match (match-end 0)) + (setq node-res (concat node-res + (org-freemind-convert-text-p head))) + (setq text (substring text end-pos-match)) + (setq end-pos (string-match end-html-mark text)) + (if end-pos + (setq end-pos-match (match-end 0)) + (message "org-freemind: Missing #+END_HTML") + (setq end-pos (length text)) + (setq end-pos-match end-pos)) + (setq node-res (concat node-res + (substring text 0 end-pos))) + (setq text (substring text end-pos-match))) + (setq node-res (concat node-res + (org-freemind-convert-text-p text)))) + (setq node-res (concat + node-res + "\n" + "\n" + "\n" + ;; Put a note that this is for the parent node + "" + "" + "" + "" + "

" + "-- This is more about \"" node-name "\" --" + "

" + "" + "" + "
\n" + "
\n" ;; ok + ))) + (list node-res note-res)))) + +(defun org-freemind-write-node (mm-buffer drawers-regexp num-left-nodes base-level current-level next-level this-m2 this-node-end this-children-visible next-node-start next-has-some-visible-child) + (let* (this-icons + this-bg-color + this-m2-escaped + this-rich-node + this-rich-note + ) + (when (string-match "TODO" this-m2) + (setq this-m2 (replace-match "" nil nil this-m2)) + (add-to-list 'this-icons "button_cancel") + (setq this-bg-color "#ffff88") + (when (string-match "\\[#\\(.\\)\\]" this-m2) + (let ((prior (string-to-char (match-string 1 this-m2)))) + (setq this-m2 (replace-match "" nil nil this-m2)) + (cond + ((= prior ?A) + (add-to-list 'this-icons "full-1") + (setq this-bg-color "#ff0000")) + ((= prior ?B) + (add-to-list 'this-icons "full-2") + (setq this-bg-color "#ffaa00")) + ((= prior ?C) + (add-to-list 'this-icons "full-3") + (setq this-bg-color "#ffdd00")) + ((= prior ?D) + (add-to-list 'this-icons "full-4") + (setq this-bg-color "#ffff00")) + ((= prior ?E) + (add-to-list 'this-icons "full-5")) + ((= prior ?F) + (add-to-list 'this-icons "full-6")) + ((= prior ?G) + (add-to-list 'this-icons "full-7")) + )))) + (setq this-m2 (org-trim this-m2)) + (setq this-m2-escaped (org-freemind-escape-str-from-org this-m2)) + (let ((node-notes (org-freemind-org-text-to-freemind-subnode/note + this-m2-escaped + this-node-end + (1- next-node-start) + drawers-regexp))) + (setq this-rich-node (nth 0 node-notes)) + (setq this-rich-note (nth 1 node-notes))) + (with-current-buffer mm-buffer + (insert " next-level current-level) + (unless (or this-children-visible + next-has-some-visible-child) + (insert " folded=\"true\""))) + (when (and (= current-level (1+ base-level)) + (> num-left-nodes 0)) + (setq num-left-nodes (1- num-left-nodes)) + (insert " position=\"left\"")) + (when this-bg-color + (insert " background_color=\"" this-bg-color "\"")) + (insert ">\n") + (when this-icons + (dolist (icon this-icons) + (insert "\n"))) + ) + (with-current-buffer mm-buffer + (when this-rich-note (insert this-rich-note)) + (when this-rich-node (insert this-rich-node)))) + num-left-nodes) + +(defun org-freemind-check-overwrite (file interactively) + "Check if file FILE already exists. +If FILE does not exists return t. + +If INTERACTIVELY is non-nil ask if the file should be replaced +and return t/nil if it should/should not be replaced. + +Otherwise give an error say the file exists." + (if (file-exists-p file) + (if interactively + (y-or-n-p (format "File %s exists, replace it? " file)) + (error "File %s already exists" file)) + t)) + +(defvar org-freemind-node-pattern (rx bol + (submatch (1+ "*")) + (1+ space) + (submatch (*? nonl)) + eol)) + +(defun org-freemind-look-for-visible-child (node-level) + (save-excursion + (save-match-data + (let ((found-visible-child nil)) + (while (and (not found-visible-child) + (re-search-forward org-freemind-node-pattern nil t)) + (let* ((m1 (match-string-no-properties 1)) + (level (length m1))) + (if (>= node-level level) + (setq found-visible-child 'none) + (unless (get-char-property (line-beginning-position) 'invisible) + (setq found-visible-child 'found))))) + (eq found-visible-child 'found) + )))) + +(defun org-freemind-goto-line (line) + "Go to line number LINE." + (save-restriction + (widen) + (goto-char (point-min)) + (forward-line (1- line)))) + +(defun org-freemind-write-mm-buffer (org-buffer mm-buffer node-at-line) + (with-current-buffer org-buffer + (dolist (node-style org-freemind-node-styles) + (when (string-match-p (car node-style) buffer-file-name) + (setq org-freemind-node-style (cadr node-style)))) + ;;(message "org-freemind-node-style =%s" org-freemind-node-style) + (save-match-data + (let* ((drawers (copy-sequence org-drawers)) + drawers-regexp + (num-top1-nodes 0) + (num-top2-nodes 0) + num-left-nodes + (unclosed-nodes 0) + (first-time t) + (current-level 1) + base-level + skipping-odd + (skipped-odd 0) + prev-node-end + rich-text + unfinished-tag + node-at-line-level + node-at-line-last) + (with-current-buffer mm-buffer + (erase-buffer) + (insert "\n") + (insert "\n") + (insert "\n")) + (save-excursion + ;; Get special buffer vars: + (goto-char (point-min)) + (while (re-search-forward (rx bol "#+DRAWERS:") nil t) + (let ((dr-txt (buffer-substring-no-properties (match-end 0) (line-end-position)))) + (setq drawers (append drawers (split-string dr-txt) nil)))) + (setq drawers-regexp + (concat (rx bol (0+ blank) ":") + (regexp-opt drawers) + (rx ":" (0+ blank) + "\n" + (*? anything) + "\n" + (0+ blank) + ":END:" + (0+ blank) + eol) + )) + + (if node-at-line + ;; Get number of top nodes and last line for this node + (progn + (org-freemind-goto-line node-at-line) + (unless (looking-at org-freemind-node-pattern) + (error "No node at line %s" node-at-line)) + (setq node-at-line-level (length (match-string-no-properties 1))) + (forward-line) + (setq node-at-line-last + (catch 'last-line + (while (re-search-forward org-freemind-node-pattern nil t) + (let* ((m1 (match-string-no-properties 1)) + (level (length m1))) + (if (<= level node-at-line-level) + (progn + (beginning-of-line) + (throw 'last-line (1- (point)))) + (if (= level (1+ node-at-line-level)) + (setq num-top2-nodes (1+ num-top2-nodes)))))))) + (setq current-level node-at-line-level) + (setq num-top1-nodes 1) + (org-freemind-goto-line node-at-line)) + + ;; First get number of top nodes + (goto-char (point-min)) + (while (re-search-forward org-freemind-node-pattern nil t) + (let* ((m1 (match-string-no-properties 1)) + (level (length m1))) + (if (= level 1) + (setq num-top1-nodes (1+ num-top1-nodes)) + (if (= level 2) + (setq num-top2-nodes (1+ num-top2-nodes)))))) + ;; If there is more than one top node we need to insert a node + ;; to keep them together. + (goto-char (point-min)) + (when (> num-top1-nodes 1) + (setq num-top2-nodes num-top1-nodes) + (setq current-level 0) + (let ((orig-name (if buffer-file-name + (file-name-nondirectory (buffer-file-name)) + (buffer-name)))) + (with-current-buffer mm-buffer + (insert "\n" + ;; Put a note that this is for the parent node + "" + "" + "" + "" + "

" + org-freemind-org-nfix "WHOLE FILE" + "

" + "" + "" + "
\n"))))) + + (setq num-left-nodes (floor num-top2-nodes 2)) + (setq base-level current-level) + (let (this-m2 + this-node-end + this-children-visible + next-m2 + next-node-start + next-level + next-has-some-visible-child + next-children-visible + ) + (while (and + (re-search-forward org-freemind-node-pattern nil t) + (if node-at-line-last (<= (point) node-at-line-last) t) + ) + (let* ((next-m1 (match-string-no-properties 1)) + (next-node-end (match-end 0)) + ) + (setq next-node-start (match-beginning 0)) + (setq next-m2 (match-string-no-properties 2)) + (setq next-level (length next-m1)) + (when (> next-level current-level) + (if (not (and org-odd-levels-only + (/= (mod current-level 2) 0) + (= next-level (+ 2 current-level)))) + (setq skipping-odd nil) + (setq skipping-odd t) + (setq skipped-odd (1+ skipped-odd))) + (unless (or (= next-level (1+ current-level)) + skipping-odd) + (if (or org-odd-levels-only + (/= next-level (+ 2 current-level))) + (error "Next level step > +1 for node ending at line %s" (line-number-at-pos)) + (error "Next level step = +2 for node ending at line %s, forgot org-odd-levels-only?" + (line-number-at-pos))) + )) + (setq next-children-visible + (not (eq 'outline + (get-char-property (line-end-position) 'invisible)))) + (setq next-has-some-visible-child + (if next-children-visible t + (org-freemind-look-for-visible-child next-level))) + (when this-m2 + (setq num-left-nodes (org-freemind-write-node mm-buffer drawers-regexp num-left-nodes base-level current-level next-level this-m2 this-node-end this-children-visible next-node-start next-has-some-visible-child))) + (when (if (= num-top1-nodes 1) (> current-level base-level) t) + (while (>= current-level next-level) + (with-current-buffer mm-buffer + (insert "
\n") + (setq current-level (1- current-level)) + (when (< 0 skipped-odd) + (setq skipped-odd (1- skipped-odd)) + (setq current-level (1- current-level))) + ))) + (setq this-node-end (1+ next-node-end)) + (setq this-m2 next-m2) + (setq current-level next-level) + (setq this-children-visible next-children-visible) + (forward-char) + )) +;;; (unless (if node-at-line-last +;;; (>= (point) node-at-line-last) +;;; nil) + ;; Write last node: + (setq this-m2 next-m2) + (setq current-level next-level) + (setq next-node-start (if node-at-line-last + (1+ node-at-line-last) + (point-max))) + (setq num-left-nodes (org-freemind-write-node mm-buffer drawers-regexp num-left-nodes base-level current-level next-level this-m2 this-node-end this-children-visible next-node-start next-has-some-visible-child)) + (with-current-buffer mm-buffer (insert "
\n")) + ;) + ) + (with-current-buffer mm-buffer + (while (> current-level base-level) + (insert "\n") + (setq current-level (1- current-level)) + )) + (with-current-buffer mm-buffer + (insert "") + (delete-trailing-whitespace) + (goto-char (point-min)) + )))))) + +(defun org-freemind-get-node-style (node-name) + "NOT READY YET." + ;; + ;; + (let (node-styles + node-style) + (dolist (style-list org-freemind-node-style) + (let ((node-regexp (car style-list))) + (message "node-regexp=%s node-name=%s" node-regexp node-name) + (when (string-match-p node-regexp node-name) + ;;(setq node-style (org-freemind-do-apply-node-style style-list)) + (setq node-style (cadr style-list)) + (when node-style + (message "node-style=%s" node-style) + (setq node-styles (append node-styles node-style))) + ))))) + +(defun org-freemind-do-apply-node-style (style-list) + (message "style-list=%S" style-list) + (let ((node-style 'fork) + (color "red") + (background-color "yellow") + (edge-color "green") + (edge-style 'bezier) + (edge-width 'thin) + (italic t) + (bold t) + (font-name "SansSerif") + (font-size 12)) + (dolist (style (cadr style-list)) + (message " style=%s" style) + (let ((what (car style))) + (cond + ((eq what 'node-style) + (setq node-style (cadr style))) + ((eq what 'color) + (setq color (cadr style))) + ((eq what 'background-color) + (setq background-color (cadr style))) + + ((eq what 'edge-color) + (setq edge-color (cadr style))) + + ((eq what 'edge-style) + (setq edge-style (cadr style))) + + ((eq what 'edge-width) + (setq edge-width (cadr style))) + + ((eq what 'italic) + (setq italic (cadr style))) + + ((eq what 'bold) + (setq bold (cadr style))) + + ((eq what 'font-name) + (setq font-name (cadr style))) + + ((eq what 'font-size) + (setq font-size (cadr style))) + ) + (insert (format " style=\"%s\"" node-style)) + (insert (format " color=\"%s\"" color)) + (insert (format " background_color=\"%s\"" background-color)) + (insert ">\n") + (insert "\n") + (insert " Org + +;; (sort '(b a c) 'org-freemind-lt-symbols) +(defun org-freemind-lt-symbols (sym-a sym-b) + (string< (symbol-name sym-a) (symbol-name sym-b))) +;; (sort '((b . 1) (a . 2) (c . 3)) 'org-freemind-lt-xml-attrs) +(defun org-freemind-lt-xml-attrs (attr-a attr-b) + (string< (symbol-name (car attr-a)) (symbol-name (car attr-b)))) + +;; xml-parse-region gives things like +;; ((p nil "\n" +;; (a +;; ((href . "link")) +;; "text") +;; "\n" +;; (b nil "hej") +;; "\n")) + +;; '(a . nil) + +;; (org-freemind-symbols= 'a (car '(A B))) +(defsubst org-freemind-symbols= (sym-a sym-b) + "Return t if downcased names of SYM-A and SYM-B are equal. +SYM-A and SYM-B should be symbols." + (or (eq sym-a sym-b) + (string= (downcase (symbol-name sym-a)) + (downcase (symbol-name sym-b))))) + +(defun org-freemind-get-children (parent path) + "Find children node to PARENT from PATH. +PATH should be a list of steps, where each step has the form + + '(NODE-NAME (ATTR-NAME . ATTR-VALUE))" + ;; Fix-me: maybe implement op? step: Name, number, attr, attr op val + ;; Fix-me: case insensitive version for children? + (let* ((children (if (not (listp (car parent))) + (cddr parent) + (let (cs) + (dolist (p parent) + (dolist (c (cddr p)) + (add-to-list 'cs c))) + cs) + )) + (step (car path)) + (step-node (if (listp step) (car step) step)) + (step-attr-list (when (listp step) (sort (cdr step) 'org-freemind-lt-xml-attrs))) + (path-tail (cdr path)) + path-children) + (dolist (child children) + ;; skip xml.el formatting nodes + (unless (stringp child) + ;; compare node name + (when (if (not step-node) + t ;; any node name + (org-freemind-symbols= step-node (car child))) + (if (not step-attr-list) + ;;(throw 'path-child child) ;; no attr to care about + (add-to-list 'path-children child) + (let* ((child-attr-list (cadr child)) + (step-attr-copy (copy-sequence step-attr-list))) + (dolist (child-attr child-attr-list) + ;; Compare attr names: + (when (org-freemind-symbols= (caar step-attr-copy) (car child-attr)) + ;; Compare values: + (let ((step-val (cdar step-attr-copy)) + (child-val (cdr child-attr))) + (when (if (not step-val) + t ;; any value + (string= step-val child-val)) + (setq step-attr-copy (cdr step-attr-copy)))))) + ;; Did we find all? + (unless step-attr-copy + ;;(throw 'path-child child) + (add-to-list 'path-children child) + )))))) + (if path-tail + (org-freemind-get-children path-children path-tail) + path-children))) + +(defun org-freemind-get-richcontent-node (node) + (let ((rc-nodes + (org-freemind-get-children node '((richcontent (type . "NODE")) html body)))) + (when (> (length rc-nodes) 1) + (lwarn t :warning "Unexpected structure: several ")) + (car rc-nodes))) + +(defun org-freemind-get-richcontent-note (node) + (let ((rc-notes + (org-freemind-get-children node '((richcontent (type . "NOTE")) html body)))) + (when (> (length rc-notes) 1) + (lwarn t :warning "Unexpected structure: several ")) + (car rc-notes))) + +(defun org-freemind-test-get-tree-text () + (let ((node '(p nil "\n" + (a + ((href . "link")) + "text") + "\n" + (b nil "hej") + "\n"))) + (org-freemind-get-tree-text node))) +;; (org-freemind-test-get-tree-text) + +(defun org-freemind-get-tree-text (node) + (when node + (let ((ntxt "") + (link nil) + (lf-after nil)) + (dolist (n node) + (case n + ;;(a (setq is-link t) ) + ((h1 h2 h3 h4 h5 h6 p) + ;;(setq ntxt (concat "\n" ntxt)) + (setq lf-after 2) + ) + (br + (setq lf-after 1) + ) + (t + (cond + ((stringp n) + (when (string= n "\n") (setq n "")) + (if link + (setq ntxt (concat ntxt + "[[" link "][" n "]]")) + (setq ntxt (concat ntxt n)))) + ((and n (listp n)) + (if (symbolp (car n)) + (setq ntxt (concat ntxt (org-freemind-get-tree-text n))) + ;; This should be the attributes: + (dolist (att-val n) + (let ((att (car att-val)) + (val (cdr att-val))) + (when (eq att 'href) + (setq link val))))) + ))))) + (if lf-after + (setq ntxt (concat ntxt (make-string lf-after ?\n))) + (setq ntxt (concat ntxt " "))) + ;;(setq ntxt (concat ntxt (format "{%s}" n))) + ntxt))) + +(defun org-freemind-get-richcontent-node-text (node) + "Get the node text as from the richcontent node NODE." + (save-match-data + (let* ((rc (org-freemind-get-richcontent-node node)) + (txt (org-freemind-get-tree-text rc))) + ;;(when txt (setq txt (replace-regexp-in-string (rx (1+ whitespace)) " " txt))) + txt + ))) + +(defun org-freemind-get-richcontent-note-text (node) + "Get the node text as from the richcontent note NODE." + (save-match-data + (let* ((rc (org-freemind-get-richcontent-note node)) + (txt (when rc (org-freemind-get-tree-text rc)))) + ;;(when txt (setq txt (replace-regexp-in-string (rx (1+ whitespace)) " " txt))) + txt + ))) + +(defun org-freemind-get-icon-names (node) + (let* ((icon-nodes (org-freemind-get-children node '((icon )))) + names) + (dolist (icn icon-nodes) + (setq names (cons (cdr (assq 'builtin (cadr icn))) names))) + ;; (icon (builtin . "full-1")) + names)) + +(defun org-freemind-node-to-org (node level skip-levels) + (let ((qname (car node)) + (attributes (cadr node)) + text + (note (org-freemind-get-richcontent-note-text node)) + (mark "-- This is more about ") + (icons (org-freemind-get-icon-names node)) + (children (cddr node))) + (when (< 0 (- level skip-levels)) + (dolist (attrib attributes) + (case (car attrib) + ('TEXT (setq text (cdr attrib))) + ('text (setq text (cdr attrib))))) + (unless text + ;; There should be a richcontent node holding the text: + (setq text (org-freemind-get-richcontent-node-text node))) + (when icons + (when (member "full-1" icons) (setq text (concat "[#A] " text))) + (when (member "full-2" icons) (setq text (concat "[#B] " text))) + (when (member "full-3" icons) (setq text (concat "[#C] " text))) + (when (member "full-4" icons) (setq text (concat "[#D] " text))) + (when (member "full-5" icons) (setq text (concat "[#E] " text))) + (when (member "full-6" icons) (setq text (concat "[#F] " text))) + (when (member "full-7" icons) (setq text (concat "[#G] " text))) + (when (member "button_cancel" icons) (setq text (concat "TODO " text))) + ) + (if (and note + (string= mark (substring note 0 (length mark)))) + (progn + (setq text (replace-regexp-in-string "\n $" "" text)) + (insert text)) + (case qname + ('node + (insert (make-string (- level skip-levels) ?*) " " text "\n") + )))) + (dolist (child children) + (unless (or (null child) + (stringp child)) + (org-freemind-node-to-org child (1+ level) skip-levels))))) + +;; Fix-me: put back special things, like drawers that are stored in +;; the notes. Should maybe all notes contents be put in drawers? +;;;###autoload +(defun org-freemind-to-org-mode (mm-file org-file) + "Convert FreeMind file MM-FILE to `org-mode' file ORG-FILE." + (interactive + (save-match-data + (let* ((mm-file (buffer-file-name)) + (default-org-file (concat (file-name-nondirectory mm-file) ".org")) + (org-file (read-file-name "Output org-mode file: " nil nil nil default-org-file))) + (list mm-file org-file)))) + (when (org-freemind-check-overwrite org-file (called-interactively-p)) + (let ((mm-buffer (find-file-noselect mm-file)) + (org-buffer (find-file-noselect org-file))) + (with-current-buffer mm-buffer + (let* ((xml-list (xml-parse-file mm-file)) + (top-node (cadr (cddar xml-list))) + (note (org-freemind-get-richcontent-note-text top-node)) + (skip-levels + (if (and note + (string-match (rx bol "--org-mode: WHOLE FILE" eol) note)) + 1 + 0))) + (with-current-buffer org-buffer + (erase-buffer) + (org-freemind-node-to-org top-node 1 skip-levels) + (goto-char (point-min)) + (org-set-tags t t) ;; Align all tags + ) + (switch-to-buffer-other-window org-buffer) + ))))) + +(provide 'org-freemind) + +;; arch-tag: e7b0d776-94fd-404a-b35e-0f855fae3627 + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; org-freemind.el ends here diff --git a/lisp/org/org-gnus.el b/lisp/org/org-gnus.el index 027787c0bf..c6b9b448ed 100644 --- a/lisp/org/org-gnus.el +++ b/lisp/org/org-gnus.el @@ -7,7 +7,7 @@ ;; Tassilo Horn ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; diff --git a/lisp/org/org-habit.el b/lisp/org/org-habit.el new file mode 100644 index 0000000000..c2f14894d5 --- /dev/null +++ b/lisp/org/org-habit.el @@ -0,0 +1,343 @@ +;;; org-habit.el --- The habit tracking code for Org-mode + +;; Copyright (C) 2009 Free Software Foundation, Inc. + +;; Author: John Wiegley +;; Keywords: outlines, hypermedia, calendar, wp +;; Homepage: http://orgmode.org +;; Version: 6.33 +;; +;; 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 . +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Commentary: + +;; This file contains the habit tracking code for Org-mode + +(require 'org) +(require 'org-agenda) +(eval-when-compile + (require 'cl) + (require 'calendar)) + +(defgroup org-habit nil + "Options concerning habit tracking in Org-mode." + :tag "Org Habit" + :group 'org-progress) + +(defcustom org-habit-graph-column 40 + "The absolute column at which to insert habit consistency graphs. +Note that consistency graphs will overwrite anything else in the buffer." + :group 'org-habit + :type 'integer) + +(defcustom org-habit-preceding-days 21 + "Number of days before today to appear in consistency graphs." + :group 'org-habit + :type 'integer) + +(defcustom org-habit-following-days 7 + "Number of days after today to appear in consistency graphs." + :group 'org-habit + :type 'integer) + +(defcustom org-habit-show-habits t + "If non-nil, show habits in agenda buffers." + :group 'org-habit + :type 'boolean) + +(defcustom org-habit-show-habits-only-for-today t + "If non-nil, only show habits on today's agenda, and not for future days. +Note that even when shown for future days, the graph is always +relative to the current effective date." + :group 'org-habit + :type 'boolean) + +(defface org-habit-clear-face + '((((background light)) (:background "slateblue")) + (((background dark)) (:background "blue"))) + "Face for days on which a task shouldn't be done yet." + :group 'org-habit + :group 'org-faces) +(defface org-habit-clear-future-face + '((((background light)) (:background "powderblue")) + (((background dark)) (:background "midnightblue"))) + "Face for future days on which a task shouldn't be done yet." + :group 'org-habit + :group 'org-faces) + +(defface org-habit-ready-face + '((((background light)) (:background "green")) + (((background dark)) (:background "forestgreen"))) + "Face for days on which a task should start to be done." + :group 'org-habit + :group 'org-faces) +(defface org-habit-ready-future-face + '((((background light)) (:background "palegreen")) + (((background dark)) (:background "darkgreen"))) + "Face for days on which a task should start to be done." + :group 'org-habit + :group 'org-faces) + +(defface org-habit-alert-face + '((((background light)) (:background "yellow")) + (((background dark)) (:background "gold"))) + "Face for days on which a task is due." + :group 'org-habit + :group 'org-faces) +(defface org-habit-alert-future-face + '((((background light)) (:background "palegoldenrod")) + (((background dark)) (:background "darkgoldenrod"))) + "Face for days on which a task is due." + :group 'org-habit + :group 'org-faces) + +(defface org-habit-overdue-face + '((((background light)) (:background "red")) + (((background dark)) (:background "firebrick"))) + "Face for days on which a task is overdue." + :group 'org-habit + :group 'org-faces) +(defface org-habit-overdue-future-face + '((((background light)) (:background "mistyrose")) + (((background dark)) (:background "darkred"))) + "Face for days on which a task is overdue." + :group 'org-habit + :group 'org-faces) + +(defun org-habit-duration-to-days (ts) + (if (string-match "\\([0-9]+\\)\\([dwmy]\\)" ts) + ;; lead time is specified. + (floor (* (string-to-number (match-string 1 ts)) + (cdr (assoc (match-string 2 ts) + '(("d" . 1) ("w" . 7) + ("m" . 30.4) ("y" . 365.25)))))) + (error "Invalid duration string: %s" ts))) + +(defun org-is-habit-p (&optional pom) + (string= "habit" (org-entry-get (or pom (point)) "STYLE"))) + +(defun org-habit-parse-todo (&optional pom) + "Parse the TODO surrounding point for its habit-related data. +Returns a list with the following elements: + + 0: Scheduled date for the habit (may be in the past) + 1: \".+\"-style repeater for the schedule, in days + 2: Optional deadline (nil if not present) + 3: If deadline, the repeater for the deadline, otherwise nil + 4: A list of all the past dates this todo was mark closed + +This list represents a \"habit\" for the rest of this module." + (save-excursion + (if pom (goto-char pom)) + (assert (org-is-habit-p (point))) + (let* ((scheduled (org-get-scheduled-time (point))) + (scheduled-repeat (org-get-repeat org-scheduled-string)) + (sr-days (org-habit-duration-to-days scheduled-repeat)) + (end (org-entry-end-position)) + (habit-entry (org-no-properties (nth 5 (org-heading-components)))) + closed-dates deadline dr-days) + (if scheduled + (setq scheduled (time-to-days scheduled)) + (error "Habit %s has no scheduled date" habit-entry)) + (unless scheduled-repeat + (error "Habit %s has no scheduled repeat period" habit-entry)) + (unless (> sr-days 0) + (error "Habit %s scheduled repeat period is less than 1d" habit-entry)) + (when (string-match "/\\([0-9]+[dwmy]\\)" scheduled-repeat) + (setq dr-days (org-habit-duration-to-days + (match-string-no-properties 1 scheduled-repeat))) + (if (<= dr-days sr-days) + (error "Habit %s deadline repeat period is less than or equal to scheduled (%s)" + habit-entry scheduled-repeat)) + (setq deadline (+ scheduled (- dr-days sr-days)))) + (org-back-to-heading t) + (while (re-search-forward "- State \"DONE\".*\\[\\([^]]+\\)\\]" end t) + (push (time-to-days + (org-time-string-to-time (match-string-no-properties 1))) + closed-dates)) + (list scheduled sr-days deadline dr-days closed-dates)))) + +(defsubst org-habit-scheduled (habit) + (nth 0 habit)) +(defsubst org-habit-scheduled-repeat (habit) + (nth 1 habit)) +(defsubst org-habit-deadline (habit) + (let ((deadline (nth 2 habit))) + (or deadline + (+ (org-habit-scheduled habit) + (1- (org-habit-scheduled-repeat habit)))))) +(defsubst org-habit-deadline-repeat (habit) + (or (nth 3 habit) + (org-habit-scheduled-repeat habit))) +(defsubst org-habit-done-dates (habit) + (nth 4 habit)) + +(defsubst org-habit-get-priority (habit &optional moment) + "Determine the relative priority of a habit. +This must take into account not just urgency, but consistency as well." + (let ((pri 1000) + (now (time-to-days + (or moment + (time-subtract (current-time) + (list 0 (* 3600 org-extend-today-until) 0))))) + (scheduled (org-habit-scheduled habit)) + (deadline (org-habit-deadline habit))) + ;; add 10 for every day past the scheduled date, and subtract for every + ;; day before it + (setq pri (+ pri (* (- now scheduled) 10))) + ;; add 50 if the deadline is today + (if (and (/= scheduled deadline) + (= now deadline)) + (setq pri (+ pri 50))) + ;; add 100 for every day beyond the deadline date, and subtract 10 for + ;; every day before it + (let ((slip (- now (1- deadline)))) + (if (> slip 0) + (setq pri (+ pri (* slip 100))) + (setq pri (+ pri (* slip 10))))) + pri)) + +(defun org-habit-get-faces (habit &optional now-days scheduled-days donep) + "Return faces for HABIT relative to NOW-DAYS and SCHEDULED-DAYS. +NOW-DAYS defaults to the current time's days-past-the-epoch if nil. +SCHEDULED-DAYS defaults to the habit's actual scheduled days if nil. + +Habits are assigned colors on the following basis: + Blue Task is before the scheduled date. + Green Task is on or after scheduled date, but before the + end of the schedule's repeat period. + Yellow If the task has a deadline, then it is after schedule's + repeat period, but before the deadline. + Orange The task has reached the deadline day, or if there is + no deadline, the end of the schedule's repeat period. + Red The task has gone beyond the deadline day or the + schedule's repeat period." + (let* ((scheduled (or scheduled-days (org-habit-scheduled habit))) + (s-repeat (org-habit-scheduled-repeat habit)) + (scheduled-end (+ scheduled (1- s-repeat))) + (d-repeat (org-habit-deadline-repeat habit)) + (deadline (if scheduled-days + (+ scheduled-days (- d-repeat s-repeat)) + (org-habit-deadline habit))) + (m-days (or now-days (time-to-days (current-time))))) + (cond + ((< m-days scheduled) + '(org-habit-clear-face . org-habit-clear-future-face)) + ((< m-days deadline) + '(org-habit-ready-face . org-habit-ready-future-face)) + ((= m-days deadline) + (if donep + '(org-habit-ready-face . org-habit-ready-future-face) + '(org-habit-alert-face . org-habit-alert-future-face))) + (t + '(org-habit-overdue-face . org-habit-overdue-future-face))))) + +(defun org-habit-build-graph (habit starting current ending) + "Build a graph for the given HABIT, from STARTING to ENDING. +CURRENT gives the current time between STARTING and ENDING, for +the purpose of drawing the graph. It need not be the actual +current time." + (let* ((done-dates (sort (org-habit-done-dates habit) '<)) + (scheduled (org-habit-scheduled habit)) + (s-repeat (org-habit-scheduled-repeat habit)) + (start (time-to-days starting)) + (now (time-to-days current)) + (end (time-to-days ending)) + (graph (make-string (1+ (- end start)) ?\ )) + (index 0) + last-done-date) + (while (and done-dates (< (car done-dates) start)) + (setq last-done-date (car done-dates) + done-dates (cdr done-dates))) + (while (< start end) + (let* ((in-the-past-p (< start now)) + (todayp (= start now)) + (donep (and done-dates + (= start (car done-dates)))) + (faces (if (and in-the-past-p + (not last-done-date) + (not (< scheduled now))) + '(org-habit-clear-face . org-habit-clear-future-face) + (org-habit-get-faces + habit start (and in-the-past-p + (if last-done-date + (+ last-done-date s-repeat) + scheduled)) + donep))) + markedp face) + (if donep + (progn + (aset graph index ?*) + (setq markedp t) + (while (and done-dates + (= start (car done-dates))) + (setq last-done-date (car done-dates) + done-dates (cdr done-dates)))) + (if todayp + (aset graph index ?!))) + (setq face (if (or in-the-past-p todayp) + (car faces) + (cdr faces))) + (if (and in-the-past-p + (not (eq face 'org-habit-overdue-face)) + (not markedp)) + (setq face (cdr faces))) + (put-text-property index (1+ index) 'face face graph)) + (setq start (1+ start) + index (1+ index))) + graph)) + +(defun org-habit-insert-consistency-graphs (&optional line) + "Insert consistency graph for any habitual tasks." + (let ((inhibit-read-only t) l c + (moment (time-subtract (current-time) + (list 0 (* 3600 org-extend-today-until) 0)))) + (save-excursion + (goto-char (if line (point-at-bol) (point-min))) + (while (not (eobp)) + (let ((habit (get-text-property (point) 'org-habit-p))) + (when habit + (move-to-column org-habit-graph-column t) + (delete-char (min (+ 1 org-habit-preceding-days + org-habit-following-days) + (- (line-end-position) (point)))) + (insert (org-habit-build-graph + habit + (time-subtract moment + (days-to-time org-habit-preceding-days)) + moment + (time-add moment + (days-to-time org-habit-following-days)))))) + (forward-line))))) + +(defun org-habit-toggle-habits () + "Toggle display of habits in an agenda buffer." + (interactive) + (org-agenda-check-type t 'agenda) + (setq org-habit-show-habits (not org-habit-show-habits)) + (org-agenda-redo) + (org-agenda-set-mode-name) + (message "Habits turned %s" + (if org-habit-show-habits "on" "off"))) + +(org-defkey org-agenda-mode-map "K" 'org-habit-toggle-habits) + +(provide 'org-habit) + +;; arch-tag: 64e070d9-bd09-4917-bd44-44465f5ed348 + +;;; org-habit.el ends here diff --git a/lisp/org/org-html.el b/lisp/org/org-html.el index 194da25796..11a692e86c 100644 --- a/lisp/org/org-html.el +++ b/lisp/org/org-html.el @@ -6,7 +6,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; @@ -507,7 +507,7 @@ in a window. A non-interactive call will only return the buffer." (setq buffer "*Org HTML Export*")) (let ((transient-mark-mode t) (zmacs-regions t) ext-plist rtn) - (setq ext-plist (plist-put ext-plist :ignore-subree-p t)) + (setq ext-plist (plist-put ext-plist :ignore-subtree-p t)) (goto-char end) (set-mark (point)) ;; to activate the region (goto-char beg) @@ -575,7 +575,7 @@ PUB-DIR is set, use this as the publishing directory." (rbeg (and region-p (region-beginning))) (rend (and region-p (region-end))) (subtree-p - (if (plist-get opt-plist :ignore-subree-p) + (if (plist-get opt-plist :ignore-subtree-p) nil (when region-p (save-excursion @@ -972,9 +972,12 @@ lang=\"%s\" xml:lang=\"%s\"> (setq line (concat line "\\\\"))))) ;; make targets to anchors + (setq start 0) (while (string-match - "<<]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line) + "<<]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line start) (cond + ((get-text-property (match-beginning 1) 'org-protected line) + (setq start (match-end 1))) ((match-end 2) (setq line (replace-match (format @@ -985,16 +988,18 @@ lang=\"%s\" xml:lang=\"%s\"> ((and org-export-with-toc (equal (string-to-char line) ?*)) ;; FIXME: NOT DEPENDENT on TOC????????????????????? (setq line (replace-match - (concat "@" (match-string 1 line) "@ ") -; (concat "@" (match-string 1 line) "@ ") + (concat "@" + (match-string 1 line) "@ ") + ;; (concat "@" (match-string 1 line) "@ ") t t line))) (t (setq line (replace-match (concat "@" (match-string 1 line) "@ ") + "\" class=\"target\">" (match-string 1 line) + "@ ") t t line))))) - + (setq line (org-html-handle-time-stamps line)) ;; replace "&" by "&", "<" and ">" by "<" and ">" @@ -1505,17 +1510,22 @@ lang=\"%s\" xml:lang=\"%s\"> (let* ((caption (org-find-text-property-in-string 'org-caption src)) (attr (org-find-text-property-in-string 'org-attributes src)) (label (org-find-text-property-in-string 'org-label src))) - (format "%s
-

%s -
%s" - (if org-par-open "

\n" "") - (if label (format "id=\"%s\" " label) "") + (concat + (if caption + (format "%s
+

" + (if org-par-open "

\n" "") + (if label (format "id=\"%s\" " label) ""))) + (format "" src (if (string-match "\\" caption "

") "") - (if org-par-open "\n

" "")))))) + (concat " " attr " alt=\"" src "\""))) + (if caption + (format "

%s +
%s" + (concat "\n

" caption "

") + (if org-par-open "\n

" "")))))))) (defun org-export-html-get-bibliography () "Find bibliography, cut it out and return it." @@ -1641,7 +1651,7 @@ lang=\"%s\" xml:lang=\"%s\"> (unless splice (push "\n" html)) (setq html (nreverse html)) (unless splice - ;; Put in col tags with the alignment (unfortuntely often ignored...) + ;; Put in col tags with the alignment (unfortunately often ignored...) (unless (car org-table-colgroup-info) (setq org-table-colgroup-info (cons :start (cdr org-table-colgroup-info)))) diff --git a/lisp/org/org-icalendar.el b/lisp/org/org-icalendar.el index 23e739fe97..4141196cb3 100644 --- a/lisp/org/org-icalendar.el +++ b/lisp/org/org-icalendar.el @@ -6,7 +6,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; @@ -47,6 +47,11 @@ The file name should be absolute, the file will be overwritten without warning." :group 'org-export-icalendar :type 'string) +(defcustom org-icalendar-use-plain-timestamp t + "Non-nil means, make an event from every plain time stamp." + :group 'org-export-icalendar + :type 'boolean) + (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: @@ -101,9 +106,9 @@ all-tags All tags, including inherited ones." (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 +nil don't include any TODO items t include all TODO items that are not in a DONE state -unblocked include all TODO idems that are not blocked +unblocked include all TODO items that are not blocked all include both done and not done items." :group 'org-export-icalendar :type '(choice @@ -112,6 +117,17 @@ all include both done and not done items." (const :tag "Unblocked" unblocked) (const :tag "All" all))) +(defvar org-icalendar-verify-function nil + "Function to verify entries for iCalendar export. +This can be set to a function that will be called at each entry that +is considered for export to iCalendar. When the function returns nil, +the entry will be skipped. When it returns a non-nil value, the entry +will be considered for export. +This is used internally when an agenda buffer is exported to an ics file, +to make sure that only entries currently listed in the agenda will end +up in the ics file. But for normal iCalendar export, you can use this +for whatever you need.") + (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." @@ -264,8 +280,8 @@ When COMBINE is non nil, add the category to each line." (while (re-search-forward re1 nil t) (catch :skip (org-agenda-skip) - (when (boundp 'org-icalendar-verify-function) - (unless (funcall org-icalendar-verify-function) + (when org-icalendar-verify-function + (unless (save-match-data (funcall org-icalendar-verify-function)) (outline-next-heading) (backward-char 1) (throw :skip nil))) @@ -307,6 +323,9 @@ When COMBINE is non nil, add the category to each line." todo (org-get-todo-state) ;; donep (org-entry-is-done-p) )) + (when (and (not org-icalendar-use-plain-timestamp) + (not deadlinep) (not scheduledp)) + (throw :skip t)) (when (and deadlinep (if todo @@ -368,6 +387,11 @@ END:VEVENT\n" (while (re-search-forward "^&?%%(" nil t) (catch :skip (org-agenda-skip) + (when org-icalendar-verify-function + (unless (save-match-data (funcall org-icalendar-verify-function)) + (outline-next-heading) + (backward-char 1) + (throw :skip nil))) (setq b (match-beginning 0)) (goto-char (1- (match-end 0))) (forward-sexp 1) @@ -384,7 +408,7 @@ END:VEVENT\n" (while (re-search-forward org-todo-line-regexp nil t) (catch :skip (org-agenda-skip) - (when (boundp 'org-icalendar-verify-function) + (when org-icalendar-verify-function (unless (save-match-data (funcall org-icalendar-verify-function)) (outline-next-heading) diff --git a/lisp/org/org-id.el b/lisp/org/org-id.el index 01ce9ef35d..c6c007f35d 100644 --- a/lisp/org/org-id.el +++ b/lisp/org/org-id.el @@ -5,7 +5,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; @@ -392,25 +392,32 @@ When CHECK is given, prepare detailed information about duplicate IDs." (interactive) (if (not org-id-track-globally) (error "Please turn on `org-id-track-globally' if you want to track IDs") - (let ((files - (or files - (append - ;; Agenda files and all associated archives - (org-agenda-files t org-id-search-archives) - ;; Explicit extra files - (if (symbolp org-id-extra-files) - (symbol-value org-id-extra-files) - org-id-extra-files) + (let* ((org-id-search-archives + (or org-id-search-archives + (and (symbolp org-id-extra-files) + (symbol-value org-id-extra-files) + (member 'agenda-archives org-id-extra-files)))) + (files + (or files + (append + ;; Agenda files and all associated archives + (org-agenda-files t org-id-search-archives) + ;; Explicit extra files + (if (symbolp org-id-extra-files) + (symbol-value org-id-extra-files) + org-id-extra-files) ;; Files associated with live org-mode buffers - (delq nil - (mapcar (lambda (b) - (with-current-buffer b - (and (org-mode-p) (buffer-file-name)))) - (buffer-list))) - ;; All files known to have IDs - org-id-files))) - org-agenda-new-buffers - file nfiles tfile ids reg found id seen (ndup 0)) + (delq nil + (mapcar (lambda (b) + (with-current-buffer b + (and (org-mode-p) (buffer-file-name)))) + (buffer-list))) + ;; All files known to have IDs + org-id-files))) + org-agenda-new-buffers + file nfiles tfile ids reg found id seen (ndup 0)) + (when (member 'agenda-archives files) + (setq files (delq 'agenda-archives (copy-sequence files)))) (setq nfiles (length files)) (while (setq file (pop files)) (message "Finding ID locations (%d/%d files): %s" @@ -430,12 +437,14 @@ When CHECK is given, prepare detailed information about duplicate IDs." (if (member id found) (progn (message "Duplicate ID \"%s\", also in file %s" - id (car (delq - nil - (mapcar - (lambda (x) - (if (member id (cdr x)) (car x))) - reg)))) + id (or (car (delq + nil + (mapcar + (lambda (x) + (if (member id (cdr x)) + (car x))) + reg))) + (buffer-file-name))) (when (= ndup 0) (ding) (sit-for 2)) diff --git a/lisp/org/org-indent.el b/lisp/org/org-indent.el index 0ae2958c3d..db0b49f154 100644 --- a/lisp/org/org-indent.el +++ b/lisp/org/org-indent.el @@ -4,7 +4,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; @@ -171,7 +171,7 @@ FIXME: How to update when broken?" (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." +useful to make it ever so slightly different." :group 'org-faces) (defun org-indent-indent-buffer () diff --git a/lisp/org/org-info.el b/lisp/org/org-info.el index 92ca1264ca..af37256f21 100644 --- a/lisp/org/org-info.el +++ b/lisp/org/org-info.el @@ -6,7 +6,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; diff --git a/lisp/org/org-inlinetask.el b/lisp/org/org-inlinetask.el index cd378bc8bc..d4be908c5e 100644 --- a/lisp/org/org-inlinetask.el +++ b/lisp/org/org-inlinetask.el @@ -5,7 +5,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; This file is part of GNU Emacs. @@ -35,7 +35,7 @@ ;; ;; 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 +;; `org-cycle', so if you are also using other commands to show/hide ;; entries, you will occasionally find these tasks to behave like ;; all other outline nodes, seemingly splitting the text of the parent ;; into children. @@ -70,7 +70,7 @@ ;; 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: +;; This package installs one new command: ;; ;; C-c C-x t Insert a new inline task with END line @@ -93,6 +93,12 @@ the value of this variable." :group 'org-inlinetask :type 'boolean) +(defcustom org-inlinetask-export t + "Non-nil means, export inline tasks. +When nil, they will not be exported." + :group 'org-inlinetask + :type 'boolean) + (defvar org-odd-levels-only) (defvar org-keyword-time-regexp) (defvar org-drawer-regexp) @@ -139,24 +145,42 @@ Either remove headline and meta data, or do special formatting." (setq content (buffer-substring beg (1- (point-at-bol)))) (delete-region beg (1+ (match-end 0)))) (goto-char beg) - (when (string-match org-complex-heading-regexp headline) - (setq headline (concat - (if (match-end 2) - (concat (match-string 2 headline) " ") "") - (match-string 4 headline))) - (if (not (string-match "\\S-" content)) - (setq content nil) - (if (string-match "[ \t\n]+\\'" content) - (setq content (substring content 0 (match-beginning 0)))) - (setq content (org-remove-indentation content)) - (if latexp (setq content (concat "\\quad \\\\\n" content)))) - (insert "- ") - (setq indent (make-string (current-column) ?\ )) - (insert headline " ::") - (when content - (insert (if htmlp " " (concat "\n" indent)) - (mapconcat 'identity (org-split-string content "\n") - (concat "\n" indent)) "\n")))))) + (when org-inlinetask-export + (when (string-match org-complex-heading-regexp headline) + (setq headline (concat + (if (match-end 2) + (concat (match-string 2 headline) " ") "") + (match-string 4 headline))) + (when content + (if (not (string-match "\\S-" content)) + (setq content nil) + (if (string-match "[ \t\n]+\\'" content) + (setq content (substring content 0 (match-beginning 0)))) + (setq content (org-remove-indentation content)) + (if latexp (setq content (concat "\\quad \\\\\n" content))))) + (insert (make-string (org-inlinetask-get-current-indentation) ?\ ) + "- ") + (setq indent (make-string (current-column) ?\ )) + (insert headline " ::") + (if content + (insert (if htmlp " " (concat "\n" indent)) + (mapconcat 'identity (org-split-string content "\n") + (concat "\n" indent)) "\n") + (insert "\n")) + (insert indent) + (backward-delete-char 2) + (insert "THISISTHEINLINELISTTEMINATOR\n")))))) + +(defun org-inlinetask-get-current-indentation () + "Get the indentation of the last non-while line above this one." + (save-excursion + (beginning-of-line 1) + (skip-chars-backward " \t\n") + (beginning-of-line 1) + (or (org-at-item-p) + (looking-at "[ \t]*")) + (goto-char (match-end 0)) + (current-column))) (defun org-inlinetask-fontify (limit) "Fontify the inline tasks." @@ -180,13 +204,32 @@ Either remove headline and meta data, or do special formatting." org-inlinetask-min-level)) (replace-match ""))) +(defun org-inlinetask-remove-terminator () + (let (beg end) + (save-excursion + (goto-char (point-min)) + (while (re-search-forward "THISISTHEINLINELISTTEMINATOR\n" nil t) + (setq beg (match-beginning 0) end (match-end 0)) + (save-excursion + (beginning-of-line 1) + (and (looking-at "THISISTHEINLINELISTTEMINATOR[ \t\n]*") + (setq beg (point) end (match-end 0)))) + (delete-region beg end))))) + (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)) +(eval-after-load "org-html" + '(add-hook 'org-export-html-final-hook 'org-inlinetask-remove-terminator)) +(eval-after-load "org-latex" + '(add-hook 'org-export-latex-final-hook 'org-inlinetask-remove-terminator)) +(eval-after-load "org-ascii" + '(add-hook 'org-export-ascii-final-hook 'org-inlinetask-remove-terminator)) +(eval-after-load "org-docbook" + '(add-hook 'org-export-docbook-final-hook 'org-inlinetask-remove-terminator)) (provide 'org-inlinetask) -;; arch-tag: b0974e46-1d51-49d5-8bda-737617019a1b ;;; org-inlinetask.el ends here diff --git a/lisp/org/org-irc.el b/lisp/org/org-irc.el index 258a5c2224..cf7bdf0f31 100644 --- a/lisp/org/org-irc.el +++ b/lisp/org/org-irc.el @@ -4,7 +4,7 @@ ;; ;; Author: Philip Jackson ;; Keywords: erc, irc, link, org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; diff --git a/lisp/org/org-jsinfo.el b/lisp/org/org-jsinfo.el index 52d5739e93..02d867a6d7 100644 --- a/lisp/org/org-jsinfo.el +++ b/lisp/org/org-jsinfo.el @@ -6,7 +6,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; diff --git a/lisp/org/org-latex.el b/lisp/org/org-latex.el index 7b6970bbca..bea5955ec5 100644 --- a/lisp/org/org-latex.el +++ b/lisp/org/org-latex.el @@ -4,7 +4,7 @@ ;; ;; Emacs Lisp Archive Entry ;; Filename: org-latex.el -;; Version: 6.31a +;; Version: 6.33 ;; Author: Bastien Guerry ;; Maintainer: Carsten Dominik ;; Keywords: org, wp, tex @@ -94,7 +94,10 @@ \\usepackage[T1]{fontenc} \\usepackage{graphicx} \\usepackage{longtable} +\\usepackage{float} +\\usepackage{wrapfig} \\usepackage{soul} +\\usepackage{amssymb} \\usepackage{hyperref}" ("\\section{%s}" . "\\section*{%s}") ("\\subsection{%s}" . "\\subsection*{%s}") @@ -107,7 +110,10 @@ \\usepackage[T1]{fontenc} \\usepackage{graphicx} \\usepackage{longtable} +\\usepackage{float} +\\usepackage{wrapfig} \\usepackage{soul} +\\usepackage{amssymb} \\usepackage{hyperref}" ("\\part{%s}" . "\\part*{%s}") ("\\chapter{%s}" . "\\chapter*{%s}") @@ -120,7 +126,10 @@ \\usepackage[T1]{fontenc} \\usepackage{graphicx} \\usepackage{longtable} +\\usepackage{float} +\\usepackage{wrapfig} \\usepackage{soul} +\\usepackage{amssymb} \\usepackage{hyperref}" ("\\part{%s}" . "\\part*{%s}") ("\\chapter{%s}" . "\\chapter*{%s}") @@ -177,7 +186,7 @@ to represent the section title." 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 +If it is \"\\verb\", Org will automatically select a delimiter character that is not in the string. The third element decides whether to protect converted text from other conversions." @@ -269,7 +278,7 @@ 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 +to two occurrences of %s for the title and a label, respectively. The third string should be like \"\\end{itemize\"." :group 'org-export-latex :type '(choice (const :tag "Ignore" nil) @@ -284,7 +293,7 @@ string should be like \"\\end{itemize\"." (string :tag "Use a section string" :value "\\subparagraph{%s}"))) (defcustom org-export-latex-list-parameters - '(:cbon "\\texttt{[X]}" :cboff "\\texttt{[ ]}") + '(:cbon "$\\boxtimes$" :cboff "$\\Box$") "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 @@ -389,12 +398,12 @@ 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 +mechanism to detect which 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." +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")) @@ -481,7 +490,7 @@ in a window. A non-interactive call will only return the buffer." (setq buffer "*Org LaTeX Export*")) (let ((transient-mark-mode t) (zmacs-regions t) ext-plist rtn) - (setq ext-plist (plist-put ext-plist :ignore-subree-p t)) + (setq ext-plist (plist-put ext-plist :ignore-subtree-p t)) (goto-char end) (set-mark (point)) ;; to activate the region (goto-char beg) @@ -535,7 +544,7 @@ 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 - (if (plist-get opt-plist :ignore-subree-p) + (if (plist-get opt-plist :ignore-subtree-p) nil (when region-p (save-excursion @@ -977,7 +986,7 @@ OPT-PLIST is the options plist for current buffer." ;; insert author info (if (plist-get opt-plist :author-info) (format "\\author{%s}\n" - (org-export-latex-fontify-headline (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 @@ -1000,7 +1009,9 @@ OPT-PLIST is the options plist for current buffer." (format "\\setcounter{tocdepth}{%s}\n\\tableofcontents\n\\vspace*{1cm}\n" (min toc (plist-get opt-plist :headline-levels)))) (toc (format "\\setcounter{tocdepth}{%s}\n\\tableofcontents\n\\vspace*{1cm}\n" - (plist-get opt-plist :headline-levels)))))))) + (plist-get opt-plist :headline-levels))))) + (when (plist-get opt-plist :preserve-breaks) + "\\obeylines\n")))) (defun org-export-latex-first-lines (opt-plist &optional beg end) "Export the first lines before first headline. @@ -1124,6 +1135,15 @@ links, keywords, lists, tables, fixed-width" ;; the beginning of the buffer - inserting "\n" is safe here though. (insert "\n" string) (goto-char (point-min)) + (let ((re (concat "\\\\[a-zA-Z]+\\(?:" + "\\[.*\\]" + "\\)?" + (org-create-multibrace-regexp "{" "}" 3)))) + (while (re-search-forward re nil t) + (unless (save-excursion (goto-char (match-beginning 0)) + (equal (char-after (point-at-bol)) ?#)) + (add-text-properties (match-beginning 0) (match-end 0) + '(org-protected t))))) (when (plist-get org-export-latex-options-plist :emphasize) (org-export-latex-fontify)) (org-export-latex-keywords-maybe) @@ -1151,13 +1171,14 @@ links, keywords, lists, tables, fixed-width" '(("\\(\\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)))) - (org-export-latex-protect-string rpl) + (let ((rpl (concat (match-string 1) + (org-export-latex-protect-string + (copy-sequence (cadr l)))))) (org-if-unprotected-1 (replace-match rpl t t))))) quote-rpl))) @@ -1329,114 +1350,115 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER." "Convert tables to LaTeX and INSERT it." (goto-char (point-min)) (while (re-search-forward "^\\([ \t]*\\)|" nil t) - (org-table-align) - (let* ((beg (org-table-begin)) - (end (org-table-end)) - (raw-table (buffer-substring beg end)) - (org-table-last-alignment (copy-sequence org-table-last-alignment)) - (org-table-last-column-widths (copy-sequence - org-table-last-column-widths)) - fnum fields line lines olines gr colgropen line-fmt align - caption label attr floatp longtblp) - (if org-export-latex-tables-verbatim - (let* ((tbl (concat "\\begin{verbatim}\n" raw-table - "\\end{verbatim}\n"))) - (apply 'delete-region (list beg end)) - (insert (org-export-latex-protect-string tbl))) - (progn - (setq caption (org-find-text-property-in-string - 'org-caption raw-table) - attr (org-find-text-property-in-string - 'org-attributes raw-table) - label (org-find-text-property-in-string - 'org-label raw-table) - longtblp (and attr (stringp attr) - (string-match "\\" attr)) - align (and attr (stringp attr) - (string-match "\\" attr)) + align (and attr (stringp attr) + (string-match "\\" attr) + (setq wrapp t floatp nil attr (replace-match "" t t attr))) + (if (string-match "[ \t]*\\" attr) + (setq wrapp nil floatp t attr (replace-match "" t t attr)))) + + (setq placement + (cond + (wrapp "{l}{0.5\\textwidth}") + (floatp "[htb]") + (t ""))) + + (when (and attr (stringp attr) + (string-match "[ \t]*\\>>?\\((INVISIBLE)\\)?") nil t) - (org-if-unprotected + (org-if-unprotected-at (+ (match-beginning 0) 2) (replace-match (org-export-latex-protect-string (format "\\label{%s}%s" (save-match-data (org-solidify-link-text @@ -1736,9 +1812,10 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER." (goto-char (point-min)) (while (re-search-forward "\\[\\([0-9]+\\)\\]" nil t) (org-if-unprotected - (when (save-match-data - (save-excursion (beginning-of-line) - (looking-at "[^:|#]"))) + (when (and (save-match-data + (save-excursion (beginning-of-line) + (looking-at "[^:|#]"))) + (not (org-in-verbatim-emphasis))) (let ((foot-beg (match-beginning 0)) (foot-end (match-end 0)) (foot-prefix (match-string 0)) @@ -1969,7 +2046,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER." (when (consp x) (add-to-list 'org-latex-entities-exceptions x) (setq x (car x))) - (if (string-match "[a-z][A-Z]$" x) + (if (string-match "[a-zA-Z]$" x) (push x names) (push x rest))) (concat "\\(" (regexp-opt (nreverse names)) "\\>\\)" diff --git a/lisp/org/org-list.el b/lisp/org/org-list.el index ed09f5b585..99cc4feeef 100644 --- a/lisp/org/org-list.el +++ b/lisp/org/org-list.el @@ -7,7 +7,7 @@ ;; Bastien Guerry ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; @@ -149,7 +149,7 @@ toggle a checkbox with \\[org-ctrl-c-ctrl-c]." (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. -This can be set to nil on a per-node basis using a COCKIE_DATA property +This can be set to nil on a per-node basis using a COOKIE_DATA property with the word \"recursive\" in the value." :group 'org-plain-lists :type 'boolean) @@ -840,6 +840,7 @@ with something like \"1.\" or \"2)\"." (org-goto-line line) (org-move-to-column col))) +(defvar org-suppress-item-indentation) ; dynamically scoped parameter (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." @@ -874,7 +875,8 @@ Also, fix the indentation." (looking-at "\\S-+ *") (setq oldbullet (match-string 0)) (unless (equal bullet oldbullet) (replace-match bullet)) - (org-shift-item-indentation (- (length bullet) (length oldbullet)))))) + (org-shift-item-indentation (- (length bullet) + (length oldbullet)))))) (org-goto-line line) (org-move-to-column col) (if (string-match "[0-9]" bullet) @@ -882,19 +884,20 @@ Also, fix the indentation." (defun org-shift-item-indentation (delta) "Shift the indentation in current item by DELTA." - (save-excursion - (let ((beg (point-at-bol)) - (end (progn (org-end-of-item) (point))) - i) - (goto-char end) - (beginning-of-line 0) - (while (> (point) beg) - (when (looking-at "[ \t]*\\S-") - ;; this is not an empty line - (setq i (org-get-indentation)) - (if (and (> i 0) (> (setq i (+ i delta)) 0)) - (indent-line-to i))) - (beginning-of-line 0))))) + (unless (org-bound-and-true-p org-suppress-item-indentation) + (save-excursion + (let ((beg (point-at-bol)) + (end (progn (org-end-of-item) (point))) + i) + (goto-char end) + (beginning-of-line 0) + (while (> (point) beg) + (when (looking-at "[ \t]*\\S-") + ;; this is not an empty line + (setq i (org-get-indentation)) + (if (and (> i 0) (> (setq i (+ i delta)) 0)) + (indent-line-to i))) + (beginning-of-line 0)))))) (defun org-beginning-of-item-list () "Go to the beginning of the current item list. @@ -1040,6 +1043,29 @@ Assumes cursor in item line." (cons ind-up bullet-up) (cons ind-down bullet-down)))) +(defvar org-tab-ind-state) ; defined in org.el +(defun org-cycle-item-indentation () + (let ((org-suppress-item-indentation t) + (org-adapt-indentation nil)) + (cond + ((and (looking-at "[ \t]*$") + (looking-back "^\\([ \t]*\\)\\([-+*]\\|[0-9]+[).]\\)[ \t]+")) + (setq this-command 'org-cycle-item-indentation) + (if (eq last-command 'org-cycle-item-indentation) + (condition-case nil + (progn (org-outdent-item 1) + (if (equal org-tab-ind-state (org-get-indentation)) + (org-outdent-item 1)) + (end-of-line 1)) + (error + (progn + (while (< (org-get-indentation) org-tab-ind-state) + (progn (org-indent-item 1) (end-of-line 1))) + (setq this-command 'org-cycle)))) + (setq org-tab-ind-state (org-get-indentation)) + (org-indent-item 1)) + t)))) + (defun org-get-bullet () (save-excursion (goto-char (point-at-bol)) @@ -1172,7 +1198,7 @@ INDENT is the indentation of the list, as a string." (goto-char pos))) (defun org-list-send-list (&optional maybe) - "Send a tranformed version of this list to the receiver position. + "Send a transformed version of this list to the receiver position. With argument MAYBE, fail quietly if no transformation is defined for this list." (interactive) @@ -1186,8 +1212,8 @@ this list." (throw 'exit nil) (error "Don't know how to transform this list")))) (let* ((name (match-string 1)) - (item-beginning (org-list-item-beginning)) (transform (intern (match-string 2))) + (item-beginning (org-list-item-beginning)) (txt (buffer-substring-no-properties (car item-beginning) (org-list-end (cdr item-beginning)))) @@ -1279,6 +1305,8 @@ Valid parameters PARAMS are (setq sublist (replace-match cbon t t sublist))) (if (string-match "\\[CBOFF\\]" sublist) (setq sublist (replace-match cboff t t sublist))) + (if (string-match "\\[-\\]" sublist) + (setq sublist (replace-match "$\\boxminus$" t t sublist))) (setq rtn (concat rtn istart term ddstart sublist ddend iend isep))) (t (setq rtn (concat rtn ;; previous list diff --git a/lisp/org/org-mac-message.el b/lisp/org/org-mac-message.el index b2abe95ad4..94fe2325dd 100644 --- a/lisp/org/org-mac-message.el +++ b/lisp/org/org-mac-message.el @@ -5,7 +5,7 @@ ;; Author: John Wiegley ;; Christopher Suckling -;; Version: 6.31a +;; Version: 6.33 ;; Keywords: outlines, hypermedia, calendar, wp ;; This file is part of GNU Emacs. diff --git a/lisp/org/org-macs.el b/lisp/org/org-macs.el index f9d1d9b712..cdcbe04ab0 100644 --- a/lisp/org/org-macs.el +++ b/lisp/org/org-macs.el @@ -6,7 +6,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; @@ -121,6 +121,8 @@ We use a macro so that the test can happen at compilation time." "Execute BODY if there is no `org-protected' text property at POS." `(unless (get-text-property ,pos 'org-protected) ,@body)) +(put 'org-if-unprotected-at 'lisp-indent-function 1) + (defmacro org-with-remote-undo (_buffer &rest _body) "Execute BODY while recording undo information in two buffers." @@ -173,7 +175,7 @@ We use a macro so that the test can happen at compilation time." (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. + "Check if external program CMD for USE exists, error if not. When the program does exist, return its 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 diff --git a/lisp/org/org-mew.el b/lisp/org/org-mew.el index 4542f5be07..6ccc995c15 100644 --- a/lisp/org/org-mew.el +++ b/lisp/org/org-mew.el @@ -5,7 +5,7 @@ ;; Author: Tokuya Kameshima ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; This file is part of GNU Emacs. diff --git a/lisp/org/org-mhe.el b/lisp/org/org-mhe.el index 3f628962ec..d70bcea688 100644 --- a/lisp/org/org-mhe.el +++ b/lisp/org/org-mhe.el @@ -6,7 +6,7 @@ ;; Author: Thomas Baumann ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; diff --git a/lisp/org/org-mobile.el b/lisp/org/org-mobile.el index 65d063db7d..b9e267113d 100644 --- a/lisp/org/org-mobile.el +++ b/lisp/org/org-mobile.el @@ -4,7 +4,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; @@ -28,20 +28,21 @@ ;; This file contains the code to interact with Richard Moreland's iPhone ;; application MobileOrg. This code is documented in Appendix B of the ;; Org-mode manual. The code is not specific for the iPhone, however. -;; Any external viewer and flagging application that uses the same +;; Any external viewer/flagging/editing application that uses the same ;; conventions could be used. (require 'org) (require 'org-agenda) +(eval-when-compile (require 'cl)) (defgroup org-mobile nil - "Options concerning support for a viewer on a mobile device." + "Options concerning support for a viewer/editor on a mobile device." :tag "Org Mobile" :group 'org) (defcustom org-mobile-files '(org-agenda-files) "Files to be staged for MobileOrg. -This is basically a list of filesand directories. Files will be staged +This is basically a list of files and directories. Files will be staged directly. Directories will be search for files with the extension `.org'. In addition to this, the list may also contain the following symbols: @@ -68,7 +69,8 @@ org-agenda-text-search-extra-files "The file where captured notes and flags will be appended to. During the execution of `org-mobile-pull', the file `org-mobile-capture-file' will be emptied it's contents have -been appended to the file given here." +been appended to the file given here. This file should be in +`org-directory', and not in the staging area or on the web server." :group 'org-mobile :type 'file) @@ -88,12 +90,26 @@ should point to this file." :group 'org-mobile :type 'boolean) +(defcustom org-mobile-force-mobile-change nil + "Non-nil means, force the change made on the mobile device. +So even if there have been changes to the computer version of the entry, +force the new value set on the mobile. +When nil, mark the entry from the mobile with an error message. +Instead of nil or t, this variable can also be a list of symbols, indicating +the editing types for which the mobile version should always dominate." + :group 'org-mobile + :type '(choice + (const :tag "Always" t) + (const :tag "Never" nil) + (set :greedy t :tag "Specify" + (const todo) + (const tags) + (const priority) + (const heading) + (const body)))) + (defcustom org-mobile-action-alist - '(("d" . (org-todo 'done)) - ("a" . (org-archive-subtree-default)) - ("d-a" . (progn (org-todo 'done) (org-archive-subtree-default))) - ("todo" . (org-todo data)) - ("tags" . (org-set-tags-to data))) + '(("edit" . (org-mobile-edit data old new))) "Alist with flags and actions for mobile sync. When flagging an entry, MobileOrg will create entries that look like @@ -105,12 +121,22 @@ optional. If present, the string after the colon will be passed to the action form as the `data' variable. The car of each elements of the alist is an actions string. The cdr is an Emacs Lisp form that will be evaluated with the cursor on the headline -of that entry." +of that entry. + +For now, it is not recommended to change this variable." :group 'org-mobile :type '(repeat (cons (string :tag "Action flag") (sexp :tag "Action form")))) +(defcustom org-mobile-checksum-binary (or (executable-find "shasum") + (executable-find "sha1sum") + (executable-find "md5sum") + (executable-find "md5")) + "Executable used for computing checksums of agenda files." + :group 'org-mobile + :type 'string) + (defvar org-mobile-pre-push-hook nil "Hook run before running `org-mobile-push'. This could be used to clean up `org-mobile-directory', for example to @@ -140,36 +166,46 @@ capture file `mobileorg.org' back to the WebDAV directory, for example using `rsync' or `scp'.") (defvar org-mobile-last-flagged-files nil - "List of files containing entreis flagged in the latest pull.") + "List of files containing entries flagged in the latest pull.") (defvar org-mobile-files-alist nil) (defvar org-mobile-checksum-files nil) (defun org-mobile-prepare-file-lists () (setq org-mobile-files-alist (org-mobile-files-alist)) - (setq org-mobile-checksum-files (mapcar 'cdr org-mobile-files-alist))) + (setq org-mobile-checksum-files nil)) (defun org-mobile-files-alist () "Expand the list in `org-mobile-files' to a list of existing files." - (let* ((files - (apply 'append (mapcar - (lambda (f) - (cond - ((eq f 'org-agenda-files) (org-agenda-files t)) - ((eq f 'org-agenda-text-search-extra-files) - org-agenda-text-search-extra-files) - ((and (stringp f) (file-directory-p f)) - (directory-files f 'full "\\.org\\'")) - ((and (stringp f) (file-exists-p f)) - (list f)) - (t nil))) - org-mobile-files))) + (let* ((include-archives + (and (member 'org-agenda-text-search-extra-files org-mobile-files) + (member 'agenda-archives org-agenda-text-search-extra-files) + t)) + (files + (apply 'append + (mapcar + (lambda (f) + (cond + ((eq f 'org-agenda-files) + (org-agenda-files t include-archives)) + ((eq f 'org-agenda-text-search-extra-files) + (delq 'agenda-archives + (copy-sequence + org-agenda-text-search-extra-files))) + ((and (stringp f) (file-directory-p f)) + (directory-files f 'full "\\.org\\'")) + ((and (stringp f) (file-exists-p f)) + (list f)) + (t nil))) + org-mobile-files))) (orgdir-uname (file-name-as-directory (file-truename org-directory))) (orgdir-re (concat "\\`" (regexp-quote orgdir-uname))) uname seen rtn file link-name) ;; Make the files unique, and determine the name under which they will ;; be listed. (while (setq file (pop files)) + (if (not (file-name-absolute-p file)) + (setq file (expand-file-name file org-directory))) (setq uname (file-truename file)) (unless (member uname seen) (push uname seen) @@ -185,16 +221,41 @@ using `rsync' or `scp'.") This will create the index file, copy all agenda files there, and also create all custom agenda views, for upload to the mobile phone." (interactive) - (org-mobile-check-setup) - (org-mobile-prepare-file-lists) - (run-hooks 'org-mobile-pre-push-hook) - (org-mobile-create-sumo-agenda) - (org-save-all-org-buffers) ; to save any IDs created by this process - (org-mobile-copy-agenda-files) - (org-mobile-create-index-file) - (org-mobile-write-checksums) - (run-hooks 'org-mobile-post-push-hook) + (let ((a-buffer (get-buffer org-agenda-buffer-name))) + (let ((org-agenda-buffer-name "*SUMO*") + (org-agenda-filter org-agenda-filter) + (org-agenda-redo-command org-agenda-redo-command)) + (save-excursion + (save-window-excursion + (org-mobile-check-setup) + (org-mobile-prepare-file-lists) + (run-hooks 'org-mobile-pre-push-hook) + (message "Creating agendas...") + (let ((inhibit-redisplay t)) (org-mobile-create-sumo-agenda)) + (message "Creating agendas...done") + (org-save-all-org-buffers) ; to save any IDs created by this process + (message "Copying files...") + (org-mobile-copy-agenda-files) + (message "Writing index file...") + (org-mobile-create-index-file) + (message "Writing checksums...") + (org-mobile-write-checksums) + (run-hooks 'org-mobile-post-push-hook)))) + (redraw-display) + (when (and a-buffer (buffer-live-p a-buffer)) + (if (not (get-buffer-window a-buffer)) + (kill-buffer a-buffer) + (let ((cw (selected-window))) + (select-window (get-buffer-window a-buffer)) + + (org-agenda-redo) + (select-window cw))))) (message "Files for mobile viewer staged")) + +(defvar org-mobile-before-process-capture-hook nil + "Hook that is run after content was moved to `org-mobile-inbox-for-pull'. +The inbox file is in the current buffer, and the buffer is arrowed to the +new captured data.") ;;;###autoload (defun org-mobile-pull () @@ -208,37 +269,52 @@ agenda view showing the flagged items." (if (not (markerp insertion-marker)) (message "No new items") (org-with-point-at insertion-marker - (org-mobile-apply-flags (point) (point-max))) + (save-restriction + (narrow-to-region (point) (point-max)) + (run-hooks 'org-mobile-before-process-capture-hook))) + (org-with-point-at insertion-marker + (org-mobile-apply (point) (point-max))) (move-marker insertion-marker nil) (run-hooks 'org-mobile-post-pull-hook) (when org-mobile-last-flagged-files ;; Make an agenda view of flagged entries, but only in the files ;; where stuff has been added. (put 'org-agenda-files 'org-restrict org-mobile-last-flagged-files) - (let ((org-agenda-keep-restriced-file-list t)) + (let ((org-agenda-keep-restricted-file-list t)) (org-agenda nil "?")))))) (defun org-mobile-check-setup () "Check if org-mobile-directory has been set up." - (when (or (not org-mobile-directory) - (not (stringp org-mobile-directory)) - (not (string-match "\\S-" org-mobile-directory)) - (not (file-exists-p org-mobile-directory)) - (not (file-directory-p org-mobile-directory))) + (unless (and org-directory + (stringp org-directory) + (string-match "\\S-" org-directory) + (file-exists-p org-directory) + (file-directory-p org-directory)) + (error + "Please set `org-directory' to the directory where your org files live")) + (unless (and org-mobile-directory + (stringp org-mobile-directory) + (string-match "\\S-" org-mobile-directory) + (file-exists-p org-mobile-directory) + (file-directory-p org-mobile-directory)) (error "Variable `org-mobile-directory' must point to an existing directory")) - (when (or (not org-mobile-inbox-for-pull) - (not (stringp org-mobile-inbox-for-pull)) - (not (string-match "\\S-" org-mobile-inbox-for-pull)) - (not (file-exists-p - (file-name-directory org-mobile-inbox-for-pull)))) + (unless (and org-mobile-inbox-for-pull + (stringp org-mobile-inbox-for-pull) + (string-match "\\S-" org-mobile-inbox-for-pull) + (file-exists-p + (file-name-directory org-mobile-inbox-for-pull))) (error "Variable `org-mobile-inbox-for-pull' must point to a file in an existing directory"))) (defun org-mobile-create-index-file () "Write the index file in the WebDAV directory." - (let ((files-alist org-mobile-files-alist) - file link-name todo-kwds done-kwds tags drawers entry) + (let ((files-alist (sort (copy-sequence org-mobile-files-alist) + (lambda (a b) (string< (cdr a) (cdr b))))) + (def-todo (default-value 'org-todo-keywords)) + (def-tags (default-value 'org-tag-alist)) + file link-name todo-kwds done-kwds tags drawers entry kwds dwds twds) + (org-prepare-agenda-buffers (mapcar 'car files-alist)) (setq done-kwds (org-uniquify org-done-keywords-for-agenda)) (setq todo-kwds (org-delete-all @@ -256,61 +332,87 @@ agenda view showing the flagged items." org-tag-alist-for-agenda)))) (with-temp-file (expand-file-name org-mobile-index-file org-mobile-directory) - (insert "#+TODO: " (mapconcat 'identity todo-kwds " ") " | " - (mapconcat 'identity done-kwds " ") "\n" - "#+TAGS: " (mapconcat 'identity tags " ") "\n" - "#+DRAWERS: " (mapconcat 'identity drawers " ") "\n") - (insert "* [[file:agendas.org][Agenda Views]]\n") + (while (setq entry (pop def-todo)) + (insert "#+READONLY\n") + (setq kwds (mapcar (lambda (x) (if (string-match "(" x) + (substring x 0 (match-beginning 0)) + x)) + (cdr entry))) + (insert "#+TODO: " (mapconcat 'identity kwds " ") "\n") + (setq dwds (member "|" kwds) + twds (org-delete-all dwds kwds) + todo-kwds (org-delete-all twds todo-kwds) + done-kwds (org-delete-all dwds done-kwds))) + (when (or todo-kwds done-kwds) + (insert "#+TODO: " (mapconcat 'identity todo-kwds " ") " | " + (mapconcat 'identity done-kwds " ") "\n")) + (setq def-tags (mapcar + (lambda (x) + (cond ((null x) nil) + ((stringp x) x) + ((eq (car x) :startgroup) "{") + ((eq (car x) :endgroup) "}") + ((eq (car x) :newline) nil) + ((listp x) (car x)) + (t nil))) + def-tags)) + (setq def-tags (delq nil def-tags)) + (setq tags (org-delete-all def-tags tags)) + (setq tags (sort tags (lambda (a b) (string< (downcase a) (downcase b))))) + (setq tags (append def-tags tags nil)) + (insert "#+TAGS: " (mapconcat 'identity tags " ") "\n") + (insert "#+DRAWERS: " (mapconcat 'identity drawers " ") "\n") + (insert "#+ALLPRIORITIES: A B C" "\n") + (when (file-exists-p (expand-file-name + org-mobile-directory "agendas.org")) + (insert "* [[file:agendas.org][Agenda Views]]\n")) (while (setq entry (pop files-alist)) (setq file (car entry) link-name (cdr entry)) (insert (format "* [[file:%s][%s]]\n" link-name link-name))) - (insert (format "* [[file:%s][Captured before last sync]]\n" - org-mobile-capture-file))))) + (push (cons org-mobile-index-file (md5 (buffer-string))) + org-mobile-checksum-files)))) (defun org-mobile-copy-agenda-files () "Copy all agenda files to the stage or WebDAV directory." (let ((files-alist org-mobile-files-alist) - file buf entry link-name target-path target-dir) + file buf entry link-name target-path target-dir check) (while (setq entry (pop files-alist)) (setq file (car entry) link-name (cdr entry)) (when (file-exists-p file) (setq target-path (expand-file-name link-name org-mobile-directory) target-dir (file-name-directory target-path)) (unless (file-directory-p target-dir) - (make-directory target-dir 'parents) - (copy-file file target-path 'ok-if-exists)))) + (make-directory target-dir 'parents)) + (copy-file file target-path 'ok-if-exists) + (setq check (shell-command-to-string + (concat org-mobile-checksum-binary " " + (shell-quote-argument (expand-file-name file))))) + (when (string-match "[a-fA-F0-9]\\{30,40\\}" check) + (push (cons link-name (match-string 0 check)) + org-mobile-checksum-files)))) (setq file (expand-file-name org-mobile-capture-file org-mobile-directory)) - (unless (file-exists-p file) - (save-excursion - (setq buf (find-file file)) - (insert "\n") - (save-buffer)) - (kill-buffer buf)))) + (save-excursion + (setq buf (find-file file)) + (and (= (point-min) (point-max)) (insert "\n")) + (save-buffer) + (push (cons org-mobile-capture-file (md5 (buffer-string))) + org-mobile-checksum-files)) + (kill-buffer buf))) (defun org-mobile-write-checksums () "Create checksums for all files in `org-mobile-directory'. The table of checksums is written to the file mobile-checksums." - (let ((cmd (cond ((executable-find "shasum")) - ((executable-find "sha1sum")) - ((executable-find "md5sum")) - ((executable-find "md5")))) - (files org-mobile-checksum-files)) - (if (not cmd) - (message "Checksums could not be generated: no executable") - (with-temp-buffer - (cd org-mobile-directory) - (if (file-exists-p "agendas.org") - (push "agendas.org" files)) - (if (file-exists-p "mobileorg.org") - (push "mobileorg.org" files)) - (setq cmd (concat cmd " " (mapconcat 'shell-quote-argument files " ") - " > checksums.dat")) - (if (equal 0 (shell-command cmd)) - (message "Checksums written") - (message "Checksums could not be generated")))))) + (let ((sumfile (expand-file-name "checksums.dat" org-mobile-directory)) + (files org-mobile-checksum-files) + entry file sum) + (with-temp-file sumfile + (set-buffer-file-coding-system 'undecided-unix nil) + (while (setq entry (pop files)) + (setq file (car entry) sum (cdr entry)) + (insert (format "%s %s\n" sum file)))))) (defun org-mobile-sumo-agenda-command () "Return an agenda custom command that comprises all custom commands." @@ -342,10 +444,10 @@ The table of checksums is written to the file mobile-checksums." settings (nth 4 e)) (setq settings (cons (list 'org-agenda-title-append - (concat "KEYS=" key " TITLE: " + (concat "KEYS=" key " TITLE: " (if (and (stringp desc) (> (length desc) 0)) desc (symbol-name type)) - " " match)) + " " match "")) settings)) (push (list type match settings) new)) ((symbolp (nth 2 e)) @@ -360,12 +462,78 @@ The table of checksums is written to the file mobile-checksums." (setq settings (append gsettings settings)) (setq settings (cons (list 'org-agenda-title-append - (concat "KEYS=" gkey "#" (number-to-string + (concat "KEYS=" gkey "#" (number-to-string (setq cnt (1+ cnt))) - " TITLE: " gdesc " " match)) + " TITLE: " gdesc " " match "")) settings)) (push (list type match settings) new))))) - (list "X" "SUMO" (reverse new) nil))) + (and new (list "X" "SUMO" (reverse new) + '((org-agenda-compact-blocks nil)))))) + +(defvar org-mobile-creating-agendas nil) +(defun org-mobile-write-agenda-for-mobile (file) + (let ((all (buffer-string)) in-date id pl prefix line app short m sexp) + (with-temp-file file + (org-mode) + (insert "#+READONLY\n") + (insert all) + (goto-char (point-min)) + (while (not (eobp)) + (cond + ((looking-at "[ \t]*$")) ; keep empty lines + ((looking-at "=+$") + ;; remove underlining + (delete-region (point) (point-at-eol))) + ((get-text-property (point) 'org-agenda-structural-header) + (setq in-date nil) + (setq app (get-text-property (point) + 'org-agenda-title-append)) + (setq short (get-text-property (point) + 'short-heading)) + (when (and short (looking-at ".+")) + (replace-match short) + (beginning-of-line 1)) + (when app + (end-of-line 1) + (insert app) + (beginning-of-line 1)) + (insert "* ")) + ((get-text-property (point) 'org-agenda-date-header) + (setq in-date t) + (insert "** ")) + ((setq m (or (get-text-property (point) 'org-hd-marker) + (get-text-property (point) 'org-marker))) + (setq sexp (member (get-text-property (point) 'type) + '("diary" "sexp"))) + (if (setq pl (get-text-property (point) 'prefix-length)) + (progn + (setq prefix (org-trim (buffer-substring + (point) (+ (point) pl))) + line (org-trim (buffer-substring + (+ (point) pl) + (point-at-eol)))) + (delete-region (point-at-bol) (point-at-eol)) + (insert line "" prefix "") + (beginning-of-line 1)) + (and (looking-at "[ \t]+") (replace-match ""))) + (insert (if in-date "*** " "** ")) + (end-of-line 1) + (insert "\n") + (unless sexp + (insert (org-agenda-get-some-entry-text + m 10 " " 'planning) + "\n") + (when (setq id + (if (org-bound-and-true-p + org-mobile-force-id-on-agenda-items) + (org-id-get m 'create) + (org-entry-get m "ID"))) + (insert " :PROPERTIES:\n :ORIGINAL_ID: " id + "\n :END:\n"))))) + (beginning-of-line 2)) + (push (cons (file-name-nondirectory file) (md5 (buffer-string))) + org-mobile-checksum-files)) + (message "Agenda written to Org file %s" file))) ;;;###autoload (defun org-mobile-create-sumo-agenda () @@ -373,17 +541,19 @@ The table of checksums is written to the file mobile-checksums." (interactive) (let* ((file (expand-file-name "agendas.org" org-mobile-directory)) + (sumo (org-mobile-sumo-agenda-command)) (org-agenda-custom-commands - (list (append (org-mobile-sumo-agenda-command) - (list (list file)))))) + (list (append sumo (list (list file))))) + (org-mobile-creating-agendas t)) (unless (file-writable-p file) (error "Cannot write to file %s" file)) - (org-store-agenda-views))) + (when sumo + (org-store-agenda-views)))) (defun org-mobile-move-capture () "Move the contents of the capture file to the inbox file. Return a marker to the location where the new content has been added. -If nothing new has beed added, return nil." +If nothing new has been added, return nil." (interactive) (let ((inbox-buffer (find-file-noselect org-mobile-inbox-for-pull)) (capture-buffer (find-file-noselect @@ -404,71 +574,180 @@ If nothing new has beed added, return nil." (save-buffer) (set-buffer capture-buffer) (erase-buffer) - (save-buffer))) + (save-buffer) + (org-mobile-update-checksum-for-capture-file (buffer-string)))) (kill-buffer capture-buffer) (if not-empty insertion-point))) -(defun org-mobile-apply-flags (&optional beg end) - "Apply all flags in the current buffer. +(defun org-mobile-update-checksum-for-capture-file (buffer-string) + (let* ((file (expand-file-name "checksums.dat" org-mobile-directory)) + (buffer (find-file-noselect file))) + (when buffer + (with-current-buffer buffer + (when (re-search-forward (concat "\\([0-9a-fA-F]\\{30,\\}\\).*?" + (regexp-quote org-mobile-capture-file) + "[ \t]*$") nil t) + (goto-char (match-beginning 1)) + (delete-region (match-beginning 1) (match-end 1)) + (insert (md5 buffer-string)) + (save-buffer))) + (kill-buffer buffer)))) + +(defun org-mobile-apply (&optional beg end) + "Apply all change requests in the current buffer. If BEG and END are given, only do this in that region." (interactive) (require 'org-archive) (setq org-mobile-last-flagged-files nil) (setq beg (or beg (point-min)) end (or end (point-max))) + + ;; Remove all Note IDs (goto-char beg) + (while (re-search-forward "^\\*\\* Note ID: [-0-9A-F]+[ \t]*\n" end t) + (replace-match "")) + + ;; Find all the referenced entries, without making any changes yet (let ((marker (make-marker)) - (org-inhibit-logging 'note) + (bos-marker (make-marker)) (end (move-marker (make-marker) end)) - action data id id-pos cmd text) + (cnt-new 0) + (cnt-edit 0) + (cnt-flag 0) + (cnt-error 0) + buf-list + id-pos org-mobile-error) + + ;; Count the new captures + (goto-char beg) + (while (re-search-forward "^\\* \\(.*\\)" end t) + (and (>= (- (match-end 1) (match-beginning 1)) 2) + (not (equal (downcase (substring (match-string 1) 0 2)) "f(")) + (incf cnt-new))) + + (goto-char beg) (while (re-search-forward - "^\\*+[ \t]+F(\\([^():\n]*\\)\\(:\\([^()\n]*\\)\\)?)[ \t]+\\[\\[id:\\([^]\n ]+\\)" end t) - (goto-char (- (match-beginning 1) 2)) + "^\\*+[ \t]+F(\\([^():\n]*\\)\\(:\\([^()\n]*\\)\\)?)[ \t]+\\[\\[\\(\\(id\\|olp\\):\\([^]\n]+\\)\\)" end t) + (setq id-pos (condition-case msg + (org-mobile-locate-entry (match-string 4)) + (error (nth 1 msg)))) + (when (and (markerp id-pos) + (not (member (marker-buffer id-pos) buf-list))) + (org-mobile-timestamp-buffer (marker-buffer id-pos)) + (push (marker-buffer id-pos) buf-list)) + + (if (or (not id-pos) (stringp id-pos)) + (progn + (goto-char (+ 2 (point-at-bol))) + (insert id-pos " ") + (incf cnt-error)) + (add-text-properties (point-at-bol) (point-at-eol) + (list 'org-mobile-marker + (or id-pos "Linked entry not found"))))) + + ;; OK, now go back and start applying + (goto-char beg) + (while (re-search-forward "^\\*+[ \t]+F(\\([^():\n]*\\)\\(:\\([^()\n]*\\)\\)?)" end t) (catch 'next - (setq action (match-string 1) - data (and (match-end 3) (match-string 3)) - id (match-string 4) - cmd (if (equal action "") - '(progn - (org-toggle-tag "FLAGGED" 'on) - (and text (org-entry-put nil "THEFLAGGINGNOTE" text))) - (cdr (assoc action org-mobile-action-alist))) - text (org-trim (buffer-substring (1+ (point-at-eol)) - (save-excursion - (org-end-of-subtree t)))) - id-pos (org-id-find id 'marker)) - (if (> (length text) 0) - ;; Make TEXT into a single line, to fit into a property - (setq text (mapconcat 'identity - (org-split-string text "\n") - "\\n")) - (setq text nil)) - (unless id-pos - (insert "BAD ID REFERENCE ") - (throw 'next t)) - (unless cmd - (insert "BAD FLAG ") - (throw 'next t)) - (move-marker marker (point)) - (save-excursion - (condition-case nil - (org-with-point-at id-pos - (progn + (setq id-pos (get-text-property (point-at-bol) 'org-mobile-marker)) + (if (not (markerp id-pos)) + (progn + (incf cnt-error) + (insert "UNKNOWN PROBLEM")) + (let* ((action (match-string 1)) + (data (and (match-end 3) (match-string 3))) + (bos (point-at-bol)) + (eos (save-excursion (org-end-of-subtree t t))) + (cmd (if (equal action "") + '(progn + (incf cnt-flag) + (org-toggle-tag "FLAGGED" 'on) + (and note + (org-entry-put nil "THEFLAGGINGNOTE" note))) + (incf cnt-edit) + (cdr (assoc action org-mobile-action-alist)))) + (note (and (equal action "") + (buffer-substring (1+ (point-at-eol)) eos))) + (org-inhibit-logging 'note) ;; Do not take notes interactively + old new) + (goto-char bos) + (move-marker bos-marker (point)) + (if (re-search-forward "^** Old value[ \t]*$" eos t) + (setq old (buffer-substring + (1+ (match-end 0)) + (progn (outline-next-heading) (point))))) + (if (re-search-forward "^** New value[ \t]*$" eos t) + (setq new (buffer-substring + (1+ (match-end 0)) + (progn (outline-next-heading) + (if (eobp) (org-back-over-empty-lines)) + (point))))) + (setq old (and old (if (string-match "\\S-" old) old nil))) + (setq new (and new (if (string-match "\\S-" new) new nil))) + (if (and note (> (length note) 0)) + ;; Make Note into a single line, to fit into a property + (setq note (mapconcat 'identity + (org-split-string (org-trim note) "\n") + "\\n"))) + (unless (equal data "body") + (setq new (and new (org-trim new)) + old (and old (org-trim old)))) + (goto-char (+ 2 bos-marker)) + (unless (markerp id-pos) + (insert "BAD REFERENCE ") + (incf cnt-error) + (throw 'next t)) + (unless cmd + (insert "BAD FLAG ") + (incf cnt-error) + (throw 'next t)) + ;; Remember this place so that we can return + (move-marker marker (point)) + (setq org-mobile-error nil) + (save-excursion + (condition-case msg + (org-with-point-at id-pos + (progn (eval cmd) (if (member "FLAGGED" (org-get-tags)) (add-to-list 'org-mobile-last-flagged-files (buffer-file-name (current-buffer)))))) - (error - (progn - (switch-to-buffer (marker-buffer marker)) - (goto-char marker) - (insert "EXECUTION FAILED ") - (throw 'next t))))) - ;; If we get here, the action has been applied successfully - ;; So remove the entry - (org-back-to-heading t) - (delete-region (point) (org-end-of-subtree t t)))) + (error (setq org-mobile-error msg)))) + (when org-mobile-error + (switch-to-buffer (marker-buffer marker)) + (goto-char marker) + (incf cnt-error) + (insert (if (stringp (nth 1 org-mobile-error)) + (nth 1 org-mobile-error) + "EXECUTION FAILED") + " ") + (throw 'next t)) + ;; If we get here, the action has been applied successfully + ;; So remove the entry + (goto-char bos-marker) + (delete-region (point) (org-end-of-subtree t t)))))) + (save-buffer) (move-marker marker nil) - (move-marker end nil))) + (move-marker end nil) + (message "%d new, %d edits, %d flags, %d errors" cnt-new + cnt-edit cnt-flag cnt-error) + (sit-for 1))) + +(defun org-mobile-timestamp-buffer (buf) + "Time stamp buffer BUF, just to make sure its checksum will change." + (with-current-buffer buf + (save-excursion + (save-restriction + (widen) + (goto-char (point-min)) + (if (re-search-forward + "^\\([ \t]*\\)#\\+LAST_MOBILE_CHANGE:.*\n?" nil t) + (progn + (goto-char (match-end 1)) + (delete-region (point) (match-end 0))) + (if (looking-at ".*?-\\*-.*-\\*-") + (forward-line 1))) + (insert "#+LAST_MOBILE_CHANGE: " + (format-time-string "%Y-%m-%d %T") "\n"))))) (defun org-mobile-smart-read () "Parse the entry at point for shortcuts and expand them. @@ -480,7 +759,7 @@ The entry is expected to contain an inactive time stamp indicating when the entry was created. When setting dates and times (for example for deadlines), the time strings are interpreted relative to that creation date. -Abbreviations are expected to take up entire lines, jst because it is so +Abbreviations are expected to take up entire lines, just because it is so easy to type RET on a mobile device. Abbreviations start with one or two letters, followed immediately by a dot and then additional information. Generally the entire shortcut line is removed after action have been taken. @@ -502,6 +781,161 @@ FIXME: Hmmm, not sure if we can make his work against the auto-correction feature. Needs a bit more thinking. So this function is currently a noop.") + +(defun org-find-olp (path) + "Return a marker pointing to the entry at outline path OLP. +If anything goes wrong, the return value will instead an error message, +as a string." + (let* ((file (pop path)) + (buffer (find-file-noselect file)) + (level 1) + (lmin 1) + (lmax 1) + limit re end found pos heading cnt) + (unless buffer (error "File not found :%s" file)) + (with-current-buffer buffer + (save-excursion + (save-restriction + (widen) + (setq limit (point-max)) + (goto-char (point-min)) + (while (setq heading (pop path)) + (setq re (format org-complex-heading-regexp-format + (regexp-quote heading))) + (setq cnt 0 pos (point)) + (while (re-search-forward re end t) + (setq level (- (match-end 1) (match-beginning 1))) + (if (and (>= level lmin) (<= level lmax)) + (setq found (match-beginning 0) cnt (1+ cnt)))) + (when (= cnt 0) (error "Heading not found on level %d: %s" + lmax heading)) + (when (> cnt 1) (error "Heading not unique on level %d: %s" + lmax heading)) + (goto-char found) + (setq lmin (1+ level) lmax (+ lmin (if org-odd-levels-only 1 0))) + (setq end (save-excursion (org-end-of-subtree t t)))) + (when (org-on-heading-p) + (move-marker (make-marker) (point)))))))) + +(defun org-mobile-locate-entry (link) + (if (string-match "\\`id:\\(.*\\)$" link) + (org-id-find (match-string 1 link) 'marker) + (if (not (string-match "\\`olp:\\(.*?\\):\\(.*\\)$" link)) + nil + (let ((file (match-string 1 link)) + (path (match-string 2 link)) + (table '((?: . "%3a") (?\[ . "%5b") (?\] . "%5d") (?/ . "%2f")))) + (setq file (org-link-unescape file table)) + (setq file (expand-file-name file org-directory)) + (setq path (mapcar (lambda (x) (org-link-unescape x table)) + (org-split-string path "/"))) + (org-find-olp (cons file path)))))) + +(defun org-mobile-edit (what old new) + "Edit item WHAT in the current entry by replacing OLD with NEW. +WHAT can be \"heading\", \"todo\", \"tags\", \"priority\", or \"body\". +The edit only takes place if the current value is equal (except for +white space) the OLD. If this is so, OLD will be replace by NEW +and the command will return t. If something goes wrong, a string will +be returned that indicates what went wrong." + (let (current old1 new1) + (if (stringp what) (setq what (intern what))) + + (cond + + ((memq what '(todo todostate)) + (setq current (org-get-todo-state)) + (cond + ((equal new "DONEARCHIVE") + (org-todo 'done) + (org-archive-subtree-default)) + ((equal new current) t) ; nothing needs to be done + ((or (equal current old) + (eq org-mobile-force-mobile-change t) + (memq 'todo org-mobile-force-mobile-change)) + (org-todo (or new 'none)) t) + (t (error "State before change was expected as \"%s\", but is \"%s\"" + old current)))) + + ((eq what 'tags) + (setq current (org-get-tags) + new1 (and new (org-split-string new ":+")) + old1 (and old (org-split-string old ":+"))) + (cond + ((org-mobile-tags-same-p current new1) t) ; no change needed + ((or (org-mobile-tags-same-p current old1) + (eq org-mobile-force-mobile-change t) + (memq 'tags org-mobile-force-mobile-change)) + (org-set-tags-to new1) t) + (t (error "Tags before change were expected as \"%s\", but are \"%s\"" + (or old "") (or current ""))))) + + ((eq what 'priority) + (when (looking-at org-complex-heading-regexp) + (setq current (and (match-end 3) (substring (match-string 3) 2 3))) + (cond + ((equal current new) t) ; no action required + ((or (equal current old) + (eq org-mobile-force-mobile-change t) + (memq 'tags org-mobile-force-mobile-change)) + (org-priority (and new (string-to-char new)))) + (t (error "Priority was expected to be %s, but is %s" + old current))))) + + ((eq what 'heading) + (when (looking-at org-complex-heading-regexp) + (setq current (match-string 4)) + (cond + ((equal current new) t) ; no action required + ((or (equal current old) + (eq org-mobile-force-mobile-change t) + (memq 'heading org-mobile-force-mobile-change)) + (goto-char (match-beginning 4)) + (insert new) + (delete-region (point) (+ (point) (length current))) + (org-set-tags nil 'align)) + (t (error "Heading changed in MobileOrg and on the computer"))))) + + ((eq what 'body) + (setq current (buffer-substring (min (1+ (point-at-eol)) (point-max)) + (save-excursion (outline-next-heading) + (point)))) + (if (not (string-match "\\S-" current)) (setq current nil)) + (cond + ((org-mobile-bodies-same-p current new) t) ; no action necessary + ((or (org-mobile-bodies-same-p current old) + (eq org-mobile-force-mobile-change t) + (memq 'body org-mobile-force-mobile-change)) + (save-excursion + (end-of-line 1) + (insert "\n" new) + (or (bolp) (insert "\n")) + (delete-region (point) (progn (org-back-to-heading t) + (outline-next-heading) + (point)))) + t) + (t (error "Body was changed in MobileOrg and on the computer"))))))) + + +(defun org-mobile-tags-same-p (list1 list2) + "Are the two tag lists the same?" + (not (or (org-delete-all list1 list2) + (org-delete-all list2 list1)))) + +(defun org-mobile-bodies-same-p (a b) + "Compare if A and B are visually equal strings. +We first remove leading and trailing white space from the entire strings. +Then we split the strings into lines and remove leading/trailing whitespace +from each line. Then we compare. +A and B must be strings or nil." + (cond + ((and (not a) (not b)) t) + ((or (not a) (not b)) nil) + (t (setq a (org-trim a) b (org-trim b)) + (setq a (mapconcat 'identity (org-split-string a "[ \t]*\n[ \t]*") "\n")) + (setq b (mapconcat 'identity (org-split-string b "[ \t]*\n[ \t]*") "\n")) + (equal a b)))) + (provide 'org-mobile) ;; arch-tag: ace0e26c-58f2-4309-8a61-05ec1535f658 diff --git a/lisp/org/org-mouse.el b/lisp/org/org-mouse.el index e5e540d84d..7860fca225 100644 --- a/lisp/org/org-mouse.el +++ b/lisp/org/org-mouse.el @@ -4,7 +4,7 @@ ;; ;; Author: Piotr Zielinski ;; Maintainer: Carsten Dominik -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; @@ -1043,9 +1043,9 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:" (org-mouse-main-buffer (current-buffer))) (when (eq (with-current-buffer buffer major-mode) 'org-mode) (let ((endmarker (with-current-buffer buffer - (outline-end-of-subtree) - (forward-char 1) - (copy-marker (point))))) + (outline-end-of-subtree) + (forward-char 1) + (copy-marker (point))))) (org-with-remote-undo buffer (with-current-buffer buffer (widen) @@ -1131,13 +1131,13 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:" (add-hook 'org-agenda-mode-hook '(lambda () (setq org-mouse-context-menu-function 'org-mouse-agenda-context-menu) - (define-key org-agenda-keymap + (define-key org-agenda-mode-map (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 (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] + (define-key org-agenda-mode-map [down-mouse-3] 'org-mouse-move-tree-start) + (define-key org-agenda-mode-map (if (featurep 'xemacs) [(control mouse-4)] [C-mouse-4]) 'org-agenda-earlier) + (define-key org-agenda-mode-map (if (featurep 'xemacs) [(control mouse-5)] [C-mouse-5]) 'org-agenda-later) + (define-key org-agenda-mode-map [drag-mouse-3] '(lambda (event) (interactive "e") (case (org-mouse-get-gesture event) (:left (org-agenda-earlier 1)) diff --git a/lisp/org/org-plot.el b/lisp/org/org-plot.el index 81605f79c3..f91df114ac 100644 --- a/lisp/org/org-plot.el +++ b/lisp/org/org-plot.el @@ -5,7 +5,7 @@ ;; Author: Eric Schulte ;; Keywords: tables, plotting ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; @@ -280,7 +280,7 @@ line directly before or after the table." (delete-other-windows) (when (get-buffer "*gnuplot*") ;; reset *gnuplot* if it already running (with-current-buffer "*gnuplot*" - (goto-char (point-max)) + (goto-char (point-max)) (gnuplot-delchar-or-maybe-eof nil))) (org-plot/goto-nearest-table) ;; set default options diff --git a/lisp/org/org-protocol.el b/lisp/org/org-protocol.el index 3b4f53f3b7..30d2dd3a05 100644 --- a/lisp/org/org-protocol.el +++ b/lisp/org/org-protocol.el @@ -9,7 +9,7 @@ ;; Author: Ross Patterson ;; Maintainer: Sebastian Rose ;; Keywords: org, emacsclient, wp -;; Version: 6.31a +;; Version: 6.33 ;; This file is part of GNU Emacs. ;; @@ -88,7 +88,7 @@ ;; 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 +;; Org-mode is loaded, emacs will pop-up 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. @@ -109,8 +109,8 @@ ;; ;; 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. +;; Note, that using double slashes is optional from org-protocol.el's point of +;; view because emacsclient squashes the slashes to one. ;; ;; ;; provides: 'org-protocol @@ -231,7 +231,7 @@ function - function that handles requests with protocol and takes exactly one `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 + detected. This is necessary for actions that can be interrupted 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. @@ -280,6 +280,17 @@ decode each split part." (mapcar 'org-protocol-unhex-string split-parts)) split-parts))) +;; This inline function is needed in org-protocol-unhex-compound to do +;; the right thing to decode UTF-8 char integer values. +(eval-when-compile + (if (>= emacs-major-version 23) + (defsubst org-protocol-char-to-string(c) + "Defsubst to decode UTF-8 character values in emacs 23 and beyond." + (char-to-string c)) + (defsubst org-protocol-char-to-string (c) + "Defsubst to decode UTF-8 character values in emacs 22." + (string (decode-char 'ucs c))))) + (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 `ü'." @@ -331,7 +342,7 @@ encodeURIComponent. E.g. `%C3%B6' is the german Umlaut `ü'." (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 ret (concat ret (org-protocol-char-to-string sum))) (setq sum 0)) )) ;; end (while bytes ret )) @@ -428,7 +439,7 @@ The sub-protocol used to reach this function is set in 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 '/' +This function detects an URL, title and optional text, separated by '/' The location for a browser's bookmark has to look like this: javascript:location.href='org-protocol://remember://'+ \\ diff --git a/lisp/org/org-publish.el b/lisp/org/org-publish.el index 2bd9226865..d42abd43fc 100644 --- a/lisp/org/org-publish.el +++ b/lisp/org/org-publish.el @@ -4,7 +4,7 @@ ;; Author: David O'Toole ;; Maintainer: Carsten Dominik ;; Keywords: hypermedia, outlines, wp -;; Version: 6.31a +;; Version: 6.33 ;; This file is part of GNU Emacs. ;; @@ -184,7 +184,7 @@ When nil, do no timestamp checking and always publish all files." (defcustom org-publish-before-export-hook nil "Hook run before export on the Org file. The hook may modify the file in arbitrary ways before publishing happens. -The orgiginal version of the buffer will be restored after publishing." +The original version of the buffer will be restored after publishing." :group 'org-publish :type 'hook) diff --git a/lisp/org/org-remember.el b/lisp/org/org-remember.el index 708c8e9aed..5eef7a22bb 100644 --- a/lisp/org/org-remember.el +++ b/lisp/org/org-remember.el @@ -6,7 +6,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; @@ -34,6 +34,7 @@ (eval-when-compile (require 'cl)) (require 'org) +(require 'org-datetree) (declare-function remember-mode "remember" ()) (declare-function remember "remember" (&optional initial)) @@ -189,7 +190,8 @@ calendar | %:type %:date" (function :tag "Function") (const :tag "Use `org-remember-default-headline'" nil) (const :tag "At beginning of file" top) - (const :tag "At end of file" bottom)) + (const :tag "At end of file" bottom) + (const :tag "In a date tree" date-tree)) (choice :tag "Context" (const :tag "Use in all contexts" nil) (const :tag "Use in all contexts" t) @@ -296,6 +298,7 @@ RET at beg-of-buf -> Append to file as level 2 headline (defvar org-jump-to-target-location nil) (defvar org-remember-previous-location nil) +(defvar org-remember-reference-date nil) (defvar org-force-remember-template-char) ;; dynamically scoped ;; Save the major mode of the buffer we called remember from @@ -534,6 +537,8 @@ to be run from that hook to function properly." (org-set-local 'org-default-notes-file file)) (if headline (org-set-local 'org-remember-default-headline headline)) + (org-set-local 'org-remember-reference-date + (list (nth 4 dct) (nth 3 dct) (nth 5 dct))) ;; Interactive template entries (goto-char (point-min)) (while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([gGtTuUCLp]\\)?" nil t) @@ -588,12 +593,14 @@ to be run from that hook to function properly." (pall (concat prop "_ALL")) (allowed (with-current-buffer - (get-buffer (file-name-nondirectory file)) + (or (find-buffer-visiting file) + (find-file-noselect file)) (or (cdr (assoc pall org-file-properties)) (cdr (assoc pall org-global-properties)) (cdr (assoc pall org-global-properties-fixed))))) (existing (with-current-buffer - (get-buffer (file-name-nondirectory file)) + (or (find-buffer-visiting file) + (find-file-noselect file)) (mapcar 'list (org-property-values prop)))) (propprompt (concat "Value for " prop ": ")) (val (if allowed @@ -614,11 +621,12 @@ 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-no-i - (concat (if prompt prompt "Enter string") - (if default (concat " [" default "]")) - ": ") - completions nil nil nil histvar default))))))) + (insert (org-without-partial-completion + (org-completing-read-no-i + (concat (if prompt prompt "Enter string") + (if default (concat " [" default "]")) + ": ") + completions nil nil nil histvar default)))))))) (goto-char (point-min)) (if (re-search-forward "%\\?" nil t) @@ -848,6 +856,7 @@ See also the variable `org-reverse-note-order'." (delete-file (concat backup-file "~")))) (set-buffer-modified-p nil) (throw 'quit t))) + (reference-date org-remember-reference-date) (previousp (and (member current-prefix-arg '((16) 0)) org-remember-previous-location)) (clockp (equal current-prefix-arg 2)) @@ -887,9 +896,9 @@ See also the variable `org-reverse-note-order'." ;; remove empty lines at end (replace-match ""))) (goto-char (point-min)) + (setq text-before-node-creation (buffer-string)) (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) @@ -947,6 +956,10 @@ See also the variable `org-reverse-note-order'." (goto-char (point-max)) (or (bolp) (newline)) (setq org-goto-start-pos (point))) + ((eq heading 'date-tree) + (org-datetree-find-date-create reference-date) + (setq reversed nil) + (setq org-goto-start-pos (point))) ((and (stringp heading) (string-match "\\S-" heading)) (goto-char (point-min)) (if (re-search-forward diff --git a/lisp/org/org-rmail.el b/lisp/org/org-rmail.el index 111124a87e..f1fe9f8f2a 100644 --- a/lisp/org/org-rmail.el +++ b/lisp/org/org-rmail.el @@ -6,7 +6,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; diff --git a/lisp/org/org-src.el b/lisp/org/org-src.el index a5718d884d..a2321d2edd 100644 --- a/lisp/org/org-src.el +++ b/lisp/org/org-src.el @@ -5,9 +5,10 @@ ;; ;; Author: Carsten Dominik ;; Bastien Guerry +;; Dan Davison ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; @@ -33,9 +34,12 @@ (require 'org-macs) (require 'org-compat) +(eval-when-compile + (require 'cl)) (declare-function org-do-remove-indentation "org" (&optional n)) (declare-function org-get-indentation "org" (&optional line)) +(declare-function org-switch-to-buffer-other-window "org" (&rest args)) (defcustom org-edit-src-region-extra nil "Additional regexps to identify regions for editing with `org-edit-src-code'. @@ -81,11 +85,23 @@ These are the regions where each line starts with a colon." (const fundamental-mode) (function :tag "Other (specify)"))) +(defcustom org-src-preserve-indentation nil + "If non-nil, leading whitespace characters in source code +blocks are preserved on export, and when switching between the +org buffer and the language mode edit buffer. If this variable +is nil then, after editing with \\[org-edit-src-code], the +minimum (across-lines) number of leading whitespace characters +are removed from all lines, and the code block is uniformly +indented according to the value of `org-edit-src-content-indentation'." + :group 'org-edit-structure + :type 'boolean) + (defcustom org-edit-src-content-indentation 2 - "Indentation for the content is a source code block. + "Indentation for the content of 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]." +editing it with \\[org-edit-src-code]. Has no effect if +`org-src-preserve-indentation' is non-nil." :group 'org-edit-structure :type 'integer) @@ -98,6 +114,25 @@ When nil, the message will only be shown intermittently in the echo area." :type 'boolean) +(defcustom org-src-window-setup 'reorganize-frame + "How the source code edit buffer should be displayed. +Possible values for this option are: + +current-window Show edit buffer in the current window, keeping all other + windows. +other-window Use `switch-to-buffer-other-window' to display edit buffer. +reorganize-frame Show only two windows on the current frame, the current + window and the edit buffer. When exiting the edit buffer, + return to one window. +other-frame Use `switch-to-buffer-other-frame' to display edit buffer. + Also, when exiting the edit buffer, kill that frame." + :group 'org-edit-structure + :type '(choice + (const current-window) + (const other-frame) + (const other-window) + (const reorganize-frame))) + (defvar org-src-mode-hook nil "Hook run after Org switched a source code snippet to its Emacs mode. This hook will run @@ -111,7 +146,7 @@ but which mess up the display of a snippet in Org exported files.") (defcustom org-src-lang-modes '(("ocaml" . tuareg) ("elisp" . emacs-lisp) ("ditaa" . artist) - ("asymptote" . asy)) + ("asymptote" . asy) ("dot" . fundamental)) "Alist mapping languages to their major mode. The key is the language name, the value is the string that should be inserted as the name of the major mode. For many languages this is @@ -135,7 +170,14 @@ For example, there is no ocaml-mode in Emacs, but the mode to use is (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) +(defvar org-edit-src-block-indentation nil) +(defvar org-edit-src-saved-temp-window-config nil) + +(defvar org-src-ask-before-returning-to-edit-buffer t + "If nil, when org-edit-src code is used on a block that already + has an active edit buffer, it will switch to that edit buffer + immediately; otherwise it will ask whether you want to return + to the existing edit buffer.") (define-minor-mode org-src-mode "Minor mode for language major mode buffers generated by org. @@ -145,14 +187,18 @@ This minor mode is turned on in two situations: There is a mode hook, and keybindings for `org-edit-src-exit' and `org-edit-src-save'") -(defun org-edit-src-code () +(defun org-edit-src-code (&optional context) "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." +the edited version. Optional argument CONTEXT is used by +\\[org-edit-src-save] when calling this function." (interactive) + (unless (eq context 'save) + (setq org-edit-src-saved-temp-window-config (current-window-configuration))) (let ((line (org-current-line)) + (col (current-column)) (case-fold-search t) (msg (substitute-command-keys "Edit, then exit with C-c ' (C-c and single quote)")) @@ -160,7 +206,8 @@ the edited version." (org-mode-p (eq major-mode 'org-mode)) (beg (make-marker)) (end (make-marker)) - nindent ovl lang lang-f single lfmt code begline buffer) + (preserve-indentation org-src-preserve-indentation) + block-nindent total-nindent ovl lang lang-f single lfmt code begline buffer) (if (not info) nil (setq beg (move-marker beg (nth 0 info)) @@ -171,15 +218,16 @@ the edited version." lang (if (symbolp lang) (symbol-name lang) lang) single (nth 3 info) lfmt (nth 4 info) - nindent (nth 5 info) + block-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)) (org-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) + (if org-src-ask-before-returning-to-edit-buffer + (y-or-n-p "Return to existing edit buffer? [n] will revert changes: ") t)) + (org-src-switch-to-buffer buffer 'return) (when buffer (with-current-buffer buffer (if (boundp 'org-edit-src-overlay) @@ -188,7 +236,6 @@ the edited version." (setq buffer (generate-new-buffer (org-src-construct-edit-buffer-name (buffer-name) lang))) (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) @@ -198,26 +245,33 @@ the edited version." (define-key map [mouse-1] 'org-edit-src-continue) map)) (org-overlay-put ovl :read-only "Leave me alone") - (switch-to-buffer buffer) + (org-src-switch-to-buffer buffer 'edit) + (if (eq single 'macro-definition) + (setq code (replace-regexp-in-string "\\\\n" "\n" code t t))) (insert code) (remove-text-properties (point-min) (point-max) '(display nil invisible nil intangible nil)) - (org-do-remove-indentation) + (unless preserve-indentation + (setq total-nindent (or (org-do-remove-indentation) 0))) (let ((org-inhibit-startup t)) (funcall lang-f)) (set (make-local-variable 'org-edit-src-force-single-line) single) (set (make-local-variable 'org-edit-src-from-org-mode) org-mode-p) + (set (make-local-variable 'org-src-preserve-indentation) preserve-indentation) (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) + (if (eq (org-current-line) line) (setq total-nindent (1+ total-nindent))) (replace-match ""))) (org-goto-line (1+ (- line begline))) + (org-move-to-column + (if preserve-indentation col (max 0 (- col total-nindent)))) (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) + (org-set-local 'org-edit-src-block-indentation block-nindent) (org-src-mode) (set-buffer-modified-p nil) (and org-edit-src-persistent-message @@ -229,9 +283,35 @@ the edited version." (interactive "e") (mouse-set-point e) (let ((buf (get-char-property (point) 'edit-buffer))) - (if buf (switch-to-buffer buf) + (if buf (org-src-switch-to-buffer buf 'continue) (error "Something is wrong here")))) +(defun org-src-switch-to-buffer (buffer context) + (case org-src-window-setup + ('current-window + (switch-to-buffer buffer)) + ('other-window + (switch-to-buffer-other-window buffer)) + ('other-frame + (case context + ('exit + (let ((frame (selected-frame))) + (switch-to-buffer-other-frame buffer) + (delete-frame frame))) + ('save + (kill-buffer (current-buffer)) + (switch-to-buffer buffer)) + (t + (switch-to-buffer-other-frame buffer)))) + ('reorganize-frame + (if (eq context 'edit) (delete-other-windows)) + (org-switch-to-buffer-other-window buffer) + (if (eq context 'exit) (delete-other-windows))) + (t + (message "Invalid value %s for org-src-window-setup" + (symbol-name org-src-window-setup)) + (switch-to-buffer buffer)))) + (defun org-src-construct-edit-buffer-name (org-buffer-name lang) "Construct the buffer name for a source editing buffer" (concat "*Org Src " org-buffer-name "[ " lang " ]*")) @@ -261,13 +341,15 @@ 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)) + (col (current-column)) (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) + (preserve-indentation org-src-preserve-indentation) + block-nindent ovl beg1 end1 code begline buffer) (beginning-of-line 1) (if (looking-at "[ \t]*[^:\n \t]") nil @@ -312,7 +394,7 @@ the fragment in the Org-mode buffer." (insert code) (remove-text-properties (point-min) (point-max) '(display nil invisible nil intangible nil)) - (setq nindent (org-do-remove-indentation)) + (setq block-nindent (or (org-do-remove-indentation) 0)) (cond ((eq org-edit-fixed-width-region-mode 'artist-mode) (fundamental-mode) @@ -325,10 +407,13 @@ the fragment in the Org-mode buffer." (while (re-search-forward "^[ \t]*: ?" nil t) (replace-match "")) (org-goto-line (1+ (- line begline))) + (org-move-to-column (max 0 (- col block-nindent 2))) (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) + (org-set-local 'org-edit-src-block-indentation block-nindent) + (org-set-local 'org-edit-src-content-indentation 0) + (org-set-local 'org-src-preserve-indentation nil) (org-src-mode) (set-buffer-modified-p nil) (and org-edit-src-persistent-message @@ -339,7 +424,7 @@ the fragment in the Org-mode buffer." (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." +the language, a switch telling if the content should be in a single line." (let ((re-list (append org-edit-src-region-extra @@ -360,6 +445,8 @@ the language, a switch telling of the content should be in a single line." ("^[ \t]*#\\+ascii:" "\n" "fundamental" single-line) ("^[ \t]*#\\+begin_ascii.*\n" "\n[ \t]*#\\+end_ascii" "fundamental") ("^[ \t]*#\\+docbook:" "\n" "xml" single-line) + ("^[ \t]*#\\+macro:[ \t]+\\S-+\\( \\|$\\)" + "\n" "fundamental" macro-definition) ("^[ \t]*#\\+begin_docbook.*\n" "\n[ \t]*#\\+end_docbook" "xml") ))) (pos (point)) @@ -418,78 +505,100 @@ the language, a switch telling of the content should be in a single line." (match-string 1 s)))) (defun org-edit-src-get-indentation (pos) - "Extract the label format." + "Count leading whitespace characters on line" (save-match-data (goto-char pos) (org-get-indentation))) -(defun org-edit-src-exit () +(defun org-edit-src-exit (&optional context) "Exit special edit and protect problematic lines." (interactive) (unless org-edit-src-from-org-mode (error "This is not a 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) + (let* ((beg org-edit-src-beg-marker) + (end org-edit-src-end-marker) + (ovl org-edit-src-overlay) + (buffer (current-buffer)) + (single (org-bound-and-true-p org-edit-src-force-single-line)) + (macro (eq single 'macro-definition)) + (total-nindent (+ (or org-edit-src-block-indentation 0) + org-edit-src-content-indentation)) + (preserve-indentation org-src-preserve-indentation) + (delta 0) code line col indent) (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 ""))) + (unless macro + (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) + (org-current-line)) + col (current-column)) + (when single + (goto-char (point-min)) + (if (re-search-forward "\\s-+\\'" nil t) (replace-match "")) (goto-char (point-min)) - (while (re-search-forward "\n" nil t) - (replace-match " ")) + (let ((cnt 0)) + (while (re-search-forward "\n" nil t) + (setq cnt (1+ cnt)) + (replace-match (if macro "\\n" " ") t t)) + (when (and macro (> cnt 0)) + (goto-char (point-max)) (insert "\\n"))) (goto-char (point-min)) - (if (looking-at "\\s-*") (replace-match " ")) - (if (re-search-forward "\\s-+\\'" nil t) - (replace-match ""))) + (if (looking-at "\\s-*") (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) + (if (eq (org-current-line) line) (setq delta (1+ delta))) (replace-match ",\\1"))) (when (org-bound-and-true-p org-edit-src-picture) + (setq preserve-indentation nil) (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) - ?\ )) + (unless (or single preserve-indentation (= total-nindent 0)) + (setq indent (make-string total-nindent ?\ )) (goto-char (point-min)) (while (re-search-forward "^" nil t) - (replace-match nindent))) + (replace-match indent))) + (if (org-bound-and-true-p org-edit-src-picture) + (setq total-nindent (+ total-nindent 2))) (setq code (buffer-string)) (set-buffer-modified-p nil) - (switch-to-buffer (marker-buffer beg)) + (org-src-switch-to-buffer (marker-buffer beg) (or context 'exit)) (kill-buffer buffer) (goto-char beg) (delete-region beg end) (insert code) (goto-char beg) + (if single (just-one-space)) (org-goto-line (1- (+ (org-current-line) line))) + (org-move-to-column (if preserve-indentation col (+ col total-nindent delta))) (move-marker beg nil) - (move-marker end nil))) + (move-marker end nil)) + (unless (eq context 'save) + (when org-edit-src-saved-temp-window-config + (set-window-configuration org-edit-src-saved-temp-window-config) + (setq org-edit-src-saved-temp-window-config nil)))) (defun org-edit-src-save () "Save parent buffer with current state source-code buffer." (interactive) - (save-window-excursion - (let ((p (point)) (m (mark)) msg) - (org-edit-src-exit) + (let ((p (point)) (m (mark)) msg) + (save-window-excursion + (org-edit-src-exit 'save) (save-buffer) (setq msg (current-message)) - (org-edit-src-code) - (push-mark m 'nomessage) - (goto-char (min p (point-max))) - (message (or msg ""))))) + (if (eq org-src-window-setup 'other-frame) + (let ((org-src-window-setup 'current-window)) + (org-edit-src-code 'save)) + (org-edit-src-code 'save))) + (push-mark m 'nomessage) + (goto-char (min p (point-max))) + (message (or msg "")))) (defun org-src-mode-configure-edit-buffer () (when org-edit-src-from-org-mode diff --git a/lisp/org/org-table.el b/lisp/org/org-table.el index 452fba8bd3..a484571dcd 100644 --- a/lisp/org/org-table.el +++ b/lisp/org/org-table.el @@ -6,7 +6,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; @@ -252,14 +252,14 @@ Automatically means, when TAB or RET or C-c C-c are pressed in the line." :type 'boolean) (defcustom org-table-relative-ref-may-cross-hline t - "Non-nil means, reltive formula references may cross hlines. + "Non-nil means, relative 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. +t Relative references may cross 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 @@ -424,17 +424,28 @@ nil When nil, the command tries to be smart and figure out the ((not (re-search-forward "^[^\n\t]+$" end t)) '(16)) ((not (re-search-forward "^[^\n,]+$" end t)) '(4)) (t 1)))) - (setq re (cond - ((equal separator '(4)) "^\\|\"?[ \t]*,[ \t]*\"?") - ((equal separator '(16)) "^\\|\t") - ((integerp separator) - (format "^ *\\| *\t *\\| \\{%d,\\}" separator)) - (t (error "This should not happen")))) (goto-char beg) - (while (re-search-forward re end t) - (replace-match "| " t t)) + (if (equal separator '(4)) + (while (<= (point) end) + ;; parse the csv stuff + (cond + ((looking-at "^") (insert "| ")) + ((looking-at "[ \t]*$") (replace-match " |") (beginning-of-line 2)) + ((looking-at "[ \t]*\"\\([^\"\n]*\\)\"") + (replace-match "\\1") + (if (looking-at "\"") (insert "\""))) + ((looking-at "[^,\n]+") (goto-char (match-end 0))) + ((looking-at "[ \t]*,") (replace-match " | ")) + (t (beginning-of-line 2)))) + (setq re (cond + ((equal separator '(4)) "^\\|\"?[ \t]*,[ \t]*\"?") + ((equal separator '(16)) "^\\|\t") + ((integerp separator) + (format "^ *\\| *\t *\\| \\{%d,\\}" separator)) + (t (error "This should not happen")))) + (while (re-search-forward re end t) + (replace-match "| " t t))) (goto-char beg) - (insert " ") (org-table-align))) (defun org-table-import (file arg) @@ -2136,7 +2147,7 @@ installed in order to use this function. In a table, this command replaces the value in the current field with the result of a formula. It also installs the formula as the \"current\" column formula, by storing it in a special line below the table. When called -with a `C-u' prefix, the current field must ba a named field, and the +with a `C-u' prefix, the current field must be a named field, and the formula is installed as valid in only this specific field. When called with two `C-u' prefixes, insert the active equation @@ -2556,7 +2567,7 @@ known that the table will be realigned a little later anyway." (push (append a (list (cdr eq))) eqlname1) (org-table-put-field-property :org-untouchable t))) - ;; Now evauluate the column formulas, but skip fields covered by + ;; Now evaluate the column formulas, but skip fields covered by ;; field formulas (goto-char beg) (while (re-search-forward line-re end t) @@ -3499,10 +3510,12 @@ 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")) + + (unless (featurep 'xemacs) + (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 @@ -4202,7 +4215,7 @@ NAME-OR-ID may be the name of a table in the current file as set by a \"#+TBLNAME:\" directive. The first table following this line will then be used. Alternatively, it may be an ID referring to any entry, also in a different file. In this case, the first table -in that netry will be referenced. +in that entry will be referenced. FORM is a field or range descriptor like \"@2$3\" or or \"B3\" or \"@I$2..@II$2\". All the references must be absolute, not relative. diff --git a/lisp/org/org-timer.el b/lisp/org/org-timer.el index 715797c402..ab2a8c1d89 100644 --- a/lisp/org/org-timer.el +++ b/lisp/org/org-timer.el @@ -5,7 +5,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; @@ -217,7 +217,7 @@ If the integer is negative, the string will start with \"-\"." (defvar org-timer-mode-line-string nil) (defun org-timer-set-mode-line (value) - "Set the mode-line dispay of the relative timer. + "Set the mode-line display of the relative timer. VALUE can be `on', `off', or `pause'." (or global-mode-string (setq global-mode-string '(""))) (or (memq 'org-timer-mode-line-string global-mode-string) @@ -284,7 +284,7 @@ VALUE can be `on', `off', or `pause'." (current-time)))) (rsecs (nth 0 rtime)) (rmins (nth 1 rtime))) - (message "%d minutes %d secondes left before next time out" + (message "%d minutes %d seconds left before next time out" rmins rsecs)))) ;;;###autoload @@ -312,12 +312,12 @@ VALUE can be `on', `off', or `pause'." (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-notify (format "%s: time out" hl) t) - org-timer-last-timer timer))) + (when (not (or (eval timer) timer-set)) + (setq timer-set t) + (setq org-timer-last-timer + (run-with-timer + secs nil 'org-notify (format "%s: time out" hl) t)) + (set timer org-timer-last-timer))) '(org-timer-timer1 org-timer-timer2 org-timer-timer3))))) diff --git a/lisp/org/org-vm.el b/lisp/org/org-vm.el index b271c51566..8b0a2eeff4 100644 --- a/lisp/org/org-vm.el +++ b/lisp/org/org-vm.el @@ -6,7 +6,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; diff --git a/lisp/org/org-w3m.el b/lisp/org/org-w3m.el index feba5608fd..359182ad5b 100644 --- a/lisp/org/org-w3m.el +++ b/lisp/org/org-w3m.el @@ -5,7 +5,7 @@ ;; Author: Andy Stewart ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; @@ -26,7 +26,7 @@ ;;; Commentary: ;; This file implements copying HTML content from a w3m buffer and -;; transfomring the text on the fly so that it can be pasted into +;; transforming the text on the fly so that it can be pasted into ;; an org-mode buffer with hot links. It will also work for regions ;; in gnus buffers that have ben washed with w3m. @@ -121,7 +121,7 @@ so that it can be yanked into an Org-mode buffer with links working correctly." (point)) (defun org-w3m-get-prev-link-start () - "Move cursor to the start of prevoius link. Return point." + "Move cursor to the start of previous link. Return point." (catch 'reach (while (previous-single-property-change (point) 'w3m-anchor-sequence) ;; jump to previous anchor diff --git a/lisp/org/org-wl.el b/lisp/org/org-wl.el index f4cdf7db25..96eb0612f3 100644 --- a/lisp/org/org-wl.el +++ b/lisp/org/org-wl.el @@ -6,7 +6,7 @@ ;; Author: Tokuya Kameshima ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; diff --git a/lisp/org/org-xoxo.el b/lisp/org/org-xoxo.el index e58a0003e3..95c13dfb6d 100644 --- a/lisp/org/org-xoxo.el +++ b/lisp/org/org-xoxo.el @@ -6,7 +6,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; diff --git a/lisp/org/org.el b/lisp/org/org.el index d3db0094aa..7b2e95b097 100644 --- a/lisp/org/org.el +++ b/lisp/org/org.el @@ -6,7 +6,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.31a +;; Version: 6.33 ;; ;; This file is part of GNU Emacs. ;; @@ -95,35 +95,36 @@ ;;; Version -(defconst org-version "6.31a" +(defconst org-version "6.33" "The version number of the file org.el.") (defun org-version (&optional here) "Show the org-mode version in the echo area. With prefix arg HERE, insert it at point." (interactive "P") - (let* ((version org-version) + (let* ((origin default-directory) + (version org-version) (git-version) (dir (concat (file-name-directory (locate-library "org")) "../" ))) - (if (and (file-exists-p (expand-file-name ".git" dir)) - (executable-find "git")) - (let ((pwd (substring (pwd) 10))) - (cd dir) - (if (eql 0 (shell-command "git describe --abbrev=4 HEAD")) + (when (and (file-exists-p (expand-file-name ".git" dir)) + (executable-find "git")) + (unwind-protect + (progn + (cd dir) + (when (eql 0 (shell-command "git describe --abbrev=4 HEAD")) (with-current-buffer "*Shell Command Output*" (goto-char (point-min)) - (re-search-forward "[^\n]+") - (setq git-version (match-string 0)) - (subst-char-in-string ?- ?. git-version t) - (shell-command "git diff-index --name-only HEAD --") - (unless (eql 1 (point-max)) - (setq git-version (concat git-version ".dirty"))) - (setq version (concat version " (" git-version ")"))) - (cd pwd)))) + (setq git-version (buffer-substring (point) (point-at-eol)))) + (subst-char-in-string ?- ?. git-version t) + (when (string-match "\\S-" + (shell-command-to-string + "git diff-index --name-only HEAD --")) + (setq git-version (concat git-version ".dirty"))) + (setq version (concat version " (" git-version ")")))) + (cd origin))) (setq version (format "Org-mode version %s" version)) (if here (insert version)) - (message version) - version)) + (message version))) ;;; Compatibility constants @@ -136,6 +137,11 @@ With prefix arg HERE, insert it at point." :group 'hypermedia :group 'calendar) +(defcustom org-mode-hook nil + "Mode hook for Org-mode, run after the mode was turned on." + :group 'org + :type 'hook) + (defcustom org-load-hook nil "Hook that is run after org.el has been loaded." :group 'org @@ -187,6 +193,7 @@ to add the symbol `xyz', and the package must have a call to (const :tag " id: Global IDs for identifying entries" org-id) (const :tag " info: Links to Info nodes" org-info) (const :tag " jsinfo: Set up Sebastian Rose's JavaScript org-info.js" org-jsinfo) + (const :tag " habit: Track your consistency with habits" org-habit) (const :tag " inlinetask: Tasks independent of outline hierarchy" org-inlinetask) (const :tag " irc: Links to IRC/ERC chat sessions" org-irc) (const :tag " mac-message: Links to messages in Apple Mail" org-mac-message) @@ -196,40 +203,40 @@ to add the symbol `xyz', and the package must have a call to (const :tag " rmail: Links to RMAIL folders/messages" org-rmail) (const :tag " vm: Links to VM folders/messages" org-vm) (const :tag " wl: Links to Wanderlust folders/messages" org-wl) - (const :tag " w3m: Special cut/paste from w3m to Org." org-w3m) + (const :tag " w3m: Special cut/paste from w3m to Org-mode." org-w3m) (const :tag " mouse: Additional mouse support" org-mouse) (const :tag "C annotate-file: Annotate a file with org syntax" org-annotate-file) - (const :tag "C annotation-helper: Call Remember directly from Browser\n\t\t\t(OBSOLETE, use org-protocol)" org-annotation-helper) - (const :tag "C bookmark: Org links to bookmarks" org-bookmark) - (const :tag "C browser-url: Store link, directly from Browser\n\t\t\t(OBSOLETE, use org-protocol)" org-browser-url) + (const :tag "C bookmark: Org-mode links to bookmarks" org-bookmark) (const :tag "C checklist: Extra functions for checklists in repeated tasks" org-checklist) (const :tag "C choose: Use TODO keywords to mark decisions states" org-choose) (const :tag "C collector: Collect properties into tables" org-collector) (const :tag "C depend: TODO dependencies for Org-mode\n\t\t\t(PARTIALLY OBSOLETE, see built-in dependency support))" org-depend) - (const :tag "C elisp-symbol: Org links to emacs-lisp symbols" org-elisp-symbol) + (const :tag "C elisp-symbol: Org-mode links to emacs-lisp symbols" org-elisp-symbol) (const :tag "C eval: Include command output as text" org-eval) (const :tag "C eval-light: Evaluate inbuffer-code on demand" org-eval-light) - (const :tag "C expiry: Expiry mechanism for Org entries" org-expiry) + (const :tag "C expiry: Expiry mechanism for Org-mode entries" org-expiry) (const :tag "C exp-bibtex: Export citations using BibTeX" org-exp-bibtex) + (const :tag "C git-link: Provide org links to specific file version" org-git-link) (const :tag "C interactive-query: Interactive modification of tags query\n\t\t\t(PARTIALLY OBSOLETE, see secondary filtering)" org-interactive-query) - (const :tag "C invoice Help manage client invoices in OrgMode" org-invoice) + (const :tag "C invoice: Help manage client invoices in Org-mode" org-invoice) - (const :tag "C jira Add a jira:ticket protocol to Org" org-jira) - (const :tag "C mairix: Hook mairix search into Org for different MUAs" org-mairix) + (const :tag "C jira: Add a jira:ticket protocol to Org-mode" org-jira) + (const :tag "C learn: SuperMemo's incremental learning algorithm" org-learn) + (const :tag "C mairix: Hook mairix search into Org-mode for different MUAs" org-mairix) (const :tag "C mac-iCal Imports events from iCal.app to the Emacs diary" org-mac-iCal) (const :tag "C man: Support for links to manpages in Org-mode" org-man) (const :tag "C mtags: Support for muse-like tags" org-mtags) (const :tag "C panel: Simple routines for us with bad memory" org-panel) (const :tag "C R: Computation using the R language" org-R) - (const :tag "C registry: A registry for Org links" org-registry) + (const :tag "C registry: A registry for Org-mode links" org-registry) (const :tag "C org2rem: Convert org appointments into reminders" org2rem) (const :tag "C screen: Visit screen sessions through Org-mode links" org-screen) (const :tag "C special-blocks: Turn blocks into LaTeX envs and HTML divs" org-special-blocks) (const :tag "C sqlinsert: Convert Org-mode tables to SQL insertions" orgtbl-sqlinsert) (const :tag "C toc: Table of contents for Org-mode buffer" org-toc) - (const :tag "C track: Keep up with Org development" org-track) + (const :tag "C track: Keep up with Org-mode development" org-track) (repeat :tag "External packages" :inline t (symbol :tag "Package")))) (defcustom org-support-shift-select nil @@ -473,7 +480,7 @@ An entry can be toggled between QUOTE and normal with :type 'string) (defconst org-repeat-re - "<[0-9]\\{4\\}-[0-9][0-9]-[0-9][0-9] [^>\n]*\\([.+]?\\+[0-9]+[dwmy]\\)" + "<[0-9]\\{4\\}-[0-9][0-9]-[0-9][0-9] [^>\n]*?\\([.+]?\\+[0-9]+[dwmy]\\(/[0-9]+[dwmy]\\)?\\)" "Regular expression for specifying repeated events. After a match, group 1 contains the repeat expression.") @@ -586,6 +593,28 @@ new-frame Make a new frame each time. Note that in this case (const :tag "Each time a new frame" new-frame) (const :tag "One dedicated frame" dedicated-frame))) +(defcustom org-use-speed-commands nil + "Non-nil means, activate single letter commands at beginning of a headline." + :group 'org-structure + :type 'boolean) + +(defcustom org-speed-commands-user nil + "Alist of additional speed commands. +This list will be checked before `org-speed-commands-default' +when the variable `org-use-speed-commands' is non-nil +and when the cursor is at the beginning of a headline. +The car if each entry is a string with a single letter, which must +be assigned to `self-insert-command' in the global map. +The cdr is either a command to be called interactively, a function +to be called, or a form to be evaluated." + :group 'org-structure + :type '(repeat + (cons + (string "Command letter") + (choice + (function) + (sexp))))) + (defgroup org-cycle nil "Options concerning visibility cycling in Org-mode." :tag "Org Cycle" @@ -650,6 +679,21 @@ of the buffer." :group 'org-cycle :type 'boolean) +(defcustom org-cycle-level-after-item/entry-creation t + "Non-nil means, cycle entry level or item indentation in new empty entries. + +When the cursor is at the end of an empty headline, i.e with only stars +and maybe a TODO keyword, TAB will then switch the entry to become a child, +and then all possible anchestor states, before returning to the original state. +This makes data entry extremely fast: M-RET to create a new headline, +on TAB to make it a child, two or more tabs to make it a (grand-)uncle. + +When the cursor is at the end of an empty plain list item, one TAB will +make it a subitem, two or more tabs will back up to make this an item +higher up in the item hierarchy." + :group 'org-cycle + :type 'boolean) + (defcustom org-cycle-emulate-tab t "Where should `org-cycle' emulate TAB. nil Never @@ -971,7 +1015,7 @@ See also the variable `org-table-auto-blank-field'." (defcustom org-self-insert-cluster-for-undo t "Non-nil means cluster self-insert commands for undo when possible. -If this is set, then, like in the Emacs command loop, 20 consequtive +If this is set, then, like in the Emacs command loop, 20 consecutive characters will be undone together. This is configurable, because there is some impact on typing performance." :group 'org-table @@ -1290,7 +1334,7 @@ changes to the current buffer." When nil, an error will be generated. This variable applies only to external applications because they might choke on non-existing files. If the link is to a file that -will be openend in Emacs, the variable is ignored." +will be opened in Emacs, the variable is ignored." :group 'org-link-follow :type 'boolean) @@ -1388,6 +1432,7 @@ See `org-file-apps'.") (defcustom org-file-apps '( (auto-mode . emacs) + ("\\.mm\\'" . default) ("\\.x?html?\\'" . default) ("\\.pdf\\'" . default) ) @@ -1905,7 +1950,7 @@ Possible values are: nil Don't add anything, just change the keyword time Add a time stamp to the task -note Prompt a closing note and add it with template `org-log-note-headings' +note Prompt for a note and add it with template `org-log-note-headings' This option can also be set with on a per-file-basis with @@ -1920,7 +1965,7 @@ property to one or more of these keywords." :type '(choice (const :tag "No logging" nil) (const :tag "Record CLOSED timestamp" time) - (const :tag "Record CLOSED timestamp with closing note." note))) + (const :tag "Record CLOSED timestamp with note." note))) ;; Normalize old uses of org-log-done. (cond @@ -1928,6 +1973,51 @@ property to one or more of these keywords." ((and (listp org-log-done) (memq 'done org-log-done)) (setq org-log-done 'note))) +(defcustom org-log-reschedule nil + "Information to record when the scheduling date of a tasks is modified. + +Possible values are: + +nil Don't add anything, just change the date +time Add a time stamp to the task +note Prompt for a note and add it with template `org-log-note-headings' + +This option can also be set with on a per-file-basis with + + #+STARTUP: nologreschedule + #+STARTUP: logreschedule + #+STARTUP: lognotereschedule" + :group 'org-todo + :group 'org-progress + :type '(choice + (const :tag "No logging" nil) + (const :tag "Record timestamp" time) + (const :tag "Record timestamp with note." note))) + +(defcustom org-log-redeadline nil + "Information to record when the deadline date of a tasks is modified. + +Possible values are: + +nil Don't add anything, just change the date +time Add a time stamp to the task +note Prompt for a note and add it with template `org-log-note-headings' + +This option can also be set with on a per-file-basis with + + #+STARTUP: nologredeadline + #+STARTUP: logredeadline + #+STARTUP: lognoteredeadline + +You can have local logging settings for a subtree by setting the LOGGING +property to one or more of these keywords." + :group 'org-todo + :group 'org-progress + :type '(choice + (const :tag "No logging" nil) + (const :tag "Record timestamp" time) + (const :tag "Record timestamp with note." note))) + (defcustom org-log-note-clock-out nil "Non-nil means, record a note when clocking out of an item. This can also be configured on a per-file basis by adding one of @@ -1949,6 +2039,8 @@ When nil, only the date will be recorded." '((done . "CLOSING NOTE %t") (state . "State %-12s from %-12S %t") (note . "Note taken on %t") + (reschedule . "Rescheduled from %S on %t") + (redeadline . "New deadline from %S on %t") (clock-out . "")) "Headings for notes added to entries. The value is an alist, with the car being a symbol indicating the note @@ -1967,7 +2059,9 @@ empty string. "Heading when changing todo state (todo sequence only)" state) string) (cons (const :tag "Heading when just taking a note" note) string) - (cons (const :tag "Heading when clocking out" clock-out) string))) + (cons (const :tag "Heading when clocking out" clock-out) string) + (cons (const :tag "Heading when rescheduling" reschedule) string) + (cons (const :tag "Heading when changing deadline" redeadline) string))) (unless (assq 'note org-log-note-headings) (push '(note . "%t") org-log-note-headings)) @@ -2173,6 +2267,18 @@ org-mode generates a time duration." :group 'org-time :type 'string) +(defcustom org-time-clocksum-use-fractional nil + "If non-nil, \\[org-clock-display] uses fractional times. +org-mode generates a time duration." + :group 'org-time + :type 'boolean) + +(defcustom org-time-clocksum-fractional-format "%.2f" + "The format string used when creating CLOCKSUM lines, or when +org-mode generates a time duration." + :group 'org-time + :type 'string) + (defcustom org-deadline-warning-days 14 "No. of days before expiration during which a deadline becomes active. This variable governs the display in sparse trees and in the agenda. @@ -2187,20 +2293,29 @@ Custom commands can set this variable in the options section." (defcustom org-read-date-prefer-future t "Non-nil means, assume future for incomplete date input from user. This affects the following situations: -1. The user gives a day, but no month. +1. The user gives a month but not a year. + For example, if it is april and you enter \"feb 2\", this will be read + as feb 2, *next* year. \"May 5\", however, will be this year. +2. The user gives a day, but no month. For example, if today is the 15th, and you enter \"3\", Org-mode will read this as the third of *next* month. However, if you enter \"17\", it will be considered as *this* month. -2. The user gives a month but not a year. - For example, if it is april and you enter \"feb 2\", this will be read - as feb 2, *next* year. \"May 5\", however, will be this year. -Currently this does not work for ISO week specifications. +If you set this variable to the symbol `time', then also the following +will work: + +3. If the user gives a time, but no day. If the time is before now, + to will be interpreted as tomorrow. -When this option is nil, the current month and year will always be used -as defaults." +Currently none of this works for ISO week specifications. + +When this option is nil, the current day, month and year will always be +used as defaults." :group 'org-time - :type 'boolean) + :type '(choice + (const :tag "Never" nil) + (const :tag "Check month and day" t) + (const :tag "Check month, day, and time" time))) (defcustom org-read-date-display-live t "Non-nil means, display current interpretation of date prompt live. @@ -2272,8 +2387,12 @@ See the manual for details." (choice (cons (string :tag "Tag name") (character :tag "Access char")) - (const :tag "Start radio group" (:startgroup)) - (const :tag "End radio group" (:endgroup)) + (list :tag "Start radio group" + (const :startgroup) + (option (string :tag "Group description"))) + (list :tag "End radio group" + (const :endgroup) + (option (string :tag "Group description"))) (const :tag "New line" (:newline))))) (defcustom org-tag-persistent-alist nil @@ -2300,7 +2419,7 @@ To disable these tags on a per-file basis, insert anywhere in the file: "List of tags that can be inherited by all entries in the file. The tags will be inherited if the variable `org-use-tag-inheritance' says they should be. -This variable is populated from #+TAG lines.") +This variable is populated from #+FILETAGS lines.") (defcustom org-use-fast-tag-selection 'auto "Non-nil means, use fast tag selection scheme. @@ -2640,12 +2759,39 @@ default is the character `k' because we use the same key in the agenda." :group 'org-agenda :type 'sexp) +(defcustom org-calendar-insert-diary-entry-key [?i] + "The key to be installed in `calendar-mode-map' for adding diary entries. +This option is irrelevant until `org-agenda-diary-file' has been configured +to point to an Org-mode file. When that is the case, the command +`org-agenda-diary-entry' will be bound to the key given here, by default +`i'. In the calendar, `i' normally adds entries to `diary-file'. So +if you want to continue doing this, you need to change this to a different +key." + :group 'org-agenda + :type 'sexp) + +(defcustom org-agenda-diary-file 'diary-file + "File to which to add new entries with the `i' key in agenda and calendar. +When this is the symbol `diary-file', the functionality in the Emacs +calendar will be used to add entries to the `diary-file'. But when this +points to a file, `org-agenda-diary-entry' will be used instead." + :group 'org-agenda + :type '(choice + (const :tag "The standard Emacs diary file" diary-file) + (file :tag "Special Org file diary entries"))) + (eval-after-load "calendar" '(progn (org-defkey calendar-mode-map org-calendar-to-agenda-key 'org-calendar-goto-agenda) (org-defkey calendar-mode-map org-calendar-agenda-action-key - 'org-agenda-action))) + 'org-agenda-action) + (add-hook 'calendar-mode-hook + (lambda () + (unless (eq org-agenda-diary-file 'diary-file) + (define-key calendar-mode-map + org-calendar-insert-diary-entry-key + 'org-agenda-diary-entry)))))) (defgroup org-latex nil "Options for embedding LaTeX code into Org-mode." @@ -2749,7 +2895,7 @@ Changing this variable requires a restart of Emacs to take effect." (defcustom org-fontify-whole-heading-line nil "Non-nil means fontify the whole line for headings. This is useful when setting a background color for the -org-leve-* faces." +org-level-* faces." :group 'org-font-lock :type 'boolean) @@ -2905,7 +3051,7 @@ See also `org-completion-use-iswitchb'." Note that `iswitchb-mode' must be active for this variable to be relevant. If you decide to turn this variable on, you might well want to turn off `org-outline-path-complete-in-steps'. -Note that thi variable has only an effect if `org-completion-use-ido' is nil." +Note that this variable has only an effect if `org-completion-use-ido' is nil." :group 'org-completion :type 'boolean) @@ -2915,7 +3061,7 @@ Normal means, no org-mode-specific context." :group 'org-completion :type 'function) -;;; Functions and variables from ther packages +;;; Functions and variables from their packages ;; Declared here to avoid compiler warnings ;; XEmacs only @@ -2959,6 +3105,7 @@ Normal means, no org-mode-specific context." (declare-function org-inlinetask-remove-END-maybe "org-inlinetask" ()) (declare-function org-indent-mode "org-indent" (&optional arg)) (declare-function parse-time-string "parse-time" (string)) +(declare-function org-attach-reveal "org-attach" (&optional if-exists)) (defvar remember-data-file) (defvar texmathp-why) (declare-function speedbar-line-directory "speedbar" (&optional depth)) @@ -3131,11 +3278,15 @@ If TABLE-TYPE is non-nil, also check for table.el-type tables." (declare-function org-clock-save-markers-for-cut-and-paste "org-clock" (beg end)) (declare-function org-clock-update-mode-line "org-clock" ()) +(declare-function org-resolve-clocks "org-clock" + (&optional also-non-dangling-p prompt last-valid)) (defvar org-clock-start-time) (defvar org-clock-marker (make-marker) "Marker recording the last clock-in.") (defvar org-clock-hd-marker (make-marker) "Marker recording the last clock-in, but the headline position.") +(defvar org-clock-heading "" + "The heading of the current clock entry.") (defun org-clock-is-active () "Return non-nil if clock is currently running. The return value is actually the clock marker." @@ -3148,7 +3299,7 @@ The return value is actually the clock marker." org-clock-goto org-clock-sum org-clock-display org-clock-remove-overlays org-clock-report org-clocktable-shift org-dblock-write:clocktable - org-get-clocktable))) + org-get-clocktable org-resolve-clocks))) (defun org-clock-update-time-maybe () "If this is a CLOCK line, update it and return t. @@ -3228,6 +3379,11 @@ If yes, offer to stop it and to save the buffer with the changes." ;; Autoload org-indent.el +;; Define the variable already here, to make sure we have it. +(defvar org-indent-mode nil + "Non-nil if Org-Indent mode is enabled. +Use the command `org-indent-mode' to change this variable.") + (eval-and-compile (org-autoload "org-indent" @@ -3280,7 +3436,7 @@ Here are a few examples: Archive in file ~/org/archive.org (absolute path), as top-level trees. \"~/org/archive.org::From %s\" - Archive in file ~/org/archive.org (absolute path), und headlines + Archive in file ~/org/archive.org (absolute path), under headlines \"From FILENAME\" where file name is the current file name. \"basement::** Finished Tasks\" @@ -3317,8 +3473,8 @@ Instead, use the key `v' to cycle the archives-mode in the agenda." :group 'org-agenda-skip :type 'boolean) -(defcustom org-columns-skip-arrchived-trees t - "Non-nil means, irgnore archived trees when creating column view." +(defcustom org-columns-skip-archived-trees t + "Non-nil means, ignore archived trees when creating column view." :group 'org-archive :group 'org-properties :type 'boolean) @@ -3367,9 +3523,17 @@ collapsed state." (let* ((re (concat ":" org-archive-tag ":"))) (goto-char beg) (while (re-search-forward re end t) - (and (org-on-heading-p) (hide-subtree)) + (and (org-on-heading-p) (org-flag-subtree t)) (org-end-of-subtree t))))) +(defun org-flag-subtree (flag) + (save-excursion + (org-back-to-heading t) + (outline-end-of-heading) + (outline-flag-region (point) + (progn (org-end-of-subtree t) (point)) + flag))) + (defalias 'org-advertized-archive-subtree 'org-archive-subtree) (eval-and-compile @@ -3513,7 +3677,7 @@ groups carry important information: "Regular expression to match a timestamp time or time range. After a match, the following groups carry important information: 0 the full match -1 date plus weekday, for backreferencing to make sure both times on same day +1 date plus weekday, for back referencing to make sure both times are on the same day 2 the first time, range or not 4 the second time, if it is a range.") @@ -3541,6 +3705,12 @@ After a match, the following groups carry important information: ("logrepeat" org-log-repeat state) ("lognoterepeat" org-log-repeat note) ("nologrepeat" org-log-repeat nil) + ("logreschedule" org-log-reschedule time) + ("lognotereschedule" org-log-reschedule note) + ("nologreschedule" org-log-reschedule nil) + ("logredeadline" org-log-redeadline time) + ("lognoteredeadline" org-log-redeadline note) + ("nologredeadline" org-log-redeadline nil) ("fninline" org-footnote-define-inline t) ("nofninline" org-footnote-define-inline nil) ("fnlocal" org-footnote-section nil) @@ -3927,7 +4097,6 @@ This is for getting out of special buffers like remember.") (defvar org-struct-menu) (defvar org-org-menu) (defvar org-tbl-menu) -(defvar org-agenda-keymap) ;;;; Define the Org-mode @@ -3945,8 +4114,6 @@ This variable is set by `org-before-change-function'. "Every change indicates that a table might need an update." (setq org-table-may-need-update t)) (defvar org-mode-map) -(defvar org-mode-hook nil - "Mode hook for Org-mode, run after the mode was turned on.") (defvar org-inhibit-startup nil) ; Dynamically-scoped param. (defvar org-agenda-keep-modes nil) ; Dynamically-scoped param. (defvar org-inhibit-logging nil) ; Dynamically-scoped param. @@ -4085,6 +4252,10 @@ The following commands are available: (org-indent-mode 1)) (org-set-startup-visibility))) +(when (fboundp 'abbrev-table-put) + (abbrev-table-put org-mode-abbrev-table + :parents (list text-mode-abbrev-table))) + (put 'org-mode 'flyspell-mode-predicate 'org-mode-flyspell-verify) (defun org-current-time () @@ -4649,6 +4820,13 @@ between words." t))) (defun org-outline-level () + "Compute the outline level of the heading at point. +This function assumes that the cursor is at the beginning of a line matched +by outline-regexp. Otherwise it returns garbage. +If this is called at a normal headline, the level is the number of stars. +Use `org-reduced-level' to remove the effect of `org-odd-levels'. +For plain list items, if they are matched by `outline-regexp', this returns +1000 plus the line indentation." (save-excursion (looking-at outline-regexp) (if (match-beginning 1) @@ -4824,11 +5002,17 @@ If KWD is a number, get the corresponding match group." (inhibit-read-only t) (inhibit-point-motion-hooks t) (inhibit-modification-hooks t) deactivate-mark buffer-file-name buffer-file-truename) - (remove-text-properties beg end - '(mouse-face t keymap t org-linked-text t - invisible t intangible t - line-prefix t wrap-prefix t - org-no-flyspell t)))) + (remove-text-properties + beg end + (if org-indent-mode + ;; also remove line-prefix and wrap-prefix properties + '(mouse-face t keymap t org-linked-text t + invisible t intangible t + line-prefix t wrap-prefix t + org-no-flyspell t) + '(mouse-face t keymap t org-linked-text t + invisible t intangible t + org-no-flyspell t))))) ;;;; Visibility cycling, including org-goto and indirect buffer @@ -4847,7 +5031,7 @@ If KWD is a number, get the corresponding match group." "TAB-action and visibility cycling for Org-mode. This is the command invoked in Org-mode by the TAB key. Its main purpose -is outine visibility cycling, but it also invokes other actions +is outline visibility cycling, but it also invokes other actions in special contexts. - When this function is called with a prefix argument, rotate the entire @@ -4885,7 +5069,10 @@ in special contexts. But only if also the variable `org-cycle-global-at-bob' is t." (interactive "P") (org-load-modules-maybe) - (unless (run-hook-with-args-until-success 'org-tab-first-hook) + (unless (or (run-hook-with-args-until-success 'org-tab-first-hook) + (and org-cycle-level-after-item/entry-creation + (or (org-cycle-level) + (org-cycle-item-indentation)))) (let* ((limit-level (or org-cycle-max-level (and (boundp 'org-inlinetask-min-level) @@ -4972,6 +5159,9 @@ in special contexts. ((org-try-cdlatex-tab)) + ((run-hook-with-args-until-success + 'org-tab-before-tab-emulation-hook)) + ((and (eq org-cycle-emulate-tab 'exc-hl-bol) (or (not (bolp)) (not (looking-at outline-regexp)))) @@ -5318,6 +5508,27 @@ are at least `org-cycle-separator-lines' empty lines before the headline." (let ((context (if (org-up-heading-safe) 'children 'overview))) (org-cycle-show-empty-lines context)))) +(defun org-files-list () + "Return `org-agenda-files' list, plus all open org-mode files. +This is useful for operations that need to scan all of a user's +open and agenda-wise Org files." + (let ((files (mapcar 'expand-file-name (org-agenda-files)))) + (dolist (buf (buffer-list)) + (with-current-buffer buf + (if (and (eq major-mode 'org-mode) (buffer-file-name)) + (let ((file (expand-file-name (buffer-file-name)))) + (unless (member file files) + (push file files)))))) + files)) + +(defsubst org-entry-beginning-position () + "Return the beginning position of the current entry." + (save-excursion (outline-back-to-heading t) (point))) + +(defsubst org-entry-end-position () + "Return the end position of the current entry." + (save-excursion (outline-next-heading) (point))) + (defun org-cycle-hide-drawers (state) "Re-hide all drawers after a visibility state change." (when (and (org-mode-p) @@ -5366,7 +5577,7 @@ Optional argument N means, put the headline into the Nth line of the window." "Regular expression for hiding blocks.") (defvar org-hide-block-overlays nil - "Overays hiding blocks.") + "Overlays hiding blocks.") (make-variable-buffer-local 'org-hide-block-overlays) (defun org-block-map (function &optional start end) @@ -5497,7 +5708,7 @@ RET=jump to location [Q]uit and return to previous location (defvar org-goto-start-pos) ; dynamically scoped parameter -;; FIXME: Docstring doe not mention both interfaces +;; FIXME: Docstring does not mention both interfaces (defun org-goto (&optional alternative-interface) "Look up a different location in the current file, keeping current visibility. @@ -5988,6 +6199,16 @@ in the region." ((eolp) (insert " ")) ((equal (char-after) ?\ ) (forward-char 1)))))) +(defun org-current-level () + "Return the level of the current entry, or nil if before the first headline. +The level is the number of stars at the beginning of the headline." + (save-excursion + (condition-case nil + (progn + (org-back-to-heading t) + (funcall outline-level)) + (error nil)))) + (defun org-reduced-level (l) "Compute the effective level of a heading. This takes into account the setting of `org-odd-levels-only'." @@ -6040,6 +6261,31 @@ in the region." (if org-adapt-indentation (org-fixup-indentation diff)) (run-hooks 'org-after-demote-entry-hook))) +(defvar org-tab-ind-state nil) + +(defun org-cycle-level () + (let ((org-adapt-indentation nil)) + (when (and (looking-at "[ \t]*$") + (looking-back + (concat "^\\(\\*+\\)[ \t]+\\(" org-todo-regexp "\\)?[ \t]*"))) + (setq this-command 'org-cycle-level) + (if (eq last-command 'org-cycle-level) + (condition-case nil + (progn (org-do-promote) + (if (equal org-tab-ind-state (org-current-level)) + (org-do-promote))) + (error + (progn + (save-excursion + (beginning-of-line 1) + (and (looking-at "\\*+") + (replace-match + (make-string org-tab-ind-state ?*)))) + (setq this-command 'org-cycle)))) + (setq org-tab-ind-state (- (match-end 1) (match-beginning 1))) + (org-do-demote)) + t))) + (defun org-map-tree (fun) "Call FUN for every heading underneath the current one." (org-back-to-heading) @@ -6489,6 +6735,7 @@ and still retain the repeater to cover future instances of the task." (org-back-to-heading t) (setq beg (point)) (org-end-of-subtree t t) + (or (bolp) (insert "\n")) (setq end (point)) (setq template (buffer-substring beg end)) (when (and doshift @@ -6565,7 +6812,7 @@ n Numerically, by converting the beginning of the entry/item to a number. a Alphabetically, ignoring the TODO keyword and the priority, if any. t By date/time, either the first active time stamp in the entry, or, if none exist, by the first inactive one. - In items, only the first line will be chekced. + In items, only the first line will be checked. s By the scheduled date/time. d By deadline date/time. c By creation time, which is assumed to be the first inactive time stamp @@ -7762,24 +8009,27 @@ from." (iswitchb-read-buffer prompt))) (defun org-icompleting-read (&rest args) - "Completing-read using `ido-mode' or `iswitchb' speedups if available" - (if (and org-completion-use-ido - (fboundp 'ido-completing-read) - (boundp 'ido-mode) ido-mode - (listp (second args))) - (let ((ido-enter-matching-directory nil)) - (apply 'ido-completing-read (concat (car args)) - (if (consp (car (nth 1 args))) - (mapcar (lambda (x) (car x)) (nth 1 args)) - (nth 1 args)) - (cddr args))) - (if (and org-completion-use-iswitchb - (boundp 'iswitchb-mode) iswitchb-mode - (listp (second args))) - (apply 'org-iswitchb-completing-read (concat (car args)) - (mapcar (lambda (x) (car x)) (nth 1 args)) - (cddr args)) - (apply 'completing-read args)))) + "Completing-read using `ido-mode' or `iswitchb' speedups if available." + (org-without-partial-completion + (if (and org-completion-use-ido + (fboundp 'ido-completing-read) + (boundp 'ido-mode) ido-mode + (listp (second args))) + (let ((ido-enter-matching-directory nil)) + (apply 'ido-completing-read (concat (car args)) + (if (consp (car (nth 1 args))) + (mapcar (lambda (x) (car x)) (nth 1 args)) + (nth 1 args)) + (cddr args))) + (if (and org-completion-use-iswitchb + (boundp 'iswitchb-mode) iswitchb-mode + (listp (second args))) + (apply 'org-iswitchb-completing-read (concat (car args)) + (if (consp (car (nth 1 args))) + (mapcar (lambda (x) (car x)) (nth 1 args)) + (nth 1 args)) + (cddr args)) + (apply 'completing-read args))))) (defun org-extract-attributes (s) "Extract the attributes cookie from a string and set as text property." @@ -7881,7 +8131,7 @@ This is still an experimental function, your mileage may vary." ;; Planner has a slash, we do not. (setq type "elisp" path (substring path 1))) ((string-match "^//\\(.?*\\)/\\(<.*>\\)$" path) - ;; A typical message link. Planner has the id after the fina slash, + ;; A typical message link. Planner has the id after the final slash, ;; we separate it with a hash mark (setq path (concat (match-string 1 path) "#" (org-remove-angle-brackets (match-string 2 path))))) @@ -7949,7 +8199,8 @@ application the system uses for this file type." org-bracket-link-regexp "\\|" org-angle-link-re "\\|" "[ \t]:[^ \t\n]+:[ \t]*$")))) - (org-offer-links-in-entry in-emacs)) + (or (org-offer-links-in-entry in-emacs) + (progn (require 'org-attach) (org-attach-reveal 'if-exists)))) ((org-at-timestamp-p t) (org-follow-timestamp-link)) ((or (org-footnote-at-reference-p) (org-footnote-at-definition-p)) (org-footnote-action)) @@ -8110,7 +8361,7 @@ application the system uses for this file type." (run-hook-with-args 'org-follow-link-hook)) (defun org-offer-links-in-entry (&optional nth zero) - "Offer links in the curren entry and follow the selected link. + "Offer links in the current entry and follow the selected link. If there is only one link, follow it immediately as well. If NTH is an integer, immediately pick the NTH link found. If ZERO is a string, check also this string for a link, and if @@ -8132,7 +8383,8 @@ there is one, offer it as link number zero." (setq links (org-uniquify (reverse links)))) (cond - ((null links) (error "No links")) + ((null links) + (message "No links")) ((equal (length links) 1) (setq link (car links))) ((and (integerp nth) (>= (length links) (if have-zero (1+ nth) nth))) @@ -8162,7 +8414,9 @@ there is one, offer it as link number zero." (unless (and (integerp nth) (>= (length links) nth)) (error "Invalid link selection")) (setq link (nth (1- nth) links)))) - (org-open-link-from-string link in-emacs (current-buffer)))) + (if link + (progn (org-open-link-from-string link in-emacs (current-buffer)) t) + nil))) ;;;; Time estimates @@ -8674,7 +8928,7 @@ on the system \"/user@host:\"." (t (error "Bad refiling target description %s" desc))) (while (setq f (pop files)) (with-current-buffer - (if (bufferp f) f (org-get-agenda-file-buffer f)) + (if (bufferp f) f (org-get-agenda-file-buffer f)) (if (bufferp f) (setq f (buffer-file-name (buffer-base-buffer f)))) (setq f (expand-file-name f)) (if (eq org-refile-use-outline-path 'file) @@ -8770,6 +9024,7 @@ With prefix arg GOTO, the command will only visit the target location, not actually move anything. With a double prefix `C-u C-u', go to the location where the last refiling operation has put the subtree. +With a prefix argument of `2', refile to the running clock. RFLOC can be a refile location obtained in a different way. @@ -8791,11 +9046,21 @@ See also `org-refile-use-outline-path' and `org-completion-use-ido'" (error "The region is not a (sequence of) subtree(s)"))) (if (equal goto '(16)) (org-refile-goto-last-stored) - (when (setq it (or rfloc - (save-excursion - (org-refile-get-location - (if goto "Goto: " "Refile to: ") default-buffer - org-refile-allow-creating-parent-nodes)))) + (when (or + (and (equal goto 2) + org-clock-hd-marker (marker-buffer org-clock-hd-marker) + (prog1 + (setq it (list (or org-clock-heading "running clock") + (buffer-file-name + (marker-buffer org-clock-hd-marker)) + "" + (marker-position org-clock-hd-marker))) + (setq goto nil))) + (setq it (or rfloc + (save-excursion + (org-refile-get-location + (if goto "Goto: " "Refile to: ") default-buffer + org-refile-allow-creating-parent-nodes))))) (setq file (nth 1 it) re (nth 2 it) pos (nth 3 it)) @@ -8823,7 +9088,7 @@ See also `org-refile-use-outline-path' and `org-completion-use-ido'" (org-save-markers-in-region region-start region-end)) (org-copy-subtree 1 nil t)) (with-current-buffer (setq nbuf (or (find-buffer-visiting file) - (find-file-noselect file))) + (find-file-noselect file))) (setq reversed (org-notes-order-reversed-p)) (save-excursion (save-restriction @@ -8992,7 +9257,7 @@ If not found, stay at current position and return nil." (defconst org-dblock-start-re "^[ \t]*#\\+BEGIN:[ \t]+\\(\\S-+\\)\\([ \t]+\\(.*\\)\\)?" - "Matches the startline of a dynamic block, with parameters.") + "Matches the start line of a dynamic block, with parameters.") (defconst org-dblock-end-re "^[ \t]*#\\+END\\([: \t\r\n]\\|$\\)" "Matches the end of a dynamic block.") @@ -9129,6 +9394,7 @@ This function can be used in a hook." "BEGIN_SRC" "END_SRC" "CATEGORY" "COLUMNS" "CAPTION" "LABEL" + "SETUPFILE" "BIND" "MACRO")) @@ -9412,7 +9678,7 @@ DONE are present, add TODO at the beginning of the heading. With C-u prefix arg, use completion to determine the new state. With numeric prefix arg, switch to that state. With a double C-u prefix, switch to the next set of TODO keywords (nextset). -With a tripple C-u prefix, circumvent any state blocking. +With a triple C-u prefix, circumvent any state blocking. For calling through lisp, arg is also interpreted in the following way: 'none -> empty state @@ -9434,7 +9700,7 @@ For calling through lisp, arg is also interpreted in the following way: (setq org-blocker-hook nil)) (save-excursion (catch 'exit - (org-back-to-heading) + (org-back-to-heading t) (if (looking-at outline-regexp) (goto-char (1- (match-end 0)))) (or (looking-at (concat " +" org-todo-regexp "\\( +\\|$\\)")) (looking-at " *")) @@ -9500,6 +9766,8 @@ For calling through lisp, arg is also interpreted in the following way: (or (car (cdr (member head org-todo-heads))) (car org-todo-heads)))) ((car (member arg org-todo-keywords-1))) + ((stringp arg) + (error "State `%s' not valid in this file" arg)) ((nth (1- (prefix-numeric-value arg)) org-todo-keywords-1)))) ((null member) (or head (car org-todo-keywords-1))) @@ -9627,7 +9895,8 @@ changes. Such blocking occurs when: (member (plist-get change-plist :from) (cons 'done org-done-keywords)) (member (plist-get change-plist :to) - (cons 'todo org-not-done-keywords))) + (cons 'todo org-not-done-keywords)) + (not (plist-get change-plist :to))) (throw 'dont-block t)) ;; If this task has children, and any are undone, it's blocked (save-excursion @@ -9709,7 +9978,7 @@ See variable `org-track-ordered-property-with-tag'." (defun org-block-todo-from-checkboxes (change-plist) "Block turning an entry into a TODO, using checkboxes. This checks whether the current task should be blocked from state -changes because there are uncheckd boxes in this entry." +changes because there are unchecked boxes in this entry." (catch 'dont-block ;; If this is not a todo state change, or if this entry is already DONE, ;; do not block @@ -9717,7 +9986,8 @@ changes because there are uncheckd boxes in this entry." (member (plist-get change-plist :from) (cons 'done org-done-keywords)) (member (plist-get change-plist :to) - (cons 'todo org-not-done-keywords))) + (cons 'todo org-not-done-keywords)) + (not (plist-get change-plist :to))) (throw 'dont-block t)) ;; If this task has checkboxes that are not checked, it's blocked (save-excursion @@ -9796,7 +10066,7 @@ statistics everywhere." (while (and (setq level (org-up-heading-safe)) (or recursive first) (>= (point) lim)) - (setq first nil) + (setq first nil cookie-present nil) (unless (and level (not (string-match "\\" @@ -9831,10 +10101,10 @@ statistics everywhere." ndel (- (match-end 0) (match-beginning 0))) (goto-char (match-beginning 0)) (insert new) - (delete-region (point) (+ (point) ndel)))) - (when cookie-present - (run-hook-with-args 'org-after-todo-statistics-hook - cnt-done (- cnt-all cnt-done))))) + (delete-region (point) (+ (point) ndel))) + (when cookie-present + (run-hook-with-args 'org-after-todo-statistics-hook + cnt-done (- cnt-all cnt-done)))))) (run-hooks 'org-todo-statistics-hook))) (defvar org-after-todo-statistics-hook nil @@ -9855,7 +10125,7 @@ when there is a statistics cookie in the headline! (defvar org-todo-statistics-hook nil "Hook that is run whenever Org thinks TODO statistics should be updated. -This hook runs even if there is no statisics cookie present, in which case +This hook runs even if there is no statistics cookie present, in which case `org-after-todo-statistics-hook' would not run.") (defun org-todo-trigger-tag-changes (state) @@ -10004,14 +10274,16 @@ Returns the new TODO keyword, or nil if no state change should occur." (throw 'exit t))) nil))) -(defun org-get-repeat () +(defun org-get-repeat (&optional tagline) "Check if there is a deadline/schedule with repeater in this entry." (save-match-data (save-excursion (org-back-to-heading t) - (if (re-search-forward - org-repeat-re (save-excursion (outline-next-heading) (point)) t) - (match-string 1))))) + (and (re-search-forward (if tagline + (concat tagline "\\s-*" org-repeat-re) + org-repeat-re) + (org-entry-end-position) t) + (match-string-no-properties 1))))) (defvar org-last-changed-timestamp) (defvar org-last-inserted-timestamp) @@ -10124,29 +10396,41 @@ With argument REMOVE, remove any deadline from the item. When TIME is set, it should be an internal time specification, and the scheduling will use the corresponding date." (interactive "P") - (if remove - (progn - (org-remove-timestamp-with-keyword org-deadline-string) - (message "Item no longer has a deadline.")) - (if (org-get-repeat) - (error "Cannot change deadline on task with repeater, please do that by hand") - (org-add-planning-info 'deadline time 'closed) - (message "Deadline on %s" org-last-inserted-timestamp)))) - + (let ((old-date (org-entry-get nil "DEADLINE"))) + (if remove + (progn + (org-remove-timestamp-with-keyword org-deadline-string) + (message "Item no longer has a deadline.")) + (if (org-get-repeat) + (error "Cannot change deadline on task with repeater, please do that by hand") + (org-add-planning-info 'deadline time 'closed) + (when (and old-date org-log-redeadline + (not (equal old-date + (substring org-last-inserted-timestamp 1 -1)))) + (org-add-log-setup 'redeadline nil old-date 'findpos + org-log-redeadline)) + (message "Deadline on %s" org-last-inserted-timestamp))))) + (defun org-schedule (&optional remove time) "Insert the SCHEDULED: string with a timestamp to schedule a TODO item. With argument REMOVE, remove any scheduling date from the item. When TIME is set, it should be an internal time specification, and the scheduling will use the corresponding date." (interactive "P") - (if remove - (progn - (org-remove-timestamp-with-keyword org-scheduled-string) - (message "Item is no longer scheduled.")) - (if (org-get-repeat) - (error "Cannot reschedule task with repeater, please do that by hand") - (org-add-planning-info 'scheduled time 'closed) - (message "Scheduled to %s" org-last-inserted-timestamp)))) + (let ((old-date (org-entry-get nil "SCHEDULED"))) + (if remove + (progn + (org-remove-timestamp-with-keyword org-scheduled-string) + (message "Item is no longer scheduled.")) + (if (org-get-repeat) + (error "Cannot reschedule task with repeater, please do that by hand") + (org-add-planning-info 'scheduled time 'closed) + (when (and old-date org-log-reschedule + (not (equal old-date + (substring org-last-inserted-timestamp 1 -1)))) + (org-add-log-setup 'reschedule nil old-date 'findpos + org-log-reschedule)) + (message "Scheduled to %s" org-last-inserted-timestamp))))) (defun org-get-scheduled-time (pom &optional inherit) "Get the scheduled time as a time tuple, of a format suitable @@ -10158,7 +10442,7 @@ returns nil." (defun org-get-deadline-time (pom &optional inherit) "Get the deadine as a time tuple, of a format suitable for -calling org-deadlin with, or if there is no scheduling, returns +calling org-deadline with, or if there is no scheduling, returns nil." (let ((time (org-entry-get pom "DEADLINE" inherit))) (when time @@ -10258,6 +10542,7 @@ be removed." (skip-chars-backward " ") (if (looking-at " +") (replace-match "")))) (goto-char (point-max)) + (and org-adapt-indentation (bolp) (org-indent-to-column col)) (when what (insert (if (not (or (bolp) (eq (char-before) ?\ ))) " " "") @@ -10387,6 +10672,10 @@ EXTRA is additional text that will be inserted into the notes buffer." (format "state change from \"%s\" to \"%s\"" (or org-log-note-previous-state "") (or org-log-note-state ""))) + ((eq org-log-note-purpose 'reschedule) + "rescheduling") + ((eq org-log-note-purpose 'redeadline) + "changing deadline") ((eq org-log-note-purpose 'note) "this entry") (t (error "This should not happen"))))) @@ -10452,7 +10741,7 @@ EXTRA is additional text that will be inserted into the notes buffer." (and org-log-post-message (message "%s" org-log-post-message))) (defun org-remove-empty-drawer-at (drawer pos) - "Remove an emptyr DARWER drawer at position POS. + "Remove an empty drawer DRAWER at position POS. POS may also be a marker." (with-current-buffer (if (markerp pos) (marker-buffer pos) (current-buffer)) (save-excursion @@ -10472,7 +10761,7 @@ t Show entries with a specific TODO keyword. m Show entries selected by a tags/property match. p Enter a property name and its value (both with completion on existing names/values) and show entries with that property. -r Show entries matching a regular expression. +/ Show entries matching a regular expression (`r' can be used as well) d Show deadlines due within `org-deadline-warning-days'. b Show deadlines and scheduled items before a date. a Show deadlines and scheduled items after a date." @@ -10656,6 +10945,8 @@ ACTION can be `set', `up', `down', or a character." have t) (setq current org-default-priority)) (cond + ((eq action 'remove) + (setq remove t new ?\ )) ((or (eq action 'set) (if (featurep 'xemacs) (characterp action) (integerp action))) (if (not (eq action 'set)) @@ -10717,7 +11008,7 @@ ACTION can be `set', `up', `down', or a character." (defvar org-agenda-archives-mode) (defvar org-map-continue-from nil "Position from where mapping should continue. -Can be set byt the action argument to `org-scan-tag's and `org-map-entries'.") +Can be set by the action argument to `org-scan-tag's and `org-map-entries'.") (defvar org-scanner-tags nil "The current tag list while the tags scanner is running.") @@ -10754,7 +11045,6 @@ only lines with a TODO keyword are included in the output." 'mouse-face 'highlight 'org-not-done-regexp org-not-done-regexp 'org-todo-regexp org-todo-regexp - 'keymap org-agenda-keymap 'help-echo (format "mouse-2 or RET jump to org file %s" (abbreviate-file-name @@ -11497,15 +11787,15 @@ Returns the new tags string, or nil to not change the current settings." (setq tbl fulltable char ?a cnt 0) (while (setq e (pop tbl)) (cond - ((equal e '(:startgroup)) + ((equal (car e) :startgroup) (push '() groups) (setq ingroup t) (when (not (= cnt 0)) (setq cnt 0) (insert "\n")) - (insert "{ ")) - ((equal e '(:endgroup)) + (insert (if (cdr e) (format "%s: " (cdr e)) "") "{ ")) + ((equal (car e) :endgroup) (setq ingroup nil cnt 0) - (insert "}\n")) + (insert "}" (if (cdr e) (format " (%s) " (cdr e)) "") "\n")) ((equal e '(:newline)) (when (not (= cnt 0)) (setq cnt 0) @@ -11550,8 +11840,8 @@ Returns the new tags string, or nil to not change the current settings." (setq rtn (catch 'exit (while t - (message "[a-z..]:Toggle [SPC]:clear [RET]:accept [TAB]:free%s%s" - (if groups " [!] no groups" " [!]groups") + (message "[a-z..]:Toggle [SPC]:clear [RET]:accept [TAB]:free [!] %sgroups%s" + (if (not groups) "no " "") (if expert " [C-c]:window" (if exit-after-next " [C-c]:single" " [C-c]:multi"))) (setq c (let ((inhibit-quit t)) (read-char-exclusive))) (cond @@ -11656,6 +11946,7 @@ Returns the new tags string, or nil to not change the current settings." (when (equal (char-after (point-at-bol 0)) ?*) (mapc (lambda (x) (add-to-list 'tags x)) (org-split-string (org-match-string-no-properties 1) ":"))))) + (mapc (lambda (s) (add-to-list 'tags s)) org-file-tags) (mapcar 'list tags))) ;;;; The mapping API @@ -11788,7 +12079,7 @@ but in some other way.") "TABLE_EXPORT_FORMAT" "TABLE_EXPORT_FILE" "EXPORT_FILE_NAME" "EXPORT_TITLE" "EXPORT_AUTHOR" "EXPORT_DATE" "ORDERED" "NOBLOCKING" "COOKIE_DATA" "LOG_INTO_DRAWER" - "CLOCK_MODELINE_TOTAL") + "CLOCK_MODELINE_TOTAL" "STYLE") "Some properties that are used by Org-mode for various purposes. Being in this list makes sure that they are offered for completion.") @@ -11843,13 +12134,24 @@ allowed value." (cur (org-entry-get nil prop)) (allowed (org-property-get-allowed-values nil prop 'table)) (existing (mapcar 'list (org-property-values prop))) + rpl (val (cond ((stringp value) value) ((and allowed (integerp value)) (or (car (nth (1- value) allowed)) (car (org-last allowed)))) (allowed - (org-completing-read "Value: " allowed nil 'req-match)) + (message "Select 1-9,0, [RET%s]: %s" + (if cur (concat "=" cur) "") + (mapconcat 'car allowed " ")) + (setq rpl (read-char-exclusive)) + (if (equal rpl ?\r) + cur + (setq rpl (- rpl ?0)) + (if (equal rpl 0) (setq rpl 10)) + (if (and (> rpl 0) (<= rpl (length allowed))) + (car (nth (1- rpl) allowed)) + (org-completing-read "Value: " allowed nil)))) (t (let (org-completion-use-ido org-completion-use-iswitchb) (org-completing-read @@ -12699,6 +13001,7 @@ user." (defvar def) (defvar defdecode) (defvar with-time) +(defvar org-read-date-analyze-futurep nil) (defun org-read-date-display () "Display the current date prompt interpretation in the minibuffer." (when org-read-date-display-live @@ -12728,6 +13031,8 @@ user." (setq txt (concat (substring txt 0 (match-end 0)) "-" org-end-time-was-given (substring txt (match-end 0))))) + (when org-read-date-analyze-futurep + (setq txt (concat txt " (=>F)"))) (setq org-read-date-overlay (org-make-overlay (1- (point-at-eol)) (point-at-eol))) (org-overlay-display org-read-date-overlay txt 'secondary-selection)))) @@ -12737,8 +13042,8 @@ user." ;; FIXME: cleanup and comment (let (delta deltan deltaw deltadef year month day hour minute second wday pm h2 m2 tl wday1 - iso-year iso-weekday iso-week iso-year iso-date) - + iso-year iso-weekday iso-week iso-year iso-date futurep) + (setq org-read-date-analyze-futurep nil) (when (string-match "\\`[ \t]*\\.[ \t]*\\'" ans) (setq ans "+0")) @@ -12811,22 +13116,36 @@ user." month (or (nth 4 tl) (if (and org-read-date-prefer-future (nth 3 tl) (< (nth 3 tl) (nth 3 defdecode))) - (1+ (nth 4 defdecode)) + (prog1 (1+ (nth 4 defdecode)) (setq futurep t)) (nth 4 defdecode))) year (or (nth 5 tl) (if (and org-read-date-prefer-future (nth 4 tl) (< (nth 4 tl) (nth 4 defdecode))) - (1+ (nth 5 defdecode)) + (prog1 (1+ (nth 5 defdecode)) (setq futurep t)) (nth 5 defdecode))) hour (or (nth 2 tl) (nth 2 defdecode)) minute (or (nth 1 tl) (nth 1 defdecode)) second (or (nth 0 tl) 0) wday (nth 6 tl)) + (when (and (eq org-read-date-prefer-future 'time) + (not (nth 3 tl)) (not (nth 4 tl)) (not (nth 5 tl)) + (equal day (nth 3 defdecode)) + (equal month (nth 4 defdecode)) + (equal year (nth 5 defdecode)) + (nth 2 tl) + (or (< (nth 2 tl) (nth 2 defdecode)) + (and (= (nth 2 tl) (nth 2 defdecode)) + (nth 1 tl) + (< (nth 1 tl) (nth 1 defdecode))))) + (setq day (1+ day) + futurep t)) + ;; Special date definitions below (cond (iso-week ;; There was an iso week + (setq futurep nil) (setq year (or iso-year year) day (or iso-weekday wday 1) wday nil ; to make sure that the trigger below does not match @@ -12846,6 +13165,7 @@ user." year (nth 2 iso-date) day (nth 1 iso-date))) (deltan + (setq futurep nil) (unless deltadef (let ((now (decode-time (current-time)))) (setq day (nth 3 now) month (nth 4 now) year (nth 5 now)))) @@ -12854,6 +13174,7 @@ user." ((equal deltaw "m") (setq month (+ month deltan))) ((equal deltaw "y") (setq year (+ year deltan))))) ((and wday (not (nth 3 tl))) + (setq futurep nil) ;; Weekday was given, but no day, so pick that day in the week ;; on or after the derived date. (setq wday1 (nth 6 (decode-time (encode-time 0 0 0 day month year)))) @@ -12864,6 +13185,7 @@ user." (setq org-time-was-given t)) (if (< year 100) (setq year (+ 2000 year))) (if (< year 1970) (setq year (nth 5 defdecode))) ; not representable + (setq org-read-date-analyze-futurep futurep) (list second minute hour day month year))) (defvar parse-time-weekdays) @@ -12982,7 +13304,7 @@ The command returns the inserted time stamp." t1 w1 with-hm tf time str w2 (off 0)) (save-match-data (setq t1 (org-parse-time-string ts t)) - (if (string-match "\\(-[0-9]+:[0-9]+\\)?\\( [.+]?\\+[0-9]+[dwmy]\\)?\\'" ts) + (if (string-match "\\(-[0-9]+:[0-9]+\\)?\\( [.+]?\\+[0-9]+[dwmy]\\(/[0-9]+[dwmy]\\)?\\)?\\'" ts) (setq off (- (match-end 0) (match-beginning 0))))) (setq end (- end off)) (setq w1 (- end beg) @@ -13494,7 +13816,7 @@ in the timestamp determines what will be changed." ts (match-string 0)) (replace-match "") (if (string-match - "\\(\\(-[012][0-9]:[0-5][0-9]\\)?\\( +[.+]?[-+][0-9]+[dwmy]\\)*\\)[]>]" + "\\(\\(-[012][0-9]:[0-5][0-9]\\)?\\( +[.+]?[-+][0-9]+[dwmy]\\(/[0-9]+[dwmy]\\)?\\)*\\)[]>]" ts) (setq extra (match-string 1 ts))) (if (string-match "^.\\{10\\}.*?[0-9]+:[0-9][0-9]" ts) @@ -13637,7 +13959,7 @@ If there is already a time stamp at the cursor position, update it." (defun org-hh:mm-string-to-minutes (s) "Convert a string H:MM to a number of minutes. -If the string is just a number, interprete it as minutes. +If the string is just a number, interpret it as minutes. In fact, the first hh:mm or number in the string will be taken, there can be extra stuff in the string. If no number is found, the return value is 0." @@ -14398,7 +14720,7 @@ Some of the options can be changed using the variable (org-defkey org-mode-map "\C-c\C-b" 'org-backward-same-level) (org-defkey org-mode-map "\C-c$" 'org-archive-subtree) (org-defkey org-mode-map "\C-c\C-x\C-s" 'org-advertized-archive-subtree) -(org-defkey org-mode-map "\C-c\C-x\C-a" 'org-toggle-archive-tag) +(org-defkey org-mode-map "\C-c\C-x\C-a" 'org-archive-subtree-default) (org-defkey org-mode-map "\C-c\C-xa" 'org-toggle-archive-tag) (org-defkey org-mode-map "\C-c\C-xA" 'org-archive-to-archive-sibling) (org-defkey org-mode-map "\C-c\C-xb" 'org-tree-to-indirect-buffer) @@ -14505,34 +14827,115 @@ Some of the options can be changed using the variable (org-defkey org-mode-map 'button3 'popup-mode-menu)) +(defconst org-speed-commands-default + '( + ("n" . outline-next-visible-heading) + ("p" . outline-previous-visible-heading) + ("f" . org-forward-same-level) + ("b" . org-backward-same-level) + ("u" . outline-up-heading) + + ("c" . org-cycle) + ("C" . org-shifttab) + ("U" . org-shiftmetaup) + ("D" . org-shiftmetadown) + ("r" . org-metaright) + ("l" . org-metaleft) + ("R" . org-shiftmetaright) + ("L" . org-shiftmetaleft) + ("i" . (progn (forward-char 1) (call-interactively + 'org-insert-heading-respect-content))) + + ("a" . org-agenda) + ("/" . org-sparse-tree) + (";" . org-set-tags-command) + ("I" . org-clock-in) + ("O" . org-clock-out) + ("o" . org-open-at-point) + ("t" . org-todo) + ("j" . org-goto) + ("g" . (org-refile t)) + ("e" . org-set-effort) + ("0" . (org-priority ?\ )) + ("1" . (org-priority ?A)) + ("2" . (org-priority ?B)) + ("3" . (org-priority ?C)) + ("." . outline-mark-subtree) + ("^" . org-sort) + ("w" . org-refile) + ("a" . org-archive-subtree-default-with-confirmation) + ("/" . org-sparse-tree) + ("?" . org-speed-command-help) + ) + "The default speed commands.") + +(defun org-print-speed-command (e) + (princ (car e)) + (princ " ") + (if (symbolp (cdr e)) + (princ (symbol-name (cdr e))) + (prin1 (cdr e))) + (princ "\n")) + +(defun org-speed-command-help () + "Show the available speed commands." + (interactive) + (if (not org-use-speed-commands) + (error "Speed commands are not activated, customize `org-use-speed-commands'.") + (with-output-to-temp-buffer "*Help*" + (princ "Speed commands\n==============\n") + (mapc 'org-print-speed-command org-speed-commands-user) + (princ "\n") + (mapc 'org-print-speed-command org-speed-commands-default)))) + (defvar org-self-insert-command-undo-counter 0) (defvar org-table-auto-blank-field) ; defined in org-table.el +(defvar org-speed-command nil) (defun org-self-insert-command (N) "Like `self-insert-command', use overwrite-mode for whitespace in tables. If the cursor is in a table looking at whitespace, the whitespace is overwritten, and the table is not marked as requiring realignment." (interactive "p") - (if (and - (org-table-p) - (progn - ;; check if we blank the field, and if that triggers align - (and (featurep 'org-table) org-table-auto-blank-field - (member last-command - '(org-cycle org-return org-shifttab org-ctrl-c-ctrl-c yas/expand)) - (if (or (equal (char-after) ?\ ) (looking-at "[^|\n]* |")) - ;; got extra space, this field does not determine column width - (let (org-table-may-need-update) (org-table-blank-field)) + (cond + ((and org-use-speed-commands + (bolp) + (looking-at outline-regexp) + (setq + org-speed-command + (or (cdr (assoc (this-command-keys) org-speed-commands-user)) + (cdr (assoc (this-command-keys) org-speed-commands-default))))) + (cond + ((commandp org-speed-command) + (setq this-command org-speed-command) + (call-interactively org-speed-command)) + ((functionp org-speed-command) + (funcall org-speed-command)) + ((and org-speed-command (listp org-speed-command)) + (eval org-speed-command)) + (t (let (org-use-speed-commands) + (call-interactively 'org-self-insert-command))))) + ((and + (org-table-p) + (progn + ;; check if we blank the field, and if that triggers align + (and (featurep 'org-table) org-table-auto-blank-field + (member last-command + '(org-cycle org-return org-shifttab org-ctrl-c-ctrl-c yas/expand)) + (if (or (equal (char-after) ?\ ) (looking-at "[^|\n]* |")) + ;; got extra space, this field does not determine column width + (let (org-table-may-need-update) (org-table-blank-field)) ;; no extra space, this field may determine column width - (org-table-blank-field))) - t) - (eq N 1) - (looking-at "[^|\n]* |")) - (let (org-table-may-need-update) - (goto-char (1- (match-end 0))) - (delete-backward-char 1) - (goto-char (match-beginning 0)) - (self-insert-command N)) + (org-table-blank-field))) + t) + (eq N 1) + (looking-at "[^|\n]* |")) + (let (org-table-may-need-update) + (goto-char (1- (match-end 0))) + (delete-backward-char 1) + (goto-char (match-beginning 0)) + (self-insert-command N))) + (t (setq org-table-may-need-update t) (self-insert-command N) (org-fix-tags-on-the-fly) @@ -14546,7 +14949,7 @@ overwritten, and the table is not marked as requiring realignment." (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))))))) + (1+ org-self-insert-command-undo-counter)))))))) (defun org-fix-tags-on-the-fly () (when (and (equal (char-after (point-at-bol)) ?*) @@ -14676,6 +15079,12 @@ This hook runs after it has been established that not table field motion and not visibility should be done because of current context. This is probably the place where a package like yasnippets can hook in.") +(defvar org-tab-before-tab-emulation-hook nil + "Hook for functions to attach themselves to TAB. +See `org-ctrl-c-ctrl-c-hook' for more information. +This hook runs after every other options for TAB have been exhausted, but +before indentation and \t insertion takes place.") + (defvar org-metaleft-hook nil "Hook for functions attaching themselves to `M-left'. See `org-ctrl-c-ctrl-c-hook' for more information.") @@ -15443,21 +15852,11 @@ See the individual commands for more information." ["Footnote new/jump" org-footnote-action t] ["Footnote extra" (org-footnote-action t) :active t :keys "C-u C-c C-x f"]) ("Archive" - ["Toggle ARCHIVE tag" org-toggle-archive-tag t] -; ["Check and Tag Children" (org-toggle-archive-tag (4)) -; :active t :keys "C-u C-c C-x C-a"] - ["Sparse trees open ARCHIVE trees" - (setq org-sparse-tree-open-archived-trees - (not org-sparse-tree-open-archived-trees)) - :style toggle :selected org-sparse-tree-open-archived-trees] - ["Cycling opens ARCHIVE trees" - (setq org-cycle-open-archived-trees (not org-cycle-open-archived-trees)) - :style toggle :selected org-cycle-open-archived-trees] + ["Archive (default method)" org-archive-subtree-default t] "--" - ["Move subtree to archive sibling" org-archive-to-archive-sibling t] - ["Move Subtree to Archive" org-advertized-archive-subtree t] - ; ["Check and Move Children" (org-archive-subtree '(4)) - ; :active t :keys "C-u C-c C-x C-s"] + ["Move Subtree to Archive file" org-advertized-archive-subtree t] + ["Toggle ARCHIVE tag" org-toggle-archive-tag t] + ["Move subtree to Archive sibling" org-archive-to-archive-sibling t] ) "--" ("Hyperlinks" @@ -15795,6 +16194,10 @@ With prefix arg UNCOMPILED, load the uncompiled versions." "Is point in a line starting with `#'?" (equal (char-after (point-at-bol)) ?#)) +(defun org-in-verbatim-emphasis () + (save-match-data + (and (org-in-regexp org-emph-re 2) (member (match-string 3) '("=" "~"))))) + (defun org-goto-marker-or-bmk (marker &optional bookmark) "Go to MARKER, widen if necessary. When marker is not live, try BOOKMARK." (if (and marker (marker-buffer marker) @@ -15913,6 +16316,18 @@ N may optionally be the number of spaces to remove." (end-of-line 1)) min))) +(defun org-fill-template (template alist) + "Find each %key of ALIST in TEMPLATE and replace it." + (let (entry key value) + (setq alist (sort (copy-sequence alist) + (lambda (a b) (< (length (car a)) (length (car b)))))) + (while (setq entry (pop alist)) + (setq template + (replace-regexp-in-string + (concat "%" (regexp-quote (car entry))) + (cdr entry) template t t))) + template)) + (defun org-base-buffer (buffer) "Return the base buffer of BUFFER, if it has one. Else return the buffer." (if (not buffer) @@ -16041,7 +16456,7 @@ and :keyword." (push (org-point-in-group p 2 :todo-keyword) clist) (push (org-point-in-group p 4 :tags) clist)) (goto-char p) - (skip-chars-backward "^[\n\r \t") (or (eobp) (backward-char 1)) + (skip-chars-backward "^[\n\r \t") (or (bobp) (backward-char 1)) (if (looking-at "\\[#[A-Z0-9]\\]") (push (org-point-in-group p 0 :priority) clist))) @@ -16422,9 +16837,10 @@ which make use of the date at the cursor." (beginning-of-line 1) (if (looking-at "\\([ \t]+\\)\\(:[-_0-9a-zA-Z]+:\\)[ \t]*\\(\\S-.*\\(\\S-\\|$\\)\\)") - (replace-match (concat "\\1" (format org-property-format - (match-string 2) (match-string 3))) - t nil)) + (replace-match (concat (match-string 1) + (format org-property-format + (match-string 2) (match-string 3))) + t t)) (org-move-to-column column))) (defun org-set-autofill-regexps () @@ -16560,7 +16976,7 @@ This looks for a line like #+BIBLIOGRAPHY: foo plain option:-d -and derives from it that foo.bib is the bbliography file relevant +and derives from it that foo.bib is the bibliography file relevant for this document. It then installs the necessary environment for RefTeX to work in this buffer and calls `reftex-citation' to insert a citation into the buffer. @@ -17162,10 +17578,11 @@ Show the heading too, if it is currently invisible." if no description is present" (save-match-data (if (string-match org-bracket-link-analytic-regexp link) - (replace-match (or (match-string 5 link) - (concat (match-string 1 link) - (match-string 3 link))) - nil nil link) + (replace-match (if (match-end 5) + (match-string 5 link) + (concat (match-string 1 link) + (match-string 3 link))) + nil t link) link))) ;; Speedbar support @@ -17188,12 +17605,9 @@ To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]." ((setq p (text-property-any (point-at-bol) (point-at-eol) 'org-imenu t)) (setq m (get-text-property p 'org-imenu-marker)) - (save-excursion - ;; FIXME: Shouldn't set-buffer be done before save-restriction? --Stef - (save-restriction - (set-buffer (marker-buffer m)) - (goto-char m) - (org-agenda-set-restriction-lock 'subtree)))) + (with-current-buffer (marker-buffer m) + (goto-char m) + (org-agenda-set-restriction-lock 'subtree))) ((setq p (text-property-any (point-at-bol) (point-at-eol) 'speedbar-function 'speedbar-find-file)) (setq tp (previous-single-property-change @@ -17203,15 +17617,12 @@ To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]." dir (speedbar-line-directory) txt (buffer-substring-no-properties (or tp (point-min)) (or np (point-max)))) - (save-excursion - ;; FIXME: Shouldn't set-buffer be done before save-restriction? --Stef - (save-restriction - (set-buffer (find-file-noselect - (let ((default-directory dir)) - (expand-file-name txt)))) - (unless (org-mode-p) - (error "Cannot restrict to non-Org-mode file")) - (org-agenda-set-restriction-lock 'file)))) + (with-current-buffer (find-file-noselect + (let ((default-directory dir)) + (expand-file-name txt))) + (unless (org-mode-p) + (error "Cannot restrict to non-Org-mode file")) + (org-agenda-set-restriction-lock 'file))) (t (error "Don't know how to restrict Org-mode's agenda"))) (org-move-overlay org-speedbar-restriction-lock-overlay (point-at-bol) (point-at-eol)) @@ -17244,7 +17655,7 @@ To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]." (flyspell-delete-region-overlays beg end)) (add-text-properties beg end '(org-no-flyspell t))) -;; Make `bookmark-jump' show the jump location if it was hidden. +;; Make `bookmark-jump' shows the jump location if it was hidden. (eval-after-load "bookmark" '(if (boundp 'bookmark-after-jump-hook) ;; We can use the hook @@ -17254,12 +17665,19 @@ To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]." "Make the position visible." (org-bookmark-jump-unhide)))) -;; Make sure saveplace show the location if it was hidden +;; Make sure saveplace shows the location if it was hidden (eval-after-load "saveplace" '(defadvice save-place-find-file-hook (after org-make-visible activate) "Make the position visible." (org-bookmark-jump-unhide))) +;; Make sure ecb shows the location if it was hidden +(eval-after-load "ecb" + '(defadvice ecb-method-clicked (after esf/org-show-context activate) + "Make hierarchy visible when jumping into location from ECB tree buffer." + (if (eq major-mode 'org-mode) + (org-show-context)))) + (defun org-bookmark-jump-unhide () "Unhide the current position, to show the bookmark location." (and (org-mode-p) @@ -17304,3 +17722,4 @@ Still experimental, may disappear in the future." ;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd ;;; org.el ends here + -- 2.20.1