pkg update and first config fix
org-brain not working, add org-roam
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
;;; org-list.el --- Plain lists for Org -*- lexical-binding: t; -*-
|
||||
;;
|
||||
;; Copyright (C) 2004-2021 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2004-2022 Free Software Foundation, Inc.
|
||||
;;
|
||||
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
|
||||
;; Bastien Guerry <bzg@gnu.org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: https://orgmode.org
|
||||
;; URL: https://orgmode.org
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
@@ -76,9 +76,14 @@
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'org-macs)
|
||||
(org-assert-version)
|
||||
|
||||
(require 'cl-lib)
|
||||
(require 'org-macs)
|
||||
(require 'org-compat)
|
||||
(require 'org-fold-core)
|
||||
(require 'org-footnote)
|
||||
|
||||
(defvar org-M-RET-may-split-line)
|
||||
(defvar org-adapt-indentation)
|
||||
@@ -103,7 +108,7 @@
|
||||
(declare-function org-back-to-heading "org" (&optional invisible-ok))
|
||||
(declare-function org-before-first-heading-p "org" ())
|
||||
(declare-function org-current-level "org" ())
|
||||
(declare-function org-element-at-point "org-element" ())
|
||||
(declare-function org-element-at-point "org-element" (&optional pom cached-only))
|
||||
(declare-function org-element-context "org-element" (&optional element))
|
||||
(declare-function org-element-interpret-data "org-element" (data))
|
||||
(declare-function org-element-lineage "org-element" (blob &optional types with-self))
|
||||
@@ -133,12 +138,13 @@
|
||||
(declare-function org-inlinetask-outline-regexp "org-inlinetask" ())
|
||||
(declare-function org-level-increment "org" ())
|
||||
(declare-function org-mode "org" ())
|
||||
(declare-function org-narrow-to-subtree "org" ())
|
||||
(declare-function org-narrow-to-subtree "org" (&optional element))
|
||||
(declare-function org-outline-level "org" ())
|
||||
(declare-function org-previous-line-empty-p "org" ())
|
||||
(declare-function org-reduced-level "org" (L))
|
||||
(declare-function org-set-tags "org" (tags))
|
||||
(declare-function org-show-subtree "org" ())
|
||||
(declare-function org-fold-show-subtree "org-fold" ())
|
||||
(declare-function org-fold-region "org-fold" (from to flag &optional spec))
|
||||
(declare-function org-sort-remove-invisible "org" (S))
|
||||
(declare-function org-time-string-to-seconds "org" (s))
|
||||
(declare-function org-timer-hms-to-secs "org-timer" (hms))
|
||||
@@ -233,7 +239,7 @@ interface or run the following code after updating it:
|
||||
:type '(choice (const :tag "dot like in \"2.\"" ?.)
|
||||
(const :tag "paren like in \"2)\"" ?\))
|
||||
(const :tag "both" t))
|
||||
:set (lambda (var val) (set var val)
|
||||
:set (lambda (var val) (set-default-toplevel-value var val)
|
||||
(when (featurep 'org-element) (org-element-update-syntax))))
|
||||
|
||||
(defcustom org-list-allow-alphabetical nil
|
||||
@@ -251,7 +257,7 @@ interface or run the following code after updating it:
|
||||
:group 'org-plain-lists
|
||||
:version "24.1"
|
||||
:type 'boolean
|
||||
:set (lambda (var val) (set var val)
|
||||
:set (lambda (var val) (set-default-toplevel-value var val)
|
||||
(when (featurep 'org-element) (org-element-update-syntax))))
|
||||
|
||||
(defcustom org-list-two-spaces-after-bullet-regexp nil
|
||||
@@ -406,7 +412,7 @@ group 4: description tag")
|
||||
(ind-ref (if (or (looking-at "^[ \t]*$")
|
||||
(and inlinetask-re (looking-at inlinetask-re)))
|
||||
10000
|
||||
(current-indentation))))
|
||||
(org-current-text-indentation))))
|
||||
(cond
|
||||
((eq (nth 2 context) 'invalid) nil)
|
||||
((looking-at item-re) (point))
|
||||
@@ -428,7 +434,7 @@ group 4: description tag")
|
||||
;; Look for an item, less indented that reference line.
|
||||
(catch 'exit
|
||||
(while t
|
||||
(let ((ind (current-indentation)))
|
||||
(let ((ind (org-current-text-indentation)))
|
||||
(cond
|
||||
;; This is exactly what we want.
|
||||
((and (looking-at item-re) (< ind ind-ref))
|
||||
@@ -517,7 +523,7 @@ Contexts `block' and `invalid' refer to `org-list-forbidden-blocks'."
|
||||
(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))))
|
||||
(1+ (line-end-position))))
|
||||
(setq end (or (and (re-search-forward end-re lim-down t)
|
||||
(1- (match-beginning 0)))
|
||||
lim-down))
|
||||
@@ -528,12 +534,12 @@ Contexts `block' and `invalid' refer to `org-list-forbidden-blocks'."
|
||||
(when (save-excursion
|
||||
(and (not (looking-at block-re))
|
||||
(setq beg (and (re-search-backward block-re lim-up t)
|
||||
(1+ (point-at-eol))))
|
||||
(1+ (line-end-position))))
|
||||
(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)))
|
||||
(1- (line-beginning-position)))
|
||||
lim-down))
|
||||
(>= end pos)
|
||||
(equal (downcase (match-string 1)) "end")))
|
||||
@@ -547,7 +553,7 @@ Contexts `block' and `invalid' refer to `org-list-forbidden-blocks'."
|
||||
(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))))
|
||||
(1+ (line-end-position))))
|
||||
(not (looking-at end-re))
|
||||
(setq end (and (re-search-forward end-re lim-down t)
|
||||
(1- (match-beginning 0))))
|
||||
@@ -569,7 +575,7 @@ values are:
|
||||
6. position at item end.
|
||||
|
||||
Thus the following list, where numbers in parens are
|
||||
point-at-bol:
|
||||
line-beginning-position:
|
||||
|
||||
- [X] first item (1)
|
||||
1. sub-item 1 (18)
|
||||
@@ -598,7 +604,7 @@ Assume point is at an item."
|
||||
(item-re (org-item-re))
|
||||
(inlinetask-re (and (featurep 'org-inlinetask)
|
||||
(org-inlinetask-outline-regexp)))
|
||||
(beg-cell (cons (point) (current-indentation)))
|
||||
(beg-cell (cons (point) (org-current-text-indentation)))
|
||||
itm-lst itm-lst-2 end-lst end-lst-2 struct
|
||||
(assoc-at-point
|
||||
;; Return association at point.
|
||||
@@ -617,14 +623,14 @@ Assume point is at an item."
|
||||
;; Ensure list ends at the first blank line.
|
||||
(lambda ()
|
||||
(skip-chars-backward " \r\t\n")
|
||||
(min (1+ (point-at-eol)) lim-down))))
|
||||
(min (1+ (line-end-position)) lim-down))))
|
||||
;; 1. Read list from starting item to its beginning, and save
|
||||
;; top item position and indentation in BEG-CELL. Also store
|
||||
;; ending position of items in END-LST.
|
||||
(save-excursion
|
||||
(catch 'exit
|
||||
(while t
|
||||
(let ((ind (current-indentation)))
|
||||
(let ((ind (org-current-text-indentation)))
|
||||
(cond
|
||||
((<= (point) lim-up)
|
||||
;; At upward limit: if we ended at an item, store it,
|
||||
@@ -684,7 +690,7 @@ Assume point is at an item."
|
||||
;; position of items in END-LST-2.
|
||||
(catch 'exit
|
||||
(while t
|
||||
(let ((ind (current-indentation)))
|
||||
(let ((ind (org-current-text-indentation)))
|
||||
(cond
|
||||
((>= (point) lim-down)
|
||||
;; At downward limit: this is de facto the end of the
|
||||
@@ -872,7 +878,7 @@ 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)))
|
||||
(line-end-position)))
|
||||
|
||||
(defun org-list-get-parent (item struct parents)
|
||||
"Return parent of ITEM or nil.
|
||||
@@ -1089,79 +1095,64 @@ 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)))
|
||||
(sub-B (cons beg-B (org-list-get-subtree beg-B struct)))
|
||||
;; Store overlays responsible for visibility status. We
|
||||
;; also need to store their boundaries as they will be
|
||||
;; removed from buffer.
|
||||
(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))))))
|
||||
;; 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.
|
||||
(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))
|
||||
;; Restore visibility status, by moving overlays to their new
|
||||
;; position.
|
||||
(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))))
|
||||
;; Return structure.
|
||||
struct)))
|
||||
(org-fold-core-ignore-modifications
|
||||
(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)))
|
||||
(sub-B (cons beg-B (org-list-get-subtree beg-B struct)))
|
||||
;; Store inner folds responsible for visibility status.
|
||||
(folds
|
||||
(cons
|
||||
(org-fold-core-get-regions :from beg-A :to end-A :relative t)
|
||||
(org-fold-core-get-regions :from beg-B :to end-B :relative t))))
|
||||
;; Clear up the folds.
|
||||
(org-fold-region beg-A end-B-no-blank nil)
|
||||
;; 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))
|
||||
;; Restore visibility status.
|
||||
(org-fold-core-regions (cdr folds) :relative beg-A)
|
||||
(org-fold-core-regions
|
||||
(car folds)
|
||||
:relative (+ beg-B (- size-B size-A (length between-A-no-blank-and-B))))
|
||||
;; 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.
|
||||
(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))
|
||||
;; Return structure.
|
||||
struct))))
|
||||
|
||||
(defun org-list-separating-blank-lines-number (pos struct prevs)
|
||||
"Return number of blank lines that should separate items in list.
|
||||
@@ -1182,7 +1173,7 @@ some heuristics to guess the result."
|
||||
(lambda ()
|
||||
;; Count blank lines above beginning of line.
|
||||
(save-excursion
|
||||
(count-lines (goto-char (point-at-bol))
|
||||
(count-lines (goto-char (line-beginning-position))
|
||||
(progn (skip-chars-backward " \r\t\n")
|
||||
(forward-line)
|
||||
(point)))))))
|
||||
@@ -1287,7 +1278,7 @@ This function modifies STRUCT."
|
||||
;; 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)))
|
||||
(delete-region (1- item-end) (line-end-position)))
|
||||
(skip-chars-backward " \r\t\n")
|
||||
;; Cut position is after any blank on the line.
|
||||
(save-excursion
|
||||
@@ -1364,7 +1355,7 @@ STRUCT is the list structure."
|
||||
(save-excursion
|
||||
(goto-char item)
|
||||
(skip-chars-backward " \r\t\n")
|
||||
(min (1+ (point-at-eol)) (point-max)))
|
||||
(min (1+ (line-end-position)) (point-max)))
|
||||
item)))
|
||||
;; Remove item from buffer.
|
||||
(delete-region beg end)
|
||||
@@ -1441,8 +1432,8 @@ This function returns, destructively, the new list structure."
|
||||
(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)))
|
||||
((string-match-p "\\`[0-9]+\\'" dest)
|
||||
(line-end-position)))
|
||||
((and (stringp dest) (string-match-p "\\`[0-9]+\\'" dest))
|
||||
(let* ((all (org-list-get-all-items item struct prevs))
|
||||
(len (length all))
|
||||
(index (mod (string-to-number dest) len)))
|
||||
@@ -1453,7 +1444,7 @@ This function returns, destructively, the new list structure."
|
||||
(save-excursion
|
||||
(goto-char
|
||||
(org-list-get-last-item item struct prevs))
|
||||
(point-at-eol)))))
|
||||
(line-end-position)))))
|
||||
(t dest)))
|
||||
(org-M-RET-may-split-line nil)
|
||||
;; Store inner overlays (to preserve visibility).
|
||||
@@ -1850,7 +1841,7 @@ Initial position of cursor is restored after the changes."
|
||||
(org-inlinetask-goto-beginning))
|
||||
;; Shift only non-empty lines.
|
||||
((looking-at-p "^[ \t]*\\S-")
|
||||
(indent-line-to (+ (current-indentation) delta))))
|
||||
(indent-line-to (+ (org-current-text-indentation) delta))))
|
||||
(forward-line -1))))
|
||||
(modify-item
|
||||
;; Replace ITEM first line elements with new elements from
|
||||
@@ -1858,7 +1849,7 @@ Initial position of cursor is restored after the changes."
|
||||
(lambda (item)
|
||||
(goto-char item)
|
||||
(let* ((new-ind (org-list-get-ind item struct))
|
||||
(old-ind (current-indentation))
|
||||
(old-ind (org-current-text-indentation))
|
||||
(new-bul (org-list-bullet-string
|
||||
(org-list-get-bullet item struct)))
|
||||
(old-bul (org-list-get-bullet item old-struct))
|
||||
@@ -1866,7 +1857,22 @@ Initial position of cursor is restored after the changes."
|
||||
(looking-at org-list-full-item-re)
|
||||
;; a. Replace bullet
|
||||
(unless (equal old-bul new-bul)
|
||||
(replace-match new-bul nil nil nil 1))
|
||||
(let ((keep-space ""))
|
||||
(save-excursion
|
||||
;; If origin is inside the bullet, preserve the
|
||||
;; spaces after origin.
|
||||
(when (<= (match-beginning 1) origin (match-end 1))
|
||||
(org-with-point-at origin
|
||||
(save-match-data
|
||||
(when (looking-at "[ \t]+")
|
||||
(setq keep-space (match-string 0))))))
|
||||
(replace-match "" nil nil nil 1)
|
||||
(goto-char (match-end 1))
|
||||
(insert-before-markers new-bul)
|
||||
(insert keep-space))))
|
||||
;; Refresh potentially shifted match markers.
|
||||
(goto-char item)
|
||||
(looking-at org-list-full-item-re)
|
||||
;; b. Replace checkbox.
|
||||
(cond
|
||||
((equal (match-string 3) new-box))
|
||||
@@ -1880,7 +1886,7 @@ Initial position of cursor is restored after the changes."
|
||||
(insert (concat new-box (unless counterp " "))))))
|
||||
;; c. Indent item to appropriate column.
|
||||
(unless (= new-ind old-ind)
|
||||
(delete-region (goto-char (point-at-bol))
|
||||
(delete-region (goto-char (line-beginning-position))
|
||||
(progn (skip-chars-forward " \t") (point)))
|
||||
(indent-to new-ind))))))
|
||||
;; 1. First get list of items and position endings. We maintain
|
||||
@@ -1933,7 +1939,7 @@ Initial position of cursor is restored after the changes."
|
||||
;; Ignore empty lines. Also ignore blocks and
|
||||
;; drawers contents.
|
||||
(unless (looking-at-p "[ \t]*$")
|
||||
(setq min-ind (min (current-indentation) min-ind))
|
||||
(setq min-ind (min (org-current-text-indentation) min-ind))
|
||||
(cond
|
||||
((and (looking-at "#\\+BEGIN\\(:\\|_\\S-+\\)")
|
||||
(re-search-forward
|
||||
@@ -2010,7 +2016,7 @@ Sublists of the list are skipped. Cursor is always at the
|
||||
beginning of the item."
|
||||
(let* ((struct (org-list-struct))
|
||||
(prevs (org-list-prevs-alist struct))
|
||||
(item (copy-marker (point-at-bol)))
|
||||
(item (copy-marker (line-beginning-position)))
|
||||
(all (org-list-get-all-items (marker-position item) struct prevs))
|
||||
(value init-value))
|
||||
(dolist (e (nreverse all))
|
||||
@@ -2029,7 +2035,7 @@ Possible values are: `folded', `children' or `subtree'. See
|
||||
((eq view 'folded)
|
||||
(let ((item-end (org-list-get-item-end-before-blank item struct)))
|
||||
;; Hide from eol
|
||||
(org-flag-region (save-excursion (goto-char item) (line-end-position))
|
||||
(org-fold-region (save-excursion (goto-char item) (line-end-position))
|
||||
item-end t 'outline)))
|
||||
((eq view 'children)
|
||||
;; First show everything.
|
||||
@@ -2042,7 +2048,7 @@ Possible values are: `folded', `children' or `subtree'. See
|
||||
((eq view 'subtree)
|
||||
;; Show everything
|
||||
(let ((item-end (org-list-get-item-end item struct)))
|
||||
(org-flag-region item item-end nil 'outline)))))
|
||||
(org-fold-region item item-end nil 'outline)))))
|
||||
|
||||
(defun org-list-item-body-column (item)
|
||||
"Return column at which body of ITEM should start."
|
||||
@@ -2147,10 +2153,10 @@ the item, so this really moves item trees."
|
||||
(interactive)
|
||||
(unless (org-at-item-p) (error "Not at an item"))
|
||||
(let* ((col (current-column))
|
||||
(item (point-at-bol))
|
||||
(item (line-beginning-position))
|
||||
(struct (org-list-struct))
|
||||
(prevs (org-list-prevs-alist struct))
|
||||
(next-item (org-list-get-next-item (point-at-bol) struct prevs)))
|
||||
(next-item (org-list-get-next-item (line-beginning-position) struct prevs)))
|
||||
(unless (or next-item org-list-use-circular-motion)
|
||||
(user-error "Cannot move this item further down"))
|
||||
(if (not next-item)
|
||||
@@ -2168,10 +2174,10 @@ the item, so this really moves item trees."
|
||||
(interactive)
|
||||
(unless (org-at-item-p) (error "Not at an item"))
|
||||
(let* ((col (current-column))
|
||||
(item (point-at-bol))
|
||||
(item (line-beginning-position))
|
||||
(struct (org-list-struct))
|
||||
(prevs (org-list-prevs-alist struct))
|
||||
(prev-item (org-list-get-prev-item (point-at-bol) struct prevs)))
|
||||
(prev-item (org-list-get-prev-item (line-beginning-position) struct prevs)))
|
||||
(unless (or prev-item org-list-use-circular-motion)
|
||||
(user-error "Cannot move this item further up"))
|
||||
(if (not prev-item)
|
||||
@@ -2212,6 +2218,7 @@ item is invisible."
|
||||
(setq struct (org-list-insert-item pos struct prevs checkbox desc))
|
||||
(org-list-write-struct struct (org-list-parents-alist struct))
|
||||
(when checkbox (org-update-checkbox-count-maybe))
|
||||
(beginning-of-line)
|
||||
(looking-at org-list-full-item-re)
|
||||
(goto-char (if (and (match-beginning 4)
|
||||
(save-match-data
|
||||
@@ -2240,12 +2247,19 @@ is an integer, 0 means `-', 1 means `+' etc. If WHICH is
|
||||
`previous', cycle backwards."
|
||||
(interactive "P")
|
||||
(unless (org-at-item-p) (error "Not at an item"))
|
||||
(save-excursion
|
||||
(let ((origin (point-marker)))
|
||||
(beginning-of-line)
|
||||
(let* ((struct (org-list-struct))
|
||||
(parents (org-list-parents-alist struct))
|
||||
(prevs (org-list-prevs-alist struct))
|
||||
(list-beg (org-list-get-first-item (point) struct prevs))
|
||||
;; Record relative point position to bullet beginning.
|
||||
(origin-offset (- origin
|
||||
(+ (point) (org-list-get-ind (point) struct))))
|
||||
;; Record relative point position to bullet end.
|
||||
(origin-offset2 (- origin
|
||||
(+ (point) (org-list-get-ind (point) struct)
|
||||
(length (org-list-get-bullet (point) struct)))))
|
||||
(bullet (org-list-get-bullet list-beg struct))
|
||||
(alpha-p (org-list-use-alpha-bul-p list-beg struct prevs))
|
||||
(case-fold-search nil)
|
||||
@@ -2291,7 +2305,24 @@ is an integer, 0 means `-', 1 means `+' etc. If WHICH is
|
||||
(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)))))
|
||||
(org-list-struct-apply-struct struct old-struct))
|
||||
(goto-char origin)
|
||||
(setq struct (org-list-struct))
|
||||
(cond
|
||||
((>= origin-offset2 0)
|
||||
(beginning-of-line)
|
||||
(move-marker origin (+ (point)
|
||||
(org-list-get-ind (point) struct)
|
||||
(length (org-list-get-bullet (point) struct))
|
||||
origin-offset2))
|
||||
(goto-char origin))
|
||||
((>= origin-offset 0)
|
||||
(beginning-of-line)
|
||||
(move-marker origin (+ (point)
|
||||
(org-list-get-ind (point) struct)
|
||||
origin-offset))
|
||||
(goto-char origin)))
|
||||
(move-marker origin nil))))
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode org-list-checkbox-radio-mode
|
||||
@@ -2312,7 +2343,7 @@ is an integer, 0 means `-', 1 means `+' etc. If WHICH is
|
||||
(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))
|
||||
(start (org-list-get-list-begin (line-beginning-position) struct prevs))
|
||||
(new (unless (and cbox (equal arg '(4)) (equal start cpos))
|
||||
"[ ]")))
|
||||
(dolist (pos (org-list-get-all-items
|
||||
@@ -2372,7 +2403,7 @@ subtree, ignoring planning line and any drawer following it."
|
||||
(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))
|
||||
(setq lim-up (line-beginning-position))
|
||||
(error "No item in region"))
|
||||
(setq lim-down (copy-marker limit))))
|
||||
((org-at-heading-p)
|
||||
@@ -2381,14 +2412,14 @@ subtree, ignoring planning line and any drawer following it."
|
||||
(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))
|
||||
(setq lim-up (line-beginning-position))
|
||||
(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))))
|
||||
(setq lim-up (line-beginning-position)
|
||||
lim-down (copy-marker (line-end-position))))
|
||||
(t (error "Not at an item or heading, and no active region"))))
|
||||
;; Determine the checkbox going to be applied to all items
|
||||
;; within bounds.
|
||||
@@ -2455,7 +2486,7 @@ subtree, ignoring planning line and any drawer following it."
|
||||
(save-restriction
|
||||
(save-excursion
|
||||
(org-narrow-to-subtree)
|
||||
(org-show-subtree)
|
||||
(org-fold-show-subtree)
|
||||
(goto-char (point-min))
|
||||
(let ((end (point-max)))
|
||||
(while (< (point) end)
|
||||
@@ -2636,7 +2667,7 @@ Return t if successful."
|
||||
;; Are we going to move the whole list?
|
||||
(specialp
|
||||
(and (not regionp)
|
||||
(= top (point-at-bol))
|
||||
(= top (line-beginning-position))
|
||||
(cdr (assq 'indent org-list-automatic-rules))
|
||||
(if no-subtree
|
||||
(user-error
|
||||
@@ -2650,12 +2681,12 @@ Return t if successful."
|
||||
(progn
|
||||
(set-marker org-last-indent-begin-marker rbeg)
|
||||
(set-marker org-last-indent-end-marker rend))
|
||||
(set-marker org-last-indent-begin-marker (point-at-bol))
|
||||
(set-marker org-last-indent-begin-marker (line-beginning-position))
|
||||
(set-marker org-last-indent-end-marker
|
||||
(cond
|
||||
(specialp (org-list-get-bottom-point struct))
|
||||
(no-subtree (1+ (point-at-bol)))
|
||||
(t (org-list-get-item-end (point-at-bol) struct))))))
|
||||
(no-subtree (1+ (line-beginning-position)))
|
||||
(t (org-list-get-item-end (line-beginning-position) struct))))))
|
||||
(let* ((beg (marker-position org-last-indent-begin-marker))
|
||||
(end (marker-position org-last-indent-end-marker)))
|
||||
(cond
|
||||
@@ -2893,8 +2924,8 @@ function is being called interactively."
|
||||
(let* ((case-func (if with-case 'identity 'downcase))
|
||||
(struct (org-list-struct))
|
||||
(prevs (org-list-prevs-alist struct))
|
||||
(start (org-list-get-list-begin (point-at-bol) struct prevs))
|
||||
(end (org-list-get-list-end (point-at-bol) struct prevs))
|
||||
(start (org-list-get-list-begin (line-beginning-position) struct prevs))
|
||||
(end (org-list-get-list-end (line-beginning-position) struct prevs))
|
||||
(sorting-type
|
||||
(or sorting-type
|
||||
(progn
|
||||
@@ -2910,7 +2941,7 @@ function is being called interactively."
|
||||
(error "Missing key extractor"))))
|
||||
(sort-func
|
||||
(cond
|
||||
((= dcst ?a) #'org-string-collate-lessp)
|
||||
((= dcst ?a) #'string-collate-lessp)
|
||||
((= dcst ?f)
|
||||
(or compare-func
|
||||
(and interactive?
|
||||
@@ -2939,21 +2970,21 @@ function is being called interactively."
|
||||
((= dcst ?n)
|
||||
(string-to-number
|
||||
(org-sort-remove-invisible
|
||||
(buffer-substring (match-end 0) (point-at-eol)))))
|
||||
(buffer-substring (match-end 0) (line-end-position)))))
|
||||
((= dcst ?a)
|
||||
(funcall case-func
|
||||
(org-sort-remove-invisible
|
||||
(buffer-substring
|
||||
(match-end 0) (point-at-eol)))))
|
||||
(match-end 0) (line-end-position)))))
|
||||
((= dcst ?t)
|
||||
(cond
|
||||
;; If it is a timer list, convert timer to seconds
|
||||
((org-at-item-timer-p)
|
||||
(org-timer-hms-to-secs (match-string 1)))
|
||||
((or (save-excursion
|
||||
(re-search-forward org-ts-regexp (point-at-eol) t))
|
||||
(re-search-forward org-ts-regexp (line-end-position) t))
|
||||
(save-excursion (re-search-forward org-ts-regexp-both
|
||||
(point-at-eol) t)))
|
||||
(line-end-position) t)))
|
||||
(org-time-string-to-seconds (match-string 0)))
|
||||
(t (float-time now))))
|
||||
((= dcst ?x) (or (and (stringp (match-string 1))
|
||||
@@ -2991,7 +3022,38 @@ 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
|
||||
(let ((extract-footnote-definitions
|
||||
(lambda (end)
|
||||
;; Remove footnote definitions from point to END.
|
||||
;; Return the list of the extracted definitions.
|
||||
(let (definitions element)
|
||||
(save-excursion
|
||||
(while (re-search-forward org-footnote-definition-re end t)
|
||||
(setq element (org-element-at-point))
|
||||
(when (eq 'footnote-definition
|
||||
(org-element-type element))
|
||||
(push (buffer-substring-no-properties
|
||||
(org-element-property :begin element)
|
||||
(org-element-property :end element))
|
||||
definitions)
|
||||
;; Ensure at least 2 blank lines after the last
|
||||
;; footnote definition, thus not slurping the
|
||||
;; following element.
|
||||
(unless (<= 2 (org-element-property
|
||||
:post-blank
|
||||
(org-element-at-point)))
|
||||
(setf (car definitions)
|
||||
(concat (car definitions)
|
||||
(make-string
|
||||
(- 2 (org-element-property
|
||||
:post-blank
|
||||
(org-element-at-point)))
|
||||
?\n))))
|
||||
(delete-region
|
||||
(org-element-property :begin element)
|
||||
(org-element-property :end element))))
|
||||
definitions))))
|
||||
(shift-text
|
||||
(lambda (ind end)
|
||||
;; Shift text in current section to IND, from point to END.
|
||||
;; The function leaves point to END line.
|
||||
@@ -3001,7 +3063,7 @@ With a prefix argument ARG, change the region in a single item."
|
||||
(save-excursion
|
||||
(catch 'exit
|
||||
(while (< (point) end)
|
||||
(let ((i (current-indentation)))
|
||||
(let ((i (org-current-text-indentation)))
|
||||
(cond
|
||||
;; Skip blank lines and inline tasks.
|
||||
((looking-at "^[ \t]*$"))
|
||||
@@ -3017,7 +3079,7 @@ With a prefix argument ARG, change the region in a single item."
|
||||
(while (< (point) end)
|
||||
(unless (or (looking-at "^[ \t]*$")
|
||||
(looking-at org-outline-regexp-bol))
|
||||
(indent-line-to (+ (current-indentation) delta)))
|
||||
(indent-line-to (+ (org-current-text-indentation) delta)))
|
||||
(forward-line))))))
|
||||
(skip-blanks
|
||||
(lambda (pos)
|
||||
@@ -3026,14 +3088,14 @@ With a prefix argument ARG, change the region in a single item."
|
||||
(save-excursion
|
||||
(goto-char pos)
|
||||
(skip-chars-forward " \r\t\n")
|
||||
(point-at-bol))))
|
||||
(line-beginning-position))))
|
||||
beg end)
|
||||
;; Determine boundaries of changes.
|
||||
(if (org-region-active-p)
|
||||
(setq beg (funcall skip-blanks (region-beginning))
|
||||
end (copy-marker (region-end)))
|
||||
(setq beg (point-at-bol)
|
||||
end (copy-marker (point-at-eol))))
|
||||
(setq beg (line-beginning-position)
|
||||
end (copy-marker (line-end-position))))
|
||||
;; Depending on the starting line, choose an action on the text
|
||||
;; between BEG and END.
|
||||
(org-with-limited-levels
|
||||
@@ -3049,7 +3111,7 @@ With a prefix argument ARG, change the region in a single item."
|
||||
(skip-chars-forward " \t")
|
||||
(delete-region (point) (match-end 0)))
|
||||
(forward-line)))
|
||||
;; Case 2. Start at an heading: convert to items.
|
||||
;; Case 2. Start at a heading: convert to items.
|
||||
((org-at-heading-p)
|
||||
;; Remove metadata
|
||||
(let (org-loop-over-headlines-in-active-region)
|
||||
@@ -3065,7 +3127,9 @@ With a prefix argument ARG, change the region in a single item."
|
||||
(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))))
|
||||
(ref-level (org-reduced-level (org-outline-level)))
|
||||
(footnote-definitions
|
||||
(funcall extract-footnote-definitions end)))
|
||||
(while (< (point) end)
|
||||
(let* ((level (org-reduced-level (org-outline-level)))
|
||||
(delta (max 0 (- level ref-level)))
|
||||
@@ -3094,8 +3158,8 @@ With a prefix argument ARG, change the region in a single item."
|
||||
"[X]"
|
||||
"[ ]"))
|
||||
(org-list-write-struct struct
|
||||
(org-list-parents-alist struct)
|
||||
old)))
|
||||
(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
|
||||
@@ -3103,13 +3167,23 @@ With a prefix argument ARG, change the region in a single item."
|
||||
(forward-line)
|
||||
(funcall shift-text
|
||||
(+ start-ind (* (1+ delta) bul-len))
|
||||
(min end section-end)))))))
|
||||
(min end section-end)))))
|
||||
(when footnote-definitions
|
||||
(goto-char end)
|
||||
;; Insert footnote definitions after the list.
|
||||
(unless (bolp) (beginning-of-line 2))
|
||||
;; At (point-max).
|
||||
(unless (bolp) (insert "\n"))
|
||||
(dolist (def footnote-definitions)
|
||||
(insert def)))))
|
||||
;; 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))
|
||||
(ref-ind (current-indentation)))
|
||||
(ref-ind (org-current-text-indentation))
|
||||
(footnote-definitions
|
||||
(funcall extract-footnote-definitions end)))
|
||||
(skip-chars-forward " \t")
|
||||
(insert bul)
|
||||
(forward-line)
|
||||
@@ -3120,7 +3194,21 @@ With a prefix argument ARG, change the region in a single item."
|
||||
(+ ref-ind bul-len)
|
||||
(min end (save-excursion (or (outline-next-heading)
|
||||
(point)))))
|
||||
(forward-line))))
|
||||
(forward-line))
|
||||
(when footnote-definitions
|
||||
;; If the new list is followed by same-level items,
|
||||
;; move past them as well.
|
||||
(goto-char (org-element-property
|
||||
:end
|
||||
(org-element-lineage
|
||||
(org-element-at-point (1- end))
|
||||
'(plain-list) t)))
|
||||
;; Insert footnote definitions after the list.
|
||||
(unless (bolp) (beginning-of-line 2))
|
||||
;; At (point-max).
|
||||
(unless (bolp) (insert "\n"))
|
||||
(dolist (def footnote-definitions)
|
||||
(insert def)))))
|
||||
;; Case 4. Normal line without ARG: turn each non-item line
|
||||
;; into an item.
|
||||
(t
|
||||
|
||||
Reference in New Issue
Block a user