update packages
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
;;; org-toc.el --- Table of contents for Org-mode buffer
|
||||
;;; org-toc.el --- Table of contents for Org-mode buffer -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright 2007-2021 Free Software Foundation, Inc.
|
||||
;;
|
||||
@@ -33,7 +33,8 @@
|
||||
|
||||
(provide 'org-toc)
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
(require 'cl-lib))
|
||||
(require 'org)
|
||||
|
||||
;;; Custom variables:
|
||||
(defvar org-toc-base-buffer nil)
|
||||
@@ -84,7 +85,7 @@ headlines in the TOC buffer."
|
||||
(defcustom org-toc-recenter 0
|
||||
"Where to recenter the Org buffer when unfolding a subtree.
|
||||
This variable is only used when `org-toc-recenter-mode' is set to
|
||||
'custom. A value >=1000 will call recenter with no arg."
|
||||
\\='custom. A value >=1000 will call recenter with no arg."
|
||||
:group 'org-toc
|
||||
:type 'integer)
|
||||
|
||||
@@ -92,7 +93,7 @@ This variable is only used when `org-toc-recenter-mode' is set to
|
||||
"A list of excluded properties when displaying info in the
|
||||
echo-area. The COLUMNS property is always excluded."
|
||||
:group 'org-toc
|
||||
:type 'lits)
|
||||
:type '(list string))
|
||||
|
||||
;;; Org TOC mode:
|
||||
(defvar org-toc-mode-map (make-sparse-keymap)
|
||||
@@ -186,8 +187,7 @@ specified, then make `org-toc-recenter' use this value."
|
||||
(format "on, line %d" org-toc-recenter) "off")))
|
||||
|
||||
(defun org-toc-cycle-subtree ()
|
||||
"Locally cycle a headline through two states: 'children and
|
||||
'folded"
|
||||
"Cycle a headline through two states: \\='children and \\='folded."
|
||||
(interactive)
|
||||
(let ((beg (point))
|
||||
(end (save-excursion (end-of-line) (point)))
|
||||
@@ -197,14 +197,16 @@ specified, then make `org-toc-recenter' use this value."
|
||||
(setq ov (make-overlay beg end)))
|
||||
;; change the folding status of this headline
|
||||
(cond ((or (null status) (eq status 'folded))
|
||||
(org-show-children)
|
||||
(if (fboundp 'org-fold-show-children)
|
||||
(org-fold-show-children)
|
||||
(with-no-warnings (org-show-children)))
|
||||
(message "CHILDREN")
|
||||
(overlay-put ov 'status 'children))
|
||||
((eq status 'children)
|
||||
(show-branches)
|
||||
(outline-show-branches)
|
||||
(message "BRANCHES")
|
||||
(overlay-put ov 'status 'branches))
|
||||
(t (hide-subtree)
|
||||
(t (outline-hide-subtree)
|
||||
(message "FOLDED")
|
||||
(overlay-put ov 'status 'folded)))))
|
||||
|
||||
@@ -223,7 +225,7 @@ specified, then make `org-toc-recenter' use this value."
|
||||
(progn (setq org-toc-base-buffer (current-buffer))
|
||||
(setq org-toc-odd-levels-only org-odd-levels-only))
|
||||
(if (eq major-mode 'org-toc-mode)
|
||||
(org-pop-to-buffer-same-window org-toc-base-buffer)
|
||||
(pop-to-buffer-same-window org-toc-base-buffer)
|
||||
(error "Not in an Org buffer")))
|
||||
;; create the new window display
|
||||
(let ((pos (or position
|
||||
@@ -280,7 +282,7 @@ specified, then make `org-toc-recenter' use this value."
|
||||
(defun org-toc-goto (&optional jump cycle)
|
||||
"From Org TOC buffer, follow the targeted subtree in the Org window.
|
||||
If JUMP is non-nil, go to the base buffer.
|
||||
If JUMP is 'delete, go to the base buffer and delete other windows.
|
||||
If JUMP is \\='delete, go to the base buffer and delete other windows.
|
||||
If CYCLE is non-nil, cycle the targeted subtree in the Org window."
|
||||
(interactive)
|
||||
(let ((pos (point))
|
||||
@@ -290,9 +292,15 @@ If CYCLE is non-nil, cycle the targeted subtree in the Org window."
|
||||
(if cycle (org-cycle)
|
||||
(progn (org-overview)
|
||||
(if org-toc-show-subtree-mode
|
||||
(org-show-subtree)
|
||||
(org-show-entry))
|
||||
(org-show-context)))
|
||||
(if (fboundp 'org-fold-show-subtree)
|
||||
(org-fold-show-subtree)
|
||||
(with-no-warnings (org-show-subtree)))
|
||||
(if (fboundp 'org-fold-show-entry)
|
||||
(org-fold-show-entry)
|
||||
(with-no-warnings (org-show-entry))))
|
||||
(if (fboundp 'org-fold-show-context)
|
||||
(org-fold-show-context)
|
||||
(with-no-warnings (org-show-context)))))
|
||||
(if org-toc-recenter-mode
|
||||
(if (>= org-toc-recenter 1000) (recenter)
|
||||
(recenter org-toc-recenter)))
|
||||
@@ -363,13 +371,13 @@ If DELETE is non-nil, delete other windows when in the Org buffer."
|
||||
"Toggle columns view in the Org buffer from Org TOC."
|
||||
(interactive)
|
||||
(let ((indirect-buffer (current-buffer)))
|
||||
(org-pop-to-buffer-same-window org-toc-base-buffer)
|
||||
(pop-to-buffer-same-window org-toc-base-buffer)
|
||||
(if (not org-toc-columns-shown)
|
||||
(progn (org-columns)
|
||||
(setq org-toc-columns-shown t))
|
||||
(progn (org-columns-remove-overlays)
|
||||
(setq org-toc-columns-shown nil)))
|
||||
(org-pop-to-buffer-same-window indirect-buffer)))
|
||||
(pop-to-buffer-same-window indirect-buffer)))
|
||||
|
||||
(defun org-toc-info ()
|
||||
"Show properties of current subtree in the echo-area."
|
||||
@@ -377,7 +385,7 @@ If DELETE is non-nil, delete other windows when in the Org buffer."
|
||||
(let ((pos (point))
|
||||
(indirect-buffer (current-buffer))
|
||||
props prop msg)
|
||||
(org-pop-to-buffer-same-window org-toc-base-buffer)
|
||||
(pop-to-buffer-same-window org-toc-base-buffer)
|
||||
(goto-char pos)
|
||||
(setq props (org-entry-properties))
|
||||
(while (setq prop (pop props))
|
||||
@@ -390,7 +398,7 @@ If DELETE is non-nil, delete other windows when in the Org buffer."
|
||||
(setq p (concat p ":"))
|
||||
(add-text-properties 0 (length p) '(face org-special-keyword) p)
|
||||
(setq msg (concat msg p " " v " ")))))
|
||||
(org-pop-to-buffer-same-window indirect-buffer)
|
||||
(pop-to-buffer-same-window indirect-buffer)
|
||||
(message msg)))
|
||||
|
||||
;;; Store and restore TOC configuration:
|
||||
@@ -441,11 +449,13 @@ current table of contents to it."
|
||||
(setq ov (make-overlay (match-beginning 0)
|
||||
(match-end 0))))
|
||||
(cond ((eq (cdr hlcfg0) 'children)
|
||||
(org-show-children)
|
||||
(if (fboundp 'org-fold-show-children)
|
||||
(org-fold-show-children)
|
||||
(with-no-warnings (org-show-children)))
|
||||
(message "CHILDREN")
|
||||
(overlay-put ov 'status 'children))
|
||||
((eq (cdr hlcfg0) 'branches)
|
||||
(show-branches)
|
||||
(outline-show-branches)
|
||||
(message "BRANCHES")
|
||||
(overlay-put ov 'status 'branches))))))
|
||||
(goto-char pos)
|
||||
@@ -457,30 +467,25 @@ current table of contents to it."
|
||||
(defun org-toc-get-headlines-status ()
|
||||
"Return an alist of headlines and their associated folding
|
||||
status."
|
||||
(let (output ovs)
|
||||
(let (output)
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(while (and (not (eobp))
|
||||
(goto-char (next-overlay-change (point))))
|
||||
(when (looking-at org-outline-regexp-bol)
|
||||
(add-to-list
|
||||
'output
|
||||
(cl-pushnew
|
||||
(cons (buffer-substring-no-properties
|
||||
(match-beginning 0)
|
||||
(save-excursion
|
||||
(end-of-line) (point)))
|
||||
(overlay-get
|
||||
(car (overlays-at (point))) 'status))))))
|
||||
(car (overlays-at (point))) 'status))
|
||||
output))))
|
||||
;; return an alist like (("* Headline" . 'status))
|
||||
output))
|
||||
|
||||
;; In Org TOC buffer, hide headlines below the first level.
|
||||
(defun org-toc-help ()
|
||||
"Display a quick help message in the echo-area for `org-toc-mode'."
|
||||
(interactive)
|
||||
(let ((st-start 0)
|
||||
(help-message
|
||||
"\[space\] show heading \[1-4\] hide headlines below this level
|
||||
(defvar org-toc--help-message
|
||||
"\[space\] show heading \[1-4\] hide headlines below this level
|
||||
\[TAB\] jump to heading \[F\] toggle follow mode (currently %s)
|
||||
\[return\] jump and delete others windows \[i\] toggle info mode (currently %s)
|
||||
\[S-TAB\] cycle subtree (in Org) \[S\] toggle show subtree mode (currently %s)
|
||||
@@ -488,17 +493,25 @@ status."
|
||||
\[:\] cycle subtree (in TOC) \[c\] toggle column view (currently %s)
|
||||
\[n/p\] next/previous heading \[s\] save TOC configuration
|
||||
\[f/b\] next/previous heading of same level
|
||||
\[q\] quit the TOC \[g\] restore last TOC configuration"))
|
||||
(while (string-match "\\[[^]]+\\]" help-message st-start)
|
||||
(add-text-properties (match-beginning 0)
|
||||
(match-end 0) '(face bold) help-message)
|
||||
(setq st-start (match-end 0)))
|
||||
(message help-message
|
||||
(if org-toc-follow-mode "on" "off")
|
||||
(if org-toc-info-mode "on" "off")
|
||||
(if org-toc-show-subtree-mode "on" "off")
|
||||
(if org-toc-recenter-mode (format "on, line %s" org-toc-recenter) "off")
|
||||
(if org-toc-columns-shown "on" "off"))))
|
||||
\[q\] quit the TOC \[g\] restore last TOC configuration"
|
||||
"Help message used by `org-toc-help'.")
|
||||
|
||||
(let ((st-start 0))
|
||||
(while (string-match "\\[[^]]+\\]" org-toc--help-message st-start)
|
||||
(add-text-properties (match-beginning 0)
|
||||
(match-end 0) '(face bold) org-toc--help-message)
|
||||
(setq st-start (match-end 0))))
|
||||
|
||||
;; In Org TOC buffer, hide headlines below the first level.
|
||||
(defun org-toc-help ()
|
||||
"Display a quick help message in the echo-area for `org-toc-mode'."
|
||||
(interactive)
|
||||
(message org-toc--help-message
|
||||
(if org-toc-follow-mode "on" "off")
|
||||
(if org-toc-info-mode "on" "off")
|
||||
(if org-toc-show-subtree-mode "on" "off")
|
||||
(if org-toc-recenter-mode (format "on, line %s" org-toc-recenter) "off")
|
||||
(if org-toc-columns-shown "on" "off")))
|
||||
|
||||
|
||||
;;;;##########################################################################
|
||||
|
||||
Reference in New Issue
Block a user