2016-08-23 16:13:56 -04:00
|
|
|
|
;;; org-list.el --- Plain lists for Org -*- lexical-binding: t; -*-
|
2008-09-23 02:03:13 -04:00
|
|
|
|
;;
|
2020-01-01 13:38:46 -05:00
|
|
|
|
;; Copyright (C) 2004-2020 Free Software Foundation, Inc.
|
2008-09-23 02:03:13 -04:00
|
|
|
|
;;
|
|
|
|
|
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
2013-10-08 02:07:21 -04:00
|
|
|
|
;; Bastien Guerry <bzg@gnu.org>
|
2008-09-23 02:03:13 -04:00
|
|
|
|
;; Keywords: outlines, hypermedia, calendar, wp
|
2018-01-16 11:22:00 -05:00
|
|
|
|
;; Homepage: https://orgmode.org
|
2008-09-23 02:03:13 -04:00
|
|
|
|
;;
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
;;
|
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2008-12-16 11:17:15 -05:00
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2008-09-23 02:03:13 -04:00
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 18:52:52 -04:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2008-09-23 02:03:13 -04:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
;;
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
2016-10-11 12:00:08 -04:00
|
|
|
|
;; This file contains the code dealing with plain lists in Org mode.
|
2008-09-23 02:03:13 -04:00
|
|
|
|
|
2011-08-23 16:17:20 -04:00
|
|
|
|
;; The core concept behind lists is their structure. A structure is
|
|
|
|
|
;; a snapshot of the list, in the shape of a data tree (see
|
|
|
|
|
;; `org-list-struct').
|
2010-12-29 14:16:00 -05:00
|
|
|
|
|
|
|
|
|
;; Once the list structure is stored, it is possible to make changes
|
2011-08-23 16:17:20 -04:00
|
|
|
|
;; on it that will be mirrored to the real list or to get information
|
|
|
|
|
;; about the list, using accessors and methods provided in the
|
2011-08-23 16:19:14 -04:00
|
|
|
|
;; library. Most of them require the use of one or two helper
|
2011-08-23 16:17:20 -04:00
|
|
|
|
;; functions, namely `org-list-parents-alist' and
|
|
|
|
|
;; `org-list-prevs-alist'.
|
2010-12-29 14:16:00 -05:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
;; Structure is eventually applied to the buffer with
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; `org-list-write-struct'. This function repairs (bullets,
|
2011-08-23 16:17:20 -04:00
|
|
|
|
;; indentation, checkboxes) the list in the process. It should be
|
|
|
|
|
;; called near the end of any function working on structures.
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
|
|
|
|
|
;; Thus, a function applying to lists should usually follow this
|
|
|
|
|
;; template:
|
2010-12-29 14:16:00 -05:00
|
|
|
|
|
|
|
|
|
;; 1. Verify point is in a list and grab item beginning (with the same
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; function `org-in-item-p'). If the function requires the cursor
|
2011-08-23 16:17:20 -04:00
|
|
|
|
;; to be at item's bullet, `org-at-item-p' is more selective. It
|
|
|
|
|
;; is also possible to move point to the closest item with
|
|
|
|
|
;; `org-list-search-backward', or `org-list-search-forward',
|
|
|
|
|
;; applied to the function `org-item-beginning-re'.
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
|
|
|
|
|
;; 2. Get list structure with `org-list-struct'.
|
|
|
|
|
|
|
|
|
|
;; 3. Compute one, or both, helper functions,
|
|
|
|
|
;; (`org-list-parents-alist', `org-list-prevs-alist') depending on
|
|
|
|
|
;; needed accessors.
|
|
|
|
|
|
|
|
|
|
;; 4. Proceed with the modifications, using methods and accessors.
|
|
|
|
|
|
|
|
|
|
;; 5. Verify and apply structure to buffer, using
|
2011-08-23 16:17:20 -04:00
|
|
|
|
;; `org-list-write-struct'.
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
|
2011-08-23 16:17:20 -04:00
|
|
|
|
;; 6. If changes made to the list might have modified check-boxes,
|
|
|
|
|
;; call `org-update-checkbox-count-maybe'.
|
|
|
|
|
|
|
|
|
|
;; Computing a structure can be a costly operation on huge lists (a
|
|
|
|
|
;; few thousand lines long). Thus, code should follow the rule:
|
|
|
|
|
;; "collect once, use many". As a corollary, it is usually a bad idea
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
;; to use directly an interactive function inside the code, as those,
|
2012-01-10 05:56:15 -05:00
|
|
|
|
;; being independent entities, read the whole list structure another
|
2010-12-29 14:16:00 -05:00
|
|
|
|
;; time.
|
|
|
|
|
|
2008-09-23 02:03:13 -04:00
|
|
|
|
;;; Code:
|
|
|
|
|
|
2015-11-06 07:04:20 -05:00
|
|
|
|
(require 'cl-lib)
|
2008-09-23 02:03:13 -04:00
|
|
|
|
(require 'org-macs)
|
|
|
|
|
(require 'org-compat)
|
|
|
|
|
|
2011-03-23 16:02:38 -04:00
|
|
|
|
(defvar org-M-RET-may-split-line)
|
2020-05-24 17:43:24 -04:00
|
|
|
|
(defvar org-adapt-indentation)
|
2011-06-05 12:53:58 -04:00
|
|
|
|
(defvar org-auto-align-tags)
|
2008-09-23 02:03:13 -04:00
|
|
|
|
(defvar org-blank-before-new-entry)
|
2011-03-23 16:02:38 -04:00
|
|
|
|
(defvar org-clock-string)
|
|
|
|
|
(defvar org-closed-string)
|
|
|
|
|
(defvar org-deadline-string)
|
2016-07-04 17:52:40 -04:00
|
|
|
|
(defvar org-done-keywords)
|
2015-12-05 03:38:49 -05:00
|
|
|
|
(defvar org-drawer-regexp)
|
|
|
|
|
(defvar org-element-all-objects)
|
|
|
|
|
(defvar org-inhibit-startup)
|
2018-04-29 06:03:17 -04:00
|
|
|
|
(defvar org-loop-over-headlines-in-active-region)
|
2009-08-03 07:28:24 -04:00
|
|
|
|
(defvar org-odd-levels-only)
|
2016-07-04 17:52:40 -04:00
|
|
|
|
(defvar org-outline-regexp-bol)
|
2011-03-23 16:02:38 -04:00
|
|
|
|
(defvar org-scheduled-string)
|
2016-07-04 17:52:40 -04:00
|
|
|
|
(defvar org-todo-line-regexp)
|
2010-09-05 11:58:30 -04:00
|
|
|
|
(defvar org-ts-regexp)
|
|
|
|
|
(defvar org-ts-regexp-both)
|
2008-09-23 02:03:13 -04:00
|
|
|
|
|
2015-06-09 11:14:13 -04:00
|
|
|
|
(declare-function org-at-heading-p "org" (&optional invisible-ok))
|
2010-12-23 16:02:05 -05:00
|
|
|
|
(declare-function org-back-to-heading "org" (&optional invisible-ok))
|
2015-06-09 11:14:13 -04:00
|
|
|
|
(declare-function org-before-first-heading-p "org" ())
|
2011-01-24 15:21:51 -05:00
|
|
|
|
(declare-function org-current-level "org" ())
|
2015-06-09 11:14:13 -04:00
|
|
|
|
(declare-function org-element-at-point "org-element" ())
|
|
|
|
|
(declare-function org-element-context "org-element" (&optional element))
|
2015-12-05 03:38:49 -05:00
|
|
|
|
(declare-function org-element-interpret-data "org-element" (data))
|
2017-12-06 10:22:09 -05:00
|
|
|
|
(declare-function org-element-lineage "org-element" (blob &optional types with-self))
|
2015-12-05 03:38:49 -05:00
|
|
|
|
(declare-function org-element-macro-interpreter "org-element" (macro ##))
|
2017-12-06 10:22:09 -05:00
|
|
|
|
(declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated))
|
2015-12-05 03:38:49 -05:00
|
|
|
|
(declare-function org-element-normalize-string "org-element" (s))
|
2017-12-06 10:22:09 -05:00
|
|
|
|
(declare-function org-element-parse-buffer "org-element" (&optional granularity visible-only))
|
2015-06-09 11:14:13 -04:00
|
|
|
|
(declare-function org-element-property "org-element" (property element))
|
2017-12-06 10:22:09 -05:00
|
|
|
|
(declare-function org-element-put-property "org-element" (element property value))
|
2015-12-05 03:38:49 -05:00
|
|
|
|
(declare-function org-element-set-element "org-element" (old new))
|
2015-06-09 11:14:13 -04:00
|
|
|
|
(declare-function org-element-type "org-element" (element))
|
|
|
|
|
(declare-function org-element-update-syntax "org-element" ())
|
2018-01-15 17:13:51 -05:00
|
|
|
|
(declare-function org-end-of-meta-data "org" (&optional full))
|
2017-12-06 10:22:09 -05:00
|
|
|
|
(declare-function org-entry-get "org" (pom property &optional inherit literal-nil))
|
2016-05-15 19:15:28 -04:00
|
|
|
|
(declare-function org-export-create-backend "ox" (&rest rest) t)
|
|
|
|
|
(declare-function org-export-data-with-backend "ox" (data backend info))
|
|
|
|
|
(declare-function org-export-get-backend "ox" (name))
|
2017-12-06 10:22:09 -05:00
|
|
|
|
(declare-function org-export-get-environment "ox" (&optional backend subtreep ext-plist))
|
|
|
|
|
(declare-function org-export-get-next-element "ox" (blob info &optional n))
|
|
|
|
|
(declare-function org-export-with-backend "ox" (backend data &optional contents info))
|
2011-06-06 14:46:31 -04:00
|
|
|
|
(declare-function org-fix-tags-on-the-fly "org" ())
|
2016-07-04 17:52:40 -04:00
|
|
|
|
(declare-function org-get-todo-state "org" ())
|
2011-07-08 10:12:35 -04:00
|
|
|
|
(declare-function org-in-block-p "org" (names))
|
2015-06-09 11:14:13 -04:00
|
|
|
|
(declare-function org-inlinetask-goto-beginning "org-inlinetask" ())
|
|
|
|
|
(declare-function org-inlinetask-goto-end "org-inlinetask" ())
|
|
|
|
|
(declare-function org-inlinetask-in-task-p "org-inlinetask" ())
|
|
|
|
|
(declare-function org-inlinetask-outline-regexp "org-inlinetask" ())
|
2010-12-23 16:02:05 -05:00
|
|
|
|
(declare-function org-level-increment "org" ())
|
2020-12-13 13:56:29 -05:00
|
|
|
|
(declare-function org-mode "org" ())
|
2010-12-23 16:02:05 -05:00
|
|
|
|
(declare-function org-narrow-to-subtree "org" ())
|
2016-07-04 17:52:40 -04:00
|
|
|
|
(declare-function org-outline-level "org" ())
|
2011-01-24 15:21:51 -05:00
|
|
|
|
(declare-function org-previous-line-empty-p "org" ())
|
2011-05-28 12:16:34 -04:00
|
|
|
|
(declare-function org-reduced-level "org" (L))
|
2018-04-29 06:03:17 -04:00
|
|
|
|
(declare-function org-set-tags "org" (tags))
|
2010-12-23 16:02:05 -05:00
|
|
|
|
(declare-function org-show-subtree "org" ())
|
2013-03-04 04:51:54 -05:00
|
|
|
|
(declare-function org-sort-remove-invisible "org" (S))
|
2017-12-03 02:57:37 -05:00
|
|
|
|
(declare-function org-time-string-to-seconds "org" (s))
|
2010-12-23 16:02:05 -05:00
|
|
|
|
(declare-function org-timer-hms-to-secs "org-timer" (hms))
|
|
|
|
|
(declare-function org-timer-item "org-timer" (&optional arg))
|
2015-06-09 11:14:13 -04:00
|
|
|
|
(declare-function outline-next-heading "outline" ())
|
|
|
|
|
(declare-function outline-previous-heading "outline" ())
|
2008-09-23 02:03:13 -04:00
|
|
|
|
|
2011-08-23 16:17:20 -04:00
|
|
|
|
|
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
;;; Configuration variables
|
|
|
|
|
|
2008-09-23 02:03:13 -04:00
|
|
|
|
(defgroup org-plain-lists nil
|
2016-10-11 12:00:08 -04:00
|
|
|
|
"Options concerning plain lists in Org mode."
|
2008-09-23 02:03:13 -04:00
|
|
|
|
:tag "Org Plain lists"
|
|
|
|
|
:group 'org-structure)
|
|
|
|
|
|
2009-07-01 03:34:13 -04:00
|
|
|
|
(defcustom org-cycle-include-plain-lists t
|
|
|
|
|
"When t, make TAB cycle visibility on plain list items.
|
|
|
|
|
Cycling plain lists works only when the cursor is on a plain list
|
|
|
|
|
item. When the cursor is on an outline heading, plain lists are
|
|
|
|
|
treated as text. This is the most stable way of handling this,
|
|
|
|
|
which is why it is the default.
|
|
|
|
|
|
2013-01-01 10:31:26 -05:00
|
|
|
|
When this is the symbol `integrate', then integrate plain list
|
|
|
|
|
items when cycling, as if they were children of outline headings.
|
|
|
|
|
|
|
|
|
|
This setting can lead to strange effects when switching visibility
|
|
|
|
|
to `children', because the first \"child\" in a subtree decides
|
|
|
|
|
what children should be listed. If that first \"child\" is a
|
|
|
|
|
plain list item with an implied large level number, all true
|
|
|
|
|
children and grand children of the outline heading will be
|
|
|
|
|
exposed in a children' view."
|
2008-09-23 02:03:13 -04:00
|
|
|
|
:group 'org-plain-lists
|
2013-03-14 08:41:06 -04:00
|
|
|
|
:group 'org-cycle
|
2009-07-01 03:34:13 -04:00
|
|
|
|
:type '(choice
|
|
|
|
|
(const :tag "Never" nil)
|
2009-07-01 03:42:24 -04:00
|
|
|
|
(const :tag "With cursor in plain list (recommended)" t)
|
|
|
|
|
(const :tag "As children of outline headings" integrate)))
|
2008-09-23 02:03:13 -04:00
|
|
|
|
|
2009-07-06 02:53:50 -04:00
|
|
|
|
(defcustom org-list-demote-modify-bullet nil
|
|
|
|
|
"Default bullet type installed when demoting an item.
|
|
|
|
|
This is an association list, for each bullet type, this alist will point
|
2010-05-23 01:11:01 -04:00
|
|
|
|
to the bullet that should be used when this item is demoted.
|
|
|
|
|
For example,
|
|
|
|
|
|
|
|
|
|
(setq org-list-demote-modify-bullet
|
2015-09-21 00:24:12 -04:00
|
|
|
|
\\='((\"+\" . \"-\") (\"-\" . \"+\") (\"*\" . \"+\")))
|
2010-05-23 01:11:01 -04:00
|
|
|
|
|
|
|
|
|
will make
|
|
|
|
|
|
|
|
|
|
+ Movies
|
|
|
|
|
+ Silence of the Lambs
|
|
|
|
|
+ My Cousin Vinny
|
|
|
|
|
+ Books
|
|
|
|
|
+ The Hunt for Red October
|
|
|
|
|
+ The Road to Omaha
|
|
|
|
|
|
|
|
|
|
into
|
|
|
|
|
|
|
|
|
|
+ Movies
|
|
|
|
|
- Silence of the Lambs
|
|
|
|
|
- My Cousin Vinny
|
|
|
|
|
+ Books
|
|
|
|
|
- The Hunt for Red October
|
|
|
|
|
- The Road to Omaha"
|
2009-07-06 02:53:50 -04:00
|
|
|
|
:group 'org-plain-lists
|
|
|
|
|
:type '(repeat
|
|
|
|
|
(cons
|
|
|
|
|
(choice :tag "If the current bullet is "
|
|
|
|
|
(const "-")
|
|
|
|
|
(const "+")
|
|
|
|
|
(const "*")
|
|
|
|
|
(const "1.")
|
|
|
|
|
(const "1)"))
|
|
|
|
|
(choice :tag "demotion will change it to"
|
|
|
|
|
(const "-")
|
|
|
|
|
(const "+")
|
|
|
|
|
(const "*")
|
|
|
|
|
(const "1.")
|
|
|
|
|
(const "1)")))))
|
|
|
|
|
|
2008-09-23 02:03:13 -04:00
|
|
|
|
(defcustom org-plain-list-ordered-item-terminator t
|
|
|
|
|
"The character that makes a line with leading number an ordered list item.
|
2019-03-16 14:36:38 -04:00
|
|
|
|
Valid values are ?. and ?\\). To get both terminators, use t.
|
2014-11-09 17:55:27 -05:00
|
|
|
|
|
|
|
|
|
This variable needs to be set before org.el is loaded. If you
|
|
|
|
|
need to make a change while Emacs is running, use the customize
|
|
|
|
|
interface or run the following code after updating it:
|
|
|
|
|
|
2016-10-15 11:36:47 -04:00
|
|
|
|
`\\[org-element-update-syntax]'"
|
2008-09-23 02:03:13 -04:00
|
|
|
|
:group 'org-plain-lists
|
|
|
|
|
:type '(choice (const :tag "dot like in \"2.\"" ?.)
|
|
|
|
|
(const :tag "paren like in \"2)\"" ?\))
|
2014-11-09 17:55:27 -05:00
|
|
|
|
(const :tag "both" t))
|
|
|
|
|
:set (lambda (var val) (set var val)
|
|
|
|
|
(when (featurep 'org-element) (org-element-update-syntax))))
|
2008-09-23 02:03:13 -04:00
|
|
|
|
|
2013-03-14 08:41:06 -04:00
|
|
|
|
(defcustom org-list-allow-alphabetical nil
|
org-list: implement alphabetical lists
* lisp/org-list.el (org-alphabetical-lists): new variable
(org-item-re, org-list-full-item, org-cycle-list-bullet,
org-list-struct-fix-bul, org-list-inc-bullet-maybe): reflect
introduction of the new variable.
(org-item-beginning-re): changed into a function, so any modification
of `org-alphabetical-lists' will not require reloading Org.
(org-at-item-p, org-toggle-checkbox, org-update-checkbox-count,
org-list-parse-list, org-list-send-list): reflect changes to
`org-item-beginning-re'.
(org-list-use-alpha-bul-p): new function.
* lisp/org.el (org-check-for-hidden): reflect changes to
`org-item-beginning-re'.
* lisp/org-capture.el (org-capture-place-item): reflect changes to
`org-item-beginning-re'.
* lisp/org-docbook.el (org-export-docbook-list-line): handle new type
of items.
* lisp/org-exp.el (org-export-mark-list-end,
org-export-mark-list-properties): reflect changes to
`org-item-beginning-re'.
* lisp/org-html.el (org-html-export-list-line): handle new type of
items.
* lisp/org-latex.el (org-export-latex-lists): handle new type of items
and reflect changes to `org-item-beginning-re'.
* lisp/org-ascii.el (org-export-ascii-preprocess): handle new counters.
Modified from a patch by Nathaniel Flath.
2011-01-13 17:25:55 -05:00
|
|
|
|
"Non-nil means single character alphabetical bullets are allowed.
|
2013-04-26 08:13:24 -04:00
|
|
|
|
|
2011-06-28 05:20:56 -04:00
|
|
|
|
Both uppercase and lowercase are handled. Lists with more than
|
|
|
|
|
26 items will fallback to standard numbering. Alphabetical
|
2013-04-26 08:13:24 -04:00
|
|
|
|
counters like \"[@c]\" will be recognized.
|
|
|
|
|
|
|
|
|
|
This variable needs to be set before org.el is loaded. If you
|
|
|
|
|
need to make a change while Emacs is running, use the customize
|
2013-10-04 15:13:23 -04:00
|
|
|
|
interface or run the following code after updating it:
|
2013-04-26 08:13:24 -04:00
|
|
|
|
|
2016-10-15 11:36:47 -04:00
|
|
|
|
`\\[org-element-update-syntax]'"
|
org-list: implement alphabetical lists
* lisp/org-list.el (org-alphabetical-lists): new variable
(org-item-re, org-list-full-item, org-cycle-list-bullet,
org-list-struct-fix-bul, org-list-inc-bullet-maybe): reflect
introduction of the new variable.
(org-item-beginning-re): changed into a function, so any modification
of `org-alphabetical-lists' will not require reloading Org.
(org-at-item-p, org-toggle-checkbox, org-update-checkbox-count,
org-list-parse-list, org-list-send-list): reflect changes to
`org-item-beginning-re'.
(org-list-use-alpha-bul-p): new function.
* lisp/org.el (org-check-for-hidden): reflect changes to
`org-item-beginning-re'.
* lisp/org-capture.el (org-capture-place-item): reflect changes to
`org-item-beginning-re'.
* lisp/org-docbook.el (org-export-docbook-list-line): handle new type
of items.
* lisp/org-exp.el (org-export-mark-list-end,
org-export-mark-list-properties): reflect changes to
`org-item-beginning-re'.
* lisp/org-html.el (org-html-export-list-line): handle new type of
items.
* lisp/org-latex.el (org-export-latex-lists): handle new type of items
and reflect changes to `org-item-beginning-re'.
* lisp/org-ascii.el (org-export-ascii-preprocess): handle new counters.
Modified from a patch by Nathaniel Flath.
2011-01-13 17:25:55 -05:00
|
|
|
|
:group 'org-plain-lists
|
2012-03-19 16:38:12 -04:00
|
|
|
|
:version "24.1"
|
2013-04-26 08:13:24 -04:00
|
|
|
|
:type 'boolean
|
2014-11-09 17:55:27 -05:00
|
|
|
|
:set (lambda (var val) (set var val)
|
|
|
|
|
(when (featurep 'org-element) (org-element-update-syntax))))
|
org-list: implement alphabetical lists
* lisp/org-list.el (org-alphabetical-lists): new variable
(org-item-re, org-list-full-item, org-cycle-list-bullet,
org-list-struct-fix-bul, org-list-inc-bullet-maybe): reflect
introduction of the new variable.
(org-item-beginning-re): changed into a function, so any modification
of `org-alphabetical-lists' will not require reloading Org.
(org-at-item-p, org-toggle-checkbox, org-update-checkbox-count,
org-list-parse-list, org-list-send-list): reflect changes to
`org-item-beginning-re'.
(org-list-use-alpha-bul-p): new function.
* lisp/org.el (org-check-for-hidden): reflect changes to
`org-item-beginning-re'.
* lisp/org-capture.el (org-capture-place-item): reflect changes to
`org-item-beginning-re'.
* lisp/org-docbook.el (org-export-docbook-list-line): handle new type
of items.
* lisp/org-exp.el (org-export-mark-list-end,
org-export-mark-list-properties): reflect changes to
`org-item-beginning-re'.
* lisp/org-html.el (org-html-export-list-line): handle new type of
items.
* lisp/org-latex.el (org-export-latex-lists): handle new type of items
and reflect changes to `org-item-beginning-re'.
* lisp/org-ascii.el (org-export-ascii-preprocess): handle new counters.
Modified from a patch by Nathaniel Flath.
2011-01-13 17:25:55 -05:00
|
|
|
|
|
2008-11-21 00:54:46 -05:00
|
|
|
|
(defcustom org-list-two-spaces-after-bullet-regexp nil
|
|
|
|
|
"A regular expression matching bullets that should have 2 spaces after them.
|
2011-06-28 05:20:56 -04:00
|
|
|
|
When nil, no bullet will have two spaces after them. When
|
|
|
|
|
a string, it will be used as a regular expression. When the
|
2010-07-10 11:02:58 -04:00
|
|
|
|
bullet type of a list is changed, the new bullet type will be
|
2011-06-28 05:20:56 -04:00
|
|
|
|
matched against this regexp. If it matches, there will be two
|
2010-07-17 17:00:22 -04:00
|
|
|
|
spaces instead of one after the bullet in each item of the list."
|
2010-04-21 03:51:30 -04:00
|
|
|
|
:group 'org-plain-lists
|
2008-11-21 00:54:46 -05:00
|
|
|
|
:type '(choice
|
|
|
|
|
(const :tag "never" nil)
|
|
|
|
|
(regexp)))
|
|
|
|
|
|
2012-08-18 03:28:27 -04:00
|
|
|
|
(defcustom org-list-automatic-rules '((checkbox . t)
|
2011-01-06 12:54:30 -05:00
|
|
|
|
(indent . t))
|
2010-07-23 14:36:42 -04:00
|
|
|
|
"Non-nil means apply set of rules when acting on lists.
|
2016-10-15 11:36:47 -04:00
|
|
|
|
\\<org-mode-map>
|
2010-07-23 14:36:42 -04:00
|
|
|
|
By default, automatic actions are taken when using
|
2016-10-15 11:36:47 -04:00
|
|
|
|
`\\[org-meta-return]',
|
|
|
|
|
`\\[org-metaright]',
|
|
|
|
|
`\\[org-metaleft]',
|
|
|
|
|
`\\[org-shiftmetaright]',
|
|
|
|
|
`\\[org-shiftmetaleft]',
|
|
|
|
|
`\\[org-ctrl-c-minus]',
|
|
|
|
|
`\\[org-toggle-checkbox]',
|
|
|
|
|
`\\[org-insert-todo-heading]'.
|
|
|
|
|
|
|
|
|
|
You can disable individually these rules by setting them to nil.
|
|
|
|
|
Valid rules are:
|
2010-07-23 14:36:42 -04:00
|
|
|
|
|
|
|
|
|
checkbox when non-nil, checkbox statistics is updated each time
|
|
|
|
|
you either insert a new checkbox or toggle a checkbox.
|
2010-08-20 05:35:56 -04:00
|
|
|
|
indent when non-nil, indenting or outdenting list top-item
|
|
|
|
|
with its subtree will move the whole list and
|
|
|
|
|
outdenting a list whose bullet is * to column 0 will
|
2011-01-06 12:54:30 -05:00
|
|
|
|
change that bullet to \"-\"."
|
2012-08-11 13:10:44 -04:00
|
|
|
|
:group 'org-plain-lists
|
|
|
|
|
:version "24.1"
|
|
|
|
|
:type '(alist :tag "Sets of rules"
|
|
|
|
|
:key-type
|
|
|
|
|
(choice
|
|
|
|
|
(const :tag "Checkbox" checkbox)
|
|
|
|
|
(const :tag "Indent" indent))
|
|
|
|
|
:value-type
|
|
|
|
|
(boolean :tag "Activate" :value t)))
|
2008-09-23 02:03:13 -04:00
|
|
|
|
|
2011-07-02 14:51:17 -04:00
|
|
|
|
(defcustom org-list-use-circular-motion nil
|
|
|
|
|
"Non-nil means commands implying motion in lists should be cyclic.
|
2016-10-15 11:36:47 -04:00
|
|
|
|
\\<org-mode-map>
|
2011-07-02 14:51:17 -04:00
|
|
|
|
In that case, the item following the last item is the first one,
|
|
|
|
|
and the item preceding the first item is the last one.
|
|
|
|
|
|
2016-10-15 11:36:47 -04:00
|
|
|
|
This affects the behavior of
|
|
|
|
|
`\\[org-move-item-up]',
|
|
|
|
|
`\\[org-move-item-down]',
|
|
|
|
|
`\\[org-next-item]',
|
|
|
|
|
`\\[org-previous-item]'."
|
2011-07-02 14:51:17 -04:00
|
|
|
|
:group 'org-plain-lists
|
2012-03-19 16:38:12 -04:00
|
|
|
|
:version "24.1"
|
2011-07-02 14:51:17 -04:00
|
|
|
|
:type 'boolean)
|
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(defvar org-checkbox-statistics-hook nil
|
|
|
|
|
"Hook that is run whenever Org thinks checkbox statistics should be updated.
|
|
|
|
|
This hook runs even if checkbox rule in
|
|
|
|
|
`org-list-automatic-rules' does not apply, so it can be used to
|
|
|
|
|
implement alternative ways of collecting statistics
|
|
|
|
|
information.")
|
|
|
|
|
|
2013-03-14 08:41:06 -04:00
|
|
|
|
(defcustom org-checkbox-hierarchical-statistics t
|
2010-01-21 10:15:40 -05:00
|
|
|
|
"Non-nil means checkbox statistics counts only the state of direct children.
|
2009-08-18 10:43:55 -04:00
|
|
|
|
When nil, all boxes below the cookie are counted.
|
2009-11-12 07:39:29 -05:00
|
|
|
|
This can be set to nil on a per-node basis using a COOKIE_DATA property
|
2009-08-18 10:43:55 -04:00
|
|
|
|
with the word \"recursive\" in the value."
|
2009-05-08 11:34:40 -04:00
|
|
|
|
:group 'org-plain-lists
|
|
|
|
|
:type 'boolean)
|
|
|
|
|
|
2011-07-10 10:40:26 -04:00
|
|
|
|
(defcustom org-list-indent-offset 0
|
|
|
|
|
"Additional indentation for sub-items in a list.
|
|
|
|
|
By setting this to a small number, usually 1 or 2, one can more
|
|
|
|
|
clearly distinguish sub-items in a list."
|
|
|
|
|
:group 'org-plain-lists
|
2012-03-19 16:38:12 -04:00
|
|
|
|
:version "24.1"
|
2011-07-10 10:40:26 -04:00
|
|
|
|
:type 'integer)
|
|
|
|
|
|
2015-02-03 10:16:54 -05:00
|
|
|
|
(defvar org-list-forbidden-blocks '("example" "verse" "src" "export")
|
2011-01-02 09:57:15 -05:00
|
|
|
|
"Names of blocks where lists are not allowed.
|
|
|
|
|
Names must be in lower case.")
|
|
|
|
|
|
2011-08-23 16:17:20 -04:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
;;; Predicates and regexps
|
2010-12-23 12:54:24 -05:00
|
|
|
|
|
2015-08-14 10:31:16 -04:00
|
|
|
|
(defconst org-list-end-re "^[ \t]*\n[ \t]*\n"
|
|
|
|
|
"Regex matching the end of a plain list.")
|
2008-09-23 02:03:13 -04:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(defconst org-list-full-item-re
|
2011-08-15 12:29:37 -04:00
|
|
|
|
(concat "^[ \t]*\\(\\(?:[-+*]\\|\\(?:[0-9]+\\|[A-Za-z]\\)[.)]\\)\\(?:[ \t]+\\|$\\)\\)"
|
2011-06-30 16:55:05 -04:00
|
|
|
|
"\\(?:\\[@\\(?:start:\\)?\\([0-9]+\\|[A-Za-z]\\)\\][ \t]*\\)?"
|
2011-08-15 12:29:37 -04:00
|
|
|
|
"\\(?:\\(\\[[ X-]\\]\\)\\(?:[ \t]+\\|$\\)\\)?"
|
2011-05-06 20:33:13 -04:00
|
|
|
|
"\\(?:\\(.*\\)[ \t]+::\\(?:[ \t]+\\|$\\)\\)?")
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
"Matches a list item and puts everything into groups:
|
|
|
|
|
group 1: bullet
|
|
|
|
|
group 2: counter
|
|
|
|
|
group 3: checkbox
|
|
|
|
|
group 4: description tag")
|
|
|
|
|
|
org-list: implement alphabetical lists
* lisp/org-list.el (org-alphabetical-lists): new variable
(org-item-re, org-list-full-item, org-cycle-list-bullet,
org-list-struct-fix-bul, org-list-inc-bullet-maybe): reflect
introduction of the new variable.
(org-item-beginning-re): changed into a function, so any modification
of `org-alphabetical-lists' will not require reloading Org.
(org-at-item-p, org-toggle-checkbox, org-update-checkbox-count,
org-list-parse-list, org-list-send-list): reflect changes to
`org-item-beginning-re'.
(org-list-use-alpha-bul-p): new function.
* lisp/org.el (org-check-for-hidden): reflect changes to
`org-item-beginning-re'.
* lisp/org-capture.el (org-capture-place-item): reflect changes to
`org-item-beginning-re'.
* lisp/org-docbook.el (org-export-docbook-list-line): handle new type
of items.
* lisp/org-exp.el (org-export-mark-list-end,
org-export-mark-list-properties): reflect changes to
`org-item-beginning-re'.
* lisp/org-html.el (org-html-export-list-line): handle new type of
items.
* lisp/org-latex.el (org-export-latex-lists): handle new type of items
and reflect changes to `org-item-beginning-re'.
* lisp/org-ascii.el (org-export-ascii-preprocess): handle new counters.
Modified from a patch by Nathaniel Flath.
2011-01-13 17:25:55 -05:00
|
|
|
|
(defun org-item-re ()
|
|
|
|
|
"Return the correct regular expression for plain lists."
|
|
|
|
|
(let ((term (cond
|
|
|
|
|
((eq org-plain-list-ordered-item-terminator t) "[.)]")
|
|
|
|
|
((= org-plain-list-ordered-item-terminator ?\)) ")")
|
|
|
|
|
((= org-plain-list-ordered-item-terminator ?.) "\\.")
|
|
|
|
|
(t "[.)]")))
|
2013-03-23 12:42:09 -04:00
|
|
|
|
(alpha (if org-list-allow-alphabetical "\\|[A-Za-z]" "")))
|
org-list: implement alphabetical lists
* lisp/org-list.el (org-alphabetical-lists): new variable
(org-item-re, org-list-full-item, org-cycle-list-bullet,
org-list-struct-fix-bul, org-list-inc-bullet-maybe): reflect
introduction of the new variable.
(org-item-beginning-re): changed into a function, so any modification
of `org-alphabetical-lists' will not require reloading Org.
(org-at-item-p, org-toggle-checkbox, org-update-checkbox-count,
org-list-parse-list, org-list-send-list): reflect changes to
`org-item-beginning-re'.
(org-list-use-alpha-bul-p): new function.
* lisp/org.el (org-check-for-hidden): reflect changes to
`org-item-beginning-re'.
* lisp/org-capture.el (org-capture-place-item): reflect changes to
`org-item-beginning-re'.
* lisp/org-docbook.el (org-export-docbook-list-line): handle new type
of items.
* lisp/org-exp.el (org-export-mark-list-end,
org-export-mark-list-properties): reflect changes to
`org-item-beginning-re'.
* lisp/org-html.el (org-html-export-list-line): handle new type of
items.
* lisp/org-latex.el (org-export-latex-lists): handle new type of items
and reflect changes to `org-item-beginning-re'.
* lisp/org-ascii.el (org-export-ascii-preprocess): handle new counters.
Modified from a patch by Nathaniel Flath.
2011-01-13 17:25:55 -05:00
|
|
|
|
(concat "\\([ \t]*\\([-+]\\|\\(\\([0-9]+" alpha "\\)" term
|
|
|
|
|
"\\)\\)\\|[ \t]+\\*\\)\\([ \t]+\\|$\\)")))
|
|
|
|
|
|
2011-01-21 10:31:30 -05:00
|
|
|
|
(defsubst org-item-beginning-re ()
|
org-list: implement alphabetical lists
* lisp/org-list.el (org-alphabetical-lists): new variable
(org-item-re, org-list-full-item, org-cycle-list-bullet,
org-list-struct-fix-bul, org-list-inc-bullet-maybe): reflect
introduction of the new variable.
(org-item-beginning-re): changed into a function, so any modification
of `org-alphabetical-lists' will not require reloading Org.
(org-at-item-p, org-toggle-checkbox, org-update-checkbox-count,
org-list-parse-list, org-list-send-list): reflect changes to
`org-item-beginning-re'.
(org-list-use-alpha-bul-p): new function.
* lisp/org.el (org-check-for-hidden): reflect changes to
`org-item-beginning-re'.
* lisp/org-capture.el (org-capture-place-item): reflect changes to
`org-item-beginning-re'.
* lisp/org-docbook.el (org-export-docbook-list-line): handle new type
of items.
* lisp/org-exp.el (org-export-mark-list-end,
org-export-mark-list-properties): reflect changes to
`org-item-beginning-re'.
* lisp/org-html.el (org-html-export-list-line): handle new type of
items.
* lisp/org-latex.el (org-export-latex-lists): handle new type of items
and reflect changes to `org-item-beginning-re'.
* lisp/org-ascii.el (org-export-ascii-preprocess): handle new counters.
Modified from a patch by Nathaniel Flath.
2011-01-13 17:25:55 -05:00
|
|
|
|
"Regexp matching the beginning of a plain list item."
|
|
|
|
|
(concat "^" (org-item-re)))
|
2010-07-20 15:13:37 -04:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(defun org-list-at-regexp-after-bullet-p (regexp)
|
|
|
|
|
"Is point at a list item with REGEXP after bullet?"
|
|
|
|
|
(and (org-at-item-p)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (match-end 0))
|
2011-04-09 10:09:32 -04:00
|
|
|
|
(let ((counter-re (concat "\\(?:\\[@\\(?:start:\\)?"
|
2013-03-23 12:42:09 -04:00
|
|
|
|
(if org-list-allow-alphabetical
|
2011-04-09 10:09:32 -04:00
|
|
|
|
"\\([0-9]+\\|[A-Za-z]\\)"
|
|
|
|
|
"[0-9]+")
|
|
|
|
|
"\\][ \t]*\\)")))
|
|
|
|
|
;; Ignore counter if any
|
|
|
|
|
(when (looking-at counter-re) (goto-char (match-end 0))))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(looking-at regexp))))
|
|
|
|
|
|
2011-03-12 11:26:18 -05:00
|
|
|
|
(defun org-list-in-valid-context-p ()
|
2011-07-08 10:12:35 -04:00
|
|
|
|
"Is point in a context where lists are allowed?"
|
|
|
|
|
(not (org-in-block-p org-list-forbidden-blocks)))
|
2011-03-09 14:30:18 -05:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(defun org-in-item-p ()
|
2012-02-16 17:47:43 -05:00
|
|
|
|
"Return item beginning position when in a plain list, nil otherwise."
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(save-excursion
|
|
|
|
|
(beginning-of-line)
|
2011-01-24 15:06:12 -05:00
|
|
|
|
(let* ((case-fold-search t)
|
|
|
|
|
(context (org-list-context))
|
|
|
|
|
(lim-up (car context))
|
|
|
|
|
(inlinetask-re (and (featurep 'org-inlinetask)
|
|
|
|
|
(org-inlinetask-outline-regexp)))
|
2011-01-24 17:37:35 -05:00
|
|
|
|
(item-re (org-item-re))
|
2011-01-24 15:06:12 -05:00
|
|
|
|
;; Indentation isn't meaningful when point starts at an empty
|
|
|
|
|
;; line or an inline task.
|
|
|
|
|
(ind-ref (if (or (looking-at "^[ \t]*$")
|
|
|
|
|
(and inlinetask-re (looking-at inlinetask-re)))
|
|
|
|
|
10000
|
2018-05-08 19:26:31 -04:00
|
|
|
|
(current-indentation))))
|
2011-01-24 15:06:12 -05:00
|
|
|
|
(cond
|
|
|
|
|
((eq (nth 2 context) 'invalid) nil)
|
2011-01-24 17:37:35 -05:00
|
|
|
|
((looking-at item-re) (point))
|
2011-01-24 15:06:12 -05:00
|
|
|
|
(t
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Detect if cursor in amidst `org-list-end-re'. First, count
|
2011-01-24 15:06:12 -05:00
|
|
|
|
;; number HL of hard lines it takes, then call `org-in-regexp'
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; to compute its boundaries END-BOUNDS. When point is
|
2011-01-24 15:06:12 -05:00
|
|
|
|
;; in-between, move cursor before regexp beginning.
|
|
|
|
|
(let ((hl 0) (i -1) end-bounds)
|
2012-02-16 17:47:43 -05:00
|
|
|
|
(when (and (progn
|
2011-01-24 15:06:12 -05:00
|
|
|
|
(while (setq i (string-match
|
|
|
|
|
"[\r\n]" org-list-end-re (1+ i)))
|
|
|
|
|
(setq hl (1+ hl)))
|
|
|
|
|
(setq end-bounds (org-in-regexp org-list-end-re hl)))
|
|
|
|
|
(>= (point) (car end-bounds))
|
|
|
|
|
(< (point) (cdr end-bounds)))
|
|
|
|
|
(goto-char (car end-bounds))
|
|
|
|
|
(forward-line -1)))
|
2012-02-16 17:47:43 -05:00
|
|
|
|
;; Look for an item, less indented that reference line.
|
2011-01-24 15:06:12 -05:00
|
|
|
|
(catch 'exit
|
|
|
|
|
(while t
|
2018-05-08 19:26:31 -04:00
|
|
|
|
(let ((ind (current-indentation)))
|
2011-01-24 15:06:12 -05:00
|
|
|
|
(cond
|
|
|
|
|
;; This is exactly what we want.
|
2012-02-16 17:47:43 -05:00
|
|
|
|
((and (looking-at item-re) (< ind ind-ref))
|
2011-01-24 15:06:12 -05:00
|
|
|
|
(throw 'exit (point)))
|
|
|
|
|
;; At upper bound of search or looking at the end of a
|
|
|
|
|
;; previous list: search is over.
|
|
|
|
|
((<= (point) lim-up) (throw 'exit nil))
|
2012-02-16 17:47:43 -05:00
|
|
|
|
((looking-at org-list-end-re) (throw 'exit nil))
|
2011-01-24 15:06:12 -05:00
|
|
|
|
;; Skip blocks, drawers, inline-tasks, blank lines
|
2011-03-17 08:01:06 -04:00
|
|
|
|
((and (looking-at "^[ \t]*#\\+end_")
|
|
|
|
|
(re-search-backward "^[ \t]*#\\+begin_" lim-up t)))
|
|
|
|
|
((and (looking-at "^[ \t]*:END:")
|
2013-10-20 08:40:09 -04:00
|
|
|
|
(re-search-backward org-drawer-regexp lim-up t))
|
2011-01-24 15:06:12 -05:00
|
|
|
|
(beginning-of-line))
|
|
|
|
|
((and inlinetask-re (looking-at inlinetask-re))
|
|
|
|
|
(org-inlinetask-goto-beginning)
|
|
|
|
|
(forward-line -1))
|
|
|
|
|
((looking-at "^[ \t]*$") (forward-line -1))
|
|
|
|
|
;; Text at column 0 cannot belong to a list: stop.
|
|
|
|
|
((zerop ind) (throw 'exit nil))
|
|
|
|
|
;; Normal text less indented than reference line, take
|
|
|
|
|
;; it as new reference.
|
|
|
|
|
((< ind ind-ref)
|
|
|
|
|
(setq ind-ref ind)
|
|
|
|
|
(forward-line -1))
|
|
|
|
|
(t (forward-line -1)))))))))))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
|
|
|
|
|
(defun org-at-item-p ()
|
|
|
|
|
"Is point in a line starting a hand-formatted item?"
|
2011-01-24 17:37:35 -05:00
|
|
|
|
(save-excursion
|
|
|
|
|
(beginning-of-line)
|
2011-03-12 11:26:18 -05:00
|
|
|
|
(and (looking-at (org-item-re)) (org-list-in-valid-context-p))))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
|
|
|
|
|
(defun org-at-item-bullet-p ()
|
|
|
|
|
"Is point at the bullet of a plain list item?"
|
|
|
|
|
(and (org-at-item-p)
|
|
|
|
|
(not (member (char-after) '(?\ ?\t)))
|
|
|
|
|
(< (point) (match-end 0))))
|
|
|
|
|
|
|
|
|
|
(defun org-at-item-timer-p ()
|
|
|
|
|
"Is point at a line starting a plain list item with a timer?"
|
|
|
|
|
(org-list-at-regexp-after-bullet-p
|
|
|
|
|
"\\([0-9]+:[0-9]+:[0-9]+\\)[ \t]+::[ \t]+"))
|
|
|
|
|
|
|
|
|
|
(defun org-at-item-description-p ()
|
|
|
|
|
"Is point at a description list item?"
|
2012-06-10 12:35:39 -04:00
|
|
|
|
(org-list-at-regexp-after-bullet-p "\\(\\S-.+\\)[ \t]+::\\([ \t]+\\|$\\)"))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
|
|
|
|
|
(defun org-at-item-checkbox-p ()
|
|
|
|
|
"Is point at a line starting a plain-list item with a checklet?"
|
|
|
|
|
(org-list-at-regexp-after-bullet-p "\\(\\[[- X]\\]\\)[ \t]+"))
|
|
|
|
|
|
|
|
|
|
(defun org-at-item-counter-p ()
|
|
|
|
|
"Is point at a line starting a plain-list item with a counter?"
|
|
|
|
|
(and (org-at-item-p)
|
|
|
|
|
(looking-at org-list-full-item-re)
|
|
|
|
|
(match-string 2)))
|
|
|
|
|
|
|
|
|
|
|
2011-08-23 16:17:20 -04:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
;;; Structures and helper functions
|
2010-12-23 12:54:24 -05:00
|
|
|
|
|
|
|
|
|
(defun org-list-context ()
|
|
|
|
|
"Determine context, and its boundaries, around point.
|
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
Context will be a cell like (MIN MAX CONTEXT) where MIN and MAX
|
2011-01-01 12:27:31 -05:00
|
|
|
|
are boundaries and CONTEXT is a symbol among `drawer', `block',
|
|
|
|
|
`invalid', `inlinetask' and nil.
|
2010-12-23 12:54:24 -05:00
|
|
|
|
|
2011-02-28 16:33:31 -05:00
|
|
|
|
Contexts `block' and `invalid' refer to `org-list-forbidden-blocks'."
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(save-match-data
|
2011-03-01 06:22:13 -05:00
|
|
|
|
(save-excursion
|
2011-03-06 09:48:36 -05:00
|
|
|
|
(org-with-limited-levels
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(let ((case-fold-search t) (pos (point)) beg end context-type
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Get positions of surrounding headings. This is the
|
2011-03-01 06:22:13 -05:00
|
|
|
|
;; default context.
|
2011-03-06 09:48:36 -05:00
|
|
|
|
(lim-up (or (save-excursion (and (ignore-errors (org-back-to-heading t))
|
|
|
|
|
(point)))
|
|
|
|
|
(point-min)))
|
|
|
|
|
(lim-down (or (save-excursion (outline-next-heading)) (point-max))))
|
|
|
|
|
;; Is point inside a drawer?
|
|
|
|
|
(let ((end-re "^[ \t]*:END:")
|
2013-10-20 08:40:09 -04:00
|
|
|
|
(beg-re org-drawer-regexp))
|
2011-03-06 09:48:36 -05:00
|
|
|
|
(when (save-excursion
|
|
|
|
|
(and (not (looking-at beg-re))
|
|
|
|
|
(not (looking-at end-re))
|
|
|
|
|
(setq beg (and (re-search-backward beg-re lim-up t)
|
|
|
|
|
(1+ (point-at-eol))))
|
|
|
|
|
(setq end (or (and (re-search-forward end-re lim-down t)
|
|
|
|
|
(1- (match-beginning 0)))
|
|
|
|
|
lim-down))
|
|
|
|
|
(>= end pos)))
|
|
|
|
|
(setq lim-up beg lim-down end context-type 'drawer)))
|
|
|
|
|
;; Is point strictly in a block, and of which type?
|
|
|
|
|
(let ((block-re "^[ \t]*#\\+\\(begin\\|end\\)_") type)
|
|
|
|
|
(when (save-excursion
|
|
|
|
|
(and (not (looking-at block-re))
|
|
|
|
|
(setq beg (and (re-search-backward block-re lim-up t)
|
|
|
|
|
(1+ (point-at-eol))))
|
|
|
|
|
(looking-at "^[ \t]*#\\+begin_\\(\\S-+\\)")
|
|
|
|
|
(setq type (downcase (match-string 1)))
|
|
|
|
|
(goto-char beg)
|
|
|
|
|
(setq end (or (and (re-search-forward block-re lim-down t)
|
|
|
|
|
(1- (point-at-bol)))
|
|
|
|
|
lim-down))
|
|
|
|
|
(>= end pos)
|
|
|
|
|
(equal (downcase (match-string 1)) "end")))
|
|
|
|
|
(setq lim-up beg lim-down end
|
|
|
|
|
context-type (if (member type org-list-forbidden-blocks)
|
|
|
|
|
'invalid 'block))))
|
|
|
|
|
;; Is point in an inlinetask?
|
|
|
|
|
(when (and (featurep 'org-inlinetask)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let* ((beg-re (org-inlinetask-outline-regexp))
|
|
|
|
|
(end-re (concat beg-re "END[ \t]*$")))
|
|
|
|
|
(and (not (looking-at "^\\*+"))
|
|
|
|
|
(setq beg (and (re-search-backward beg-re lim-up t)
|
|
|
|
|
(1+ (point-at-eol))))
|
|
|
|
|
(not (looking-at end-re))
|
|
|
|
|
(setq end (and (re-search-forward end-re lim-down t)
|
|
|
|
|
(1- (match-beginning 0))))
|
|
|
|
|
(> (point) pos)))))
|
|
|
|
|
(setq lim-up beg lim-down end context-type 'inlinetask))
|
|
|
|
|
;; Return context boundaries and type.
|
|
|
|
|
(list lim-up lim-down context-type))))))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(defun org-list-struct ()
|
|
|
|
|
"Return structure of list at point.
|
2010-07-19 05:21:22 -04:00
|
|
|
|
|
2011-01-26 07:11:39 -05:00
|
|
|
|
A list structure is an alist where key is point at item, and
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
values are:
|
|
|
|
|
1. indentation,
|
|
|
|
|
2. bullet with trailing whitespace,
|
|
|
|
|
3. bullet counter, if any,
|
|
|
|
|
4. checkbox, if any,
|
2011-04-24 05:25:40 -04:00
|
|
|
|
5. description tag, if any,
|
|
|
|
|
6. position at item end.
|
2010-08-28 06:53:19 -04:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
Thus the following list, where numbers in parens are
|
|
|
|
|
point-at-bol:
|
2010-08-28 06:53:19 -04:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
- [X] first item (1)
|
|
|
|
|
1. sub-item 1 (18)
|
|
|
|
|
5. [@5] sub-item 2 (34)
|
|
|
|
|
some other text belonging to first item (55)
|
|
|
|
|
- last item (97)
|
|
|
|
|
+ tag :: description (109)
|
|
|
|
|
(131)
|
2010-07-15 12:28:01 -04:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
will get the following structure:
|
2011-01-20 11:20:16 -05:00
|
|
|
|
|
2015-09-17 19:08:20 -04:00
|
|
|
|
((1 0 \"- \" nil \"[X]\" nil 97)
|
|
|
|
|
(18 2 \"1. \" nil nil nil 34)
|
|
|
|
|
(34 2 \"5. \" \"5\" nil nil 55)
|
|
|
|
|
(97 0 \"- \" nil nil nil 131)
|
|
|
|
|
(109 2 \"+ \" nil nil \"tag\" 131))
|
2010-12-29 14:16:00 -05:00
|
|
|
|
|
2010-12-23 12:54:24 -05:00
|
|
|
|
Assume point is at an item."
|
2010-07-30 18:45:34 -04:00
|
|
|
|
(save-excursion
|
|
|
|
|
(beginning-of-line)
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(let* ((case-fold-search t)
|
|
|
|
|
(context (org-list-context))
|
|
|
|
|
(lim-up (car context))
|
|
|
|
|
(lim-down (nth 1 context))
|
|
|
|
|
(text-min-ind 10000)
|
2011-01-21 10:31:30 -05:00
|
|
|
|
(item-re (org-item-re))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(inlinetask-re (and (featurep 'org-inlinetask)
|
|
|
|
|
(org-inlinetask-outline-regexp)))
|
2018-05-08 19:26:31 -04:00
|
|
|
|
(beg-cell (cons (point) (current-indentation)))
|
2015-05-04 11:32:43 -04:00
|
|
|
|
itm-lst itm-lst-2 end-lst end-lst-2 struct
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(assoc-at-point
|
|
|
|
|
(function
|
2011-01-26 07:11:39 -05:00
|
|
|
|
;; Return association at point.
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(lambda (ind)
|
|
|
|
|
(looking-at org-list-full-item-re)
|
2012-08-18 06:37:39 -04:00
|
|
|
|
(let ((bullet (match-string-no-properties 1)))
|
|
|
|
|
(list (point)
|
|
|
|
|
ind
|
|
|
|
|
bullet
|
|
|
|
|
(match-string-no-properties 2) ; counter
|
|
|
|
|
(match-string-no-properties 3) ; checkbox
|
|
|
|
|
;; Description tag.
|
2016-09-02 21:05:10 -04:00
|
|
|
|
(and (string-match-p "[-+*]" bullet)
|
2012-08-18 06:37:39 -04:00
|
|
|
|
(match-string-no-properties 4)))))))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(end-before-blank
|
|
|
|
|
(function
|
2011-01-26 07:11:39 -05:00
|
|
|
|
;; Ensure list ends at the first blank line.
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(lambda ()
|
|
|
|
|
(skip-chars-backward " \r\t\n")
|
|
|
|
|
(min (1+ (point-at-eol)) lim-down)))))
|
|
|
|
|
;; 1. Read list from starting item to its beginning, and save
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; top item position and indentation in BEG-CELL. Also store
|
2010-12-23 12:54:24 -05:00
|
|
|
|
;; ending position of items in END-LST.
|
|
|
|
|
(save-excursion
|
|
|
|
|
(catch 'exit
|
|
|
|
|
(while t
|
2018-05-08 19:26:31 -04:00
|
|
|
|
(let ((ind (current-indentation)))
|
2010-07-30 18:45:34 -04:00
|
|
|
|
(cond
|
2010-12-23 12:54:24 -05:00
|
|
|
|
((<= (point) lim-up)
|
|
|
|
|
;; At upward limit: if we ended at an item, store it,
|
2012-01-10 05:56:15 -05:00
|
|
|
|
;; else dismiss useless data recorded above BEG-CELL.
|
2010-12-23 12:54:24 -05:00
|
|
|
|
;; Jump to part 2.
|
|
|
|
|
(throw 'exit
|
|
|
|
|
(setq itm-lst
|
2013-01-30 10:06:01 -05:00
|
|
|
|
(if (not (looking-at item-re))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(memq (assq (car beg-cell) itm-lst) itm-lst)
|
|
|
|
|
(setq beg-cell (cons (point) ind))
|
|
|
|
|
(cons (funcall assoc-at-point ind) itm-lst)))))
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Looking at a list ending regexp. Dismiss useless
|
|
|
|
|
;; data recorded above BEG-CELL. Jump to part 2.
|
2012-02-16 17:47:43 -05:00
|
|
|
|
((looking-at org-list-end-re)
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(throw 'exit
|
|
|
|
|
(setq itm-lst
|
|
|
|
|
(memq (assq (car beg-cell) itm-lst) itm-lst))))
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Point is at an item. Add data to ITM-LST. It may
|
|
|
|
|
;; also end a previous item: save it in END-LST. If
|
|
|
|
|
;; ind is less or equal than BEG-CELL and there is no
|
|
|
|
|
;; end at this ind or lesser, this item becomes the new
|
2011-04-24 05:23:01 -04:00
|
|
|
|
;; BEG-CELL.
|
|
|
|
|
((looking-at item-re)
|
|
|
|
|
(push (funcall assoc-at-point ind) itm-lst)
|
|
|
|
|
(push (cons ind (point)) end-lst)
|
2012-02-29 15:04:15 -05:00
|
|
|
|
(when (< ind text-min-ind) (setq beg-cell (cons (point) ind)))
|
2011-04-24 05:23:01 -04:00
|
|
|
|
(forward-line -1))
|
|
|
|
|
;; Skip blocks, drawers, inline tasks, blank lines.
|
2011-03-17 08:01:06 -04:00
|
|
|
|
((and (looking-at "^[ \t]*#\\+end_")
|
|
|
|
|
(re-search-backward "^[ \t]*#\\+begin_" lim-up t)))
|
|
|
|
|
((and (looking-at "^[ \t]*:END:")
|
2013-10-20 08:40:09 -04:00
|
|
|
|
(re-search-backward org-drawer-regexp lim-up t))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(beginning-of-line))
|
|
|
|
|
((and inlinetask-re (looking-at inlinetask-re))
|
|
|
|
|
(org-inlinetask-goto-beginning)
|
|
|
|
|
(forward-line -1))
|
|
|
|
|
((looking-at "^[ \t]*$")
|
|
|
|
|
(forward-line -1))
|
2012-08-11 13:10:44 -04:00
|
|
|
|
;; From there, point is not at an item. Interpret
|
2012-02-16 17:47:43 -05:00
|
|
|
|
;; line's indentation:
|
2011-01-26 07:11:39 -05:00
|
|
|
|
;; - text at column 0 is necessarily out of any list.
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Dismiss data recorded above BEG-CELL. Jump to
|
2011-01-26 07:11:39 -05:00
|
|
|
|
;; part 2.
|
2011-04-24 05:23:01 -04:00
|
|
|
|
;; - any other case may be an ending position for an
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; hypothetical item above. Store it and proceed.
|
2011-01-26 07:11:39 -05:00
|
|
|
|
((zerop ind)
|
|
|
|
|
(throw 'exit
|
|
|
|
|
(setq itm-lst
|
|
|
|
|
(memq (assq (car beg-cell) itm-lst) itm-lst))))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(t
|
2011-01-26 07:11:39 -05:00
|
|
|
|
(when (< ind text-min-ind) (setq text-min-ind ind))
|
|
|
|
|
(push (cons ind (point)) end-lst)
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(forward-line -1)))))))
|
|
|
|
|
;; 2. Read list from starting point to its end, that is until we
|
2011-04-24 05:23:01 -04:00
|
|
|
|
;; get out of context, or that a non-item line is less or
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; equally indented than BEG-CELL's cdr. Also, store ending
|
2011-04-24 05:23:01 -04:00
|
|
|
|
;; position of items in END-LST-2.
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(catch 'exit
|
2012-05-08 03:00:18 -04:00
|
|
|
|
(while t
|
2018-05-08 19:26:31 -04:00
|
|
|
|
(let ((ind (current-indentation)))
|
2012-05-08 03:00:18 -04:00
|
|
|
|
(cond
|
|
|
|
|
((>= (point) lim-down)
|
2010-12-23 12:54:24 -05:00
|
|
|
|
;; At downward limit: this is de facto the end of the
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; list. Save point as an ending position, and jump to
|
2010-12-23 12:54:24 -05:00
|
|
|
|
;; part 3.
|
2012-05-08 03:00:18 -04:00
|
|
|
|
(throw 'exit
|
2011-01-01 12:27:31 -05:00
|
|
|
|
(push (cons 0 (funcall end-before-blank)) end-lst-2)))
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Looking at a list ending regexp. Save point as an
|
2011-01-22 18:32:03 -05:00
|
|
|
|
;; ending position and jump to part 3.
|
2012-02-16 17:47:43 -05:00
|
|
|
|
((looking-at org-list-end-re)
|
2011-01-26 07:11:39 -05:00
|
|
|
|
(throw 'exit (push (cons 0 (point)) end-lst-2)))
|
2011-01-21 10:31:30 -05:00
|
|
|
|
((looking-at item-re)
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Point is at an item. Add data to ITM-LST-2. It may
|
|
|
|
|
;; also end a previous item, so save it in END-LST-2.
|
2011-01-01 12:27:31 -05:00
|
|
|
|
(push (funcall assoc-at-point ind) itm-lst-2)
|
2011-01-26 07:11:39 -05:00
|
|
|
|
(push (cons ind (point)) end-lst-2)
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(forward-line 1))
|
2011-04-24 05:23:01 -04:00
|
|
|
|
;; Skip inline tasks and blank lines along the way
|
|
|
|
|
((and inlinetask-re (looking-at inlinetask-re))
|
|
|
|
|
(org-inlinetask-goto-end))
|
|
|
|
|
((looking-at "^[ \t]*$")
|
|
|
|
|
(forward-line 1))
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Ind is lesser or equal than BEG-CELL's. The list is
|
2011-04-24 05:23:01 -04:00
|
|
|
|
;; over: store point as an ending position and jump to
|
|
|
|
|
;; part 3.
|
2012-02-16 17:47:43 -05:00
|
|
|
|
((<= ind (cdr beg-cell))
|
2011-01-26 07:11:39 -05:00
|
|
|
|
(throw 'exit
|
|
|
|
|
(push (cons 0 (funcall end-before-blank)) end-lst-2)))
|
2011-04-24 05:23:01 -04:00
|
|
|
|
;; Else, if ind is lesser or equal than previous item's,
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; this is an ending position: store it. In any case,
|
2011-04-24 05:23:01 -04:00
|
|
|
|
;; skip block or drawer at point, and move to next line.
|
|
|
|
|
(t
|
2012-02-16 17:47:43 -05:00
|
|
|
|
(when (<= ind (nth 1 (car itm-lst-2)))
|
2011-04-24 05:23:01 -04:00
|
|
|
|
(push (cons ind (point)) end-lst-2))
|
|
|
|
|
(cond
|
|
|
|
|
((and (looking-at "^[ \t]*#\\+begin_")
|
|
|
|
|
(re-search-forward "^[ \t]*#\\+end_" lim-down t)))
|
2013-10-20 08:40:09 -04:00
|
|
|
|
((and (looking-at org-drawer-regexp)
|
2011-04-24 05:23:01 -04:00
|
|
|
|
(re-search-forward "^[ \t]*:END:" lim-down t))))
|
|
|
|
|
(forward-line 1))))))
|
|
|
|
|
(setq struct (append itm-lst (cdr (nreverse itm-lst-2)))
|
|
|
|
|
end-lst (append end-lst (cdr (nreverse end-lst-2))))
|
2011-09-22 13:04:27 -04:00
|
|
|
|
;; 3. Associate each item to its end position.
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(org-list-struct-assoc-end struct end-lst)
|
2011-09-22 13:04:27 -04:00
|
|
|
|
;; 4. Return STRUCT
|
2010-12-23 12:54:24 -05:00
|
|
|
|
struct)))
|
|
|
|
|
|
|
|
|
|
(defun org-list-struct-assoc-end (struct end-list)
|
|
|
|
|
"Associate proper ending point to items in STRUCT.
|
|
|
|
|
|
|
|
|
|
END-LIST is a pseudo-alist where car is indentation and cdr is
|
|
|
|
|
ending position.
|
|
|
|
|
|
|
|
|
|
This function modifies STRUCT."
|
|
|
|
|
(let ((endings end-list))
|
|
|
|
|
(mapc
|
|
|
|
|
(lambda (elt)
|
|
|
|
|
(let ((pos (car elt))
|
|
|
|
|
(ind (nth 1 elt)))
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Remove end candidates behind current item.
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(while (or (<= (cdar endings) pos))
|
|
|
|
|
(pop endings))
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Add end position to item assoc.
|
2010-12-30 12:39:36 -05:00
|
|
|
|
(let ((old-end (nthcdr 6 elt))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(new-end (assoc-default ind endings '<=)))
|
|
|
|
|
(if old-end
|
|
|
|
|
(setcar old-end new-end)
|
|
|
|
|
(setcdr elt (append (cdr elt) (list new-end)))))))
|
|
|
|
|
struct)))
|
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(defun org-list-prevs-alist (struct)
|
2010-12-23 12:54:24 -05:00
|
|
|
|
"Return alist between item and previous item in STRUCT."
|
2010-12-30 12:39:36 -05:00
|
|
|
|
(let ((item-end-alist (mapcar (lambda (e) (cons (car e) (nth 6 e)))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
struct)))
|
|
|
|
|
(mapcar (lambda (e)
|
|
|
|
|
(let ((prev (car (rassq (car e) item-end-alist))))
|
|
|
|
|
(cons (car e) prev)))
|
|
|
|
|
struct)))
|
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(defun org-list-parents-alist (struct)
|
2010-12-23 12:54:24 -05:00
|
|
|
|
"Return alist between item and parent in STRUCT."
|
2011-09-22 13:04:27 -04:00
|
|
|
|
(let* ((ind-to-ori (list (list (nth 1 (car struct)))))
|
|
|
|
|
(top-item (org-list-get-top-point struct))
|
|
|
|
|
(prev-pos (list top-item)))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(cons prev-pos
|
|
|
|
|
(mapcar (lambda (item)
|
|
|
|
|
(let ((pos (car item))
|
|
|
|
|
(ind (nth 1 item))
|
|
|
|
|
(prev-ind (caar ind-to-ori)))
|
2011-01-01 12:27:31 -05:00
|
|
|
|
(push pos prev-pos)
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(cond
|
|
|
|
|
((> prev-ind ind)
|
2011-09-22 13:04:27 -04:00
|
|
|
|
;; A sub-list is over. Find the associated
|
|
|
|
|
;; origin in IND-TO-ORI. If it cannot be
|
|
|
|
|
;; found (ill-formed list), set its parent as
|
|
|
|
|
;; the first item less indented. If there is
|
|
|
|
|
;; none, make it a top-level item.
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(setq ind-to-ori
|
2011-09-22 13:04:27 -04:00
|
|
|
|
(or (member (assq ind ind-to-ori) ind-to-ori)
|
|
|
|
|
(catch 'exit
|
|
|
|
|
(mapc
|
|
|
|
|
(lambda (e)
|
|
|
|
|
(when (< (car e) ind)
|
|
|
|
|
(throw 'exit (member e ind-to-ori))))
|
|
|
|
|
ind-to-ori)
|
|
|
|
|
(list (list ind)))))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(cons pos (cdar ind-to-ori)))
|
2011-09-22 13:04:27 -04:00
|
|
|
|
;; A sub-list starts. Every item at IND will
|
|
|
|
|
;; have previous item as its parent.
|
2010-12-23 12:54:24 -05:00
|
|
|
|
((< prev-ind ind)
|
|
|
|
|
(let ((origin (nth 1 prev-pos)))
|
2011-01-01 12:27:31 -05:00
|
|
|
|
(push (cons ind origin) ind-to-ori)
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(cons pos origin)))
|
2011-09-22 13:04:27 -04:00
|
|
|
|
;; Another item in the same sub-list: it shares
|
|
|
|
|
;; the same parent as the previous item.
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(t (cons pos (cdar ind-to-ori))))))
|
|
|
|
|
(cdr struct)))))
|
|
|
|
|
|
2018-03-17 06:32:40 -04:00
|
|
|
|
(defun org-list--delete-metadata ()
|
|
|
|
|
"Delete metadata from the heading at point.
|
|
|
|
|
Metadata are tags, planning information and properties drawers."
|
|
|
|
|
(save-match-data
|
|
|
|
|
(org-with-wide-buffer
|
2018-04-20 04:45:19 -04:00
|
|
|
|
(org-set-tags nil)
|
2018-03-17 06:32:40 -04:00
|
|
|
|
(delete-region (line-beginning-position 2)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(org-end-of-meta-data)
|
|
|
|
|
(org-skip-whitespace)
|
|
|
|
|
(if (eobp) (point) (line-beginning-position)))))))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
|
2011-08-23 16:17:20 -04:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
;;; Accessors
|
|
|
|
|
|
2011-01-21 10:31:30 -05:00
|
|
|
|
(defsubst org-list-get-nth (n key struct)
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
"Return the Nth value of KEY in STRUCT."
|
|
|
|
|
(nth n (assq key struct)))
|
|
|
|
|
|
|
|
|
|
(defun org-list-set-nth (n key struct new)
|
|
|
|
|
"Set the Nth value of KEY in STRUCT to NEW.
|
|
|
|
|
\nThis function modifies STRUCT."
|
|
|
|
|
(setcar (nthcdr n (assq key struct)) new))
|
|
|
|
|
|
2011-01-21 10:31:30 -05:00
|
|
|
|
(defsubst org-list-get-ind (item struct)
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
"Return indentation of ITEM in STRUCT."
|
|
|
|
|
(org-list-get-nth 1 item struct))
|
|
|
|
|
|
|
|
|
|
(defun org-list-set-ind (item struct ind)
|
|
|
|
|
"Set indentation of ITEM in STRUCT to IND.
|
|
|
|
|
\nThis function modifies STRUCT."
|
|
|
|
|
(org-list-set-nth 1 item struct ind))
|
|
|
|
|
|
2011-01-21 10:31:30 -05:00
|
|
|
|
(defsubst org-list-get-bullet (item struct)
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
"Return bullet of ITEM in STRUCT."
|
|
|
|
|
(org-list-get-nth 2 item struct))
|
|
|
|
|
|
|
|
|
|
(defun org-list-set-bullet (item struct bullet)
|
|
|
|
|
"Set bullet of ITEM in STRUCT to BULLET.
|
|
|
|
|
\nThis function modifies STRUCT."
|
|
|
|
|
(org-list-set-nth 2 item struct bullet))
|
|
|
|
|
|
2011-01-21 10:31:30 -05:00
|
|
|
|
(defsubst org-list-get-counter (item struct)
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
"Return counter of ITEM in STRUCT."
|
|
|
|
|
(org-list-get-nth 3 item struct))
|
|
|
|
|
|
2011-01-21 10:31:30 -05:00
|
|
|
|
(defsubst org-list-get-checkbox (item struct)
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
"Return checkbox of ITEM in STRUCT or nil."
|
|
|
|
|
(org-list-get-nth 4 item struct))
|
|
|
|
|
|
|
|
|
|
(defun org-list-set-checkbox (item struct checkbox)
|
|
|
|
|
"Set checkbox of ITEM in STRUCT to CHECKBOX.
|
|
|
|
|
\nThis function modifies STRUCT."
|
|
|
|
|
(org-list-set-nth 4 item struct checkbox))
|
|
|
|
|
|
2011-01-21 10:31:30 -05:00
|
|
|
|
(defsubst org-list-get-tag (item struct)
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
"Return end position of ITEM in STRUCT."
|
|
|
|
|
(org-list-get-nth 5 item struct))
|
|
|
|
|
|
|
|
|
|
(defun org-list-get-item-end (item struct)
|
|
|
|
|
"Return end position of ITEM in STRUCT."
|
|
|
|
|
(org-list-get-nth 6 item struct))
|
|
|
|
|
|
|
|
|
|
(defun org-list-get-item-end-before-blank (item struct)
|
|
|
|
|
"Return point at end of ITEM in STRUCT, before any blank line.
|
|
|
|
|
Point returned is at end of line."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (org-list-get-item-end item struct))
|
|
|
|
|
(skip-chars-backward " \r\t\n")
|
|
|
|
|
(point-at-eol)))
|
|
|
|
|
|
2010-12-28 19:43:20 -05:00
|
|
|
|
(defun org-list-get-parent (item struct parents)
|
2011-02-18 07:41:49 -05:00
|
|
|
|
"Return parent of ITEM or nil.
|
2011-06-28 05:20:56 -04:00
|
|
|
|
STRUCT is the list structure. PARENTS is the alist of parents,
|
|
|
|
|
as returned by `org-list-parents-alist'."
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(let ((parents (or parents (org-list-parents-alist struct))))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(cdr (assq item parents))))
|
|
|
|
|
|
2010-12-28 19:43:20 -05:00
|
|
|
|
(defun org-list-has-child-p (item struct)
|
2011-02-18 07:41:49 -05:00
|
|
|
|
"Non-nil if ITEM has a child.
|
|
|
|
|
|
|
|
|
|
STRUCT is the list structure.
|
|
|
|
|
|
2010-12-29 14:16:00 -05:00
|
|
|
|
Value returned is the position of the first child of ITEM."
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(let ((ind (org-list-get-ind item struct))
|
|
|
|
|
(child-maybe (car (nth 1 (member (assq item struct) struct)))))
|
2010-12-23 18:53:30 -05:00
|
|
|
|
(when (and child-maybe
|
|
|
|
|
(< ind (org-list-get-ind child-maybe struct)))
|
|
|
|
|
child-maybe)))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
|
2015-05-04 11:32:43 -04:00
|
|
|
|
(defun org-list-get-next-item (item _struct prevs)
|
2011-02-18 07:41:49 -05:00
|
|
|
|
"Return next item in same sub-list as ITEM, or nil.
|
2011-06-28 05:20:56 -04:00
|
|
|
|
STRUCT is the list structure. PREVS is the alist of previous
|
2011-02-18 07:41:49 -05:00
|
|
|
|
items, as returned by `org-list-prevs-alist'."
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(car (rassq item prevs)))
|
|
|
|
|
|
2015-05-04 11:32:43 -04:00
|
|
|
|
(defun org-list-get-prev-item (item _struct prevs)
|
2011-02-18 07:41:49 -05:00
|
|
|
|
"Return previous item in same sub-list as ITEM, or nil.
|
2011-06-28 05:20:56 -04:00
|
|
|
|
STRUCT is the list structure. PREVS is the alist of previous
|
2011-02-18 07:41:49 -05:00
|
|
|
|
items, as returned by `org-list-prevs-alist'."
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(cdr (assq item prevs)))
|
|
|
|
|
|
|
|
|
|
(defun org-list-get-subtree (item struct)
|
2011-02-18 07:41:49 -05:00
|
|
|
|
"List all items having ITEM as a common ancestor, or nil.
|
|
|
|
|
STRUCT is the list structure."
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(let* ((item-end (org-list-get-item-end item struct))
|
|
|
|
|
(sub-struct (cdr (member (assq item struct) struct)))
|
2020-05-01 09:51:43 -04:00
|
|
|
|
items)
|
|
|
|
|
(catch :exit
|
|
|
|
|
(pcase-dolist (`(,pos . ,_) sub-struct)
|
|
|
|
|
(if (< pos item-end)
|
|
|
|
|
(push pos items)
|
|
|
|
|
(throw :exit nil))))
|
|
|
|
|
(nreverse items)))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
|
|
|
|
|
(defun org-list-get-all-items (item struct prevs)
|
2011-02-18 07:41:49 -05:00
|
|
|
|
"List all items in the same sub-list as ITEM.
|
2011-06-28 05:20:56 -04:00
|
|
|
|
STRUCT is the list structure. PREVS is the alist of previous
|
2011-02-18 07:41:49 -05:00
|
|
|
|
items, as returned by `org-list-prevs-alist'."
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(let ((prev-item item)
|
|
|
|
|
(next-item item)
|
|
|
|
|
before-item after-item)
|
|
|
|
|
(while (setq prev-item (org-list-get-prev-item prev-item struct prevs))
|
2010-12-28 19:43:20 -05:00
|
|
|
|
(push prev-item before-item))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(while (setq next-item (org-list-get-next-item next-item struct prevs))
|
2010-12-28 19:43:20 -05:00
|
|
|
|
(push next-item after-item))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(append before-item (list item) (nreverse after-item))))
|
|
|
|
|
|
2015-05-04 11:32:43 -04:00
|
|
|
|
(defun org-list-get-children (item _struct parents)
|
2011-02-18 07:41:49 -05:00
|
|
|
|
"List all children of ITEM, or nil.
|
2011-08-23 15:26:51 -04:00
|
|
|
|
STRUCT is the list structure. PARENTS is the alist of parents,
|
|
|
|
|
as returned by `org-list-parents-alist'."
|
2011-01-24 15:21:51 -05:00
|
|
|
|
(let (all child)
|
2010-12-28 19:43:20 -05:00
|
|
|
|
(while (setq child (car (rassq item parents)))
|
2011-01-01 12:27:31 -05:00
|
|
|
|
(setq parents (cdr (member (assq child parents) parents)))
|
|
|
|
|
(push child all))
|
2010-12-28 19:43:20 -05:00
|
|
|
|
(nreverse all)))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
|
|
|
|
|
(defun org-list-get-top-point (struct)
|
|
|
|
|
"Return point at beginning of list.
|
2011-02-18 07:41:49 -05:00
|
|
|
|
STRUCT is the list structure."
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(caar struct))
|
|
|
|
|
|
|
|
|
|
(defun org-list-get-bottom-point (struct)
|
|
|
|
|
"Return point at bottom of list.
|
2011-02-18 07:41:49 -05:00
|
|
|
|
STRUCT is the list structure."
|
2015-05-04 11:32:43 -04:00
|
|
|
|
(apply #'max
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(mapcar (lambda (e) (org-list-get-item-end (car e) struct)) struct)))
|
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(defun org-list-get-list-begin (item struct prevs)
|
|
|
|
|
"Return point at beginning of sub-list ITEM belongs.
|
2011-06-28 05:20:56 -04:00
|
|
|
|
STRUCT is the list structure. PREVS is the alist of previous
|
2011-02-18 07:41:49 -05:00
|
|
|
|
items, as returned by `org-list-prevs-alist'."
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(let ((first-item item) prev-item)
|
|
|
|
|
(while (setq prev-item (org-list-get-prev-item first-item struct prevs))
|
|
|
|
|
(setq first-item prev-item))
|
|
|
|
|
first-item))
|
|
|
|
|
|
|
|
|
|
(defalias 'org-list-get-first-item 'org-list-get-list-begin)
|
|
|
|
|
|
|
|
|
|
(defun org-list-get-last-item (item struct prevs)
|
|
|
|
|
"Return point at last item of sub-list ITEM belongs.
|
2011-06-28 05:20:56 -04:00
|
|
|
|
STRUCT is the list structure. PREVS is the alist of previous
|
2011-02-18 07:41:49 -05:00
|
|
|
|
items, as returned by `org-list-prevs-alist'."
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(let ((last-item item) next-item)
|
|
|
|
|
(while (setq next-item (org-list-get-next-item last-item struct prevs))
|
|
|
|
|
(setq last-item next-item))
|
|
|
|
|
last-item))
|
|
|
|
|
|
|
|
|
|
(defun org-list-get-list-end (item struct prevs)
|
|
|
|
|
"Return point at end of sub-list ITEM belongs.
|
2011-06-28 05:20:56 -04:00
|
|
|
|
STRUCT is the list structure. PREVS is the alist of previous
|
2011-02-18 07:41:49 -05:00
|
|
|
|
items, as returned by `org-list-prevs-alist'."
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(org-list-get-item-end (org-list-get-last-item item struct prevs) struct))
|
|
|
|
|
|
|
|
|
|
(defun org-list-get-list-type (item struct prevs)
|
2011-02-18 07:41:49 -05:00
|
|
|
|
"Return the type of the list containing ITEM, as a symbol.
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
|
2011-06-28 05:20:56 -04:00
|
|
|
|
STRUCT is the list structure. PREVS is the alist of previous
|
2011-02-18 07:41:49 -05:00
|
|
|
|
items, as returned by `org-list-prevs-alist'.
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
|
2011-06-28 05:20:56 -04:00
|
|
|
|
Possible types are `descriptive', `ordered' and `unordered'. The
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
type is determined by the first item of the list."
|
|
|
|
|
(let ((first (org-list-get-list-begin item struct prevs)))
|
|
|
|
|
(cond
|
2016-09-02 21:05:10 -04:00
|
|
|
|
((string-match-p "[[:alnum:]]" (org-list-get-bullet first struct)) 'ordered)
|
2012-08-18 03:28:27 -04:00
|
|
|
|
((org-list-get-tag first struct) 'descriptive)
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(t 'unordered))))
|
|
|
|
|
|
2012-03-19 16:38:12 -04:00
|
|
|
|
(defun org-list-get-item-number (item struct prevs parents)
|
|
|
|
|
"Return ITEM's sequence number.
|
|
|
|
|
|
|
|
|
|
STRUCT is the list structure. PREVS is the alist of previous
|
|
|
|
|
items, as returned by `org-list-prevs-alist'. PARENTS is the
|
|
|
|
|
alist of ancestors, as returned by `org-list-parents-alist'.
|
|
|
|
|
|
|
|
|
|
Return value is a list of integers. Counters have an impact on
|
|
|
|
|
that value."
|
|
|
|
|
(let ((get-relative-number
|
|
|
|
|
(function
|
|
|
|
|
(lambda (item struct prevs)
|
|
|
|
|
;; Return relative sequence number of ITEM in the sub-list
|
|
|
|
|
;; it belongs. STRUCT is the list structure. PREVS is
|
|
|
|
|
;; the alist of previous items.
|
|
|
|
|
(let ((seq 0) (pos item) counter)
|
|
|
|
|
(while (and (not (setq counter (org-list-get-counter pos struct)))
|
|
|
|
|
(setq pos (org-list-get-prev-item pos struct prevs)))
|
2015-12-05 03:41:14 -05:00
|
|
|
|
(cl-incf seq))
|
2012-03-19 16:38:12 -04:00
|
|
|
|
(if (not counter) (1+ seq)
|
|
|
|
|
(cond
|
|
|
|
|
((string-match "[A-Za-z]" counter)
|
|
|
|
|
(+ (- (string-to-char (upcase (match-string 0 counter))) 64)
|
|
|
|
|
seq))
|
|
|
|
|
((string-match "[0-9]+" counter)
|
|
|
|
|
(+ (string-to-number (match-string 0 counter)) seq))
|
|
|
|
|
(t (1+ seq)))))))))
|
|
|
|
|
;; Cons each parent relative number into return value (OUT).
|
|
|
|
|
(let ((out (list (funcall get-relative-number item struct prevs)))
|
|
|
|
|
(parent item))
|
|
|
|
|
(while (setq parent (org-list-get-parent parent struct parents))
|
|
|
|
|
(push (funcall get-relative-number parent struct prevs) out))
|
|
|
|
|
;; Return value.
|
|
|
|
|
out)))
|
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
|
2011-08-23 16:17:20 -04:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
;;; Searching
|
|
|
|
|
|
|
|
|
|
(defun org-list-search-generic (search re bound noerr)
|
|
|
|
|
"Search a string in valid contexts for lists.
|
2011-02-18 07:41:49 -05:00
|
|
|
|
Arguments SEARCH, RE, BOUND and NOERR are similar to those used
|
|
|
|
|
in `re-search-forward'."
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(catch 'exit
|
|
|
|
|
(let ((origin (point)))
|
|
|
|
|
(while t
|
|
|
|
|
;; 1. No match: return to origin or bound, depending on NOERR.
|
|
|
|
|
(unless (funcall search re bound noerr)
|
|
|
|
|
(throw 'exit (and (goto-char (if (memq noerr '(t nil)) origin bound))
|
|
|
|
|
nil)))
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; 2. Match in valid context: return point. Else, continue
|
2011-03-09 14:30:18 -05:00
|
|
|
|
;; searching.
|
2011-03-12 11:26:18 -05:00
|
|
|
|
(when (org-list-in-valid-context-p) (throw 'exit (point)))))))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
|
|
|
|
|
(defun org-list-search-backward (regexp &optional bound noerror)
|
|
|
|
|
"Like `re-search-backward' but stop only where lists are recognized.
|
|
|
|
|
Arguments REGEXP, BOUND and NOERROR are similar to those used in
|
|
|
|
|
`re-search-backward'."
|
|
|
|
|
(org-list-search-generic #'re-search-backward
|
|
|
|
|
regexp (or bound (point-min)) noerror))
|
|
|
|
|
|
|
|
|
|
(defun org-list-search-forward (regexp &optional bound noerror)
|
|
|
|
|
"Like `re-search-forward' but stop only where lists are recognized.
|
|
|
|
|
Arguments REGEXP, BOUND and NOERROR are similar to those used in
|
|
|
|
|
`re-search-forward'."
|
|
|
|
|
(org-list-search-generic #'re-search-forward
|
|
|
|
|
regexp (or bound (point-max)) noerror))
|
|
|
|
|
|
|
|
|
|
|
2011-08-23 16:17:20 -04:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
;;; Methods on structures
|
|
|
|
|
|
2011-01-24 15:21:51 -05:00
|
|
|
|
(defsubst org-list-bullet-string (bullet)
|
|
|
|
|
"Return BULLET with the correct number of whitespaces.
|
|
|
|
|
It determines the number of whitespaces to append by looking at
|
|
|
|
|
`org-list-two-spaces-after-bullet-regexp'."
|
|
|
|
|
(save-match-data
|
|
|
|
|
(let ((spaces (if (and org-list-two-spaces-after-bullet-regexp
|
|
|
|
|
(string-match
|
|
|
|
|
org-list-two-spaces-after-bullet-regexp bullet))
|
|
|
|
|
" "
|
|
|
|
|
" ")))
|
2013-02-15 17:09:10 -05:00
|
|
|
|
(if (string-match "\\S-+\\([ \t]*\\)" bullet)
|
|
|
|
|
(replace-match spaces nil nil bullet 1)
|
|
|
|
|
bullet))))
|
2011-01-24 15:21:51 -05:00
|
|
|
|
|
2011-07-11 10:49:31 -04:00
|
|
|
|
(defun org-list-swap-items (beg-A beg-B struct)
|
|
|
|
|
"Swap item starting at BEG-A with item starting at BEG-B in STRUCT.
|
2012-05-07 16:34:16 -04:00
|
|
|
|
|
|
|
|
|
Blank lines at the end of items are left in place. Item
|
|
|
|
|
visibility is preserved. Return the new structure after the
|
|
|
|
|
changes.
|
2011-07-11 10:49:31 -04:00
|
|
|
|
|
|
|
|
|
Assume BEG-A is lesser than BEG-B and that BEG-A and BEG-B belong
|
|
|
|
|
to the same sub-list.
|
|
|
|
|
|
|
|
|
|
This function modifies STRUCT."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let* ((end-A-no-blank (org-list-get-item-end-before-blank beg-A struct))
|
|
|
|
|
(end-B-no-blank (org-list-get-item-end-before-blank beg-B struct))
|
|
|
|
|
(end-A (org-list-get-item-end beg-A struct))
|
|
|
|
|
(end-B (org-list-get-item-end beg-B struct))
|
|
|
|
|
(size-A (- end-A-no-blank beg-A))
|
|
|
|
|
(size-B (- end-B-no-blank beg-B))
|
|
|
|
|
(body-A (buffer-substring beg-A end-A-no-blank))
|
|
|
|
|
(body-B (buffer-substring beg-B end-B-no-blank))
|
|
|
|
|
(between-A-no-blank-and-B (buffer-substring end-A-no-blank beg-B))
|
|
|
|
|
(sub-A (cons beg-A (org-list-get-subtree beg-A struct)))
|
2012-05-07 16:34:16 -04:00
|
|
|
|
(sub-B (cons beg-B (org-list-get-subtree beg-B struct)))
|
2012-05-08 03:00:18 -04:00
|
|
|
|
;; Store overlays responsible for visibility status. We
|
|
|
|
|
;; also need to store their boundaries as they will be
|
|
|
|
|
;; removed from buffer.
|
2015-01-29 18:20:01 -05:00
|
|
|
|
(overlays
|
|
|
|
|
(cons
|
|
|
|
|
(delq nil
|
|
|
|
|
(mapcar (lambda (o)
|
|
|
|
|
(and (>= (overlay-start o) beg-A)
|
|
|
|
|
(<= (overlay-end o) end-A)
|
|
|
|
|
(list o (overlay-start o) (overlay-end o))))
|
|
|
|
|
(overlays-in beg-A end-A)))
|
|
|
|
|
(delq nil
|
|
|
|
|
(mapcar (lambda (o)
|
|
|
|
|
(and (>= (overlay-start o) beg-B)
|
|
|
|
|
(<= (overlay-end o) end-B)
|
|
|
|
|
(list o (overlay-start o) (overlay-end o))))
|
|
|
|
|
(overlays-in beg-B end-B))))))
|
2011-07-11 10:49:31 -04:00
|
|
|
|
;; 1. Move effectively items in buffer.
|
|
|
|
|
(goto-char beg-A)
|
|
|
|
|
(delete-region beg-A end-B-no-blank)
|
|
|
|
|
(insert (concat body-B between-A-no-blank-and-B body-A))
|
|
|
|
|
;; 2. Now modify struct. No need to re-read the list, the
|
|
|
|
|
;; transformation is just a shift of positions. Some special
|
|
|
|
|
;; attention is required for items ending at END-A and END-B
|
|
|
|
|
;; as empty spaces are not moved there. In others words,
|
|
|
|
|
;; item BEG-A will end with whitespaces that were at the end
|
|
|
|
|
;; of BEG-B and the same applies to BEG-B.
|
2015-01-29 18:20:01 -05:00
|
|
|
|
(dolist (e struct)
|
|
|
|
|
(let ((pos (car e)))
|
|
|
|
|
(cond
|
|
|
|
|
((< pos beg-A))
|
|
|
|
|
((memq pos sub-A)
|
|
|
|
|
(let ((end-e (nth 6 e)))
|
|
|
|
|
(setcar e (+ pos (- end-B-no-blank end-A-no-blank)))
|
|
|
|
|
(setcar (nthcdr 6 e)
|
|
|
|
|
(+ end-e (- end-B-no-blank end-A-no-blank)))
|
|
|
|
|
(when (= end-e end-A) (setcar (nthcdr 6 e) end-B))))
|
|
|
|
|
((memq pos sub-B)
|
|
|
|
|
(let ((end-e (nth 6 e)))
|
|
|
|
|
(setcar e (- (+ pos beg-A) beg-B))
|
|
|
|
|
(setcar (nthcdr 6 e) (+ end-e (- beg-A beg-B)))
|
|
|
|
|
(when (= end-e end-B)
|
|
|
|
|
(setcar (nthcdr 6 e)
|
|
|
|
|
(+ beg-A size-B (- end-A end-A-no-blank))))))
|
|
|
|
|
((< pos beg-B)
|
|
|
|
|
(let ((end-e (nth 6 e)))
|
|
|
|
|
(setcar e (+ pos (- size-B size-A)))
|
|
|
|
|
(setcar (nthcdr 6 e) (+ end-e (- size-B size-A))))))))
|
|
|
|
|
(setq struct (sort struct #'car-less-than-car))
|
2012-05-08 03:00:18 -04:00
|
|
|
|
;; Restore visibility status, by moving overlays to their new
|
|
|
|
|
;; position.
|
2015-01-29 18:20:01 -05:00
|
|
|
|
(dolist (ov (car overlays))
|
|
|
|
|
(move-overlay
|
|
|
|
|
(car ov)
|
|
|
|
|
(+ (nth 1 ov) (- (+ beg-B (- size-B size-A)) beg-A))
|
|
|
|
|
(+ (nth 2 ov) (- (+ beg-B (- size-B size-A)) beg-A))))
|
|
|
|
|
(dolist (ov (cdr overlays))
|
|
|
|
|
(move-overlay (car ov)
|
|
|
|
|
(+ (nth 1 ov) (- beg-A beg-B))
|
|
|
|
|
(+ (nth 2 ov) (- beg-A beg-B))))
|
2012-05-07 16:34:16 -04:00
|
|
|
|
;; Return structure.
|
|
|
|
|
struct)))
|
2011-07-11 10:49:31 -04:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(defun org-list-separating-blank-lines-number (pos struct prevs)
|
|
|
|
|
"Return number of blank lines that should separate items in list.
|
2011-02-18 07:41:49 -05:00
|
|
|
|
|
2011-05-15 16:38:56 -04:00
|
|
|
|
POS is the position of point where `org-list-insert-item' was called.
|
2011-02-18 07:41:49 -05:00
|
|
|
|
|
2011-06-28 05:20:56 -04:00
|
|
|
|
STRUCT is the list structure. PREVS is the alist of previous
|
2011-02-18 07:41:49 -05:00
|
|
|
|
items, as returned by `org-list-prevs-alist'.
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
|
2011-06-28 05:20:56 -04:00
|
|
|
|
Assume point is at item's beginning. If the item is alone, apply
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
some heuristics to guess the result."
|
|
|
|
|
(save-excursion
|
2011-05-15 16:38:56 -04:00
|
|
|
|
(let ((item (point))
|
|
|
|
|
(insert-blank-p
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(cdr (assq 'plain-list-item org-blank-before-new-entry)))
|
2011-08-21 15:31:58 -04:00
|
|
|
|
usr-blank
|
|
|
|
|
(count-blanks
|
|
|
|
|
(function
|
|
|
|
|
(lambda ()
|
|
|
|
|
;; Count blank lines above beginning of line.
|
|
|
|
|
(save-excursion
|
|
|
|
|
(count-lines (goto-char (point-at-bol))
|
|
|
|
|
(progn (skip-chars-backward " \r\t\n")
|
|
|
|
|
(forward-line)
|
|
|
|
|
(point))))))))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(cond
|
|
|
|
|
;; Trivial cases where there should be none.
|
2015-08-14 10:31:16 -04:00
|
|
|
|
((not insert-blank-p) 0)
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
;; When `org-blank-before-new-entry' says so, it is 1.
|
|
|
|
|
((eq insert-blank-p t) 1)
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; `plain-list-item' is 'auto. Count blank lines separating
|
2014-01-12 03:54:21 -05:00
|
|
|
|
;; neighbors' items in list.
|
2011-05-15 16:38:56 -04:00
|
|
|
|
(t (let ((next-p (org-list-get-next-item item struct prevs)))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(cond
|
|
|
|
|
;; Is there a next item?
|
|
|
|
|
(next-p (goto-char next-p)
|
2011-08-21 15:31:58 -04:00
|
|
|
|
(funcall count-blanks))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
;; Is there a previous item?
|
2011-05-15 16:38:56 -04:00
|
|
|
|
((org-list-get-prev-item item struct prevs)
|
2011-08-21 15:31:58 -04:00
|
|
|
|
(funcall count-blanks))
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; User inserted blank lines, trust him.
|
2011-05-15 16:38:56 -04:00
|
|
|
|
((and (> pos (org-list-get-item-end-before-blank item struct))
|
2011-08-21 15:31:58 -04:00
|
|
|
|
(> (save-excursion (goto-char pos)
|
|
|
|
|
(setq usr-blank (funcall count-blanks)))
|
|
|
|
|
0))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
usr-blank)
|
2011-07-11 10:35:31 -04:00
|
|
|
|
;; Are there blank lines inside the list so far?
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
((save-excursion
|
2011-07-11 10:35:31 -04:00
|
|
|
|
(goto-char (org-list-get-top-point struct))
|
2012-11-13 09:45:09 -05:00
|
|
|
|
;; Do not use `org-list-search-forward' so blank lines
|
|
|
|
|
;; in blocks can be counted in.
|
|
|
|
|
(re-search-forward
|
2011-07-26 11:46:24 -04:00
|
|
|
|
"^[ \t]*$" (org-list-get-item-end-before-blank item struct) t))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
1)
|
2011-07-11 10:35:31 -04:00
|
|
|
|
;; Default choice: no blank line.
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(t 0))))))))
|
|
|
|
|
|
|
|
|
|
(defun org-list-insert-item (pos struct prevs &optional checkbox after-bullet)
|
2011-02-18 07:41:49 -05:00
|
|
|
|
"Insert a new list item at POS and return the new structure.
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
If POS is before first character after bullet of the item, the
|
|
|
|
|
new item will be created before the current one.
|
2010-12-23 12:54:24 -05:00
|
|
|
|
|
2014-06-23 03:40:19 -04:00
|
|
|
|
STRUCT is the list structure. PREVS is the alist of previous
|
2011-02-18 07:41:49 -05:00
|
|
|
|
items, as returned by `org-list-prevs-alist'.
|
2010-12-30 12:41:19 -05:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
Insert a checkbox if CHECKBOX is non-nil, and string AFTER-BULLET
|
2011-06-28 05:20:56 -04:00
|
|
|
|
after the bullet. Cursor will be after this text once the
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
function ends.
|
2010-12-30 12:41:19 -05:00
|
|
|
|
|
2011-02-18 07:41:49 -05:00
|
|
|
|
This function modifies STRUCT."
|
2020-04-09 09:42:36 -04:00
|
|
|
|
(let* ((case-fold-search t)
|
|
|
|
|
;; Get information about list: ITEM containing POS, position
|
|
|
|
|
;; of point with regards to item start (BEFOREP), blank lines
|
|
|
|
|
;; number separating items (BLANK-NB), if we're allowed to
|
|
|
|
|
;; (SPLIT-LINE-P).
|
|
|
|
|
(item
|
|
|
|
|
(catch :exit
|
|
|
|
|
(let ((i nil))
|
|
|
|
|
(pcase-dolist (`(,start ,_ ,_ ,_ ,_ ,_ ,end) struct)
|
|
|
|
|
(cond
|
|
|
|
|
((> start pos) (throw :exit i))
|
|
|
|
|
((< end pos) nil) ;skip sub-lists before point
|
|
|
|
|
(t (setq i start))))
|
2020-04-10 09:09:49 -04:00
|
|
|
|
;; If no suitable item is found, insert a sibling of the
|
|
|
|
|
;; last item in buffer.
|
|
|
|
|
(or i (caar (reverse struct))))))
|
2020-04-09 09:42:36 -04:00
|
|
|
|
(item-end (org-list-get-item-end item struct))
|
|
|
|
|
(item-end-no-blank (org-list-get-item-end-before-blank item struct))
|
|
|
|
|
(beforep
|
|
|
|
|
(progn
|
|
|
|
|
(goto-char item)
|
|
|
|
|
(looking-at org-list-full-item-re)
|
|
|
|
|
(<= pos
|
|
|
|
|
(cond
|
|
|
|
|
((not (match-beginning 4)) (match-end 0))
|
|
|
|
|
;; Ignore tag in a non-descriptive list.
|
|
|
|
|
((save-match-data (string-match "[.)]" (match-string 1)))
|
|
|
|
|
(match-beginning 4))
|
|
|
|
|
(t (save-excursion
|
|
|
|
|
(goto-char (match-end 4))
|
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
(point)))))))
|
|
|
|
|
(split-line-p (org-get-alist-option org-M-RET-may-split-line 'item))
|
|
|
|
|
(blank-nb (org-list-separating-blank-lines-number pos struct prevs))
|
|
|
|
|
;; Build the new item to be created. Concatenate same bullet
|
|
|
|
|
;; as item, checkbox, text AFTER-BULLET if provided, and text
|
|
|
|
|
;; cut from point to end of item (TEXT-CUT) to form item's
|
|
|
|
|
;; BODY. TEXT-CUT depends on BEFOREP and SPLIT-LINE-P. The
|
|
|
|
|
;; difference of size between what was cut and what was
|
|
|
|
|
;; inserted in buffer is stored in SIZE-OFFSET.
|
|
|
|
|
(ind (org-list-get-ind item struct))
|
|
|
|
|
(ind-size (if indent-tabs-mode
|
|
|
|
|
(+ (/ ind tab-width) (mod ind tab-width))
|
|
|
|
|
ind))
|
|
|
|
|
(bullet (org-list-bullet-string (org-list-get-bullet item struct)))
|
|
|
|
|
(box (and checkbox "[ ]"))
|
|
|
|
|
(text-cut
|
|
|
|
|
(and (not beforep)
|
|
|
|
|
split-line-p
|
|
|
|
|
(progn
|
|
|
|
|
(goto-char pos)
|
|
|
|
|
;; If POS is greater than ITEM-END, then point is in
|
|
|
|
|
;; some white lines after the end of the list. Those
|
|
|
|
|
;; must be removed, or they will be left, stacking up
|
|
|
|
|
;; after the list.
|
|
|
|
|
(when (< item-end pos)
|
|
|
|
|
(delete-region (1- item-end) (point-at-eol)))
|
|
|
|
|
(skip-chars-backward " \r\t\n")
|
2020-08-16 05:42:53 -04:00
|
|
|
|
;; Cut position is after any blank on the line.
|
|
|
|
|
(save-excursion
|
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
(setq pos (point)))
|
|
|
|
|
(delete-and-extract-region (point) item-end-no-blank))))
|
2020-04-09 09:42:36 -04:00
|
|
|
|
(body
|
|
|
|
|
(concat bullet
|
|
|
|
|
(and box (concat box " "))
|
|
|
|
|
after-bullet
|
|
|
|
|
(and text-cut
|
|
|
|
|
(if (string-match "\\`[ \t]+" text-cut)
|
|
|
|
|
(replace-match "" t t text-cut)
|
|
|
|
|
text-cut))))
|
|
|
|
|
(item-sep (make-string (1+ blank-nb) ?\n))
|
|
|
|
|
(item-size (+ ind-size (length body) (length item-sep)))
|
|
|
|
|
(size-offset (- item-size (length text-cut))))
|
|
|
|
|
;; Insert effectively item into buffer.
|
|
|
|
|
(goto-char item)
|
|
|
|
|
(indent-to-column ind)
|
|
|
|
|
(insert body item-sep)
|
|
|
|
|
;; Add new item to STRUCT.
|
|
|
|
|
(dolist (e struct)
|
|
|
|
|
(let ((p (car e)) (end (nth 6 e)))
|
|
|
|
|
(cond
|
|
|
|
|
;; Before inserted item, positions don't change but an item
|
|
|
|
|
;; ending after insertion has its end shifted by SIZE-OFFSET.
|
|
|
|
|
((< p item)
|
|
|
|
|
(when (> end item)
|
|
|
|
|
(setcar (nthcdr 6 e) (+ end size-offset))))
|
|
|
|
|
;; Item where insertion happens may be split in two parts.
|
|
|
|
|
;; In this case, move start by ITEM-SIZE and end by
|
|
|
|
|
;; SIZE-OFFSET.
|
|
|
|
|
((and (= p item) (not beforep) split-line-p)
|
|
|
|
|
(setcar e (+ p item-size))
|
|
|
|
|
(setcar (nthcdr 6 e) (+ end size-offset)))
|
|
|
|
|
;; Items starting after modified item fall into two
|
2020-08-16 05:42:53 -04:00
|
|
|
|
;; categories.
|
|
|
|
|
;;
|
|
|
|
|
;; If modified item was split, and current sub-item was
|
|
|
|
|
;; located after split point, it was moved to the new item:
|
|
|
|
|
;; the part between body start and split point (POS) was
|
|
|
|
|
;; removed. So we compute the length of that part and shift
|
|
|
|
|
;; item's positions accordingly.
|
|
|
|
|
;;
|
|
|
|
|
;; Otherwise, the item was simply shifted by SIZE-OFFSET.
|
2020-04-10 10:06:05 -04:00
|
|
|
|
((and split-line-p (not beforep) (>= p pos) (<= p item-end-no-blank))
|
2020-04-09 09:42:36 -04:00
|
|
|
|
(let ((offset (- pos item ind (length bullet) (length after-bullet))))
|
|
|
|
|
(setcar e (- p offset))
|
|
|
|
|
(setcar (nthcdr 6 e) (- end offset))))
|
|
|
|
|
(t
|
2020-07-06 06:05:18 -04:00
|
|
|
|
(setcar e (+ p size-offset))
|
|
|
|
|
(setcar (nthcdr 6 e) (+ end size-offset))))))
|
2020-04-09 09:42:36 -04:00
|
|
|
|
(push (list item ind bullet nil box nil (+ item item-size)) struct)
|
|
|
|
|
(setq struct (sort struct #'car-less-than-car))
|
|
|
|
|
;; If not BEFOREP, new item must appear after ITEM, so exchange
|
|
|
|
|
;; ITEM with the next item in list. Position cursor after bullet,
|
|
|
|
|
;; counter, checkbox, and label.
|
|
|
|
|
(if beforep
|
|
|
|
|
(goto-char item)
|
|
|
|
|
(setq struct (org-list-swap-items item (+ item item-size) struct))
|
|
|
|
|
(goto-char (org-list-get-next-item
|
|
|
|
|
item struct (org-list-prevs-alist struct))))
|
|
|
|
|
struct))
|
2010-12-19 16:03:05 -05:00
|
|
|
|
|
2011-07-02 04:24:51 -04:00
|
|
|
|
(defun org-list-delete-item (item struct)
|
|
|
|
|
"Remove ITEM from the list and return the new structure.
|
|
|
|
|
|
|
|
|
|
STRUCT is the list structure."
|
|
|
|
|
(let* ((end (org-list-get-item-end item struct))
|
|
|
|
|
(beg (if (= (org-list-get-bottom-point struct) end)
|
|
|
|
|
;; If ITEM ends with the list, delete blank lines
|
|
|
|
|
;; before it.
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char item)
|
|
|
|
|
(skip-chars-backward " \r\t\n")
|
|
|
|
|
(min (1+ (point-at-eol)) (point-max)))
|
|
|
|
|
item)))
|
|
|
|
|
;; Remove item from buffer.
|
|
|
|
|
(delete-region beg end)
|
|
|
|
|
;; Remove item from structure and shift others items accordingly.
|
|
|
|
|
;; Don't forget to shift also ending position when appropriate.
|
|
|
|
|
(let ((size (- end beg)))
|
|
|
|
|
(delq nil (mapcar (lambda (e)
|
|
|
|
|
(let ((pos (car e)))
|
|
|
|
|
(cond
|
|
|
|
|
((< pos item)
|
|
|
|
|
(let ((end-e (nth 6 e)))
|
|
|
|
|
(cond
|
|
|
|
|
((< end-e item) e)
|
|
|
|
|
((= end-e item)
|
|
|
|
|
(append (butlast e) (list beg)))
|
|
|
|
|
(t
|
|
|
|
|
(append (butlast e) (list (- end-e size)))))))
|
|
|
|
|
((< pos end) nil)
|
|
|
|
|
(t
|
|
|
|
|
(cons (- pos size)
|
|
|
|
|
(append (butlast (cdr e))
|
|
|
|
|
(list (- (nth 6 e) size))))))))
|
|
|
|
|
struct)))))
|
|
|
|
|
|
|
|
|
|
(defun org-list-send-item (item dest struct)
|
|
|
|
|
"Send ITEM to destination DEST.
|
|
|
|
|
|
|
|
|
|
STRUCT is the list structure.
|
|
|
|
|
|
|
|
|
|
DEST can have various values.
|
|
|
|
|
|
|
|
|
|
If DEST is a buffer position, the function will assume it points
|
|
|
|
|
to another item in the same list as ITEM, and will move the
|
|
|
|
|
latter just before the former.
|
|
|
|
|
|
2012-05-08 03:00:18 -04:00
|
|
|
|
If DEST is `begin' (respectively `end'), ITEM will be moved at
|
|
|
|
|
the beginning (respectively end) of the list it belongs to.
|
2011-07-02 04:24:51 -04:00
|
|
|
|
|
|
|
|
|
If DEST is a string like \"N\", where N is an integer, ITEM will
|
|
|
|
|
be moved at the Nth position in the list.
|
|
|
|
|
|
|
|
|
|
If DEST is `kill', ITEM will be deleted and its body will be
|
|
|
|
|
added to the kill-ring.
|
|
|
|
|
|
|
|
|
|
If DEST is `delete', ITEM will be deleted.
|
|
|
|
|
|
2012-05-07 16:34:16 -04:00
|
|
|
|
Visibility of item is preserved.
|
|
|
|
|
|
2011-07-02 04:24:51 -04:00
|
|
|
|
This function returns, destructively, the new list structure."
|
|
|
|
|
(let* ((prevs (org-list-prevs-alist struct))
|
|
|
|
|
(item-end (org-list-get-item-end item struct))
|
|
|
|
|
;; Grab full item body minus its bullet.
|
|
|
|
|
(body (org-trim
|
|
|
|
|
(buffer-substring
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char item)
|
|
|
|
|
(looking-at
|
|
|
|
|
(concat "[ \t]*"
|
|
|
|
|
(regexp-quote (org-list-get-bullet item struct))))
|
|
|
|
|
(match-end 0))
|
|
|
|
|
item-end)))
|
|
|
|
|
;; Change DEST into a buffer position. A trick is needed
|
|
|
|
|
;; when ITEM is meant to be sent at the end of the list.
|
|
|
|
|
;; Indeed, by setting locally `org-M-RET-may-split-line' to
|
|
|
|
|
;; nil and insertion point (INS-POINT) to the first line's
|
|
|
|
|
;; end of the last item, we ensure the new item will be
|
|
|
|
|
;; inserted after the last item, and not after any of its
|
|
|
|
|
;; hypothetical sub-items.
|
|
|
|
|
(ins-point (cond
|
|
|
|
|
((or (eq dest 'kill) (eq dest 'delete)))
|
|
|
|
|
((eq dest 'begin)
|
|
|
|
|
(setq dest (org-list-get-list-begin item struct prevs)))
|
|
|
|
|
((eq dest 'end)
|
|
|
|
|
(setq dest (org-list-get-list-end item struct prevs))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (org-list-get-last-item item struct prevs))
|
|
|
|
|
(point-at-eol)))
|
2016-09-02 21:05:10 -04:00
|
|
|
|
((string-match-p "\\`[0-9]+\\'" dest)
|
2011-07-02 04:24:51 -04:00
|
|
|
|
(let* ((all (org-list-get-all-items item struct prevs))
|
|
|
|
|
(len (length all))
|
|
|
|
|
(index (mod (string-to-number dest) len)))
|
|
|
|
|
(if (not (zerop index))
|
|
|
|
|
(setq dest (nth (1- index) all))
|
|
|
|
|
;; Send ITEM at the end of the list.
|
|
|
|
|
(setq dest (org-list-get-list-end item struct prevs))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char
|
|
|
|
|
(org-list-get-last-item item struct prevs))
|
|
|
|
|
(point-at-eol)))))
|
|
|
|
|
(t dest)))
|
2012-05-07 16:34:16 -04:00
|
|
|
|
(org-M-RET-may-split-line nil)
|
2015-01-29 18:20:01 -05:00
|
|
|
|
;; Store inner overlays (to preserve visibility).
|
2015-11-06 07:04:20 -05:00
|
|
|
|
(overlays (cl-remove-if (lambda (o) (or (< (overlay-start o) item)
|
2018-03-05 04:57:43 -05:00
|
|
|
|
(> (overlay-end o) item)))
|
|
|
|
|
(overlays-in item item-end))))
|
2011-07-02 04:24:51 -04:00
|
|
|
|
(cond
|
|
|
|
|
((eq dest 'delete) (org-list-delete-item item struct))
|
|
|
|
|
((eq dest 'kill)
|
|
|
|
|
(kill-new body)
|
|
|
|
|
(org-list-delete-item item struct))
|
|
|
|
|
((and (integerp dest) (/= item ins-point))
|
|
|
|
|
(setq item (copy-marker item))
|
|
|
|
|
(setq struct (org-list-insert-item ins-point struct prevs nil body))
|
|
|
|
|
;; 1. Structure returned by `org-list-insert-item' may not be
|
|
|
|
|
;; accurate, as it cannot see sub-items included in BODY.
|
|
|
|
|
;; Thus, first compute the real structure so far.
|
|
|
|
|
(let ((moved-items
|
|
|
|
|
(cons (marker-position item)
|
|
|
|
|
(org-list-get-subtree (marker-position item) struct)))
|
|
|
|
|
(new-end (org-list-get-item-end (point) struct))
|
|
|
|
|
(old-end (org-list-get-item-end (marker-position item) struct))
|
|
|
|
|
(new-item (point))
|
|
|
|
|
(shift (- (point) item)))
|
|
|
|
|
;; 1.1. Remove the item just created in structure.
|
|
|
|
|
(setq struct (delete (assq new-item struct) struct))
|
|
|
|
|
;; 1.2. Copy ITEM and any of its sub-items at NEW-ITEM.
|
2011-08-13 17:40:04 -04:00
|
|
|
|
(setq struct (sort
|
2011-07-02 04:24:51 -04:00
|
|
|
|
(append
|
|
|
|
|
struct
|
|
|
|
|
(mapcar (lambda (e)
|
|
|
|
|
(let* ((cell (assq e struct))
|
|
|
|
|
(pos (car cell))
|
|
|
|
|
(end (nth 6 cell)))
|
|
|
|
|
(cons (+ pos shift)
|
|
|
|
|
(append (butlast (cdr cell))
|
|
|
|
|
(list (if (= end old-end)
|
|
|
|
|
new-end
|
|
|
|
|
(+ end shift)))))))
|
|
|
|
|
moved-items))
|
2015-01-29 18:20:01 -05:00
|
|
|
|
#'car-less-than-car)))
|
|
|
|
|
;; 2. Restore inner overlays.
|
|
|
|
|
(dolist (o overlays)
|
|
|
|
|
(move-overlay o
|
|
|
|
|
(+ (overlay-start o) (- (point) item))
|
|
|
|
|
(+ (overlay-end o) (- (point) item))))
|
2012-05-07 16:34:16 -04:00
|
|
|
|
;; 3. Eventually delete extra copy of the item and clean marker.
|
|
|
|
|
(prog1 (org-list-delete-item (marker-position item) struct)
|
2011-07-02 04:24:51 -04:00
|
|
|
|
(move-marker item nil)))
|
|
|
|
|
(t struct))))
|
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(defun org-list-struct-outdent (start end struct parents)
|
2011-02-18 07:41:49 -05:00
|
|
|
|
"Outdent items between positions START and END.
|
2010-12-19 16:03:05 -05:00
|
|
|
|
|
2011-06-28 05:20:56 -04:00
|
|
|
|
STRUCT is the list structure. PARENTS is the alist of items'
|
2011-02-18 07:41:49 -05:00
|
|
|
|
parents, as returned by `org-list-parents-alist'.
|
2010-12-19 16:03:05 -05:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
START is included, END excluded."
|
|
|
|
|
(let* (acc
|
|
|
|
|
(out (lambda (cell)
|
|
|
|
|
(let* ((item (car cell))
|
|
|
|
|
(parent (cdr cell)))
|
|
|
|
|
(cond
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Item not yet in zone: keep association.
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
((< item start) cell)
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Item out of zone: follow associations in ACC.
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
((>= item end)
|
|
|
|
|
(let ((convert (and parent (assq parent acc))))
|
|
|
|
|
(if convert (cons item (cdr convert)) cell)))
|
|
|
|
|
;; Item has no parent: error
|
|
|
|
|
((not parent)
|
|
|
|
|
(error "Cannot outdent top-level items"))
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Parent is outdented: keep association.
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
((>= parent start)
|
|
|
|
|
(push (cons parent item) acc) cell)
|
|
|
|
|
(t
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Parent isn't outdented: reparent to grand-parent.
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(let ((grand-parent (org-list-get-parent
|
|
|
|
|
parent struct parents)))
|
|
|
|
|
(push (cons parent item) acc)
|
|
|
|
|
(cons item grand-parent))))))))
|
|
|
|
|
(mapcar out parents)))
|
2010-12-19 16:03:05 -05:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(defun org-list-struct-indent (start end struct parents prevs)
|
2011-02-18 07:41:49 -05:00
|
|
|
|
"Indent items between positions START and END.
|
2010-12-19 16:03:05 -05:00
|
|
|
|
|
2011-06-28 05:20:56 -04:00
|
|
|
|
STRUCT is the list structure. PARENTS is the alist of parents
|
|
|
|
|
and PREVS is the alist of previous items, returned by,
|
|
|
|
|
respectively, `org-list-parents-alist' and
|
|
|
|
|
`org-list-prevs-alist'.
|
2010-12-19 16:03:05 -05:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
START is included and END excluded.
|
2010-12-19 16:03:05 -05:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
STRUCT may be modified if `org-list-demote-modify-bullet' matches
|
|
|
|
|
bullets between START and END."
|
|
|
|
|
(let* (acc
|
|
|
|
|
(set-assoc (lambda (cell) (push cell acc) cell))
|
|
|
|
|
(ind
|
|
|
|
|
(lambda (cell)
|
|
|
|
|
(let* ((item (car cell))
|
|
|
|
|
(parent (cdr cell)))
|
|
|
|
|
(cond
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Item not yet in zone: keep association.
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
((< item start) cell)
|
|
|
|
|
((>= item end)
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Item out of zone: follow associations in ACC.
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(let ((convert (assq parent acc)))
|
|
|
|
|
(if convert (cons item (cdr convert)) cell)))
|
|
|
|
|
(t
|
|
|
|
|
;; Item is in zone...
|
|
|
|
|
(let ((prev (org-list-get-prev-item item struct prevs)))
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Check if bullet needs to be changed.
|
2019-07-09 05:53:08 -04:00
|
|
|
|
(pcase (assoc (let ((b (org-list-get-bullet item struct))
|
|
|
|
|
(case-fold-search nil))
|
|
|
|
|
(cond ((string-match "[A-Z]\\." b) "A.")
|
|
|
|
|
((string-match "[A-Z])" b) "A)")
|
|
|
|
|
((string-match "[a-z]\\." b) "a.")
|
|
|
|
|
((string-match "[a-z])" b) "a)")
|
|
|
|
|
((string-match "[0-9]\\." b) "1.")
|
|
|
|
|
((string-match "[0-9])" b) "1)")
|
|
|
|
|
(t (org-trim b))))
|
|
|
|
|
org-list-demote-modify-bullet)
|
|
|
|
|
(`(,_ . ,bullet)
|
|
|
|
|
(org-list-set-bullet
|
|
|
|
|
item struct (org-list-bullet-string bullet)))
|
|
|
|
|
(_ nil))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(cond
|
|
|
|
|
;; First item indented but not parent: error
|
2018-05-01 09:02:52 -04:00
|
|
|
|
((and (not prev) (or (not parent) (< parent start)))
|
|
|
|
|
(user-error "Cannot indent the first item of a list"))
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; First item and parent indented: keep same
|
|
|
|
|
;; parent.
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
((not prev) (funcall set-assoc cell))
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Previous item not indented: reparent to it.
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
((< prev start) (funcall set-assoc (cons item prev)))
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Previous item indented: reparent like it.
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(t
|
|
|
|
|
(funcall set-assoc
|
|
|
|
|
(cons item (cdr (assq prev acc)))))))))))))
|
|
|
|
|
(mapcar ind parents)))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
|
2010-12-19 16:03:05 -05:00
|
|
|
|
|
2011-08-23 16:17:20 -04:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
;;; Repairing structures
|
2010-07-30 18:45:34 -04:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(defun org-list-use-alpha-bul-p (first struct prevs)
|
2011-02-18 07:41:49 -05:00
|
|
|
|
"Non-nil if list starting at FIRST can have alphabetical bullets.
|
2010-08-21 07:32:33 -04:00
|
|
|
|
|
2011-08-23 15:26:51 -04:00
|
|
|
|
STRUCT is list structure. PREVS is the alist of previous items,
|
2011-02-18 07:41:49 -05:00
|
|
|
|
as returned by `org-list-prevs-alist'."
|
2013-03-23 12:42:09 -04:00
|
|
|
|
(and org-list-allow-alphabetical
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(catch 'exit
|
|
|
|
|
(let ((item first) (ascii 64) (case-fold-search nil))
|
|
|
|
|
;; Pretend that bullets are uppercase and check if alphabet
|
|
|
|
|
;; is sufficient, taking counters into account.
|
|
|
|
|
(while item
|
2015-05-04 11:32:43 -04:00
|
|
|
|
(let ((count (org-list-get-counter item struct)))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
;; Virtually determine current bullet
|
2016-09-02 21:05:10 -04:00
|
|
|
|
(if (and count (string-match-p "[a-zA-Z]" count))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
;; Counters are not case-sensitive.
|
|
|
|
|
(setq ascii (string-to-char (upcase count)))
|
|
|
|
|
(setq ascii (1+ ascii)))
|
|
|
|
|
;; Test if bullet would be over z or Z.
|
|
|
|
|
(if (> ascii 90)
|
|
|
|
|
(throw 'exit nil)
|
|
|
|
|
(setq item (org-list-get-next-item item struct prevs)))))
|
2012-08-11 13:10:44 -04:00
|
|
|
|
;; All items checked. All good.
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
t))))
|
2010-12-30 12:39:36 -05:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(defun org-list-inc-bullet-maybe (bullet)
|
|
|
|
|
"Increment BULLET if applicable."
|
|
|
|
|
(let ((case-fold-search nil))
|
|
|
|
|
(cond
|
|
|
|
|
;; Num bullet: increment it.
|
|
|
|
|
((string-match "[0-9]+" bullet)
|
|
|
|
|
(replace-match
|
|
|
|
|
(number-to-string (1+ (string-to-number (match-string 0 bullet))))
|
|
|
|
|
nil nil bullet))
|
|
|
|
|
;; Alpha bullet: increment it.
|
|
|
|
|
((string-match "[A-Za-z]" bullet)
|
|
|
|
|
(replace-match
|
|
|
|
|
(char-to-string (1+ (string-to-char (match-string 0 bullet))))
|
|
|
|
|
nil nil bullet))
|
|
|
|
|
;; Unordered bullet: leave it.
|
|
|
|
|
(t bullet))))
|
2010-12-23 18:54:48 -05:00
|
|
|
|
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(defun org-list-struct-fix-bul (struct prevs)
|
2011-02-18 07:41:49 -05:00
|
|
|
|
"Verify and correct bullets in STRUCT.
|
|
|
|
|
PREVS is the alist of previous items, as returned by
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
`org-list-prevs-alist'.
|
2010-12-29 14:16:00 -05:00
|
|
|
|
|
|
|
|
|
This function modifies STRUCT."
|
org-list: implement alphabetical lists
* lisp/org-list.el (org-alphabetical-lists): new variable
(org-item-re, org-list-full-item, org-cycle-list-bullet,
org-list-struct-fix-bul, org-list-inc-bullet-maybe): reflect
introduction of the new variable.
(org-item-beginning-re): changed into a function, so any modification
of `org-alphabetical-lists' will not require reloading Org.
(org-at-item-p, org-toggle-checkbox, org-update-checkbox-count,
org-list-parse-list, org-list-send-list): reflect changes to
`org-item-beginning-re'.
(org-list-use-alpha-bul-p): new function.
* lisp/org.el (org-check-for-hidden): reflect changes to
`org-item-beginning-re'.
* lisp/org-capture.el (org-capture-place-item): reflect changes to
`org-item-beginning-re'.
* lisp/org-docbook.el (org-export-docbook-list-line): handle new type
of items.
* lisp/org-exp.el (org-export-mark-list-end,
org-export-mark-list-properties): reflect changes to
`org-item-beginning-re'.
* lisp/org-html.el (org-html-export-list-line): handle new type of
items.
* lisp/org-latex.el (org-export-latex-lists): handle new type of items
and reflect changes to `org-item-beginning-re'.
* lisp/org-ascii.el (org-export-ascii-preprocess): handle new counters.
Modified from a patch by Nathaniel Flath.
2011-01-13 17:25:55 -05:00
|
|
|
|
(let ((case-fold-search nil)
|
|
|
|
|
(fix-bul
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(function
|
org-list: implement alphabetical lists
* lisp/org-list.el (org-alphabetical-lists): new variable
(org-item-re, org-list-full-item, org-cycle-list-bullet,
org-list-struct-fix-bul, org-list-inc-bullet-maybe): reflect
introduction of the new variable.
(org-item-beginning-re): changed into a function, so any modification
of `org-alphabetical-lists' will not require reloading Org.
(org-at-item-p, org-toggle-checkbox, org-update-checkbox-count,
org-list-parse-list, org-list-send-list): reflect changes to
`org-item-beginning-re'.
(org-list-use-alpha-bul-p): new function.
* lisp/org.el (org-check-for-hidden): reflect changes to
`org-item-beginning-re'.
* lisp/org-capture.el (org-capture-place-item): reflect changes to
`org-item-beginning-re'.
* lisp/org-docbook.el (org-export-docbook-list-line): handle new type
of items.
* lisp/org-exp.el (org-export-mark-list-end,
org-export-mark-list-properties): reflect changes to
`org-item-beginning-re'.
* lisp/org-html.el (org-html-export-list-line): handle new type of
items.
* lisp/org-latex.el (org-export-latex-lists): handle new type of items
and reflect changes to `org-item-beginning-re'.
* lisp/org-ascii.el (org-export-ascii-preprocess): handle new counters.
Modified from a patch by Nathaniel Flath.
2011-01-13 17:25:55 -05:00
|
|
|
|
;; Set bullet of ITEM in STRUCT, depending on the type of
|
|
|
|
|
;; first item of the list, the previous bullet and counter
|
|
|
|
|
;; if any.
|
2010-12-19 16:04:12 -05:00
|
|
|
|
(lambda (item)
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(let* ((prev (org-list-get-prev-item item struct prevs))
|
|
|
|
|
(prev-bul (and prev (org-list-get-bullet prev struct)))
|
|
|
|
|
(counter (org-list-get-counter item struct))
|
2011-01-19 07:58:47 -05:00
|
|
|
|
(bullet (org-list-get-bullet item struct))
|
|
|
|
|
(alphap (and (not prev)
|
|
|
|
|
(org-list-use-alpha-bul-p item struct prevs))))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(org-list-set-bullet
|
|
|
|
|
item struct
|
|
|
|
|
(org-list-bullet-string
|
|
|
|
|
(cond
|
org-list: implement alphabetical lists
* lisp/org-list.el (org-alphabetical-lists): new variable
(org-item-re, org-list-full-item, org-cycle-list-bullet,
org-list-struct-fix-bul, org-list-inc-bullet-maybe): reflect
introduction of the new variable.
(org-item-beginning-re): changed into a function, so any modification
of `org-alphabetical-lists' will not require reloading Org.
(org-at-item-p, org-toggle-checkbox, org-update-checkbox-count,
org-list-parse-list, org-list-send-list): reflect changes to
`org-item-beginning-re'.
(org-list-use-alpha-bul-p): new function.
* lisp/org.el (org-check-for-hidden): reflect changes to
`org-item-beginning-re'.
* lisp/org-capture.el (org-capture-place-item): reflect changes to
`org-item-beginning-re'.
* lisp/org-docbook.el (org-export-docbook-list-line): handle new type
of items.
* lisp/org-exp.el (org-export-mark-list-end,
org-export-mark-list-properties): reflect changes to
`org-item-beginning-re'.
* lisp/org-html.el (org-html-export-list-line): handle new type of
items.
* lisp/org-latex.el (org-export-latex-lists): handle new type of items
and reflect changes to `org-item-beginning-re'.
* lisp/org-ascii.el (org-export-ascii-preprocess): handle new counters.
Modified from a patch by Nathaniel Flath.
2011-01-13 17:25:55 -05:00
|
|
|
|
;; Alpha counter in alpha list: use counter.
|
|
|
|
|
((and prev counter
|
|
|
|
|
(string-match "[a-zA-Z]" counter)
|
|
|
|
|
(string-match "[a-zA-Z]" prev-bul))
|
|
|
|
|
;; Use cond to be sure `string-match' is used in
|
|
|
|
|
;; both cases.
|
|
|
|
|
(let ((real-count
|
|
|
|
|
(cond
|
|
|
|
|
((string-match "[a-z]" prev-bul) (downcase counter))
|
|
|
|
|
((string-match "[A-Z]" prev-bul) (upcase counter)))))
|
|
|
|
|
(replace-match real-count nil nil prev-bul)))
|
|
|
|
|
;; Num counter in a num list: use counter.
|
|
|
|
|
((and prev counter
|
|
|
|
|
(string-match "[0-9]+" counter)
|
|
|
|
|
(string-match "[0-9]+" prev-bul))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(replace-match counter nil nil prev-bul))
|
org-list: implement alphabetical lists
* lisp/org-list.el (org-alphabetical-lists): new variable
(org-item-re, org-list-full-item, org-cycle-list-bullet,
org-list-struct-fix-bul, org-list-inc-bullet-maybe): reflect
introduction of the new variable.
(org-item-beginning-re): changed into a function, so any modification
of `org-alphabetical-lists' will not require reloading Org.
(org-at-item-p, org-toggle-checkbox, org-update-checkbox-count,
org-list-parse-list, org-list-send-list): reflect changes to
`org-item-beginning-re'.
(org-list-use-alpha-bul-p): new function.
* lisp/org.el (org-check-for-hidden): reflect changes to
`org-item-beginning-re'.
* lisp/org-capture.el (org-capture-place-item): reflect changes to
`org-item-beginning-re'.
* lisp/org-docbook.el (org-export-docbook-list-line): handle new type
of items.
* lisp/org-exp.el (org-export-mark-list-end,
org-export-mark-list-properties): reflect changes to
`org-item-beginning-re'.
* lisp/org-html.el (org-html-export-list-line): handle new type of
items.
* lisp/org-latex.el (org-export-latex-lists): handle new type of items
and reflect changes to `org-item-beginning-re'.
* lisp/org-ascii.el (org-export-ascii-preprocess): handle new counters.
Modified from a patch by Nathaniel Flath.
2011-01-13 17:25:55 -05:00
|
|
|
|
;; No counter: increase, if needed, previous bullet.
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(prev
|
|
|
|
|
(org-list-inc-bullet-maybe (org-list-get-bullet prev struct)))
|
org-list: implement alphabetical lists
* lisp/org-list.el (org-alphabetical-lists): new variable
(org-item-re, org-list-full-item, org-cycle-list-bullet,
org-list-struct-fix-bul, org-list-inc-bullet-maybe): reflect
introduction of the new variable.
(org-item-beginning-re): changed into a function, so any modification
of `org-alphabetical-lists' will not require reloading Org.
(org-at-item-p, org-toggle-checkbox, org-update-checkbox-count,
org-list-parse-list, org-list-send-list): reflect changes to
`org-item-beginning-re'.
(org-list-use-alpha-bul-p): new function.
* lisp/org.el (org-check-for-hidden): reflect changes to
`org-item-beginning-re'.
* lisp/org-capture.el (org-capture-place-item): reflect changes to
`org-item-beginning-re'.
* lisp/org-docbook.el (org-export-docbook-list-line): handle new type
of items.
* lisp/org-exp.el (org-export-mark-list-end,
org-export-mark-list-properties): reflect changes to
`org-item-beginning-re'.
* lisp/org-html.el (org-html-export-list-line): handle new type of
items.
* lisp/org-latex.el (org-export-latex-lists): handle new type of items
and reflect changes to `org-item-beginning-re'.
* lisp/org-ascii.el (org-export-ascii-preprocess): handle new counters.
Modified from a patch by Nathaniel Flath.
2011-01-13 17:25:55 -05:00
|
|
|
|
;; Alpha counter at first item: use counter.
|
|
|
|
|
((and counter (org-list-use-alpha-bul-p item struct prevs)
|
|
|
|
|
(string-match "[A-Za-z]" counter)
|
|
|
|
|
(string-match "[A-Za-z]" bullet))
|
|
|
|
|
(let ((real-count
|
|
|
|
|
(cond
|
|
|
|
|
((string-match "[a-z]" bullet) (downcase counter))
|
|
|
|
|
((string-match "[A-Z]" bullet) (upcase counter)))))
|
|
|
|
|
(replace-match real-count nil nil bullet)))
|
|
|
|
|
;; Num counter at first item: use counter.
|
|
|
|
|
((and counter
|
|
|
|
|
(string-match "[0-9]+" counter)
|
|
|
|
|
(string-match "[0-9]+" bullet))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(replace-match counter nil nil bullet))
|
org-list: implement alphabetical lists
* lisp/org-list.el (org-alphabetical-lists): new variable
(org-item-re, org-list-full-item, org-cycle-list-bullet,
org-list-struct-fix-bul, org-list-inc-bullet-maybe): reflect
introduction of the new variable.
(org-item-beginning-re): changed into a function, so any modification
of `org-alphabetical-lists' will not require reloading Org.
(org-at-item-p, org-toggle-checkbox, org-update-checkbox-count,
org-list-parse-list, org-list-send-list): reflect changes to
`org-item-beginning-re'.
(org-list-use-alpha-bul-p): new function.
* lisp/org.el (org-check-for-hidden): reflect changes to
`org-item-beginning-re'.
* lisp/org-capture.el (org-capture-place-item): reflect changes to
`org-item-beginning-re'.
* lisp/org-docbook.el (org-export-docbook-list-line): handle new type
of items.
* lisp/org-exp.el (org-export-mark-list-end,
org-export-mark-list-properties): reflect changes to
`org-item-beginning-re'.
* lisp/org-html.el (org-html-export-list-line): handle new type of
items.
* lisp/org-latex.el (org-export-latex-lists): handle new type of items
and reflect changes to `org-item-beginning-re'.
* lisp/org-ascii.el (org-export-ascii-preprocess): handle new counters.
Modified from a patch by Nathaniel Flath.
2011-01-13 17:25:55 -05:00
|
|
|
|
;; First bullet is alpha uppercase: use "A".
|
2011-01-19 07:58:47 -05:00
|
|
|
|
((and alphap (string-match "[A-Z]" bullet))
|
org-list: implement alphabetical lists
* lisp/org-list.el (org-alphabetical-lists): new variable
(org-item-re, org-list-full-item, org-cycle-list-bullet,
org-list-struct-fix-bul, org-list-inc-bullet-maybe): reflect
introduction of the new variable.
(org-item-beginning-re): changed into a function, so any modification
of `org-alphabetical-lists' will not require reloading Org.
(org-at-item-p, org-toggle-checkbox, org-update-checkbox-count,
org-list-parse-list, org-list-send-list): reflect changes to
`org-item-beginning-re'.
(org-list-use-alpha-bul-p): new function.
* lisp/org.el (org-check-for-hidden): reflect changes to
`org-item-beginning-re'.
* lisp/org-capture.el (org-capture-place-item): reflect changes to
`org-item-beginning-re'.
* lisp/org-docbook.el (org-export-docbook-list-line): handle new type
of items.
* lisp/org-exp.el (org-export-mark-list-end,
org-export-mark-list-properties): reflect changes to
`org-item-beginning-re'.
* lisp/org-html.el (org-html-export-list-line): handle new type of
items.
* lisp/org-latex.el (org-export-latex-lists): handle new type of items
and reflect changes to `org-item-beginning-re'.
* lisp/org-ascii.el (org-export-ascii-preprocess): handle new counters.
Modified from a patch by Nathaniel Flath.
2011-01-13 17:25:55 -05:00
|
|
|
|
(replace-match "A" nil nil bullet))
|
|
|
|
|
;; First bullet is alpha lowercase: use "a".
|
2011-01-19 07:58:47 -05:00
|
|
|
|
((and alphap (string-match "[a-z]" bullet))
|
org-list: implement alphabetical lists
* lisp/org-list.el (org-alphabetical-lists): new variable
(org-item-re, org-list-full-item, org-cycle-list-bullet,
org-list-struct-fix-bul, org-list-inc-bullet-maybe): reflect
introduction of the new variable.
(org-item-beginning-re): changed into a function, so any modification
of `org-alphabetical-lists' will not require reloading Org.
(org-at-item-p, org-toggle-checkbox, org-update-checkbox-count,
org-list-parse-list, org-list-send-list): reflect changes to
`org-item-beginning-re'.
(org-list-use-alpha-bul-p): new function.
* lisp/org.el (org-check-for-hidden): reflect changes to
`org-item-beginning-re'.
* lisp/org-capture.el (org-capture-place-item): reflect changes to
`org-item-beginning-re'.
* lisp/org-docbook.el (org-export-docbook-list-line): handle new type
of items.
* lisp/org-exp.el (org-export-mark-list-end,
org-export-mark-list-properties): reflect changes to
`org-item-beginning-re'.
* lisp/org-html.el (org-html-export-list-line): handle new type of
items.
* lisp/org-latex.el (org-export-latex-lists): handle new type of items
and reflect changes to `org-item-beginning-re'.
* lisp/org-ascii.el (org-export-ascii-preprocess): handle new counters.
Modified from a patch by Nathaniel Flath.
2011-01-13 17:25:55 -05:00
|
|
|
|
(replace-match "a" nil nil bullet))
|
|
|
|
|
;; First bullet is num: use "1".
|
|
|
|
|
((string-match "\\([0-9]+\\|[A-Za-z]\\)" bullet)
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(replace-match "1" nil nil bullet))
|
org-list: implement alphabetical lists
* lisp/org-list.el (org-alphabetical-lists): new variable
(org-item-re, org-list-full-item, org-cycle-list-bullet,
org-list-struct-fix-bul, org-list-inc-bullet-maybe): reflect
introduction of the new variable.
(org-item-beginning-re): changed into a function, so any modification
of `org-alphabetical-lists' will not require reloading Org.
(org-at-item-p, org-toggle-checkbox, org-update-checkbox-count,
org-list-parse-list, org-list-send-list): reflect changes to
`org-item-beginning-re'.
(org-list-use-alpha-bul-p): new function.
* lisp/org.el (org-check-for-hidden): reflect changes to
`org-item-beginning-re'.
* lisp/org-capture.el (org-capture-place-item): reflect changes to
`org-item-beginning-re'.
* lisp/org-docbook.el (org-export-docbook-list-line): handle new type
of items.
* lisp/org-exp.el (org-export-mark-list-end,
org-export-mark-list-properties): reflect changes to
`org-item-beginning-re'.
* lisp/org-html.el (org-html-export-list-line): handle new type of
items.
* lisp/org-latex.el (org-export-latex-lists): handle new type of items
and reflect changes to `org-item-beginning-re'.
* lisp/org-ascii.el (org-export-ascii-preprocess): handle new counters.
Modified from a patch by Nathaniel Flath.
2011-01-13 17:25:55 -05:00
|
|
|
|
;; Not an ordered list: keep bullet.
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(t bullet)))))))))
|
2015-05-04 11:32:43 -04:00
|
|
|
|
(mapc fix-bul (mapcar #'car struct))))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
|
|
|
|
|
(defun org-list-struct-fix-ind (struct parents &optional bullet-size)
|
2011-02-18 07:41:49 -05:00
|
|
|
|
"Verify and correct indentation in STRUCT.
|
2010-12-23 12:54:24 -05:00
|
|
|
|
|
2011-02-18 07:41:49 -05:00
|
|
|
|
PARENTS is the alist of parents, as returned by
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
`org-list-parents-alist'.
|
2010-12-29 14:16:00 -05:00
|
|
|
|
|
2010-12-23 12:54:24 -05:00
|
|
|
|
If numeric optional argument BULLET-SIZE is set, assume all
|
|
|
|
|
bullets in list have this length to determine new indentation.
|
2010-08-21 07:32:33 -04:00
|
|
|
|
|
2010-07-30 18:45:34 -04:00
|
|
|
|
This function modifies STRUCT."
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(let* ((ancestor (org-list-get-top-point struct))
|
|
|
|
|
(top-ind (org-list-get-ind ancestor struct))
|
2010-07-30 18:45:34 -04:00
|
|
|
|
(new-ind
|
|
|
|
|
(lambda (item)
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(let ((parent (org-list-get-parent item struct parents)))
|
2010-07-30 18:45:34 -04:00
|
|
|
|
(if parent
|
2011-07-10 10:40:26 -04:00
|
|
|
|
;; Indent like parent + length of parent's bullet +
|
|
|
|
|
;; sub-list offset.
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(org-list-set-ind
|
|
|
|
|
item struct (+ (or bullet-size
|
|
|
|
|
(length
|
|
|
|
|
(org-list-get-bullet parent struct)))
|
2011-07-10 10:40:26 -04:00
|
|
|
|
(org-list-get-ind parent struct)
|
|
|
|
|
org-list-indent-offset))
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; If no parent, indent like top-point.
|
2010-12-19 16:03:05 -05:00
|
|
|
|
(org-list-set-ind item struct top-ind))))))
|
2015-05-04 11:32:43 -04:00
|
|
|
|
(mapc new-ind (mapcar #'car (cdr struct)))))
|
2010-07-30 18:45:34 -04:00
|
|
|
|
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(defun org-list-struct-fix-box (struct parents prevs &optional ordered)
|
2011-02-18 07:41:49 -05:00
|
|
|
|
"Verify and correct checkboxes in STRUCT.
|
2010-12-19 16:04:12 -05:00
|
|
|
|
|
2011-02-18 07:41:49 -05:00
|
|
|
|
PARENTS is the alist of parents and PREVS is the alist of
|
|
|
|
|
previous items, as returned by, respectively,
|
|
|
|
|
`org-list-parents-alist' and `org-list-prevs-alist'.
|
2010-12-29 14:16:00 -05:00
|
|
|
|
|
2010-12-19 16:04:12 -05:00
|
|
|
|
If ORDERED is non-nil, a checkbox can only be checked when every
|
2011-06-28 05:20:56 -04:00
|
|
|
|
checkbox before it is checked too. If there was an attempt to
|
|
|
|
|
break this rule, the function will return the blocking item. In
|
2010-12-29 14:16:00 -05:00
|
|
|
|
all others cases, the return value will be nil.
|
2010-12-19 16:04:12 -05:00
|
|
|
|
|
2010-12-23 12:54:24 -05:00
|
|
|
|
This function modifies STRUCT."
|
2015-05-04 11:32:43 -04:00
|
|
|
|
(let ((all-items (mapcar #'car struct))
|
2010-12-19 16:04:12 -05:00
|
|
|
|
(set-parent-box
|
|
|
|
|
(function
|
|
|
|
|
(lambda (item)
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(let* ((box-list
|
|
|
|
|
(mapcar (lambda (child)
|
|
|
|
|
(org-list-get-checkbox child struct))
|
2010-12-28 19:43:20 -05:00
|
|
|
|
(org-list-get-children item struct parents))))
|
2010-12-19 16:04:12 -05:00
|
|
|
|
(org-list-set-checkbox
|
|
|
|
|
item struct
|
|
|
|
|
(cond
|
|
|
|
|
((and (member "[ ]" box-list) (member "[X]" box-list)) "[-]")
|
|
|
|
|
((member "[-]" box-list) "[-]")
|
|
|
|
|
((member "[X]" box-list) "[X]")
|
|
|
|
|
((member "[ ]" box-list) "[ ]")
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Parent has no boxed child: leave box as-is.
|
2010-12-19 16:04:12 -05:00
|
|
|
|
(t (org-list-get-checkbox item struct))))))))
|
|
|
|
|
parent-list)
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; 1. List all parents with a checkbox.
|
2010-12-19 16:04:12 -05:00
|
|
|
|
(mapc
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(lambda (e)
|
|
|
|
|
(let* ((parent (org-list-get-parent e struct parents))
|
2010-12-19 16:04:12 -05:00
|
|
|
|
(parent-box-p (org-list-get-checkbox parent struct)))
|
|
|
|
|
(when (and parent-box-p (not (memq parent parent-list)))
|
2011-01-01 12:27:31 -05:00
|
|
|
|
(push parent parent-list))))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
all-items)
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; 2. Sort those parents by decreasing indentation.
|
2010-12-19 16:04:12 -05:00
|
|
|
|
(setq parent-list (sort parent-list
|
|
|
|
|
(lambda (e1 e2)
|
|
|
|
|
(> (org-list-get-ind e1 struct)
|
|
|
|
|
(org-list-get-ind e2 struct)))))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
;; 3. For each parent, get all children's checkboxes to determine
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; and set its checkbox accordingly.
|
2010-12-19 16:04:12 -05:00
|
|
|
|
(mapc set-parent-box parent-list)
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; 4. If ORDERED is set, see if we need to uncheck some boxes.
|
2010-12-19 16:04:12 -05:00
|
|
|
|
(when ordered
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(let* ((box-list
|
2010-12-19 16:04:12 -05:00
|
|
|
|
(mapcar (lambda (e) (org-list-get-checkbox e struct)) all-items))
|
|
|
|
|
(after-unchecked (member "[ ]" box-list)))
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; There are boxes checked after an unchecked one: fix that.
|
2010-12-19 16:04:12 -05:00
|
|
|
|
(when (member "[X]" after-unchecked)
|
|
|
|
|
(let ((index (- (length struct) (length after-unchecked))))
|
2020-05-01 09:51:43 -04:00
|
|
|
|
(dolist (e (nthcdr index all-items))
|
|
|
|
|
(when (org-list-get-checkbox e struct)
|
|
|
|
|
(org-list-set-checkbox e struct "[ ]")))
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Verify once again the structure, without ORDERED.
|
2010-12-23 18:53:30 -05:00
|
|
|
|
(org-list-struct-fix-box struct parents prevs nil)
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Return blocking item.
|
2010-12-19 16:04:12 -05:00
|
|
|
|
(nth index all-items)))))))
|
|
|
|
|
|
2011-09-22 13:04:27 -04:00
|
|
|
|
(defun org-list-struct-fix-item-end (struct)
|
|
|
|
|
"Verify and correct each item end position in STRUCT.
|
|
|
|
|
|
|
|
|
|
This function modifies STRUCT."
|
|
|
|
|
(let (end-list acc-end)
|
2020-05-01 09:51:43 -04:00
|
|
|
|
(pcase-dolist (`(,pos . ,_) struct)
|
|
|
|
|
(let ((ind-pos (org-list-get-ind pos struct))
|
|
|
|
|
(end-pos (org-list-get-item-end pos struct)))
|
|
|
|
|
(unless (assq end-pos struct)
|
|
|
|
|
;; To determine real ind of an ending position that is not
|
|
|
|
|
;; at an item, we have to find the item it belongs to: it is
|
|
|
|
|
;; the last item (ITEM-UP), whose ending is further than the
|
|
|
|
|
;; position we're interested in.
|
|
|
|
|
(let ((item-up (assoc-default end-pos acc-end #'>)))
|
|
|
|
|
(push (cons
|
|
|
|
|
;; Else part is for the bottom point.
|
|
|
|
|
(if item-up (+ (org-list-get-ind item-up struct) 2) 0)
|
|
|
|
|
end-pos)
|
|
|
|
|
end-list)))
|
|
|
|
|
(push (cons ind-pos pos) end-list)
|
|
|
|
|
(push (cons end-pos pos) acc-end)))
|
2011-09-22 13:04:27 -04:00
|
|
|
|
(setq end-list (sort end-list (lambda (e1 e2) (< (cdr e1) (cdr e2)))))
|
|
|
|
|
(org-list-struct-assoc-end struct end-list)))
|
|
|
|
|
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(defun org-list-struct-apply-struct (struct old-struct)
|
2011-08-23 15:26:51 -04:00
|
|
|
|
"Apply set difference between STRUCT and OLD-STRUCT to the buffer.
|
2010-08-28 06:53:19 -04:00
|
|
|
|
|
2011-02-18 07:41:49 -05:00
|
|
|
|
OLD-STRUCT is the structure before any modifications, and STRUCT
|
2011-06-28 05:20:56 -04:00
|
|
|
|
the structure to be applied. The function will only modify parts
|
2011-02-18 07:41:49 -05:00
|
|
|
|
of the list which have changed.
|
2010-12-23 12:54:24 -05:00
|
|
|
|
|
|
|
|
|
Initial position of cursor is restored after the changes."
|
2011-08-23 20:11:36 -04:00
|
|
|
|
(let* ((origin (point-marker))
|
2011-01-26 15:36:39 -05:00
|
|
|
|
(inlinetask-re (and (featurep 'org-inlinetask)
|
|
|
|
|
(org-inlinetask-outline-regexp)))
|
2011-01-24 17:37:35 -05:00
|
|
|
|
(item-re (org-item-re))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(shift-body-ind
|
|
|
|
|
(function
|
2015-02-14 06:37:41 -05:00
|
|
|
|
;; Shift the indentation between END and BEG by DELTA.
|
|
|
|
|
;; Start from the line before END.
|
|
|
|
|
(lambda (end beg delta)
|
2011-01-21 10:31:30 -05:00
|
|
|
|
(goto-char end)
|
2011-01-23 15:59:36 -05:00
|
|
|
|
(skip-chars-backward " \r\t\n")
|
|
|
|
|
(beginning-of-line)
|
2011-01-21 10:31:30 -05:00
|
|
|
|
(while (or (> (point) beg)
|
2011-01-24 17:37:35 -05:00
|
|
|
|
(and (= (point) beg)
|
|
|
|
|
(not (looking-at item-re))))
|
2011-01-26 15:36:39 -05:00
|
|
|
|
(cond
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Skip inline tasks.
|
2011-01-26 15:36:39 -05:00
|
|
|
|
((and inlinetask-re (looking-at inlinetask-re))
|
|
|
|
|
(org-inlinetask-goto-beginning))
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Shift only non-empty lines.
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
((looking-at-p "^[ \t]*\\S-")
|
2018-05-08 19:26:31 -04:00
|
|
|
|
(indent-line-to (+ (current-indentation) delta))))
|
2011-01-21 10:31:30 -05:00
|
|
|
|
(forward-line -1)))))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(modify-item
|
|
|
|
|
(function
|
2011-01-21 10:31:30 -05:00
|
|
|
|
;; Replace ITEM first line elements with new elements from
|
2010-12-23 12:54:24 -05:00
|
|
|
|
;; STRUCT, if appropriate.
|
|
|
|
|
(lambda (item)
|
|
|
|
|
(goto-char item)
|
|
|
|
|
(let* ((new-ind (org-list-get-ind item struct))
|
2018-05-08 19:26:31 -04:00
|
|
|
|
(old-ind (current-indentation))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(new-bul (org-list-bullet-string
|
|
|
|
|
(org-list-get-bullet item struct)))
|
|
|
|
|
(old-bul (org-list-get-bullet item old-struct))
|
|
|
|
|
(new-box (org-list-get-checkbox item struct)))
|
|
|
|
|
(looking-at org-list-full-item-re)
|
2012-08-11 13:10:44 -04:00
|
|
|
|
;; a. Replace bullet
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(unless (equal old-bul new-bul)
|
|
|
|
|
(replace-match new-bul nil nil nil 1))
|
2012-08-11 13:10:44 -04:00
|
|
|
|
;; b. Replace checkbox.
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(cond
|
|
|
|
|
((equal (match-string 3) new-box))
|
|
|
|
|
((and (match-string 3) new-box)
|
|
|
|
|
(replace-match new-box nil nil nil 3))
|
|
|
|
|
((match-string 3)
|
2011-06-30 16:55:05 -04:00
|
|
|
|
(looking-at ".*?\\([ \t]*\\[[ X-]\\]\\)")
|
|
|
|
|
(replace-match "" nil nil nil 1))
|
|
|
|
|
(t (let ((counterp (match-end 2)))
|
|
|
|
|
(goto-char (if counterp (1+ counterp) (match-end 1)))
|
2011-08-23 15:26:51 -04:00
|
|
|
|
(insert (concat new-box (unless counterp " "))))))
|
2012-08-11 13:10:44 -04:00
|
|
|
|
;; c. Indent item to appropriate column.
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(unless (= new-ind old-ind)
|
|
|
|
|
(delete-region (goto-char (point-at-bol))
|
|
|
|
|
(progn (skip-chars-forward " \t") (point)))
|
|
|
|
|
(indent-to new-ind)))))))
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; 1. First get list of items and position endings. We maintain
|
2010-12-23 12:54:24 -05:00
|
|
|
|
;; two alists: ITM-SHIFT, determining indentation shift needed
|
2013-09-04 09:21:33 -04:00
|
|
|
|
;; at item, and END-LIST, a pseudo-alist where key is ending
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; position and value point.
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(let (end-list acc-end itm-shift all-ends sliced-struct)
|
2013-09-04 09:21:33 -04:00
|
|
|
|
(dolist (e old-struct)
|
|
|
|
|
(let* ((pos (car e))
|
|
|
|
|
(ind-pos (org-list-get-ind pos struct))
|
|
|
|
|
(ind-old (org-list-get-ind pos old-struct))
|
|
|
|
|
(bul-pos (org-list-get-bullet pos struct))
|
|
|
|
|
(bul-old (org-list-get-bullet pos old-struct))
|
|
|
|
|
(ind-shift (- (+ ind-pos (length bul-pos))
|
|
|
|
|
(+ ind-old (length bul-old))))
|
|
|
|
|
(end-pos (org-list-get-item-end pos old-struct)))
|
|
|
|
|
(push (cons pos ind-shift) itm-shift)
|
|
|
|
|
(unless (assq end-pos old-struct)
|
|
|
|
|
;; To determine real ind of an ending position that
|
|
|
|
|
;; is not at an item, we have to find the item it
|
|
|
|
|
;; belongs to: it is the last item (ITEM-UP), whose
|
|
|
|
|
;; ending is further than the position we're
|
|
|
|
|
;; interested in.
|
2015-02-14 06:37:41 -05:00
|
|
|
|
(let ((item-up (assoc-default end-pos acc-end #'>)))
|
2013-09-04 09:21:33 -04:00
|
|
|
|
(push (cons end-pos item-up) end-list)))
|
|
|
|
|
(push (cons end-pos pos) acc-end)))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
;; 2. Slice the items into parts that should be shifted by the
|
2013-09-04 09:21:33 -04:00
|
|
|
|
;; same amount of indentation. Each slice follow the pattern
|
2015-02-14 06:37:41 -05:00
|
|
|
|
;; (END BEG DELTA). Slices are returned in reverse order.
|
|
|
|
|
(setq all-ends (sort (append (mapcar #'car itm-shift)
|
|
|
|
|
(org-uniquify (mapcar #'car end-list)))
|
|
|
|
|
#'<)
|
|
|
|
|
acc-end (nreverse acc-end))
|
2010-12-23 12:54:24 -05:00
|
|
|
|
(while (cdr all-ends)
|
|
|
|
|
(let* ((up (pop all-ends))
|
|
|
|
|
(down (car all-ends))
|
2013-09-04 09:21:33 -04:00
|
|
|
|
(itemp (assq up struct))
|
2015-02-14 06:37:41 -05:00
|
|
|
|
(delta
|
|
|
|
|
(if itemp (cdr (assq up itm-shift))
|
|
|
|
|
;; If we're not at an item, there's a child of the
|
|
|
|
|
;; item point belongs to above. Make sure the less
|
|
|
|
|
;; indented line in this slice has the same column
|
|
|
|
|
;; as that child.
|
|
|
|
|
(let* ((child (cdr (assq up acc-end)))
|
|
|
|
|
(ind (org-list-get-ind child struct))
|
|
|
|
|
(min-ind most-positive-fixnum))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char up)
|
|
|
|
|
(while (< (point) down)
|
|
|
|
|
;; Ignore empty lines. Also ignore blocks and
|
|
|
|
|
;; drawers contents.
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(unless (looking-at-p "[ \t]*$")
|
2018-05-08 19:26:31 -04:00
|
|
|
|
(setq min-ind (min (current-indentation) min-ind))
|
2015-02-14 06:37:41 -05:00
|
|
|
|
(cond
|
|
|
|
|
((and (looking-at "#\\+BEGIN\\(:\\|_\\S-+\\)")
|
|
|
|
|
(re-search-forward
|
|
|
|
|
(format "^[ \t]*#\\+END%s[ \t]*$"
|
|
|
|
|
(match-string 1))
|
|
|
|
|
down t)))
|
|
|
|
|
((and (looking-at org-drawer-regexp)
|
|
|
|
|
(re-search-forward "^[ \t]*:END:[ \t]*$"
|
|
|
|
|
down t)))))
|
|
|
|
|
(forward-line)))
|
|
|
|
|
(- ind min-ind)))))
|
|
|
|
|
(push (list down up delta) sliced-struct)))
|
2011-01-21 10:31:30 -05:00
|
|
|
|
;; 3. Shift each slice in buffer, provided delta isn't 0, from
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; end to beginning. Take a special action when beginning is
|
2011-01-21 10:31:30 -05:00
|
|
|
|
;; at item bullet.
|
2013-09-04 09:21:33 -04:00
|
|
|
|
(dolist (e sliced-struct)
|
2015-02-14 06:37:41 -05:00
|
|
|
|
(unless (zerop (nth 2 e)) (apply shift-body-ind e))
|
2013-09-04 09:21:33 -04:00
|
|
|
|
(let* ((beg (nth 1 e))
|
|
|
|
|
(cell (assq beg struct)))
|
|
|
|
|
(unless (or (not cell) (equal cell (assq beg old-struct)))
|
|
|
|
|
(funcall modify-item beg)))))
|
2011-07-17 18:57:01 -04:00
|
|
|
|
;; 4. Go back to initial position and clean marker.
|
|
|
|
|
(goto-char origin)
|
|
|
|
|
(move-marker origin nil)))
|
2010-08-21 07:32:33 -04:00
|
|
|
|
|
2011-12-31 09:36:53 -05:00
|
|
|
|
(defun org-list-write-struct (struct parents &optional old-struct)
|
2011-02-18 07:41:49 -05:00
|
|
|
|
"Correct bullets, checkboxes and indentation in list at point.
|
2011-12-31 09:36:53 -05:00
|
|
|
|
|
2011-06-28 05:20:56 -04:00
|
|
|
|
STRUCT is the list structure. PARENTS is the alist of parents,
|
2011-12-31 09:36:53 -05:00
|
|
|
|
as returned by `org-list-parents-alist'.
|
|
|
|
|
|
|
|
|
|
When non-nil, optional argument OLD-STRUCT is the reference
|
|
|
|
|
structure of the list. It should be provided whenever STRUCT
|
|
|
|
|
doesn't correspond anymore to the real list in buffer."
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
;; Order of functions matters here: checkboxes and endings need
|
|
|
|
|
;; correct indentation to be set, and indentation needs correct
|
|
|
|
|
;; bullets.
|
|
|
|
|
;;
|
|
|
|
|
;; 0. Save a copy of structure before modifications
|
2011-12-31 09:36:53 -05:00
|
|
|
|
(let ((old-struct (or old-struct (copy-tree struct))))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
;; 1. Set a temporary, but coherent with PARENTS, indentation in
|
|
|
|
|
;; order to get items endings and bullets properly
|
|
|
|
|
(org-list-struct-fix-ind struct parents 2)
|
2011-09-22 13:04:27 -04:00
|
|
|
|
;; 2. Fix each item end to get correct prevs alist.
|
|
|
|
|
(org-list-struct-fix-item-end struct)
|
|
|
|
|
;; 3. Get bullets right.
|
|
|
|
|
(let ((prevs (org-list-prevs-alist struct)))
|
|
|
|
|
(org-list-struct-fix-bul struct prevs)
|
|
|
|
|
;; 4. Now get real indentation.
|
|
|
|
|
(org-list-struct-fix-ind struct parents)
|
|
|
|
|
;; 5. Eventually fix checkboxes.
|
|
|
|
|
(org-list-struct-fix-box struct parents prevs))
|
|
|
|
|
;; 6. Apply structure modifications to buffer.
|
2018-04-28 06:43:14 -04:00
|
|
|
|
(org-list-struct-apply-struct struct old-struct))
|
|
|
|
|
;; 7. Return the updated structure
|
|
|
|
|
struct)
|
2009-11-02 16:01:38 -05:00
|
|
|
|
|
2010-07-10 11:02:58 -04:00
|
|
|
|
|
2011-08-23 16:17:20 -04:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
;;; Misc Tools
|
2008-09-23 02:03:13 -04:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(defun org-apply-on-list (function init-value &rest args)
|
|
|
|
|
"Call FUNCTION on each item of the list at point.
|
|
|
|
|
FUNCTION must be called with at least one argument: INIT-VALUE,
|
|
|
|
|
that will contain the value returned by the function at the
|
|
|
|
|
previous item, plus ARGS extra arguments.
|
org-list: implement alphabetical lists
* lisp/org-list.el (org-alphabetical-lists): new variable
(org-item-re, org-list-full-item, org-cycle-list-bullet,
org-list-struct-fix-bul, org-list-inc-bullet-maybe): reflect
introduction of the new variable.
(org-item-beginning-re): changed into a function, so any modification
of `org-alphabetical-lists' will not require reloading Org.
(org-at-item-p, org-toggle-checkbox, org-update-checkbox-count,
org-list-parse-list, org-list-send-list): reflect changes to
`org-item-beginning-re'.
(org-list-use-alpha-bul-p): new function.
* lisp/org.el (org-check-for-hidden): reflect changes to
`org-item-beginning-re'.
* lisp/org-capture.el (org-capture-place-item): reflect changes to
`org-item-beginning-re'.
* lisp/org-docbook.el (org-export-docbook-list-line): handle new type
of items.
* lisp/org-exp.el (org-export-mark-list-end,
org-export-mark-list-properties): reflect changes to
`org-item-beginning-re'.
* lisp/org-html.el (org-html-export-list-line): handle new type of
items.
* lisp/org-latex.el (org-export-latex-lists): handle new type of items
and reflect changes to `org-item-beginning-re'.
* lisp/org-ascii.el (org-export-ascii-preprocess): handle new counters.
Modified from a patch by Nathaniel Flath.
2011-01-13 17:25:55 -05:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
FUNCTION is applied on items in reverse order.
|
org-list: implement alphabetical lists
* lisp/org-list.el (org-alphabetical-lists): new variable
(org-item-re, org-list-full-item, org-cycle-list-bullet,
org-list-struct-fix-bul, org-list-inc-bullet-maybe): reflect
introduction of the new variable.
(org-item-beginning-re): changed into a function, so any modification
of `org-alphabetical-lists' will not require reloading Org.
(org-at-item-p, org-toggle-checkbox, org-update-checkbox-count,
org-list-parse-list, org-list-send-list): reflect changes to
`org-item-beginning-re'.
(org-list-use-alpha-bul-p): new function.
* lisp/org.el (org-check-for-hidden): reflect changes to
`org-item-beginning-re'.
* lisp/org-capture.el (org-capture-place-item): reflect changes to
`org-item-beginning-re'.
* lisp/org-docbook.el (org-export-docbook-list-line): handle new type
of items.
* lisp/org-exp.el (org-export-mark-list-end,
org-export-mark-list-properties): reflect changes to
`org-item-beginning-re'.
* lisp/org-html.el (org-html-export-list-line): handle new type of
items.
* lisp/org-latex.el (org-export-latex-lists): handle new type of items
and reflect changes to `org-item-beginning-re'.
* lisp/org-ascii.el (org-export-ascii-preprocess): handle new counters.
Modified from a patch by Nathaniel Flath.
2011-01-13 17:25:55 -05:00
|
|
|
|
|
2015-09-17 19:08:20 -04:00
|
|
|
|
As an example, \(org-apply-on-list \(lambda \(result) \(1+ result)) 0)
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
will return the number of items in the current list.
|
|
|
|
|
|
2011-06-28 05:20:56 -04:00
|
|
|
|
Sublists of the list are skipped. Cursor is always at the
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
beginning of the item."
|
|
|
|
|
(let* ((struct (org-list-struct))
|
|
|
|
|
(prevs (org-list-prevs-alist struct))
|
|
|
|
|
(item (copy-marker (point-at-bol)))
|
|
|
|
|
(all (org-list-get-all-items (marker-position item) struct prevs))
|
|
|
|
|
(value init-value))
|
2020-05-01 09:51:43 -04:00
|
|
|
|
(dolist (e (nreverse all))
|
|
|
|
|
(goto-char e)
|
|
|
|
|
(setq value (apply function value args)))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(goto-char item)
|
2011-07-17 18:57:01 -04:00
|
|
|
|
(move-marker item nil)
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
value))
|
|
|
|
|
|
2011-01-30 11:42:38 -05:00
|
|
|
|
(defun org-list-set-item-visibility (item struct view)
|
2011-02-18 07:41:49 -05:00
|
|
|
|
"Set visibility of ITEM in STRUCT to VIEW.
|
2011-01-30 11:42:38 -05:00
|
|
|
|
|
2011-08-23 15:26:51 -04:00
|
|
|
|
Possible values are: `folded', `children' or `subtree'. See
|
2011-02-18 07:41:49 -05:00
|
|
|
|
`org-cycle' for more information."
|
2011-01-30 11:42:38 -05:00
|
|
|
|
(cond
|
|
|
|
|
((eq view 'folded)
|
|
|
|
|
(let ((item-end (org-list-get-item-end-before-blank item struct)))
|
|
|
|
|
;; Hide from eol
|
2017-12-06 10:22:09 -05:00
|
|
|
|
(org-flag-region (save-excursion (goto-char item) (line-end-position))
|
|
|
|
|
item-end t 'outline)))
|
2011-01-30 11:42:38 -05:00
|
|
|
|
((eq view 'children)
|
|
|
|
|
;; First show everything.
|
|
|
|
|
(org-list-set-item-visibility item struct 'subtree)
|
|
|
|
|
;; Then fold every child.
|
|
|
|
|
(let* ((parents (org-list-parents-alist struct))
|
|
|
|
|
(children (org-list-get-children item struct parents)))
|
2020-05-01 09:51:43 -04:00
|
|
|
|
(dolist (child children)
|
|
|
|
|
(org-list-set-item-visibility child struct 'folded))))
|
2011-01-30 11:42:38 -05:00
|
|
|
|
((eq view 'subtree)
|
|
|
|
|
;; Show everything
|
|
|
|
|
(let ((item-end (org-list-get-item-end item struct)))
|
2017-12-06 10:22:09 -05:00
|
|
|
|
(org-flag-region item item-end nil 'outline)))))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
|
2011-01-30 14:22:35 -05:00
|
|
|
|
(defun org-list-item-body-column (item)
|
2011-02-18 07:41:49 -05:00
|
|
|
|
"Return column at which body of ITEM should start."
|
2014-10-13 13:03:14 -04:00
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char item)
|
2019-01-30 18:20:09 -05:00
|
|
|
|
(looking-at "[ \t]*\\(\\S-+\\)")
|
|
|
|
|
(+ (progn (goto-char (match-end 1)) (current-column))
|
|
|
|
|
(if (and org-list-two-spaces-after-bullet-regexp
|
|
|
|
|
(string-match-p org-list-two-spaces-after-bullet-regexp
|
|
|
|
|
(match-string 1)))
|
|
|
|
|
2
|
|
|
|
|
1))))
|
2011-01-30 14:22:35 -05:00
|
|
|
|
|
|
|
|
|
|
2011-08-23 16:17:20 -04:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
;;; Interactive functions
|
|
|
|
|
|
|
|
|
|
(defalias 'org-list-get-item-begin 'org-in-item-p)
|
|
|
|
|
|
|
|
|
|
(defun org-beginning-of-item ()
|
2011-02-18 07:41:49 -05:00
|
|
|
|
"Go to the beginning of the current item.
|
|
|
|
|
Throw an error when not in a list."
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(interactive)
|
|
|
|
|
(let ((begin (org-in-item-p)))
|
|
|
|
|
(if begin (goto-char begin) (error "Not in an item"))))
|
|
|
|
|
|
|
|
|
|
(defun org-beginning-of-item-list ()
|
|
|
|
|
"Go to the beginning item of the current list or sublist.
|
2011-02-18 07:41:49 -05:00
|
|
|
|
Throw an error when not in a list."
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(interactive)
|
|
|
|
|
(let ((begin (org-in-item-p)))
|
|
|
|
|
(if (not begin)
|
|
|
|
|
(error "Not in an item")
|
|
|
|
|
(goto-char begin)
|
|
|
|
|
(let* ((struct (org-list-struct))
|
|
|
|
|
(prevs (org-list-prevs-alist struct)))
|
|
|
|
|
(goto-char (org-list-get-list-begin begin struct prevs))))))
|
|
|
|
|
|
|
|
|
|
(defun org-end-of-item-list ()
|
|
|
|
|
"Go to the end of the current list or sublist.
|
2011-02-18 07:41:49 -05:00
|
|
|
|
Throw an error when not in a list."
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(interactive)
|
|
|
|
|
(let ((begin (org-in-item-p)))
|
|
|
|
|
(if (not begin)
|
|
|
|
|
(error "Not in an item")
|
|
|
|
|
(goto-char begin)
|
|
|
|
|
(let* ((struct (org-list-struct))
|
|
|
|
|
(prevs (org-list-prevs-alist struct)))
|
|
|
|
|
(goto-char (org-list-get-list-end begin struct prevs))))))
|
|
|
|
|
|
|
|
|
|
(defun org-end-of-item ()
|
2011-02-18 07:41:49 -05:00
|
|
|
|
"Go to the end of the current item.
|
|
|
|
|
Throw an error when not in a list."
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(interactive)
|
|
|
|
|
(let ((begin (org-in-item-p)))
|
|
|
|
|
(if (not begin)
|
|
|
|
|
(error "Not in an item")
|
|
|
|
|
(goto-char begin)
|
|
|
|
|
(let ((struct (org-list-struct)))
|
|
|
|
|
(goto-char (org-list-get-item-end begin struct))))))
|
|
|
|
|
|
|
|
|
|
(defun org-previous-item ()
|
|
|
|
|
"Move to the beginning of the previous item.
|
2011-07-02 14:51:17 -04:00
|
|
|
|
Throw an error when not in a list. Also throw an error when at
|
|
|
|
|
first item, unless `org-list-use-circular-motion' is non-nil."
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(interactive)
|
2011-07-02 14:51:17 -04:00
|
|
|
|
(let ((item (org-in-item-p)))
|
|
|
|
|
(if (not item)
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(error "Not in an item")
|
2011-07-02 14:51:17 -04:00
|
|
|
|
(goto-char item)
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(let* ((struct (org-list-struct))
|
|
|
|
|
(prevs (org-list-prevs-alist struct))
|
2011-07-02 14:51:17 -04:00
|
|
|
|
(prevp (org-list-get-prev-item item struct prevs)))
|
|
|
|
|
(cond
|
|
|
|
|
(prevp (goto-char prevp))
|
|
|
|
|
(org-list-use-circular-motion
|
|
|
|
|
(goto-char (org-list-get-last-item item struct prevs)))
|
|
|
|
|
(t (error "On first item")))))))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
|
|
|
|
|
(defun org-next-item ()
|
|
|
|
|
"Move to the beginning of the next item.
|
2011-07-02 14:51:17 -04:00
|
|
|
|
Throw an error when not in a list. Also throw an error when at
|
|
|
|
|
last item, unless `org-list-use-circular-motion' is non-nil."
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(interactive)
|
2011-07-02 14:51:17 -04:00
|
|
|
|
(let ((item (org-in-item-p)))
|
|
|
|
|
(if (not item)
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(error "Not in an item")
|
2011-07-02 14:51:17 -04:00
|
|
|
|
(goto-char item)
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(let* ((struct (org-list-struct))
|
|
|
|
|
(prevs (org-list-prevs-alist struct))
|
2011-07-02 14:51:17 -04:00
|
|
|
|
(prevp (org-list-get-next-item item struct prevs)))
|
|
|
|
|
(cond
|
|
|
|
|
(prevp (goto-char prevp))
|
|
|
|
|
(org-list-use-circular-motion
|
|
|
|
|
(goto-char (org-list-get-first-item item struct prevs)))
|
|
|
|
|
(t (error "On last item")))))))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
|
|
|
|
|
(defun org-move-item-down ()
|
2011-02-18 07:41:49 -05:00
|
|
|
|
"Move the item at point down, i.e. swap with following item.
|
2011-07-02 14:51:17 -04:00
|
|
|
|
Sub-items (items with larger indentation) are considered part of
|
2011-02-18 07:41:49 -05:00
|
|
|
|
the item, so this really moves item trees."
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(interactive)
|
|
|
|
|
(unless (org-at-item-p) (error "Not at an item"))
|
2011-07-02 14:51:17 -04:00
|
|
|
|
(let* ((col (current-column))
|
|
|
|
|
(item (point-at-bol))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(struct (org-list-struct))
|
|
|
|
|
(prevs (org-list-prevs-alist struct))
|
|
|
|
|
(next-item (org-list-get-next-item (point-at-bol) struct prevs)))
|
2011-07-02 14:51:17 -04:00
|
|
|
|
(unless (or next-item org-list-use-circular-motion)
|
2013-02-22 04:31:35 -05:00
|
|
|
|
(user-error "Cannot move this item further down"))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(if (not next-item)
|
2011-07-02 14:51:17 -04:00
|
|
|
|
(setq struct (org-list-send-item item 'begin struct))
|
2011-07-11 10:49:31 -04:00
|
|
|
|
(setq struct (org-list-swap-items item next-item struct))
|
2011-07-02 14:51:17 -04:00
|
|
|
|
(goto-char
|
|
|
|
|
(org-list-get-next-item item struct (org-list-prevs-alist struct))))
|
|
|
|
|
(org-list-write-struct struct (org-list-parents-alist struct))
|
|
|
|
|
(org-move-to-column col)))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
|
|
|
|
|
(defun org-move-item-up ()
|
2011-02-18 07:41:49 -05:00
|
|
|
|
"Move the item at point up, i.e. swap with previous item.
|
2011-07-02 14:51:17 -04:00
|
|
|
|
Sub-items (items with larger indentation) are considered part of
|
2011-02-18 07:41:49 -05:00
|
|
|
|
the item, so this really moves item trees."
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(interactive)
|
|
|
|
|
(unless (org-at-item-p) (error "Not at an item"))
|
2011-07-02 14:51:17 -04:00
|
|
|
|
(let* ((col (current-column))
|
|
|
|
|
(item (point-at-bol))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(struct (org-list-struct))
|
|
|
|
|
(prevs (org-list-prevs-alist struct))
|
|
|
|
|
(prev-item (org-list-get-prev-item (point-at-bol) struct prevs)))
|
2011-07-02 14:51:17 -04:00
|
|
|
|
(unless (or prev-item org-list-use-circular-motion)
|
2013-02-22 04:31:35 -05:00
|
|
|
|
(user-error "Cannot move this item further up"))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(if (not prev-item)
|
2011-07-02 14:51:17 -04:00
|
|
|
|
(setq struct (org-list-send-item item 'end struct))
|
2011-07-11 10:49:31 -04:00
|
|
|
|
(setq struct (org-list-swap-items prev-item item struct)))
|
2011-07-02 14:51:17 -04:00
|
|
|
|
(org-list-write-struct struct (org-list-parents-alist struct))
|
|
|
|
|
(org-move-to-column col)))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
|
|
|
|
|
(defun org-insert-item (&optional checkbox)
|
|
|
|
|
"Insert a new item at the current level.
|
|
|
|
|
If cursor is before first character after bullet of the item, the
|
|
|
|
|
new item will be created before the current one.
|
|
|
|
|
|
|
|
|
|
If CHECKBOX is non-nil, add a checkbox next to the bullet.
|
|
|
|
|
|
|
|
|
|
Return t when things worked, nil when we are not in an item, or
|
|
|
|
|
item is invisible."
|
2016-10-28 13:48:47 -04:00
|
|
|
|
(interactive "P")
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(let ((itemp (org-in-item-p))
|
|
|
|
|
(pos (point)))
|
|
|
|
|
;; If cursor isn't is a list or if list is invisible, return nil.
|
|
|
|
|
(unless (or (not itemp)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char itemp)
|
Fix breakage due to outline-invisible-p defn change in emacs 26+
* lisp/org.el (org-invisible-p): New function. Restore the behavior
of outline-invisible-p prior to the following commint on emacs master
<http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=9cc59ffbbb2f20fbbf1c72d2e0c9dc47c7906a99>.
* lisp/org.el (org-cycle-internal-local)
(org-clean-visibility-after-subtree-move, org-goto)
(org-get-location, org-move-subtree-down, org-copy-subtree)
(org-paste-subtree, org-next-link, org-mark-ring-goto)
(org-todo, org-deadline, org-schedule, org-set-tags)
(org-truely-invisible-p, org-invisible-p2)
(org-forward-heading-same-level, org-forward-paragraph)
(org-backward-paragraph, org-down-element)
(org-bookmark-jump-unhide, org-mark-jump-unhide):
* lisp/org-list.el (org-insert-item):
* lisp/org-crypt.el (org-encrypt-entry, org-decrypt-entry):
* lisp/org-clock.el (org-clock-load):
* lisp/org-archive.el (org-archive-subtree)
(org-archive-to-archive-sibling, org-toggle-archive-tag)
(org-archive-set-tag):
* contrib/lisp/org-drill.el (org-drill-hide-subheadings-if): Use
org-invisible-p instead of outline-invisible-p.
Reference:
<http://lists.gnu.org/archive/html/emacs-orgmode/2017-06/msg00230.html>
2017-06-14 11:20:05 -04:00
|
|
|
|
(org-invisible-p)))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(if (save-excursion
|
|
|
|
|
(goto-char itemp)
|
|
|
|
|
(org-at-item-timer-p))
|
|
|
|
|
;; Timer list: delegate to `org-timer-item'.
|
|
|
|
|
(progn (org-timer-item) t)
|
2011-07-18 07:51:15 -04:00
|
|
|
|
(let* ((struct (save-excursion (goto-char itemp)
|
|
|
|
|
(org-list-struct)))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(prevs (org-list-prevs-alist struct))
|
|
|
|
|
;; If we're in a description list, ask for the new term.
|
2012-08-18 06:37:39 -04:00
|
|
|
|
(desc (when (eq (org-list-get-list-type itemp struct prevs)
|
|
|
|
|
'descriptive)
|
2013-03-16 14:15:58 -04:00
|
|
|
|
" :: ")))
|
|
|
|
|
(setq struct (org-list-insert-item pos struct prevs checkbox desc))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(org-list-write-struct struct (org-list-parents-alist struct))
|
2012-06-09 08:38:20 -04:00
|
|
|
|
(when checkbox (org-update-checkbox-count-maybe))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(looking-at org-list-full-item-re)
|
2012-08-18 06:37:39 -04:00
|
|
|
|
(goto-char (if (and (match-beginning 4)
|
|
|
|
|
(save-match-data
|
|
|
|
|
(string-match "[.)]" (match-string 1))))
|
|
|
|
|
(match-beginning 4)
|
|
|
|
|
(match-end 0)))
|
Many small code improvements
* lisp/org-capture.el (org-capture-member): Make obsolete; the old
definition was identical to ‘org-capture-get’ anyway.
(org-capture-mode-map): Move the calls to ‘define-key’ up to where the
variable is defined.
(org-capture-mode-hook): Small docstring tweak.
(org-capture-mode): Fix typo in mode lighter.
(org-capture-set-target-location, org-capture-place-item):
(org-capture-place-plain-text, org-capture-narrow):
(org-capture-empty-lines-after):
(org-capture-import-remember-templates): ‘if’ without else -> ‘when’
* lisp/org-colview.el (org-columns-edit-value): Change an error to a
user-error.
(org-columns-uncompile-format): Improve docstring.
* lisp/org-compat.el (org-remove-from-invisibility-spec): Make
obsolete, the underlying emacs function exists since 1997, commit 31aa282e.
(org-in-invisibility-spec-p, org-count-lines): ‘if’ without else -> ‘when’.
* lisp/org-element.el (org-element-swap-A-B):
* lisp/org-entities.el (org-entities-create-table):
* lisp/org-list.el (org-insert-item):
* lisp/org-macs.el (org-with-point-at, org-base-buffer):
(org-preserve-local-variables, org-overlay-display):
(org-overlay-before-string): ‘if’ without else -> ‘when’.
* lisp/org-eshell.el (org-eshell-open): Fix docstring typo.
* lisp/org-pcomplete.el (pcomplete/org-mode/file-option/language):
(pcomplete/org-mode/file-option/startup):
(pcomplete/org-mode/file-option/options):
(pcomplete/org-mode/file-option/infojs_opt):
(pcomplete/org-mode/link, pcomplete/org-mode/tex):
(pcomplete/org-mode/todo, pcomplete/org-mode/searchhead):
(pcomplete/org-mode/tag, pcomplete/org-mode/prop): Avoid the formerly
misspelled ‘pcomplete-uniqify-list’ function. It has a defalias in
emacs >= 27; we add our own for older emacsen.
(pcomplete/org-mode/file-option/bind): ‘if’ without else -> ‘when’.
* lisp/org-protocol.el (org-protocol-capture):
(org-protocol-convert-query-to-plist): ‘if’ without else -> ‘when’.
(org-protocol-do-capture): Pacify byte compiler, simplify conditional
logic.
* lisp/org-table.el (org-table-create-with-table.el): Simplify conditional
logic.
(org-table-create, org-table-convert-region, org-table-next-field):
(org-table-beginning-of-field, org-table-end-of-field):
* lisp/org-w3m.el (org-w3m-copy-for-org-mode): ‘if’ without else ->
‘when’.
* lisp/org.el (org-babel-do-load-languages, org-previous-link):
(org-refile): Use ‘(foo ...)’ instead of ‘(funcall 'foo ...)’.
(org-add-log-note): Convert a long cond into a cl-case.
(org-priority): Improve docstring, show a deprecation warning if the
‘show’ argument is passed (which was previously silently ignored).
Also, use ?\s instead of ?\ as a character literal for space.
(org-fast-tag-insert): Fix docstring typo.
(org-fill-element): ‘if’ without else -> ‘when’.
(org-on-target-p): Remove ancient compatibility alias.
2018-05-09 21:02:35 -04:00
|
|
|
|
(when desc (backward-char 1))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
t)))))
|
2010-07-27 14:52:30 -04:00
|
|
|
|
|
2010-12-23 18:53:30 -05:00
|
|
|
|
(defun org-list-repair ()
|
2014-06-01 08:20:12 -04:00
|
|
|
|
"Fix indentation, bullets and checkboxes in the list at point."
|
2010-07-10 11:02:58 -04:00
|
|
|
|
(interactive)
|
|
|
|
|
(unless (org-at-item-p) (error "This is not a list"))
|
2010-12-23 18:53:30 -05:00
|
|
|
|
(let* ((struct (org-list-struct))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(parents (org-list-parents-alist struct)))
|
|
|
|
|
(org-list-write-struct struct parents)))
|
2010-07-30 18:45:34 -04:00
|
|
|
|
|
2010-07-10 11:02:58 -04:00
|
|
|
|
(defun org-cycle-list-bullet (&optional which)
|
|
|
|
|
"Cycle through the different itemize/enumerate bullets.
|
2010-07-20 06:36:01 -04:00
|
|
|
|
This cycle the entire list level through the sequence:
|
2010-07-10 11:02:58 -04:00
|
|
|
|
|
2010-07-20 05:06:35 -04:00
|
|
|
|
`-' -> `+' -> `*' -> `1.' -> `1)'
|
2010-07-10 11:02:58 -04:00
|
|
|
|
|
2011-06-28 05:20:56 -04:00
|
|
|
|
If WHICH is a valid string, use that as the new bullet. If WHICH
|
|
|
|
|
is an integer, 0 means `-', 1 means `+' etc. If WHICH is
|
2010-12-23 18:53:30 -05:00
|
|
|
|
`previous', cycle backwards."
|
2010-07-10 11:02:58 -04:00
|
|
|
|
(interactive "P")
|
2011-01-24 17:37:35 -05:00
|
|
|
|
(unless (org-at-item-p) (error "Not at an item"))
|
2010-11-19 17:47:02 -05:00
|
|
|
|
(save-excursion
|
2010-12-23 18:53:30 -05:00
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(let* ((struct (org-list-struct))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(parents (org-list-parents-alist struct))
|
|
|
|
|
(prevs (org-list-prevs-alist struct))
|
org-list: implement alphabetical lists
* lisp/org-list.el (org-alphabetical-lists): new variable
(org-item-re, org-list-full-item, org-cycle-list-bullet,
org-list-struct-fix-bul, org-list-inc-bullet-maybe): reflect
introduction of the new variable.
(org-item-beginning-re): changed into a function, so any modification
of `org-alphabetical-lists' will not require reloading Org.
(org-at-item-p, org-toggle-checkbox, org-update-checkbox-count,
org-list-parse-list, org-list-send-list): reflect changes to
`org-item-beginning-re'.
(org-list-use-alpha-bul-p): new function.
* lisp/org.el (org-check-for-hidden): reflect changes to
`org-item-beginning-re'.
* lisp/org-capture.el (org-capture-place-item): reflect changes to
`org-item-beginning-re'.
* lisp/org-docbook.el (org-export-docbook-list-line): handle new type
of items.
* lisp/org-exp.el (org-export-mark-list-end,
org-export-mark-list-properties): reflect changes to
`org-item-beginning-re'.
* lisp/org-html.el (org-html-export-list-line): handle new type of
items.
* lisp/org-latex.el (org-export-latex-lists): handle new type of items
and reflect changes to `org-item-beginning-re'.
* lisp/org-ascii.el (org-export-ascii-preprocess): handle new counters.
Modified from a patch by Nathaniel Flath.
2011-01-13 17:25:55 -05:00
|
|
|
|
(list-beg (org-list-get-first-item (point) struct prevs))
|
2010-12-23 18:53:30 -05:00
|
|
|
|
(bullet (org-list-get-bullet list-beg struct))
|
org-list: implement alphabetical lists
* lisp/org-list.el (org-alphabetical-lists): new variable
(org-item-re, org-list-full-item, org-cycle-list-bullet,
org-list-struct-fix-bul, org-list-inc-bullet-maybe): reflect
introduction of the new variable.
(org-item-beginning-re): changed into a function, so any modification
of `org-alphabetical-lists' will not require reloading Org.
(org-at-item-p, org-toggle-checkbox, org-update-checkbox-count,
org-list-parse-list, org-list-send-list): reflect changes to
`org-item-beginning-re'.
(org-list-use-alpha-bul-p): new function.
* lisp/org.el (org-check-for-hidden): reflect changes to
`org-item-beginning-re'.
* lisp/org-capture.el (org-capture-place-item): reflect changes to
`org-item-beginning-re'.
* lisp/org-docbook.el (org-export-docbook-list-line): handle new type
of items.
* lisp/org-exp.el (org-export-mark-list-end,
org-export-mark-list-properties): reflect changes to
`org-item-beginning-re'.
* lisp/org-html.el (org-html-export-list-line): handle new type of
items.
* lisp/org-latex.el (org-export-latex-lists): handle new type of items
and reflect changes to `org-item-beginning-re'.
* lisp/org-ascii.el (org-export-ascii-preprocess): handle new counters.
Modified from a patch by Nathaniel Flath.
2011-01-13 17:25:55 -05:00
|
|
|
|
(alpha-p (org-list-use-alpha-bul-p list-beg struct prevs))
|
|
|
|
|
(case-fold-search nil)
|
2010-11-19 17:47:02 -05:00
|
|
|
|
(current (cond
|
org-list: implement alphabetical lists
* lisp/org-list.el (org-alphabetical-lists): new variable
(org-item-re, org-list-full-item, org-cycle-list-bullet,
org-list-struct-fix-bul, org-list-inc-bullet-maybe): reflect
introduction of the new variable.
(org-item-beginning-re): changed into a function, so any modification
of `org-alphabetical-lists' will not require reloading Org.
(org-at-item-p, org-toggle-checkbox, org-update-checkbox-count,
org-list-parse-list, org-list-send-list): reflect changes to
`org-item-beginning-re'.
(org-list-use-alpha-bul-p): new function.
* lisp/org.el (org-check-for-hidden): reflect changes to
`org-item-beginning-re'.
* lisp/org-capture.el (org-capture-place-item): reflect changes to
`org-item-beginning-re'.
* lisp/org-docbook.el (org-export-docbook-list-line): handle new type
of items.
* lisp/org-exp.el (org-export-mark-list-end,
org-export-mark-list-properties): reflect changes to
`org-item-beginning-re'.
* lisp/org-html.el (org-html-export-list-line): handle new type of
items.
* lisp/org-latex.el (org-export-latex-lists): handle new type of items
and reflect changes to `org-item-beginning-re'.
* lisp/org-ascii.el (org-export-ascii-preprocess): handle new counters.
Modified from a patch by Nathaniel Flath.
2011-01-13 17:25:55 -05:00
|
|
|
|
((string-match "[a-z]\\." bullet) "a.")
|
|
|
|
|
((string-match "[a-z])" bullet) "a)")
|
|
|
|
|
((string-match "[A-Z]\\." bullet) "A.")
|
|
|
|
|
((string-match "[A-Z])" bullet) "A)")
|
2010-11-19 17:47:02 -05:00
|
|
|
|
((string-match "\\." bullet) "1.")
|
|
|
|
|
((string-match ")" bullet) "1)")
|
2010-12-23 18:53:30 -05:00
|
|
|
|
(t (org-trim bullet))))
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Compute list of possible bullets, depending on context.
|
org-list: implement alphabetical lists
* lisp/org-list.el (org-alphabetical-lists): new variable
(org-item-re, org-list-full-item, org-cycle-list-bullet,
org-list-struct-fix-bul, org-list-inc-bullet-maybe): reflect
introduction of the new variable.
(org-item-beginning-re): changed into a function, so any modification
of `org-alphabetical-lists' will not require reloading Org.
(org-at-item-p, org-toggle-checkbox, org-update-checkbox-count,
org-list-parse-list, org-list-send-list): reflect changes to
`org-item-beginning-re'.
(org-list-use-alpha-bul-p): new function.
* lisp/org.el (org-check-for-hidden): reflect changes to
`org-item-beginning-re'.
* lisp/org-capture.el (org-capture-place-item): reflect changes to
`org-item-beginning-re'.
* lisp/org-docbook.el (org-export-docbook-list-line): handle new type
of items.
* lisp/org-exp.el (org-export-mark-list-end,
org-export-mark-list-properties): reflect changes to
`org-item-beginning-re'.
* lisp/org-html.el (org-html-export-list-line): handle new type of
items.
* lisp/org-latex.el (org-export-latex-lists): handle new type of items
and reflect changes to `org-item-beginning-re'.
* lisp/org-ascii.el (org-export-ascii-preprocess): handle new counters.
Modified from a patch by Nathaniel Flath.
2011-01-13 17:25:55 -05:00
|
|
|
|
(bullet-list
|
|
|
|
|
(append '("-" "+" )
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; *-bullets are not allowed at column 0.
|
2012-08-18 03:28:27 -04:00
|
|
|
|
(unless (looking-at "\\S-") '("*"))
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Description items cannot be numbered.
|
org-list: implement alphabetical lists
* lisp/org-list.el (org-alphabetical-lists): new variable
(org-item-re, org-list-full-item, org-cycle-list-bullet,
org-list-struct-fix-bul, org-list-inc-bullet-maybe): reflect
introduction of the new variable.
(org-item-beginning-re): changed into a function, so any modification
of `org-alphabetical-lists' will not require reloading Org.
(org-at-item-p, org-toggle-checkbox, org-update-checkbox-count,
org-list-parse-list, org-list-send-list): reflect changes to
`org-item-beginning-re'.
(org-list-use-alpha-bul-p): new function.
* lisp/org.el (org-check-for-hidden): reflect changes to
`org-item-beginning-re'.
* lisp/org-capture.el (org-capture-place-item): reflect changes to
`org-item-beginning-re'.
* lisp/org-docbook.el (org-export-docbook-list-line): handle new type
of items.
* lisp/org-exp.el (org-export-mark-list-end,
org-export-mark-list-properties): reflect changes to
`org-item-beginning-re'.
* lisp/org-html.el (org-html-export-list-line): handle new type of
items.
* lisp/org-latex.el (org-export-latex-lists): handle new type of items
and reflect changes to `org-item-beginning-re'.
* lisp/org-ascii.el (org-export-ascii-preprocess): handle new counters.
Modified from a patch by Nathaniel Flath.
2011-01-13 17:25:55 -05:00
|
|
|
|
(unless (or (eq org-plain-list-ordered-item-terminator ?\))
|
2012-08-18 03:28:27 -04:00
|
|
|
|
(org-at-item-description-p))
|
org-list: implement alphabetical lists
* lisp/org-list.el (org-alphabetical-lists): new variable
(org-item-re, org-list-full-item, org-cycle-list-bullet,
org-list-struct-fix-bul, org-list-inc-bullet-maybe): reflect
introduction of the new variable.
(org-item-beginning-re): changed into a function, so any modification
of `org-alphabetical-lists' will not require reloading Org.
(org-at-item-p, org-toggle-checkbox, org-update-checkbox-count,
org-list-parse-list, org-list-send-list): reflect changes to
`org-item-beginning-re'.
(org-list-use-alpha-bul-p): new function.
* lisp/org.el (org-check-for-hidden): reflect changes to
`org-item-beginning-re'.
* lisp/org-capture.el (org-capture-place-item): reflect changes to
`org-item-beginning-re'.
* lisp/org-docbook.el (org-export-docbook-list-line): handle new type
of items.
* lisp/org-exp.el (org-export-mark-list-end,
org-export-mark-list-properties): reflect changes to
`org-item-beginning-re'.
* lisp/org-html.el (org-html-export-list-line): handle new type of
items.
* lisp/org-latex.el (org-export-latex-lists): handle new type of items
and reflect changes to `org-item-beginning-re'.
* lisp/org-ascii.el (org-export-ascii-preprocess): handle new counters.
Modified from a patch by Nathaniel Flath.
2011-01-13 17:25:55 -05:00
|
|
|
|
'("1."))
|
|
|
|
|
(unless (or (eq org-plain-list-ordered-item-terminator ?.)
|
2012-08-18 03:28:27 -04:00
|
|
|
|
(org-at-item-description-p))
|
org-list: implement alphabetical lists
* lisp/org-list.el (org-alphabetical-lists): new variable
(org-item-re, org-list-full-item, org-cycle-list-bullet,
org-list-struct-fix-bul, org-list-inc-bullet-maybe): reflect
introduction of the new variable.
(org-item-beginning-re): changed into a function, so any modification
of `org-alphabetical-lists' will not require reloading Org.
(org-at-item-p, org-toggle-checkbox, org-update-checkbox-count,
org-list-parse-list, org-list-send-list): reflect changes to
`org-item-beginning-re'.
(org-list-use-alpha-bul-p): new function.
* lisp/org.el (org-check-for-hidden): reflect changes to
`org-item-beginning-re'.
* lisp/org-capture.el (org-capture-place-item): reflect changes to
`org-item-beginning-re'.
* lisp/org-docbook.el (org-export-docbook-list-line): handle new type
of items.
* lisp/org-exp.el (org-export-mark-list-end,
org-export-mark-list-properties): reflect changes to
`org-item-beginning-re'.
* lisp/org-html.el (org-html-export-list-line): handle new type of
items.
* lisp/org-latex.el (org-export-latex-lists): handle new type of items
and reflect changes to `org-item-beginning-re'.
* lisp/org-ascii.el (org-export-ascii-preprocess): handle new counters.
Modified from a patch by Nathaniel Flath.
2011-01-13 17:25:55 -05:00
|
|
|
|
'("1)"))
|
|
|
|
|
(unless (or (not alpha-p)
|
|
|
|
|
(eq org-plain-list-ordered-item-terminator ?\))
|
2012-08-18 03:28:27 -04:00
|
|
|
|
(org-at-item-description-p))
|
org-list: implement alphabetical lists
* lisp/org-list.el (org-alphabetical-lists): new variable
(org-item-re, org-list-full-item, org-cycle-list-bullet,
org-list-struct-fix-bul, org-list-inc-bullet-maybe): reflect
introduction of the new variable.
(org-item-beginning-re): changed into a function, so any modification
of `org-alphabetical-lists' will not require reloading Org.
(org-at-item-p, org-toggle-checkbox, org-update-checkbox-count,
org-list-parse-list, org-list-send-list): reflect changes to
`org-item-beginning-re'.
(org-list-use-alpha-bul-p): new function.
* lisp/org.el (org-check-for-hidden): reflect changes to
`org-item-beginning-re'.
* lisp/org-capture.el (org-capture-place-item): reflect changes to
`org-item-beginning-re'.
* lisp/org-docbook.el (org-export-docbook-list-line): handle new type
of items.
* lisp/org-exp.el (org-export-mark-list-end,
org-export-mark-list-properties): reflect changes to
`org-item-beginning-re'.
* lisp/org-html.el (org-html-export-list-line): handle new type of
items.
* lisp/org-latex.el (org-export-latex-lists): handle new type of items
and reflect changes to `org-item-beginning-re'.
* lisp/org-ascii.el (org-export-ascii-preprocess): handle new counters.
Modified from a patch by Nathaniel Flath.
2011-01-13 17:25:55 -05:00
|
|
|
|
'("a." "A."))
|
|
|
|
|
(unless (or (not alpha-p)
|
|
|
|
|
(eq org-plain-list-ordered-item-terminator ?.)
|
2012-08-18 03:28:27 -04:00
|
|
|
|
(org-at-item-description-p))
|
org-list: implement alphabetical lists
* lisp/org-list.el (org-alphabetical-lists): new variable
(org-item-re, org-list-full-item, org-cycle-list-bullet,
org-list-struct-fix-bul, org-list-inc-bullet-maybe): reflect
introduction of the new variable.
(org-item-beginning-re): changed into a function, so any modification
of `org-alphabetical-lists' will not require reloading Org.
(org-at-item-p, org-toggle-checkbox, org-update-checkbox-count,
org-list-parse-list, org-list-send-list): reflect changes to
`org-item-beginning-re'.
(org-list-use-alpha-bul-p): new function.
* lisp/org.el (org-check-for-hidden): reflect changes to
`org-item-beginning-re'.
* lisp/org-capture.el (org-capture-place-item): reflect changes to
`org-item-beginning-re'.
* lisp/org-docbook.el (org-export-docbook-list-line): handle new type
of items.
* lisp/org-exp.el (org-export-mark-list-end,
org-export-mark-list-properties): reflect changes to
`org-item-beginning-re'.
* lisp/org-html.el (org-html-export-list-line): handle new type of
items.
* lisp/org-latex.el (org-export-latex-lists): handle new type of items
and reflect changes to `org-item-beginning-re'.
* lisp/org-ascii.el (org-export-ascii-preprocess): handle new counters.
Modified from a patch by Nathaniel Flath.
2011-01-13 17:25:55 -05:00
|
|
|
|
'("a)" "A)"))))
|
2010-11-19 17:47:02 -05:00
|
|
|
|
(len (length bullet-list))
|
|
|
|
|
(item-index (- len (length (member current bullet-list))))
|
|
|
|
|
(get-value (lambda (index) (nth (mod index len) bullet-list)))
|
|
|
|
|
(new (cond
|
|
|
|
|
((member which bullet-list) which)
|
|
|
|
|
((numberp which) (funcall get-value which))
|
|
|
|
|
((eq 'previous which) (funcall get-value (1- item-index)))
|
|
|
|
|
(t (funcall get-value (1+ item-index))))))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
;; Use a short variation of `org-list-write-struct' as there's
|
|
|
|
|
;; no need to go through all the steps.
|
2011-01-21 10:31:30 -05:00
|
|
|
|
(let ((old-struct (copy-tree struct)))
|
2010-12-23 18:53:30 -05:00
|
|
|
|
(org-list-set-bullet list-beg struct (org-list-bullet-string new))
|
|
|
|
|
(org-list-struct-fix-bul struct prevs)
|
|
|
|
|
(org-list-struct-fix-ind struct parents)
|
|
|
|
|
(org-list-struct-apply-struct struct old-struct)))))
|
2010-07-10 11:02:58 -04:00
|
|
|
|
|
2020-02-11 17:55:53 -05:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(define-minor-mode org-list-checkbox-radio-mode
|
|
|
|
|
"When turned on, use list checkboxes as radio buttons."
|
|
|
|
|
nil " CheckBoxRadio" nil
|
|
|
|
|
(unless (eq major-mode 'org-mode)
|
|
|
|
|
(user-error "Cannot turn this mode outside org-mode buffers")))
|
|
|
|
|
|
|
|
|
|
(defun org-toggle-radio-button (&optional arg)
|
|
|
|
|
"Toggle off all checkboxes and toggle on the one at point."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(if (not (org-at-item-p))
|
|
|
|
|
(user-error "Cannot toggle checkbox outside of a list")
|
|
|
|
|
(let* ((cpos (org-in-item-p))
|
|
|
|
|
(struct (org-list-struct))
|
|
|
|
|
(orderedp (org-entry-get nil "ORDERED"))
|
|
|
|
|
(parents (org-list-parents-alist struct))
|
|
|
|
|
(old-struct (copy-tree struct))
|
|
|
|
|
(cbox (org-list-get-checkbox cpos struct))
|
|
|
|
|
(prevs (org-list-prevs-alist struct))
|
|
|
|
|
(start (org-list-get-list-begin (point-at-bol) struct prevs))
|
|
|
|
|
(new (unless (and cbox (equal arg '(4)) (equal start cpos))
|
|
|
|
|
"[ ]")))
|
|
|
|
|
(dolist (pos (org-list-get-all-items
|
|
|
|
|
start struct (org-list-prevs-alist struct)))
|
|
|
|
|
(org-list-set-checkbox pos struct new))
|
|
|
|
|
(when new
|
|
|
|
|
(org-list-set-checkbox
|
|
|
|
|
cpos struct
|
|
|
|
|
(cond ((equal arg '(4)) (unless cbox "[ ]"))
|
|
|
|
|
((equal arg '(16)) (unless cbox "[-]"))
|
|
|
|
|
(t (if (equal cbox "[X]") "[ ]" "[X]")))))
|
|
|
|
|
(org-list-struct-fix-box struct parents prevs orderedp)
|
|
|
|
|
(org-list-struct-apply-struct struct old-struct)
|
|
|
|
|
(org-update-checkbox-count-maybe))))
|
|
|
|
|
|
2020-02-16 18:31:39 -05:00
|
|
|
|
(defun org-at-radio-list-p ()
|
|
|
|
|
"Is point at a list item with radio buttons?"
|
|
|
|
|
(when (org-match-line (org-item-re)) ;short-circuit
|
|
|
|
|
(let* ((e (save-excursion (beginning-of-line) (org-element-at-point))))
|
|
|
|
|
;; Check we're really on a line with a bullet.
|
|
|
|
|
(when (memq (org-element-type e) '(item plain-list))
|
|
|
|
|
;; Look for ATTR_ORG attribute in the current plain list.
|
|
|
|
|
(let ((plain-list (org-element-lineage e '(plain-list) t)))
|
|
|
|
|
(org-with-point-at (org-element-property :post-affiliated plain-list)
|
|
|
|
|
(let ((case-fold-search t)
|
|
|
|
|
(regexp "^[ \t]*#\\+attr_org:.* :radio \\(\\S-+\\)")
|
|
|
|
|
(begin (org-element-property :begin plain-list)))
|
|
|
|
|
(and (re-search-backward regexp begin t)
|
|
|
|
|
(not (string-equal "nil" (match-string 1)))))))))))
|
2020-02-11 19:51:46 -05:00
|
|
|
|
|
2010-07-10 11:02:58 -04:00
|
|
|
|
(defun org-toggle-checkbox (&optional toggle-presence)
|
|
|
|
|
"Toggle the checkbox in the current line.
|
2018-01-15 17:13:51 -05:00
|
|
|
|
|
|
|
|
|
With prefix argument TOGGLE-PRESENCE, add or remove checkboxes.
|
|
|
|
|
With a double prefix argument, set the checkbox to \"[-]\".
|
2010-07-28 09:53:37 -04:00
|
|
|
|
|
|
|
|
|
When there is an active region, toggle status or presence of the
|
2011-02-18 07:41:49 -05:00
|
|
|
|
first checkbox there, and make every item inside have the same
|
|
|
|
|
status or presence, respectively.
|
2010-07-28 09:53:37 -04:00
|
|
|
|
|
2018-01-15 17:13:51 -05:00
|
|
|
|
If point is on a headline, apply this to all checkbox items in
|
|
|
|
|
the text below the heading, taking as reference the first item in
|
|
|
|
|
subtree, ignoring planning line and any drawer following it."
|
2010-07-10 11:02:58 -04:00
|
|
|
|
(interactive "P")
|
2020-02-11 19:51:46 -05:00
|
|
|
|
(if (org-at-radio-list-p)
|
|
|
|
|
(org-toggle-radio-button toggle-presence)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let* (singlep
|
|
|
|
|
block-item
|
|
|
|
|
lim-up
|
|
|
|
|
lim-down
|
|
|
|
|
(orderedp (org-entry-get nil "ORDERED"))
|
|
|
|
|
(_bounds
|
|
|
|
|
;; In a region, start at first item in region.
|
|
|
|
|
(cond
|
|
|
|
|
((org-region-active-p)
|
|
|
|
|
(let ((limit (region-end)))
|
|
|
|
|
(goto-char (region-beginning))
|
|
|
|
|
(if (org-list-search-forward (org-item-beginning-re) limit t)
|
|
|
|
|
(setq lim-up (point-at-bol))
|
|
|
|
|
(error "No item in region"))
|
|
|
|
|
(setq lim-down (copy-marker limit))))
|
|
|
|
|
((org-at-heading-p)
|
|
|
|
|
;; On a heading, start at first item after drawers and
|
|
|
|
|
;; time-stamps (scheduled, etc.).
|
|
|
|
|
(let ((limit (save-excursion (outline-next-heading) (point))))
|
|
|
|
|
(org-end-of-meta-data t)
|
|
|
|
|
(if (org-list-search-forward (org-item-beginning-re) limit t)
|
|
|
|
|
(setq lim-up (point-at-bol))
|
|
|
|
|
(error "No item in subtree"))
|
|
|
|
|
(setq lim-down (copy-marker limit))))
|
|
|
|
|
;; Just one item: set SINGLEP flag.
|
|
|
|
|
((org-at-item-p)
|
|
|
|
|
(setq singlep t)
|
|
|
|
|
(setq lim-up (point-at-bol)
|
|
|
|
|
lim-down (copy-marker (point-at-eol))))
|
|
|
|
|
(t (error "Not at an item or heading, and no active region"))))
|
|
|
|
|
;; Determine the checkbox going to be applied to all items
|
|
|
|
|
;; within bounds.
|
|
|
|
|
(ref-checkbox
|
|
|
|
|
(progn
|
|
|
|
|
(goto-char lim-up)
|
|
|
|
|
(let ((cbox (and (org-at-item-checkbox-p) (match-string 1))))
|
|
|
|
|
(cond
|
|
|
|
|
((equal toggle-presence '(16)) "[-]")
|
|
|
|
|
((equal toggle-presence '(4))
|
|
|
|
|
(unless cbox "[ ]"))
|
|
|
|
|
((equal "[X]" cbox) "[ ]")
|
|
|
|
|
(t "[X]"))))))
|
|
|
|
|
;; When an item is found within bounds, grab the full list at
|
|
|
|
|
;; point structure, then: (1) set check-box of all its items
|
|
|
|
|
;; within bounds to REF-CHECKBOX, (2) fix check-boxes of the
|
|
|
|
|
;; whole list, (3) move point after the list.
|
|
|
|
|
(goto-char lim-up)
|
|
|
|
|
(while (and (< (point) lim-down)
|
|
|
|
|
(org-list-search-forward (org-item-beginning-re)
|
|
|
|
|
lim-down 'move))
|
|
|
|
|
(let* ((struct (org-list-struct))
|
|
|
|
|
(struct-copy (copy-tree struct))
|
|
|
|
|
(parents (org-list-parents-alist struct))
|
|
|
|
|
(prevs (org-list-prevs-alist struct))
|
|
|
|
|
(bottom (copy-marker (org-list-get-bottom-point struct)))
|
|
|
|
|
(items-to-toggle (cl-remove-if
|
|
|
|
|
(lambda (e) (or (< e lim-up) (> e lim-down)))
|
|
|
|
|
(mapcar #'car struct))))
|
2020-05-01 09:51:43 -04:00
|
|
|
|
(dolist (e items-to-toggle)
|
|
|
|
|
(org-list-set-checkbox
|
|
|
|
|
e struct
|
|
|
|
|
;; If there is no box at item, leave as-is unless
|
|
|
|
|
;; function was called with C-u prefix.
|
|
|
|
|
(let ((cur-box (org-list-get-checkbox e struct)))
|
|
|
|
|
(if (or cur-box (equal toggle-presence '(4)))
|
|
|
|
|
ref-checkbox
|
|
|
|
|
cur-box))))
|
2020-02-11 19:51:46 -05:00
|
|
|
|
(setq block-item (org-list-struct-fix-box
|
|
|
|
|
struct parents prevs orderedp))
|
|
|
|
|
;; Report some problems due to ORDERED status of subtree.
|
|
|
|
|
;; If only one box was being checked, throw an error, else,
|
|
|
|
|
;; only signal problems.
|
2010-12-17 13:54:25 -05:00
|
|
|
|
(cond
|
2020-02-11 19:51:46 -05:00
|
|
|
|
((and singlep block-item (> lim-up block-item))
|
|
|
|
|
(error
|
|
|
|
|
"Checkbox blocked because of unchecked box at line %d"
|
|
|
|
|
(org-current-line block-item)))
|
|
|
|
|
(block-item
|
|
|
|
|
(message
|
|
|
|
|
"Checkboxes were removed due to unchecked box at line %d"
|
|
|
|
|
(org-current-line block-item))))
|
|
|
|
|
(goto-char bottom)
|
|
|
|
|
(move-marker bottom nil)
|
|
|
|
|
(org-list-struct-apply-struct struct struct-copy)))
|
|
|
|
|
(move-marker lim-down nil))))
|
2011-03-30 13:00:45 -04:00
|
|
|
|
(org-update-checkbox-count-maybe))
|
2010-07-10 11:02:58 -04:00
|
|
|
|
|
|
|
|
|
(defun org-reset-checkbox-state-subtree ()
|
|
|
|
|
"Reset all checkboxes in an entry subtree."
|
|
|
|
|
(interactive "*")
|
2011-06-20 15:59:58 -04:00
|
|
|
|
(if (org-before-first-heading-p)
|
|
|
|
|
(error "Not inside a tree")
|
|
|
|
|
(save-restriction
|
|
|
|
|
(save-excursion
|
|
|
|
|
(org-narrow-to-subtree)
|
|
|
|
|
(org-show-subtree)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(let ((end (point-max)))
|
|
|
|
|
(while (< (point) end)
|
|
|
|
|
(when (org-at-item-checkbox-p)
|
|
|
|
|
(replace-match "[ ]" t t nil 1))
|
|
|
|
|
(beginning-of-line 2)))
|
|
|
|
|
(org-update-checkbox-count-maybe 'all)))))
|
2010-07-10 11:02:58 -04:00
|
|
|
|
|
|
|
|
|
(defun org-update-checkbox-count (&optional all)
|
|
|
|
|
"Update the checkbox statistics in the current section.
|
2015-06-09 11:06:17 -04:00
|
|
|
|
|
2010-12-17 13:54:25 -05:00
|
|
|
|
This will find all statistic cookies like [57%] and [6/12] and
|
|
|
|
|
update them with the current numbers.
|
|
|
|
|
|
|
|
|
|
With optional prefix argument ALL, do this for the whole buffer."
|
2010-07-10 11:02:58 -04:00
|
|
|
|
(interactive "P")
|
2015-06-09 11:06:17 -04:00
|
|
|
|
(org-with-wide-buffer
|
|
|
|
|
(let* ((cookie-re "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)")
|
|
|
|
|
(box-re "^[ \t]*\\([-+*]\\|\\([0-9]+\\|[A-Za-z]\\)[.)]\\)[ \t]+\
|
|
|
|
|
\\(?:\\[@\\(?:start:\\)?\\([0-9]+\\|[A-Za-z]\\)\\][ \t]*\\)?\\(\\[[- X]\\]\\)")
|
2010-12-17 13:54:25 -05:00
|
|
|
|
(recursivep
|
2013-03-23 12:42:09 -04:00
|
|
|
|
(or (not org-checkbox-hierarchical-statistics)
|
2010-12-17 13:54:25 -05:00
|
|
|
|
(string-match "\\<recursive\\>"
|
2011-02-12 17:52:40 -05:00
|
|
|
|
(or (org-entry-get nil "COOKIE_DATA") ""))))
|
2015-06-09 11:06:17 -04:00
|
|
|
|
(within-inlinetask (and (not all)
|
|
|
|
|
(featurep 'org-inlinetask)
|
|
|
|
|
(org-inlinetask-in-task-p)))
|
|
|
|
|
(end (cond (all (point-max))
|
|
|
|
|
(within-inlinetask
|
|
|
|
|
(save-excursion (outline-next-heading) (point)))
|
|
|
|
|
(t (save-excursion
|
|
|
|
|
(org-with-limited-levels (outline-next-heading))
|
|
|
|
|
(point)))))
|
2010-12-17 13:54:25 -05:00
|
|
|
|
(count-boxes
|
2015-06-09 11:06:17 -04:00
|
|
|
|
(lambda (item structs recursivep)
|
|
|
|
|
;; Return number of checked boxes and boxes of all types
|
|
|
|
|
;; in all structures in STRUCTS. If RECURSIVEP is
|
|
|
|
|
;; non-nil, also count boxes in sub-lists. If ITEM is
|
|
|
|
|
;; nil, count across the whole structure, else count only
|
|
|
|
|
;; across subtree whose ancestor is ITEM.
|
|
|
|
|
(let ((c-on 0) (c-all 0))
|
|
|
|
|
(dolist (s structs (list c-on c-all))
|
|
|
|
|
(let* ((pre (org-list-prevs-alist s))
|
|
|
|
|
(par (org-list-parents-alist s))
|
|
|
|
|
(items
|
|
|
|
|
(cond
|
|
|
|
|
((and recursivep item) (org-list-get-subtree item s))
|
|
|
|
|
(recursivep (mapcar #'car s))
|
|
|
|
|
(item (org-list-get-children item s par))
|
|
|
|
|
(t (org-list-get-all-items
|
|
|
|
|
(org-list-get-top-point s) s pre))))
|
|
|
|
|
(cookies (delq nil (mapcar
|
|
|
|
|
(lambda (e)
|
|
|
|
|
(org-list-get-checkbox e s))
|
|
|
|
|
items))))
|
2015-12-05 03:41:14 -05:00
|
|
|
|
(cl-incf c-all (length cookies))
|
|
|
|
|
(cl-incf c-on (cl-count "[X]" cookies :test #'equal)))))))
|
2015-06-09 11:06:17 -04:00
|
|
|
|
cookies-list cache)
|
|
|
|
|
;; Move to start.
|
|
|
|
|
(cond (all (goto-char (point-min)))
|
|
|
|
|
(within-inlinetask (org-back-to-heading t))
|
|
|
|
|
(t (org-with-limited-levels (outline-previous-heading))))
|
|
|
|
|
;; Build an alist for each cookie found. The key is the position
|
|
|
|
|
;; at beginning of cookie and values ending position, format of
|
|
|
|
|
;; cookie, number of checked boxes to report and total number of
|
|
|
|
|
;; boxes.
|
|
|
|
|
(while (re-search-forward cookie-re end t)
|
|
|
|
|
(let ((context (save-excursion (backward-char)
|
|
|
|
|
(save-match-data (org-element-context)))))
|
|
|
|
|
(when (eq (org-element-type context) 'statistics-cookie)
|
|
|
|
|
(push
|
|
|
|
|
(append
|
|
|
|
|
(list (match-beginning 1) (match-end 1) (match-end 2))
|
|
|
|
|
(let* ((container
|
|
|
|
|
(org-element-lineage
|
|
|
|
|
context
|
2015-08-10 17:23:39 -04:00
|
|
|
|
'(drawer center-block dynamic-block inlinetask item
|
2015-06-09 11:06:17 -04:00
|
|
|
|
quote-block special-block verse-block)))
|
2015-08-10 17:23:39 -04:00
|
|
|
|
(beg (if container
|
|
|
|
|
(org-element-property :contents-begin container)
|
2015-06-09 11:06:17 -04:00
|
|
|
|
(save-excursion
|
2015-08-10 17:23:39 -04:00
|
|
|
|
(org-with-limited-levels
|
|
|
|
|
(outline-previous-heading))
|
2015-06-09 11:06:17 -04:00
|
|
|
|
(point)))))
|
|
|
|
|
(or (cdr (assq beg cache))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char beg)
|
|
|
|
|
(let ((end
|
2015-08-10 17:23:39 -04:00
|
|
|
|
(if container
|
|
|
|
|
(org-element-property :contents-end container)
|
2015-06-09 11:06:17 -04:00
|
|
|
|
(save-excursion
|
|
|
|
|
(org-with-limited-levels (outline-next-heading))
|
|
|
|
|
(point))))
|
|
|
|
|
structs)
|
|
|
|
|
(while (re-search-forward box-re end t)
|
|
|
|
|
(let ((element (org-element-at-point)))
|
|
|
|
|
(when (eq (org-element-type element) 'item)
|
|
|
|
|
(push (org-element-property :structure element)
|
|
|
|
|
structs)
|
2015-08-11 08:11:15 -04:00
|
|
|
|
;; Skip whole list since we have its
|
|
|
|
|
;; structure anyway.
|
|
|
|
|
(while (setq element (org-element-lineage
|
|
|
|
|
element '(plain-list)))
|
|
|
|
|
(goto-char
|
|
|
|
|
(min (org-element-property :end element)
|
|
|
|
|
end))))))
|
2015-06-09 11:06:17 -04:00
|
|
|
|
;; Cache count for cookies applying to the same
|
|
|
|
|
;; area. Then return it.
|
|
|
|
|
(let ((count
|
|
|
|
|
(funcall count-boxes
|
|
|
|
|
(and (eq (org-element-type container)
|
2015-08-10 17:23:39 -04:00
|
|
|
|
'item)
|
2015-06-09 11:06:17 -04:00
|
|
|
|
(org-element-property
|
2015-08-10 17:23:39 -04:00
|
|
|
|
:begin container))
|
2015-06-09 11:06:17 -04:00
|
|
|
|
structs
|
|
|
|
|
recursivep)))
|
|
|
|
|
(push (cons beg count) cache)
|
|
|
|
|
count))))))
|
2010-12-17 13:54:25 -05:00
|
|
|
|
cookies-list))))
|
2015-06-09 11:06:17 -04:00
|
|
|
|
;; Apply alist to buffer.
|
|
|
|
|
(dolist (cookie cookies-list)
|
|
|
|
|
(let* ((beg (car cookie))
|
|
|
|
|
(end (nth 1 cookie))
|
|
|
|
|
(percent (nth 2 cookie))
|
|
|
|
|
(checked (nth 3 cookie))
|
|
|
|
|
(total (nth 4 cookie)))
|
|
|
|
|
(goto-char beg)
|
|
|
|
|
(insert
|
2015-07-31 13:12:37 -04:00
|
|
|
|
(if percent (format "[%d%%]" (floor (* 100.0 checked)
|
|
|
|
|
(max 1 total)))
|
2015-06-09 11:06:17 -04:00
|
|
|
|
(format "[%d/%d]" checked total)))
|
|
|
|
|
(delete-region (point) (+ (point) (- end beg)))
|
|
|
|
|
(when org-auto-align-tags (org-fix-tags-on-the-fly)))))))
|
2010-07-10 11:02:58 -04:00
|
|
|
|
|
|
|
|
|
(defun org-get-checkbox-statistics-face ()
|
|
|
|
|
"Select the face for checkbox statistics.
|
|
|
|
|
The face will be `org-done' when all relevant boxes are checked.
|
|
|
|
|
Otherwise it will be `org-todo'."
|
|
|
|
|
(if (match-end 1)
|
|
|
|
|
(if (equal (match-string 1) "100%")
|
|
|
|
|
'org-checkbox-statistics-done
|
|
|
|
|
'org-checkbox-statistics-todo)
|
|
|
|
|
(if (and (> (match-end 2) (match-beginning 2))
|
|
|
|
|
(equal (match-string 2) (match-string 3)))
|
|
|
|
|
'org-checkbox-statistics-done
|
|
|
|
|
'org-checkbox-statistics-todo)))
|
|
|
|
|
|
2011-06-20 15:59:58 -04:00
|
|
|
|
(defun org-update-checkbox-count-maybe (&optional all)
|
2011-08-23 15:26:51 -04:00
|
|
|
|
"Update checkbox statistics unless turned off by user.
|
|
|
|
|
With an optional argument ALL, update them in the whole buffer."
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(when (cdr (assq 'checkbox org-list-automatic-rules))
|
2011-06-20 15:59:58 -04:00
|
|
|
|
(org-update-checkbox-count all))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(run-hooks 'org-checkbox-statistics-hook))
|
2010-07-10 11:02:58 -04:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(defvar org-last-indent-begin-marker (make-marker))
|
|
|
|
|
(defvar org-last-indent-end-marker (make-marker))
|
|
|
|
|
(defun org-list-indent-item-generic (arg no-subtree struct)
|
|
|
|
|
"Indent a local list item including its children.
|
|
|
|
|
When number ARG is a negative, item will be outdented, otherwise
|
|
|
|
|
it will be indented.
|
2010-07-10 11:02:58 -04:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
If a region is active, all items inside will be moved.
|
2010-12-29 11:58:58 -05:00
|
|
|
|
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
If NO-SUBTREE is non-nil, only indent the item itself, not its
|
|
|
|
|
children.
|
2010-07-12 11:40:00 -04:00
|
|
|
|
|
2011-02-18 07:41:49 -05:00
|
|
|
|
STRUCT is the list structure.
|
|
|
|
|
|
|
|
|
|
Return t if successful."
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(save-excursion
|
|
|
|
|
(let* ((regionp (org-region-active-p))
|
|
|
|
|
(rbeg (and regionp (region-beginning)))
|
|
|
|
|
(rend (and regionp (region-end)))
|
|
|
|
|
(top (org-list-get-top-point struct))
|
|
|
|
|
(parents (org-list-parents-alist struct))
|
|
|
|
|
(prevs (org-list-prevs-alist struct))
|
|
|
|
|
;; Are we going to move the whole list?
|
|
|
|
|
(specialp
|
2012-04-18 07:01:44 -04:00
|
|
|
|
(and (not regionp)
|
|
|
|
|
(= top (point-at-bol))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(cdr (assq 'indent org-list-automatic-rules))
|
|
|
|
|
(if no-subtree
|
2018-03-21 21:22:15 -04:00
|
|
|
|
(user-error
|
|
|
|
|
"At first item: use S-M-<left/right> to move the whole list")
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
t))))
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Determine begin and end points of zone to indent. If moving
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
;; more than one item, save them for subsequent moves.
|
|
|
|
|
(unless (and (memq last-command '(org-shiftmetaright org-shiftmetaleft))
|
|
|
|
|
(memq this-command '(org-shiftmetaright org-shiftmetaleft)))
|
|
|
|
|
(if regionp
|
|
|
|
|
(progn
|
|
|
|
|
(set-marker org-last-indent-begin-marker rbeg)
|
|
|
|
|
(set-marker org-last-indent-end-marker rend))
|
2012-04-18 07:01:44 -04:00
|
|
|
|
(set-marker org-last-indent-begin-marker (point-at-bol))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(set-marker org-last-indent-end-marker
|
|
|
|
|
(cond
|
|
|
|
|
(specialp (org-list-get-bottom-point struct))
|
2012-04-18 07:01:44 -04:00
|
|
|
|
(no-subtree (1+ (point-at-bol)))
|
|
|
|
|
(t (org-list-get-item-end (point-at-bol) struct))))))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(let* ((beg (marker-position org-last-indent-begin-marker))
|
|
|
|
|
(end (marker-position org-last-indent-end-marker)))
|
|
|
|
|
(cond
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Special case: moving top-item with indent rule.
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(specialp
|
|
|
|
|
(let* ((level-skip (org-level-increment))
|
|
|
|
|
(offset (if (< arg 0) (- level-skip) level-skip))
|
|
|
|
|
(top-ind (org-list-get-ind beg struct))
|
2011-01-21 10:31:30 -05:00
|
|
|
|
(old-struct (copy-tree struct)))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(if (< (+ top-ind offset) 0)
|
|
|
|
|
(error "Cannot outdent beyond margin")
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Change bullet if necessary.
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(when (and (= (+ top-ind offset) 0)
|
2019-03-04 21:00:00 -05:00
|
|
|
|
(string-match "\\*"
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(org-list-get-bullet beg struct)))
|
|
|
|
|
(org-list-set-bullet beg struct
|
|
|
|
|
(org-list-bullet-string "-")))
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; Shift every item by OFFSET and fix bullets. Then
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
;; apply changes to buffer.
|
2020-05-01 09:51:43 -04:00
|
|
|
|
(pcase-dolist (`(,pos . ,_) struct)
|
|
|
|
|
(let ((ind (org-list-get-ind pos struct)))
|
|
|
|
|
(org-list-set-ind pos struct (+ ind offset))))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(org-list-struct-fix-bul struct prevs)
|
|
|
|
|
(org-list-struct-apply-struct struct old-struct))))
|
|
|
|
|
;; Forbidden move:
|
|
|
|
|
((and (< arg 0)
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; If only one item is moved, it mustn't have a child.
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(or (and no-subtree
|
|
|
|
|
(not regionp)
|
|
|
|
|
(org-list-has-child-p beg struct))
|
|
|
|
|
;; If a subtree or region is moved, the last item
|
2011-06-28 05:20:56 -04:00
|
|
|
|
;; of the subtree mustn't have a child.
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(let ((last-item (caar
|
|
|
|
|
(reverse
|
2015-11-06 07:04:20 -05:00
|
|
|
|
(cl-remove-if
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(lambda (e) (>= (car e) end))
|
|
|
|
|
struct)))))
|
|
|
|
|
(org-list-has-child-p last-item struct))))
|
|
|
|
|
(error "Cannot outdent an item without its children"))
|
|
|
|
|
;; Normal shifting
|
|
|
|
|
(t
|
2019-07-09 05:53:08 -04:00
|
|
|
|
(let* ((old-struct (copy-tree struct))
|
|
|
|
|
(new-parents
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(if (< arg 0)
|
|
|
|
|
(org-list-struct-outdent beg end struct parents)
|
|
|
|
|
(org-list-struct-indent beg end struct parents prevs))))
|
2019-07-09 05:53:08 -04:00
|
|
|
|
(org-list-write-struct struct new-parents old-struct))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(org-update-checkbox-count-maybe))))))
|
|
|
|
|
t)
|
|
|
|
|
|
|
|
|
|
(defun org-outdent-item ()
|
|
|
|
|
"Outdent a local list item, but not its children.
|
|
|
|
|
If a region is active, all items inside will be moved."
|
|
|
|
|
(interactive)
|
2012-04-18 07:01:44 -04:00
|
|
|
|
(let ((regionp (org-region-active-p)))
|
|
|
|
|
(cond
|
|
|
|
|
((or (org-at-item-p)
|
|
|
|
|
(and regionp
|
|
|
|
|
(save-excursion (goto-char (region-beginning))
|
|
|
|
|
(org-at-item-p))))
|
|
|
|
|
(let ((struct (if (not regionp) (org-list-struct)
|
|
|
|
|
(save-excursion (goto-char (region-beginning))
|
|
|
|
|
(org-list-struct)))))
|
|
|
|
|
(org-list-indent-item-generic -1 t struct)))
|
|
|
|
|
(regionp (error "Region not starting at an item"))
|
|
|
|
|
(t (error "Not at an item")))))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
|
|
|
|
|
(defun org-indent-item ()
|
|
|
|
|
"Indent a local list item, but not its children.
|
|
|
|
|
If a region is active, all items inside will be moved."
|
|
|
|
|
(interactive)
|
2012-04-18 07:01:44 -04:00
|
|
|
|
(let ((regionp (org-region-active-p)))
|
|
|
|
|
(cond
|
|
|
|
|
((or (org-at-item-p)
|
|
|
|
|
(and regionp
|
|
|
|
|
(save-excursion (goto-char (region-beginning))
|
|
|
|
|
(org-at-item-p))))
|
|
|
|
|
(let ((struct (if (not regionp) (org-list-struct)
|
|
|
|
|
(save-excursion (goto-char (region-beginning))
|
|
|
|
|
(org-list-struct)))))
|
|
|
|
|
(org-list-indent-item-generic 1 t struct)))
|
|
|
|
|
(regionp (error "Region not starting at an item"))
|
|
|
|
|
(t (error "Not at an item")))))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
|
|
|
|
|
(defun org-outdent-item-tree ()
|
|
|
|
|
"Outdent a local list item including its children.
|
|
|
|
|
If a region is active, all items inside will be moved."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let ((regionp (org-region-active-p)))
|
|
|
|
|
(cond
|
|
|
|
|
((or (org-at-item-p)
|
2012-04-18 07:01:44 -04:00
|
|
|
|
(and regionp
|
|
|
|
|
(save-excursion (goto-char (region-beginning))
|
|
|
|
|
(org-at-item-p))))
|
|
|
|
|
(let ((struct (if (not regionp) (org-list-struct)
|
|
|
|
|
(save-excursion (goto-char (region-beginning))
|
|
|
|
|
(org-list-struct)))))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(org-list-indent-item-generic -1 nil struct)))
|
|
|
|
|
(regionp (error "Region not starting at an item"))
|
|
|
|
|
(t (error "Not at an item")))))
|
|
|
|
|
|
|
|
|
|
(defun org-indent-item-tree ()
|
|
|
|
|
"Indent a local list item including its children.
|
|
|
|
|
If a region is active, all items inside will be moved."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let ((regionp (org-region-active-p)))
|
|
|
|
|
(cond
|
|
|
|
|
((or (org-at-item-p)
|
2012-04-18 07:01:44 -04:00
|
|
|
|
(and regionp
|
|
|
|
|
(save-excursion (goto-char (region-beginning))
|
|
|
|
|
(org-at-item-p))))
|
|
|
|
|
(let ((struct (if (not regionp) (org-list-struct)
|
|
|
|
|
(save-excursion (goto-char (region-beginning))
|
|
|
|
|
(org-list-struct)))))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(org-list-indent-item-generic 1 nil struct)))
|
|
|
|
|
(regionp (error "Region not starting at an item"))
|
|
|
|
|
(t (error "Not at an item")))))
|
|
|
|
|
|
|
|
|
|
(defvar org-tab-ind-state)
|
|
|
|
|
(defun org-cycle-item-indentation ()
|
|
|
|
|
"Cycle levels of indentation of an empty item.
|
2020-05-24 17:43:24 -04:00
|
|
|
|
|
2012-01-10 05:56:15 -05:00
|
|
|
|
The first run indents the item, if applicable. Subsequent runs
|
2011-06-28 05:20:56 -04:00
|
|
|
|
outdent it at meaningful levels in the list. When done, item is
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
put back at its original position with its original bullet.
|
|
|
|
|
|
|
|
|
|
Return t at each successful move."
|
|
|
|
|
(when (org-at-item-p)
|
2020-05-24 17:43:24 -04:00
|
|
|
|
(let* ((struct (org-list-struct))
|
|
|
|
|
(item (line-beginning-position))
|
|
|
|
|
(ind (org-list-get-ind item struct)))
|
2011-02-22 12:56:36 -05:00
|
|
|
|
;; Accept empty items or if cycle has already started.
|
|
|
|
|
(when (or (eq last-command 'org-cycle-item-indentation)
|
2020-05-24 17:43:24 -04:00
|
|
|
|
(and (org-match-line org-list-full-item-re)
|
|
|
|
|
(>= (match-end 0)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (org-list-get-item-end item struct))
|
|
|
|
|
(skip-chars-backward " \t\n")
|
|
|
|
|
(point)))))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(setq this-command 'org-cycle-item-indentation)
|
2020-05-24 17:43:24 -04:00
|
|
|
|
(let ((prevs (org-list-prevs-alist struct))
|
|
|
|
|
(parents (org-list-parents-alist struct)))
|
|
|
|
|
(if (eq last-command 'org-cycle-item-indentation)
|
|
|
|
|
;; When in the middle of the cycle, try to outdent. If
|
|
|
|
|
;; it fails, move point back to its initial position and
|
|
|
|
|
;; reset cycle.
|
|
|
|
|
(pcase-let ((`(,old-ind . ,old-bul) org-tab-ind-state)
|
|
|
|
|
(allow-outdent
|
|
|
|
|
(lambda (struct prevs parents)
|
|
|
|
|
;; Non-nil if current item can be
|
|
|
|
|
;; outdented.
|
|
|
|
|
(and (not (org-list-get-next-item item nil prevs))
|
|
|
|
|
(not (org-list-has-child-p item struct))
|
|
|
|
|
(org-list-get-parent item struct parents)))))
|
|
|
|
|
(cond
|
|
|
|
|
((and (> ind old-ind)
|
|
|
|
|
(org-list-get-prev-item item nil prevs))
|
|
|
|
|
(org-list-indent-item-generic 1 t struct))
|
|
|
|
|
((and (< ind old-ind)
|
|
|
|
|
(funcall allow-outdent struct prevs parents))
|
|
|
|
|
(org-list-indent-item-generic -1 t struct))
|
|
|
|
|
(t
|
|
|
|
|
(delete-region (line-beginning-position) (line-end-position))
|
|
|
|
|
(indent-to-column old-ind)
|
|
|
|
|
(insert old-bul " ")
|
|
|
|
|
(let* ((struct (org-list-struct))
|
|
|
|
|
(parents (org-list-parents-alist struct)))
|
|
|
|
|
(if (and (> ind old-ind)
|
|
|
|
|
;; We were previously indenting item. It
|
|
|
|
|
;; is no longer possible. Try to outdent
|
|
|
|
|
;; from initial position.
|
|
|
|
|
(funcall allow-outdent
|
|
|
|
|
struct
|
|
|
|
|
(org-list-prevs-alist struct)
|
|
|
|
|
parents))
|
|
|
|
|
(org-list-indent-item-generic -1 t struct)
|
|
|
|
|
(org-list-write-struct struct parents)
|
|
|
|
|
;; Start cycle over.
|
|
|
|
|
(setq this-command 'identity)
|
|
|
|
|
t)))))
|
|
|
|
|
;; If a cycle is starting, remember initial indentation
|
|
|
|
|
;; and bullet, then try to indent. If it fails, try to
|
|
|
|
|
;; outdent.
|
|
|
|
|
(setq org-tab-ind-state
|
|
|
|
|
(cons ind (org-trim (org-current-line-string))))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(cond
|
2020-05-24 17:43:24 -04:00
|
|
|
|
((org-list-get-prev-item item nil prevs)
|
|
|
|
|
(org-list-indent-item-generic 1 t struct))
|
|
|
|
|
((and (not (org-list-get-next-item item nil prevs))
|
|
|
|
|
(org-list-get-parent item struct parents))
|
|
|
|
|
(org-list-indent-item-generic -1 t struct))
|
|
|
|
|
(t
|
|
|
|
|
;; This command failed. So will the following one.
|
|
|
|
|
;; There's no point in starting the cycle.
|
|
|
|
|
(setq this-command 'identity)
|
|
|
|
|
(user-error "Cannot move item")))))))))
|
2010-07-10 11:02:58 -04:00
|
|
|
|
|
2017-05-09 14:57:40 -04:00
|
|
|
|
(defun org-sort-list
|
|
|
|
|
(&optional with-case sorting-type getkey-func compare-func interactive?)
|
2011-02-18 07:41:49 -05:00
|
|
|
|
"Sort list items.
|
2010-07-10 11:02:58 -04:00
|
|
|
|
The cursor may be at any item of the list that should be sorted.
|
2011-06-28 05:20:56 -04:00
|
|
|
|
Sublists are not sorted. Checkboxes, if any, are ignored.
|
2010-07-10 11:02:58 -04:00
|
|
|
|
|
2011-06-28 05:20:56 -04:00
|
|
|
|
Sorting can be alphabetically, numerically, by date/time as given
|
|
|
|
|
by a time stamp, by a property or by priority.
|
2010-07-10 11:02:58 -04:00
|
|
|
|
|
2011-06-28 05:20:56 -04:00
|
|
|
|
Comparing entries ignores case by default. However, with an
|
2018-03-11 11:43:47 -04:00
|
|
|
|
optional argument WITH-CASE, the sorting considers case as well,
|
|
|
|
|
if the current locale allows for it.
|
2010-08-21 07:32:33 -04:00
|
|
|
|
|
2010-07-17 07:56:11 -04:00
|
|
|
|
The command prompts for the sorting type unless it has been given
|
|
|
|
|
to the function through the SORTING-TYPE argument, which needs to
|
2020-05-13 13:10:35 -04:00
|
|
|
|
be a character, among ?n ?N ?a ?A ?t ?T ?f ?F ?x or ?X. Here is
|
|
|
|
|
the detailed meaning of each character:
|
2010-07-10 11:02:58 -04:00
|
|
|
|
|
2010-07-17 07:56:11 -04:00
|
|
|
|
n Numerically, by converting the beginning of the item to a number.
|
2010-07-28 05:19:08 -04:00
|
|
|
|
a Alphabetically. Only the first line of item is checked.
|
2010-07-17 07:56:11 -04:00
|
|
|
|
t By date/time, either the first active time stamp in the entry, if
|
2010-07-28 05:19:08 -04:00
|
|
|
|
any, or by the first inactive one. In a timer list, sort the timers.
|
2013-07-03 19:33:02 -04:00
|
|
|
|
x By \"checked\" status of a check list.
|
2010-07-10 11:02:58 -04:00
|
|
|
|
|
|
|
|
|
Capital letters will reverse the sort order.
|
|
|
|
|
|
2011-06-28 05:20:56 -04:00
|
|
|
|
If the SORTING-TYPE is ?f or ?F, then GETKEY-FUNC specifies
|
|
|
|
|
a function to be called with point at the beginning of the
|
2017-05-09 14:57:40 -04:00
|
|
|
|
record. It must return a value that is compatible with COMPARE-FUNC,
|
|
|
|
|
the function used to compare entries.
|
2013-02-25 04:15:44 -05:00
|
|
|
|
|
|
|
|
|
Sorting is done against the visible part of the headlines, it
|
2017-05-09 14:57:40 -04:00
|
|
|
|
ignores hidden links.
|
|
|
|
|
|
|
|
|
|
A non-nil value for INTERACTIVE? is used to signal that this
|
|
|
|
|
function is being called interactively."
|
|
|
|
|
(interactive (list current-prefix-arg nil nil nil t))
|
2010-07-10 11:02:58 -04:00
|
|
|
|
(let* ((case-func (if with-case 'identity 'downcase))
|
2010-12-23 18:53:30 -05:00
|
|
|
|
(struct (org-list-struct))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
(prevs (org-list-prevs-alist struct))
|
2010-12-23 18:53:30 -05:00
|
|
|
|
(start (org-list-get-list-begin (point-at-bol) struct prevs))
|
|
|
|
|
(end (org-list-get-list-end (point-at-bol) struct prevs))
|
2010-07-10 11:02:58 -04:00
|
|
|
|
(sorting-type
|
2012-10-09 02:27:17 -04:00
|
|
|
|
(or sorting-type
|
|
|
|
|
(progn
|
|
|
|
|
(message
|
2013-07-03 19:33:02 -04:00
|
|
|
|
"Sort plain list: [a]lpha [n]umeric [t]ime [f]unc [x]checked A/N/T/F/X means reversed:")
|
2012-10-09 02:27:17 -04:00
|
|
|
|
(read-char-exclusive))))
|
2017-05-09 14:57:40 -04:00
|
|
|
|
(dcst (downcase sorting-type))
|
2012-10-09 02:27:17 -04:00
|
|
|
|
(getkey-func
|
2017-05-09 14:57:40 -04:00
|
|
|
|
(and (= dcst ?f)
|
|
|
|
|
(or getkey-func
|
|
|
|
|
(and interactive?
|
|
|
|
|
(org-read-function "Function for extracting keys: "))
|
|
|
|
|
(error "Missing key extractor"))))
|
|
|
|
|
(sort-func
|
|
|
|
|
(cond
|
2018-03-11 11:43:47 -04:00
|
|
|
|
((= dcst ?a) #'org-string-collate-lessp)
|
2017-05-09 14:57:40 -04:00
|
|
|
|
((= dcst ?f)
|
|
|
|
|
(or compare-func
|
|
|
|
|
(and interactive?
|
|
|
|
|
(org-read-function
|
2017-05-23 14:46:42 -04:00
|
|
|
|
(concat "Function for comparing keys "
|
2017-05-09 14:57:40 -04:00
|
|
|
|
"(empty for default `sort-subr' predicate): ")
|
|
|
|
|
'allow-empty))))
|
|
|
|
|
((= dcst ?t) #'<)
|
|
|
|
|
((= dcst ?x) #'string<))))
|
2010-07-10 11:02:58 -04:00
|
|
|
|
(message "Sorting items...")
|
|
|
|
|
(save-restriction
|
|
|
|
|
(narrow-to-region start end)
|
2010-10-30 08:26:40 -04:00
|
|
|
|
(goto-char (point-min))
|
2017-05-09 14:57:40 -04:00
|
|
|
|
(let* ((case-fold-search nil)
|
2010-07-10 11:02:58 -04:00
|
|
|
|
(now (current-time))
|
2010-12-23 18:53:30 -05:00
|
|
|
|
(next-record (lambda ()
|
2012-08-11 13:10:44 -04:00
|
|
|
|
(skip-chars-forward " \r\t\n")
|
2013-04-21 18:24:39 -04:00
|
|
|
|
(or (eobp) (beginning-of-line))))
|
2010-07-10 11:02:58 -04:00
|
|
|
|
(end-record (lambda ()
|
2011-01-02 13:25:52 -05:00
|
|
|
|
(goto-char (org-list-get-item-end-before-blank
|
|
|
|
|
(point) struct))))
|
2010-07-17 07:56:11 -04:00
|
|
|
|
(value-to-sort
|
|
|
|
|
(lambda ()
|
|
|
|
|
(when (looking-at "[ \t]*[-+*0-9.)]+\\([ \t]+\\[[- X]\\]\\)?[ \t]+")
|
|
|
|
|
(cond
|
|
|
|
|
((= dcst ?n)
|
2013-02-25 04:15:44 -05:00
|
|
|
|
(string-to-number
|
|
|
|
|
(org-sort-remove-invisible
|
|
|
|
|
(buffer-substring (match-end 0) (point-at-eol)))))
|
2010-07-17 07:56:11 -04:00
|
|
|
|
((= dcst ?a)
|
2011-05-06 20:17:19 -04:00
|
|
|
|
(funcall case-func
|
2013-02-25 04:15:44 -05:00
|
|
|
|
(org-sort-remove-invisible
|
|
|
|
|
(buffer-substring
|
|
|
|
|
(match-end 0) (point-at-eol)))))
|
2010-07-17 07:56:11 -04:00
|
|
|
|
((= dcst ?t)
|
|
|
|
|
(cond
|
|
|
|
|
;; If it is a timer list, convert timer to seconds
|
2010-07-17 09:17:38 -04:00
|
|
|
|
((org-at-item-timer-p)
|
2010-07-17 07:56:11 -04:00
|
|
|
|
(org-timer-hms-to-secs (match-string 1)))
|
2013-04-16 02:23:52 -04:00
|
|
|
|
((or (save-excursion
|
|
|
|
|
(re-search-forward org-ts-regexp (point-at-eol) t))
|
|
|
|
|
(save-excursion (re-search-forward org-ts-regexp-both
|
|
|
|
|
(point-at-eol) t)))
|
2010-07-17 07:56:11 -04:00
|
|
|
|
(org-time-string-to-seconds (match-string 0)))
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(t (float-time now))))
|
2013-07-03 19:33:02 -04:00
|
|
|
|
((= dcst ?x) (or (and (stringp (match-string 1))
|
2013-07-03 08:57:19 -04:00
|
|
|
|
(match-string 1))
|
|
|
|
|
""))
|
2010-07-17 07:56:11 -04:00
|
|
|
|
((= dcst ?f)
|
|
|
|
|
(if getkey-func
|
|
|
|
|
(let ((value (funcall getkey-func)))
|
|
|
|
|
(if (stringp value)
|
|
|
|
|
(funcall case-func value)
|
|
|
|
|
value))
|
|
|
|
|
(error "Invalid key function `%s'" getkey-func)))
|
|
|
|
|
(t (error "Invalid sorting type `%c'" sorting-type)))))))
|
2010-08-19 10:40:21 -04:00
|
|
|
|
(sort-subr (/= dcst sorting-type)
|
2010-12-23 18:53:30 -05:00
|
|
|
|
next-record
|
2010-08-19 10:40:21 -04:00
|
|
|
|
end-record
|
|
|
|
|
value-to-sort
|
|
|
|
|
nil
|
|
|
|
|
sort-func)
|
2011-01-02 13:25:52 -05:00
|
|
|
|
;; Read and fix list again, as `sort-subr' probably destroyed
|
|
|
|
|
;; its structure.
|
|
|
|
|
(org-list-repair)
|
2010-07-10 11:02:58 -04:00
|
|
|
|
(run-hooks 'org-after-sorting-entries-or-items-hook)
|
|
|
|
|
(message "Sorting items...done")))))
|
|
|
|
|
|
2016-07-04 17:52:40 -04:00
|
|
|
|
(defun org-toggle-item (arg)
|
|
|
|
|
"Convert headings or normal lines to items, items to normal lines.
|
|
|
|
|
If there is no active region, only the current line is considered.
|
|
|
|
|
|
|
|
|
|
If the first non blank line in the region is a headline, convert
|
|
|
|
|
all headlines to items, shifting text accordingly.
|
|
|
|
|
|
|
|
|
|
If it is an item, convert all items to normal lines.
|
|
|
|
|
|
|
|
|
|
If it is normal text, change region into a list of items.
|
|
|
|
|
With a prefix argument ARG, change the region in a single item."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(let ((shift-text
|
|
|
|
|
(lambda (ind end)
|
|
|
|
|
;; Shift text in current section to IND, from point to END.
|
|
|
|
|
;; The function leaves point to END line.
|
|
|
|
|
(let ((min-i 1000) (end (copy-marker end)))
|
|
|
|
|
;; First determine the minimum indentation (MIN-I) of
|
|
|
|
|
;; the text.
|
|
|
|
|
(save-excursion
|
|
|
|
|
(catch 'exit
|
|
|
|
|
(while (< (point) end)
|
2018-05-08 19:26:31 -04:00
|
|
|
|
(let ((i (current-indentation)))
|
2016-07-04 17:52:40 -04:00
|
|
|
|
(cond
|
|
|
|
|
;; Skip blank lines and inline tasks.
|
|
|
|
|
((looking-at "^[ \t]*$"))
|
|
|
|
|
((looking-at org-outline-regexp-bol))
|
|
|
|
|
;; We can't find less than 0 indentation.
|
|
|
|
|
((zerop i) (throw 'exit (setq min-i 0)))
|
|
|
|
|
((< i min-i) (setq min-i i))))
|
|
|
|
|
(forward-line))))
|
|
|
|
|
;; Then indent each line so that a line indented to
|
|
|
|
|
;; MIN-I becomes indented to IND. Ignore blank lines
|
|
|
|
|
;; and inline tasks in the process.
|
|
|
|
|
(let ((delta (- ind min-i)))
|
|
|
|
|
(while (< (point) end)
|
|
|
|
|
(unless (or (looking-at "^[ \t]*$")
|
|
|
|
|
(looking-at org-outline-regexp-bol))
|
2018-05-08 19:26:31 -04:00
|
|
|
|
(indent-line-to (+ (current-indentation) delta)))
|
2016-07-04 17:52:40 -04:00
|
|
|
|
(forward-line))))))
|
|
|
|
|
(skip-blanks
|
|
|
|
|
(lambda (pos)
|
|
|
|
|
;; Return beginning of first non-blank line, starting from
|
|
|
|
|
;; line at POS.
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char pos)
|
|
|
|
|
(skip-chars-forward " \r\t\n")
|
|
|
|
|
(point-at-bol))))
|
|
|
|
|
beg end)
|
|
|
|
|
;; Determine boundaries of changes.
|
|
|
|
|
(if (org-region-active-p)
|
|
|
|
|
(setq beg (funcall skip-blanks (region-beginning))
|
|
|
|
|
end (copy-marker (region-end)))
|
2020-07-31 18:38:11 -04:00
|
|
|
|
(setq beg (point-at-bol)
|
2016-07-04 17:52:40 -04:00
|
|
|
|
end (copy-marker (point-at-eol))))
|
|
|
|
|
;; Depending on the starting line, choose an action on the text
|
|
|
|
|
;; between BEG and END.
|
|
|
|
|
(org-with-limited-levels
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char beg)
|
|
|
|
|
(cond
|
|
|
|
|
;; Case 1. Start at an item: de-itemize. Note that it only
|
|
|
|
|
;; happens when a region is active: `org-ctrl-c-minus'
|
|
|
|
|
;; would call `org-cycle-list-bullet' otherwise.
|
|
|
|
|
((org-at-item-p)
|
|
|
|
|
(while (< (point) end)
|
|
|
|
|
(when (org-at-item-p)
|
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
(delete-region (point) (match-end 0)))
|
|
|
|
|
(forward-line)))
|
|
|
|
|
;; Case 2. Start at an heading: convert to items.
|
|
|
|
|
((org-at-heading-p)
|
2018-03-05 04:57:43 -05:00
|
|
|
|
;; Remove metadata
|
|
|
|
|
(let (org-loop-over-headlines-in-active-region)
|
2018-03-17 06:32:40 -04:00
|
|
|
|
(org-list--delete-metadata))
|
2016-07-04 17:52:40 -04:00
|
|
|
|
(let* ((bul (org-list-bullet-string "-"))
|
|
|
|
|
(bul-len (length bul))
|
|
|
|
|
;; Indentation of the first heading. It should be
|
|
|
|
|
;; relative to the indentation of its parent, if any.
|
|
|
|
|
(start-ind (save-excursion
|
|
|
|
|
(cond
|
|
|
|
|
((not org-adapt-indentation) 0)
|
|
|
|
|
((not (outline-previous-heading)) 0)
|
|
|
|
|
(t (length (match-string 0))))))
|
|
|
|
|
;; Level of first heading. Further headings will be
|
|
|
|
|
;; compared to it to determine hierarchy in the list.
|
|
|
|
|
(ref-level (org-reduced-level (org-outline-level))))
|
|
|
|
|
(while (< (point) end)
|
|
|
|
|
(let* ((level (org-reduced-level (org-outline-level)))
|
|
|
|
|
(delta (max 0 (- level ref-level)))
|
|
|
|
|
(todo-state (org-get-todo-state)))
|
|
|
|
|
;; If current headline is less indented than the first
|
|
|
|
|
;; one, set it as reference, in order to preserve
|
|
|
|
|
;; subtrees.
|
|
|
|
|
(when (< level ref-level) (setq ref-level level))
|
2018-03-05 04:57:43 -05:00
|
|
|
|
;; Remove metadata
|
|
|
|
|
(let (org-loop-over-headlines-in-active-region)
|
2018-03-17 06:32:40 -04:00
|
|
|
|
(org-list--delete-metadata))
|
2016-07-04 17:52:40 -04:00
|
|
|
|
;; Remove stars and TODO keyword.
|
2016-11-13 04:58:23 -05:00
|
|
|
|
(let ((case-fold-search nil)) (looking-at org-todo-line-regexp))
|
2016-07-04 17:52:40 -04:00
|
|
|
|
(delete-region (point) (or (match-beginning 3)
|
|
|
|
|
(line-end-position)))
|
|
|
|
|
(insert bul)
|
|
|
|
|
(indent-line-to (+ start-ind (* delta bul-len)))
|
|
|
|
|
;; Turn TODO keyword into a check box.
|
|
|
|
|
(when todo-state
|
|
|
|
|
(let* ((struct (org-list-struct))
|
|
|
|
|
(old (copy-tree struct)))
|
|
|
|
|
(org-list-set-checkbox
|
|
|
|
|
(line-beginning-position)
|
|
|
|
|
struct
|
|
|
|
|
(if (member todo-state org-done-keywords)
|
|
|
|
|
"[X]"
|
|
|
|
|
"[ ]"))
|
|
|
|
|
(org-list-write-struct struct
|
|
|
|
|
(org-list-parents-alist struct)
|
|
|
|
|
old)))
|
|
|
|
|
;; Ensure all text down to END (or SECTION-END) belongs
|
|
|
|
|
;; to the newly created item.
|
|
|
|
|
(let ((section-end (save-excursion
|
|
|
|
|
(or (outline-next-heading) (point)))))
|
|
|
|
|
(forward-line)
|
|
|
|
|
(funcall shift-text
|
|
|
|
|
(+ start-ind (* (1+ delta) bul-len))
|
|
|
|
|
(min end section-end)))))))
|
|
|
|
|
;; Case 3. Normal line with ARG: make the first line of region
|
|
|
|
|
;; an item, and shift indentation of others lines to
|
|
|
|
|
;; set them as item's body.
|
|
|
|
|
(arg (let* ((bul (org-list-bullet-string "-"))
|
|
|
|
|
(bul-len (length bul))
|
2018-05-08 19:26:31 -04:00
|
|
|
|
(ref-ind (current-indentation)))
|
2016-07-04 17:52:40 -04:00
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
(insert bul)
|
|
|
|
|
(forward-line)
|
|
|
|
|
(while (< (point) end)
|
|
|
|
|
;; Ensure that lines less indented than first one
|
|
|
|
|
;; still get included in item body.
|
|
|
|
|
(funcall shift-text
|
|
|
|
|
(+ ref-ind bul-len)
|
|
|
|
|
(min end (save-excursion (or (outline-next-heading)
|
|
|
|
|
(point)))))
|
|
|
|
|
(forward-line))))
|
|
|
|
|
;; Case 4. Normal line without ARG: turn each non-item line
|
|
|
|
|
;; into an item.
|
|
|
|
|
(t
|
|
|
|
|
(while (< (point) end)
|
|
|
|
|
(unless (or (org-at-heading-p) (org-at-item-p))
|
|
|
|
|
(when (looking-at "\\([ \t]*\\)\\(\\S-\\)")
|
|
|
|
|
(replace-match
|
|
|
|
|
(concat "\\1" (org-list-bullet-string "-") "\\2"))))
|
|
|
|
|
(forward-line))))))))
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
|
2011-08-23 16:17:20 -04:00
|
|
|
|
|
2008-09-23 02:13:32 -04:00
|
|
|
|
;;; Send and receive lists
|
org-list: reorder file, rename functions, improve comments
* lisp/ob.el (org-babel-result-end): apply renaming.
* lisp/org-exp.el (org-export-mark-list-properties): apply renaming.
* lisp/org-list.el (org-list-prevs-alist): renamed from
org-list-struct-prev-alist.
(org-list-parents-alist): renamed from org-list-struct-parent-alist.
(org-list-write-struct): renamed from org-list-struct-fix-struct.
(org-list-parse-list, org-sort-list, org-list-indent-item-generic,
org-toggle-checkbox, org-update-checkbox-count, org-cycle-list-bullet,
org-list-repair, org-insert-item, org-move-item-up, org-move-item-up,
org-move-item-down, org-next-item, org-previous-item,
org-end-of-item-list, org-beginning-of-item-list, org-apply-on-list):
apply renaming.
(org-get-bullet): removed function, as it is not needed anymore.
2011-01-20 13:28:23 -05:00
|
|
|
|
|
2015-12-02 17:30:54 -05:00
|
|
|
|
(defun org-list-to-lisp (&optional delete)
|
2008-09-23 02:03:13 -04:00
|
|
|
|
"Parse the list at point and maybe DELETE it.
|
2010-12-28 19:43:42 -05:00
|
|
|
|
|
|
|
|
|
Return a list whose car is a symbol of list type, among
|
2011-06-17 09:11:49 -04:00
|
|
|
|
`ordered', `unordered' and `descriptive'. Then, each item is
|
2015-12-02 17:30:54 -05:00
|
|
|
|
a list of strings and other sub-lists.
|
2010-12-28 19:43:42 -05:00
|
|
|
|
|
|
|
|
|
For example, the following list:
|
|
|
|
|
|
2015-12-02 17:30:54 -05:00
|
|
|
|
1. first item
|
|
|
|
|
+ sub-item one
|
|
|
|
|
+ [X] sub-item two
|
|
|
|
|
more text in first item
|
|
|
|
|
2. [@3] last item
|
2010-12-28 19:43:42 -05:00
|
|
|
|
|
2015-12-02 17:30:54 -05:00
|
|
|
|
is parsed as
|
2010-12-28 19:43:42 -05:00
|
|
|
|
|
2016-10-31 05:01:33 -04:00
|
|
|
|
(ordered
|
|
|
|
|
(\"first item\"
|
|
|
|
|
(unordered
|
|
|
|
|
(\"sub-item one\")
|
|
|
|
|
(\"[X] sub-item two\"))
|
2015-12-02 17:30:54 -05:00
|
|
|
|
\"more text in first item\")
|
2016-10-31 05:01:33 -04:00
|
|
|
|
(\"[@3] last item\"))
|
2010-12-28 19:43:42 -05:00
|
|
|
|
|
2015-12-02 17:30:54 -05:00
|
|
|
|
Point is left at list's end."
|
2015-11-07 18:07:33 -05:00
|
|
|
|
(letrec ((struct (org-list-struct))
|
|
|
|
|
(prevs (org-list-prevs-alist struct))
|
|
|
|
|
(parents (org-list-parents-alist struct))
|
|
|
|
|
(top (org-list-get-top-point struct))
|
|
|
|
|
(bottom (org-list-get-bottom-point struct))
|
2015-12-02 17:30:54 -05:00
|
|
|
|
(trim
|
|
|
|
|
(lambda (text)
|
|
|
|
|
;; Remove indentation and final newline from TEXT.
|
|
|
|
|
(org-remove-indentation
|
|
|
|
|
(if (string-match-p "\n\\'" text)
|
|
|
|
|
(substring text 0 -1)
|
|
|
|
|
text))))
|
2015-11-07 18:07:33 -05:00
|
|
|
|
(parse-sublist
|
|
|
|
|
(lambda (e)
|
2015-12-02 17:30:54 -05:00
|
|
|
|
;; Return a list whose car is list type and cdr a list
|
|
|
|
|
;; of items' body.
|
2015-11-07 18:07:33 -05:00
|
|
|
|
(cons (org-list-get-list-type (car e) struct prevs)
|
|
|
|
|
(mapcar parse-item e))))
|
|
|
|
|
(parse-item
|
|
|
|
|
(lambda (e)
|
2015-12-02 17:30:54 -05:00
|
|
|
|
;; Return a list containing counter of item, if any,
|
|
|
|
|
;; text and any sublist inside it.
|
|
|
|
|
(let* ((end (org-list-get-item-end e struct))
|
|
|
|
|
(children (org-list-get-children e struct parents))
|
|
|
|
|
(body
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char e)
|
|
|
|
|
(looking-at "[ \t]*\\S-+[ \t]*")
|
|
|
|
|
(list
|
|
|
|
|
(funcall
|
|
|
|
|
trim
|
|
|
|
|
(concat
|
|
|
|
|
(make-string (string-width (match-string 0)) ?\s)
|
|
|
|
|
(buffer-substring-no-properties
|
|
|
|
|
(match-end 0) (or (car children) end))))))))
|
|
|
|
|
(while children
|
|
|
|
|
(let* ((child (car children))
|
|
|
|
|
(sub (org-list-get-all-items child struct prevs))
|
|
|
|
|
(last-in-sub (car (last sub))))
|
|
|
|
|
(push (funcall parse-sublist sub) body)
|
|
|
|
|
;; Remove whole sub-list from children.
|
|
|
|
|
(setq children (cdr (memq last-in-sub children)))
|
|
|
|
|
;; There is a chunk of text belonging to the item
|
|
|
|
|
;; if last child doesn't end where next child
|
|
|
|
|
;; starts or where item ends.
|
|
|
|
|
(let ((sub-end (org-list-get-item-end last-in-sub struct))
|
|
|
|
|
(next (or (car children) end)))
|
|
|
|
|
(when (/= sub-end next)
|
|
|
|
|
(push (funcall
|
|
|
|
|
trim
|
|
|
|
|
(buffer-substring-no-properties sub-end next))
|
|
|
|
|
body)))))
|
|
|
|
|
(nreverse body)))))
|
2011-01-17 14:15:05 -05:00
|
|
|
|
;; Store output, take care of cursor position and deletion of
|
2010-12-28 19:43:42 -05:00
|
|
|
|
;; list, then return output.
|
2015-11-07 18:07:33 -05:00
|
|
|
|
(prog1 (funcall parse-sublist (org-list-get-all-items top struct prevs))
|
|
|
|
|
(goto-char top)
|
|
|
|
|
(when delete
|
|
|
|
|
(delete-region top bottom)
|
|
|
|
|
(when (and (not (looking-at "[ \t]*$")) (looking-at org-list-end-re))
|
|
|
|
|
(replace-match ""))))))
|
2008-09-23 02:03:13 -04:00
|
|
|
|
|
2009-07-25 16:48:32 -04:00
|
|
|
|
(defun org-list-make-subtree ()
|
|
|
|
|
"Convert the plain list at point into a subtree."
|
|
|
|
|
(interactive)
|
2019-06-09 18:08:26 -04:00
|
|
|
|
(let ((item (org-in-item-p)))
|
|
|
|
|
(unless item (error "Not in a list"))
|
|
|
|
|
(goto-char item)
|
|
|
|
|
(let ((level (pcase (org-current-level)
|
|
|
|
|
(`nil 1)
|
|
|
|
|
(l (1+ (org-reduced-level l)))))
|
|
|
|
|
(list (save-excursion (org-list-to-lisp t))))
|
|
|
|
|
(insert (org-list-to-subtree list level) "\n"))))
|
2009-07-25 16:48:32 -04:00
|
|
|
|
|
2008-09-23 02:03:13 -04:00
|
|
|
|
(defun org-list-to-generic (list params)
|
2015-12-02 17:30:54 -05:00
|
|
|
|
"Convert a LIST parsed through `org-list-to-lisp' to a custom format.
|
|
|
|
|
|
|
|
|
|
LIST is a list as returned by `org-list-to-lisp', which see.
|
|
|
|
|
PARAMS is a property list of parameters used to tweak the output
|
|
|
|
|
format.
|
|
|
|
|
|
|
|
|
|
Valid parameters are:
|
|
|
|
|
|
|
|
|
|
:backend, :raw
|
|
|
|
|
|
|
|
|
|
Export back-end used as a basis to transcode elements of the
|
|
|
|
|
list, when no specific parameter applies to it. It is also
|
|
|
|
|
used to translate its contents. You can prevent this by
|
|
|
|
|
setting :raw property to a non-nil value.
|
|
|
|
|
|
|
|
|
|
:splice
|
|
|
|
|
|
|
|
|
|
When non-nil, only export the contents of the top most plain
|
|
|
|
|
list, effectively ignoring its opening and closing lines.
|
|
|
|
|
|
|
|
|
|
:ustart, :uend
|
|
|
|
|
|
|
|
|
|
Strings to start and end an unordered list. They can also be
|
|
|
|
|
set to a function returning a string or nil, which will be
|
|
|
|
|
called with the depth of the list, counting from 1.
|
|
|
|
|
|
|
|
|
|
:ostart, :oend
|
|
|
|
|
|
|
|
|
|
Strings to start and end an ordered list. They can also be set
|
|
|
|
|
to a function returning a string or nil, which will be called
|
|
|
|
|
with the depth of the list, counting from 1.
|
|
|
|
|
|
|
|
|
|
:dstart, :dend
|
|
|
|
|
|
|
|
|
|
Strings to start and end a descriptive list. They can also be
|
|
|
|
|
set to a function returning a string or nil, which will be
|
|
|
|
|
called with the depth of the list, counting from 1.
|
|
|
|
|
|
|
|
|
|
:dtstart, :dtend, :ddstart, :ddend
|
|
|
|
|
|
|
|
|
|
Strings to start and end a descriptive term.
|
|
|
|
|
|
|
|
|
|
:istart, :iend
|
|
|
|
|
|
|
|
|
|
Strings to start or end a list item, and to start a list item
|
|
|
|
|
with a counter. They can also be set to a function returning
|
2016-10-29 19:00:49 -04:00
|
|
|
|
a string or nil, which will be called with two arguments: the
|
|
|
|
|
type of list and the depth of the item, counting from 1.
|
2015-12-02 17:30:54 -05:00
|
|
|
|
|
|
|
|
|
:icount
|
|
|
|
|
|
|
|
|
|
Strings to start a list item with a counter. It can also be
|
|
|
|
|
set to a function returning a string or nil, which will be
|
2016-10-29 19:00:49 -04:00
|
|
|
|
called with three arguments: the type of list, the depth of the
|
|
|
|
|
item, counting from 1, and the counter. Its value, when
|
|
|
|
|
non-nil, has precedence over `:istart'.
|
2015-12-02 17:30:54 -05:00
|
|
|
|
|
|
|
|
|
:isep
|
|
|
|
|
|
|
|
|
|
String used to separate items. It can also be set to
|
|
|
|
|
a function returning a string or nil, which will be called with
|
2016-10-29 19:00:49 -04:00
|
|
|
|
two arguments: the type of list and the depth of the item,
|
|
|
|
|
counting from 1. It always start on a new line.
|
|
|
|
|
|
|
|
|
|
:ifmt
|
|
|
|
|
|
|
|
|
|
Function to be applied to the contents of every item. It is
|
|
|
|
|
called with two arguments: the type of list and the contents.
|
2015-12-02 17:30:54 -05:00
|
|
|
|
|
|
|
|
|
:cbon, :cboff, :cbtrans
|
|
|
|
|
|
|
|
|
|
String to insert, respectively, an un-checked check-box,
|
|
|
|
|
a checked check-box and a check-box in transitional state."
|
|
|
|
|
(require 'ox)
|
|
|
|
|
(let* ((backend (plist-get params :backend))
|
|
|
|
|
(custom-backend
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:parent (or backend 'org)
|
|
|
|
|
:transcoders
|
|
|
|
|
`((plain-list . ,(org-list--to-generic-plain-list params))
|
|
|
|
|
(item . ,(org-list--to-generic-item params))
|
|
|
|
|
(macro . (lambda (m c i) (org-element-macro-interpreter m nil))))))
|
|
|
|
|
data info)
|
|
|
|
|
;; Write LIST back into Org syntax and parse it.
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(let ((org-inhibit-startup t)) (org-mode))
|
|
|
|
|
(letrec ((insert-list
|
|
|
|
|
(lambda (l)
|
|
|
|
|
(dolist (i (cdr l))
|
|
|
|
|
(funcall insert-item i (car l)))))
|
|
|
|
|
(insert-item
|
|
|
|
|
(lambda (i type)
|
|
|
|
|
(let ((start (point)))
|
|
|
|
|
(insert (if (eq type 'ordered) "1. " "- "))
|
|
|
|
|
(dolist (e i)
|
|
|
|
|
(if (consp e) (funcall insert-list e)
|
|
|
|
|
(insert e)
|
|
|
|
|
(insert "\n")))
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((ind (if (eq type 'ordered) 3 2)))
|
|
|
|
|
(while (> (point) start)
|
|
|
|
|
(unless (looking-at-p "[ \t]*$")
|
|
|
|
|
(indent-to ind))
|
|
|
|
|
(forward-line -1))))))))
|
|
|
|
|
(funcall insert-list list))
|
|
|
|
|
(setf data
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'plain-list
|
|
|
|
|
#'identity nil t))
|
|
|
|
|
(setf info (org-export-get-environment backend nil params)))
|
|
|
|
|
(when (and backend (symbolp backend) (not (org-export-get-backend backend)))
|
|
|
|
|
(user-error "Unknown :backend value"))
|
|
|
|
|
(unless backend (require 'ox-org))
|
|
|
|
|
;; When`:raw' property has a non-nil value, turn all objects back
|
|
|
|
|
;; into Org syntax.
|
|
|
|
|
(when (and backend (plist-get params :raw))
|
|
|
|
|
(org-element-map data org-element-all-objects
|
|
|
|
|
(lambda (object)
|
|
|
|
|
(org-element-set-element
|
|
|
|
|
object (org-element-interpret-data object)))))
|
|
|
|
|
;; We use a low-level mechanism to export DATA so as to skip all
|
|
|
|
|
;; usual pre-processing and post-processing, i.e., hooks, filters,
|
|
|
|
|
;; Babel code evaluation, include keywords and macro expansion,
|
|
|
|
|
;; and filters.
|
|
|
|
|
(let ((output (org-export-data-with-backend data custom-backend info)))
|
|
|
|
|
;; Remove final newline.
|
|
|
|
|
(if (org-string-nw-p output) (substring-no-properties output 0 -1) ""))))
|
|
|
|
|
|
|
|
|
|
(defun org-list--depth (element)
|
|
|
|
|
"Return the level of ELEMENT within current plain list.
|
|
|
|
|
ELEMENT is either an item or a plain list."
|
|
|
|
|
(cl-count-if (lambda (ancestor) (eq (org-element-type ancestor) 'plain-list))
|
|
|
|
|
(org-element-lineage element nil t)))
|
|
|
|
|
|
|
|
|
|
(defun org-list--trailing-newlines (string)
|
|
|
|
|
"Return the number of trailing newlines in STRING."
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert string)
|
|
|
|
|
(skip-chars-backward " \t\n")
|
|
|
|
|
(count-lines (line-beginning-position 2) (point-max))))
|
|
|
|
|
|
|
|
|
|
(defun org-list--generic-eval (value &rest args)
|
|
|
|
|
"Evaluate VALUE according to its type.
|
|
|
|
|
VALUE is either nil, a string or a function. In the latter case,
|
|
|
|
|
it is called with arguments ARGS."
|
|
|
|
|
(cond ((null value) nil)
|
|
|
|
|
((stringp value) value)
|
|
|
|
|
((functionp value) (apply value args))
|
|
|
|
|
(t (error "Wrong value: %s" value))))
|
|
|
|
|
|
|
|
|
|
(defun org-list--to-generic-plain-list (params)
|
|
|
|
|
"Return a transcoder for `plain-list' elements.
|
|
|
|
|
PARAMS is a plist used to tweak the behavior of the transcoder."
|
|
|
|
|
(let ((ustart (plist-get params :ustart))
|
|
|
|
|
(uend (plist-get params :uend))
|
|
|
|
|
(ostart (plist-get params :ostart))
|
|
|
|
|
(oend (plist-get params :oend))
|
|
|
|
|
(dstart (plist-get params :dstart))
|
|
|
|
|
(dend (plist-get params :dend))
|
|
|
|
|
(splice (plist-get params :splice))
|
|
|
|
|
(backend (plist-get params :backend)))
|
|
|
|
|
(lambda (plain-list contents info)
|
|
|
|
|
(let* ((type (org-element-property :type plain-list))
|
|
|
|
|
(depth (org-list--depth plain-list))
|
|
|
|
|
(start (and (not splice)
|
|
|
|
|
(org-list--generic-eval
|
|
|
|
|
(pcase type
|
|
|
|
|
(`ordered ostart)
|
|
|
|
|
(`unordered ustart)
|
|
|
|
|
(_ dstart))
|
|
|
|
|
depth)))
|
|
|
|
|
(end (and (not splice)
|
|
|
|
|
(org-list--generic-eval
|
|
|
|
|
(pcase type
|
|
|
|
|
(`ordered oend)
|
|
|
|
|
(`unordered uend)
|
|
|
|
|
(_ dend))
|
|
|
|
|
depth))))
|
|
|
|
|
;; Make sure trailing newlines in END appear in the output by
|
|
|
|
|
;; setting `:post-blank' property to their number.
|
|
|
|
|
(when end
|
|
|
|
|
(org-element-put-property
|
|
|
|
|
plain-list :post-blank (org-list--trailing-newlines end)))
|
|
|
|
|
;; Build output.
|
|
|
|
|
(concat (and start (concat start "\n"))
|
|
|
|
|
(if (or start end splice (not backend))
|
|
|
|
|
contents
|
|
|
|
|
(org-export-with-backend backend plain-list contents info))
|
|
|
|
|
end)))))
|
|
|
|
|
|
|
|
|
|
(defun org-list--to-generic-item (params)
|
|
|
|
|
"Return a transcoder for `item' elements.
|
|
|
|
|
PARAMS is a plist used to tweak the behavior of the transcoder."
|
|
|
|
|
(let ((backend (plist-get params :backend))
|
|
|
|
|
(istart (plist-get params :istart))
|
|
|
|
|
(iend (plist-get params :iend))
|
|
|
|
|
(isep (plist-get params :isep))
|
|
|
|
|
(icount (plist-get params :icount))
|
2016-10-29 19:00:49 -04:00
|
|
|
|
(ifmt (plist-get params :ifmt))
|
2015-12-02 17:30:54 -05:00
|
|
|
|
(cboff (plist-get params :cboff))
|
|
|
|
|
(cbon (plist-get params :cbon))
|
|
|
|
|
(cbtrans (plist-get params :cbtrans))
|
|
|
|
|
(dtstart (plist-get params :dtstart))
|
|
|
|
|
(dtend (plist-get params :dtend))
|
|
|
|
|
(ddstart (plist-get params :ddstart))
|
|
|
|
|
(ddend (plist-get params :ddend)))
|
|
|
|
|
(lambda (item contents info)
|
|
|
|
|
(let* ((type
|
|
|
|
|
(org-element-property :type (org-element-property :parent item)))
|
|
|
|
|
(tag (org-element-property :tag item))
|
|
|
|
|
(depth (org-list--depth item))
|
|
|
|
|
(separator (and (org-export-get-next-element item info)
|
2016-10-29 19:00:49 -04:00
|
|
|
|
(org-list--generic-eval isep type depth)))
|
|
|
|
|
(closing (pcase (org-list--generic-eval iend type depth)
|
|
|
|
|
((or `nil "") "\n")
|
2015-12-02 17:30:54 -05:00
|
|
|
|
((and (guard separator) s)
|
|
|
|
|
(if (equal (substring s -1) "\n") s (concat s "\n")))
|
|
|
|
|
(s s))))
|
|
|
|
|
;; When a closing line or a separator is provided, make sure
|
|
|
|
|
;; its trailing newlines are taken into account when building
|
|
|
|
|
;; output. This is done by setting `:post-blank' property to
|
|
|
|
|
;; the number of such lines in the last line to be added.
|
|
|
|
|
(let ((last-string (or separator closing)))
|
|
|
|
|
(when last-string
|
|
|
|
|
(org-element-put-property
|
|
|
|
|
item
|
|
|
|
|
:post-blank
|
|
|
|
|
(max (1- (org-list--trailing-newlines last-string)) 0))))
|
|
|
|
|
;; Build output.
|
|
|
|
|
(concat
|
|
|
|
|
(let ((c (org-element-property :counter item)))
|
2016-10-29 19:00:49 -04:00
|
|
|
|
(if (and c icount) (org-list--generic-eval icount type depth c)
|
|
|
|
|
(org-list--generic-eval istart type depth)))
|
2015-12-02 17:30:54 -05:00
|
|
|
|
(let ((body
|
2016-10-29 19:00:49 -04:00
|
|
|
|
(if (or istart iend icount ifmt cbon cboff cbtrans (not backend)
|
2015-12-02 17:30:54 -05:00
|
|
|
|
(and (eq type 'descriptive)
|
|
|
|
|
(or dtstart dtend ddstart ddend)))
|
|
|
|
|
(concat
|
|
|
|
|
(pcase (org-element-property :checkbox item)
|
|
|
|
|
(`on cbon)
|
|
|
|
|
(`off cboff)
|
|
|
|
|
(`trans cbtrans))
|
|
|
|
|
(and tag
|
|
|
|
|
(concat dtstart
|
|
|
|
|
(if backend
|
|
|
|
|
(org-export-data-with-backend
|
|
|
|
|
tag backend info)
|
|
|
|
|
(org-element-interpret-data tag))
|
|
|
|
|
dtend))
|
|
|
|
|
(and tag ddstart)
|
2016-10-29 19:00:49 -04:00
|
|
|
|
(let ((contents
|
|
|
|
|
(if (= (length contents) 0) ""
|
|
|
|
|
(substring contents 0 -1))))
|
|
|
|
|
(if ifmt (org-list--generic-eval ifmt type contents)
|
|
|
|
|
contents))
|
2015-12-02 17:30:54 -05:00
|
|
|
|
(and tag ddend))
|
|
|
|
|
(org-export-with-backend backend item contents info))))
|
|
|
|
|
;; Remove final newline.
|
|
|
|
|
(if (equal body "") ""
|
|
|
|
|
(substring (org-element-normalize-string body) 0 -1)))
|
|
|
|
|
closing
|
|
|
|
|
separator)))))
|
|
|
|
|
|
|
|
|
|
(defun org-list-to-latex (list &optional params)
|
2009-01-06 11:23:36 -05:00
|
|
|
|
"Convert LIST into a LaTeX list.
|
2015-12-02 17:30:54 -05:00
|
|
|
|
LIST is a parsed plain list, as returned by `org-list-to-lisp'.
|
2016-10-30 15:25:57 -04:00
|
|
|
|
PARAMS is a property list with overruling parameters for
|
|
|
|
|
`org-list-to-generic'. Return converted list as a string."
|
2013-03-04 04:51:54 -05:00
|
|
|
|
(require 'ox-latex)
|
2015-12-02 17:30:54 -05:00
|
|
|
|
(org-list-to-generic list (org-combine-plists '(:backend latex) params)))
|
2013-03-04 04:51:54 -05:00
|
|
|
|
|
2015-12-02 17:30:54 -05:00
|
|
|
|
(defun org-list-to-html (list &optional params)
|
2009-01-06 11:23:36 -05:00
|
|
|
|
"Convert LIST into a HTML list.
|
2015-12-02 17:30:54 -05:00
|
|
|
|
LIST is a parsed plain list, as returned by `org-list-to-lisp'.
|
2016-10-30 15:25:57 -04:00
|
|
|
|
PARAMS is a property list with overruling parameters for
|
|
|
|
|
`org-list-to-generic'. Return converted list as a string."
|
2013-03-04 04:51:54 -05:00
|
|
|
|
(require 'ox-html)
|
2015-12-02 17:30:54 -05:00
|
|
|
|
(org-list-to-generic list (org-combine-plists '(:backend html) params)))
|
2009-01-06 11:23:36 -05:00
|
|
|
|
|
2015-12-02 17:30:54 -05:00
|
|
|
|
(defun org-list-to-texinfo (list &optional params)
|
2009-01-06 11:23:36 -05:00
|
|
|
|
"Convert LIST into a Texinfo list.
|
2015-12-02 17:30:54 -05:00
|
|
|
|
LIST is a parsed plain list, as returned by `org-list-to-lisp'.
|
2016-10-30 15:25:57 -04:00
|
|
|
|
PARAMS is a property list with overruling parameters for
|
|
|
|
|
`org-list-to-generic'. Return converted list as a string."
|
2013-03-04 04:51:54 -05:00
|
|
|
|
(require 'ox-texinfo)
|
2015-12-02 17:30:54 -05:00
|
|
|
|
(org-list-to-generic list (org-combine-plists '(:backend texinfo) params)))
|
2008-09-23 02:03:13 -04:00
|
|
|
|
|
2016-10-29 19:06:36 -04:00
|
|
|
|
(defun org-list-to-org (list &optional params)
|
|
|
|
|
"Convert LIST into an Org plain list.
|
|
|
|
|
LIST is as returned by `org-list-parse-list'. PARAMS is a property list
|
|
|
|
|
with overruling parameters for `org-list-to-generic'."
|
|
|
|
|
(let* ((make-item
|
|
|
|
|
(lambda (type _depth &optional c)
|
|
|
|
|
(concat (if (eq type 'ordered) "1. " "- ")
|
|
|
|
|
(and c (format "[@%d] " c)))))
|
|
|
|
|
(defaults
|
|
|
|
|
(list :istart make-item
|
|
|
|
|
:icount make-item
|
|
|
|
|
:ifmt (lambda (_type contents)
|
|
|
|
|
(replace-regexp-in-string "\n" "\n " contents))
|
|
|
|
|
:dtend " :: "
|
|
|
|
|
:cbon "[X] "
|
|
|
|
|
:cboff "[ ] "
|
|
|
|
|
:cbtrans "[-] ")))
|
|
|
|
|
(org-list-to-generic list (org-combine-plists defaults params))))
|
|
|
|
|
|
2019-06-09 18:08:26 -04:00
|
|
|
|
(defun org-list-to-subtree (list &optional start-level params)
|
2011-01-20 10:32:30 -05:00
|
|
|
|
"Convert LIST into an Org subtree.
|
2019-06-09 18:08:26 -04:00
|
|
|
|
LIST is as returned by `org-list-to-lisp'. Subtree starts at
|
|
|
|
|
START-LEVEL or level 1 if nil. PARAMS is a property list with
|
|
|
|
|
overruling parameters for `org-list-to-generic'."
|
2015-12-02 17:30:54 -05:00
|
|
|
|
(let* ((blank (pcase (cdr (assq 'heading org-blank-before-new-entry))
|
|
|
|
|
(`t t)
|
|
|
|
|
(`auto (save-excursion
|
|
|
|
|
(org-with-limited-levels (outline-previous-heading))
|
|
|
|
|
(org-previous-line-empty-p)))))
|
2019-06-09 18:08:26 -04:00
|
|
|
|
(level (or start-level 1))
|
2015-12-02 17:30:54 -05:00
|
|
|
|
(make-stars
|
2016-10-29 19:00:49 -04:00
|
|
|
|
(lambda (_type depth &optional _count)
|
2015-12-02 17:30:54 -05:00
|
|
|
|
;; Return the string for the heading, depending on DEPTH
|
|
|
|
|
;; of current sub-list.
|
2019-06-09 18:08:26 -04:00
|
|
|
|
(let ((oddeven-level (+ level (1- depth))))
|
2015-11-07 18:07:33 -05:00
|
|
|
|
(concat (make-string (if org-odd-levels-only
|
|
|
|
|
(1- (* 2 oddeven-level))
|
|
|
|
|
oddeven-level)
|
|
|
|
|
?*)
|
|
|
|
|
" ")))))
|
2011-01-20 10:32:30 -05:00
|
|
|
|
(org-list-to-generic
|
|
|
|
|
list
|
|
|
|
|
(org-combine-plists
|
2015-12-02 17:30:54 -05:00
|
|
|
|
(list :splice t
|
|
|
|
|
:istart make-stars
|
|
|
|
|
:icount make-stars
|
|
|
|
|
:dtstart " " :dtend " "
|
|
|
|
|
:isep (if blank "\n\n" "\n")
|
|
|
|
|
:cbon "DONE " :cboff "TODO " :cbtrans "TODO ")
|
2011-01-20 10:32:30 -05:00
|
|
|
|
params))))
|
|
|
|
|
|
2008-09-23 02:03:13 -04:00
|
|
|
|
(provide 'org-list)
|
|
|
|
|
|
2020-02-18 17:37:24 -05:00
|
|
|
|
;; Local variables:
|
|
|
|
|
;; generated-autoload-file: "org-loaddefs.el"
|
|
|
|
|
;; End:
|
|
|
|
|
|
2008-09-23 02:03:13 -04:00
|
|
|
|
;;; org-list.el ends here
|