Function: allout-listify-exposed
allout-listify-exposed is an interactive and byte-compiled function
defined in allout.el.gz.
Signature
(allout-listify-exposed &optional START END FORMAT)
Documentation
Produce a list representing exposed topics in current region.
This list can then be used by allout-process-exposed to manipulate
the subject region.
Optional START and END indicate bounds of region.
Optional arg, FORMAT, designates an alternate presentation form for the prefix:
list -- Present prefix as numeric section.subsection..., starting with
section indicated by the list, innermost nesting first.
indent (symbol) -- Convert header prefixes to all white space,
except for distinctive bullets.
The elements of the list produced are lists that represents a topic header and body. The elements of that list are:
- a number representing the depth of the topic,
- a string representing the header-prefix, including trailing whitespace and
bullet.
- a string representing the bullet character,
- and a series of strings, each containing one line of the exposed
portion of the topic entry.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/allout.el.gz
;;;_ > allout-listify-exposed (&optional start end format)
(defun allout-listify-exposed (&optional start end format)
"Produce a list representing exposed topics in current region.
This list can then be used by `allout-process-exposed' to manipulate
the subject region.
Optional START and END indicate bounds of region.
Optional arg, FORMAT, designates an alternate presentation form for
the prefix:
list -- Present prefix as numeric section.subsection..., starting with
section indicated by the list, innermost nesting first.
`indent' (symbol) -- Convert header prefixes to all white space,
except for distinctive bullets.
The elements of the list produced are lists that represents a topic
header and body. The elements of that list are:
- a number representing the depth of the topic,
- a string representing the header-prefix, including trailing whitespace and
bullet.
- a string representing the bullet character,
- and a series of strings, each containing one line of the exposed
portion of the topic entry."
(interactive "r")
(save-excursion
(let*
((inhibit-field-text-motion t)
;; state vars:
strings prefix result depth new-depth out gone-out bullet beg
next done)
(goto-char start)
(beginning-of-line)
;; Goto initial topic, and register preceding stuff, if any:
(if (> (allout-goto-prefix-doublechecked) start)
;; First topic follows beginning point -- register preliminary stuff:
(setq result
(list (list 0 "" nil
(buffer-substring-no-properties start
(1- (point)))))))
(while (and (not done)
(not (eobp)) ; Loop until we've covered the region.
(not (> (point) end)))
(setq depth allout-recent-depth ; Current topics depth,
bullet (allout-recent-bullet) ; ... bullet,
prefix (allout-recent-prefix)
beg (progn (allout-end-of-prefix t) (point))) ; and beginning.
(setq done ; The boundary for the current topic:
(not (allout-next-visible-heading 1)))
(setq new-depth allout-recent-depth)
(setq gone-out out
out (< new-depth depth))
(beginning-of-line)
(setq next (point))
(goto-char beg)
(setq strings nil)
(while (> next (point)) ; Get all the exposed text in
(setq strings
(cons (buffer-substring-no-properties
beg
;To hidden text or end of line:
(progn
(end-of-line)
(allout-back-to-visible-text)))
strings))
(when (< (point) next) ; Resume from after hid text, if any.
(line-move 1)
(beginning-of-line))
(setq beg (point)))
;; Accumulate list for this topic:
(setq strings (nreverse strings))
(setq result
(cons
(if format
(let ((special (if (string-match
(regexp-quote bullet)
allout-distinctive-bullets-string)
bullet)))
(cond ((listp format)
(list depth
(if allout-flattened-numbering-abbreviation
(allout-stringify-flat-index format
gone-out)
(allout-stringify-flat-index-plain
format))
strings
special))
((eq format 'indent)
(if special
(list depth
(concat (make-string (1+ depth) ? )
(substring prefix -1))
strings)
(list depth
(make-string depth ? )
strings)))
(t (error "allout-listify-exposed: %s %s"
"invalid format" format))))
(list depth prefix strings))
result))
;; Reassess format, if any:
(if (and format (listp format))
(cond ((= new-depth depth)
(setq format (cons (1+ (car format))
(cdr format))))
((> new-depth depth) ; descending -- assume by 1:
(setq format (cons 1 format)))
(t
; Pop the residue:
(while (< new-depth depth)
(setq format (cdr format))
(setq depth (1- depth)))
; And increment the current one:
(setq format
(cons (1+ (or (car format)
-1))
(cdr format)))))))
;; Put the list with first at front, to last at back:
(nreverse result))))