annotate lisp/org/org-list.el @ 104810:86b7fe7d1d8f

2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-protocol.el (org-protocol-store-link) (org-protocol-remember, org-protocol-open-source): Add autoloads. * org-compat.el (org-float-time): New function. * org.el (org-clock-update-time-maybe) (org-sort-entries-or-items, org-do-sort) (org-evaluate-time-range, org-time-string-to-seconds) (org-closed-in-range): Use `org-float-time'. * org-timer.el (org-timer-start, org-timer-pause-or-continue) (org-timer-seconds): Use `org-float-time'. * org-clock.el (org-clock-get-clocked-time, org-clock-out) (org-clock-sum, org-dblock-write:clocktable) (org-clocktable-steps): Use `org-float-time'. * org-agenda.el (org-agenda-last-marker-time) (org-agenda-new-marker, org-diary): Use `org-float-time'. * org-compat.el (w32-focus-frame): Declare the w32-focus-frame function. * org-exp.el (org-get-file-contents): Only protect lines that really need it. * org-html.el (require): Require cl for compilation. * org.el: Avoid using `default-major-mode'. * org-plot.el (require): Require CL only at compile time. * org-exp.el (require): Require CL only at compile time. * org-agenda.el (org-agenda-quit): When the agenda window is dedicated, remove other windows before exiting, so that the frame really will be killed. * org-exp.el (org-export-handle-include-files): Reset START and END for each loop cycle. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-eval-in-calendar): Use `org-select-frame-set-input-focus'. * org-compat.el (org-select-frame-set-input-focus): New function. * org.el (org-update-statistics-cookies): New function. (org-mode-map): Bind `C-c #' to `org-update-statistics-cookies'. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-src.el (org-edit-fixed-width-region): Set org-src-mode only after the local variables are set. * org-latex.el (org-export-latex-protect-amp): New function. (org-export-latex-links): Protect link ampersands in tables. * org-exp.el (org-export-select-backend-specific-text): Match in two steps, to avoid regexp problems. * org.el (org-offer-links-in-entry): Improve working with many and duplicate links. * org-agenda.el (org-agenda-show-1): Make more consistent with normal cycling. (org-agenda-cycle-show): Make more consistent with normal cycling. * org-gnus.el (org-gnus-store-link): Restore the linking to a website. 2009-09-02 Bastien Guerry <bzg@altern.org> * org-latex.el (org-export-latex-first-lines): Bugfix. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-clock.el (org-clock-modify-effort-estimate): Emit message about new effort. * org.el (org-set-effort): New function. (org-mode-map): New key for effort setting command. * org-agenda.el (org-agenda): Keep window setup when calling agenda from within agenda window. (org-agenda-mode-map): New keys for effort setting commands. (org-agenda-menu): Add effort setting commands to menu. (org-agenda-set-property, org-agenda-set-effort): New functions. * org-latex.el (org-export-latex-tables): Fix `org-table-last-alignment' and `org-table-last-column-widths' if the first column has been removed. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-remove-timestamp-with-keyword): Only remove in entry, not in subtree. * org-src.el (org-src-lang-modes): Add abbreviation elisp for emacs lisp. * org.el (org-open-at-point): When on headline, offer all strings in entry. * org-remember.el (org-remember-templates): Documentation fix. * org.el (org-move-subtree-down): Use `org-get-next-sibling' and `org-get-last-sibling' instead of the outline versions of these functions. (org-get-last-sibling): New function. (org-refile): Use `org-get-next-sibling' instead of the outline version of this function. (org-clean-visibility-after-subtree-move): Use `org-get-next-sibling' and `org-get-last-sibling' instead of the outline versions of these functions. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-prepare-agenda): When creating a new frame for the agenda, make the window dedicated. * org-agenda.el (org-agenda-mode-map): New keys for time motion. * org-table.el (org-table-align): Change the order of reinsertion and deletion, to avoid problems with overlays following the table. * org.el (org-parse-time-string): Better error message. (org-show-subtree): Use org-end-of-subtree. * org-macs.el (org-goto-line): New defsubst. * org.el (org-open-file, org-change-tag-in-region) (org-fast-tag-show-exit): Don't use `goto-line'. * org-table.el (org-table-align, org-table-insert-column) (org-table-delete-column, org-table-move-column) (org-table-sort-lines, org-table-copy-region) (org-table-paste-rectangle, org-table-wrap-region) (org-table-get-specials, org-table-rotate-recalc-marks) (org-table-get-range, org-table-recalculate) (org-table-edit-formulas, org-table-fedit-convert-buffer) (org-table-show-reference, org-table-highlight-rectangle): Don't use `goto-line'. * org-src.el (org-edit-src-code, org-edit-fixed-width-region) (org-edit-src-exit): Don't use `goto-line'. * org-macs.el (org-preserve-lc): Don't use `goto-line'. * org-list.el (org-renumber-ordered-list, org-fix-bullet-type): Don't use `goto-line'. * org-exp.el (org-export-number-lines): Don't use `goto-line'. * org-colview.el (org-columns, org-columns-redo) (org-agenda-columns): Don't use `goto-line'. * org-colview-xemacs.el (org-columns, org-agenda-columns): Don't use `goto-line'. * org-agenda.el (org-agenda-mode): Force visual line motion off. (org-agenda-add-entry-text-maxlines): Improve docstring. (org-agenda-start-with-entry-text-mode): New option. (org-agenda-entry-text-maxlines): New option. (org-agenda-entry-text-mode): New variable. (org-agenda-mode): Set initial value of `org-agenda-entry-text-mode'. (org-agenda-mode-map): Add the `E' key. (org-agenda-menu): Add entry text mode to the menu. (org-agenda-get-some-entry-text): Fix line count bug. (org-finalize-agenda): Apply entry text mode if appropriate. (org-agenda-entry-text-show-here): New function. (org-agenda-entry-text-show): New function. (org-agenda-entry-text-hide): New function. (org-agenda-view-mode-dispatch): Add entry text mode to the view key menu. (org-agenda-entry-text-mode): New command. (org-agenda-set-mode-name): Add entry text mode to the mode line string. (org-agenda-undo, org-agenda-get-restriction-and-command) (org-agenda-get-some-entry-text, org-agenda-redo): Don't use `goto-line'. 2009-09-02 Bernt Hansen <bernt@norang.ca> * org-clock.el (org-notify): Bugfix. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-agenda-open-link): Handle multiple links and check for after-string. * org-gnus.el (org-gnus-store-link): Simplify. * org.el (org-latex-regexps): Don't add extra empty lines for display formulas. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-agenda-get-some-entry-text): New function. (org-agenda-add-entry-text): Use `org-agenda-get-some-entry-text'. * org.el (org-cycle-separator-lines): Update docstring. (org-cycle-show-empty-lines): Handle negative values for `org-cycle-show-empty-lines'. * org-exp.el (org-export-protect-sub-super): New function. (org-export-normalize-links): Protect the url of plain links from supscript and superscript processing. * org-remember.el (org-remember-escaped-%): New function. (org-remember-apply-template): Use `org-remember-escaped-%' to detect escaped % signs. 2009-09-02 Bastien Guerry <bzg@altern.org> * org-timer.el (org-timer-set-timer): Use `org-notify' and play a sound when showing the notification. * org-clock.el (org-notify): New function. (org-clock-notify-once-if-expired): Use `org-notify'. * org-gnus.el (org-gnus-store-link): Handle `gnus-summary-mode' and `gnus-article-mode' separately. (gnus-summary-article-header): Fix the declare-function. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-format-source-code-or-example): Translate language. * org-src.el (org-src-lang-modes): New variable (org-edit-src-code): Translate language. * org-exp.el (org-export-format-source-code-or-example): Deal wit the new structure of the `org-export-latex-listings-langs' variable. * org-latex.el (org-export-latex-listings-langs): Change structure of the variable from plist to alist. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-in-commented-line): New function. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-hide-block-toggle): Make folded blocks searchable. 2009-09-02 Friedrich Delgado Friedrichs <friedel@nomaden.org> (tiny change) * org.el (org-flag-drawer): More useful error. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-remember.el (org-remember-apply-template): Use org-icompleting-read. * org-publish.el (org-publish): Use org-icompleting-read. * org-colview.el (org-columns-edit-value, org-columns-new) (org-insert-columns-dblock): Use org-icompleting-read. * org-colview-xemacs.el (org-columns-edit-value) (org-columns-new, org-insert-columns-dblock): Use org-icompleting-read. * org-attach.el (org-attach-delete-one, org-attach-open): Use org-icompleting-read. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-hierarchical-todo-statistics): Improve docstring. (org-version): Return the version text. (org-org-menu): Add a menu entry for the new bug reporter. (org-submit-bug-report): New command. * org-list.el (org-hierarchical-checkbox-statistics): Improve docstring. * org.el (org-emphasis-regexp-components): Add "`" to set of pre-emphasis characters. * org-latex.el (org-export-latex-classes): Always include the soul package. (org-export-latex-emphasis-alist): Use \st for strikethough. * org-exp-blocks.el (org-export-blocks-preprocess): Use `indent-code-rigidly' to indent. * org-agenda.el (org-agenda-get-restriction-and-command): Remove properties only if MATCH really is a string. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-latex.el (org-export-latex-packages-alist): Fix customization type. * org.el (org-create-formula-image): Also use `org-export-latex-packages-alist'. * org-html.el (org-export-as-html): Fix bug in footnote regexp. (org-export-as-html): Format footnotes correctly. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-fast-tag-selection): Avoid text properties on tags in the alist. * org-agenda.el (org-agenda-get-restriction-and-command): Avoid text properties on the match element. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-set-regexps-and-options): Make sure the list of done keywords is not invalid. * org-exp.el (org-export-interpolate-newlines): New function. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-format-latex): Avoid nested overlays. * org-latex.el (org-export-latex-listings-langs): Add a few more languages. * org-exp.el (org-export-preprocess-apply-macros): Make sure to ignore newlines and space before the first macro argument. * org-latex.el (org-export-latex-tables): Remove save-excursion around `org-table-align'. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-export-html-special-string-regexps): Definition moved into org.el * org-exp.el (org-export-preprocess-apply-macros): Allow newlines in macro calls. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-latex.el (org-export-latex-listings) (org-export-latex-listings-langs): New options. * org-exp.el (org-export-format-source-code-or-example): Use listing package if requested by the user. 2009-09-02 Bastien Guerry <bzg@altern.org> * org.el (org-iswitchb): Fix bug when aborting the `org-iswitchb' command before actually switching to a buffer. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-get-file-contents): Only quote org lines when the markup is src or example. * org-agenda.el (org-agenda-skip-scheduled-if-deadline-is-shown): New option (org-agenda-get-day-entries): Remember deadline results and pass them on into the function getting the scheduling information. (org-agenda-get-scheduled): Accept deadline results as parameters and maybe skip some entries. (org-agenda-skip-scheduled-if-deadline-is-shown): New option. * org.el (org-insert-heading): When respecting content, do not convert current line to headline. * org-clock.el (org-clock-save-markers-for-cut-and-paste): Also cheeeeeck the hd marker (org-clock-in): Also set the hd marker. (org-clock-out): Also set the hd marker. (org-clock-cancel): Reset markers. * org.el (org-clock-hd-marker): New marker. * org-faces.el (org-agenda-clocking): New face. * org-agenda.el (org-agenda-mark-clocking-task): New function. (org-finalize-agenda): call `org-agenda-mark-clocking-task'. * org.el (org-modules): Add org-track.el. * org-agenda.el (org-agenda-bulk-marked-p): New function. (org-agenda-bulk-mark, org-agenda-bulk-unmark): Use `org-agenda-bulk-marked-p'. (org-agenda-bulk-toggle): New command. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-move-subtree-down): Hide subtree if it was folded, not just the body. * org-remember.el (org-remember-finalize): Avoid buffer-modified messages.
author Carsten Dominik <dominik@science.uva.nl>
date Wed, 02 Sep 2009 12:59:52 +0000
parents ac1a55cc2c38
children c54e9253e596
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1 ;;; org-list.el --- Plain lists for Org-mode
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2 ;;
101515
64ef70f990a9 2009-01-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 101458
diff changeset
3 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
64ef70f990a9 2009-01-26 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 101458
diff changeset
4 ;; Free Software Foundation, Inc.
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5 ;;
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6 ;; Author: Carsten Dominik <carsten at orgmode dot org>
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
7 ;; Bastien Guerry <bzg AT altern DOT org>
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8 ;; Keywords: outlines, hypermedia, calendar, wp
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9 ;; Homepage: http://orgmode.org
104810
86b7fe7d1d8f 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 104164
diff changeset
10 ;; Version: 6.30c
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11 ;;
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12 ;; This file is part of GNU Emacs.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13 ;;
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14 ;; GNU Emacs is free software: you can redistribute it and/or modify
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
15 ;; it under the terms of the GNU General Public License as published by
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
16 ;; the Free Software Foundation, either version 3 of the License, or
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
17 ;; (at your option) any later version.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
18
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
19 ;; GNU Emacs is distributed in the hope that it will be useful,
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
22 ;; GNU General Public License for more details.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
23
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
25 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
26 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
27 ;;
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
28 ;;; Commentary:
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
29
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
30 ;; This file contains the code dealing with plain lists in Org-mode.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
31
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
32 ;;; Code:
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
33
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
34 (require 'org-macs)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
35 (require 'org-compat)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
36
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
37 (defvar org-blank-before-new-entry)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
38 (defvar org-M-RET-may-split-line)
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
39 (defvar org-complex-heading-regexp)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
40 (defvar org-odd-levels-only)
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
41
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
42 (declare-function org-invisible-p "org" ())
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
43 (declare-function org-on-heading-p "org" (&optional invisible-ok))
99180
84fe37d605df (outline-next-heading, outline-back-to-heading): Fix declarations.
Glenn Morris <rgm@gnu.org>
parents: 99139
diff changeset
44 (declare-function outline-next-heading "outline" ())
84fe37d605df (outline-next-heading, outline-back-to-heading): Fix declarations.
Glenn Morris <rgm@gnu.org>
parents: 99139
diff changeset
45 (declare-function outline-back-to-heading "outline" (&optional invisible-ok))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
46 (declare-function org-back-to-heading "org" (&optional invisible-ok))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
47 (declare-function org-back-over-empty-lines "org" ())
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
48 (declare-function org-skip-whitespace "org" ())
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
49 (declare-function org-trim "org" (s))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
50 (declare-function org-get-indentation "org" (&optional line))
100267
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
51 (declare-function org-timer-item "org-timer" (&optional arg))
101458
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
52 (declare-function org-combine-plists "org" (&rest plists))
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
53 (declare-function org-entry-get "org" (pom property &optional inherit))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
54 (declare-function org-narrow-to-subtree "org" ())
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
55 (declare-function org-show-subtree "org" ())
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
56
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
57 (defgroup org-plain-lists nil
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
58 "Options concerning plain lists in Org-mode."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
59 :tag "Org Plain lists"
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
60 :group 'org-structure)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
61
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
62 (defcustom org-cycle-include-plain-lists t
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
63 "When t, make TAB cycle visibility on plain list items.
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
64
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
65 Cycling plain lists works only when the cursor is on a plain list
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
66 item. When the cursor is on an outline heading, plain lists are
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
67 treated as text. This is the most stable way of handling this,
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
68 which is why it is the default.
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
69
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
70 When this is the symbol `integrate', then during cycling, plain
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
71 list items will *temporarily* be interpreted as outline headlines
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
72 with a level given by 1000+i where i is the indentation of the
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
73 bullet. This setting can lead to strange effects when switching
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
74 visibility to `children', because the first \"child\" in a
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
75 subtree decides what children should be listed. If that first
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
76 \"child\" is a plain list item with an implied large level
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
77 number, all true children and grand children of the outline
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
78 heading will be exposed in a children' view."
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
79 :group 'org-plain-lists
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
80 :type '(choice
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
81 (const :tag "Never" nil)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
82 (const :tag "With cursor in plain list (recommended)" t)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
83 (const :tag "As children of outline headings" integrate)))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
84
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
85 (defcustom org-list-demote-modify-bullet nil
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
86 "Default bullet type installed when demoting an item.
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
87 This is an association list, for each bullet type, this alist will point
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
88 to the bulled that should be used when this item is demoted."
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
89 :group 'org-plain-lists
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
90 :type '(repeat
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
91 (cons
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
92 (choice :tag "If the current bullet is "
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
93 (const "-")
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
94 (const "+")
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
95 (const "*")
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
96 (const "1.")
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
97 (const "1)"))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
98 (choice :tag "demotion will change it to"
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
99 (const "-")
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
100 (const "+")
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
101 (const "*")
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
102 (const "1.")
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
103 (const "1)")))))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
104
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
105 (defcustom org-plain-list-ordered-item-terminator t
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
106 "The character that makes a line with leading number an ordered list item.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
107 Valid values are ?. and ?\). To get both terminators, use t. While
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
108 ?. may look nicer, it creates the danger that a line with leading
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
109 number may be incorrectly interpreted as an item. ?\) therefore is
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
110 the safe choice."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
111 :group 'org-plain-lists
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
112 :type '(choice (const :tag "dot like in \"2.\"" ?.)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
113 (const :tag "paren like in \"2)\"" ?\))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
114 (const :tab "both" t)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
115
99849
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
116 (defcustom org-list-two-spaces-after-bullet-regexp nil
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
117 "A regular expression matching bullets that should have 2 spaces after them.
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
118 When nil, no bullet will have two spaces after them.
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
119 When a string, it will be used as a regular expression. When the bullet
99849
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
120 type of a list is changed, the new bullet type will be matched against this
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
121 regexp. If it matches, there will be two spaces instead of one after
99849
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
122 the bullet in each item of he list."
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
123 :group 'org-plain-list
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
124 :type '(choice
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
125 (const :tag "never" nil)
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
126 (regexp)))
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
127
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
128 (defcustom org-empty-line-terminates-plain-lists nil
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
129 "Non-nil means, an empty line ends all plain list levels.
101681
9bc864ce1de6 (org-empty-line-terminates-plain-lists, org-toggle-checkbox): Doc fixes.
Glenn Morris <rgm@gnu.org>
parents: 101670
diff changeset
130 When nil, empty lines are part of the preceding item."
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
131 :group 'org-plain-lists
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
132 :type 'boolean)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
133
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
134 (defcustom org-auto-renumber-ordered-lists t
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
135 "Non-nil means, automatically renumber ordered plain lists.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
136 Renumbering happens when the sequence have been changed with
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
137 \\[org-shiftmetaup] or \\[org-shiftmetadown]. After other editing commands,
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
138 use \\[org-ctrl-c-ctrl-c] to trigger renumbering."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
139 :group 'org-plain-lists
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
140 :type 'boolean)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
141
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
142 (defcustom org-provide-checkbox-statistics t
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
143 "Non-nil means, update checkbox statistics after insert and toggle.
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
144 When this is set, checkbox statistics is updated each time you
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
145 either insert a new checkbox with \\[org-insert-todo-heading] or
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
146 toggle a checkbox with \\[org-ctrl-c-ctrl-c]."
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
147 :group 'org-plain-lists
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
148 :type 'boolean)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
149
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
150 (defcustom org-hierarchical-checkbox-statistics t
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
151 "Non-nil means, checkbox statistics counts only the state of direct children.
104810
86b7fe7d1d8f 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 104164
diff changeset
152 When nil, all boxes below the cookie are counted.
86b7fe7d1d8f 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 104164
diff changeset
153 This can be set to nil on a per-node basis using a COCKIE_DATA property
86b7fe7d1d8f 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 104164
diff changeset
154 with the word \"recursive\" in the value."
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
155 :group 'org-plain-lists
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
156 :type 'boolean)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
157
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
158 (defcustom org-description-max-indent 20
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
159 "Maximum indentation for the second line of a description list.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
160 When the indentation would be larger than this, it will become
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
161 5 characters instead."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
162 :group 'org-plain-lists
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
163 :type 'integer)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
164
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
165 (defvar org-list-beginning-re
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
166 "^\\([ \t]*\\)\\([-+]\\|[0-9]+[.)]\\) +\\(.*\\)$")
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
167
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
168 (defcustom org-list-radio-list-templates
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
169 '((latex-mode "% BEGIN RECEIVE ORGLST %n
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
170 % END RECEIVE ORGLST %n
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
171 \\begin{comment}
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
172 #+ORGLST: SEND %n org-list-to-latex
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
173 | | |
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
174 \\end{comment}\n")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
175 (texinfo-mode "@c BEGIN RECEIVE ORGLST %n
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
176 @c END RECEIVE ORGLST %n
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
177 @ignore
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
178 #+ORGLST: SEND %n org-list-to-texinfo
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
179 | | |
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
180 @end ignore\n")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
181 (html-mode "<!-- BEGIN RECEIVE ORGLST %n -->
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
182 <!-- END RECEIVE ORGLST %n -->
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
183 <!--
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
184 #+ORGLST: SEND %n org-list-to-html
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
185 | | |
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
186 -->\n"))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
187 "Templates for radio lists in different major modes.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
188 All occurrences of %n in a template will be replaced with the name of the
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
189 list, obtained by prompting the user."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
190 :group 'org-plain-lists
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
191 :type '(repeat
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
192 (list (symbol :tag "Major mode")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
193 (string :tag "Format"))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
194
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
195 ;;;; Plain list items, including checkboxes
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
196
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
197 ;;; Plain list items
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
198
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
199 (defun org-at-item-p ()
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
200 "Is point in a line starting a hand-formatted item?"
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
201 (let ((llt org-plain-list-ordered-item-terminator))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
202 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
203 (goto-char (point-at-bol))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
204 (looking-at
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
205 (cond
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
206 ((eq llt t) "\\([ \t]*\\([-+]\\|\\([0-9]+[.)]\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
207 ((= llt ?.) "\\([ \t]*\\([-+]\\|\\([0-9]+\\.\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)")
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
208 ((= llt ?\)) "\\([ \t]*\\([-+]\\|\\([0-9]+)\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)")
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
209 (t (error "Invalid value of `org-plain-list-ordered-item-terminator'")))))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
210
101568
f5aedb5cbd80 2009-01-27 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101515
diff changeset
211 (defun org-at-item-bullet-p ()
f5aedb5cbd80 2009-01-27 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101515
diff changeset
212 "Is point at the bullet of a plain list item?"
f5aedb5cbd80 2009-01-27 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101515
diff changeset
213 (and (org-at-item-p)
f5aedb5cbd80 2009-01-27 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101515
diff changeset
214 (not (member (char-after) '(?\ ?\t)))
f5aedb5cbd80 2009-01-27 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101515
diff changeset
215 (< (point) (match-end 0))))
f5aedb5cbd80 2009-01-27 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101515
diff changeset
216
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
217 (defun org-in-item-p ()
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
218 "It the cursor inside a plain list item.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
219 Does not have to be the first line."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
220 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
221 (condition-case nil
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
222 (progn
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
223 (org-beginning-of-item)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
224 (org-at-item-p)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
225 t)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
226 (error nil))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
227
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
228 (defun org-insert-item (&optional checkbox)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
229 "Insert a new item at the current level.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
230 Return t when things worked, nil when we are not in an item."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
231 (when (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
232 (condition-case nil
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
233 (progn
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
234 (org-beginning-of-item)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
235 (org-at-item-p)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
236 (if (org-invisible-p) (error "Invisible item"))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
237 t)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
238 (error nil)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
239 (let* ((bul (match-string 0))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
240 (descp (save-excursion (goto-char (match-beginning 0))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
241 (beginning-of-line 1)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
242 (save-match-data
100267
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
243 (and (looking-at "[ \t]*\\(.*?\\) ::")
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
244 (match-string 1)))))
101458
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
245 (empty-line-p (save-excursion
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
246 (goto-char (match-beginning 0))
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
247 (and (not (bobp))
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
248 (or (beginning-of-line 0) t)
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
249 (save-match-data
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
250 (looking-at "[ \t]*$")))))
100267
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
251 (timerp (and descp
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
252 (save-match-data
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
253 (string-match "^[-+*][ \t]+[0-9]+:[0-9]+:[0-9]+$"
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
254 descp))))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
255 (eow (save-excursion (beginning-of-line 1) (looking-at "[ \t]*")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
256 (match-end 0)))
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
257 (blank-a (if org-empty-line-terminates-plain-lists
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
258 nil
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
259 (cdr (assq 'plain-list-item org-blank-before-new-entry))))
101458
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
260 (blank (if (eq blank-a 'auto) empty-line-p blank-a))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
261 pos)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
262 (if descp (setq checkbox nil))
100267
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
263 (if timerp
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
264 (progn (org-timer-item) t)
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
265 (cond
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
266 ((and (org-at-item-p) (<= (point) eow))
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
267 ;; before the bullet
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
268 (beginning-of-line 1)
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
269 (open-line (if blank 2 1)))
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
270 ((<= (point) eow)
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
271 (beginning-of-line 1))
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
272 (t
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
273 (unless (org-get-alist-option org-M-RET-may-split-line 'item)
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
274 (end-of-line 1)
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
275 (delete-horizontal-space))
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
276 (newline (if blank 2 1))))
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
277 (insert bul
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
278 (if checkbox "[ ]" "")
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
279 (if descp (concat (if checkbox " " "")
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
280 (read-string "Term: ") " :: ") ""))
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
281 (just-one-space)
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
282 (setq pos (point))
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
283 (end-of-line 1)
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
284 (unless (= (point) pos) (just-one-space) (backward-delete-char 1)))
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
285 (org-maybe-renumber-ordered-list)
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
286 (and checkbox (org-update-checkbox-count-maybe))
c851df8e004e 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99866
diff changeset
287 t)))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
288
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
289 ;;; Checkboxes
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
290
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
291 (defun org-at-item-checkbox-p ()
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
292 "Is point at a line starting a plain-list item with a checklet?"
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
293 (and (org-at-item-p)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
294 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
295 (goto-char (match-end 0))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
296 (skip-chars-forward " \t")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
297 (looking-at "\\[[- X]\\]"))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
298
101607
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
299 (defun org-toggle-checkbox (&optional toggle-presence)
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
300 "Toggle the checkbox in the current line.
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
301 With prefix arg TOGGLE-PRESENCE, add or remove checkboxes.
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
302 With double prefix, set checkbox to [-].
101607
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
303 When there is an active region, toggle status or presence of the checkbox
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
304 in the first line, and make every item in the region have the same
101681
9bc864ce1de6 (org-empty-line-terminates-plain-lists, org-toggle-checkbox): Doc fixes.
Glenn Morris <rgm@gnu.org>
parents: 101670
diff changeset
305 status or presence, respectively.
101670
a15c11f894f1 2009-01-30 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101607
diff changeset
306 If the cursor is in a headline, apply this to all checkbox items in the
a15c11f894f1 2009-01-30 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101607
diff changeset
307 text below the heading."
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
308 (interactive "P")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
309 (catch 'exit
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
310 (let (beg end status first-present first-status blocked)
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
311 (cond
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
312 ((org-region-active-p)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
313 (setq beg (region-beginning) end (region-end)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
314 ((org-on-heading-p)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
315 (setq beg (point) end (save-excursion (outline-next-heading) (point))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
316 ((org-at-item-checkbox-p)
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
317 (save-excursion
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
318 (if (equal toggle-presence '(4))
101607
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
319 (progn
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
320 (replace-match "")
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
321 (goto-char (match-beginning 0))
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
322 (just-one-space))
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
323 (when (setq blocked (org-checkbox-blocked-p))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
324 (error "Checkbox blocked because of unchecked box in line %d"
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
325 blocked))
101607
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
326 (replace-match
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
327 (cond ((equal toggle-presence '(16)) "[-]")
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
328 ((member (match-string 0) '("[ ]" "[-]")) "[X]")
101607
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
329 (t "[ ]"))
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
330 t t)))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
331 (throw 'exit t))
101607
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
332 ((org-at-item-p)
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
333 ;; add a checkbox
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
334 (save-excursion
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
335 (goto-char (match-end 0))
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
336 (insert "[ ] "))
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
337 (throw 'exit t))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
338 (t (error "Not at a checkbox or heading, and no active region")))
101607
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
339 (setq end (move-marker (make-marker) end))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
340 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
341 (goto-char beg)
101607
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
342 (setq first-present (org-at-item-checkbox-p)
101670
a15c11f894f1 2009-01-30 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101607
diff changeset
343 first-status
a15c11f894f1 2009-01-30 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101607
diff changeset
344 (save-excursion
a15c11f894f1 2009-01-30 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101607
diff changeset
345 (and (re-search-forward "[ \t]\\(\\[[ X]\\]\\)" end t)
a15c11f894f1 2009-01-30 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101607
diff changeset
346 (equal (match-string 1) "[X]"))))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
347 (while (< (point) end)
101607
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
348 (if toggle-presence
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
349 (cond
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
350 ((and first-present (org-at-item-checkbox-p))
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
351 (save-excursion
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
352 (replace-match "")
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
353 (goto-char (match-beginning 0))
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
354 (just-one-space)))
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
355 ((and (not first-present) (not (org-at-item-checkbox-p))
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
356 (org-at-item-p))
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
357 (save-excursion
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
358 (goto-char (match-end 0))
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
359 (insert "[ ] "))))
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
360 (when (org-at-item-checkbox-p)
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
361 (setq status (equal (match-string 0) "[X]"))
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
362 (replace-match
59ea090317cd 2009-01-28 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101568
diff changeset
363 (if first-status "[ ]" "[X]") t t)))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
364 (beginning-of-line 2)))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
365 (org-update-checkbox-count-maybe))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
366
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
367 (defun org-reset-checkbox-state-subtree ()
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
368 "Reset all checkboxes in an entry subtree."
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
369 (interactive "*")
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
370 (save-restriction
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
371 (save-excursion
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
372 (org-narrow-to-subtree)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
373 (org-show-subtree)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
374 (goto-char (point-min))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
375 (let ((end (point-max)))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
376 (while (< (point) end)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
377 (when (org-at-item-checkbox-p)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
378 (replace-match "[ ]" t t))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
379 (beginning-of-line 2))))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
380 (org-update-checkbox-count-maybe)))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
381
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
382 (defun org-checkbox-blocked-p ()
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
383 "Is the current checkbox blocked from for being checked now?
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
384 A checkbox is blocked if all of the following conditions are fulfilled:
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
385
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
386 1. The checkbox is not checked already.
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
387 2. The current entry has the ORDERED property set.
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
388 3. There is an unchecked checkbox in this entry before the current line."
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
389 (catch 'exit
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
390 (save-match-data
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
391 (save-excursion
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
392 (unless (org-at-item-checkbox-p) (throw 'exit nil))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
393 (when (equal (match-string 0) "[X]")
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
394 ;; the box is already checked!
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
395 (throw 'exit nil))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
396 (let ((end (point-at-bol)))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
397 (condition-case nil (org-back-to-heading t)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
398 (error (throw 'exit nil)))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
399 (unless (org-entry-get nil "ORDERED") (throw 'exit nil))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
400 (if (re-search-forward "^[ \t]*[-+*0-9.)] \\[[- ]\\]" end t)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
401 (org-current-line)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
402 nil))))))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
403
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
404 (defvar org-checkbox-statistics-hook nil
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
405 "Hook that is run whenever Org thinks checkbox statistics should be updated.
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
406 This hook runs even if `org-provide-checkbox-statistics' is nil, to it can
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
407 be used to implement alternative ways of collecting statistics information.")
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
408
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
409 (defun org-update-checkbox-count-maybe ()
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
410 "Update checkbox statistics unless turned off by user."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
411 (when org-provide-checkbox-statistics
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
412 (org-update-checkbox-count))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
413 (run-hooks 'org-checkbox-statistics-hook))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
414
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
415 (defun org-update-checkbox-count (&optional all)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
416 "Update the checkbox statistics in the current section.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
417 This will find all statistic cookies like [57%] and [6/12] and update them
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
418 with the current numbers. With optional prefix argument ALL, do this for
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
419 the whole buffer."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
420 (interactive "P")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
421 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
422 (let* ((buffer-invisibility-spec (org-inhibit-invisibility)) ; Emacs 21
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
423 (beg (condition-case nil
99849
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
424 (progn (org-back-to-heading) (point))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
425 (error (point-min))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
426 (end (move-marker (make-marker)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
427 (progn (outline-next-heading) (point))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
428 (re "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
429 (re-box "^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[- X]\\]\\)")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
430 (re-find (concat re "\\|" re-box))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
431 beg-cookie end-cookie is-percent c-on c-off lim
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
432 eline curr-ind next-ind continue-from startsearch
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
433 (recursive
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
434 (or (not org-hierarchical-checkbox-statistics)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
435 (string-match "\\<recursive\\>"
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
436 (or (org-entry-get nil "COOKIE_DATA") ""))))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
437 (cstat 0)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
438 )
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
439 (when all
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
440 (goto-char (point-min))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
441 (outline-next-heading)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
442 (setq beg (point) end (point-max)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
443 (goto-char end)
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
444 ;; find each statistics cookie
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
445 (while (and (re-search-backward re-find beg t)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
446 (not (save-match-data
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
447 (and (org-on-heading-p)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
448 (string-match "\\<todo\\>"
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
449 (downcase
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
450 (or (org-entry-get
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
451 nil "COOKIE_DATA")
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
452 "")))))))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
453 (setq beg-cookie (match-beginning 1)
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
454 end-cookie (match-end 1)
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
455 cstat (+ cstat (if end-cookie 1 0))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
456 startsearch (point-at-eol)
101670
a15c11f894f1 2009-01-30 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101607
diff changeset
457 continue-from (match-beginning 0)
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
458 is-percent (match-beginning 2)
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
459 lim (cond
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
460 ((org-on-heading-p) (outline-next-heading) (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
461 ((org-at-item-p) (org-end-of-item) (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
462 (t nil))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
463 c-on 0
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
464 c-off 0)
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
465 (when lim
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
466 ;; find first checkbox for this cookie and gather
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
467 ;; statistics from all that are at this indentation level
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
468 (goto-char startsearch)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
469 (if (re-search-forward re-box lim t)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
470 (progn
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
471 (org-beginning-of-item)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
472 (setq curr-ind (org-get-indentation))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
473 (setq next-ind curr-ind)
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
474 (while (and (bolp) (org-at-item-p)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
475 (if recursive
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
476 (<= curr-ind next-ind)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
477 (= curr-ind next-ind)))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
478 (save-excursion (end-of-line) (setq eline (point)))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
479 (if (re-search-forward re-box eline t)
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
480 (if (member (match-string 2) '("[ ]" "[-]"))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
481 (setq c-off (1+ c-off))
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
482 (setq c-on (1+ c-on))))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
483 (if (not recursive)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
484 (org-end-of-item)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
485 (end-of-line)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
486 (when (re-search-forward org-list-beginning-re lim t)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
487 (beginning-of-line)))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
488 (setq next-ind (org-get-indentation)))))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
489 (goto-char continue-from)
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
490 ;; update cookie
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
491 (when end-cookie
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
492 (delete-region beg-cookie end-cookie)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
493 (goto-char beg-cookie)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
494 (insert
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
495 (if is-percent
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
496 (format "[%d%%]" (/ (* 100 c-on) (max 1 (+ c-on c-off))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
497 (format "[%d/%d]" c-on (+ c-on c-off)))))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
498 ;; update items checkbox if it has one
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
499 (when (org-at-item-p)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
500 (org-beginning-of-item)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
501 (when (and (> (+ c-on c-off) 0)
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
502 (re-search-forward re-box (point-at-eol) t))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
503 (setq beg-cookie (match-beginning 2)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
504 end-cookie (match-end 2))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
505 (delete-region beg-cookie end-cookie)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
506 (goto-char beg-cookie)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
507 (cond ((= c-off 0) (insert "[X]"))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
508 ((= c-on 0) (insert "[ ]"))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
509 (t (insert "[-]")))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
510 )))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
511 (goto-char continue-from))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
512 (when (interactive-p)
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
513 (message "Checkbox statistics updated %s (%d places)"
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
514 (if all "in entire file" "in current outline entry") cstat)))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
515
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
516 (defun org-get-checkbox-statistics-face ()
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
517 "Select the face for checkbox statistics.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
518 The face will be `org-done' when all relevant boxes are checked. Otherwise
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
519 it will be `org-todo'."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
520 (if (match-end 1)
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
521 (if (equal (match-string 1) "100%")
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
522 'org-checkbox-statistics-done
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
523 'org-checkbox-statistics-todo)
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
524 (if (and (> (match-end 2) (match-beginning 2))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
525 (equal (match-string 2) (match-string 3)))
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
526 'org-checkbox-statistics-done
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
527 'org-checkbox-statistics-todo)))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
528
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
529 (defun org-beginning-of-item ()
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
530 "Go to the beginning of the current hand-formatted item.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
531 If the cursor is not in an item, throw an error."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
532 (interactive)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
533 (let ((pos (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
534 (limit (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
535 (condition-case nil
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
536 (progn
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
537 (org-back-to-heading)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
538 (beginning-of-line 2) (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
539 (error (point-min)))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
540 (ind-empty (if org-empty-line-terminates-plain-lists 0 10000))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
541 ind ind1)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
542 (if (org-at-item-p)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
543 (beginning-of-line 1)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
544 (beginning-of-line 1)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
545 (skip-chars-forward " \t")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
546 (setq ind (current-column))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
547 (if (catch 'exit
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
548 (while t
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
549 (beginning-of-line 0)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
550 (if (or (bobp) (< (point) limit)) (throw 'exit nil))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
551
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
552 (if (looking-at "[ \t]*$")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
553 (setq ind1 ind-empty)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
554 (skip-chars-forward " \t")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
555 (setq ind1 (current-column)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
556 (if (< ind1 ind)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
557 (progn (beginning-of-line 1) (throw 'exit (org-at-item-p))))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
558 nil
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
559 (goto-char pos)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
560 (error "Not in an item")))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
561
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
562 (defun org-end-of-item ()
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
563 "Go to the end of the current hand-formatted item.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
564 If the cursor is not in an item, throw an error."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
565 (interactive)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
566 (let* ((pos (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
567 ind1
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
568 (ind-empty (if org-empty-line-terminates-plain-lists 0 10000))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
569 (limit (save-excursion (outline-next-heading) (point)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
570 (ind (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
571 (org-beginning-of-item)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
572 (skip-chars-forward " \t")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
573 (current-column)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
574 (end (catch 'exit
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
575 (while t
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
576 (beginning-of-line 2)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
577 (if (eobp) (throw 'exit (point)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
578 (if (>= (point) limit) (throw 'exit (point-at-bol)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
579 (if (looking-at "[ \t]*$")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
580 (setq ind1 ind-empty)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
581 (skip-chars-forward " \t")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
582 (setq ind1 (current-column)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
583 (if (<= ind1 ind)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
584 (throw 'exit (point-at-bol)))))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
585 (if end
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
586 (goto-char end)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
587 (goto-char pos)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
588 (error "Not in an item"))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
589
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
590 (defun org-next-item ()
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
591 "Move to the beginning of the next item in the current plain list.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
592 Error if not at a plain list, or if this is the last item in the list."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
593 (interactive)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
594 (let (ind ind1 (pos (point)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
595 (org-beginning-of-item)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
596 (setq ind (org-get-indentation))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
597 (org-end-of-item)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
598 (setq ind1 (org-get-indentation))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
599 (unless (and (org-at-item-p) (= ind ind1))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
600 (goto-char pos)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
601 (error "On last item"))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
602
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
603 (defun org-previous-item ()
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
604 "Move to the beginning of the previous item in the current plain list.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
605 Error if not at a plain list, or if this is the first item in the list."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
606 (interactive)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
607 (let (beg ind ind1 (pos (point)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
608 (org-beginning-of-item)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
609 (setq beg (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
610 (setq ind (org-get-indentation))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
611 (goto-char beg)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
612 (catch 'exit
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
613 (while t
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
614 (beginning-of-line 0)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
615 (if (looking-at "[ \t]*$")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
616 nil
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
617 (if (<= (setq ind1 (org-get-indentation)) ind)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
618 (throw 'exit t)))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
619 (condition-case nil
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
620 (if (or (not (org-at-item-p))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
621 (< ind1 (1- ind)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
622 (error "")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
623 (org-beginning-of-item))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
624 (error (goto-char pos)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
625 (error "On first item")))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
626
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
627 (defun org-first-list-item-p ()
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
628 "Is this heading the first item in a plain list?"
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
629 (unless (org-at-item-p)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
630 (error "Not at a plain list item"))
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
631 (save-excursion
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
632 (org-beginning-of-item)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
633 (= (point) (save-excursion (org-beginning-of-item-list)))))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
634
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
635 (defun org-move-item-down ()
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
636 "Move the plain list item at point down, i.e. swap with following item.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
637 Subitems (items with larger indentation) are considered part of the item,
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
638 so this really moves item trees."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
639 (interactive)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
640 (let ((col (current-column))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
641 (pos (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
642 beg beg0 end end0 ind ind1 txt ne-end ne-beg)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
643 (org-beginning-of-item)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
644 (setq beg0 (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
645 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
646 (setq ne-beg (org-back-over-empty-lines))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
647 (setq beg (point)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
648 (goto-char beg0)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
649 (setq ind (org-get-indentation))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
650 (org-end-of-item)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
651 (setq end0 (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
652 (setq ind1 (org-get-indentation))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
653 (setq ne-end (org-back-over-empty-lines))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
654 (setq end (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
655 (goto-char beg0)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
656 (when (and (org-first-list-item-p) (< ne-end ne-beg))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
657 ;; include less whitespace
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
658 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
659 (goto-char beg)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
660 (forward-line (- ne-beg ne-end))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
661 (setq beg (point))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
662 (goto-char end0)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
663 (if (and (org-at-item-p) (= ind ind1))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
664 (progn
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
665 (org-end-of-item)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
666 (org-back-over-empty-lines)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
667 (setq txt (buffer-substring beg end))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
668 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
669 (delete-region beg end))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
670 (setq pos (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
671 (insert txt)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
672 (goto-char pos) (org-skip-whitespace)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
673 (org-maybe-renumber-ordered-list)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
674 (move-to-column col))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
675 (goto-char pos)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
676 (move-to-column col)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
677 (error "Cannot move this item further down"))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
678
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
679 (defun org-move-item-up (arg)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
680 "Move the plain list item at point up, i.e. swap with previous item.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
681 Subitems (items with larger indentation) are considered part of the item,
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
682 so this really moves item trees."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
683 (interactive "p")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
684 (let ((col (current-column)) (pos (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
685 beg beg0 end ind ind1 txt
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
686 ne-beg ne-ins ins-end)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
687 (org-beginning-of-item)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
688 (setq beg0 (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
689 (setq ind (org-get-indentation))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
690 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
691 (setq ne-beg (org-back-over-empty-lines))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
692 (setq beg (point)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
693 (goto-char beg0)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
694 (org-end-of-item)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
695 (org-back-over-empty-lines)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
696 (setq end (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
697 (goto-char beg0)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
698 (catch 'exit
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
699 (while t
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
700 (beginning-of-line 0)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
701 (if (looking-at "[ \t]*$")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
702 (if org-empty-line-terminates-plain-lists
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
703 (progn
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
704 (goto-char pos)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
705 (error "Cannot move this item further up"))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
706 nil)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
707 (if (<= (setq ind1 (org-get-indentation)) ind)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
708 (throw 'exit t)))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
709 (condition-case nil
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
710 (org-beginning-of-item)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
711 (error (goto-char beg0)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
712 (move-to-column col)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
713 (error "Cannot move this item further up")))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
714 (setq ind1 (org-get-indentation))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
715 (if (and (org-at-item-p) (= ind ind1))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
716 (progn
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
717 (setq ne-ins (org-back-over-empty-lines))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
718 (setq txt (buffer-substring beg end))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
719 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
720 (delete-region beg end))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
721 (setq pos (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
722 (insert txt)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
723 (setq ins-end (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
724 (goto-char pos) (org-skip-whitespace)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
725
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
726 (when (and (org-first-list-item-p) (> ne-ins ne-beg))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
727 ;; Move whitespace back to beginning
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
728 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
729 (goto-char ins-end)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
730 (let ((kill-whole-line t))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
731 (kill-line (- ne-ins ne-beg)) (point)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
732 (insert (make-string (- ne-ins ne-beg) ?\n)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
733
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
734 (org-maybe-renumber-ordered-list)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
735 (move-to-column col))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
736 (goto-char pos)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
737 (move-to-column col)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
738 (error "Cannot move this item further up"))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
739
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
740 (defun org-maybe-renumber-ordered-list ()
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
741 "Renumber the ordered list at point if setup allows it.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
742 This tests the user option `org-auto-renumber-ordered-lists' before
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
743 doing the renumbering."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
744 (interactive)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
745 (when (and org-auto-renumber-ordered-lists
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
746 (org-at-item-p))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
747 (if (match-beginning 3)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
748 (org-renumber-ordered-list 1)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
749 (org-fix-bullet-type))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
750
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
751 (defun org-maybe-renumber-ordered-list-safe ()
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
752 (condition-case nil
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
753 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
754 (org-maybe-renumber-ordered-list))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
755 (error nil)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
756
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
757 (defun org-cycle-list-bullet (&optional which)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
758 "Cycle through the different itemize/enumerate bullets.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
759 This cycle the entire list level through the sequence:
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
760
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
761 `-' -> `+' -> `*' -> `1.' -> `1)'
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
762
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
763 If WHICH is a string, use that as the new bullet. If WHICH is an integer,
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
764 0 means `-', 1 means `+' etc."
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
765 (interactive "P")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
766 (org-preserve-lc
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
767 (org-beginning-of-item-list)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
768 (org-at-item-p)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
769 (beginning-of-line 1)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
770 (let ((current (match-string 0))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
771 (prevp (eq which 'previous))
99849
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
772 new old)
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
773 (setq new (cond
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
774 ((and (numberp which)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
775 (nth (1- which) '("-" "+" "*" "1." "1)"))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
776 ((string-match "-" current) (if prevp "1)" "+"))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
777 ((string-match "\\+" current)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
778 (if prevp "-" (if (looking-at "\\S-") "1." "*")))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
779 ((string-match "\\*" current) (if prevp "+" "1."))
99849
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
780 ((string-match "\\." current)
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
781 (if prevp (if (looking-at "\\S-") "+" "*") "1)"))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
782 ((string-match ")" current) (if prevp "1." "-"))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
783 (t (error "This should not happen"))))
99849
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
784 (and (looking-at "\\([ \t]*\\)\\(\\S-+\\)")
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
785 (setq old (match-string 2))
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
786 (replace-match (concat "\\1" new)))
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
787 (org-shift-item-indentation (- (length new) (length old)))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
788 (org-fix-bullet-type)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
789 (org-maybe-renumber-ordered-list))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
790
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
791 (defun org-get-string-indentation (s)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
792 "What indentation has S due to SPACE and TAB at the beginning of the string?"
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
793 (let ((n -1) (i 0) (w tab-width) c)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
794 (catch 'exit
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
795 (while (< (setq n (1+ n)) (length s))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
796 (setq c (aref s n))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
797 (cond ((= c ?\ ) (setq i (1+ i)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
798 ((= c ?\t) (setq i (* (/ (+ w i) w) w)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
799 (t (throw 'exit t)))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
800 i))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
801
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
802 (defun org-renumber-ordered-list (arg)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
803 "Renumber an ordered plain list.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
804 Cursor needs to be in the first line of an item, the line that starts
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
805 with something like \"1.\" or \"2)\"."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
806 (interactive "p")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
807 (unless (and (org-at-item-p)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
808 (match-beginning 3))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
809 (error "This is not an ordered list"))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
810 (let ((line (org-current-line))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
811 (col (current-column))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
812 (ind (org-get-string-indentation
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
813 (buffer-substring (point-at-bol) (match-beginning 3))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
814 ;; (term (substring (match-string 3) -1))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
815 ind1 (n (1- arg))
99849
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
816 fmt bobp old new)
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
817 ;; find where this list begins
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
818 (org-beginning-of-item-list)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
819 (setq bobp (bobp))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
820 (looking-at "[ \t]*[0-9]+\\([.)]\\)")
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
821 (setq fmt (concat "%d" (or (match-string 1) ".")))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
822 (beginning-of-line 0)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
823 ;; walk forward and replace these numbers
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
824 (catch 'exit
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
825 (while t
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
826 (catch 'next
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
827 (if bobp (setq bobp nil) (beginning-of-line 2))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
828 (if (eobp) (throw 'exit nil))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
829 (if (looking-at "[ \t]*$") (throw 'next nil))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
830 (skip-chars-forward " \t") (setq ind1 (current-column))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
831 (if (> ind1 ind) (throw 'next t))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
832 (if (< ind1 ind) (throw 'exit t))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
833 (if (not (org-at-item-p)) (throw 'exit nil))
99849
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
834 (setq old (match-string 2))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
835 (delete-region (match-beginning 2) (match-end 2))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
836 (goto-char (match-beginning 2))
99849
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
837 (insert (setq new (format fmt (setq n (1+ n)))))
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
838 (org-shift-item-indentation (- (length new) (length old))))))
104810
86b7fe7d1d8f 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 104164
diff changeset
839 (org-goto-line line)
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
840 (org-move-to-column col)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
841
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
842 (defun org-fix-bullet-type (&optional force-bullet)
99849
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
843 "Make sure all items in this list have the same bullet as the first item.
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
844 Also, fix the indentation."
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
845 (interactive)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
846 (unless (org-at-item-p) (error "This is not a list"))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
847 (let ((line (org-current-line))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
848 (col (current-column))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
849 (ind (current-indentation))
99849
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
850 ind1 bullet oldbullet)
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
851 ;; find where this list begins
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
852 (org-beginning-of-item-list)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
853 (beginning-of-line 1)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
854 ;; find out what the bullet type is
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
855 (looking-at "[ \t]*\\(\\S-+\\)")
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
856 (setq bullet (concat (or force-bullet (match-string 1)) " "))
99849
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
857 (if (and org-list-two-spaces-after-bullet-regexp
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
858 (string-match org-list-two-spaces-after-bullet-regexp bullet))
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
859 (setq bullet (concat bullet " ")))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
860 ;; walk forward and replace these numbers
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
861 (beginning-of-line 0)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
862 (catch 'exit
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
863 (while t
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
864 (catch 'next
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
865 (beginning-of-line 2)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
866 (if (eobp) (throw 'exit nil))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
867 (if (looking-at "[ \t]*$") (throw 'next nil))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
868 (skip-chars-forward " \t") (setq ind1 (current-column))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
869 (if (> ind1 ind) (throw 'next t))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
870 (if (< ind1 ind) (throw 'exit t))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
871 (if (not (org-at-item-p)) (throw 'exit nil))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
872 (skip-chars-forward " \t")
99849
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
873 (looking-at "\\S-+ *")
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
874 (setq oldbullet (match-string 0))
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
875 (unless (equal bullet oldbullet) (replace-match bullet))
99849
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
876 (org-shift-item-indentation (- (length bullet) (length oldbullet))))))
104810
86b7fe7d1d8f 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 104164
diff changeset
877 (org-goto-line line)
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
878 (org-move-to-column col)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
879 (if (string-match "[0-9]" bullet)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
880 (org-renumber-ordered-list 1))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
881
99849
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
882 (defun org-shift-item-indentation (delta)
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
883 "Shift the indentation in current item by DELTA."
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
884 (save-excursion
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
885 (let ((beg (point-at-bol))
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
886 (end (progn (org-end-of-item) (point)))
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
887 i)
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
888 (goto-char end)
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
889 (beginning-of-line 0)
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
890 (while (> (point) beg)
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
891 (when (looking-at "[ \t]*\\S-")
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
892 ;; this is not an empty line
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
893 (setq i (org-get-indentation))
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
894 (if (and (> i 0) (> (setq i (+ i delta)) 0))
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
895 (indent-line-to i)))
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
896 (beginning-of-line 0)))))
621e15919df0 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 99501
diff changeset
897
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
898 (defun org-beginning-of-item-list ()
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
899 "Go to the beginning of the current item list.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
900 I.e. to the first item in this list."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
901 (interactive)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
902 (org-beginning-of-item)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
903 (let ((pos (point-at-bol))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
904 (ind (org-get-indentation))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
905 ind1)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
906 ;; find where this list begins
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
907 (catch 'exit
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
908 (while t
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
909 (catch 'next
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
910 (beginning-of-line 0)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
911 (if (looking-at "[ \t]*$")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
912 (throw (if (bobp) 'exit 'next) t))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
913 (skip-chars-forward " \t") (setq ind1 (current-column))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
914 (if (or (< ind1 ind)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
915 (and (= ind1 ind)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
916 (not (org-at-item-p)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
917 (and (= (point-at-bol) (point-min))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
918 (setq pos (point-min))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
919 (throw 'exit t)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
920 (when (org-at-item-p) (setq pos (point-at-bol)))))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
921 (goto-char pos)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
922
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
923 (defun org-end-of-item-list ()
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
924 "Go to the end of the current item list.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
925 I.e. to the text after the last item."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
926 (interactive)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
927 (org-beginning-of-item)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
928 (let ((pos (point-at-bol))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
929 (ind (org-get-indentation))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
930 ind1)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
931 ;; find where this list begins
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
932 (catch 'exit
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
933 (while t
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
934 (catch 'next
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
935 (beginning-of-line 2)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
936 (if (looking-at "[ \t]*$")
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
937 (if (eobp)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
938 (progn (setq pos (point)) (throw 'exit t))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
939 (throw 'next t)))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
940 (skip-chars-forward " \t") (setq ind1 (current-column))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
941 (if (or (< ind1 ind)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
942 (and (= ind1 ind)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
943 (not (org-at-item-p)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
944 (eobp))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
945 (progn
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
946 (setq pos (point-at-bol))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
947 (throw 'exit t))))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
948 (goto-char pos)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
949
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
950
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
951 (defvar org-last-indent-begin-marker (make-marker))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
952 (defvar org-last-indent-end-marker (make-marker))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
953
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
954 (defun org-outdent-item (arg)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
955 "Outdent a local list item."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
956 (interactive "p")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
957 (org-indent-item (- arg)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
958
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
959 (defun org-indent-item (arg)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
960 "Indent a local list item."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
961 (interactive "p")
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
962 (and (org-region-active-p) (org-cursor-to-region-beginning))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
963 (unless (org-at-item-p)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
964 (error "Not on an item"))
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
965 (let (beg end ind ind1 ind-bul delta ind-down ind-up firstp)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
966 (setq firstp (org-first-list-item-p))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
967 (save-excursion
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
968 (setq end (and (org-region-active-p) (region-end)))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
969 (if (memq last-command '(org-shiftmetaright org-shiftmetaleft))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
970 (setq beg org-last-indent-begin-marker
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
971 end org-last-indent-end-marker)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
972 (org-beginning-of-item)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
973 (setq beg (move-marker org-last-indent-begin-marker (point)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
974 (org-end-of-item)
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
975 (setq end (move-marker org-last-indent-end-marker (or end (point)))))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
976 (goto-char beg)
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
977 (setq ind-bul (org-item-indent-positions)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
978 ind (caar ind-bul)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
979 ind-down (car (nth 2 ind-bul))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
980 ind-up (car (nth 1 ind-bul))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
981 delta (if (> arg 0)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
982 (if ind-down (- ind-down ind) 2)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
983 (if ind-up (- ind-up ind) -2)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
984 (if (< (+ delta ind) 0) (error "Cannot outdent beyond margin"))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
985 (while (< (point) end)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
986 (beginning-of-line 1)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
987 (skip-chars-forward " \t") (setq ind1 (current-column))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
988 (delete-region (point-at-bol) (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
989 (or (eolp) (org-indent-to-column (+ ind1 delta)))
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
990 (beginning-of-line 2)))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
991 (org-fix-bullet-type
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
992 (and (> arg 0)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
993 (not firstp)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
994 (cdr (assoc (cdr (nth 0 ind-bul)) org-list-demote-modify-bullet))))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
995 (org-maybe-renumber-ordered-list-safe)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
996 (save-excursion
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
997 (beginning-of-line 0)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
998 (condition-case nil (org-beginning-of-item) (error nil))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
999 (org-maybe-renumber-ordered-list-safe))))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1000
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1001 (defun org-item-indent-positions ()
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1002 "Return indentation for plain list items.
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1003 This returns a list with three values: The current indentation, the
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1004 parent indentation and the indentation a child should have.
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1005 Assumes cursor in item line."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1006 (let* ((bolpos (point-at-bol))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1007 (ind (org-get-indentation))
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1008 (bullet (org-get-bullet))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1009 ind-down ind-up bullet-up bullet-down pos)
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1010 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1011 (org-beginning-of-item-list)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1012 (skip-chars-backward "\n\r \t")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1013 (when (org-in-item-p)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1014 (org-beginning-of-item)
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1015 (setq ind-up (org-get-indentation))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1016 (setq bullet-up (org-get-bullet))))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1017 (setq pos (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1018 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1019 (cond
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1020 ((and (condition-case nil (progn (org-previous-item) t)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1021 (error nil))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1022 (or (forward-char 1) t)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1023 (re-search-forward "^\\([ \t]*\\([-+]\\|\\([0-9]+[.)]\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)" bolpos t))
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1024 (setq ind-down (org-get-indentation)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1025 bullet-down (org-get-bullet)))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1026 ((and (goto-char pos)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1027 (org-at-item-p))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1028 (goto-char (match-end 0))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1029 (skip-chars-forward " \t")
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1030 (setq ind-down (current-column)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1031 bullet-down (org-get-bullet)))))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1032 (if (and bullet-down (string-match "\\`[0-9]+\\(\\.\\|)\\)\\'" bullet-down))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1033 (setq bullet-down (concat "1" (match-string 1 bullet-down))))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1034 (if (and bullet-up (string-match "\\`[0-9]+\\(\\.\\|)\\)\\'" bullet-up))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1035 (setq bullet-up (concat "1" (match-string 1 bullet-up))))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1036 (if (and bullet (string-match "\\`[0-9]+\\(\\.\\|)\\)\\'" bullet))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1037 (setq bullet (concat "1" (match-string 1 bullet))))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1038 (list (cons ind bullet)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1039 (cons ind-up bullet-up)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1040 (cons ind-down bullet-down))))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1041
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1042 (defun org-get-bullet ()
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1043 (save-excursion
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1044 (goto-char (point-at-bol))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1045 (and (looking-at
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1046 "^\\([ \t]*\\([-+]\\|\\([0-9]+[.)]\\)\\)\\|[ \t]+\\(\\*\\)\\)\\( \\|$\\)")
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1047 (or (match-string 2) (match-string 4)))))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1048
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1049 ;;; Send and receive lists
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1050
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1051 (defun org-list-parse-list (&optional delete)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1052 "Parse the list at point and maybe DELETE it.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1053 Return a list containing first level items as strings and
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1054 sublevels as a list of strings."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1055 (let* ((item-beginning (org-list-item-beginning))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1056 (start (car item-beginning))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1057 (end (org-list-end (cdr item-beginning)))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1058 output itemsep ltype)
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1059 (while (re-search-forward org-list-beginning-re end t)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1060 (goto-char (match-beginning 3))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1061 (save-match-data
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1062 (cond ((string-match "[0-9]" (match-string 2))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1063 (setq itemsep "[0-9]+\\(?:\\.\\|)\\)"
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1064 ltype 'ordered))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1065 ((string-match "^.*::" (match-string 0))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1066 (setq itemsep "[-+]" ltype 'descriptive))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1067 (t (setq itemsep "[-+]" ltype 'unordered))))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1068 (let* ((indent1 (match-string 1))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1069 (nextitem (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1070 (save-match-data
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1071 (or (and (re-search-forward
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1072 (concat "^" indent1 itemsep " *?") end t)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1073 (match-beginning 0)) end))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1074 (item (buffer-substring
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1075 (point)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1076 (or (and (re-search-forward
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1077 org-list-beginning-re end t)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1078 (goto-char (match-beginning 0)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1079 (goto-char end))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1080 (nextindent (match-string 1))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1081 (item (org-trim item))
101458
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1082 (item (if (string-match "^\\[\\([xX ]\\)\\]" item)
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1083 (replace-match (if (equal (match-string 1 item) " ")
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1084 "[CBOFF]"
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1085 "[CBON]")
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1086 t nil item)
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1087 item)))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1088 (push item output)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1089 (when (> (length nextindent)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1090 (length indent1))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1091 (narrow-to-region (point) nextitem)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1092 (push (org-list-parse-list) output)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1093 (widen))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1094 (when delete (delete-region start end))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1095 (setq output (nreverse output))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1096 (push ltype output)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1097
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1098 (defun org-list-item-beginning ()
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1099 "Find the beginning of the list item.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1100 Return a cons which car is the beginning position of the item and
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1101 cdr is the indentation string."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1102 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1103 (if (not (or (looking-at org-list-beginning-re)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1104 (re-search-backward
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1105 org-list-beginning-re nil t)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1106 (progn (goto-char (point-min)) (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1107 (cons (match-beginning 0) (match-string 1)))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1108
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1109 (defun org-list-goto-true-beginning ()
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1110 "Go to the beginning of the list at point."
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1111 (beginning-of-line 1)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1112 (while (looking-at org-list-beginning-re)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1113 (beginning-of-line 0))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1114 (progn
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1115 (re-search-forward org-list-beginning-re nil t)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1116 (goto-char (match-beginning 0))))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1117
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1118 (defun org-list-make-subtree ()
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1119 "Convert the plain list at point into a subtree."
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1120 (interactive)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1121 (org-list-goto-true-beginning)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1122 (let ((list (org-list-parse-list t)) nstars)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1123 (save-excursion
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1124 (if (condition-case nil
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1125 (org-back-to-heading)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1126 (error nil))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1127 (progn (re-search-forward org-complex-heading-regexp nil t)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1128 (setq nstars (length (match-string 1))))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1129 (setq nstars 0)))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1130 (org-list-make-subtrees list (1+ nstars))))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1131
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1132 (defun org-list-make-subtrees (list level)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1133 "Convert LIST into subtrees starting at LEVEL."
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1134 (if (symbolp (car list))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1135 (org-list-make-subtrees (cdr list) level)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1136 (mapcar (lambda (item)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1137 (if (stringp item)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1138 (insert (make-string
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1139 (if org-odd-levels-only
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1140 (1- (* 2 level)) level) ?*) " " item "\n")
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1141 (org-list-make-subtrees item (1+ level))))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1142 list)))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1143
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1144 (defun org-list-end (indent)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1145 "Return the position of the end of the list.
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1146 INDENT is the indentation of the list, as a string."
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1147 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1148 (catch 'exit
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1149 (while (or (looking-at org-list-beginning-re)
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1150 (looking-at (concat "^" indent "[ \t]+\\|^$"))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1151 (> (or (get-text-property (point) 'original-indentation) -1)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1152 (length indent)))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1153 (if (eq (point) (point-max))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1154 (throw 'exit (point-max)))
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1155 (forward-line 1)))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1156 (point)))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1157
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1158 (defun org-list-insert-radio-list ()
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1159 "Insert a radio list template appropriate for this major mode."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1160 (interactive)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1161 (let* ((e (assq major-mode org-list-radio-list-templates))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1162 (txt (nth 1 e))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1163 name pos)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1164 (unless e (error "No radio list setup defined for %s" major-mode))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1165 (setq name (read-string "List name: "))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1166 (while (string-match "%n" txt)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1167 (setq txt (replace-match name t t txt)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1168 (or (bolp) (insert "\n"))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1169 (setq pos (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1170 (insert txt)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1171 (goto-char pos)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1172
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1173 (defun org-list-send-list (&optional maybe)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1174 "Send a tranformed version of this list to the receiver position.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1175 With argument MAYBE, fail quietly if no transformation is defined for
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1176 this list."
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1177 (interactive)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1178 (catch 'exit
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1179 (unless (org-at-item-p) (error "Not at a list"))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1180 (save-excursion
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1181 (org-list-goto-true-beginning)
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1182 (beginning-of-line 0)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1183 (unless (looking-at "#\\+ORGLST: *SEND +\\([a-zA-Z0-9_]+\\) +\\([^ \t\r\n]+\\)\\( +.*\\)?")
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1184 (if maybe
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1185 (throw 'exit nil)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1186 (error "Don't know how to transform this list"))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1187 (let* ((name (match-string 1))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1188 (item-beginning (org-list-item-beginning))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1189 (transform (intern (match-string 2)))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1190 (txt (buffer-substring-no-properties
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1191 (car item-beginning)
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1192 (org-list-end (cdr item-beginning))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1193 (list (org-list-parse-list))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1194 beg)
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1195 (unless (fboundp transform)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1196 (error "No such transformation function %s" transform))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1197 (setq txt (funcall transform list))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1198 ;; Find the insertion place
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1199 (save-excursion
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1200 (goto-char (point-min))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1201 (unless (re-search-forward
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1202 (concat "BEGIN RECEIVE ORGLST +" name "\\([ \t]\\|$\\)") nil t)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1203 (error "Don't know where to insert translated list"))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1204 (goto-char (match-beginning 0))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1205 (beginning-of-line 2)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1206 (setq beg (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1207 (unless (re-search-forward (concat "END RECEIVE ORGLST +" name) nil t)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1208 (error "Cannot find end of insertion region"))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1209 (beginning-of-line 1)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1210 (delete-region beg (point))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1211 (goto-char beg)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1212 (insert txt "\n"))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1213 (message "List converted and installed at receiver location"))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1214
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1215 (defun org-list-to-generic (list params)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1216 "Convert a LIST parsed through `org-list-parse-list' to other formats.
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1217
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1218 Valid parameters PARAMS are
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1219
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1220 :ustart String to start an unordered list
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1221 :uend String to end an unordered list
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1222
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1223 :ostart String to start an ordered list
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1224 :oend String to end an ordered list
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1225
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1226 :dstart String to start a descriptive list
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1227 :dend String to end a descriptive list
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1228 :dtstart String to start a descriptive term
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1229 :dtend String to end a descriptive term
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1230 :ddstart String to start a description
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1231 :ddend String to end a description
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1232
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1233 :splice When set to t, return only list body lines, don't wrap
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1234 them into :[u/o]start and :[u/o]end. Default is nil.
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1235
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1236 :istart String to start a list item
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1237 :iend String to end a list item
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1238 :isep String to separate items
101458
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1239 :lsep String to separate sublists
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1240
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1241 :cboff String to insert for an unchecked checkbox
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1242 :cbon String to insert for a checked checkbox"
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1243 (interactive)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1244 (let* ((p params) sublist
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1245 (splicep (plist-get p :splice))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1246 (ostart (plist-get p :ostart))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1247 (oend (plist-get p :oend))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1248 (ustart (plist-get p :ustart))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1249 (uend (plist-get p :uend))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1250 (dstart (plist-get p :dstart))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1251 (dend (plist-get p :dend))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1252 (dtstart (plist-get p :dtstart))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1253 (dtend (plist-get p :dtend))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1254 (ddstart (plist-get p :ddstart))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1255 (ddend (plist-get p :ddend))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1256 (istart (plist-get p :istart))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1257 (iend (plist-get p :iend))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1258 (isep (plist-get p :isep))
101458
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1259 (lsep (plist-get p :lsep))
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1260 (cbon (plist-get p :cbon))
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1261 (cboff (plist-get p :cboff)))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1262 (let ((wrapper
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1263 (cond ((eq (car list) 'ordered)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1264 (concat ostart "\n%s" oend "\n"))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1265 ((eq (car list) 'unordered)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1266 (concat ustart "\n%s" uend "\n"))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1267 ((eq (car list) 'descriptive)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1268 (concat dstart "\n%s" dend "\n"))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1269 rtn term defstart defend)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1270 (while (setq sublist (pop list))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1271 (cond ((symbolp sublist) nil)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1272 ((stringp sublist)
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1273 (when (string-match "^\\(.*\\) ::" sublist)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1274 (setq term (org-trim (format (concat dtstart "%s" dtend)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1275 (match-string 1 sublist))))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1276 (setq sublist (substring sublist (1+ (length term)))))
101458
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1277 (if (string-match "\\[CBON\\]" sublist)
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1278 (setq sublist (replace-match cbon t t sublist)))
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1279 (if (string-match "\\[CBOFF\\]" sublist)
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1280 (setq sublist (replace-match cboff t t sublist)))
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1281 (setq rtn (concat rtn istart term ddstart
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1282 sublist ddend iend isep)))
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1283 (t (setq rtn (concat rtn ;; previous list
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1284 lsep ;; list separator
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1285 (org-list-to-generic sublist p)
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1286 lsep ;; list separator
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
1287 )))))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1288 (format wrapper rtn))))
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1289
101458
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1290 (defun org-list-to-latex (list &optional params)
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1291 "Convert LIST into a LaTeX list.
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1292 LIST is as returnd by `org-list-parse-list'. PARAMS is a property list
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1293 with overruling parameters for `org-list-to-generic'."
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1294 (org-list-to-generic
101458
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1295 list
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1296 (org-combine-plists
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1297 '(:splicep nil :ostart "\\begin{enumerate}" :oend "\\end{enumerate}"
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1298 :ustart "\\begin{itemize}" :uend "\\end{itemize}"
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1299 :dstart "\\begin{description}" :dend "\\end{description}"
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1300 :dtstart "[" :dtend "]"
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1301 :ddstart "" :ddend ""
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1302 :istart "\\item " :iend ""
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1303 :isep "\n" :lsep "\n"
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1304 :cbon "\\texttt{[X]}" :cboff "\\texttt{[ ]}")
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1305 params)))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1306
101458
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1307 (defun org-list-to-html (list &optional params)
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1308 "Convert LIST into a HTML list.
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1309 LIST is as returnd by `org-list-parse-list'. PARAMS is a property list
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1310 with overruling parameters for `org-list-to-generic'."
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1311 (org-list-to-generic
101458
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1312 list
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1313 (org-combine-plists
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1314 '(:splicep nil :ostart "<ol>" :oend "</ol>"
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1315 :ustart "<ul>" :uend "</ul>"
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1316 :dstart "<dl>" :dend "</dl>"
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1317 :dtstart "<dt>" :dtend "</dt>"
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1318 :ddstart "<dd>" :ddend "</dd>"
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1319 :istart "<li>" :iend "</li>"
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1320 :isep "\n" :lsep "\n"
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1321 :cbon "<code>[X]</code>" :cboff "<code>[ ]</code>")
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1322 params)))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1323
101458
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1324 (defun org-list-to-texinfo (list &optional params)
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1325 "Convert LIST into a Texinfo list.
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1326 LIST is as returnd by `org-list-parse-list'. PARAMS is a property list
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1327 with overruling parameters for `org-list-to-generic'."
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1328 (org-list-to-generic
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
1329 list
101458
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1330 (org-combine-plists
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1331 '(:splicep nil :ostart "@itemize @minus" :oend "@end itemize"
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1332 :ustart "@enumerate" :uend "@end enumerate"
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1333 :dstart "@table" :dend "@end table"
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1334 :dtstart "@item " :dtend "\n"
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1335 :ddstart "" :ddend ""
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1336 :istart "@item\n" :iend ""
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1337 :isep "\n" :lsep "\n"
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1338 :cbon "@code{[X]}" :cboff "@code{[ ]}")
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
1339 params)))
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1340
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1341 (provide 'org-list)
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1342
98696
7e941d6d7c4c Add arch tagline
Miles Bader <miles@gnu.org>
parents: 98645
diff changeset
1343 ;; arch-tag: 73cf50c1-200f-4d1d-8a53-4e842a5b11c8
98645
8339497a5b87 New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1344 ;;; org-list.el ends here