+2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
+
+ * org.el (org-edit-fixed-width-region): Exclude final newline from
+ picture area.
+
+ * org-export-latex.el (org-export-latex-subcontent): Add labels to
+ sections, to make internal links work.
+ (org-export-latex-fontify-headline): Do not remove all text
+ properties, to make sure that target properties survive this
+ process.
+
+ * org-exp.el (org-export-preprocess-string): Change sequence of
+ modifications, to make sure links are prepared before the LaTeX
+ conversions do happen.
+
+ * org-attach.el (org-attach-delete-all): Renamed from
+ `org-attch-delete'. Add a security query before deleting the
+ entire directory. New optional argument FORCE can overrule the
+ security query.
+ (org-attach-delete-one): New command.
+
+ * org-attach.el (org-attach-file-list): Fix bug with directory.
+
+ * org.el (org-apps-regexp-alist): New function.
+ (org-file-apps): Add auto-mode to the default value.
+ (org-open-file): Use the new structure of org-file-apps.
+
+ * org-attach.el (org-attach): Support the new keys.
+ (org-attach-method): New option.
+
+ * org-bbdb.el (org-bbdb-anniversaries): Fix but with 29 Feb/1
+ March.
+
+ * org.el (org-remove-uniherited-tags): Fix reverse interpretation
+ of the list value o `org-use-tag-inheritance'.
+
+ * org-attach.el (org-attach-auto-tag): New option.
+ (org-attach-tag, org-attach-untag): New functions.
+ (org-attach-attach, org-attach-new, org-attach-sync): Call
+ `org-attach-tag'.
+ (org-attach-delete): Call `org-attach-untag'.
+
+ * org-attach.el: New file.
+
+ * org-table.el (orgtbl-self-insert-command): Make this work for
+ the keypad as well.
+
+ * org.el (org-add-log-setup): Limit searc for drawers to entry
+ text, not to subtree.
+
+ * org-clock.el (org-clock-heading-for-remember): New variable.
+ (org-clock-in): Set `org-clock-heading-for-remember'.
+
+2008-10-12 James TD Smith <ahktenzero@mohorovi.cc>
+
+ * org-remember.el (org-remember-apply-template): Add new
+ expansions: %k, %K for currently clocked task and a link to the
+ currently clocked task, and %< to file notes in the currently
+ clocked task.
+
+2008-10-12 Carsten Dominik <dominik@science.uva.nl>
+
+ * org-export-latex.el (org-export-latex-make-header): Also insert
+ the content of the property :latex-header-extra.
+
+ * org-exp.el (org-infile-export-plist): Put the content of
+ #+LATEX_HEADER: into the property :latex-header-extra.
+
+ * org-colview.el (org-columns-get-format-and-top-level): Remove
+ resetting the marker.
+
+ * org-colview-xemacs.el (org-columns-get-format-and-top-level):
+ Remove resetting the marker.
+
+ * org.el (org-entry-property-inherited-from): Improve docstring.
+ (org-entry-get-with-inheritance): Reset marker before starting the
+ search.
+
+ * org-exp.el (org-infile-export-plist): Allow multiple STYLE lines.
+
+ * org.el (org-entry-get-multivalued-property)
+ (org-entry-protect-space, org-entry-restore-space): New
+ functions.
+ (org-file-apps-defaults-macosx): Let postscript files be opened by
+ preview.
+ (org-time-stamp-inactive): Call `org-time-stamp'.
+ (org-time-stamp): New argument `inactive'. Also edit inacive
+ stamps. Convert time stamp type.
+ (org-open-file): Interpret the `default' value for the `command'
+ in `org-file-apps'.
+
+ * org-id.el (org-id-int-to-b36-one-digit)
+ (org-id-b36-to-int-one-digit, org-id-int-to-b36)
+ (org-id-b36-to-int, org-id-time-to-b36): Modified from b62 to
+ b36.
+
+ * org-id.el (org-id-reverse-string): New function.
+ (org-id-new): Use `org-id-reverse-string' to make sure the
+ beginning chars of the ID are mutating fast. This allows to use a
+ directory structure to spread things better.
+ (org-id-prefix): Changed default to nil.
+
+ * org-list.el (org-move-item-down, org-move-item-up): Remember and
+ restore the column of the cursor position.
+
+ * org-remember.el (org-remember-apply-template): Remove properties
+ from `initial'.
+
+ * org-wl.el (org-wl-open): Remove useless call to
+ `wl-thread-open-all'.
+
+ * org-remember.el (org-remember-handler): Fix bug with `bottom'
+ location.
+
+ * org-bbdb.el (org-bbdb-anniversaries): Require bbdb in
+ `org-bbdb-anniversaries'.
+
+ * org.el (org-get-next-sibling, org-forward-same-level): New
+ functions, similar to the outline versions, but invisible headings
+ are OK.
+
+2008-10-12 Bastien Guerry <bzg@altern.org>
+
+ * org.el (org-auto-repeat-maybe): Insert a space between
+ the timestamp's type and the timestamp itself.
+
+2008-10-12 Carsten Dominik <dominik@science.uva.nl>
+
+ * org-table.el (org-table-sum): Do not format the result with %g,
+ it does rounding when there are too many digits.
+
+ * org.el (org-map-entries): Protect the keyword-selecting variables.
+
+2008-10-12 Bastien Guerry <bzg@altern.org>
+
+ * org-agenda.el (org-agenda-to-appt): Make sure the function check
+ against all agenda files.
+
+2008-10-12 Carsten Dominik <dominik@science.uva.nl>
+
+ * org-list.el: New file, aggregating list functions from org.el
+ and org-export-latex.el.
+
+ * org.el (org-edit-src-region-extra): New option.
+
+ * org-agenda.el (org-agenda-to-appt): Fix bug with appointment
+ time before 1am.
+
+2008-10-12 Bastien Guerry <bzg@altern.org>
+
+ * org-export-latex.el (org-export-latex-keywords-maybe): Bug fix.
+
+2008-10-12 James TA Smith <ahktenzero@mohorovi.cc>
+
+ * org-plot.el (org-plot/gnuplot): Make tables starting with a
+ hline work correctly.
+ (org-plot/gnuplot-script): Put commas at the end of each script
+ line.
+
+ * org.el (org-get-refile-targets): Replace links with their
+ descriptions
+ (org-imenu-get-tree): Replace links with their descriptions.
+
+ * org-remember.el (org-remember-apply-template): Add a new
+ expansion for adding properties to remember items.
+
+ * org.el (org-add-log-setup): Skip over drawers (properties,
+ clocks etc) when adding notes.
+
+ * org-agenda.el (org-agenda-get-closed): show durations of clocked
+ items as well as the start and end times.
+
+ * org-compat.el (org-get-x-clipboard-compat): Add a compat
+ function for fetching the X clipboard on XEmacs and GNU Emacs 21.
+
+ * org-remember.el (org-get-x-clipboard): Use the compat
+ function to get clipboard values when x-selection-value is
+ unavailable. Use substring-no-properties instead of
+ set-text-properties to remove text properties from the clipboard
+ value.
+
+ * lisp/org-clock.el (org-update-mode-line): Support limiting the
+ modeline clock string, and display the full todo value in the
+ tooltip. Set a local keymap so mouse-3 on the clock string goes to
+ the currently clocked task.
+ (org-clock-string-limit): Add a custom value for the maximum
+ length of the clock string in the modeline.
+ (org-clock-mode-map): Add a keymap for the modeline string
+
+2008-10-12 Carsten Dominik <dominik@science.uva.nl>
+
+ * org-compat.el (org-propertize): New function.
+
+2008-10-12 Bastien Guerry <bzg@altern.org>
+
+ * org-export-latex.el (org-export-latex-tables): protect exported
+ tables from further special chars conversion.
+ (org-export-latex-preprocess): Preserve LaTeX environments.
+ (org-list-parse-list): Parse descriptive lists.
+ (org-list-to-generic, org-list-to-latex, org-list-to-html)
+ (org-list-to-texinfo): Export descriptive lists.
+ (org-quote-chars): Remove.
+ (org-export-latex-keywords-maybe): Use `replace-regexp-in-string'.
+ (org-export-latex-list-beginning-re): Rename to
+ `org-list-beginning-re'
+ (org-list-item-begin): Rename to `org-list-item-beginning'
+
+2008-10-12 Carsten Dominik <dominik@science.uva.nl>
+
+ * org.el (org-refile): Allow refiling to the last entry in the
+ buffer.
+ (org-get-tags-at): Fix bug when inheritance is turned off.
+
+ * org.el (org-indent-line-function): No longer check for src
+ regions, this is too much overhead.
+
+ * org-agenda.el (org-agenda-highlight-todo): Fix bugs with keyword
+ matching.
+
+ * org.el (org-scan-tags): Make sure that tags matching is not case
+ sensitive. TODO keyword matching is case sensitive, however, to
+ avoid confusion with similar words that are not meant to be
+ keywords.
+
+ * org.el (org-get-local-tags-at): New function.
+ (org-get-local-tags): New function.
+
+ * org-exp.el (org-export-get-categories): New function.
+
+ * org-agenda.el (org-sorting-choice)
+ (org-agenda-sorting-strategy, org-agenda-get-todos)
+ (org-agenda-get-timestamps, org-agenda-get-deadlines)
+ (org-agenda-get-scheduled, org-agenda-get-blocks)
+ (org-entries-lessp): Implement sorting by TODO state.
+ (org-cmp-todo-state): New defsubst.
+
+ * org-colview.el (org-colview-construct-allowed-dates): New
+ function.
+ (org-columns-next-allowed-value): Use
+ `org-colview-construct-allowed-dates'.
+
+ * org-colview-xemacs.el (org-colview-construct-allowed-dates): New
+ function.
+ (org-columns-next-allowed-value): Use
+ `org-colview-construct-allowed-dates'.
+
+ * org.el (org-protect-slash): New function.
+ (org-get-refile-targets): Use `org-protect-slash'.
+
+ * org-agenda.el (org-global-tags-completion-table): New variable.
+
+ * org-exp.el (org-export-handle-export-tags): New function.
+ (org-export-preprocess-string): Call
+ `org-export-handle-export-tags'.
+
+ * org-plot.el: New file.
+
+ * org-publish.el (org-publish-expand-components): Function removed.
+ (org-publish-expand-projects): Allow components to have components.
+
+ * org.el (org-indent-line-function): Do not indent in regions that
+ are external source code.
+ (org-yank-and-fold-if-subtree): New function.
+
+ * org-agenda.el (org-agenda-todayp): New function.
+ (org-agenda-get-deadlines, org-agenda-get-scheduled): Use
+ `org-agenda-todayp'.
+
+ * org.el (org-insert-heading-respect-content)
+ (org-insert-todo-heading-respect-content): New commands.
+ (org-insert-heading-respect-content): New option.
+ (org-insert-heading): Respect `org-insert-heading-respect-content'.
+
+ * org-clock.el (org-clock-find-position): Make sure the note after
+ the clock line gets moved into the new clock drawer.
+
+ * org-id.el (org-id-new): New option.
+
+ * org-table.el (org-table-copy-down): Avoid overflow during
+ increment. Use prefix argument 0 to temporarily disable the
+ increment.
+
+ * org-exp.el (org-export-as-html): Do not turn on the major mode
+ if the buffer will be killed anyway.
+ (org-get-current-options): Exclude the #+TEXT field.
+ (org-export-as-html): Make sure text before the first headline is
+ a paragraph.
+
+ * org-publish.el (org-publish-org-to): Tell the exporter that this
+ buffer will be killed, so it is not necessary to do major mode
+ initialization.
+
+ * org-archive.el (org-archive-to-archive-sibling): Show empty
+ lines after folding the archive sibling.
+
+ * org.el (org-log-note-extra): New variable.
+
+2008-10-12 Bastien Guerry <bzg@altern.org>
+
+ * org.el (org-additional-option-like-keywords): Added keywords for
+ the _QUOTE, _VERSE and _SRC environments.
+
+ * org-export-latex.el (org-export-latex-preprocess): Fix bug when
+ exporting _QUOTE and _VERSE environments.
+
+2008-10-12 Carsten Dominik <dominik@science.uva.nl>
+
+ * org-agenda.el (org-agenda-filter-by-tag): New command.
+
+ * org-exp.el (org-get-current-options): Remove angular brackets
+ from the date entry.
+
+ * org.el (org-edit-fixed-width-region): New function.
+ (org-edit-fixed-width-region): Also try
+ `org-edit-fixed-width-region'.
+ (org-edit-fixed-width-region-mode): New option.
+ (org-activate-code): Only interprete lines starting with colon
+ plus a space as example lines.
+
+ * org-remember.el (org-remember-templates): Add nil instead of
+ empty strings to fix the length of remember templates.
+
+ * org-table.el (org-calc-default-modes): Fix the time format for
+ calc, from 12 hour to 24 hour clock.
+
+ * org-agenda.el (org-agenda-get-deadlines)
+ (org-agenda-get-scheduled): Avoid `time-of-day' extraction for
+ entries that are pre-warnings of deadlines or reminders.
+
+ * org.el (org-sort-entries-or-items): Make numeric and alpha
+ comparisons ignore any TODO keyword and priority cookie.
+
+ * org-remember.el (org-remember-handler): Reinterpretation of the
+ prefix argument.
+
+ * org-agenda.el (org-agenda-get-scheduled): Use new
+ `org-scheduled' face.
+
+ * org-faces.el (org-scheduled): New face.
+
+ * org-wl.el (org-wl-open): Remove incorrect declaration.
+
+ * org-gnus.el (org-gnus-store-link): Support for :to information
+ in gnus links.
+
+ * org-exp.el (org-export-as-html): Fixed typo in creator
+ information.
+ (org-export-protect-examples): New parameter indent. Insert extra
+ spaces only when this parameter is specified.
+ (org-export-preprocess-string): Call `org-export-protect-examples'
+ with an indentation parameter when exporting to ASCII.
+
+ * org-remember.el (org-remember-templates)
+ (org-remember-apply-template): Allow the file component to be a
+ function.
+
+ * org.el (org-goto-local-search-headings): Renamed from
+ `org-goto-local-search-forward-headings'. Added the possibility
+ to search backwards.
+
+ * org-export-latex.el (org-export-latex): New customization
+ group.
+
+ * org-agenda.el (org-write-agenda): Erase buffer for txt export.
+
+ * org-exp.el (org-html-do-expand): Allow {} to terminate
+ tex macro
+
+ * org.el (org-buffer-list): Select buffers based on major mode,
+ not on file name.
+
+ * org-agenda.el (org-agenda-align-tags): Fix bug with malformed
+ face property.
+
+ * org-colview.el (org-columns-display-here): Use
+ `org-columns-modify-value-for-display-function'.
+
+ * org-colview-xemacs.el (org-columns-display-here): Use
+ `org-columns-modify-value-for-display-function'.
+
+ * org.el (org-columns-modify-value-for-display-function): New option.
+
+
+ * org-publish.el (org-publish-file): Make sure the directory match
+ for the publishing directory works correctly.
+
+ * org-agenda.el (org-agenda-execute-calendar-command)
+ (org-agenda-diary-entry): Additional optional argument.
+
+2008-07-24 Carsten Dominik <dominik@science.uva.nl>
+
+ * org-exp.el (org-export-as-html): Add attributes also in mailto
+ and ftp links.
+
+ * org.el (org-autoload): Add `org-dblock-write:columnview'.
+
+
2008-08-11 Glenn Morris <rgm@gnu.org>
* org-mac-message.el (do-applescript): Fix declaration.
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
-;; Version: 6.06b
+;; Version: 6.09a
;;
;; This file is part of GNU Emacs.
;;
(const category-keep) (const category-up) (const category-down)
(const tag-down) (const tag-up)
(const priority-up) (const priority-down)
+ (const todo-state-up) (const todo-state-down)
(const effort-up) (const effort-down))
"Sorting choices.")
tag-down Sort alphabetically by last tag, Z-A.
priority-up Sort numerically by priority, high priority last.
priority-down Sort numerically by priority, high priority first.
+todo-state-up Sort by todo state, tasks that are done last.
+todo-state-down Sort by todo state, tasks that are done first.
effort-up Sort numerically by estimated effort, high effort last.
effort-down Sort numerically by estimated effort, high effort first.
(defcustom org-agenda-fontify-priorities t
"Non-nil means, highlight low and high priorities in agenda.
When t, the highest priority entries are bold, lowest priority italic.
-This may also be an association list of priority faces. The face may be
-a names face, or a list like `(:background \"Red\")'."
+This may also be an association list of priority faces, whose
+keys are the character values of `org-highest-priority',
+`org-default-priority', and `org-lowest-priority' (the default values
+are ?A, ?B, and ?C, respectively). The face may be a names face,
+or a list like `(:background \"Red\")'."
:group 'org-agenda-line-format
:type '(choice
(const :tag "Never" nil)
(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 "\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)
(org-defkey org-agenda-mode-map "," 'org-agenda-priority)
(org-defkey org-agenda-mode-map "]" 'org-agenda-manipulate-query-subtract)
(org-defkey org-agenda-mode-map "{" 'org-agenda-manipulate-query-add-re)
(org-defkey org-agenda-mode-map "}" 'org-agenda-manipulate-query-subtract-re)
+(org-defkey org-agenda-mode-map "/" 'org-agenda-filter-by-tag)
(defvar org-agenda-keymap (copy-keymap org-agenda-mode-map)
"Local keymap for agenda entries from Org-mode.")
-------------------------------- > Remove restriction
a Agenda for current week or day e Export agenda views
t List of all TODO entries T Entries with special TODO kwd
-m Match a TAGS query M Like m, but only TODO entries
+m Match a TAGS/PROP/TODO query M Like m, but only TODO entries
L Timeline for current buffer # List stuck projects (!=configure)
s Search for keywords C Configure custom agenda commands
/ Multi-occur
(t
(let ((bs (buffer-string)))
(find-file file)
+ (erase-buffer)
(insert bs)
(save-buffer 0)
(kill-buffer (current-buffer))
"\\)\\>"))
org-not-done-regexp)
"[^\n\r]*\\)"))
- marker priority category tags
+ marker priority category tags todo-state
ee txt beg end)
(goto-char (point-min))
(while (re-search-forward regexp nil t)
category (org-get-category)
tags (org-get-tags-at (point))
txt (org-format-agenda-item "" (match-string 1) category tags)
- priority (1+ (org-get-priority txt)))
+ priority (1+ (org-get-priority txt))
+ todo-state (org-get-todo-state))
(org-add-props txt props
'org-marker marker 'org-hd-marker marker
'priority priority 'org-category category
- 'type "todo")
+ 'type "todo" 'todo-state todo-state)
(push txt ee)
(if org-agenda-todo-list-sublevels
(goto-char (match-end 1))
"\\|\\(<[0-9]+-[0-9]+-[0-9]+[^>\n]+?\\+[0-9]+[dwmy]>\\)"
"\\|\\(<%%\\(([^>\n]+)\\)>\\)"))
marker hdmarker deadlinep scheduledp clockp closedp inactivep
- donep tmp priority category ee txt timestr tags b0 b3 e3 head)
+ donep tmp priority category ee txt timestr tags b0 b3 e3 head
+ todo-state)
(goto-char (point-min))
(while (re-search-forward regexp nil t)
(setq b0 (match-beginning 0)
clockp (and org-agenda-include-inactive-timestamps
(or (string-match org-clock-string tmp)
(string-match "]-+\\'" tmp)))
- donep (org-entry-is-done-p))
+ todo-state (org-get-todo-state)
+ donep (member todo-state org-done-keywords))
(if (or scheduledp deadlinep closedp clockp)
(throw :skip t))
(if (string-match ">" timestr)
'org-marker marker 'org-hd-marker hdmarker)
(org-add-props txt nil 'priority priority
'org-category category 'date date
+ 'todo-state todo-state
'type "timestamp")
(push txt ee))
(outline-next-heading)))
(list 0 0 0 (nth 1 date) (car date) (nth 2 date))))
1 11))))
marker hdmarker priority category tags closedp
- ee txt timestr rest)
+ ee txt timestr rest clocked)
(goto-char (point-min))
(while (re-search-forward regexp nil t)
(catch :skip
(setq rest (substring timestr (match-end 0))
timestr (substring timestr 0 (match-end 0)))
(if (and (not closedp)
- (string-match "\\([0-9]\\{1,2\\}:[0-9]\\{2\\}\\)\\]" rest))
- (setq timestr (concat (substring timestr 0 -1)
- "-" (match-string 1 rest) "]"))))
-
+ (string-match "\\([0-9]\\{1,2\\}:[0-9]\\{2\\}\\)\\].*\\([0-9]\\{1,2\\}:[0-9]\\{2\\}\\)" rest))
+ (progn (setq timestr (concat (substring timestr 0 -1)
+ "-" (match-string 1 rest) "]"))
+ (setq clocked (match-string 2 rest)))
+ (setq clocked "-")))
(save-excursion
(if (re-search-backward "^\\*+ " nil t)
(progn
tags (org-get-tags-at))
(looking-at "\\*+[ \t]+\\([^\r\n]+\\)")
(setq txt (org-format-agenda-item
- (if closedp "Closed: " "Clocked: ")
+ (if closedp "Closed: "
+ (concat "Clocked: (" clocked ")"))
(match-string 1) category tags timestr)))
(setq txt org-agenda-no-heading-message))
(setq priority 100000)
(format "mouse-2 or RET jump to org file %s"
(abbreviate-file-name buffer-file-name))))
(regexp org-deadline-time-regexp)
- (todayp (equal date (calendar-current-date))) ; DATE bound by calendar
+ (todayp (org-agenda-todayp date)) ; DATE bound by calendar
(d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar
d2 diff dfrac wdays pos pos1 category tags
- ee txt head face s upcomingp donep timestr)
+ ee txt head face s todo-state upcomingp donep timestr)
(goto-char (point-min))
(while (re-search-forward regexp nil t)
(catch :skip
(= diff 0))
(save-excursion
(setq category (org-get-category))
+ (setq todo-state (org-get-todo-state))
(if (re-search-backward "^\\*+[ \t]+" nil t)
(progn
(goto-char (match-end 0))
(point)
(progn (skip-chars-forward "^\r\n")
(point))))
- (setq donep (string-match org-looking-at-done-regexp head))
+ (setq donep (member todo-state org-done-keywords))
(if (string-match " \\([012]?[0-9]:[0-9][0-9]\\)" s)
(setq timestr
(concat (substring s (match-beginning 1)) " "))
(funcall (nth 1 org-agenda-deadline-leaders) diff date)
(format (nth 1 org-agenda-deadline-leaders)
diff)))
- head category tags timestr))))
+ head category tags
+ (if (not (= diff 0)) nil timestr)))))
(setq txt org-agenda-no-heading-message))
(when txt
(setq face (org-agenda-deadline-face dfrac wdays))
'priority (+ (- diff)
(org-get-priority txt))
'org-category category
+ 'todo-state todo-state
'type (if upcomingp "upcoming-deadline" "deadline")
'date (if upcomingp date d2)
'face (if donep 'org-done face)
(format "mouse-2 or RET jump to org file %s"
(abbreviate-file-name buffer-file-name))))
(regexp org-scheduled-time-regexp)
- (todayp (equal date (calendar-current-date))) ; DATE bound by calendar
+ (todayp (org-agenda-todayp date)) ; DATE bound by calendar
(d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar
- d2 diff pos pos1 category tags
- ee txt head pastschedp donep face timestr s)
+ d2 diff pos pos1 category tags donep
+ ee txt head pastschedp todo-state face timestr s)
(goto-char (point-min))
(while (re-search-forward regexp nil t)
(catch :skip
(= diff 0))
(save-excursion
(setq category (org-get-category))
+ (setq todo-state (org-get-todo-state))
(if (re-search-backward "^\\*+[ \t]+" nil t)
(progn
(goto-char (match-end 0))
(setq head (buffer-substring-no-properties
(point)
(progn (skip-chars-forward "^\r\n") (point))))
- (setq donep (string-match org-looking-at-done-regexp head))
+ (setq donep (member todo-state org-done-keywords))
(if (string-match " \\([012]?[0-9]:[0-9][0-9]\\)" s)
(setq timestr
(concat (substring s (match-beginning 1)) " "))
(car org-agenda-scheduled-leaders)
(format (nth 1 org-agenda-scheduled-leaders)
(- 1 diff)))
- head category tags timestr))))
+ head category tags
+ (if (not (= diff 0)) nil timestr)))))
(setq txt org-agenda-no-heading-message))
(when txt
- (setq face (if pastschedp
- 'org-scheduled-previously
- 'org-scheduled-today))
+ (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-done face)
'type (if pastschedp "past-scheduled" "scheduled")
'date (if pastschedp d2 date)
'priority (+ 94 (- 5 diff) (org-get-priority txt))
- 'org-category category)
+ 'org-category category
+ 'todo-state todo-state)
(push txt ee))))))
(nreverse ee)))
(abbreviate-file-name buffer-file-name))))
(regexp org-tr-regexp)
(d0 (calendar-absolute-from-gregorian date))
- marker hdmarker ee txt d1 d2 s1 s2 timestr category tags pos
+ marker hdmarker ee txt d1 d2 s1 s2 timestr category todo-state tags pos
donep head)
(goto-char (point-min))
(while (re-search-forward regexp nil t)
(save-excursion
(setq marker (org-agenda-new-marker (point)))
(setq category (org-get-category))
+ (setq todo-state (org-get-todo-state))
(if (re-search-backward "^\\*+ " nil t)
(progn
(goto-char (match-beginning 0))
(org-add-props txt props
'org-marker marker 'org-hd-marker hdmarker
'type "block" 'date date
+ 'todo-state todo-state
'priority (org-get-priority txt) 'org-category category)
(push txt ee)))
(goto-char pos)))
(mapconcat 'identity (sort list 'org-entries-lessp) "\n")))
(defun org-agenda-highlight-todo (x)
- (let (re pl)
+ (let ((org-done-keywords org-done-keywords-for-agenda)
+ re pl)
(if (eq x 'line)
(save-excursion
(beginning-of-line 1)
(setq re (get-text-property (point) 'org-todo-regexp))
(goto-char (+ (point) (or (get-text-property (point) 'prefix-length) 0)))
- (when (looking-at (concat "[ \t]*\\.*" re " +"))
+ (when (looking-at (concat "[ \t]*\\.*\\(" re "\\) +"))
(add-text-properties (match-beginning 0) (match-end 0)
- (list 'face (org-get-todo-face 0)))
+ (list 'face (org-get-todo-face 1)))
(let ((s (buffer-substring (match-beginning 1) (match-end 1))))
(delete-region (match-beginning 1) (1- (match-end 0)))
(goto-char (match-beginning 1))
((string-lessp cb ca) +1)
(t nil))))
+(defsubst org-cmp-todo-state (a b)
+ "Compare the todo states of strings A and B."
+ (let* ((ta (or (get-text-property 1 'todo-state a) ""))
+ (tb (or (get-text-property 1 'todo-state b) ""))
+ (la (- (length (member ta org-todo-keywords-for-agenda))))
+ (lb (- (length (member tb org-todo-keywords-for-agenda))))
+ (donepa (member ta org-done-keywords-for-agenda))
+ (donepb (member tb org-done-keywords-for-agenda)))
+ (cond ((and donepa (not donepb)) -1)
+ ((and (not donepa) donepb) +1)
+ ((< la lb) -1)
+ ((< lb la) +1)
+ (t nil))))
+
(defsubst org-cmp-tag (a b)
"Compare the string values of categories of strings A and B."
(let ((ta (car (last (get-text-property 1 'tags a))))
(category-down (if category-up (- category-up) nil))
(category-keep (if category-up +1 nil))
(tag-up (org-cmp-tag a b))
- (tag-down (if tag-up (- tag-up) nil)))
+ (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)))
(cdr (assoc
(eval (cons 'or org-agenda-sorting-strategy-selected))
'((-1 . t) (1 . nil) (nil . nil))))))
(goto-line line)
(recenter window-line)))
+(defvar org-global-tags-completion-table nil)
+(defun org-agenda-filter-by-tag (strip &optional char)
+ "Keep only those lines in the agenda buffer that have a specific tag.
+The tag is selected with its fast selection letter, as configured.
+With prefix argument STRIP, remove all lines that do have the tag."
+ (interactive "P")
+ (let (char a tag tags (inhibit-read-only t))
+ (message "Select tag [%s] or no tag [ ], [TAB] to complete, [/] to restore: "
+ (mapconcat
+ (lambda (x) (if (cdr x) (char-to-string (cdr x)) ""))
+ org-tag-alist-for-agenda ""))
+ (setq char (read-char))
+ (when (equal char ?\t)
+ (unless (local-variable-p 'org-global-tags-completion-table)
+ (org-set-local 'org-global-tags-completion-table
+ (org-global-tags-completion-table)))
+ (let ((completion-ignore-case t))
+ (setq tag (completing-read
+ "Tag: " org-global-tags-completion-table))))
+ (cond
+ ((equal char ?/) (org-agenda-filter-by-tag-show-all))
+ ((or (equal char ?\ )
+ (setq a (rassoc char org-tag-alist-for-agenda))
+ (and tag (setq a (cons tag nil))))
+ (org-agenda-filter-by-tag-show-all)
+ (setq tag (car a))
+ (save-excursion
+ (goto-char (point-min))
+ (while (not (eobp))
+ (if (get-text-property (point) 'org-marker)
+ (progn
+ (setq tags (get-text-property (point) 'tags))
+ (if (not tag)
+ (if (or (and strip (not tags))
+ (and (not strip) tags))
+ (org-agenda-filter-by-tag-hide-line))
+ (if (or (and (member tag tags) strip)
+ (and (not (member tag tags)) (not strip)))
+ (org-agenda-filter-by-tag-hide-line)))
+ (beginning-of-line 2))
+ (beginning-of-line 2)))))
+ (t (error "Invalid tag selection character %c" char)))))
+
+(defvar org-agenda-filter-overlays nil)
+
+(defun org-agenda-filter-by-tag-hide-line ()
+ (let (ov)
+ (setq ov (org-make-overlay (max (point-min) (1- (point-at-bol)))
+ (point-at-eol)))
+ (org-overlay-put ov 'invisible t)
+ (org-overlay-put ov 'type 'tags-filter)
+ (push ov org-agenda-filter-overlays)))
+
+(defun org-agenda-filter-by-tag-show-all ()
+ (mapc 'org-delete-overlay org-agenda-filter-overlays)
+ (setq org-agenda-filter-overlays nil))
+
(defun org-agenda-manipulate-query-add ()
"Manipulate the query by adding a search term with positive selection.
Positive selection means, the term must be matched for selection of an entry."
(if line (point-at-eol) nil) t)
(add-text-properties
(match-beginning 2) (match-end 2)
- (list 'face (delq nil (list 'org-tag (get-text-property
- (match-beginning 2) 'face)))))
+ (list 'face (delq nil (adjoin 'org-tag
+ (let ((prop (get-text-property
+ (match-beginning 2) 'face)))
+ (if (listp prop)
+ prop
+ (list prop)))))))
(setq l (- (match-end 2) (match-beginning 2))
c (if (< org-agenda-tags-column 0)
(- (abs org-agenda-tags-column) l)
(org-deadline-warning-days 0)
(today (org-date-to-gregorian
(time-to-days (current-time))))
- (files (org-agenda-files)) entries file)
+ (files (org-agenda-files 'unrestricted)) entries file)
;; Get all entries which may contain an appt
(while (setq file (pop files))
(setq entries
;; Map thru entries and find if we should filter them out
(mapc
(lambda(x)
- (let* ((evt (org-trim (get-text-property 1 'txt x)))
+ (let* ((evt (org-trim (or (get-text-property 1 'txt x) "")))
(cat (get-text-property 1 'org-category x))
(tod (get-text-property 1 'time-of-day x))
(ok (or (null filter)
;; FIXME: Shall we remove text-properties for the appt text?
;; (setq evt (set-text-properties 0 (length evt) nil evt))
(when (and ok tod)
- (setq tod (number-to-string tod)
+ (setq tod (concat "00" (number-to-string tod))
tod (when (string-match
- "\\([0-9]\\{1,2\\}\\)\\([0-9]\\{2\\}\\)" tod)
+ "\\([0-9]\\{1,2\\}\\)\\([0-9]\\{2\\}\\)\\'" tod)
(concat (match-string 1 tod) ":"
(match-string 2 tod))))
(appt-add tod evt)
(message "No event to add")
(message "Added %d event%s for today" cnt (if (> cnt 1) "s" "")))))
+(defun org-agenda-todayp (date)
+ "Does DATE mean today, when considering `org-extend-today-until'?"
+ (let (today h)
+ (if (listp date) (setq date (calendar-absolute-from-gregorian date)))
+ (setq today (calendar-absolute-from-gregorian (calendar-current-date)))
+ (setq h (nth 2 (decode-time (current-time))))
+ (or (and (>= h org-extend-today-until)
+ (= date today))
+ (and (< h org-extend-today-until)
+ (= date (1- today))))))
+
(provide 'org-agenda)
;; arch-tag: 77f7565d-7c4b-44af-a2df-9f6f7070cff1
;;; org-agenda.el ends here
-
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
-;; Version: 6.06b
+;; Version: 6.09a
;;
;; This file is part of GNU Emacs.
;;
(current-time)))
(outline-up-heading 1 t)
(hide-subtree)
+ (org-cycle-show-empty-lines 'folded)
(goto-char pos))))
(defun org-archive-all-done (&optional tag)
;; Thomas Baumann <thomas dot baumann at ch dot tum dot de>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
-;; Version: 6.06b
+;; Version: 6.09a
;;
;; This file is part of GNU Emacs.
;;
;;;###autoload
(defun org-bbdb-anniversaries()
"Extract anniversaries from BBDB for display in the agenda."
+ (require 'bbdb)
(require 'diary-lib)
(unless (hash-table-p org-bbdb-anniv-hash)
(setq org-bbdb-anniv-hash
(y (nth 2 date)) ; year
(annivs (gethash (list m d) org-bbdb-anniv-hash))
(text ())
- split class form rec)
+ split class form rec recs)
;; we don't want to miss people born on Feb. 29th
- (when (and (= m 3) (= d 1) (not (calendar-leap-year-p y)))
- (setq annivs (cons annivs (gethash (list 2 29) org-bbdb-anniv-hash))))
+ (when (and (= m 3) (= d 1)
+ (not (null (gethash (list 2 29) org-bbdb-anniv-hash)))
+ (not (calendar-leap-year-p y)))
+ (setq recs (gethash (list 2 29) org-bbdb-anniv-hash))
+ (while (setq rec (pop recs))
+ (push rec annivs)))
(when annivs
(while (setq rec (pop annivs))
;; Author: Bastien Guerry <bzg at altern dot org>
;; Carsten Dominik <carsten dot dominik at gmail dot com>
;; Keywords: org, wp, remember
-;; Version: 6.06b
+;; Version: 6.09a
;;
;; This file is part of GNU Emacs.
;;
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
-;; Version: 6.06b
+;; Version: 6.09a
;;
;; This file is part of GNU Emacs.
;;
:group 'org-clock
:type 'function)
+(defcustom org-clock-string-limit 0
+ "Maximum length of clock strings in the modeline. 0 means no limit"
+ :group 'org-clock
+ :type 'integer)
;;; The clock for measuring work time.
(defvar org-mode-line-timer nil)
(defvar org-clock-heading "")
+(defvar org-clock-heading-for-remember "")
(defvar org-clock-start-time "")
(defvar org-clock-history nil
(defvar org-clock-interrupted-task (make-marker)
"Marker pointing to the task that has been interrupted by the current clock.")
+(defvar org-clock-mode-map (make-sparse-keymap))
+(define-key org-clock-mode-map [mode-line mouse-2] 'org-clock-goto)
+
(defun org-clock-history-push (&optional pos buffer)
"Push a marker to the clock history."
(setq org-clock-history-length (max 1 (min 35 org-clock-history-length)))
(when (and cat task)
(insert (format "[%c] %-15s %s\n" i cat task))
(cons i marker)))))
-
+
(defun org-update-mode-line ()
(let* ((delta (- (time-to-seconds (current-time))
- (time-to-seconds org-clock-start-time)))
+ (time-to-seconds org-clock-start-time)))
(h (floor delta 3600))
(m (floor (- delta (* 3600 h)) 60)))
(setq org-mode-line-string
- (propertize (format (concat "-[" org-time-clocksum-format " (%s)]") h m org-clock-heading)
- 'help-echo "Org-mode clock is running"))
+ (org-propertize
+ (let ((clock-string (format (concat "-[" org-time-clocksum-format " (%s)]")
+ h m org-clock-heading))
+ (help-text "Org-mode clock is running. Mouse-2 to go there."))
+ (if (and (> org-clock-string-limit 0)
+ (> (length clock-string) org-clock-string-limit))
+ (org-propertize (substring clock-string 0 org-clock-string-limit)
+ 'help-echo (concat help-text ": " org-clock-heading))
+ (org-propertize clock-string 'help-echo help-text)))
+ 'local-map org-clock-mode-map
+ 'mouse-face '(face mode-line-highlight)))
(force-mode-line-update)))
(defvar org-clock-mode-line-entry nil
org-clock-in-switch-to-state
"\\>"))))
(org-todo org-clock-in-switch-to-state))
- (if (and org-clock-heading-function
- (functionp org-clock-heading-function))
- (setq org-clock-heading (funcall org-clock-heading-function))
- (if (looking-at org-complex-heading-regexp)
- (setq org-clock-heading (match-string 4))
- (setq org-clock-heading "???")))
- (setq org-clock-heading (propertize org-clock-heading 'face nil))
+ (setq org-clock-heading-for-remember
+ (and (looking-at org-complex-heading-regexp)
+ (match-end 4)
+ (org-trim (buffer-substring (match-end 1) (match-end 4)))))
+ (setq org-clock-heading
+ (cond ((and org-clock-heading-function
+ (functionp org-clock-heading-function))
+ (funcall org-clock-heading-function))
+ ((looking-at org-complex-heading-regexp)
+ (match-string 4))
+ (t "???")))
+ (setq org-clock-heading (org-propertize org-clock-heading 'face nil))
(org-clock-find-position)
(insert "\n") (backward-char 1)
;; Wrap current entries into a new drawer
(goto-char last)
(beginning-of-line 2)
+ (if (org-at-item-p) (org-end-of-item))
(insert ":END:\n")
(beginning-of-line 0)
(org-indent-line-function)
(delete-char 1)))
(move-marker org-clock-marker nil)
(when org-log-note-clock-out
- (org-add-log-setup 'clock-out))
+ (org-add-log-setup 'clock-out nil nil nil
+ (concat "# Task: " (org-get-heading t) "\n\n")))
(when org-mode-line-timer
(cancel-timer org-mode-line-timer)
(setq org-mode-line-timer nil))
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
-;; Version: 6.06b
+;; Version: 6.09a
;;
;; This file is part of GNU Emacs.
;;
(face (list color 'org-column 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 s1 s2)
+ pom property ass width f string ov column val modval s1 s2 title)
;; Check if the entry is in another buffer.
(unless props
(if (eq major-mode 'org-agenda-mode)
;; Walk the format
(while (setq column (pop fmt))
(setq property (car column)
+ title (nth 1 column)
ass (if (equal property "ITEM")
(cons "ITEM"
(save-match-data
(length property))
f (format "%%-%d.%ds | " width width)
val (or (cdr ass) "")
- modval (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 (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)))))
(setq s2 (org-columns-add-ellipses (or modval val) width))
(setq string (format f s2))
;; Create the overlay
(and (memq
(nth 4 (assoc key org-columns-current-fmt-compiled))
'(checkbox checkbox-n-of-m checkbox-percent))
- '("[ ]" "[X]"))))
+ '("[ ]" "[X]"))
+ (org-colview-construct-allowed-dates value)))
nval)
(when (integerp nth)
(setq nth (1- nth))
(and (nth 3 (assoc key org-columns-current-fmt-compiled))
(org-columns-update key))))))
+(defun org-colview-construct-allowed-dates (s)
+ "Construct a list of three dates around the date in S.
+This respects the format of the time stamp in S, active or non-active,
+and also including time or not. S must be just a time stamp, no text
+around it."
+ (when (string-match (concat "^" org-ts-regexp3 "$") s)
+ (let* ((time (org-parse-time-string s 'nodefaults))
+ (active (equal (string-to-char s) ?<))
+ (fmt (funcall (if (nth 1 time) 'cdr 'car) org-time-stamp-formats))
+ time-before time-after)
+ (unless active (setq fmt (concat "[" (substring fmt 1 -1) "]")))
+ (setf (car time) (or (car time) 0))
+ (setf (nth 1 time) (or (nth 1 time) 0))
+ (setf (nth 2 time) (or (nth 2 time) 0))
+ (setq time-before (copy-sequence time))
+ (setq time-after (copy-sequence time))
+ (setf (nth 3 time-before) (1- (nth 3 time)))
+ (setf (nth 3 time-after) (1+ (nth 3 time)))
+ (mapcar (lambda (x) (format-time-string fmt (apply 'encode-time x)))
+ (list time-before time time-after)))))
+
(defun org-verify-version (task)
(cond
((eq task 'columns)
(defun org-columns-get-format-and-top-level ()
(let (fmt)
(when (condition-case nil (org-back-to-heading) (error nil))
- (move-marker org-entry-property-inherited-from nil)
(setq fmt (org-entry-get nil "COLUMNS" t)))
(setq fmt (or fmt org-columns-default-format))
(org-set-local 'org-columns-current-fmt fmt)
(hlines (plist-get params :hlines))
(vlines (plist-get params :vlines))
(maxlevel (plist-get params :maxlevel))
+ (content-lines (org-split-string (plist-get params :content) "\n"))
(skip-empty-rows (plist-get params :skip-empty-rows))
- tbl id idpos nfields tmp)
+ tbl id idpos nfields tmp recalc line)
(save-excursion
(save-restriction
(when (setq id (plist-get params :id))
tbl))
(setq tbl (append tbl (list (cons "/" (make-list nfields "<>"))))))
(setq pos (point))
+ (when content-lines
+ (while (string-match "^#" (car content-lines))
+ (insert (pop content-lines) "\n")))
(insert (org-listtable-to-string tbl))
(when (plist-get params :width)
(insert "\n|" (mapconcat (lambda (x) (format "<%d>" (max 3 x)))
org-columns-current-widths "|")))
- (goto-char pos)
- (org-table-align))))
+ (while (setq line (pop content-lines))
+ (when (string-match "^#" line)
+ (insert "\n" line)
+ (when (string-match "^#\\+TBLFM" line)
+ (setq recalc t))))
+ (if recalc
+ (progn (goto-char pos) (org-table-recalculate 'all))
+ (goto-char pos)
+ (org-table-align)))))
(defun org-listtable-to-string (tbl)
"Convert a listtable TBL to a string that contains the Org-mode table.
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
-;; Version: 6.06b
+;; Version: 6.09a
;;
;; This file is part of GNU Emacs.
;;
;;; Code:
+(require 'org-macs)
+
(defconst org-xemacs-p (featurep 'xemacs)) ; not used by org.el itself
(defconst org-format-transports-properties-p
(let ((x "a"))
(set-extent-property (car ext-inv-spec) 'invisible
(cadr ext-inv-spec))))
(move-to-column column force)))
+
+(defun org-get-x-clipboard-compat (value)
+ "Get the clipboard value on XEmacs or Emacs 21"
+ (cond (org-xemacs-p (org-no-warnings (get-selection-no-error value)))
+ ((fboundp 'x-get-selection)
+ (condition-case nil
+ (or (x-get-selection value 'UTF8_STRING)
+ (x-get-selection value 'COMPOUND_TEXT)
+ (x-get-selection value 'STRING)
+ (x-get-selection value 'TEXT))
+ (error nil)))))
+
+(defun org-propertize (string &rest properties)
+ (if (featurep 'xemacs)
+ (add-text-properties 0 (length string) properties string)
+ (apply 'propertize string properties)))
(provide 'org-compat)
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
-;; Version: 6.06b
+;; Version: 6.09a
;;
;; This file is part of GNU Emacs.
;;
:group 'org-export-general
:type 'boolean)
+
+(defcustom org-export-select-tags '("export")
+ "Tags that select a tree for export.
+If any such tag is found in a buffer, all trees that do not carry one
+of these tags will be deleted before export.
+Inside trees that are selected like this, you can still deselect a
+subtree by tagging it with one of the `org-export-excude-tags'."
+ :group 'org-export-general
+ :type '(repeat (string :tag "Tag")))
+
+(defcustom org-export-exclude-tags '("noexport")
+ "Tags that exclude a tree from export.
+All trees carrying any of these tags will be excluded from export.
+This is without contition, so even subtrees inside that carry one of the
+`org-export-select-tags' will be removed."
+ :group 'org-export-general
+ :type '(repeat (string :tag "Tag")))
+
(defcustom org-export-with-special-strings t
"Non-nil means, interpret \"\-\", \"--\" and \"---\" for export.
When this option is turned on, these strings will be exported as:
table { border-collapse: collapse; }
td, th { vertical-align: top; }
dt { font-weight: bold; }
+
+ .org-info-js_info-navigation { border-style:none; }
+ #org-info-js_console-label { font-size:10px; font-weight:bold;
+ white-space:nowrap; }
+ .org-info-js_search-highlight {background-color:#ffff00; color:#000000;
+ font-weight:bold; }
+
</style>"
"The default style specification for exported HTML files.
Please use the variables `org-export-html-style' and
;;;###autoload
(put 'org-export-html-style-extra 'safe-local-variable 'stringp)
+
(defcustom org-export-html-title-format "<h1 class=\"title\">%s</h1>\n"
"Format for typesetting the document title in HTML export."
:group 'org-export-html
(const :tag "SCHEDULED in TODO entries become start date"
todo-start)))
+(defcustom org-icalendar-categories '(local-tags category)
+ "Items that should be entered into the categories field.
+This is a list of symbols, the following are valid:
+
+category The Org-mode category of the current file or tree
+todo-state The todo state, if any
+local-tags The tags, defined in the current line
+all-tags All tags, including inherited ones."
+ :group 'org-export-icalendar
+ :type '(repeat
+ (choice
+ (const :tag "The file or tree category" category)
+ (const :tag "The TODO state" todo-state)
+ (const :tag "Tags defined in current line" local-tags)
+ (const :tag "All tags, including inherited ones" all-tags))))
+
(defcustom org-icalendar-include-todo nil
"Non-nil means, export to iCalendar files should also cover TODO items."
:group 'org-export-icalendar
(defconst org-level-max 20)
(defvar org-export-html-preamble nil
- "Preamble, to be inserted just after <body>. Set by publishing functions.")
+ "Preamble, to be inserted just before <body>. Set by publishing functions.")
(defvar org-export-html-postamble nil
- "Preamble, to be inserted just before </body>. Set by publishing functions.")
+ "Preamble, to be inserted just after </body>. Set by publishing functions.")
(defvar org-export-html-auto-preamble t
"Should default preamble be inserted? Set by publishing functions.")
(defvar org-export-html-auto-postamble t
(:auto-preamble . org-export-html-auto-preamble)
(:auto-postamble . org-export-html-auto-postamble)
(:author . user-full-name)
- (:email . user-mail-address)))
+ (:email . user-mail-address)
+ (:select-tags . org-export-select-tags)
+ (:exclude-tags . org-export-exclude-tags)))
(defun org-default-export-plist ()
"Return the property list with default settings for the export variables."
(let ((re (org-make-options-regexp
(append
'("TITLE" "AUTHOR" "DATE" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE"
- "LINK_UP" "LINK_HOME" "SETUPFILE")
+ "LINK_UP" "LINK_HOME" "SETUPFILE" "STYLE" "LATEX_HEADER"
+ "EXPORT_SELECT_TAGS" "EXPORT_EXCLUDE_TAGS")
(mapcar 'car org-export-inbuffer-options-extra))))
- p key val text options js-up js-main js-css js-opt a pr
+ p key val text options js-up js-main js-css js-opt a pr style
+ latex-header
ext-setup-or-nil setup-contents (start 0))
(while (or (and ext-setup-or-nil
(string-match re ext-setup-or-nil start)
((string-equal key "EMAIL") (setq p (plist-put p :email val)))
((string-equal key "DATE") (setq p (plist-put p :date val)))
((string-equal key "LANGUAGE") (setq p (plist-put p :language val)))
+ ((string-equal key "STYLE")
+ (setq style (concat style "\n" val)))
+ ((string-equal key "LATEX_HEADER")
+ (setq latex-header (concat latex-header "\n" val)))
((string-equal key "TEXT")
(setq text (if text (concat text "\n" val) val)))
((string-equal key "OPTIONS")
(setq p (plist-put p :link-up val)))
((string-equal key "LINK_HOME")
(setq p (plist-put p :link-home val)))
+ ((string-equal key "EXPORT_SELECT_TAGS")
+ (setq p (plist-put p :select-tags (org-split-string val))))
+ ((string-equal key "EXPORT_EXCLUDE_TAGS")
+ (setq p (plist-put p :exclude-tags (org-split-string val))))
((equal key "SETUPFILE")
(setq setup-contents (org-file-contents
(expand-file-name
"\n" setup-contents "\n"
(substring ext-setup-or-nil start)))))))
(setq p (plist-put p :text text))
+ (when style (setq p (plist-put p :style-extra style)))
+ (when latex-header
+ (setq p (plist-put p :latex-header-extra (substring latex-header 1))))
(when options
(setq p (org-export-add-options-to-plist p options)))
p))))
(setq case-fold-search t)
(untabify (point-min) (point-max))
- ;; Handle incude files
+ ;; Handle include files
(org-export-handle-include-files)
+ ;; Get rid of excluded trees
+ (org-export-handle-export-tags (plist-get parameters :select-tags)
+ (plist-get parameters :exclude-tags))
+
;; Handle source code snippets
(org-export-replace-src-segments)
(setq target-alist (org-export-handle-invisible-targets target-alist))
;; Protect examples
- (org-export-protect-examples)
+ (org-export-protect-examples (if asciip 'indent nil))
;; Protect backend specific stuff, throw away the others.
(org-export-select-backend-specific-text
;; Remove comment environment and comment subtrees
(org-export-remove-comment-blocks-and-subtrees)
+
+ ;; Find matches for radio targets and turn them into internal links
+ (org-export-mark-radio-links)
+
+ ;; Find all links that contain a newline and put them into a single line
+ (org-export-concatenate-multiline-links)
+
+ ;; Normalize links: Convert angle and plain links into bracket links
+ ;; and expand link abbreviations
+ (org-export-normalize-links)
+
+ ;; Find all internal links. If they have a fuzzy match (i.e. not
+ ;; a *dedicated* target match, let the link point to the
+ ;; corresponding section.
+ (org-export-target-internal-links target-alist)
+
+ ;; Find multiline emphasis and put them into single line
+ (when (plist-get parameters :emph-multiline)
+ (org-export-concatenate-multiline-emphasis))
+
;; Remove special table lines
(when org-export-table-remove-special-lines
(org-export-remove-special-table-lines))
;; Remove or replace comments
(org-export-handle-comments (plist-get parameters :comments))
- ;; Find matches for radio targets and turn them into internal links
- (org-export-mark-radio-links)
-
- ;; Find all links that contain a newline and put them into a single line
- (org-export-concatenate-multiline-links)
-
- ;; Normalize links: Convert angle and plain links into bracket links
- ;; and expand link abbreviations
- (org-export-normalize-links)
-
- ;; Find all internal links. If they have a fuzzy match (i.e. not
- ;; a *dedicated* target match, let the link point to the
- ;; corresponding section.
- (org-export-target-internal-links target-alist)
-
- ;; Find multiline emphasis and put them into single line
- (when (plist-get parameters :emph-multiline)
- (org-export-concatenate-multiline-emphasis))
(setq rtn (buffer-string)))
(kill-buffer " org-mode-tmp")
(while (re-search-forward re nil t)
(replace-match "")))))
+(defun org-export-handle-export-tags (select-tags exclude-tags)
+ "Modify the buffer, honoring SELECT-TAGS and EXCLUDE-TAGS.
+Both arguments are lists of tags.
+If any of SELECT-TAGS is found, all trees not marked by a SELECT-TAG
+will be removed.
+After that, all subtrees that are marked by EXCLUDE-TAGS will be
+removed as well."
+ (remove-text-properties (point-min) (point-max) '(:org-delete t))
+ (let* ((re-sel (concat ":\\(" (mapconcat 'regexp-quote
+ select-tags "\\|")
+ "\\):"))
+ (re-excl (concat ":\\(" (mapconcat 'regexp-quote
+ exclude-tags "\\|")
+ "\\):"))
+ beg end cont)
+ (goto-char (point-min))
+ (when (and select-tags
+ (re-search-forward
+ (concat "^\\*+[ \t].*" re-sel "[^ \t\n]*[ \t]*$") nil t))
+ ;; At least one tree is marked for export, this means
+ ;; all the unmarked stuff needs to go.
+ ;; Dig out the trees that should be exported
+ (goto-char (point-min))
+ (outline-next-heading)
+ (setq beg (point))
+ (put-text-property beg (point-max) :org-delete t)
+ (while (re-search-forward re-sel nil t)
+ (when (org-on-heading-p)
+ (org-back-to-heading)
+ (remove-text-properties
+ (max (1- (point)) (point-min))
+ (setq cont (save-excursion (org-end-of-subtree t t)))
+ '(:org-delete t))
+ (while (and (org-up-heading-safe)
+ (get-text-property (point) :org-delete))
+ (remove-text-properties (max (1- (point)) (point-min))
+ (point-at-eol) '(:org-delete t)))
+ (goto-char cont))))
+ ;; Remove the trees explicitly marked for noexport
+ (when exclude-tags
+ (goto-char (point-min))
+ (while (re-search-forward re-excl nil t)
+ (when (org-at-heading-p)
+ (org-back-to-heading t)
+ (setq beg (point))
+ (org-end-of-subtree t)
+ (delete-region beg (point)))))
+ ;; 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))
+ (setq end (or (next-single-property-change beg :org-delete)
+ (point-max)))
+ (delete-region beg end))))
+
(defun org-export-remove-archived-trees (export-archived-trees)
"Remove archived trees.
When EXPORT-ARCHIVED-TREES is `headline;, only the headline will be exported.
'(org-protected t))
(goto-char (1+ (match-end 4)))))
-(defun org-export-protect-examples ()
+(defun org-export-protect-examples (&optional indent)
"Protect code that should be exported as monospaced examples."
(goto-char (point-min))
(while (re-search-forward "^#\\+BEGIN_EXAMPLE[ \t]*\n" nil t)
(goto-char (match-end 0))
(while (and (not (looking-at "#\\+END_EXAMPLE")) (not (eobp)))
- (insert ": ")
+ (insert (if indent ": " ":"))
(beginning-of-line 2)))
(goto-char (point-min))
(while (re-search-forward "^[ \t]*:.*\\(\n[ \t]*:.*\\)*" nil t)
(let ((inhibit-read-only t))
(save-excursion
(goto-char (point-min))
- (let ((end (save-excursion (outline-next-heading) (point))))
+ (let ((end (if (looking-at org-outline-regexp)
+ (point)
+ (save-excursion (outline-next-heading) (point)))))
(when (re-search-forward "^[ \t]*[^|# \t\r\n].*\n" end t)
;; Mark the line so that it will not be exported as normal text.
(org-unmodified
(plist-get opt-plist :skip-before-1st-heading)
:drawers (plist-get opt-plist :drawers)
:verbatim-multiline t
+ :select-tags (plist-get opt-plist :select-tags)
+ :exclude-tags (plist-get opt-plist :exclude-tags)
:archived-trees
(plist-get opt-plist :archived-trees)
:add-text (plist-get opt-plist :text))
#+EMAIL: %s
#+DATE: %s
#+LANGUAGE: %s
-#+TEXT: Some descriptive text to be emitted. Several lines OK.
#+OPTIONS: H:%d num:%s toc:%s \\n:%s @:%s ::%s |:%s ^:%s -:%s f:%s *:%s TeX:%s LaTeX:%s skip:%s d:%s tags:%s
%s
+#+EXPORT_SELECT_TAGS: %s
+#+EXPORT_EXCUDE_TAGS: %s
#+LINK_UP: %s
#+LINK_HOME: %s
#+CATEGORY: %s
#+LINK: %s
"
(buffer-name) (user-full-name) user-mail-address
- (format-time-string (car org-time-stamp-formats))
+ (format-time-string (substring (car org-time-stamp-formats) 1 -1))
org-export-default-language
org-export-headline-levels
org-export-with-section-numbers
org-export-with-drawers
org-export-with-tags
(if (featurep 'org-jsinfo) (org-infojs-options-inbuffer-template) "")
+ (mapconcat 'identity org-export-select-tags " ")
+ (mapconcat 'identity org-export-exclude-tags " ")
org-export-html-link-up
org-export-html-link-home
(file-name-nondirectory buffer-file-name)
:drawers (plist-get opt-plist :drawers)
:archived-trees
(plist-get opt-plist :archived-trees)
+ :select-tags (plist-get opt-plist :select-tags)
+ :exclude-tags (plist-get opt-plist :exclude-tags)
:add-text
(plist-get opt-plist :text)
:LaTeX-fragments
(setq head-count 0)
(org-init-section-numbers)
+ (org-open-par)
+
(while (setq line (pop lines) origline line)
(catch 'nextline
(throw 'nextline nil))
(when inverse
(let ((i (org-get-string-indentation line)))
- (if (> i 0)
- (setq line (concat (mapconcat 'identity
- (make-list (* 2 i) "\\nbsp") "")
- " " (org-trim line))))
- (setq line (concat line " \\\\"))))
+ (if (> i 0)
+ (setq line (concat (mapconcat 'identity
+ (make-list (* 2 i) "\\nbsp") "")
+ " " (org-trim line))))
+ (setq line (concat line " \\\\"))))
;; make targets to anchors
(while (string-match "<<<?\\([^<>]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line)
(org-html-level-start 1 nil umax
(and org-export-with-toc (<= level umax))
head-count)
- ;; the </div> to lose the last text-... div.
+ ;; the </div> to close the last text-... div.
(insert "</div>\n")
(unless body-only
(nth 2 lang-words) ": "
date "</p>\n"))
(when org-export-creator-info
- (insert (format "<p>HTML generated by org-mode %s in emacs %s<\p>\n"
+ (insert (format "<p>HTML generated by org-mode %s in emacs %s</p>\n"
org-version emacs-major-version)))
(insert "</div>"))
(insert (or (plist-get opt-plist :postamble) ""))
(insert "</body>\n</html>\n"))
- (normal-mode)
- (if (eq major-mode default-major-mode) (html-mode))
+ (unless (plist-get opt-plist :buffer-will-be-killed)
+ (normal-mode)
+ (if (eq major-mode default-major-mode) (html-mode)))
;; insert the table of contents
(goto-char (point-min))
(setq s (org-export-html-convert-sub-super s)))
(if org-export-with-TeX-macros
(let ((start 0) wd ass)
- (while (setq start (string-match "\\\\\\([a-zA-Z]+\\)" s start))
+ (while (setq start (string-match "\\\\\\([a-zA-Z]+\\)\\({}\\)?"
+ s start))
(if (get-text-property (match-beginning 0) 'org-protected s)
(setq start (match-end 0))
(setq wd (match-string 1 s))
"DTSTART"))
hd ts ts2 state status (inc t) pos b sexp rrule
scheduledp deadlinep todo prefix due start
- tmp pri category entry location summary desc uid
+ tmp pri categories entry location summary desc uid
(sexp-buffer (get-buffer-create "*ical-tmp*")))
(org-refresh-category-properties)
(save-excursion
uid (if org-icalendar-store-UID
(org-id-get-create)
(or (org-id-get) (org-id-new)))
- category (org-get-category)
+ categories (org-export-get-categories)
deadlinep nil scheduledp nil)
(if (looking-at re2)
(progn
(concat "\nDESCRIPTION: " desc) "")
(if (and location (string-match "\\S-" location))
(concat "\nLOCATION: " location) "")
- category)))))
+ categories)))))
(when (and org-icalendar-include-sexps
(condition-case nil (require 'icalendar) (error nil))
(fboundp 'icalendar-export-region))
(org-entry-get nil "DEADLINE"))
start (and (member 'todo-start org-icalendar-use-scheduled)
(org-entry-get nil "SCHEDULED"))
+ categories (org-export-get-categories)
uid (if org-icalendar-store-UID
(org-id-get-create)
(or (org-id-get) (org-id-new))))
(if (and desc (string-match "\\S-" desc))
(concat "\nDESCRIPTION: " desc) "")
(if due (concat "\n" due) "")
- category
+ categories
pri status)))))))))
+(defun org-export-get-categories ()
+ "Get categories according to `org-icalendar-categories'."
+ (let ((cs org-icalendar-categories) c rtn tmp)
+ (while (setq c (pop cs))
+ (cond
+ ((eq c 'category) (push (org-get-category) rtn))
+ ((eq c 'todo-state)
+ (setq tmp (org-get-todo-state))
+ (and tmp (push tmp rtn)))
+ ((eq c 'local-tags)
+ (setq rtn (append (nreverse (org-get-local-tags-at (point))) rtn)))
+ ((eq c 'all-tags)
+ (setq rtn (append (nreverse (org-get-tags-at (point))) rtn)))))
+ (mapconcat 'identity (nreverse rtn) ",")))
+
(defun org-icalendar-cleanup-string (s &optional is-body maxlength)
"Take out stuff and quote what needs to be quoted.
When IS-BODY is non-nil, assume that this is the body of an item, clean up
;;
;; Emacs Lisp Archive Entry
;; Filename: org-export-latex.el
-;; Version: 6.06b
+;; Version: 6.09a
;; Author: Bastien Guerry <bzg AT altern DOT org>
;; Maintainer: Bastien Guerry <bzg AT altern DOT org>
;; Keywords: org, wp, tex
(defvar org-export-latex-add-level 0)
(defvar org-export-latex-sectioning "")
(defvar org-export-latex-sectioning-depth 0)
-(defvar org-export-latex-list-beginning-re
- "^\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) +?")
-
(defvar org-export-latex-special-string-regexps
'(org-ts-regexp
org-scheduled-string
;;; User variables:
+(defgroup org-export-latex nil
+ "Options for exporting Org-mode files to LaTeX."
+ :tag "Org Export LaTeX"
+ :group 'org-export)
+
(defcustom org-export-latex-default-class "article"
"The default LaTeX class."
:group 'org-export-latex
:type 'string)
(defcustom org-export-latex-tables-verbatim nil
- "When non-nil, export tables as verbatim."
+ "When non-nil, tables are exported verbatim."
:group 'org-export-latex
:type 'boolean)
(defcustom org-export-latex-tables-column-borders nil
- "When non-nil, group of columns are surrounded with borders,
-XSeven if these borders are the outside borders of the table."
+ "When non-nil, group of columns are surrounded with borders."
:group 'org-export-latex
:type 'boolean)
:type 'alist)
(defcustom org-export-latex-low-levels 'description
- "How to convert sections below the current level of sectioning,
-as specified by `org-export-headline-levels' or the value of \"H:\"
-in Org's #+OPTION line.
+ "How to convert sections below the current level of sectioning.
+This is specified by the `org-export-headline-levels' option or the
+value of \"H:\" in Org's #+OPTION line.
This can be either nil (skip the sections), 'description (convert
the sections as descriptive lists) or a string to be used instead
:group 'org-export-latex
:type 'coding-system)
-(defcustom org-list-radio-list-templates
- '((latex-mode "% BEGIN RECEIVE ORGLST %n
-% END RECEIVE ORGLST %n
-\\begin{comment}
-#+ORGLST: SEND %n org-list-to-latex
-| | |
-\\end{comment}\n")
- (texinfo-mode "@c BEGIN RECEIVE ORGLST %n
-@c END RECEIVE ORGLST %n
-@ignore
-#+ORGLST: SEND %n org-list-to-texinfo
-| | |
-@end ignore\n")
- (html-mode "<!-- BEGIN RECEIVE ORGLST %n -->
-<!-- END RECEIVE ORGLST %n -->
-<!--
-#+ORGLST: SEND %n org-list-to-html
-| | |
--->\n"))
- "Templates for radio lists in different major modes.
-All occurrences of %n in a template will be replaced with the name of the
-list, obtained by prompting the user."
- :group 'org-plain-lists
- :type '(repeat
- (list (symbol :tag "Major mode")
- (string :tag "Format"))))
-
;;; Autoload functions:
;;;###autoload
(defun org-export-as-latex-batch ()
- "Call `org-export-as-latex', may be used in batch processing as
+ "Call `org-export-as-latex', may be used in batch processing.
+For example:
+
emacs --batch
--load=$HOME/lib/emacs/org.el
--eval \"(setq org-export-headline-levels 2)\"
(goto-char rbeg)
(and (org-at-heading-p)
(>= (org-end-of-subtree t t) rend)))))
- (opt-plist (if subtree-p
+ (opt-plist (if subtree-p
(org-export-add-subtree-options opt-plist rbeg)
opt-plist))
;; Make sure the variable contains the updated values.
:comments nil
:add-text (if (eq to-buffer 'string) nil text)
:skip-before-1st-heading skip
+ :select-tags (plist-get opt-plist :select-tags)
+ :exclude-tags (plist-get opt-plist :exclude-tags)
:LaTeX-fragments nil)))
(set-buffer buffer)
(mapc (lambda(x) (org-export-latex-subcontent x num)) subcontent)))
(defun org-export-latex-subcontent (subcontent num)
- "Export each cell of SUBCONTENT to LaTeX."
- (let ((heading (org-export-latex-fontify-headline
- (cdr (assoc 'heading subcontent))))
- (level (- (cdr (assoc 'level subcontent))
- org-export-latex-add-level))
- (occur (number-to-string (cdr (assoc 'occur subcontent))))
- (content (cdr (assoc 'content subcontent)))
- (subcontent (cadr (assoc 'subcontent subcontent))))
+ "Export each cell of SUBCONTENT to LaTeX.
+If NUM, export sections as numerical sections."
+ (let* ((heading (org-export-latex-fontify-headline
+ (cdr (assoc 'heading subcontent))))
+ (level (- (cdr (assoc 'level subcontent))
+ org-export-latex-add-level))
+ (occur (number-to-string (cdr (assoc 'occur subcontent))))
+ (content (cdr (assoc 'content subcontent)))
+ (subcontent (cadr (assoc 'subcontent subcontent)))
+ (label (org-get-text-property-any 0 'target heading)))
(cond
;; Normal conversion
((<= level org-export-latex-sectioning-depth)
(let ((sec (nth (1- level) org-export-latex-sectioning)))
(insert (format (if num (car sec) (cdr sec)) heading) "\n"))
+ (when label (insert (format "\\label{%s}\n" label)))
(insert (org-export-latex-content content))
(cond ((stringp subcontent) (insert subcontent))
((listp subcontent) (org-export-latex-sub subcontent))))
;; At a level under the hl option: we can drop this subsection
((> level org-export-latex-sectioning-depth)
(cond ((eq org-export-latex-low-levels 'description)
- (insert (format "\\begin{description}\n\n\\item[%s]\n\n" heading))
+ (insert (format "\\begin{description}\n\n\\item[%s]%s\n\n"
+ heading
+ (if label (format "\\label{%s}" label) "")))
(insert (org-export-latex-content content))
(cond ((stringp subcontent) (insert subcontent))
((listp subcontent) (org-export-latex-sub subcontent)))
(insert "\\end{description}\n"))
((stringp org-export-latex-low-levels)
(insert (format org-export-latex-low-levels heading) "\n")
+ (when label (insert (format "\\label{%s}\n" label)))
(insert (org-export-latex-content content))
(cond ((stringp subcontent) (insert subcontent))
((listp subcontent) (org-export-latex-sub subcontent)))))))))
(car p) (cadr p))))
org-export-latex-packages-alist "\n"))
;; insert additional commands in the header
+ (plist-get opt-plist :latex-header-extra)
org-export-latex-append-header
;; insert the title
(format
(buffer-substring (point-min) (point-max))))
(defun org-export-latex-protect-string (s)
- "Prevent further conversion for string S by adding the
-org-protect property."
+ "Add the org-protected property to string S."
(add-text-properties 0 (length s) '(org-protected t) s) s)
(defun org-export-latex-protect-char-in-string (char-list string)
(if (or (not org-export-with-tags)
(plist-get remove-list :tags))
(replace-match "")
- (replace-match
+ (replace-match
(org-export-latex-protect-string
- (format "\\texttt{%s}" (save-match-data
- (org-quote-chars (match-string 0)))))
- t t)))))
-
-(defun org-quote-chars (s)
- (let ((start 0))
- (while (string-match "_" s start)
- (setq start (+ 2 (match-beginning 0))
- s (replace-match "\\_" t t s))))
- s)
+ (format "\\texttt{%s}"
+ (save-match-data
+ (replace-regexp-in-string
+ "_" "\\\\_" (match-string 0)))))
+ t t)))))
(defun org-export-latex-fontify-headline (string)
- "Fontify special words in string."
+ "Fontify special words in STRING."
(with-temp-buffer
;; FIXME: org-inside-LaTeX-fragment-p doesn't work when the $...$ is at
;; the beginning of the buffer - inserting "\n" is safe here though.
(org-export-latex-special-chars
(plist-get org-export-latex-options-plist :sub-superscript))
(org-export-latex-links)
- (org-trim (buffer-substring-no-properties (point-min) (point-max)))))
+; (org-trim (buffer-substring-no-properties (point-min) (point-max)))))
+ (org-trim (buffer-string))))
(defun org-export-latex-quotation-marks ()
- "Export question marks depending on language conventions."
+ "Export quotation marks depending on language conventions."
(let* ((lang (plist-get org-export-latex-options-plist :language))
(quote-rpl (if (equal lang "fr")
- '(("\\(\\s-\\)\"" "«~")
- ("\\(\\S-\\)\"" "~»")
+ '(("\\(\\s-\\)\"" "«~")
+ ("\\(\\S-\\)\"" "~»")
("\\(\\s-\\)'" "`"))
'(("\\(\\s-\\)\"" "``")
("\\(\\S-\\)\"" "''")
(replace-match (or (save-match-data
(org-export-latex-treat-sub-super-char
sub-superscript
- (match-string 1)
(match-string 2)
+ (match-string 1)
(match-string 3))) "") t t)))))))
'("^\\([^\n$]*?\\|^\\)\\(\\\\?\\$\\)\\([^\n$]*\\)$"
"\\([a-za-z0-9]+\\|[ \t\n]\\|\\b\\|\\\\\\)\\(_\\|\\^\\)\\([a-za-z0-9]+\\|[ \t\n]\\|[:punct:]\\|{[a-za-z0-9]+}\\|([a-za-z0-9]+)\\)"
)))
(defun org-export-latex-treat-sub-super-char
- (subsup string-before char string-after)
+ (subsup char string-before string-after)
"Convert the \"_\" and \"^\" characters to LaTeX.
SUBSUP corresponds to the ^: option in the #+OPTIONS line.
Convert CHAR depending on STRING-BEFORE and STRING-AFTER."
(defun org-export-latex-keywords (timestamps)
"Convert special keywords to LaTeX.
-Regexps are those from `org-export-latex-special-string-regexps'."
+Regexps are those from `org-export-latex-special-string-regexps'.
+If TIMESTAMPS, convert timestamps, otherwise delete them."
(let ((rg org-export-latex-special-string-regexps) r)
(while (setq r (pop rg))
(goto-char (point-min))
(let* ((tbl (concat "\\begin{verbatim}\n" raw-table
"\\end{verbatim}\n")))
(apply 'delete-region (list beg end))
- (insert tbl))
+ (insert (org-export-latex-protect-string tbl)))
(progn
(setq lines (split-string raw-table "\n" t))
(apply 'delete-region (list beg end))
(split-string (org-trim elem) "|" t)))
lines))
(when insert
- (insert (orgtbl-to-latex
- lines `(:tstart ,(concat "\\begin{tabular}{" align "}")))
+ (insert (org-export-latex-protect-string
+ (orgtbl-to-latex
+ lines `(:tstart ,(concat "\\begin{tabular}{" align "}"))))
"\n\n")))))))
(defun org-export-latex-fontify ()
;; image option should be set be a comment line
org-export-latex-image-default-option
(expand-file-name raw-path))))
- (radiop (insert (format "\\hyperref[%s]{%s}" raw-path desc)))
+ (radiop (insert (format "\\hyperref[%s]{%s}"
+ (org-solidify-link-text raw-path) desc)))
+ ((not type)
+ (insert (format "\\hyperref[%s]{%s}"
+ (org-solidify-link-text raw-path) desc)))
(path (insert (format "\\href{%s}{%s}" path desc)))
(t (insert "\\texttt{" desc "}")))))))
(add-text-properties (match-beginning 0) (match-end 0)
'(org-protected t)))
+ ;; Preserve latex environments
+ (goto-char (point-min))
+ (while (search-forward "\\begin{" nil t)
+ (let ((start (progn (beginning-of-line) (point)))
+ (end (or (and (search-forward "\\end{" nil t)
+ (end-of-line) (point))
+ (point-max))))
+ (add-text-properties start end '(org-protected t))))
+
;; Convert LaTeX to \LaTeX{}
(goto-char (point-min))
(let ((case-fold-search nil) rpl)
;; Convert blockquotes
(goto-char (point-min))
- (while (re-search-forward "^#\\+BEGIN_QUOTE" nil t)
+ (while (search-forward "ORG-BLOCKQUOTE-START" nil t)
(replace-match "\\begin{quote}" t t))
(goto-char (point-min))
- (while (re-search-forward "^#\\+END_QUOTE" nil t)
+ (while (search-forward "ORG-BLOCKQUOTE-END" nil t)
(replace-match "\\end{quote}" t t))
;; Convert verse
(goto-char (point-min))
- (while (re-search-forward "^#\\+BEGIN_VERSE" nil t)
+ (while (search-forward "ORG-VERSE-START" nil t)
(replace-match "\\begin{verse}" t t))
(goto-char (point-min))
- (while (re-search-forward "^#\\+END_VERSE" nil t)
+ (while (search-forward "ORG-VERSE-END" nil t)
(replace-match "\\end{verse}" t t))
;; Convert horizontal rules
">>>?\\((INVISIBLE)\\)?") nil t)
(replace-match
(org-export-latex-protect-string
- (format "\\label{%s}%s"(match-string 1)
+ (format "\\label{%s}%s" (save-match-data (org-solidify-link-text
+ (match-string 1)))
(if (match-string 2) "" (match-string 1)))) t t))
;; Delete @<...> constructs
"Replace plain text lists in current buffer into LaTeX lists."
"Convert lists to LaTeX."
(goto-char (point-min))
- (while (re-search-forward org-export-latex-list-beginning-re nil t)
+ (while (re-search-forward org-list-beginning-re nil t)
(beginning-of-line)
(insert (org-list-to-latex (org-list-parse-list t)) "\n")))
-(defun org-list-parse-list (&optional delete)
- "Parse the list at point.
-Return a list containing first level items as strings and
-sublevels as a list of strings."
- (let ((start (org-list-item-begin))
- (end (org-list-end))
- output itemsep)
- (while (re-search-forward org-export-latex-list-beginning-re end t)
- (setq itemsep (if (save-match-data
- (string-match "^[0-9]" (match-string 2)))
- "[0-9]+\\(?:\\.\\|)\\)" "[-+]"))
- (let* ((indent1 (match-string 1))
- (nextitem (save-excursion
- (save-match-data
- (or (and (re-search-forward
- (concat "^" indent1 itemsep " *?") end t)
- (match-beginning 0)) end))))
- (item (buffer-substring
- (point)
- (or (and (re-search-forward
- org-export-latex-list-beginning-re end t)
- (goto-char (match-beginning 0)))
- (goto-char end))))
- (nextindent (match-string 1))
- (item (org-trim item))
- (item (if (string-match "^\\[.+\\]" item)
- (replace-match "\\\\texttt{\\&}"
- t nil item) item)))
- (push item output)
- (when (> (length nextindent)
- (length indent1))
- (narrow-to-region (point) nextitem)
- (push (org-list-parse-list) output)
- (widen))))
- (when delete (delete-region start end))
- (setq output (nreverse output))
- (push (if (string-match "^\\[0" itemsep)
- 'ordered 'unordered) output)))
-
-(defun org-list-item-begin ()
- "Find the beginning of the list item and return its position."
- (save-excursion
- (if (not (or (looking-at org-export-latex-list-beginning-re)
- (re-search-backward
- org-export-latex-list-beginning-re nil t)))
- (progn (goto-char (point-min)) (point))
- (match-beginning 0))))
-
-(defun org-list-end ()
- "Find the end of the list and return its position."
- (save-excursion
- (catch 'exit
- (while (or (looking-at org-export-latex-list-beginning-re)
- (looking-at "^[ \t]+\\|^$"))
- (if (eq (point) (point-max))
- (throw 'exit (point-max)))
- (forward-line 1))) (point)))
-
-(defun org-list-insert-radio-list ()
- "Insert a radio list template appropriate for this major mode."
- (interactive)
- (let* ((e (assq major-mode org-list-radio-list-templates))
- (txt (nth 1 e))
- name pos)
- (unless e (error "No radio list setup defined for %s" major-mode))
- (setq name (read-string "List name: "))
- (while (string-match "%n" txt)
- (setq txt (replace-match name t t txt)))
- (or (bolp) (insert "\n"))
- (setq pos (point))
- (insert txt)
- (goto-char pos)))
-
-(defun org-list-send-list (&optional maybe)
- "Send a tranformed version of this list to the receiver position.
-With argument MAYBE, fail quietly if no transformation is defined for
-this list."
- (interactive)
- (catch 'exit
- (unless (org-at-item-p) (error "Not at a list"))
- (save-excursion
- (goto-char (org-list-item-begin))
- (beginning-of-line 0)
- (unless (looking-at "#\\+ORGLST: *SEND +\\([a-zA-Z0-9_]+\\) +\\([^ \t\r\n]+\\)\\( +.*\\)?")
- (if maybe
- (throw 'exit nil)
- (error "Don't know how to transform this list"))))
- (let* ((name (match-string 1))
- beg
- (transform (intern (match-string 2)))
- (txt (buffer-substring-no-properties
- (org-list-item-begin)
- (org-list-end)))
- (list (org-list-parse-list)))
- (unless (fboundp transform)
- (error "No such transformation function %s" transform))
- (setq txt (funcall transform list))
- ;; Find the insertion place
- (save-excursion
- (goto-char (point-min))
- (unless (re-search-forward
- (concat "BEGIN RECEIVE ORGLST +" name "\\([ \t]\\|$\\)") nil t)
- (error "Don't know where to insert translated list"))
- (goto-char (match-beginning 0))
- (beginning-of-line 2)
- (setq beg (point))
- (unless (re-search-forward (concat "END RECEIVE ORGLST +" name) nil t)
- (error "Cannot find end of insertion region"))
- (beginning-of-line 1)
- (delete-region beg (point))
- (goto-char beg)
- (insert txt "\n"))
- (message "List converted and installed at receiver location"))))
-
-(defun org-list-to-generic (list params)
- "Convert a LIST parsed through `org-list-parse-list' to other formats.
-
-Valid parameters are
-
-:ustart String to start an unordered list
-:uend String to end an unordered list
-
-:ostart String to start an ordered list
-:oend String to end an ordered list
-
-:splice When set to t, return only list body lines, don't wrap
- them into :[u/o]start and :[u/o]end. Default is nil.
-
-:istart String to start a list item
-:iend String to end a list item
-:isep String to separate items
-:lsep String to separate sublists"
- (interactive)
- (let* ((p params) sublist
- (splicep (plist-get p :splice))
- (ostart (plist-get p :ostart))
- (oend (plist-get p :oend))
- (ustart (plist-get p :ustart))
- (uend (plist-get p :uend))
- (istart (plist-get p :istart))
- (iend (plist-get p :iend))
- (isep (plist-get p :isep))
- (lsep (plist-get p :lsep)))
- (let ((wrapper
- (cond ((eq (car list) 'ordered)
- (concat ostart "\n%s" oend "\n"))
- ((eq (car list) 'unordered)
- (concat ustart "\n%s" uend "\n"))))
- rtn)
- (while (setq sublist (pop list))
- (cond ((symbolp sublist) nil)
- ((stringp sublist)
- (setq rtn (concat rtn istart sublist iend isep)))
- (t
- (setq rtn (concat rtn ;; previous list
- lsep ;; list separator
- (org-list-to-generic sublist p)
- lsep ;; list separator
- )))))
- (format wrapper rtn))))
-
-(defun org-list-to-latex (list)
- "Convert LIST into a LaTeX list."
- (org-list-to-generic
- list '(:splicep nil :ostart "\\begin{enumerate}" :oend "\\end{enumerate}"
- :ustart "\\begin{itemize}" :uend "\\end{itemize}"
- :istart "\\item " :iend ""
- :isep "\n" :lsep "\n")))
-
-(defun org-list-to-html (list)
- "Convert LIST into a HTML list."
- (org-list-to-generic
- list '(:splicep nil :ostart "<ol>" :oend "</ol>"
- :ustart "<ul>" :uend "</ul>"
- :istart "<li>" :iend "</li>"
- :isep "\n" :lsep "\n")))
-
-(defun org-list-to-texinfo (list)
- "Convert LIST into a Texinfo list."
- (org-list-to-generic
- list '(:splicep nil :ostart "@itemize @minus" :oend "@end itemize"
- :ustart "@enumerate" :uend "@end enumerate"
- :istart "@item\n" :iend ""
- :isep "\n" :lsep "\n")))
-
(defconst org-latex-entities
'("\\!"
"\\'"
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
-;; Version: 6.06b
+;; Version: 6.09a
;;
;; This file is part of GNU Emacs.
;;
(when (fboundp 'set-face-attribute)
(set-face-attribute 'org-agenda-date-weekend nil :weight 'bold)))
+(defface org-scheduled
+ (org-compatible-face nil
+ '((((class color) (min-colors 88) (background light)) (:foreground "DarkGreen"))
+ (((class color) (min-colors 88) (background dark)) (:foreground "PaleGreen"))
+ (((class color) (min-colors 8)) (:foreground "green"))
+ (t (:bold t :italic t))))
+ "Face for items scheduled for a certain day."
+ :group 'org-faces)
+
(defface org-scheduled-today
(org-compatible-face nil
'((((class color) (min-colors 88) (background light)) (:foreground "DarkGreen"))
"Face for items scheduled for a certain day."
:group 'org-faces)
+
(defface org-scheduled-previously
(org-compatible-face nil
'((((class color) (min-colors 88) (background light)) (:foreground "Firebrick"))
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
-;; Version: 6.06b
+;; Version: 6.09a
;;
;; This file is part of GNU Emacs.
;;
(from (mail-header-from header))
(message-id (mail-header-id header))
(date (mail-header-date header))
+ (extra (mail-header-extra header))
+ (to (cdr (assoc 'To extra)))
(subject (gnus-summary-subject-string))
desc link)
(org-store-link-props :type "gnus" :from from :subject subject
- :message-id message-id :group group)
+ :message-id message-id :group group :to to)
(setq desc (org-email-link-description))
(if (org-xor current-prefix-arg org-usenet-links-prefer-google)
(setq link
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
-;; Version: 6.06b
+;; Version: 6.09a
;;
;; This file is part of GNU Emacs.
;;
;; are provided that create and retrieve such identifiers, and that find
;; entries based on the identifier.
-;; Identifiers consist of a prefix (default "Org") and a compact encoding
-;; of the creation time of the ID, with microsecond accuracy. This virtually
+;; Identifiers consist of a prefix (default "Org" given by the variable
+;; `org-id-prefix') and a unique part that can be created by a number
+;; of different methods, see the variable `org-id-method'.
+;; Org has a builtin method that uses a compact encoding of the creation
+;; time of the ID, with microsecond accuracy. This virtually
;; guarantees globally unique identifiers, even if several people are
;; creating ID's at the same time in files that will eventually be used
-;; together. Even higher security can be achieved by using different
-;; prefix values for each collaborator or file.
+;; together. As an exernal method `uuidgen' is supported, if installed
+;; on the system.
;;
;; This file defines the following API:
;;
:tag "Org ID"
:group 'org)
-(defcustom org-id-prefix "Org"
+(defcustom org-id-method 'org
+ "The method that should be used to create new ID's.
+
+An ID will consist of the prefix specified in `org-id-prefix', and a unique
+part created by the method this variable specifies.
+
+Allowed values are:
+
+org Org's own internal method, using an encoding of the current time,
+ and the current domain of the computer. This method will
+ honor the variable `org-id-include-domain'.
+
+uuidgen Call the external command uuidgen."
+ :group 'org-id
+ :type '(choice
+ (const :tag "Org's internal method" org)
+ (const :tag "external: uuidgen" uuidgen)))
+
+(defcustom org-id-prefix nil
"The prefix for IDs.
This may be a string, or it can be nil to indicate that no prefix is required.
(defcustom org-id-include-domain t
"Non-nil means, add the domain name to new IDs.
This ensures global uniqueness of ID's, and is also suggested by
-RFC 2445 in combination with RFC 822."
+RFC 2445 in combination with RFC 822. This is only relevant if
+`org-id-method' is `org'. When uuidgen is used, the domain will never
+be added."
:group 'org-id
:type 'boolean)
An ID consists of two parts separated by a colon:
- a prefix
-- an encoding of the current time to micro-second accuracy
+- a unique part that will be created according to `org-id-method'.
PREFIX can specify the prefix, the default is given by the variable
`org-id-prefix'. However, if PREFIX is the symbol `none', don't use any
So a typical ID could look like \"Org:4nd91V40HI\"."
(let* ((prefix (if (eq prefix 'none)
- nil
- (or prefix org-id-prefix)))
- (etime (org-id-time-to-b62))
- (postfix (if org-id-include-domain
- (progn
- (require 'message)
- (concat "@" (message-make-fqdn))))))
- (if prefix
- (concat prefix ":" etime postfix)
- (concat etime postfix))))
-
-(defun org-id-int-to-b62-one-digit (i)
+ ""
+ (concat (or prefix org-id-prefix) ":")))
+ unique)
+ (if (equal prefix ":") (setq prefix ""))
+ (cond
+ ((eq org-id-method 'uuidgen)
+ (setq unique (substring (shell-command-to-string "uuidgen") 1 -1)))
+ ((eq org-id-method 'org)
+ (let* ((etime (org-id-reverse-string (org-id-time-to-b36)))
+ (postfix (if org-id-include-domain
+ (progn
+ (require 'message)
+ (concat "@" (message-make-fqdn))))))
+ (setq unique (concat etime postfix))))
+ (t (error "Invalid `org-id-method'")))
+ (concat prefix unique)))
+
+(defun org-id-reverse-string (s)
+ (mapconcat 'char-to-string (nreverse (string-to-list s)) ""))
+
+(defun org-id-int-to-b36-one-digit (i)
"Turn an integer between 0 and 61 into a single character 0..9, A..Z, a..z."
(cond
((< i 10) (+ ?0 i))
- ((< i 36) (+ ?A i -10))
- ((< i 62) (+ ?a i -36))
- (t (error "Larger that 61"))))
+ ((< i 36) (+ ?a i -10))
+ (t (error "Larger that 35"))))
-(defun org-id-b62-to-int-one-digit (i)
+(defun org-id-b36-to-int-one-digit (i)
"Turn a character 0..9, A..Z, a..z into a number 0..61.
The input I may be a character, or a single-letter string."
(and (stringp i) (setq i (string-to-char i)))
(cond
((and (>= i ?0) (<= i ?9)) (- i ?0))
- ((and (>= i ?A) (<= i ?Z)) (+ (- i ?A) 10))
- ((and (>= i ?a) (<= i ?z)) (+ (- i ?a) 36))
- (t (error "Invalid b62 letter"))))
+ ((and (>= i ?a) (<= i ?z)) (+ (- i ?a) 10))
+ (t (error "Invalid b36 letter"))))
-(defun org-id-int-to-b62 (i &optional length)
- "Convert an integer to a base-62 number represented as a string."
+(defun org-id-int-to-b36 (i &optional length)
+ "Convert an integer to a base-36 number represented as a string."
(let ((s ""))
(while (> i 0)
(setq s (concat (char-to-string
- (org-id-int-to-b62-one-digit (mod i 62))) s)
- i (/ i 62)))
+ (org-id-int-to-b36-one-digit (mod i 36))) s)
+ i (/ i 36)))
(setq length (max 1 (or length 1)))
(if (< (length s) length)
(setq s (concat (make-string (- length (length s)) ?0) s)))
s))
-(defun org-id-b62-to-int (s)
- "Convert a base-62 string into the corresponding integer."
+(defun org-id-b36-to-int (s)
+ "Convert a base-36 string into the corresponding integer."
(let ((r 0))
- (mapc (lambda (i) (setq r (+ (* r 62) (org-id-b62-to-int-one-digit i))))
+ (mapc (lambda (i) (setq r (+ (* r 36) (org-id-b36-to-int-one-digit i))))
s)
r))
-(defun org-id-time-to-b62 (&optional time)
+(defun org-id-time-to-b36 (&optional time)
"Encode TIME as a 10-digit string.
This string holds the time to micro-second accuracy, and can be decoded
using `org-id-decode'."
(setq time (or time (current-time)))
- (concat (org-id-int-to-b62 (nth 0 time) 3)
- (org-id-int-to-b62 (nth 1 time) 3)
- (org-id-int-to-b62 (or (nth 2 time) 0) 4)))
+ (concat (org-id-int-to-b36 (nth 0 time) 4)
+ (org-id-int-to-b36 (nth 1 time) 4)
+ (org-id-int-to-b36 (or (nth 2 time) 0) 4)))
(defun org-id-decode (id)
"Split ID into the prefix and the time value that was used to create it.
(if (= 2 (length parts))
(setq prefix (car parts) time (nth 1 parts))
(setq prefix nil time (nth 0 parts)))
- (setq time (list (org-id-b62-to-int (substring time 0 3))
- (org-id-b62-to-int (substring time 3 6))
- (org-id-b62-to-int (substring time 6 10))))
+ (setq time (org-id-reverse-string time))
+ (setq time (list (org-id-b36-to-int (substring time 0 4))
+ (org-id-b36-to-int (substring time 4 8))
+ (org-id-b36-to-int (substring time 8 12))))
(cons prefix time)))
;; Storing ID locations (files)
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
-;; Version: 6.06b
+;; Version: 6.09a
;;
;; This file is part of GNU Emacs.
;;
;;
;; Author: Philip Jackson <emacs@shellarchive.co.uk>
;; Keywords: erc, irc, link, org
-;; Version: 6.06b
+;; Version: 6.09a
;;
;; This file is part of GNU Emacs.
;;
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
-;; Version: 6.06b
+;; Version: 6.09a
;;
;; This file is part of GNU Emacs.
;;
;; Copyright (C) 2008 Free Software Foundation, Inc.
;; Author: John Wiegley <johnw@gnu.org>
-;; Version: 6.06b
+;; Version: 6.09a
;; Keywords: outlines, hypermedia, calendar, wp
;; This file is part of GNU Emacs.
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
-;; Version: 6.06b
+;; Version: 6.09a
;;
;; This file is part of GNU Emacs.
;;
;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
-;; Version: 6.06b
+;; Version: 6.09a
;; This file is part of GNU Emacs.
;; Author: Thomas Baumann <thomas dot baumann at ch dot tum dot de>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
-;; Version: 6.06b
+;; Version: 6.09a
;;
;; This file is part of GNU Emacs.
;;
;;
;; Author: Piotr Zielinski <piotr dot zielinski at gmail dot com>
;; Maintainer: Carsten Dominik <carsten at orgmode dot org>
-;; Version: 6.06b
+;; Version: 6.09a
;;
;; This file is part of GNU Emacs.
;;
;; Author: David O'Toole <dto@gnu.org>
;; Maintainer: Bastien Guerry <bzg AT altern DOT org>
;; Keywords: hypermedia, outlines, wp
-;; Version: 6.06b
+;; Version: 6.09a
;; This file is part of GNU Emacs.
;;
;;; Commentary:
-;; Requires at least version 4.27 of org.el
-
;; This program allow configurable publishing of related sets of
;; Org-mode files as a complete website.
;;
all-files))
(defun org-publish-expand-projects (projects-alist)
- "Expand projects contained in PROJECTS-ALIST."
- (let (without-component with-component)
- (mapc (lambda(p)
- (add-to-list
- (if (plist-get (cdr p) :components)
- 'with-component 'without-component) p))
- projects-alist)
- (org-publish-delete-dups
- (append without-component
- (car (mapcar (lambda(p) (org-publish-expand-components p))
- with-component))))))
-
-(defun org-publish-expand-components (project)
- "Expand PROJECT into an alist of its components."
- (let* ((components (plist-get (cdr project) :components)))
- (org-publish-delete-dups
- (delq nil (mapcar (lambda(c) (assoc c org-publish-project-alist))
- components)))))
-
+ "Expand projects in PROJECTS-ALIST.
+This splices all the components into the list."
+ (let ((rest projects-alist) rtn p components)
+ (while (setq p (pop rest))
+ (if (setq components (plist-get (cdr p) :components))
+ (setq rest (append
+ (mapcar (lambda (x) (assoc x org-publish-project-alist))
+ components)
+ rest))
+ (push p rtn)))
+ (nreverse (org-publish-delete-dups (delq nil rtn)))))
+
(defun org-publish-get-base-files-1 (base-dir &optional recurse match skip-file skip-dir)
"Set `org-publish-temp-files' with files from BASE-DIR directory.
If RECURSE is non-nil, check BASE-DIR recursively. If MATCH is
(require 'org)
(unless (file-exists-p pub-dir)
(make-directory pub-dir t))
- (find-file filename)
- (let ((init-buf (current-buffer))
- (init-point (point))
- (init-buf-string (buffer-string)) export-buf)
+ (let* ((visiting (find-buffer-visiting filename))
+ (plist (cons :buffer-will-be-killed (cons t plist)))
+ (init-buf (or visiting (find-file filename)))
+ (init-point (point))
+ (init-buf-string (buffer-string)) export-buf)
;; run hooks before exporting
(run-hooks 'org-publish-before-export-hook)
;; export the possibly modified buffer
(insert init-buf-string)
(save-buffer)
(goto-char init-point))
- (unless (eq init-buf org-publish-initial-buffer)
+ (unless visiting
(kill-buffer init-buf))))
(defun org-publish-org-to-latex (plist filename pub-dir)
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
-;; Version: 6.06b
+;; Version: 6.09a
;;
;; This file is part of GNU Emacs.
;;
(require 'cl))
(require 'org)
+(declare-function remember-mode "remember" ())
(declare-function remember "remember" (&optional initial))
(declare-function remember-buffer-desc "remember" ())
(declare-function remember-finalize "remember" ())
(defvar remember-save-after-remembering)
-(defvar remember-data-file)
(defvar remember-register)
(defvar remember-buffer)
(defvar remember-handler-functions)
(defvar remember-annotation-functions)
+(defvar org-clock-heading)
+(defvar org-clock-heading-for-remember)
(defgroup org-remember nil
"Options concerning interaction with remember.el."
%x content of the X clipboard
%^C Interactive selection of which kill or clip to use
%^L Like %^C, but insert as link
+ %k title of currently clocked task
+ %K link to currently clocked task
%^g prompt for tags, with completion on tags in target file
%^G prompt for tags, with completion all tags in all agenda files
+ %^{prop}p Prompt the user for a value for property `prop'
%:keyword specific information for certain link types, see below
%[pathname] insert the contents of the file given by `pathname'
%(sexp) evaluate elisp `(sexp)' and replace with the result
:get (lambda (var) ; Make sure all entries have at least 5 elements
(mapcar (lambda (x)
(if (not (stringp (car x))) (setq x (cons "" x)))
- (cond ((= (length x) 4) (append x '("")))
- ((= (length x) 3) (append x '("" "")))
+ (cond ((= (length x) 4) (append x '(nil)))
+ ((= (length x) 3) (append x '(nil nil)))
(t x)))
(default-value var)))
:type '(repeat
(string :tag "Template")
(choice :tag "Destination file"
(file :tag "Specify")
+ (function :tag "Function")
(const :tag "Use `org-default-notes-file'" nil))
(choice :tag "Destin. headline"
(string :tag "Specify")
;;;###autoload
(defun org-remember-insinuate ()
- "Setup remember.el for use wiht Org-mode."
- (require 'remember)
+ "Setup remember.el for use with Org-mode."
+ (org-require-remember)
(setq remember-annotation-functions '(org-remember-annotation))
(setq remember-handler-functions '(org-remember-handler))
(add-hook 'remember-mode-hook 'org-remember-apply-template))
(cddr (assoc char templates)))))
(defun org-get-x-clipboard (value)
- "Get the value of the x clibboard, in a way that also works with XEmacs."
+ "Get the value of the x clibboard, compatible with XEmacs, and GNU Emacs 21."
(if (eq window-system 'x)
- (let ((x (if org-xemacs-p
- (org-no-warnings (get-selection-no-error value))
- (and (fboundp 'x-selection-value)
- (x-selection-value value)))))
- (and (> (length x) 0) (set-text-properties 0 (length x) nil x) x))))
+ (let ((x (org-get-x-clipboard-compat value)))
+ (if x (org-no-properties x)))))
;;;###autoload
(defun org-remember-apply-template (&optional use-char skip-interactive)
"Initialize *remember* buffer with template, invoke `org-mode'.
This function should be placed into `remember-mode-hook' and in fact requires
to be run from that hook to function properly."
+ (when (and (boundp 'initial) (stringp initial))
+ (setq initial (org-no-properties initial))
+ (remove-text-properties 0 (length initial) '(read-only t) initial))
(if org-remember-templates
(let* ((entry (org-select-remember-template use-char))
(ct (or org-overriding-default-time (org-current-time)))
+ (dct (decode-time ct))
+ (ct1
+ (if (< (nth 2 dct) org-extend-today-until)
+ (encode-time 0 59 23 (1- (nth 3 dct)) (nth 4 dct) (nth 5 dct))
+ ct))
(tpl (car entry))
(plist-p (if org-store-link-plist t nil))
- (file (if (and (nth 1 entry) (stringp (nth 1 entry))
- (string-match "\\S-" (nth 1 entry)))
+ (file (if (and (nth 1 entry)
+ (or (and (stringp (nth 1 entry))
+ (string-match "\\S-" (nth 1 entry)))
+ (functionp (nth 1 entry))))
(nth 1 entry)
org-default-notes-file))
(headline (nth 2 entry))
(replace-match "[\\1[%^{Link description}]]" nil nil v-a)
v-a))
(v-n user-full-name)
+ (v-k (if (marker-buffer org-clock-marker)
+ (substring-no-properties org-clock-heading)))
+ (v-K (if (marker-buffer org-clock-marker)
+ (org-make-link-string
+ (buffer-file-name (marker-buffer org-clock-marker))
+ org-clock-heading)))
+ v-I
(org-startup-folded nil)
+ (org-inhibit-startup t)
org-time-was-given org-end-time-was-given x
prompt completions char time pos default histvar)
+
+ (when (functionp file)
+ (setq file (funcall file)))
(when (and file (not (file-name-absolute-p file)))
(setq file (expand-file-name file org-directory)))
+
+
(setq org-store-link-plist
(append (list :annotation v-a :initial v-i)
org-store-link-plist))
(erase-buffer)
(insert (substitute-command-keys
(format
-"## Filing location: Select interactively, default, or last used:
+"## %s \"%s\" -> \"* %s\"
+## C-u C-c C-c like C-c C-c, and immediately visit note at target location
+## C-0 C-c C-c \"%s\" -> \"* %s\"
## %s to select file and header location interactively.
-## %s \"%s\" -> \"* %s\"
-## C-u C-u C-c C-c \"%s\" -> \"* %s\"
+## C-2 C-c C-c as child of the currently clocked item
## To switch templates, use `\\[org-remember]'. To abort use `C-c C-k'.\n\n"
- (if org-remember-store-without-prompt " C-u C-c C-c" " C-c C-c")
- (if org-remember-store-without-prompt " C-c C-c" " C-u C-c C-c")
+ (if org-remember-store-without-prompt " C-c C-c" " C-1 C-c C-c")
(abbreviate-file-name (or file org-default-notes-file))
(or headline "")
(or (car org-remember-previous-location) "???")
- (or (cdr org-remember-previous-location) "???"))))
- (insert tpl) (goto-char (point-min))
+ (or (cdr org-remember-previous-location) "???")
+ (if org-remember-store-without-prompt "C-1 C-c C-c" " C-c C-c"))))
+ (insert tpl)
+ (goto-char (point-min))
+
;; Simple %-escapes
- (while (re-search-forward "%\\([tTuUaiAcx]\\)" nil t)
+ (while (re-search-forward "%\\([tTuUaiAcxkKI]\\)" nil t)
(when (and initial (equal (match-string 0) "%i"))
(save-match-data
(let* ((lead (buffer-substring
(replace-match x t t))))
;; Turn on org-mode in the remember buffer, set local variables
- (org-mode)
+ (let ((org-inhibit-startup t)) (org-mode))
(org-set-local 'org-finish-function 'org-remember-finalize)
(if (and file (string-match "\\S-" file) (not (file-directory-p file)))
(org-set-local 'org-default-notes-file file))
(org-set-local 'org-remember-default-headline headline))
;; Interactive template entries
(goto-char (point-min))
- (while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([gGtTuUCL]\\)?" nil t)
+ (while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([gGtTuUCLp]\\)?" nil t)
(setq char (if (match-end 3) (match-string 3))
prompt (if (match-end 2) (match-string 2)))
(goto-char (match-beginning 0))
(car clipboards)
'(clipboards . 1)
(car clipboards))))))
+ ((equal char "p")
+ (let*
+ ((prop (substring-no-properties prompt))
+ (allowed (with-current-buffer
+ (get-buffer (file-name-nondirectory file))
+ (org-property-get-allowed-values nil prop 'table)))
+ (existing (with-current-buffer
+ (get-buffer (file-name-nondirectory file))
+ (mapcar 'list (org-property-values prop))))
+ (propprompt (concat "Value for " prop ": "))
+ (val (if allowed
+ (org-completing-read propprompt allowed nil
+ 'req-match)
+ (org-completing-read propprompt existing nil nil
+ "" nil ""))))
+ (org-set-property prop val)))
(char
;; These are the date/time related ones
(setq org-time-was-given (equal (upcase char) char))
(if (re-search-forward "%\\?" nil t)
(replace-match "")
(and (re-search-forward "^[^#\n]" nil t) (backward-char 1))))
- (org-mode)
+ (let ((org-inhibit-startup t)) (org-mode))
(org-set-local 'org-finish-function 'org-remember-finalize))
(when (save-excursion
(goto-char (point-min))
Lisp programs can set ORG-FORCE-REMEMBER-TEMPLATE-CHAR to a character
associated with a template in `org-remember-templates'."
(interactive "P")
+ (org-require-remember)
(cond
((equal goto '(4)) (org-go-to-remember-target))
((equal goto '(16)) (org-remember-goto-last-stored))
;;;###autoload
(defun org-remember-handler ()
"Store stuff from remember.el into an org file.
-First prompts for an org file. If the user just presses return, the value
-of `org-default-notes-file' is used.
-Then the command offers the headings tree of the selected file in order to
-file the text at a specific location.
-You can either immediately press RET to get the note appended to the
-file, or you can use vertical cursor motion and visibility cycling (TAB) to
-find a better place. Then press RET or <left> or <right> in insert the note.
-
-Key Cursor position Note gets inserted
------------------------------------------------------------------------------
-RET buffer-start as level 1 heading at end of file
-RET on headline as sublevel of the heading at cursor
-RET no heading at cursor position, level taken from context.
- Or use prefix arg to specify level manually.
-<left> on headline as same level, before current heading
-<right> on headline as same level, after current heading
-
-So the fastest way to store the note is to press RET RET to append it to
-the default file. This way your current train of thought is not
-interrupted, in accordance with the principles of remember.el.
-You can also get the fast execution without prompting by using
-C-u C-c C-c to exit the remember buffer. See also the variable
-`org-remember-store-without-prompt'.
-
-Before being stored away, the function ensures that the text has a
-headline, i.e. a first line that starts with a \"*\". If not, a headline
-is constructed from the current date and some additional data.
+When the template has specified a file and a headline, the entry is filed
+there, or in the location defined by `org-default-notes-file' and
+`org-remember-default-headline'.
+
+If no defaults have been defined, or if the current prefix argument
+is 1 (so you must use `C-1 C-c C-c' to exit remember), an interactive
+process is used to select the target location.
+
+When the prefix is 0 (i.e. when remember is exited with `C-0 C-c C-c'),
+the entry is filed to the same location as the previous note.
+
+When the prefix is 2 (i.e. when remember is exited with `C-2 C-c C-c'),
+the entry is fild as a subentry of the entry where the clock is
+currently running.
+
+When `C-u' has been used as prefix argument, the note is stored and emacs
+moves point to the new location of the note, so that editing can be
+continued there (smilar to inserting \"%&\" into the tempate).
+
+Before storing the note, the function ensures that the text has an
+org-mode-style headline, i.e. a first line that starts with
+a \"*\". If not, a headline is constructed from the current date and
+some additional data.
If the variable `org-adapt-indentation' is non-nil, the entire text is
also indented so that it starts in the same column as the headline
\(i.e. after the stars).
See also the variable `org-reverse-note-order'."
+ (when (and (equal current-prefix-arg 2)
+ (not (marker-buffer org-clock-marker)))
+ (error "No runing clock"))
(when (org-bound-and-true-p org-jump-to-target-location)
(let* ((end (min (point-max) (1+ (point))))
(beg (point)))
(catch 'quit
(if org-note-abort (throw 'quit nil))
(let* ((visitp (org-bound-and-true-p org-jump-to-target-location))
- (fastp (org-xor (equal current-prefix-arg '(4))
+ (previousp (and (member current-prefix-arg '((16) 0))
+ org-remember-previous-location))
+ (clockp (equal current-prefix-arg 2))
+ (fastp (org-xor (equal current-prefix-arg 1)
org-remember-store-without-prompt))
(file (cond
(fastp org-default-notes-file)
((and (eq org-remember-interactive-interface 'refile)
org-refile-targets)
org-default-notes-file)
- ((not (and (equal current-prefix-arg '(16))
- org-remember-previous-location))
+ ((not previousp)
(org-get-org-file))))
(heading org-remember-default-headline)
(visiting (and file (org-find-base-buffer-visiting file)))
(org-startup-align-all-tables nil)
(org-goto-start-pos 1)
spos exitcmd level reversed txt)
- (if (and (equal current-prefix-arg '(16)) org-remember-previous-location)
- (setq file (car org-remember-previous-location)
- heading (cdr org-remember-previous-location)
- fastp t))
+ (when (equal current-prefix-arg '(4))
+ (setq visitp t))
+ (when previousp
+ (setq file (car org-remember-previous-location)
+ heading (cdr org-remember-previous-location)
+ fastp t))
+ (when clockp
+ (setq file (buffer-file-name (marker-buffer org-clock-marker))
+ heading org-clock-heading-for-remember
+ fastp t))
(setq current-prefix-arg nil)
;; Modify text so that it becomes a nice subtree which can be inserted
;; into an org tree.
(setq org-goto-start-pos (or (match-beginning 0) (point-min))))
((eq heading 'bottom)
(goto-char (point-max))
- (re-search-backward "^\\* " nil t)
(or (bolp) (newline))
(setq org-goto-start-pos (point)))
((and (stringp heading) (string-match "\\S-" heading))
(cond
((and fastp (memq heading '(top bottom)))
(setq spos org-goto-start-pos
- exitcmd (if (eq heading 'top) 'left 'right)))
+ exitcmd (if (eq heading 'top) 'left nil)))
(fastp (setq spos org-goto-start-pos
exitcmd 'return))
((eq org-remember-interactive-interface 'outline)
(move-marker org-remember-last-stored-marker (point)))
(t (error "This should not happen"))))
+ ((eq heading 'bottom)
+ (org-paste-subtree 1 txt)
+ (and org-auto-align-tags (org-set-tags nil t))
+ (bookmark-set "org-remember-last-stored")
+ (move-marker org-remember-last-stored-marker (point)))
+
((and (bobp) (not reversed))
;; Put it at the end, one level below level 1
(save-restriction
t) ;; return t to indicate that we took care of this note.
-
(defun org-do-remember (&optional initial)
"Call remember."
(remember initial))
+(defun org-require-remember ()
+ "Make sure remember is loaded, or install our own emergency version of it."
+ (condition-case nil
+ (require 'remember)
+ (error
+ ;; Lets install our own micro version of remember
+ (defvar remember-register ?R)
+ (defvar remember-mode-hook nil)
+ (defvar remember-handler-functions nil)
+ (defvar remember-buffer "*Remember*")
+ (defvar remember-save-after-remembering t)
+ (defvar remember-annotation-functions '(buffer-file-name))
+ (defun remember-finalize ()
+ (run-hook-with-args-until-success 'remember-handler-functions)
+ (when (equal remember-buffer (buffer-name))
+ (kill-buffer (current-buffer))
+ (jump-to-register remember-register)))
+ (defun remember-mode ()
+ (fundamental-mode)
+ (setq mode-name "Remember")
+ (run-hooks 'remember-mode-hook))
+ (defun remember (&optional initial)
+ (window-configuration-to-register remember-register)
+ (let* ((annotation (run-hook-with-args-until-success
+ 'remember-annotation-functions)))
+ (switch-to-buffer-other-window (get-buffer-create remember-buffer))
+ (remember-mode)))
+ (defun remember-buffer-desc ()
+ (buffer-substring (point-min) (save-excursion (goto-char (point-min))
+ (point-at-eol)))))))
+
(provide 'org-remember)
;; arch-tag: 497f30d0-4bc3-4097-8622-2d27ac5f2698
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
-;; Version: 6.06b
+;; Version: 6.09a
;;
;; This file is part of GNU Emacs.
;;
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
-;; Version: 6.06b
+;; Version: 6.09a
;;
;; This file is part of GNU Emacs.
;;
calc-angle-mode deg
calc-prefer-frac nil
calc-symbolic-mode nil
- calc-date-format (YYYY "-" MM "-" DD " " Www (" " HH ":" mm))
+ calc-date-format (YYYY "-" MM "-" DD " " Www (" " hh ":" mm))
calc-display-working-message t
)
"List with Calc mode settings for use in calc-eval for table formulas.
(field (org-table-get-field))
(non-empty (string-match "[^ \t]" field))
(beg (org-table-begin))
+ (orig-n n)
txt)
(org-table-check-inside-data-field)
(if non-empty
(org-table-goto-column colpos t)
(if (and (looking-at
"|[ \t]*\\([^| \t][^|]*?\\)[ \t]*|")
- (= (setq n (1- n)) 0))
+ (<= (setq n (1- n)) 0))
(throw 'exit (match-string 1))))))))
(if txt
(progn
(if (and org-table-copy-increment
- (string-match "^[0-9]+$" txt))
+ (not (equal orig-n 0))
+ (string-match "^[0-9]+$" txt)
+ (< (string-to-number txt) 100000000))
(setq txt (format "%d" (+ (string-to-number txt) 1))))
(insert txt)
(org-move-to-column col)
items1)))
(res (apply '+ numbers))
(sres (if (= org-timecnt 0)
- (format "%g" res)
+ (number-to-string res)
(setq diff (* 3600 res)
h (floor (/ diff 3600)) diff (mod diff 3600)
m (floor (/ diff 60)) diff (mod diff 60)
'("\C-c{" org-table-toggle-formula-debugger)
'("\C-m" org-table-next-row)
'([(shift return)] org-table-copy-down)
- '("\C-c\C-q" org-table-wrap-region)
'("\C-c?" org-table-field-info)
'("\C-c " org-table-blank-field)
'("\C-c+" org-table-sum)
(goto-char (match-beginning 0))
(self-insert-command N))
(setq org-table-may-need-update t)
- (let (orgtbl-mode)
- (call-interactively (key-binding (vector last-input-event))))))
+ (let (orgtbl-mode a)
+ (call-interactively
+ (key-binding
+ (or (and (listp function-key-map)
+ (setq a (assoc last-input-event function-key-map))
+ (cdr a))
+ (vector last-input-event)))))))
(defvar orgtbl-exp-regexp "^\\([-+]?[0-9][0-9.]*\\)[eE]\\([-+]?[0-9]+\\)$"
"Regular expression matching exponentials as produced by calc.")
(delete-region beg (point))))
(insert txt "\n")))
+;;;###autoload
(defun org-table-to-lisp (&optional txt)
"Convert the table at point to a Lisp structure.
The structure will be a list. Each item is either the symbol `hline'
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
-;; Version: 6.06b
+;; Version: 6.09a
;;
;; This file is part of GNU Emacs.
;;
;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
-;; Version: 6.06b
+;; Version: 6.09a
;;
;; This file is part of GNU Emacs.
;;
;; Backward compatibility to old version of wl
(declare-function wl "ext:wl" () t)
(declare-function wl-summary-buffer-msgdb "ext:wl-folder" () t)
-(declare-function wl-folder-get-elmo-folder "ext:wl-folder"
- (entity &optional no-cache))
+;(declare-function wl-folder-get-elmo-folder "ext:wl-folder"
+; (entity &optional no-cache))
(declare-function wl-summary-goto-folder-subr "ext:wl-summary"
(&optional name scan-type other-window sticky interactive
scoring force-exit))
(declare-function wl-summary-registered-temp-mark "ext:wl-action" (number))
(declare-function wl-folder-goto-folder-subr "ext:wl-folder"
(&optional folder sticky))
-(declare-function wl-thread-open-all "ext:wl-thread" ())
(defvar wl-init)
(defvar wl-summary-buffer-elmo-folder)
(defvar wl-summary-buffer-folder-name)
(error "Error in Wanderlust link"))
(let ((folder (match-string 1 path))
(article (match-string 3 path)))
- (if (not (elmo-folder-exists-p (wl-folder-get-elmo-folder folder)))
+ (if (not (elmo-folder-exists-p (org-no-warnings
+ (wl-folder-get-elmo-folder folder))))
(error "No such folder: %s" folder))
(let ((old-buf (current-buffer))
(old-point (point-marker)))
;; in the old buffer.
(set-buffer old-buf)
(goto-char old-point))
- (wl-thread-open-all)
(and (wl-summary-jump-to-msg-by-message-id (org-add-angle-brackets
article))
(wl-summary-redisplay)))))
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
-;; Version: 6.06b
+;; Version: 6.09a
;;
;; This file is part of GNU Emacs.
;;
(require 'org-macs)
(require 'org-compat)
(require 'org-faces)
+(require 'org-list)
;;;; Customization variables
;;; Version
-(defconst org-version "6.06b"
+(defconst org-version "6.09a"
"The version number of the file org.el.")
(defun org-version (&optional here)
:group 'org-startup
:type 'boolean)
-(defcustom org-startup-indented nil
- "Non-nil means, turn on `org-indent-mode' on startup.
-This can also be configured on a per-file basis by adding one of
-the following lines anywhere in the buffer:
-
- #+STARTUP: localindent
- #+STARTUP: indent
- #+STARTUP: noindent"
- :group 'org-structure
- :type '(choice
- (const :tag "Not" nil)
- (const :tag "Locally" local)
- (const :tag "Globally (slow on startup in large files)" t)))
-
(defcustom org-startup-align-all-tables nil
"Non-nil means, align all tables when visiting a file.
This is useful when the column width in tables is forced with <N> cookies
:group 'org-startup
:type 'boolean)
+(defcustom org-use-extra-keys nil
+ "Non-nil means use extra key sequence definitions for certain
+commands. This happens automatically if you run XEmacs or if
+window-system is nil. This variable lets you do the same
+manually. You must set it before loading org.
+
+Example: on Carbon Emacs 22 running graphically, with an external
+keyboard on a Powerbook, the default way of setting M-left might
+not work for either Alt or ESC. Setting this variable will make
+it work for ESC."
+ :group 'org-startup
+ :type 'boolean)
+
(if (fboundp 'defvaralias)
(defvaralias 'org-CUA-compatible 'org-replace-disputed-keys))
Special case: when 0, never leave empty lines in collapsed view."
:group 'org-cycle
:type 'integer)
+(put 'org-cycle-separator-lines 'safe-local-variable 'integerp)
(defcustom org-cycle-hook '(org-cycle-hide-archived-subtrees
org-cycle-hide-drawers
:group 'org-edit-structure
:type 'boolean)
+(defcustom org-yank-folded-subtrees t
+ "Non-nil means, when yanking subtrees, fold them.
+If the kill is a single subtree, or a sequence of subtrees, i.e. if
+it starts with a heading and all other headings in it are either children
+or siblings, then fold all the subtrees."
+ :group 'org-edit-structure
+ :type 'boolean)
+
(defcustom org-M-RET-may-split-line '((default . t))
"Non-nil means, M-RET will split the line at the cursor position.
When nil, it will go to the end of the line before making a
(boolean)))))
+(defcustom org-insert-heading-respect-content nil
+ "Non-nil means, insert new headings after the current subtree.
+When nil, the new heading is created directly after the current line.
+The commands \\[org-insert-heading-respect-content] and
+\\[org-insert-todo-heading-respect-content] turn this variable on
+for the duration of the command."
+ :group 'org-structure
+ :type 'boolean)
+
(defcustom org-blank-before-new-entry '((heading . nil)
(plain-list-item . nil))
"Should `org-insert-heading' leave a blank line before new heading/item?
:group 'org-edit-structure
:type 'boolean)
+(defcustom org-edit-src-region-extra nil
+ "Additional regexps to identify regions for editing with `org-edit-src-code'.
+For examples see the function `org-edit-src-find-region-and-lang'.
+The regular expression identifying the begin marker should end with a newline,
+and the regexp marking the end line should start with a newline, to make sure
+there are kept outside the narrowed region."
+ :group 'org-edit-structure
+ :type '(repeat
+ (list
+ (regexp :tag "begin regexp")
+ (regexp :tag "end regexp")
+ (choice :tag "language"
+ (string :tag "specify")
+ (integer :tag "from match group")
+ (const :tag "from `lang' element")
+ (const :tag "from `style' element")))))
+
+(defcustom org-edit-fixed-width-region-mode 'artist-mode
+ "The mode that should be used to edit fixed-width regions.
+These are the regions where each line starts with a colon."
+ :group 'org-edit-structure
+ :type '(choice
+ (const artist-mode)
+ (const picture-mode)
+ (const fundamental-mode)
+ (function :tag "Other (specify)")))
+
(defcustom org-goto-auto-isearch t
"Non-nil means, typing characters in org-goto starts incremental search."
:group 'org-edit-structure
:group 'org-sparse-trees
:type 'hook)
-(defgroup org-plain-lists nil
- "Options concerning plain lists in Org-mode."
- :tag "Org Plain lists"
- :group 'org-structure)
-
-(defcustom org-cycle-include-plain-lists nil
- "Non-nil means, include plain lists into visibility cycling.
-This means that during cycling, plain list items will *temporarily* be
-interpreted as outline headlines with a level given by 1000+i where i is the
-indentation of the bullet. In all other operations, plain list items are
-not seen as headlines. For example, you cannot assign a TODO keyword to
-such an item."
- :group 'org-plain-lists
- :type 'boolean)
-
-(defcustom org-plain-list-ordered-item-terminator t
- "The character that makes a line with leading number an ordered list item.
-Valid values are ?. and ?\). To get both terminators, use t. While
-?. may look nicer, it creates the danger that a line with leading
-number may be incorrectly interpreted as an item. ?\) therefore is
-the safe choice."
- :group 'org-plain-lists
- :type '(choice (const :tag "dot like in \"2.\"" ?.)
- (const :tag "paren like in \"2)\"" ?\))
- (const :tab "both" t)))
-
-(defcustom org-empty-line-terminates-plain-lists nil
- "Non-nil means, an empty line ends all plain list levels.
-When nil, empty lines are part of the preceeding item."
- :group 'org-plain-lists
- :type 'boolean)
-
-(defcustom org-auto-renumber-ordered-lists t
- "Non-nil means, automatically renumber ordered plain lists.
-Renumbering happens when the sequence have been changed with
-\\[org-shiftmetaup] or \\[org-shiftmetadown]. After other editing commands,
-use \\[org-ctrl-c-ctrl-c] to trigger renumbering."
- :group 'org-plain-lists
- :type 'boolean)
-
-(defcustom org-provide-checkbox-statistics t
- "Non-nil means, update checkbox statistics after insert and toggle.
-When this is set, checkbox statistics is updated each time you either insert
-a new checkbox with \\[org-insert-todo-heading] or toggle a checkbox
-with \\[org-ctrl-c-ctrl-c\\]."
- :group 'org-plain-lists
- :type 'boolean)
-
-(defcustom org-description-max-indent 20
- "Maximum indentation for the second line of a description list.
-When the indentation would be larger than this, it will become
-5 characters instead."
- :group 'org-plain-lists
- :type 'integer)
-
(defgroup org-imenu-and-speedbar nil
"Options concerning imenu and speedbar in Org-mode."
:tag "Org Imenu and Speedbar"
(defconst org-file-apps-defaults-macosx
'((remote . emacs)
(t . "open %s")
- ("ps" . "gv %s")
("ps.gz" . "gv %s")
- ("eps" . "gv %s")
("eps.gz" . "gv %s")
("dvi" . "xdvi %s")
("fig" . "xfig %s"))
(defcustom org-file-apps
'(
- ("txt" . emacs)
- ("tex" . emacs)
- ("ltx" . emacs)
- ("org" . emacs)
- ("el" . emacs)
- ("bib" . emacs)
+ (auto-mode . emacs)
+ ("\\.x?html?\\'" . default)
)
"External applications for opening `file:path' items in a document.
Org-mode uses system defaults for different file types, but
extension. The entries in this list are cons cells where the car identifies
files and the cdr the corresponding command. Possible values for the
file identifier are
- \"ext\" A string identifying an extension
+ \"regex\" Regular expression matched against the file name. For backward
+ compatibility, this can also be a string with only alphanumeric
+ characters, which is then interpreted as an extension.
`directory' Matches a directory
`remote' Matches a remote file, accessible through tramp or efs.
Remote files most likely should be visited through Emacs
because external applications cannot handle such paths.
- t Default for all remaining files
+`auto-mode' Matches files that are mached by any entry in `auto-mode-alist',
+ so all files Emacs knows how to handle. Useing this with
+ command `emacs' will open most files in Emacs. Beware that this
+ will also open html files insite Emacs, unless you add
+ (\"html\" . default) to the list as well.
+ t Default for files not matched by any of the other options.
Possible values for the command are:
`emacs' The file will be visited by the current Emacs process.
- `default' Use the default application for this file type.
+ `default' Use the default application for this file type, which is the
+ association for t in the list, most likely in the system-specific
+ part.
+ This can be used to overrule an unwanted seting in the
+ system-specific variable.
string A command to be executed by a shell; %s will be replaced
by the path to the file.
sexp A Lisp form which will be evaluated. The file path will
(string :tag "Extension")
(const :tag "Default for unrecognized files" t)
(const :tag "Remote file" remote)
- (const :tag "Links to a directory" directory))
+ (const :tag "Links to a directory" directory)
+ (const :tag "Any files that have Emacs modes"
+ auto-mode))
(choice :value ""
(const :tag "Visit with Emacs" emacs)
(const :tag "Use system default" default)
- a cons cell (:regexp . \"REGEXP\") with a regular expression matching
headlines that are refiling targets.
- a cons cell (:level . N). Any headline of level N is considered a target.
- - a cons cell (:maxlevel . N). Any headline with level <= N is a target."
+ - a cons cell (:maxlevel . N). Any headline with level <= N is a target.
+
+When this variable is nil, all top-level headlines in the current buffer
+are used, equivalent to the vlaue `((nil . (:level . 1))'."
:group 'org-remember
:type '(repeat
(cons
(make-variable-buffer-local 'org-todo-keywords-1)
(defvar org-todo-keywords-for-agenda nil)
(defvar org-done-keywords-for-agenda nil)
+(defvar org-todo-keyword-alist-for-agenda nil)
+(defvar org-tag-alist-for-agenda nil)
(defvar org-agenda-contributing-files nil)
(defvar org-not-done-keywords nil)
(make-variable-buffer-local 'org-not-done-keywords)
(setq org-log-done 'note)))
(defcustom org-log-note-clock-out nil
- "Non-nil means, recored a note when clocking out of an item.
+ "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
the following lines anywhere in the buffer:
'org-read-date-popup-calendar))
(defcustom org-extend-today-until 0
- "The hour when your day really ends.
+ "The hour when your day really ends. Must be an integer.
This has influence for the following applications:
- When switching the agenda to \"today\". It it is still earlier than
the time given here, the day recognized as TODAY is actually yesterday.
- When a date is read from the user and it is still before the time given
here, the current date and time will be assumed to be yesterday, 23:59.
+ Also, timestamps inserted in remember templates follow this rule.
-FIXME:
-IMPORTANT: This is still a very experimental feature, it may disappear
-again or it may be extended to mean more things."
+IMPORTANT: This is a feature whose implementation is and likely will
+remain incomplete. Really, it is only here because past midnight seems to
+ne the favorite working time of John Wiegley :-)"
:group 'org-time
:type 'number)
:group 'org-properties
:type 'string)
+(defcustom org-columns-modify-value-for-display-function nil
+ "Function that modifies values for display in column view.
+For example, it can be used to cut out a certain part from a time stamp.
+The function must take 2 argments:
+
+column-title The tite of the column (*not* the property name)
+value The value that should be modified.
+
+The function should return the value that should be displayed,
+or nil if the normal value should be used."
+ :group 'org-properties
+ :type 'function)
(defcustom org-effort-property "Effort"
"The property that is being used to keep track of effort estimates.
If the file does not specify a category, then file's base name
is used instead.")
(make-variable-buffer-local 'org-category)
+(put 'org-category 'safe-local-variable '(lambda (x) (or (symbolp x) (stringp x))))
(defcustom org-agenda-files nil
"The files to be used for agenda display.
org-table-rotate-recalc-marks org-table-sort-lines org-table-sum
org-table-toggle-coordinate-overlays
org-table-toggle-formula-debugger org-table-wrap-region
- orgtbl-mode turn-on-orgtbl)))
+ orgtbl-mode turn-on-orgtbl org-table-to-lisp)))
(defun org-at-table-p (&optional table-type)
"Return t if the cursor is inside an org-type table.
org-table-clean-before-export
org-export-icalendar-combine-agenda-files org-export-as-xoxo)))
-;; Declare and autoload functions from org-exp.el
+;; Declare and autoload functions from org-agenda.el
(eval-and-compile
- (org-autoload "org-exp"
+ (org-autoload "org-agenda"
'(org-agenda org-agenda-list org-search-view
org-todo-list org-tags-view org-agenda-list-stuck-projects
org-diary org-agenda-to-appt)))
(throw 'exit t))))))
(defun org-activate-code (limit)
- (if (re-search-forward "^[ \t]*\\(:.*\\)" limit t)
- (unless (get-text-property (match-beginning 1) 'face)
+ (if (re-search-forward "^[ \t]*\\(: .*\n?\\)" limit t)
+ (progn
(remove-text-properties (match-beginning 0) (match-end 0)
'(display t invisible t intangible t))
t)))
1. OVERVIEW: Show only top-level headlines.
2. CONTENTS: Show all headlines of all levels, but no body text.
3. SHOW ALL: Show everything.
- When called with two C-c C-u prefixes, switch to the startup visibility,
+ When called with two C-u C-u prefixes, switch to the startup visibility,
determined by the variable `org-startup-folded', and by any VISIBILITY
properties in the buffer.
+ When called with three C-u C-u C-u prefixed, show the entire buffer,
+ including drawers.
- When point is at the beginning of a headline, rotate the subtree started
by this line through 3 different states (local cycling)
((equal arg '(16))
(org-set-startup-visibility)
- (message "Startup visibility, plus VISIBILITY properties."))
+ (message "Startup visibility, plus VISIBILITY properties"))
+
+ ((equal arg '(64))
+ (show-all)
+ (message "Entire buffer visible, including drawers"))
((org-at-table-p 'any)
;; Enter the table or move to the next field in the table
(let ((isearch-mode-map org-goto-local-auto-isearch-map)
(isearch-hide-immediately nil)
(isearch-search-fun-function
- (lambda () 'org-goto-local-search-forward-headings))
+ (lambda () 'org-goto-local-search-headings))
(org-goto-selected-point org-goto-exit-command))
(save-excursion
(save-window-excursion
(define-key org-goto-local-auto-isearch-map "\C-i" 'isearch-other-control-char)
(define-key org-goto-local-auto-isearch-map "\C-m" 'isearch-other-control-char)
-(defun org-goto-local-search-forward-headings (string bound noerror)
- "Search and make sure that anu matches are in headlines."
+(defun org-goto-local-search-headings (string bound noerror)
+ "Search and make sure that any matches are in headlines."
(catch 'return
- (while (search-forward string bound noerror)
+ (while (if isearch-forward
+ (search-forward string bound noerror)
+ (search-backward string bound noerror))
(when (let ((context (mapcar 'car (save-match-data (org-context)))))
(and (member :headline context)
(not (member :tags context))))
(let ((split
(org-get-alist-option org-M-RET-may-split-line 'headline))
tags pos)
- (if (org-on-heading-p)
- (progn
- (looking-at ".*?\\([ \t]+\\(:[[:alnum:]_@:]+:\\)\\)?[ \t]*$")
- (setq tags (and (match-end 2) (match-string 2)))
- (and (match-end 1)
- (delete-region (match-beginning 1) (match-end 1)))
- (setq pos (point-at-bol))
- (or split (end-of-line 1))
- (delete-horizontal-space)
- (newline (if blank 2 1))
- (when tags
- (save-excursion
- (goto-char pos)
- (end-of-line 1)
- (insert " " tags)
- (org-set-tags nil 'align))))
+ (cond
+ (org-insert-heading-respect-content
+ (org-end-of-subtree nil t)
+ (open-line 1))
+ ((org-on-heading-p)
+ (looking-at ".*?\\([ \t]+\\(:[[:alnum:]_@:]+:\\)\\)?[ \t]*$")
+ (setq tags (and (match-end 2) (match-string 2)))
+ (and (match-end 1)
+ (delete-region (match-beginning 1) (match-end 1)))
+ (setq pos (point-at-bol))
(or split (end-of-line 1))
- (newline (if blank 2 1))))))
+ (delete-horizontal-space)
+ (newline (if blank 2 1))
+ (when tags
+ (save-excursion
+ (goto-char pos)
+ (end-of-line 1)
+ (insert " " tags)
+ (org-set-tags nil 'align))))
+ (t
+ (or split (end-of-line 1))
+ (newline (if blank 2 1)))))))
(insert head) (just-one-space)
(setq pos (point))
(end-of-line 1)
(org-move-subtree-down)
(end-of-line 1))
+(defun org-insert-heading-respect-content ()
+ (interactive)
+ (let ((org-insert-heading-respect-content t))
+ (call-interactively 'org-insert-heading)))
+
+(defun org-insert-todo-heading-respect-content ()
+ (interactive)
+ (let ((org-insert-heading-respect-content t))
+ (call-interactively 'org-insert-todo-todo-heading)))
+
(defun org-insert-todo-heading (arg)
"Insert a new heading with the same level and TODO state as current heading.
If the heading has no TODO state, or if the state is DONE, use the first
kill)
(- (match-end 2) (match-beginning 2) 1)))
(re (concat "^" org-outline-regexp))
- (start (1+ (match-beginning 2))))
+ (start (1+ (or (match-beginning 2) -1))))
(if (not start-level)
(progn
nil) ;; does not even start with a heading
(lambda nil
(cond
((= dcst ?n)
- (if (looking-at outline-regexp)
- (string-to-number (buffer-substring (match-end 0)
- (point-at-eol)))
+ (if (looking-at org-complex-heading-regexp)
+ (string-to-number (match-string 4))
nil))
((= dcst ?a)
- (funcall case-func (buffer-substring (point-at-bol)
- (point-at-eol))))
+ (if (looking-at org-complex-heading-regexp)
+ (funcall case-func (match-string 4))
+ nil))
((= dcst ?t)
(if (re-search-forward org-ts-regexp
(save-excursion
(define-key org-exit-edit-mode-map "\C-c'" 'org-edit-src-exit)
(defvar org-edit-src-force-single-line nil)
(defvar org-edit-src-from-org-mode nil)
+(defvar org-edit-src-picture nil)
(define-minor-mode org-exit-edit-mode
"Minor mode installing a single key binding, \"C-c '\" to exit special edit.")
(message "%s" msg)
t)))
+(defun org-edit-fixed-width-region ()
+ "Edit the fixed-width ascii drawing at point.
+This must be a region where each line starts with ca colon followed by
+a space character.
+An indirect buffer is created, and that buffer is then narrowed to the
+example at point and switched to artist-mode. When done,
+exit by killing the buffer with \\[org-edit-src-exit]."
+ (interactive)
+ (let ((line (org-current-line))
+ (case-fold-search t)
+ (msg (substitute-command-keys
+ "Edit, then exit with C-c ' (C-c and single quote)"))
+ (org-mode-p (eq major-mode 'org-mode))
+ beg end lang lang-f)
+ (beginning-of-line 1)
+ (if (looking-at "[ \t]*[^:\n \t]")
+ nil
+ (if (looking-at "[ \t]*\\(\n\\|\\'\\)]")
+ (setq beg (point) end (match-end 0))
+ (save-excursion
+ (if (re-search-backward "^[ \t]*[^:]" nil 'move)
+ (setq beg (point-at-bol 2))
+ (setq beg (point))))
+ (save-excursion
+ (if (re-search-forward "^[ \t]*[^:]" nil 'move)
+ (setq end (1- (match-beginning 0)))
+ (setq end (point))))
+ (goto-line line)
+ (if (get-buffer "*Org Edit Picture*")
+ (kill-buffer "*Org Edit Picture*"))
+ (switch-to-buffer (make-indirect-buffer (current-buffer)
+ "*Org Edit Picture*"))
+ (narrow-to-region beg end)
+ (remove-text-properties beg end '(display nil invisible nil
+ intangible nil))
+ (when (fboundp 'font-lock-unfontify-region)
+ (font-lock-unfontify-region (point-min) (point-max)))
+ (cond
+ ((eq org-edit-fixed-width-region-mode 'artist-mode)
+ (fundamental-mode)
+ (artist-mode 1))
+ (t (funcall org-edit-fixed-width-region-mode)))
+ (set (make-local-variable 'org-edit-src-force-single-line) nil)
+ (set (make-local-variable 'org-edit-src-from-org-mode) org-mode-p)
+ (set (make-local-variable 'org-edit-src-picture) t)
+ (goto-char (point-min))
+ (while (re-search-forward "^[ \t]*: " nil t)
+ (replace-match ""))
+ (goto-line line)
+ (org-exit-edit-mode)
+ (org-set-local 'header-line-format msg)
+ (message "%s" msg)
+ t))))
+
+
(defun org-edit-src-find-region-and-lang ()
"Find the region and language for a local edit.
Return a list with beginning and end of the region, a string representing
the language, a switch telling of the content should be in a single line."
(let ((re-list
- '(
- ("<src\\>[^<]*>[ \t]*\n?" "\n?[ \t]*</src>" lang)
- ("<literal\\>[^<]*>[ \t]*\n?" "\n?[ \t]*</literal>" style)
- ("<example>[ \t]*\n?" "\n?[ \t]*</example>" "fundamental")
- ("<lisp>[ \t]*\n?" "\n?[ \t]*</lisp>" "emacs-lisp")
- ("<perl>[ \t]*\n?" "\n?[ \t]*</perl>" "perl")
- ("<python>[ \t]*\n?" "\n?[ \t]*</python>" "python")
- ("<ruby>[ \t]*\n?" "\n?[ \t]*</ruby>" "ruby")
- ("^#\\+begin_src\\( \\([^ \t\n]+\\)\\)?.*\n" "\n#\\+end_src" 2)
- ("^#\\+begin_example.*\n" "^#\\+end_example" "fundamental")
- ("^#\\+html:" "\n" "html" single-line)
- ("^#\\+begin_html.*\n" "\n#\\+end_html" "html")
- ("^#\\+begin_latex.*\n" "\n#\\+end_latex" "latex")
- ("^#\\+latex:" "\n" "latex" single-line)
- ("^#\\+begin_ascii.*\n" "\n#\\+end_ascii" "fundamental")
- ("^#\\+ascii:" "\n" "ascii" single-line)
- ))
+ (append
+ org-edit-src-region-extra
+ '(
+ ("<src\\>[^<]*>[ \t]*\n?" "\n?[ \t]*</src>" lang)
+ ("<literal\\>[^<]*>[ \t]*\n?" "\n?[ \t]*</literal>" style)
+ ("<example>[ \t]*\n?" "\n?[ \t]*</example>" "fundamental")
+ ("<lisp>[ \t]*\n?" "\n?[ \t]*</lisp>" "emacs-lisp")
+ ("<perl>[ \t]*\n?" "\n?[ \t]*</perl>" "perl")
+ ("<python>[ \t]*\n?" "\n?[ \t]*</python>" "python")
+ ("<ruby>[ \t]*\n?" "\n?[ \t]*</ruby>" "ruby")
+ ("^#\\+begin_src\\( \\([^ \t\n]+\\)\\)?.*\n" "\n#\\+end_src" 2)
+ ("^#\\+begin_example.*\n" "\n#\\+end_example" "fundamental")
+ ("^#\\+html:" "\n" "html" single-line)
+ ("^#\\+begin_html.*\n" "\n#\\+end_html" "html")
+ ("^#\\+begin_latex.*\n" "\n#\\+end_latex" "latex")
+ ("^#\\+latex:" "\n" "latex" single-line)
+ ("^#\\+begin_ascii.*\n" "\n#\\+end_ascii" "fundamental")
+ ("^#\\+ascii:" "\n" "ascii" single-line)
+ )))
(pos (point))
re re1 re2 single beg end lang)
(catch 'exit
(cond
((stringp lang) lang)
((integerp lang) (match-string lang))
- ((and (eq lang lang)
+ ((and (eq lang 'lang)
(string-match "\\<lang=\"\\([^ \t\n\"]+\\)\"" m))
(match-string 1 m))
- ((and (eq lang lang)
+ ((and (eq lang 'style)
(string-match "\\<style=\"\\([^ \t\n\"]+\\)\"" m))
(match-string 1 m))
(t "fundamental"))))
(when font-lock-mode
(font-lock-unfontify-region (point-min) (point-max)))
(put-text-property (point-min) (point-max) 'font-lock-fontified t))
+ (when (org-bound-and-true-p org-edit-src-picture)
+ (goto-char (point-min))
+ (while (re-search-forward "^" nil t)
+ (replace-match ": "))
+ (when font-lock-mode
+ (font-lock-unfontify-region (point-min) (point-max)))
+ (put-text-property (point-min) (point-max) 'font-lock-fontified t))
(kill-buffer (current-buffer))
(and (org-mode-p) (org-restart-font-lock)))
-;;;; Plain list items, including checkboxes
-
-;;; Plain list items
-
-(defun org-at-item-p ()
- "Is point in a line starting a hand-formatted item?"
- (let ((llt org-plain-list-ordered-item-terminator))
- (save-excursion
- (goto-char (point-at-bol))
- (looking-at
- (cond
- ((eq llt t) "\\([ \t]*\\([-+]\\|\\([0-9]+[.)]\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)")
- ((= llt ?.) "\\([ \t]*\\([-+]\\|\\([0-9]+\\.\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)")
- ((= llt ?\)) "\\([ \t]*\\([-+]\\|\\([0-9]+))\\)\\|[ \t]+\\*\\)\\( \\|$\\)")
- (t (error "Invalid value of `org-plain-list-ordered-item-terminator'")))))))
-
-(defun org-in-item-p ()
- "It the cursor inside a plain list item.
-Does not have to be the first line."
- (save-excursion
- (condition-case nil
- (progn
- (org-beginning-of-item)
- (org-at-item-p)
- t)
- (error nil))))
-
-(defun org-insert-item (&optional checkbox)
- "Insert a new item at the current level.
-Return t when things worked, nil when we are not in an item."
- (when (save-excursion
- (condition-case nil
- (progn
- (org-beginning-of-item)
- (org-at-item-p)
- (if (org-invisible-p) (error "Invisible item"))
- t)
- (error nil)))
- (let* ((bul (match-string 0))
- (descp (save-excursion (goto-char (match-beginning 0))
- (beginning-of-line 1)
- (save-match-data
- (looking-at "[ \t]*.*? ::"))))
- (eow (save-excursion (beginning-of-line 1) (looking-at "[ \t]*")
- (match-end 0)))
- (blank (cdr (assq 'plain-list-item org-blank-before-new-entry)))
- pos)
- (if descp (setq checkbox nil))
- (cond
- ((and (org-at-item-p) (<= (point) eow))
- ;; before the bullet
- (beginning-of-line 1)
- (open-line (if blank 2 1)))
- ((<= (point) eow)
- (beginning-of-line 1))
- (t
- (unless (org-get-alist-option org-M-RET-may-split-line 'item)
- (end-of-line 1)
- (delete-horizontal-space))
- (newline (if blank 2 1))))
- (insert bul
- (if checkbox "[ ]" "")
- (if descp (concat (if checkbox " " "")
- (read-string "Term: ") " :: ") ""))
- (just-one-space)
- (setq pos (point))
- (end-of-line 1)
- (unless (= (point) pos) (just-one-space) (backward-delete-char 1)))
- (org-maybe-renumber-ordered-list)
- (and checkbox (org-update-checkbox-count-maybe))
- t))
-
-;;; Checkboxes
-
-(defun org-at-item-checkbox-p ()
- "Is point at a line starting a plain-list item with a checklet?"
- (and (org-at-item-p)
- (save-excursion
- (goto-char (match-end 0))
- (skip-chars-forward " \t")
- (looking-at "\\[[- X]\\]"))))
-
-(defun org-toggle-checkbox (&optional arg)
- "Toggle the checkbox in the current line."
- (interactive "P")
- (catch 'exit
- (let (beg end status (firstnew 'unknown))
- (cond
- ((org-region-active-p)
- (setq beg (region-beginning) end (region-end)))
- ((org-on-heading-p)
- (setq beg (point) end (save-excursion (outline-next-heading) (point))))
- ((org-at-item-checkbox-p)
- (let ((pos (point)))
- (replace-match
- (cond (arg "[-]")
- ((member (match-string 0) '("[ ]" "[-]")) "[X]")
- (t "[ ]"))
- t t)
- (goto-char pos))
- (throw 'exit t))
- (t (error "Not at a checkbox or heading, and no active region")))
- (save-excursion
- (goto-char beg)
- (while (< (point) end)
- (when (org-at-item-checkbox-p)
- (setq status (equal (match-string 0) "[X]"))
- (when (eq firstnew 'unknown)
- (setq firstnew (not status)))
- (replace-match
- (if (if arg (not status) firstnew) "[X]" "[ ]") t t))
- (beginning-of-line 2)))))
- (org-update-checkbox-count-maybe))
-
-(defun org-update-checkbox-count-maybe ()
- "Update checkbox statistics unless turned off by user."
- (when org-provide-checkbox-statistics
- (org-update-checkbox-count)))
-
-(defun org-update-checkbox-count (&optional all)
- "Update the checkbox statistics in the current section.
-This will find all statistic cookies like [57%] and [6/12] and update them
-with the current numbers. With optional prefix argument ALL, do this for
-the whole buffer."
- (interactive "P")
- (save-excursion
- (let* ((buffer-invisibility-spec (org-inhibit-invisibility)) ; Emacs 21
- (beg (condition-case nil
- (progn (outline-back-to-heading) (point))
- (error (point-min))))
- (end (move-marker (make-marker)
- (progn (outline-next-heading) (point))))
- (re "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)")
- (re-box "^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[- X]\\]\\)")
- (re-find (concat re "\\|" re-box))
- beg-cookie end-cookie is-percent c-on c-off lim
- eline curr-ind next-ind continue-from startsearch
- (cstat 0)
- )
- (when all
- (goto-char (point-min))
- (outline-next-heading)
- (setq beg (point) end (point-max)))
- (goto-char end)
- ;; find each statistic cookie
- (while (re-search-backward re-find beg t)
- (setq beg-cookie (match-beginning 1)
- end-cookie (match-end 1)
- cstat (+ cstat (if end-cookie 1 0))
- startsearch (point-at-eol)
- continue-from (point-at-bol)
- is-percent (match-beginning 2)
- lim (cond
- ((org-on-heading-p) (outline-next-heading) (point))
- ((org-at-item-p) (org-end-of-item) (point))
- (t nil))
- c-on 0
- c-off 0)
- (when lim
- ;; find first checkbox for this cookie and gather
- ;; statistics from all that are at this indentation level
- (goto-char startsearch)
- (if (re-search-forward re-box lim t)
- (progn
- (org-beginning-of-item)
- (setq curr-ind (org-get-indentation))
- (setq next-ind curr-ind)
- (while (and (bolp) (org-at-item-p) (= curr-ind next-ind))
- (save-excursion (end-of-line) (setq eline (point)))
- (if (re-search-forward re-box eline t)
- (if (member (match-string 2) '("[ ]" "[-]"))
- (setq c-off (1+ c-off))
- (setq c-on (1+ c-on))
- )
- )
- (org-end-of-item)
- (setq next-ind (org-get-indentation))
- )))
- (goto-char continue-from)
- ;; update cookie
- (when end-cookie
- (delete-region beg-cookie end-cookie)
- (goto-char beg-cookie)
- (insert
- (if is-percent
- (format "[%d%%]" (/ (* 100 c-on) (max 1 (+ c-on c-off))))
- (format "[%d/%d]" c-on (+ c-on c-off)))))
- ;; update items checkbox if it has one
- (when (org-at-item-p)
- (org-beginning-of-item)
- (when (and (> (+ c-on c-off) 0)
- (re-search-forward re-box (point-at-eol) t))
- (setq beg-cookie (match-beginning 2)
- end-cookie (match-end 2))
- (delete-region beg-cookie end-cookie)
- (goto-char beg-cookie)
- (cond ((= c-off 0) (insert "[X]"))
- ((= c-on 0) (insert "[ ]"))
- (t (insert "[-]")))
- )))
- (goto-char continue-from))
- (when (interactive-p)
- (message "Checkbox satistics updated %s (%d places)"
- (if all "in entire file" "in current outline entry") cstat)))))
-
-(defun org-get-checkbox-statistics-face ()
- "Select the face for checkbox statistics.
-The face will be `org-done' when all relevant boxes are checked. Otherwise
-it will be `org-todo'."
- (if (match-end 1)
- (if (equal (match-string 1) "100%") 'org-done 'org-todo)
- (if (and (> (match-end 2) (match-beginning 2))
- (equal (match-string 2) (match-string 3)))
- 'org-done
- 'org-todo)))
-
-(defun org-get-indentation (&optional line)
- "Get the indentation of the current line, interpreting tabs.
-When LINE is given, assume it represents a line and compute its indentation."
- (if line
- (if (string-match "^ *" (org-remove-tabs line))
- (match-end 0))
- (save-excursion
- (beginning-of-line 1)
- (skip-chars-forward " \t")
- (current-column))))
-
-(defun org-remove-tabs (s &optional width)
- "Replace tabulators in S with spaces.
-Assumes that s is a single line, starting in column 0."
- (setq width (or width tab-width))
- (while (string-match "\t" s)
- (setq s (replace-match
- (make-string
- (- (* width (/ (+ (match-beginning 0) width) width))
- (match-beginning 0)) ?\ )
- t t s)))
- s)
-
-(defun org-fix-indentation (line ind)
- "Fix indentation in LINE.
-IND is a cons cell with target and minimum indentation.
-If the current indenation in LINE is smaller than the minimum,
-leave it alone. If it is larger than ind, set it to the target."
- (let* ((l (org-remove-tabs line))
- (i (org-get-indentation l))
- (i1 (car ind)) (i2 (cdr ind)))
- (if (>= i i2) (setq l (substring line i2)))
- (if (> i1 0)
- (concat (make-string i1 ?\ ) l)
- l)))
-
-(defun org-beginning-of-item ()
- "Go to the beginning of the current hand-formatted item.
-If the cursor is not in an item, throw an error."
- (interactive)
- (let ((pos (point))
- (limit (save-excursion
- (condition-case nil
- (progn
- (org-back-to-heading)
- (beginning-of-line 2) (point))
- (error (point-min)))))
- (ind-empty (if org-empty-line-terminates-plain-lists 0 10000))
- ind ind1)
- (if (org-at-item-p)
- (beginning-of-line 1)
- (beginning-of-line 1)
- (skip-chars-forward " \t")
- (setq ind (current-column))
- (if (catch 'exit
- (while t
- (beginning-of-line 0)
- (if (or (bobp) (< (point) limit)) (throw 'exit nil))
-
- (if (looking-at "[ \t]*$")
- (setq ind1 ind-empty)
- (skip-chars-forward " \t")
- (setq ind1 (current-column)))
- (if (< ind1 ind)
- (progn (beginning-of-line 1) (throw 'exit (org-at-item-p))))))
- nil
- (goto-char pos)
- (error "Not in an item")))))
-
-(defun org-end-of-item ()
- "Go to the end of the current hand-formatted item.
-If the cursor is not in an item, throw an error."
- (interactive)
- (let* ((pos (point))
- ind1
- (ind-empty (if org-empty-line-terminates-plain-lists 0 10000))
- (limit (save-excursion (outline-next-heading) (point)))
- (ind (save-excursion
- (org-beginning-of-item)
- (skip-chars-forward " \t")
- (current-column)))
- (end (catch 'exit
- (while t
- (beginning-of-line 2)
- (if (eobp) (throw 'exit (point)))
- (if (>= (point) limit) (throw 'exit (point-at-bol)))
- (if (looking-at "[ \t]*$")
- (setq ind1 ind-empty)
- (skip-chars-forward " \t")
- (setq ind1 (current-column)))
- (if (<= ind1 ind)
- (throw 'exit (point-at-bol)))))))
- (if end
- (goto-char end)
- (goto-char pos)
- (error "Not in an item"))))
-
-(defun org-next-item ()
- "Move to the beginning of the next item in the current plain list.
-Error if not at a plain list, or if this is the last item in the list."
- (interactive)
- (let (ind ind1 (pos (point)))
- (org-beginning-of-item)
- (setq ind (org-get-indentation))
- (org-end-of-item)
- (setq ind1 (org-get-indentation))
- (unless (and (org-at-item-p) (= ind ind1))
- (goto-char pos)
- (error "On last item"))))
-
-(defun org-previous-item ()
- "Move to the beginning of the previous item in the current plain list.
-Error if not at a plain list, or if this is the first item in the list."
- (interactive)
- (let (beg ind ind1 (pos (point)))
- (org-beginning-of-item)
- (setq beg (point))
- (setq ind (org-get-indentation))
- (goto-char beg)
- (catch 'exit
- (while t
- (beginning-of-line 0)
- (if (looking-at "[ \t]*$")
- nil
- (if (<= (setq ind1 (org-get-indentation)) ind)
- (throw 'exit t)))))
- (condition-case nil
- (if (or (not (org-at-item-p))
- (< ind1 (1- ind)))
- (error "")
- (org-beginning-of-item))
- (error (goto-char pos)
- (error "On first item")))))
-
-(defun org-first-list-item-p ()
- "Is this heading the item in a plain list?"
- (unless (org-at-item-p)
- (error "Not at a plain list item"))
- (org-beginning-of-item)
- (= (point) (save-excursion (org-beginning-of-item-list))))
-
-(defun org-move-item-down ()
- "Move the plain list item at point down, i.e. swap with following item.
-Subitems (items with larger indentation) are considered part of the item,
-so this really moves item trees."
- (interactive)
- (let (beg beg0 end end0 ind ind1 (pos (point)) txt ne-end ne-beg)
- (org-beginning-of-item)
- (setq beg0 (point))
- (save-excursion
- (setq ne-beg (org-back-over-empty-lines))
- (setq beg (point)))
- (goto-char beg0)
- (setq ind (org-get-indentation))
- (org-end-of-item)
- (setq end0 (point))
- (setq ind1 (org-get-indentation))
- (setq ne-end (org-back-over-empty-lines))
- (setq end (point))
- (goto-char beg0)
- (when (and (org-first-list-item-p) (< ne-end ne-beg))
- ;; include less whitespace
- (save-excursion
- (goto-char beg)
- (forward-line (- ne-beg ne-end))
- (setq beg (point))))
- (goto-char end0)
- (if (and (org-at-item-p) (= ind ind1))
- (progn
- (org-end-of-item)
- (org-back-over-empty-lines)
- (setq txt (buffer-substring beg end))
- (save-excursion
- (delete-region beg end))
- (setq pos (point))
- (insert txt)
- (goto-char pos) (org-skip-whitespace)
- (org-maybe-renumber-ordered-list))
- (goto-char pos)
- (error "Cannot move this item further down"))))
-
-(defun org-move-item-up (arg)
- "Move the plain list item at point up, i.e. swap with previous item.
-Subitems (items with larger indentation) are considered part of the item,
-so this really moves item trees."
- (interactive "p")
- (let (beg beg0 end ind ind1 (pos (point)) txt
- ne-beg ne-ins ins-end)
- (org-beginning-of-item)
- (setq beg0 (point))
- (setq ind (org-get-indentation))
- (save-excursion
- (setq ne-beg (org-back-over-empty-lines))
- (setq beg (point)))
- (goto-char beg0)
- (org-end-of-item)
- (org-back-over-empty-lines)
- (setq end (point))
- (goto-char beg0)
- (catch 'exit
- (while t
- (beginning-of-line 0)
- (if (looking-at "[ \t]*$")
- (if org-empty-line-terminates-plain-lists
- (progn
- (goto-char pos)
- (error "Cannot move this item further up"))
- nil)
- (if (<= (setq ind1 (org-get-indentation)) ind)
- (throw 'exit t)))))
- (condition-case nil
- (org-beginning-of-item)
- (error (goto-char beg0)
- (error "Cannot move this item further up")))
- (setq ind1 (org-get-indentation))
- (if (and (org-at-item-p) (= ind ind1))
- (progn
- (setq ne-ins (org-back-over-empty-lines))
- (setq txt (buffer-substring beg end))
- (save-excursion
- (delete-region beg end))
- (setq pos (point))
- (insert txt)
- (setq ins-end (point))
- (goto-char pos) (org-skip-whitespace)
-
- (when (and (org-first-list-item-p) (> ne-ins ne-beg))
- ;; Move whitespace back to beginning
- (save-excursion
- (goto-char ins-end)
- (let ((kill-whole-line t))
- (kill-line (- ne-ins ne-beg)) (point)))
- (insert (make-string (- ne-ins ne-beg) ?\n)))
-
- (org-maybe-renumber-ordered-list))
- (goto-char pos)
- (error "Cannot move this item further up"))))
-
-(defun org-maybe-renumber-ordered-list ()
- "Renumber the ordered list at point if setup allows it.
-This tests the user option `org-auto-renumber-ordered-lists' before
-doing the renumbering."
- (interactive)
- (when (and org-auto-renumber-ordered-lists
- (org-at-item-p))
- (if (match-beginning 3)
- (org-renumber-ordered-list 1)
- (org-fix-bullet-type))))
-
-(defun org-maybe-renumber-ordered-list-safe ()
- (condition-case nil
- (save-excursion
- (org-maybe-renumber-ordered-list))
- (error nil)))
-
-(defun org-cycle-list-bullet (&optional which)
- "Cycle through the different itemize/enumerate bullets.
-This cycle the entire list level through the sequence:
-
- `-' -> `+' -> `*' -> `1.' -> `1)'
-
-If WHICH is a string, use that as the new bullet. If WHICH is an integer,
-0 meand `-', 1 means `+' etc."
- (interactive "P")
- (org-preserve-lc
- (org-beginning-of-item-list)
- (org-at-item-p)
- (beginning-of-line 1)
- (let ((current (match-string 0))
- (prevp (eq which 'previous))
- new)
- (setq new (cond
- ((and (numberp which)
- (nth (1- which) '("-" "+" "*" "1." "1)"))))
- ((string-match "-" current) (if prevp "1)" "+"))
- ((string-match "\\+" current)
- (if prevp "-" (if (looking-at "\\S-") "1." "*")))
- ((string-match "\\*" current) (if prevp "+" "1."))
- ((string-match "\\." current) (if prevp "*" "1)"))
- ((string-match ")" current) (if prevp "1." "-"))
- (t (error "This should not happen"))))
- (and (looking-at "\\([ \t]*\\)\\S-+") (replace-match (concat "\\1" new)))
- (org-fix-bullet-type)
- (org-maybe-renumber-ordered-list))))
-
-(defun org-get-string-indentation (s)
- "What indentation has S due to SPACE and TAB at the beginning of the string?"
- (let ((n -1) (i 0) (w tab-width) c)
- (catch 'exit
- (while (< (setq n (1+ n)) (length s))
- (setq c (aref s n))
- (cond ((= c ?\ ) (setq i (1+ i)))
- ((= c ?\t) (setq i (* (/ (+ w i) w) w)))
- (t (throw 'exit t)))))
- i))
-
-(defun org-renumber-ordered-list (arg)
- "Renumber an ordered plain list.
-Cursor needs to be in the first line of an item, the line that starts
-with something like \"1.\" or \"2)\"."
- (interactive "p")
- (unless (and (org-at-item-p)
- (match-beginning 3))
- (error "This is not an ordered list"))
- (let ((line (org-current-line))
- (col (current-column))
- (ind (org-get-string-indentation
- (buffer-substring (point-at-bol) (match-beginning 3))))
- ;; (term (substring (match-string 3) -1))
- ind1 (n (1- arg))
- fmt bobp)
- ;; find where this list begins
- (org-beginning-of-item-list)
- (setq bobp (bobp))
- (looking-at "[ \t]*[0-9]+\\([.)]\\)")
- (setq fmt (concat "%d" (match-string 1)))
- (beginning-of-line 0)
- ;; walk forward and replace these numbers
- (catch 'exit
- (while t
- (catch 'next
- (if bobp (setq bobp nil) (beginning-of-line 2))
- (if (eobp) (throw 'exit nil))
- (if (looking-at "[ \t]*$") (throw 'next nil))
- (skip-chars-forward " \t") (setq ind1 (current-column))
- (if (> ind1 ind) (throw 'next t))
- (if (< ind1 ind) (throw 'exit t))
- (if (not (org-at-item-p)) (throw 'exit nil))
- (delete-region (match-beginning 2) (match-end 2))
- (goto-char (match-beginning 2))
- (insert (format fmt (setq n (1+ n)))))))
- (goto-line line)
- (org-move-to-column col)))
-
-(defun org-fix-bullet-type ()
- "Make sure all items in this list have the same bullet as the firsst item."
- (interactive)
- (unless (org-at-item-p) (error "This is not a list"))
- (let ((line (org-current-line))
- (col (current-column))
- (ind (current-indentation))
- ind1 bullet)
- ;; find where this list begins
- (org-beginning-of-item-list)
- (beginning-of-line 1)
- ;; find out what the bullet type is
- (looking-at "[ \t]*\\(\\S-+\\)")
- (setq bullet (match-string 1))
- ;; walk forward and replace these numbers
- (beginning-of-line 0)
- (catch 'exit
- (while t
- (catch 'next
- (beginning-of-line 2)
- (if (eobp) (throw 'exit nil))
- (if (looking-at "[ \t]*$") (throw 'next nil))
- (skip-chars-forward " \t") (setq ind1 (current-column))
- (if (> ind1 ind) (throw 'next t))
- (if (< ind1 ind) (throw 'exit t))
- (if (not (org-at-item-p)) (throw 'exit nil))
- (skip-chars-forward " \t")
- (looking-at "\\S-+")
- (replace-match bullet))))
- (goto-line line)
- (org-move-to-column col)
- (if (string-match "[0-9]" bullet)
- (org-renumber-ordered-list 1))))
-
-(defun org-beginning-of-item-list ()
- "Go to the beginning of the current item list.
-I.e. to the first item in this list."
- (interactive)
- (org-beginning-of-item)
- (let ((pos (point-at-bol))
- (ind (org-get-indentation))
- ind1)
- ;; find where this list begins
- (catch 'exit
- (while t
- (catch 'next
- (beginning-of-line 0)
- (if (looking-at "[ \t]*$")
- (throw (if (bobp) 'exit 'next) t))
- (skip-chars-forward " \t") (setq ind1 (current-column))
- (if (or (< ind1 ind)
- (and (= ind1 ind)
- (not (org-at-item-p)))
- (and (= (point-at-bol) (point-min))
- (setq pos (point-min))))
- (throw 'exit t)
- (when (org-at-item-p) (setq pos (point-at-bol)))))))
- (goto-char pos)))
-
-
-(defun org-end-of-item-list ()
- "Go to the end of the current item list.
-I.e. to the text after the last item."
- (interactive)
- (org-beginning-of-item)
- (let ((pos (point-at-bol))
- (ind (org-get-indentation))
- ind1)
- ;; find where this list begins
- (catch 'exit
- (while t
- (catch 'next
- (beginning-of-line 2)
- (if (looking-at "[ \t]*$")
- (throw (if (eobp) 'exit 'next) t))
- (skip-chars-forward " \t") (setq ind1 (current-column))
- (if (or (< ind1 ind)
- (and (= ind1 ind)
- (not (org-at-item-p)))
- (eobp))
- (progn
- (setq pos (point-at-bol))
- (throw 'exit t))))))
- (goto-char pos)))
-
-
-(defvar org-last-indent-begin-marker (make-marker))
-(defvar org-last-indent-end-marker (make-marker))
-
-(defun org-outdent-item (arg)
- "Outdent a local list item."
- (interactive "p")
- (org-indent-item (- arg)))
-
-(defun org-indent-item (arg)
- "Indent a local list item."
- (interactive "p")
- (unless (org-at-item-p)
- (error "Not on an item"))
- (save-excursion
- (let (beg end ind ind1 tmp delta ind-down ind-up)
- (if (memq last-command '(org-shiftmetaright org-shiftmetaleft))
- (setq beg org-last-indent-begin-marker
- end org-last-indent-end-marker)
- (org-beginning-of-item)
- (setq beg (move-marker org-last-indent-begin-marker (point)))
- (org-end-of-item)
- (setq end (move-marker org-last-indent-end-marker (point))))
- (goto-char beg)
- (setq tmp (org-item-indent-positions)
- ind (car tmp)
- ind-down (nth 2 tmp)
- ind-up (nth 1 tmp)
- delta (if (> arg 0)
- (if ind-down (- ind-down ind) 2)
- (if ind-up (- ind-up ind) -2)))
- (if (< (+ delta ind) 0) (error "Cannot outdent beyond margin"))
- (while (< (point) end)
- (beginning-of-line 1)
- (skip-chars-forward " \t") (setq ind1 (current-column))
- (delete-region (point-at-bol) (point))
- (or (eolp) (org-indent-to-column (+ ind1 delta)))
- (beginning-of-line 2))))
- (org-fix-bullet-type)
- (org-maybe-renumber-ordered-list-safe)
- (save-excursion
- (beginning-of-line 0)
- (condition-case nil (org-beginning-of-item) (error nil))
- (org-maybe-renumber-ordered-list-safe)))
-
-(defun org-item-indent-positions ()
- "Return indentation for plain list items.
-This returns a list with three values: The current indentation, the
-parent indentation and the indentation a child should habe.
-Assumes cursor in item line."
- (let* ((bolpos (point-at-bol))
- (ind (org-get-indentation))
- ind-down ind-up pos)
- (save-excursion
- (org-beginning-of-item-list)
- (skip-chars-backward "\n\r \t")
- (when (org-in-item-p)
- (org-beginning-of-item)
- (setq ind-up (org-get-indentation))))
- (setq pos (point))
- (save-excursion
- (cond
- ((and (condition-case nil (progn (org-previous-item) t)
- (error nil))
- (or (forward-char 1) t)
- (re-search-forward "^\\([ \t]*\\([-+]\\|\\([0-9]+[.)]\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)" bolpos t))
- (setq ind-down (org-get-indentation)))
- ((and (goto-char pos)
- (org-at-item-p))
- (goto-char (match-end 0))
- (skip-chars-forward " \t")
- (setq ind-down (current-column)))))
- (list ind ind-up ind-down)))
;;; The orgstruct minor mode
'('orgstruct-error))))))))
(defun org-context-p (&rest contexts)
- "Check if local context is and of CONTEXTS.
+ "Check if local context is any of CONTEXTS.
Possible values in the list of contexts are `table', `headline', and `item'."
(let ((pos (point)))
(goto-char (point-at-bol))
(prog1 (or (and (memq 'table contexts)
(looking-at "[ \t]*|"))
(and (memq 'headline contexts)
- (looking-at "\\*+"))
+;;????????? (looking-at "\\*+"))
+ (looking-at outline-regexp))
(and (memq 'item contexts)
(looking-at "[ \t]*\\([-+*] \\|[0-9]+[.)] \\)")))
(goto-char pos))))
(defun org-extract-attributes (s)
"Extract the attributes cookie from a string and set as text property."
- (let (a attr key value (start 0))
+ (let (a attr (start 0) key value)
(save-match-data
(when (string-match "{{\\([^}]+\\)}}$" s)
(setq a (match-string 1 s) s (substring s 0 (match-beginning 0)))
(file (if (and dirp org-open-directory-means-index-dot-org)
(concat (file-name-as-directory file) "index.org")
file))
+ (a-m-a-p (assq 'auto-mode apps))
(dfile (downcase file))
(old-buffer (current-buffer))
(old-pos (point))
(setq cmd 'emacs)
(setq cmd (or (and remp (cdr (assoc 'remote apps)))
(and dirp (cdr (assoc 'directory apps)))
+ (assoc-default dfile (org-apps-regexp-alist apps a-m-a-p)
+ 'string-match)
(cdr (assoc ext apps))
(cdr (assoc t apps)))))
+ (when (eq cmd 'default)
+ (setq cmd (cdr (assoc t apps))))
(when (eq cmd 'mailcap)
(require 'mailcap)
(mailcap-parse-mailcaps)
org-file-apps-defaults-windowsnt)
(t org-file-apps-defaults-gnu)))
+(defun org-apps-regexp-alist (list &optional add-auto-mode)
+ "Convert extensions to regular expressions in the cars of LIST.
+Also, weed out any non-string entries, because the return value is used
+only for regexp matching.
+When ADD-AUTO-MODE is set, make all matches in `auto-mode-alist'
+point to the symbol `emacs', indicating that the file should
+be opened in Emacs."
+ (append
+ (delq nil
+ (mapcar (lambda (x)
+ (if (not (stringp (car x)))
+ nil
+ (if (string-match "\\W" (car x))
+ x
+ (cons (concat "\\." (car x) "\\'") (cdr x)))))
+ list))
+ (if add-auto-mode
+ (mapcar (lambda (x) (cons (car x) 'emacs)) auto-mode-alist))))
+
(defvar ange-ftp-name-format) ; to silence the XEmacs compiler.
(defun org-file-remote-p (file)
"Test whether FILE specifies a location on a remote system.
(while (re-search-forward descre nil t)
(goto-char (point-at-bol))
(when (looking-at org-complex-heading-regexp)
- (setq txt (match-string 4)
+ (setq txt (org-link-display-format (match-string 4))
re (concat "^" (regexp-quote
(buffer-substring (match-beginning 1)
(match-end 4)))))
(match-string 5)))))
(setq re (concat re "[ \t]*$"))
(when org-refile-use-outline-path
- (setq txt (mapconcat 'identity
+ (setq txt (mapconcat 'org-protect-slash
(append
(if (eq org-refile-use-outline-path 'file)
(list (file-name-nondirectory
(goto-char (point-at-eol))))))))
(nreverse targets))))
+(defun org-protect-slash (s)
+ (while (string-match "/" s)
+ (setq s (replace-match "\\" t t s)))
+ s)
+
(defun org-get-outline-path ()
"Return the outline path to the current entry, as a list."
(let (rtn)
With prefix arg GOTO, the command will only visit the target location,
not actually move anything.
-With a double prefix `C-c C-c', go to the location where the last refiling
+With a double prefix `C-u C-u', go to the location where the last refiling
operation has put the subtree."
(interactive "P")
(let* ((cbuf (current-buffer))
(setq level (org-get-valid-level (funcall outline-level) 1))
(goto-char
(if reversed
- (outline-next-heading)
+ (or (outline-next-heading) (point-max))
(or (save-excursion (outline-get-next-sibling))
(org-end-of-subtree t t)
(point-max))))
+ (if (not (bolp)) (newline))
(bookmark-set "org-refile-last-stored")
(org-paste-subtree level))))
(org-cut-subtree)
(defconst org-additional-option-like-keywords
'("BEGIN_HTML" "BEGIN_LaTeX" "END_HTML" "END_LaTeX"
"ORGTBL" "HTML:" "LaTeX:" "BEGIN:" "END:" "TBLFM"
- "BEGIN_EXAMPLE" "END_EXAMPLE"))
+ "BEGIN_EXAMPLE" "END_EXAMPLE"
+ "BEGIN_QUOTE" "END_QUOTE"
+ "BEGIN_VERSE" "END_VERSE"
+ "BEGIN_SRC" "END_SRC"))
(defcustom org-structure-template-alist
'(
(and (member kwd org-done-keywords)
(setq cnt-done (1+ cnt-done)))
(condition-case nil
- (outline-forward-same-level 1)
+ (org-forward-same-level 1)
(error (end-of-line 1)))))
(replace-match
(if is-percent
(defvar org-log-post-message)
(defvar org-log-note-purpose)
(defvar org-log-note-how)
+(defvar org-log-note-extra)
(defun org-auto-repeat-maybe (done-word)
"Check if the current headline contains a repeated deadline/schedule.
If yes, set TODO state back to what it was and change the base date
(setq ts (match-string 1))
(string-match "\\([.+]\\)?\\(\\+[0-9]+\\)\\([dwmy]\\)" ts))))
(org-timestamp-change n (cdr (assoc what whata)))
- (setq msg (concat msg type org-last-changed-timestamp " "))))
+ (setq msg (concat msg type " " org-last-changed-timestamp " "))))
(setq org-log-post-message msg)
(message "%s" msg))))
(defvar org-log-note-purpose nil)
(defvar org-log-note-state nil)
(defvar org-log-note-how nil)
+(defvar org-log-note-extra nil)
(defvar org-log-note-window-configuration nil)
(defvar org-log-note-return-to (make-marker))
(defvar org-log-post-message nil
"Add a note to the current entry.
This is done in the same way as adding a state change note."
(interactive)
- (org-add-log-setup 'note nil t nil))
+ (org-add-log-setup 'note nil 'findpos nil))
-(defun org-add-log-setup (&optional purpose state findpos how)
+(defvar org-property-end-re)
+(defun org-add-log-setup (&optional purpose state findpos how &optional extra)
"Set up the post command hook to take a note.
If this is about to TODO state change, the new state is expected in STATE.
When FINDPOS is non-nil, find the correct position for the note in
-the current entry. If not, assume that it can be inserted at point."
- (save-excursion
- (when findpos
- (org-back-to-heading t)
- (looking-at (concat outline-regexp "\\( *\\)[^\r\n]*"
- "\\(\n[^\r\n]*?" org-keyword-time-not-clock-regexp
- "[^\r\n]*\\)?"))
- (goto-char (match-end 0))
- (unless org-log-states-order-reversed
- (and (= (char-after) ?\n) (forward-char 1))
- (org-skip-over-state-notes)
- (skip-chars-backward " \t\n\r")))
- (move-marker org-log-note-marker (point))
- (setq org-log-note-purpose purpose
- org-log-note-state state
- org-log-note-how how)
- (add-hook 'post-command-hook 'org-add-log-note 'append)))
+the current entry. If not, assume that it can be inserted at point.
+HOW is an indicator what kind of note should be created.
+EXTRA is additional text that will be inserted into the notes buffer."
+ (save-restriction
+ (save-excursion
+ (when findpos
+ (org-back-to-heading t)
+ (narrow-to-region (point) (save-excursion
+ (outline-next-heading) (point)))
+ (while (re-search-forward
+ (concat "\\(" org-drawer-regexp "\\|" org-property-end-re "\\)")
+ (point-max) t) (forward-line))
+ (looking-at (concat outline-regexp "\\( *\\)[^\r\n]*"
+ "\\(\n[^\r\n]*?" org-keyword-time-not-clock-regexp
+ "[^\r\n]*\\)?"))
+ (goto-char (match-end 0))
+ (unless org-log-states-order-reversed
+ (and (= (char-after) ?\n) (forward-char 1))
+ (org-skip-over-state-notes)
+ (skip-chars-backward " \t\n\r")))
+ (move-marker org-log-note-marker (point))
+ (setq org-log-note-purpose purpose
+ org-log-note-state state
+ org-log-note-how how
+ org-log-note-extra extra)
+ (add-hook 'post-command-hook 'org-add-log-note 'append))))
(defun org-skip-over-state-notes ()
"Skip past the list of State notes in an entry."
((eq org-log-note-purpose 'note)
"this entry")
(t (error "This should not happen")))))
+ (if org-log-note-extra (insert org-log-note-extra))
(org-set-local 'org-finish-function 'org-store-log-note)))
(defvar org-note-abort nil) ; dynamically scoped
(tags-alist (list (cons 0 (mapcar 'downcase org-file-tags))))
(llast 0) rtn rtn1 level category i txt
todo marker entry priority)
- (when (not (member action '(agenda sparse-tree)))
+ (when (not (or (member action '(agenda sparse-tree)) (functionp action)))
(setq action (list 'lambda nil action)))
(save-excursion
(goto-char (point-min))
(setcdr (car tags-alist)
(org-remove-uniherited-tags (cdar tags-alist))))
(when (and (or (not todo-only) (member todo org-not-done-keywords))
- (eval matcher)
+ (let ((case-fold-search t)) (eval matcher))
(or
(not (member org-archive-tag tags-list))
;; we have an archive tag, should we use this anyway?
(lambda (x) (if (string-match org-use-tag-inheritance x) x nil))
tags)))
((listp org-use-tag-inheritance)
- (org-delete-all org-use-tag-inheritance tags))))
+ (delq nil (mapcar
+ (lambda (x) (if (member x org-use-tag-inheritance) x nil))
+ tags)))))
(defvar todo-only) ;; dynamically scoped
(re (org-re "^&?\\([-+:]\\)?\\({[^}]+}\\|LEVEL\\([<=>]\\{1,2\\}\\)\\([0-9]+\\)\\|\\([[:alnum:]_]+\\)\\([<>=]\\{1,2\\}\\)\\({[^}]+}\\|\"[^\"]*\"\\|-?[.0-9]+\\(?:[eE][-+]?[0-9]+\\)?\\)\\|[[:alnum:]_@]+\\)"))
minus tag mm
tagsmatch todomatch tagsmatcher todomatcher kwd matcher
- orterms term orlist re-p str-p level-p level-op
- prop-p pn pv po cat-p gv time-p)
+ orterms term orlist re-p str-p level-p level-op time-p
+ prop-p pn pv po cat-p gv)
(if (string-match "/+" match)
;; match contains also a todo-matching request
(progn
(defvar org-tags-overlay (org-make-overlay 1 1))
(org-detach-overlay org-tags-overlay)
-(defun org-get-tags-at (&optional pos)
+(defun org-get-local-tags-at (&optional pos)
+ "Get a list of tags defined in the current headline."
+ (org-get-tags-at pos 'local))
+
+(defun org-get-local-tags ()
+ "Get a list of tags defined in the current headline."
+ (org-get-tags-at nil 'local))
+
+(defun org-get-tags-at (&optional pos local)
"Get a list of all headline tags applicable at POS.
POS defaults to point. If tags are inherited, the list contains
the targets in the same sequence as the headlines appear, i.e.
-the tags of the current headline come last."
+the tags of the current headline come last.
+When LOCAL is non-nil, only return tags from the current headline,
+ignore inherited ones."
(interactive)
(let (tags ltags lastpos parent)
(save-excursion
(widen)
(goto-char (or pos (point)))
(save-match-data
- (condition-case nil
- (progn
- (org-back-to-heading t)
- (while (not (equal lastpos (point)))
- (setq lastpos (point))
- (when (looking-at (org-re "[^\r\n]+?:\\([[:alnum:]_@:]+\\):[ \t]*$"))
- (setq ltags (org-split-string
- (org-match-string-no-properties 1) ":"))
- (setq tags (append (org-remove-uniherited-tags ltags)
- tags)))
- (or org-use-tag-inheritance (error ""))
- (org-up-heading-all 1)
- (setq parent t)))
- (error nil))))
+ (catch 'done
+ (condition-case nil
+ (progn
+ (org-back-to-heading t)
+ (while (not (equal lastpos (point)))
+ (setq lastpos (point))
+ (when (looking-at (org-re "[^\r\n]+?:\\([[:alnum:]_@:]+\\):[ \t]*$"))
+ (setq ltags (org-split-string
+ (org-match-string-no-properties 1) ":"))
+ (setq tags (append
+ (if parent
+ (org-remove-uniherited-tags ltags)
+ ltags)
+ tags)))
+ (or org-use-tag-inheritance (throw 'done t))
+ (if local (throw 'done t))
+ (org-up-heading-all 1)
+ (setq parent t)))
+ (error nil)))))
(append (org-remove-uniherited-tags org-file-tags) tags))))
(defun org-toggle-tag (tag &optional onoff)
(org-agenda-skip-function
(car (org-delete-all '(comment archive) skip)))
(org-tags-match-list-sublevels t)
- matcher pos file)
+ matcher pos file
+ org-todo-keywords-for-agenda
+ org-done-keywords-for-agenda
+ org-todo-keyword-alist-for-agenda
+ org-tag-alist-for-agenda)
(cond
((eq match t) (setq matcher t))
"Add VALUE to the words in the PROPERTY in entry at point-or-marker POM."
(let* ((old (org-entry-get pom property))
(values (and old (org-split-string old "[ \t]"))))
+ (setq value (org-entry-protect-space value))
(unless (member value values)
(setq values (cons value values))
(org-entry-put pom property
"Remove VALUE from words in the PROPERTY in entry at point-or-marker POM."
(let* ((old (org-entry-get pom property))
(values (and old (org-split-string old "[ \t]"))))
+ (setq value (org-entry-protect-space value))
(when (member value values)
(setq values (delete value values))
(org-entry-put pom property
"Is VALUE one of the words in the PROPERTY in entry at point-or-marker POM?"
(let* ((old (org-entry-get pom property))
(values (and old (org-split-string old "[ \t]"))))
+ (setq value (org-entry-protect-space value))
(member value values)))
-(defvar org-entry-property-inherited-from (make-marker))
+(defun org-entry-get-multivalued-property (pom property)
+ "Return a list of values in a multivalued property."
+ (let* ((value (org-entry-get pom property))
+ (values (and value (org-split-string value "[ \t]"))))
+ (mapcar 'org-entry-restore-space values)))
+
+(defun org-entry-put-multivalued-property (pom property &rest values)
+ "Set multivalued PROPERTY at point-or-marker POM to VALUES.
+VALUES should be a list of strings. Spaces will be protected."
+ (org-entry-put pom property
+ (mapconcat 'org-entry-protect-space values " "))
+ (let* ((value (org-entry-get pom property))
+ (values (and value (org-split-string value "[ \t]"))))
+ (mapcar 'org-entry-restore-space values)))
+
+(defun org-entry-protect-space (s)
+ "Protect spaces and newline in string S."
+ (while (string-match " " s)
+ (setq s (replace-match "%20" t t s)))
+ (while (string-match "\n" s)
+ (setq s (replace-match "%0A" t t s)))
+ s)
+
+(defun org-entry-restore-space (s)
+ "Restore spaces and newline in string S."
+ (while (string-match "%20" s)
+ (setq s (replace-match " " t t s)))
+ (while (string-match "%0A" s)
+ (setq s (replace-match "\n" t t s)))
+ s)
+
+(defvar org-entry-property-inherited-from (make-marker)
+ "Marker pointing to the entry from where a proerty was inherited.
+Each call to `org-entry-get-with-inheritance' will set this marker to the
+location of the entry where the inheriance search matched. If there was
+no match, the marker will point nowhere.
+Note that also `org-entry-get' calls this function, if the INHERIT flag
+is set.")
(defun org-entry-get-with-inheritance (property)
"Get entry property, and search higher levels if not present."
+ (move-marker org-entry-property-inherited-from nil)
(let (tmp)
(save-excursion
(save-restriction
(defvar org-end-time-was-given) ; dynamically scoped parameter
(defvar org-ts-what) ; dynamically scoped parameter
-(defun org-time-stamp (arg)
+(defun org-time-stamp (arg &optional inactive)
"Prompt for a date/time and insert a time stamp.
If the user specifies a time like HH:MM, or if this command is called
with a prefix argument, the time stamp will contain date and time.
(default-input (and ts (org-get-compact-tod ts)))
org-time-was-given org-end-time-was-given time)
(cond
- ((and (org-at-timestamp-p)
- (eq last-command 'org-time-stamp)
- (eq this-command 'org-time-stamp))
+ ((and (org-at-timestamp-p t)
+ (memq last-command '(org-time-stamp org-time-stamp-inactive))
+ (memq this-command '(org-time-stamp org-time-stamp-inactive)))
(insert "--")
(setq time (let ((this-command this-command))
- (org-read-date arg 'totime nil nil default-time default-input)))
- (org-insert-time-stamp time (or org-time-was-given arg)))
- ((org-at-timestamp-p)
+ (org-read-date arg 'totime nil nil
+ default-time default-input)))
+ (org-insert-time-stamp time (or org-time-was-given arg) inactive))
+ ((org-at-timestamp-p t)
(setq time (let ((this-command this-command))
(org-read-date arg 'totime nil nil default-time default-input)))
- (when (org-at-timestamp-p) ; just to get the match data
+ (when (org-at-timestamp-p t) ; just to get the match data
+; (setq inactive (eq (char-after (match-beginning 0)) ?\[))
(replace-match "")
(setq org-last-changed-timestamp
(org-insert-time-stamp
time (or org-time-was-given arg)
- nil nil nil (list org-end-time-was-given))))
+ inactive nil nil (list org-end-time-was-given))))
(message "Timestamp updated"))
(t
(setq time (let ((this-command this-command))
(org-read-date arg 'totime nil nil default-time default-input)))
- (org-insert-time-stamp time (or org-time-was-given arg)
- nil nil nil (list org-end-time-was-given))))))
+ (org-insert-time-stamp time (or org-time-was-given arg) inactive
+ nil nil (list org-end-time-was-given))))))
;; FIXME: can we use this for something else, like computing time differences?
(defun org-get-compact-tod (s)
does not link to the calendar and cannot be changed with the S-cursor keys.
So these are more for recording a certain time/date."
(interactive "P")
- (let (org-time-was-given org-end-time-was-given time)
- (setq time (org-read-date arg 'totime))
- (org-insert-time-stamp time (or org-time-was-given arg) 'inactive
- nil nil (list org-end-time-was-given))))
+ (org-time-stamp arg 'inactive))
(defvar org-date-ovl (org-make-overlay 1 1))
(org-overlay-put org-date-ovl 'face 'org-warning)
org-end-time-was-given
(substring txt (match-end 0)))))
(setq org-read-date-overlay
- (make-overlay (1- (point-at-eol)) (point-at-eol)))
+ (org-make-overlay (1- (point-at-eol)) (point-at-eol)))
(org-overlay-display org-read-date-overlay txt 'secondary-selection))))
(defun org-read-date-analyze (ans def defdecode)
(org-move-overlay org-date-ovl (1- (point)) (1+ (point)) (current-buffer))
(select-window sw)))
-; ;; Update the prompt to show new default date
-; (save-excursion
-; (goto-char (point-min))
-; (when (and org-ans2
-; (re-search-forward "\\[[-0-9]+\\]" nil t)
-; (get-text-property (match-end 0) 'field))
-; (let ((inhibit-read-only t))
-; (replace-match (concat "[" org-ans2 "]") t t)
-; (add-text-properties (point-min) (1+ (match-end 0))
-; (text-properties-at (1+ (point-min)))))))))
-
(defun org-calendar-select ()
"Return to `org-read-date' with the date currently selected.
This is used by `org-read-date' in a temporary keymap for the calendar buffer."
With a prefix argument, restrict available to files.
With two prefix arguments, restrict available buffers to agenda files.
-Due to some yet unresolved reason, global function
+Due to some yet unresolved reason, the global function
`iswitchb-mode' needs to be active for this function to work."
(interactive "P")
(require 'iswitchb)
"Switch-to: " nil t))
(or enabled (iswitchb-mode -1))))))
-(defun org-buffer-list (&optional predicate tmp)
+(defun org-buffer-list (&optional predicate exclude-tmp)
"Return a list of Org buffers.
-PREDICATE can be either 'export, 'files or 'agenda.
-
-'export restrict the list to Export buffers.
-'files restrict the list to buffers visiting Org files.
-'agenda restrict the list to buffers visiting agenda files.
-
-If TMP is non-nil, don't include temporary buffers."
- (let (filter blist)
- (setq filter
- (cond ((eq predicate 'files) "\.org$")
- ((eq predicate 'export) "\*Org .*Export")
- (t "\*Org \\|\.org$")))
- (setq blist
+PREDICATE can be `export', `files' or `agenda'.
+
+export restrict the list to Export buffers.
+files restrict the list to buffers visiting Org files.
+agenda restrict the list to buffers visiting agenda files.
+
+If EXCLUDE-TMP is non-nil, ignore temporary buffers."
+ (let* ((bfn nil)
+ (agenda-files (and (eq predicate 'agenda)
+ (mapcar 'file-truename (org-agenda-files t))))
+ (filter
+ (cond
+ ((eq predicate 'files)
+ (lambda (b) (with-current-buffer b (eq major-mode 'org-mode))))
+ ((eq predicate 'export)
+ (lambda (b) (string-match "\*Org .*Export" (buffer-name b))))
+ ((eq predicate 'agenda)
+ (lambda (b)
+ (with-current-buffer b
+ (and (eq major-mode 'org-mode)
+ (setq bfn (buffer-file-name b))
+ (member (file-truename bfn) agenda-files)))))
+ (t (lambda (b) (with-current-buffer b
+ (or (eq major-mode 'org-mode)
+ (string-match "\*Org .*Export"
+ (buffer-name b)))))))))
+ (delq nil
(mapcar
(lambda(b)
- (let ((bname (buffer-name b))
- (bfile (buffer-file-name b)))
- (if (and (string-match filter bname)
- (if (eq predicate 'agenda)
- (member bfile
- (mapcar (lambda(f) (file-truename f))
- org-agenda-files)) t)
- (if tmp (not (string-match "tmp" bname)) t)) b)))
- (buffer-list)))
- (delete nil blist)))
+ (if (and (funcall filter b)
+ (or (not exclude-tmp)
+ (not (string-match "tmp" (buffer-name b)))))
+ b
+ nil))
+ (buffer-list)))))
(defun org-agenda-files (&optional unrestricted archives)
"Get the list of agenda files.
(append org-todo-keywords-for-agenda org-todo-keywords-1))
(setq org-done-keywords-for-agenda
(append org-done-keywords-for-agenda org-done-keywords))
+ (setq org-todo-keyword-alist-for-agenda
+ (append org-todo-keyword-alist-for-agenda org-todo-key-alist))
+ (setq org-tag-alist-for-agenda
+ (append org-tag-alist-for-agenda org-tag-alist))
+
(save-excursion
(remove-text-properties (point-min) (point-max) pall)
(when org-agenda-skip-archived-trees
(while (re-search-forward re nil t)
(add-text-properties
(match-beginning 0) (org-end-of-subtree t) pc)))
- (set-buffer-modified-p bmp))))))
+ (set-buffer-modified-p bmp))))
+ (setq org-todo-keyword-alist-for-agenda
+ (org-uniquify org-todo-keyword-alist-for-agenda)
+ org-tag-alist-for-agenda (org-uniquify org-tag-alist-for-agenda))))
;;;; Embedded LaTeX
;; We only set them when really needed because otherwise the
;; menus don't show the simple keys
-(when (or (featurep 'xemacs) ;; because XEmacs supports multi-device stuff
+(when (or org-use-extra-keys
+ (featurep 'xemacs) ;; because XEmacs supports multi-device stuff
(not window-system))
(org-defkey org-mode-map "\C-c\C-xc" 'org-table-copy-down)
(org-defkey org-mode-map "\C-c\C-xM" 'org-insert-todo-heading)
(org-defkey org-mode-map "\C-c\\" 'org-tags-sparse-tree) ; Minor-mode res.
(org-defkey org-mode-map "\C-c\C-m" 'org-ctrl-c-ret)
(org-defkey org-mode-map "\M-\C-m" 'org-insert-heading)
-(org-defkey org-mode-map [(control return)] 'org-insert-heading-after-current)
+(org-defkey org-mode-map [(control return)] 'org-insert-heading-respect-content)
+(org-defkey org-mode-map [(shift control return)] 'org-insert-todo-heading-respect-content)
(org-defkey org-mode-map "\C-c\C-x\C-n" 'org-next-link)
(org-defkey org-mode-map "\C-c\C-x\C-p" 'org-previous-link)
(org-defkey org-mode-map "\C-c\C-l" 'org-insert-link)
(org-defkey org-mode-map "\C-c|" 'org-table-create-or-convert-from-region)
(org-defkey org-mode-map [(control ?#)] 'org-table-rotate-recalc-marks)
(org-defkey org-mode-map "\C-c~" 'org-table-create-with-table.el)
-(org-defkey org-mode-map "\C-c\C-q" 'org-table-wrap-region)
+(org-defkey org-mode-map "\C-c\C-a" 'org-attach)
(org-defkey org-mode-map "\C-c}" 'org-table-toggle-coordinate-overlays)
(org-defkey org-mode-map "\C-c{" 'org-table-toggle-formula-debugger)
(org-defkey org-mode-map "\C-c\C-e" 'org-export)
(org-defkey org-mode-map "\C-c\C-x\C-l" 'org-preview-latex-fragment)
(org-defkey org-mode-map "\C-c\C-x\C-b" 'org-toggle-checkbox)
(org-defkey org-mode-map "\C-c\C-xp" 'org-set-property)
-(org-defkey org-mode-map "\C-c\C-xr" 'org-insert-columns-dblock)
+(org-defkey org-mode-map "\C-c\C-xi" 'org-insert-columns-dblock)
(define-key org-mode-map "\C-c\C-x\C-c" 'org-columns)
(looking-at "\\(?:#\\+\\(?:setupfile\\|include\\):?[ \t]+\"?\\|[ \t]*<include\\>.*?file=\"\\)\\([^\"\n>]+\\)"))
(find-file (org-trim (match-string 1))))
((org-edit-src-code))
+ ((org-edit-fixed-width-region))
(t (call-interactively 'ffap))))
(defun org-ctrl-c-ctrl-c (&optional arg)
((save-excursion (beginning-of-line 1) (looking-at "#\\+BEGIN:"))
;; Dynamic block
(beginning-of-line 1)
- (org-update-dblock))
+ (save-excursion (org-update-dblock)))
((save-excursion (beginning-of-line 1) (looking-at "#\\+\\([A-Z]+\\)"))
(cond
((equal (match-string 1) "TBLFM")
(setq org-cycle-open-archived-trees (not org-cycle-open-archived-trees))
:style toggle :selected org-cycle-open-archived-trees]
"--"
+ ["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"]
(sit-for 0))))
(defun org-goto-marker-or-bmk (marker &optional bookmark)
- "Go to MARKER, widen if necesary. When marker is not live, try BOOKMARK."
+ "Go to MARKER, widen if necessary. When marker is not live, try BOOKMARK."
(if (and marker (marker-buffer marker)
(buffer-live-p (marker-buffer marker)))
(progn
(setq l (- l (get-text-property b 'org-dwidth-n s))))
l))
+(defun org-get-indentation (&optional line)
+ "Get the indentation of the current line, interpreting tabs.
+When LINE is given, assume it represents a line and compute its indentation."
+ (if line
+ (if (string-match "^ *" (org-remove-tabs line))
+ (match-end 0))
+ (save-excursion
+ (beginning-of-line 1)
+ (skip-chars-forward " \t")
+ (current-column))))
+
+(defun org-remove-tabs (s &optional width)
+ "Replace tabulators in S with spaces.
+Assumes that s is a single line, starting in column 0."
+ (setq width (or width tab-width))
+ (while (string-match "\t" s)
+ (setq s (replace-match
+ (make-string
+ (- (* width (/ (+ (match-beginning 0) width) width))
+ (match-beginning 0)) ?\ )
+ t t s)))
+ s)
+
+(defun org-fix-indentation (line ind)
+ "Fix indentation in LINE.
+IND is a cons cell with target and minimum indentation.
+If the current indenation in LINE is smaller than the minimum,
+leave it alone. If it is larger than ind, set it to the target."
+ (let* ((l (org-remove-tabs line))
+ (i (org-get-indentation l))
+ (i1 (car ind)) (i2 (cdr ind)))
+ (if (>= i i2) (setq l (substring line i2)))
+ (if (> i1 0)
+ (concat (make-string i1 ?\ ) l)
+ l)))
+
(defun org-base-buffer (buffer)
"Return the base buffer of BUFFER, if it has one. Else return the buffer."
(if (not buffer)
(setq column (current-column))))
((org-in-item-p)
(org-beginning-of-item)
-; (looking-at "[ \t]*\\(\\S-+\\)[ \t]*")
(looking-at "[ \t]*\\(\\S-+\\)[ \t]*\\(\\[[- X]\\][ \t]*\\|.*? :: \\)?")
(setq bpos (match-beginning 1) tpos (match-end 0)
bcol (progn (goto-char bpos) (current-column))
(org-set-tags nil t))
(t (kill-region (point) (point-at-eol)))))
+
(define-key org-mode-map "\C-k" 'org-kill-line)
+(defun org-yank ()
+ "Yank, and if the yanked text is a single subtree, fold it.
+In fact, if the yanked text is a sequence of subtrees, fold all of them."
+ (interactive)
+ (if org-yank-folded-subtrees
+ (let ((beg (point)) end)
+ (call-interactively 'yank)
+ (setq end (point))
+ (goto-char beg)
+ (when (and (bolp)
+ (org-kill-is-subtree-p))
+ (or (looking-at outline-regexp)
+ (re-search-forward (concat "^" outline-regexp) end t))
+ (while (and (< (point) end) (looking-at outline-regexp))
+ (hide-subtree)
+ (org-cycle-show-empty-lines 'folded)
+ (condition-case nil
+ (outline-forward-same-level 1)
+ (error (goto-char end)))))
+ (goto-char end)
+ (skip-chars-forward " \t\n\r"))
+ (call-interactively 'yank)))
+
+(define-key org-mode-map "\C-y" 'org-yank)
+
(defun org-invisible-p ()
"Check if point is at a character currently not visible."
;; Early versions of noutline don't have `outline-invisible-p'.
(save-excursion (outline-end-of-heading) (point))
flag))))
+(defun org-forward-same-level (arg)
+ "Move forward to the ARG'th subheading at same level as this one.
+Stop at the first and last subheadings of a superior heading.
+This is like outline-forward-same-level, but invisible headings are ok."
+ (interactive "p")
+ (outline-back-to-heading t)
+ (while (> arg 0)
+ (let ((point-to-move-to (save-excursion
+ (org-get-next-sibling))))
+ (if point-to-move-to
+ (progn
+ (goto-char point-to-move-to)
+ (setq arg (1- arg)))
+ (progn
+ (setq arg 0)
+ (error "No following same-level heading"))))))
+
+(defun org-get-next-sibling ()
+ "Move to next heading of the same level, and return point.
+If there is no such heading, return nil.
+This is like outline-next-sibling, but invisible headings are ok."
+ (let ((level (funcall outline-level)))
+ (outline-next-heading)
+ (while (and (not (eobp)) (> (funcall outline-level) level))
+ (outline-next-heading))
+ (if (or (eobp) (< (funcall outline-level) level))
+ nil
+ (point))))
+
(defun org-end-of-subtree (&optional invisible-OK to-heading)
;; This is an exact copy of the original function, but it uses
;; `org-back-to-heading', to make it work also in invisible
(setq level (org-reduced-level (funcall outline-level)))
(when (<= level n)
(looking-at org-complex-heading-regexp)
- (setq head (org-match-string-no-properties 4)
+ (setq head (org-link-display-format
+ (org-match-string-no-properties 4))
m (org-imenu-new-marker))
(org-add-props head nil 'org-imenu-marker m 'org-imenu t)
(if (>= level last-level)
(if (eq major-mode 'org-mode)
(org-show-context 'org-goto))))))
+(defun org-link-display-format (link)
+ "Replace a link with either the description, or the link target
+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)
+ link)))
+
;; Speedbar support
(defvar org-speedbar-restriction-lock-overlay (org-make-overlay 1 1)