Function: allout-expose-topic
allout-expose-topic is an interactive and byte-compiled function
defined in allout.el.gz.
Signature
(allout-expose-topic SPEC)
Documentation
Apply exposure specs to successive outline topic items.
Use the more convenient frontend, allout-new-exposure, if you don't
need evaluation of the arguments, or even better, the allout-layout
variable-keyed mode-activation/auto-exposure feature of allout outline
mode. See the respective documentation strings for more details.
Cursor is left at start position.
SPEC is either a number or a list.
Successive specs on a list are applied to successive sibling topics.
A simple spec (either a number, one of a few symbols, or the null list) dictates the exposure for the corresponding topic.
Non-null lists recursively designate exposure specs for respective subtopics of the current topic.
The : repeat spec is used to specify exposure for any number of
successive siblings, up to the trailing ones for which there are
explicit specs following the :.
Simple (numeric and null-list) specs are interpreted as follows:
Numbers indicate the relative depth to open the corresponding topic.
- negative numbers force the topic to be closed before opening to the
absolute value of the number, so all siblings are open only to
that level.
- positive numbers open to the relative depth indicated by the
number, but do not force already opened subtopics to be closed.
- 0 means to close topic -- hide all offspring.
: - repeat
apply prior element to all siblings at current level, *up to*
those siblings that would be covered by specs following the :
on the list. Ie, apply to all topics at level but the last
ones. (Only first of multiple colons at same level is
respected -- subsequent ones are discarded.)
* - completely opens the topic, including bodies.
+ - shows all the sub headers, but not the bodies
- - exposes the body of the corresponding topic.
Examples:
(allout-expose-topic '(-1 : 0))
Close this and all following topics at current level, exposing
only their immediate children, but close down the last topic
at this current level completely.
(allout-expose-topic '(-1 () : 1 0))
Close current topic so only the immediate subtopics are shown;
show the children in the second to last topic, and completely
close the last one.
(allout-expose-topic '(-2 : -1 *))
Expose children and grandchildren of all topics at current
level except the last two; expose children of the second to
last and completely open the last one.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/allout.el.gz
;;;_ > allout-expose-topic (spec)
(defun allout-expose-topic (spec)
"Apply exposure specs to successive outline topic items.
Use the more convenient frontend, `allout-new-exposure', if you don't
need evaluation of the arguments, or even better, the `allout-layout'
variable-keyed mode-activation/auto-exposure feature of allout outline
mode. See the respective documentation strings for more details.
Cursor is left at start position.
SPEC is either a number or a list.
Successive specs on a list are applied to successive sibling topics.
A simple spec (either a number, one of a few symbols, or the null
list) dictates the exposure for the corresponding topic.
Non-null lists recursively designate exposure specs for respective
subtopics of the current topic.
The `:' repeat spec is used to specify exposure for any number of
successive siblings, up to the trailing ones for which there are
explicit specs following the `:'.
Simple (numeric and null-list) specs are interpreted as follows:
Numbers indicate the relative depth to open the corresponding topic.
- negative numbers force the topic to be closed before opening to the
absolute value of the number, so all siblings are open only to
that level.
- positive numbers open to the relative depth indicated by the
number, but do not force already opened subtopics to be closed.
- 0 means to close topic -- hide all offspring.
: - `repeat'
apply prior element to all siblings at current level, *up to*
those siblings that would be covered by specs following the `:'
on the list. Ie, apply to all topics at level but the last
ones. (Only first of multiple colons at same level is
respected -- subsequent ones are discarded.)
* - completely opens the topic, including bodies.
+ - shows all the sub headers, but not the bodies
- - exposes the body of the corresponding topic.
Examples:
\(allout-expose-topic \\='(-1 : 0))
Close this and all following topics at current level, exposing
only their immediate children, but close down the last topic
at this current level completely.
\(allout-expose-topic \\='(-1 () : 1 0))
Close current topic so only the immediate subtopics are shown;
show the children in the second to last topic, and completely
close the last one.
\(allout-expose-topic \\='(-2 : -1 *))
Expose children and grandchildren of all topics at current
level except the last two; expose children of the second to
last and completely open the last one."
(interactive "xExposure spec: ")
(if (not (listp spec))
nil
(let ((depth (allout-depth))
(max-pos 0)
prev-elem curr-elem
stay)
(while spec
(setq prev-elem curr-elem
curr-elem (car spec)
spec (cdr spec))
(cond ; Do current element:
((null curr-elem) nil)
((symbolp curr-elem)
(cond ((eq curr-elem '*) (allout-show-current-subtree)
(if (> allout-recent-end-of-subtree max-pos)
(setq max-pos allout-recent-end-of-subtree)))
((eq curr-elem '+)
(if (not (allout-hidden-p))
(save-excursion (allout-hide-current-subtree t)))
(allout-show-current-branches)
(if (> allout-recent-end-of-subtree max-pos)
(setq max-pos allout-recent-end-of-subtree)))
((eq curr-elem '-) (allout-show-current-entry))
((eq curr-elem ':)
(setq stay t)
;; Expand the `repeat' spec to an explicit version,
;; w.r.t. remaining siblings:
(let ((residue ; = # of sibs not covered by remaining spec
;; Dang, could be nice to make use of the chart, sigh:
(- (length (allout-chart-siblings))
(length spec))))
(if (< 0 residue)
;; Some residue -- cover it with prev-elem:
(setq spec (append (make-list residue prev-elem)
spec)))))))
((numberp curr-elem)
(if (and (>= 0 curr-elem) (not (allout-hidden-p)))
(save-excursion (allout-hide-current-subtree t)
(if (> 0 curr-elem)
nil
(if (> allout-recent-end-of-subtree max-pos)
(setq max-pos
allout-recent-end-of-subtree)))))
(if (> (abs curr-elem) 0)
(progn (allout-show-children (abs curr-elem))
(if (> allout-recent-end-of-subtree max-pos)
(setq max-pos allout-recent-end-of-subtree)))))
((listp curr-elem)
(if (allout-descend-to-depth (1+ depth))
(let ((got (allout-expose-topic curr-elem)))
(if (and got (> got max-pos)) (setq max-pos got))))))
(cond (stay (setq stay nil))
((listp (car spec)) nil)
((> max-pos (point))
;; Capitalize on max-pos state to get us nearer next sibling:
(progn (goto-char (min (point-max) max-pos))
(allout-next-heading)))
((allout-next-sibling depth))))
max-pos)))