+ (save-excursion
+ (outline-goto-prefix)
+ (outline-flag-region (if (not (bobp)) (1- (point)) (point))
+ (progn (outline-pre-next-preface)
+ (if (= ?\r (following-char))
+ (point)
+ (1- (point))))
+ ?\r)))
+;;;_ > outline-show-current-subtree (&optional arg)
+(defun outline-show-current-subtree (&optional arg)
+ "Show everything within the current topic. With a repeat-count,
+expose this topic and its siblings."
+ (interactive "P")
+ (save-excursion
+ (if (<= (outline-current-depth) 0)
+ ;; Outside any topics - try to get to the first:
+ (if (not (outline-next-heading))
+ (error "No topics.")
+ ;; got to first, outermost topic - set to expose it and siblings:
+ (message "Above outermost topic - exposing all.")
+ (outline-flag-region (point-min)(point-max) ?\n))
+ (if (not arg)
+ (outline-flag-current-subtree ?\n)
+ (outline-beginning-of-level)
+ (outline-expose-topic '(* :))))))
+;;;_ > outline-hide-current-subtree (&optional just-close)
+(defun outline-hide-current-subtree (&optional just-close)
+ "Close the current topic, or containing topic if this one is already closed.
+
+If this topic is closed and it's a top level topic, close this topic
+and its siblings.
+
+If optional arg JUST-CLOSE is non-nil, do not treat the parent or
+siblings, even if the target topic is already closed."
+
+ (interactive)
+ (let ((from (point))
+ (orig-eol (progn (end-of-line)
+ (if (not (outline-goto-prefix))
+ (error "No topics found.")
+ (end-of-line)(point)))))
+ (outline-flag-current-subtree ?\^M)
+ (goto-char from)
+ (if (and (= orig-eol (progn (goto-char orig-eol)
+ (end-of-line)
+ (point)))
+ (not just-close)
+ ;; Structure didn't change - try hiding current level:
+ (goto-char from)
+ (if (outline-up-current-level 1 t)
+ t
+ (goto-char 0)
+ (let ((msg
+ "Top-level topic already closed - closing siblings..."))
+ (message msg)
+ (outline-expose-topic '(0 :))
+ (message (concat msg " Done.")))
+ nil)
+ (/= (outline-recent-depth) 0))
+ (outline-hide-current-subtree))
+ (goto-char from)))
+;;;_ > outline-show-current-branches ()
+(defun outline-show-current-branches ()
+ "Show all subheadings of this heading, but not their bodies."
+ (interactive)
+ (beginning-of-line)
+ (outline-show-children t))
+;;;_ > outline-hide-current-leaves ()
+(defun outline-hide-current-leaves ()
+ "Hide the bodies of the current topic and all its offspring."
+ (interactive)
+ (outline-back-to-current-heading)
+ (outline-hide-region-body (point) (progn (outline-end-of-current-subtree)
+ (point))))
+
+;;;_ - Region and beyond
+;;;_ > outline-show-all ()
+(defun outline-show-all ()
+ "Show all of the text in the buffer."
+ (interactive)
+ (message "Exposing entire buffer...")
+ (outline-flag-region (point-min) (point-max) ?\n)
+ (message "Exposing entire buffer... Done."))
+;;;_ > outline-hide-bodies ()
+(defun outline-hide-bodies ()
+ "Hide all of buffer except headings."
+ (interactive)
+ (outline-hide-region-body (point-min) (point-max)))
+;;;_ > outline-hide-region-body (start end)
+(defun outline-hide-region-body (start end)
+ "Hide all body lines in the region, but not headings."
+ (save-excursion
+ (save-restriction
+ (narrow-to-region start end)
+ (goto-char (point-min))
+ (while (not (eobp))
+ (outline-flag-region (point)
+ (progn (outline-pre-next-preface) (point)) ?\^M)
+ (if (not (eobp))
+ (forward-char
+ (if (looking-at "[\n\r][\n\r]")
+ 2 1)))))))
+
+;;;_ > outline-expose-topic (spec)
+(defun outline-expose-topic (spec)
+ "Apply exposure specs to successive outline topic items.
+
+Use the more convenient frontend, `outline-new-exposure', if you don't
+need evaluation of the arguments, or even better, the `outline-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:
+\(outline-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.
+\(outline-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.
+\(outline-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 (outline-depth))
+ (max-pos 0)
+ prev-elem curr-elem
+ stay done
+ snug-back
+ )
+ (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 '*) (outline-show-current-subtree)
+ (if (> outline-recent-end-of-subtree max-pos)
+ (setq max-pos outline-recent-end-of-subtree)))
+ ((eq curr-elem '+) (outline-show-current-branches)
+ (if (> outline-recent-end-of-subtree max-pos)
+ (setq max-pos outline-recent-end-of-subtree)))
+ ((eq curr-elem '-) (outline-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 (outline-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) (outline-visible-p))
+ (save-excursion (outline-hide-current-subtree t)
+ (if (> 0 curr-elem)
+ nil
+ (if (> outline-recent-end-of-subtree max-pos)
+ (setq max-pos
+ outline-recent-end-of-subtree)))))
+ (if (> (abs curr-elem) 0)
+ (progn (outline-show-children (abs curr-elem))
+ (if (> outline-recent-end-of-subtree max-pos)
+ (setq max-pos outline-recent-end-of-subtree)))))
+ ((listp curr-elem)
+ (if (outline-descend-to-depth (1+ depth))
+ (let ((got (outline-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))
+ (outline-next-heading)))
+ ((outline-next-sibling depth))))
+ max-pos)))
+;;;_ > outline-old-expose-topic (spec &rest followers)
+(defun outline-old-expose-topic (spec &rest followers)
+
+ "Deprecated. Use outline-expose-topic \(with different schema
+format\) instead.
+
+Dictate wholesale exposure scheme for current topic, according to SPEC.
+
+SPEC is either a number or a list. Optional successive args
+dictate exposure for subsequent siblings of current topic.
+
+A simple spec (either a number, a special symbol, or the null list)
+dictates the overall exposure for a topic. Non null lists are
+composite specs whose first element dictates the overall exposure for
+a topic, with the subsequent elements in the list interpreted as specs
+that dictate the exposure for the successive offspring of the topic.
+
+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 close before opening to the
+ absolute value of the number.
+ - positive numbers just open to the relative depth indicated by the number.
+ - 0 just closes
+ - `*' completely opens the topic, including bodies.
+ - `+' shows all the sub headers, but not the bodies
+ - `-' exposes the body and immediate offspring of the corresponding topic.
+
+If the spec is a list, the first element must be a number, which
+dictates the exposure depth of the topic as a whole. Subsequent
+elements of the list are nested SPECs, dictating the specific exposure
+for the corresponding offspring of the topic.
+
+Optional FOLLOWER arguments dictate exposure for succeeding siblings."
+
+ (interactive "xExposure spec: ")
+ (let ((depth (outline-current-depth))
+ done
+ max-pos)
+ (cond ((null spec) nil)
+ ((symbolp spec)
+ (if (eq spec '*) (outline-show-current-subtree))
+ (if (eq spec '+) (outline-show-current-branches))
+ (if (eq spec '-) (outline-show-current-entry)))
+ ((numberp spec)
+ (if (>= 0 spec)
+ (save-excursion (outline-hide-current-subtree t)
+ (end-of-line)
+ (if (or (not max-pos)
+ (> (point) max-pos))
+ (setq max-pos (point)))
+ (if (> 0 spec)
+ (setq spec (* -1 spec)))))
+ (if (> spec 0)
+ (outline-show-children spec)))
+ ((listp spec)
+ ;(let ((got (outline-old-expose-topic (car spec))))
+ ; (if (and got (or (not max-pos) (> got max-pos)))
+ ; (setq max-pos got)))
+ (let ((new-depth (+ (outline-current-depth) 1))
+ got)
+ (setq max-pos (outline-old-expose-topic (car spec)))
+ (setq spec (cdr spec))
+ (if (and spec
+ (outline-descend-to-depth new-depth)
+ (not (outline-hidden-p)))
+ (progn (setq got (apply 'outline-old-expose-topic spec))
+ (if (and got (or (not max-pos) (> got max-pos)))
+ (setq max-pos got)))))))
+ (while (and followers
+ (progn (if (and max-pos (< (point) max-pos))
+ (progn (goto-char max-pos)
+ (setq max-pos nil)))
+ (end-of-line)
+ (outline-next-sibling depth)))
+ (outline-old-expose-topic (car followers))
+ (setq followers (cdr followers)))
+ max-pos))
+;;;_ > outline-new-exposure '()
+(defmacro outline-new-exposure (&rest spec)
+ "Literal frontend for `outline-expose-topic', doesn't evaluate arguments.
+Some arguments that would need to be quoted in outline-expose-topic
+need not be quoted in outline-new-exposure.
+
+Cursor is left at start position.
+
+Use this instead of obsolete `outline-exposure'.
+
+Examples:
+\(outline-exposure (-1 () () () 1) 0)
+ Close current topic at current level so only the immediate
+ subtopics are shown, except also show the children of the
+ third subtopic; and close the next topic at the current level.
+\(outline-exposure : -1 0)
+ Close all topics at current level to expose only their
+ immediate children, except for the last topic at the current
+ level, in which even its immediate children are hidden.
+\(outline-exposure -2 : -1 *)
+ Expose children and grandchildren of first topic at current
+ level, and expose children of subsequent topics at current
+ level *except* for the last, which should be opened completely."
+ (list 'save-excursion
+ '(if (not (or (outline-goto-prefix)
+ (outline-next-heading)))
+ (error "outline-new-exposure: Can't find any outline topics."))
+ (list 'outline-expose-topic (list 'quote spec))))
+;;;_ > outline-exposure '()
+(defmacro outline-exposure (&rest spec)
+ "Being deprecated - use more recent `outline-new-exposure' instead.
+
+Literal frontend for `outline-old-expose-topic', doesn't evaluate arguments
+and retains start position."
+ (list 'save-excursion
+ '(if (not (or (outline-goto-prefix)
+ (outline-next-heading)))
+ (error "Can't find any outline topics."))
+ (cons 'outline-old-expose-topic
+ (mapcar '(lambda (x) (list 'quote x)) spec))))
+
+;;;_ #7 ISearch with Dynamic Exposure
+;;;_ = outline-search-reconceal
+(defvar outline-search-reconceal nil
+ "Track whether current search match was concealed outside of search.
+
+The value is the location of the match, if it was concealed, regular
+if the entire topic was concealed, in a list if the entry was concealed.")
+;;;_ = outline-search-quitting
+(defconst outline-search-quitting nil
+ "Distinguishes isearch conclusion and cancellation.
+
+Used by isearch-terminate/outline-provisions and
+isearch-done/outline-provisions")
+
+
+;;;_ > outline-enwrap-isearch ()
+(defun outline-enwrap-isearch ()
+ "Impose outline-mode isearch-mode wrappers for dynamic exposure in isearch.
+
+Isearch progressively exposes and reconceals hidden topics when
+working in outline mode, but works normally elsewhere.
+
+The function checks to ensure that the rebindings are done only once."
+
+ ; Should isearch-mode be employed,
+ (if (or (not outline-enwrap-isearch-mode)
+ ; or are preparations already done?
+ (fboundp 'real-isearch-terminate))
+
+ ;; ... no - skip this all:
+ nil
+
+ ;; ... yes:
+
+ ; Ensure load of isearch-mode:
+ (if (or (and (fboundp 'isearch-mode)
+ (fboundp 'isearch-quote-char))
+ (condition-case error
+ (load-library outline-enwrap-isearch-mode)
+ (file-error (message "Skipping isearch-mode provisions - %s '%s'"
+ (car (cdr error))
+ (car (cdr (cdr error))))
+ (sit-for 1)
+ ;; Inhibit subsequent tries and return nil:
+ (setq outline-enwrap-isearch-mode nil))))
+ ;; Isearch-mode loaded, encapsulate specific entry points for
+ ;; outline dynamic-exposure business:
+ (progn
+
+ ;; stash crucial isearch-mode funcs under known, private
+ ;; names, then register wrapper functions under the old
+ ;; names, in their stead: `isearch-quit' is pre isearch v 1.2.
+ (fset 'real-isearch-terminate
+ ; `isearch-quit' is pre v 1.2:
+ (or (if (fboundp 'isearch-quit)
+ (symbol-function 'isearch-quit))
+ (if (fboundp 'isearch-abort)
+ ; `isearch-abort' is v 1.2 and on:
+ (symbol-function 'isearch-abort))))
+ (fset 'isearch-quit 'isearch-terminate/outline-provisions)
+ (fset 'isearch-abort 'isearch-terminate/outline-provisions)
+ (fset 'real-isearch-done (symbol-function 'isearch-done))
+ (fset 'isearch-done 'isearch-done/outline-provisions)
+ (fset 'real-isearch-update (symbol-function 'isearch-update))
+ (fset 'isearch-update 'isearch-update/outline-provisions)
+ (make-variable-buffer-local 'outline-search-reconceal)))))
+;;;_ > outline-isearch-arrival-business ()
+(defun outline-isearch-arrival-business ()
+ "Do outline business like exposing current point, if necessary.
+
+Registers reconcealment requirements in outline-search-reconceal
+accordingly.
+
+Set outline-search-reconceal to nil if current point is not
+concealed, to value of point if entire topic is concealed, and a
+list containing point if only the topic body is concealed.
+
+This will be used to determine whether outline-hide-current-entry
+or outline-hide-current-entry-completely will be necessary to
+restore the prior concealment state."
+
+ (if (outline-mode-p)
+ (setq outline-search-reconceal
+ (if (outline-hidden-p)
+ (save-excursion
+ (if (re-search-backward outline-line-boundary-regexp nil 1)
+ ;; Nil value means we got to b-o-b - wouldn't need
+ ;; to advance.
+ (forward-char 1))
+ ; We'll return point or list
+ ; containing point, depending
+ ; on concealment state of
+ ; topic prefix.
+ (prog1 (if (outline-hidden-p) (point) (list (point)))
+ ; And reveal the current
+ ; search target:
+ (outline-show-entry)))))))
+;;;_ > outline-isearch-advancing-business ()
+(defun outline-isearch-advancing-business ()
+ "Do outline business like deexposing current point, if necessary.
+
+Works according to reconceal state registration."
+ (if (and (outline-mode-p) outline-search-reconceal)
+ (save-excursion
+ (if (listp outline-search-reconceal)
+ ;; Leave the topic visible:
+ (progn (goto-char (car outline-search-reconceal))
+ (outline-hide-current-entry))
+ ;; Rehide the entire topic:
+ (goto-char outline-search-reconceal)
+ (outline-hide-current-entry-completely)))))
+;;;_ > isearch-terminate/outline-provisions ()
+(defun isearch-terminate/outline-provisions ()
+ (interactive)
+ (if (and (outline-mode-p) outline-enwrap-isearch-mode)
+ (outline-isearch-advancing-business))
+ (let ((outline-search-quitting t)
+ (outline-search-reconceal nil))
+ (real-isearch-terminate)))
+;;;_ > isearch-done/outline-provisions ()
+(defun isearch-done/outline-provisions (&optional nopush edit)
+ (interactive)
+ (if (and (outline-mode-p) outline-enwrap-isearch-mode)
+ (progn (if (and outline-search-reconceal
+ (not (listp outline-search-reconceal)))
+ ;; The topic was concealed - reveal it, its siblings,
+ ;; and any ancestors that are still concealed:
+ (save-excursion
+ (message "(exposing destination)")(sit-for 0)
+ (outline-goto-prefix)
+ ; There may be a closed blank
+ ; line between prior and
+ ; current topic that would be
+ ; missed - provide for it:
+ (if (not (bobp))
+ (progn (forward-char -1) ; newline
+ (if (eq ?\r (preceding-char))
+ (outline-flag-region (1- (point))
+ (point)
+ ?\n))
+ (forward-char 1)))
+ ; Goto parent
+ (outline-ascend-to-depth (1- (outline-recent-depth)))
+ (outline-show-children)))
+ (if (and (boundp 'outline-search-quitting)
+ outline-search-quitting)
+ nil
+ ; We're concluding abort:
+ (outline-isearch-arrival-business)
+ (outline-show-children))))
+ (if nopush
+ ;; isearch-done in newer version of isearch mode takes arg:
+ (real-isearch-done nopush)
+ (real-isearch-done)))
+;;;_ > isearch-update/outline-provisions ()
+(defun isearch-update/outline-provisions ()
+ "Wrapper dynamically adjusts isearch target exposure.
+
+Appropriately exposes and reconceals hidden outline portions, as
+necessary, in the course of searching."
+ (if (not (and (outline-mode-p) outline-enwrap-isearch-mode))
+ ;; Just do the plain business:
+ (real-isearch-update)
+
+ ;; Ah - provide for outline conditions:
+ (outline-isearch-advancing-business)
+ (real-isearch-update)
+ (cond (isearch-success (outline-isearch-arrival-business))
+ ((not isearch-success) (outline-isearch-advancing-business)))))
+
+;;;_ #8 Copying and printing
+
+;;;_ - Copy exposed
+;;;_ > outline-insert-listified (depth prefix bullet text)
+(defun outline-insert-listified (depth prefix bullet text)
+ "Insert contents of listified outline portion in current buffer."
+ (insert-string (concat (if (> depth 1) prefix "")
+ (make-string (1- depth) ?\ )
+ bullet))
+ (while text
+ (insert-string (car text))
+ (if (setq text (cdr text))
+ (insert-string "\n")))
+ (insert-string "\n"))
+;;;_ > outline-copy-exposed (arg &optional tobuf)
+(defun outline-copy-exposed (arg &optional tobuf)
+ "Duplicate exposed portions of current topic to another buffer.
+
+Other buffer has current buffers' name with \" exposed\" appended to it.
+
+With repeat count, copy the exposed portions of entire buffer."
+
+ (interactive "P")
+ (if (not tobuf)
+ (setq tobuf (get-buffer-create (concat "*" (buffer-name) " exposed*"))))
+ (let* ((start-pt (point))
+ (beg (if arg (point-min) (outline-back-to-current-heading)))
+ (end (if arg (point-max) (outline-end-of-current-subtree)))
+ (buf (current-buffer)))
+ (save-excursion (set-buffer tobuf)(erase-buffer))
+ (outline-process-exposed 'outline-insert-listified
+ beg
+ end
+ (current-buffer)
+ tobuf)
+ (goto-char (point-min))
+ (pop-to-buffer buf)
+ (goto-char start-pt)))
+
+;;;_ - LaTeX formatting
+;;;_ > outline-latex-verb-quote (str &optional flow)
+(defun outline-latex-verb-quote (str &optional flow)
+ "Return copy of STRING for literal reproduction across latex processing.
+Expresses the original characters \(including carriage returns) of the
+string across latex processing."
+ (mapconcat '(lambda (char)
+ ;;;mess: (cond ((memq char '(?"" ?$ ?% ?# ?& ?- ?" ?` ?^ ?- ?*));;;"))))
+ (cond ((memq char '(?\\ ?$ ?% ?# ?& ?{ ?} ?_ ?^ ?- ?*))
+ (concat "\\char" (number-to-string char) "{}"))
+ ((= char ?\n) "\\\\")
+ (t (char-to-string char))))
+ str
+ ""))
+;;;_ > outline-latex-verbatim-quote-curr-line ()
+(defun outline-latex-verbatim-quote-curr-line ()
+ "Express line for exact \(literal\) representation across latex processing.
+
+Adjust line contents so it is unaltered \(from the original line)
+across latex processing, within the context of a `verbatim'
+environment. Leaves point at the end of the line."
+ (beginning-of-line)
+ (let ((beg (point))
+ (end (progn (end-of-line)(point))))
+ (goto-char beg)
+ (while (re-search-forward "\\\\"
+ ;;"\\\\\\|\\{\\|\\}\\|\\_\\|\\$\\|\\\"\\|\\&\\|\\^\\|\\-\\|\\*\\|#"
+ end ; bounded by end-of-line
+ 1) ; no matches, move to end & return nil
+ (goto-char (match-beginning 0))
+ (insert-string "\\")
+ (setq end (1+ end))
+ (goto-char (1+ (match-end 0))))))
+;;;_ > outline-insert-latex-header (buf)
+(defun outline-insert-latex-header (buf)
+ "Insert initial latex commands at point in BUFFER."
+ ;; Much of this is being derived from the stuff in appendix of E in
+ ;; the TeXBook, pg 421.
+ (set-buffer buf)
+ (let ((doc-style (format "\n\\documentstyle{%s}\n"
+ "report"))
+ (page-numbering (if outline-number-pages
+ "\\pagestyle{empty}\n"
+ ""))
+ (linesdef (concat "\\def\\beginlines{"
+ "\\par\\begingroup\\nobreak\\medskip"
+ "\\parindent=0pt\n"
+ " \\kern1pt\\nobreak \\obeylines \\obeyspaces "
+ "\\everypar{\\strut}}\n"
+ "\\def\\endlines{"
+ "\\kern1pt\\endgroup\\medbreak\\noindent}\n"))
+ (titlecmd (format "\\newcommand{\\titlecmd}[1]{{%s #1}}\n"
+ outline-title-style))
+ (labelcmd (format "\\newcommand{\\labelcmd}[1]{{%s #1}}\n"
+ outline-label-style))
+ (headlinecmd (format "\\newcommand{\\headlinecmd}[1]{{%s #1}}\n"
+ outline-head-line-style))
+ (bodylinecmd (format "\\newcommand{\\bodylinecmd}[1]{{%s #1}}\n"
+ outline-body-line-style))
+ (setlength (format "%s%s%s%s"
+ "\\newlength{\\stepsize}\n"
+ "\\setlength{\\stepsize}{"
+ outline-indent
+ "}\n"))
+ (oneheadline (format "%s%s%s%s%s%s%s"
+ "\\newcommand{\\OneHeadLine}[3]{%\n"
+ "\\noindent%\n"
+ "\\hspace*{#2\\stepsize}%\n"
+ "\\labelcmd{#1}\\hspace*{.2cm}"
+ "\\headlinecmd{#3}\\\\["
+ outline-line-skip
+ "]\n}\n"))
+ (onebodyline (format "%s%s%s%s%s%s"
+ "\\newcommand{\\OneBodyLine}[2]{%\n"
+ "\\noindent%\n"
+ "\\hspace*{#1\\stepsize}%\n"
+ "\\bodylinecmd{#2}\\\\["
+ outline-line-skip
+ "]\n}\n"))
+ (begindoc "\\begin{document}\n\\begin{center}\n")
+ (title (format "%s%s%s%s"
+ "\\titlecmd{"
+ (outline-latex-verb-quote (if outline-title
+ (condition-case err
+ (eval outline-title)
+ (error "<unnamed buffer>"))
+ "Unnamed Outline"))
+ "}\n"
+ "\\end{center}\n\n"))
+ (hsize "\\hsize = 7.5 true in\n")
+ (hoffset "\\hoffset = -1.5 true in\n")
+ (vspace "\\vspace{.1cm}\n\n"))
+ (insert (concat doc-style
+ page-numbering
+ titlecmd
+ labelcmd
+ headlinecmd
+ bodylinecmd
+ setlength
+ oneheadline
+ onebodyline
+ begindoc
+ title
+ hsize
+ hoffset
+ vspace)
+ )))
+;;;_ > outline-insert-latex-trailer (buf)
+(defun outline-insert-latex-trailer (buf)
+ "Insert concluding latex commands at point in BUFFER."
+ (set-buffer buf)
+ (insert "\n\\end{document}\n"))
+;;;_ > outline-latexify-one-item (depth prefix bullet text)
+(defun outline-latexify-one-item (depth prefix bullet text)
+ "Insert LaTeX commands for formatting one outline item.
+
+Args are the topics' numeric DEPTH, the header PREFIX lead string, the
+BULLET string, and a list of TEXT strings for the body."
+ (let* ((head-line (if text (car text)))
+ (body-lines (cdr text))
+ (curr-line)
+ body-content bop)
+ ; Do the head line:
+ (insert-string (concat "\\OneHeadLine{\\verb\1 "
+ (outline-latex-verb-quote bullet)
+ "\1}{"
+ depth
+ "}{\\verb\1 "
+ (if head-line
+ (outline-latex-verb-quote head-line)
+ "")
+ "\1}\n"))
+ (if (not body-lines)
+ nil
+ ;;(insert-string "\\beginlines\n")
+ (insert-string "\\begin{verbatim}\n")
+ (while body-lines
+ (setq curr-line (car body-lines))
+ (if (and (not body-content)
+ (not (string-match "^\\s-*$" curr-line)))
+ (setq body-content t))
+ ; Mangle any occurrences of
+ ; "\end{verbatim}" in text,
+ ; it's special:
+ (if (and body-content
+ (setq bop (string-match "\\end{verbatim}" curr-line)))
+ (setq curr-line (concat (substring curr-line 0 bop)
+ ">"
+ (substring curr-line bop))))
+ ;;(insert-string "|" (car body-lines) "|")
+ (insert-string curr-line)
+ (outline-latex-verbatim-quote-curr-line)
+ (insert-string "\n")
+ (setq body-lines (cdr body-lines)))
+ (if body-content
+ (setq body-content nil)
+ (forward-char -1)
+ (insert-string "\\ ")
+ (forward-char 1))
+ ;;(insert-string "\\endlines\n")
+ (insert-string "\\end{verbatim}\n")
+ )))
+;;;_ > outline-latexify-exposed (arg &optional tobuf)
+(defun outline-latexify-exposed (arg &optional tobuf)
+ "Format current topic's exposed portions to TOBUF for latex processing.
+TOBUF defaults to a buffer named the same as the current buffer, but
+with \"*\" prepended and \" latex-formed*\" appended.
+
+With repeat count, copy the exposed portions of entire buffer."
+
+ (interactive "P")
+ (if (not tobuf)
+ (setq tobuf
+ (get-buffer-create (concat "*" (buffer-name) " latexified*"))))
+ (let* ((start-pt (point))
+ (beg (if arg (point-min) (outline-back-to-current-heading)))
+ (end (if arg (point-max) (outline-end-of-current-subtree)))
+ (buf (current-buffer)))
+ (set-buffer tobuf)