outline.el 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126
  1. ;;; outline.el --- outline mode commands for Emacs
  2. ;; Copyright (C) 1986, 1993-1995, 1997, 2000-2012
  3. ;; Free Software Foundation, Inc.
  4. ;; Maintainer: FSF
  5. ;; Keywords: outlines
  6. ;; This file is part of GNU Emacs.
  7. ;; GNU Emacs is free software: you can redistribute it and/or modify
  8. ;; it under the terms of the GNU General Public License as published by
  9. ;; the Free Software Foundation, either version 3 of the License, or
  10. ;; (at your option) any later version.
  11. ;; GNU Emacs is distributed in the hope that it will be useful,
  12. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;; GNU General Public License for more details.
  15. ;; You should have received a copy of the GNU General Public License
  16. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  17. ;;; Commentary:
  18. ;; This package is a major mode for editing outline-format documents.
  19. ;; An outline can be `abstracted' to show headers at any given level,
  20. ;; with all stuff below hidden. See the Emacs manual for details.
  21. ;;; Todo:
  22. ;; - subtree-terminators
  23. ;; - better handle comments before function bodies (i.e. heading)
  24. ;; - don't bother hiding whitespace
  25. ;;; Code:
  26. (defvar font-lock-warning-face)
  27. (defgroup outlines nil
  28. "Support for hierarchical outlining."
  29. :prefix "outline-"
  30. :group 'wp)
  31. (defcustom outline-regexp "[*\^L]+"
  32. "Regular expression to match the beginning of a heading.
  33. Any line whose beginning matches this regexp is considered to start a heading.
  34. Note that Outline mode only checks this regexp at the start of a line,
  35. so the regexp need not (and usually does not) start with `^'.
  36. The recommended way to set this is with a Local Variables: list
  37. in the file it applies to. See also `outline-heading-end-regexp'."
  38. :type 'regexp
  39. :group 'outlines)
  40. ;;;###autoload(put 'outline-regexp 'safe-local-variable 'stringp)
  41. (defcustom outline-heading-end-regexp "\n"
  42. "Regular expression to match the end of a heading line.
  43. You can assume that point is at the beginning of a heading when this
  44. regexp is searched for. The heading ends at the end of the match.
  45. The recommended way to set this is with a `Local Variables:' list
  46. in the file it applies to."
  47. :type 'regexp
  48. :group 'outlines)
  49. ;;;###autoload(put 'outline-heading-end-regexp 'safe-local-variable 'stringp)
  50. (defvar outline-mode-prefix-map
  51. (let ((map (make-sparse-keymap)))
  52. (define-key map "@" 'outline-mark-subtree)
  53. (define-key map "\C-n" 'outline-next-visible-heading)
  54. (define-key map "\C-p" 'outline-previous-visible-heading)
  55. (define-key map "\C-i" 'show-children)
  56. (define-key map "\C-s" 'show-subtree)
  57. (define-key map "\C-d" 'hide-subtree)
  58. (define-key map "\C-u" 'outline-up-heading)
  59. (define-key map "\C-f" 'outline-forward-same-level)
  60. (define-key map "\C-b" 'outline-backward-same-level)
  61. (define-key map "\C-t" 'hide-body)
  62. (define-key map "\C-a" 'show-all)
  63. (define-key map "\C-c" 'hide-entry)
  64. (define-key map "\C-e" 'show-entry)
  65. (define-key map "\C-l" 'hide-leaves)
  66. (define-key map "\C-k" 'show-branches)
  67. (define-key map "\C-q" 'hide-sublevels)
  68. (define-key map "\C-o" 'hide-other)
  69. (define-key map "\C-^" 'outline-move-subtree-up)
  70. (define-key map "\C-v" 'outline-move-subtree-down)
  71. (define-key map [(control ?<)] 'outline-promote)
  72. (define-key map [(control ?>)] 'outline-demote)
  73. (define-key map "\C-m" 'outline-insert-heading)
  74. ;; Where to bind outline-cycle ?
  75. map))
  76. (defvar outline-mode-menu-bar-map
  77. (let ((map (make-sparse-keymap)))
  78. (define-key map [hide] (cons "Hide" (make-sparse-keymap "Hide")))
  79. (define-key map [hide hide-other]
  80. '(menu-item "Hide Other" hide-other
  81. :help "Hide everything except current body and parent and top-level headings"))
  82. (define-key map [hide hide-sublevels]
  83. '(menu-item "Hide Sublevels" hide-sublevels
  84. :help "Hide everything but the top LEVELS levels of headers, in whole buffer"))
  85. (define-key map [hide hide-subtree]
  86. '(menu-item "Hide Subtree" hide-subtree
  87. :help "Hide everything after this heading at deeper levels"))
  88. (define-key map [hide hide-entry]
  89. '(menu-item "Hide Entry" hide-entry
  90. :help "Hide the body directly following this heading"))
  91. (define-key map [hide hide-body]
  92. '(menu-item "Hide Body" hide-body
  93. :help "Hide all body lines in buffer, leaving all headings visible"))
  94. (define-key map [hide hide-leaves]
  95. '(menu-item "Hide Leaves" hide-leaves
  96. :help "Hide the body after this heading and at deeper levels"))
  97. (define-key map [show] (cons "Show" (make-sparse-keymap "Show")))
  98. (define-key map [show show-subtree]
  99. '(menu-item "Show Subtree" show-subtree
  100. :help "Show everything after this heading at deeper levels"))
  101. (define-key map [show show-children]
  102. '(menu-item "Show Children" show-children
  103. :help "Show all direct subheadings of this heading"))
  104. (define-key map [show show-branches]
  105. '(menu-item "Show Branches" show-branches
  106. :help "Show all subheadings of this heading, but not their bodies"))
  107. (define-key map [show show-entry]
  108. '(menu-item "Show Entry" show-entry
  109. :help "Show the body directly following this heading"))
  110. (define-key map [show show-all]
  111. '(menu-item "Show All" show-all
  112. :help "Show all of the text in the buffer"))
  113. (define-key map [headings]
  114. (cons "Headings" (make-sparse-keymap "Headings")))
  115. (define-key map [headings demote-subtree]
  116. '(menu-item "Demote Subtree" outline-demote
  117. :help "Demote headings lower down the tree"))
  118. (define-key map [headings promote-subtree]
  119. '(menu-item "Promote Subtree" outline-promote
  120. :help "Promote headings higher up the tree"))
  121. (define-key map [headings move-subtree-down]
  122. '(menu-item "Move Subtree Down" outline-move-subtree-down
  123. :help "Move the current subtree down past arg headlines of the same level"))
  124. (define-key map [headings move-subtree-up]
  125. '(menu-item "Move Subtree Up" outline-move-subtree-up
  126. :help "Move the current subtree up past arg headlines of the same level"))
  127. (define-key map [headings copy]
  128. '(menu-item "Copy to Kill Ring" outline-headers-as-kill
  129. :enable mark-active
  130. :help "Save the visible outline headers in region at the start of the kill ring"))
  131. (define-key map [headings outline-insert-heading]
  132. '(menu-item "New Heading" outline-insert-heading
  133. :help "Insert a new heading at same depth at point"))
  134. (define-key map [headings outline-backward-same-level]
  135. '(menu-item "Previous Same Level" outline-backward-same-level
  136. :help "Move backward to the arg'th subheading at same level as this one."))
  137. (define-key map [headings outline-forward-same-level]
  138. '(menu-item "Next Same Level" outline-forward-same-level
  139. :help "Move forward to the arg'th subheading at same level as this one"))
  140. (define-key map [headings outline-previous-visible-heading]
  141. '(menu-item "Previous" outline-previous-visible-heading
  142. :help "Move to the previous heading line"))
  143. (define-key map [headings outline-next-visible-heading]
  144. '(menu-item "Next" outline-next-visible-heading
  145. :help "Move to the next visible heading line"))
  146. (define-key map [headings outline-up-heading]
  147. '(menu-item "Up" outline-up-heading
  148. :help "Move to the visible heading line of which the present line is a subheading"))
  149. map))
  150. (defvar outline-minor-mode-menu-bar-map
  151. (let ((map (make-sparse-keymap)))
  152. (define-key map [outline]
  153. (cons "Outline"
  154. (nconc (make-sparse-keymap "Outline")
  155. ;; Remove extra separator
  156. (cdr
  157. ;; Flatten the major mode's menus into a single menu.
  158. (apply 'append
  159. (mapcar (lambda (x)
  160. (if (consp x)
  161. ;; Add a separator between each
  162. ;; part of the unified menu.
  163. (cons '(--- "---") (cdr x))))
  164. outline-mode-menu-bar-map))))))
  165. map))
  166. (defvar outline-mode-map
  167. (let ((map (make-sparse-keymap)))
  168. (define-key map "\C-c" outline-mode-prefix-map)
  169. (define-key map [menu-bar] outline-mode-menu-bar-map)
  170. map))
  171. (defvar outline-font-lock-keywords
  172. '(;;
  173. ;; Highlight headings according to the level.
  174. (eval . (list (concat "^\\(?:" outline-regexp "\\).+")
  175. 0 '(outline-font-lock-face) nil t)))
  176. "Additional expressions to highlight in Outline mode.")
  177. (defface outline-1
  178. '((t :inherit font-lock-function-name-face))
  179. "Level 1."
  180. :group 'outlines)
  181. (defface outline-2
  182. '((t :inherit font-lock-variable-name-face))
  183. "Level 2."
  184. :group 'outlines)
  185. (defface outline-3
  186. '((t :inherit font-lock-keyword-face))
  187. "Level 3."
  188. :group 'outlines)
  189. (defface outline-4
  190. '((t :inherit font-lock-comment-face))
  191. "Level 4."
  192. :group 'outlines)
  193. (defface outline-5
  194. '((t :inherit font-lock-type-face))
  195. "Level 5."
  196. :group 'outlines)
  197. (defface outline-6
  198. '((t :inherit font-lock-constant-face))
  199. "Level 6."
  200. :group 'outlines)
  201. (defface outline-7
  202. '((t :inherit font-lock-builtin-face))
  203. "Level 7."
  204. :group 'outlines)
  205. (defface outline-8
  206. '((t :inherit font-lock-string-face))
  207. "Level 8."
  208. :group 'outlines)
  209. (defvar outline-font-lock-faces
  210. [outline-1 outline-2 outline-3 outline-4
  211. outline-5 outline-6 outline-7 outline-8])
  212. ;; (defvar outline-font-lock-levels nil)
  213. ;; (make-variable-buffer-local 'outline-font-lock-levels)
  214. (defun outline-font-lock-face ()
  215. ;; (save-excursion
  216. ;; (outline-back-to-heading t)
  217. ;; (let* ((count 0)
  218. ;; (start-level (funcall outline-level))
  219. ;; (level start-level)
  220. ;; face-level)
  221. ;; (while (not (setq face-level
  222. ;; (if (or (bobp) (eq level 1)) 0
  223. ;; (cdr (assq level outline-font-lock-levels)))))
  224. ;; (outline-up-heading 1 t)
  225. ;; (setq count (1+ count))
  226. ;; (setq level (funcall outline-level)))
  227. ;; ;; Remember for later.
  228. ;; (unless (zerop count)
  229. ;; (setq face-level (+ face-level count))
  230. ;; (push (cons start-level face-level) outline-font-lock-levels))
  231. ;; (condition-case nil
  232. ;; (aref outline-font-lock-faces face-level)
  233. ;; (error font-lock-warning-face))))
  234. (save-excursion
  235. (goto-char (match-beginning 0))
  236. (looking-at outline-regexp)
  237. (aref outline-font-lock-faces (% (1- (funcall outline-level)) (length outline-font-lock-faces)))))
  238. (defvar outline-view-change-hook nil
  239. "Normal hook to be run after outline visibility changes.")
  240. (defvar outline-mode-hook nil
  241. "*This hook is run when outline mode starts.")
  242. (defvar outline-blank-line nil
  243. "*Non-nil means to leave unhidden blank line before heading.")
  244. ;;;###autoload
  245. (define-derived-mode outline-mode text-mode "Outline"
  246. "Set major mode for editing outlines with selective display.
  247. Headings are lines which start with asterisks: one for major headings,
  248. two for subheadings, etc. Lines not starting with asterisks are body lines.
  249. Body text or subheadings under a heading can be made temporarily
  250. invisible, or visible again. Invisible lines are attached to the end
  251. of the heading, so they move with it, if the line is killed and yanked
  252. back. A heading with text hidden under it is marked with an ellipsis (...).
  253. Commands:\\<outline-mode-map>
  254. \\[outline-next-visible-heading] outline-next-visible-heading move by visible headings
  255. \\[outline-previous-visible-heading] outline-previous-visible-heading
  256. \\[outline-forward-same-level] outline-forward-same-level similar but skip subheadings
  257. \\[outline-backward-same-level] outline-backward-same-level
  258. \\[outline-up-heading] outline-up-heading move from subheading to heading
  259. \\[hide-body] make all text invisible (not headings).
  260. \\[show-all] make everything in buffer visible.
  261. \\[hide-sublevels] make only the first N levels of headers visible.
  262. The remaining commands are used when point is on a heading line.
  263. They apply to some of the body or subheadings of that heading.
  264. \\[hide-subtree] hide-subtree make body and subheadings invisible.
  265. \\[show-subtree] show-subtree make body and subheadings visible.
  266. \\[show-children] show-children make direct subheadings visible.
  267. No effect on body, or subheadings 2 or more levels down.
  268. With arg N, affects subheadings N levels down.
  269. \\[hide-entry] make immediately following body invisible.
  270. \\[show-entry] make it visible.
  271. \\[hide-leaves] make body under heading and under its subheadings invisible.
  272. The subheadings remain visible.
  273. \\[show-branches] make all subheadings at all levels visible.
  274. The variable `outline-regexp' can be changed to control what is a heading.
  275. A line is a heading if `outline-regexp' matches something at the
  276. beginning of the line. The longer the match, the deeper the level.
  277. Turning on outline mode calls the value of `text-mode-hook' and then of
  278. `outline-mode-hook', if they are non-nil."
  279. (make-local-variable 'line-move-ignore-invisible)
  280. (setq line-move-ignore-invisible t)
  281. ;; Cause use of ellipses for invisible text.
  282. (add-to-invisibility-spec '(outline . t))
  283. (set (make-local-variable 'paragraph-start)
  284. (concat paragraph-start "\\|\\(?:" outline-regexp "\\)"))
  285. ;; Inhibit auto-filling of header lines.
  286. (set (make-local-variable 'auto-fill-inhibit-regexp) outline-regexp)
  287. (set (make-local-variable 'paragraph-separate)
  288. (concat paragraph-separate "\\|\\(?:" outline-regexp "\\)"))
  289. (set (make-local-variable 'font-lock-defaults)
  290. '(outline-font-lock-keywords t nil nil backward-paragraph))
  291. (setq imenu-generic-expression
  292. (list (list nil (concat "^\\(?:" outline-regexp "\\).*$") 0)))
  293. (add-hook 'change-major-mode-hook 'show-all nil t))
  294. (defcustom outline-minor-mode-prefix "\C-c@"
  295. "Prefix key to use for Outline commands in Outline minor mode.
  296. The value of this variable is checked as part of loading Outline mode.
  297. After that, changing the prefix key requires manipulating keymaps."
  298. :type 'string
  299. :group 'outlines)
  300. ;;;###autoload
  301. (define-minor-mode outline-minor-mode
  302. "Toggle Outline minor mode.
  303. With a prefix argument ARG, enable Outline minor mode if ARG is
  304. positive, and disable it otherwise. If called from Lisp, enable
  305. the mode if ARG is omitted or nil.
  306. See the command `outline-mode' for more information on this mode."
  307. nil " Outl" (list (cons [menu-bar] outline-minor-mode-menu-bar-map)
  308. (cons outline-minor-mode-prefix outline-mode-prefix-map))
  309. :group 'outlines
  310. (if outline-minor-mode
  311. (progn
  312. ;; Turn off this mode if we change major modes.
  313. (add-hook 'change-major-mode-hook
  314. (lambda () (outline-minor-mode -1))
  315. nil t)
  316. (set (make-local-variable 'line-move-ignore-invisible) t)
  317. ;; Cause use of ellipses for invisible text.
  318. (add-to-invisibility-spec '(outline . t)))
  319. (setq line-move-ignore-invisible nil)
  320. ;; Cause use of ellipses for invisible text.
  321. (remove-from-invisibility-spec '(outline . t))
  322. ;; When turning off outline mode, get rid of any outline hiding.
  323. (show-all)))
  324. (defvar outline-level 'outline-level
  325. "*Function of no args to compute a header's nesting level in an outline.
  326. It can assume point is at the beginning of a header line and that the match
  327. data reflects the `outline-regexp'.")
  328. ;;;###autoload(put 'outline-level 'risky-local-variable t)
  329. (defvar outline-heading-alist ()
  330. "Alist associating a heading for every possible level.
  331. Each entry is of the form (HEADING . LEVEL).
  332. This alist is used two ways: to find the heading corresponding to
  333. a given level and to find the level of a given heading.
  334. If a mode or document needs several sets of outline headings (for example
  335. numbered and unnumbered sections), list them set by set and sorted by level
  336. within each set. For example in texinfo mode:
  337. (setq outline-heading-alist
  338. '((\"@chapter\" . 2) (\"@section\" . 3) (\"@subsection\" . 4)
  339. (\"@subsubsection\" . 5)
  340. (\"@unnumbered\" . 2) (\"@unnumberedsec\" . 3)
  341. (\"@unnumberedsubsec\" . 4) (\"@unnumberedsubsubsec\" . 5)
  342. (\"@appendix\" . 2) (\"@appendixsec\" . 3)...
  343. (\"@appendixsubsec\" . 4) (\"@appendixsubsubsec\" . 5) ..))
  344. Instead of sorting the entries in each set, you can also separate the
  345. sets with nil.")
  346. (make-variable-buffer-local 'outline-heading-alist)
  347. ;; This used to count columns rather than characters, but that made ^L
  348. ;; appear to be at level 2 instead of 1. Columns would be better for
  349. ;; tab handling, but the default regexp doesn't use tabs, and anyone
  350. ;; who changes the regexp can also redefine the outline-level variable
  351. ;; as appropriate.
  352. (defun outline-level ()
  353. "Return the depth to which a statement is nested in the outline.
  354. Point must be at the beginning of a header line.
  355. This is actually either the level specified in `outline-heading-alist'
  356. or else the number of characters matched by `outline-regexp'."
  357. (or (cdr (assoc (match-string 0) outline-heading-alist))
  358. (- (match-end 0) (match-beginning 0))))
  359. (defun outline-next-preface ()
  360. "Skip forward to just before the next heading line.
  361. If there's no following heading line, stop before the newline
  362. at the end of the buffer."
  363. (if (re-search-forward (concat "\n\\(?:" outline-regexp "\\)")
  364. nil 'move)
  365. (goto-char (match-beginning 0)))
  366. (if (and (bolp) (or outline-blank-line (eobp)) (not (bobp)))
  367. (forward-char -1)))
  368. (defun outline-next-heading ()
  369. "Move to the next (possibly invisible) heading line."
  370. (interactive)
  371. ;; Make sure we don't match the heading we're at.
  372. (if (and (bolp) (not (eobp))) (forward-char 1))
  373. (if (re-search-forward (concat "^\\(?:" outline-regexp "\\)")
  374. nil 'move)
  375. (goto-char (match-beginning 0))))
  376. (defun outline-previous-heading ()
  377. "Move to the previous (possibly invisible) heading line."
  378. (interactive)
  379. (re-search-backward (concat "^\\(?:" outline-regexp "\\)")
  380. nil 'move))
  381. (defsubst outline-invisible-p (&optional pos)
  382. "Non-nil if the character after point is invisible."
  383. (get-char-property (or pos (point)) 'invisible))
  384. (defun outline-back-to-heading (&optional invisible-ok)
  385. "Move to previous heading line, or beg of this line if it's a heading.
  386. Only visible heading lines are considered, unless INVISIBLE-OK is non-nil."
  387. (beginning-of-line)
  388. (or (outline-on-heading-p invisible-ok)
  389. (let (found)
  390. (save-excursion
  391. (while (not found)
  392. (or (re-search-backward (concat "^\\(?:" outline-regexp "\\)")
  393. nil t)
  394. (error "before first heading"))
  395. (setq found (and (or invisible-ok (not (outline-invisible-p)))
  396. (point)))))
  397. (goto-char found)
  398. found)))
  399. (defun outline-on-heading-p (&optional invisible-ok)
  400. "Return t if point is on a (visible) heading line.
  401. If INVISIBLE-OK is non-nil, an invisible heading line is ok too."
  402. (save-excursion
  403. (beginning-of-line)
  404. (and (bolp) (or invisible-ok (not (outline-invisible-p)))
  405. (looking-at outline-regexp))))
  406. (defun outline-insert-heading ()
  407. "Insert a new heading at same depth at point."
  408. (interactive)
  409. (let ((head (save-excursion
  410. (condition-case nil
  411. (outline-back-to-heading)
  412. (error (outline-next-heading)))
  413. (if (eobp)
  414. (or (caar outline-heading-alist) "")
  415. (match-string 0)))))
  416. (unless (or (string-match "[ \t]\\'" head)
  417. (not (string-match (concat "\\`\\(?:" outline-regexp "\\)")
  418. (concat head " "))))
  419. (setq head (concat head " ")))
  420. (unless (bolp) (end-of-line) (newline))
  421. (insert head)
  422. (unless (eolp)
  423. (save-excursion (newline-and-indent)))
  424. (run-hooks 'outline-insert-heading-hook)))
  425. (defun outline-invent-heading (head up)
  426. (save-match-data
  427. ;; Let's try to invent one by repeating or deleting the last char.
  428. (let ((new-head (if up (substring head 0 -1)
  429. (concat head (substring head -1)))))
  430. (if (string-match (concat "\\`\\(?:" outline-regexp "\\)")
  431. new-head)
  432. ;; Why bother checking that it is indeed higher/lower level ?
  433. new-head
  434. ;; Didn't work, so ask what to do.
  435. (read-string (format "%s heading for `%s': "
  436. (if up "Parent" "Demoted") head)
  437. head nil nil t)))))
  438. (defun outline-promote (&optional which)
  439. "Promote headings higher up the tree.
  440. If transient-mark-mode is on, and mark is active, promote headings in
  441. the region (from a Lisp program, pass `region' for WHICH). Otherwise:
  442. without prefix argument, promote current heading and all headings in the
  443. subtree (from a Lisp program, pass `subtree' for WHICH); with prefix
  444. argument, promote just the current heading (from a Lisp program, pass
  445. nil for WHICH, or do not pass any argument)."
  446. (interactive
  447. (list (if (and transient-mark-mode mark-active) 'region
  448. (outline-back-to-heading)
  449. (if current-prefix-arg nil 'subtree))))
  450. (cond
  451. ((eq which 'region)
  452. (outline-map-region 'outline-promote (region-beginning) (region-end)))
  453. (which
  454. (outline-map-region 'outline-promote
  455. (point)
  456. (save-excursion (outline-get-next-sibling) (point))))
  457. (t
  458. (outline-back-to-heading t)
  459. (let* ((head (match-string-no-properties 0))
  460. (level (save-match-data (funcall outline-level)))
  461. (up-head (or (outline-head-from-level (1- level) head)
  462. ;; Use the parent heading, if it is really
  463. ;; one level less.
  464. (save-excursion
  465. (save-match-data
  466. (outline-up-heading 1 t)
  467. (and (= (1- level) (funcall outline-level))
  468. (match-string-no-properties 0))))
  469. ;; Bummer!! There is no lower level heading.
  470. (outline-invent-heading head 'up))))
  471. (unless (rassoc level outline-heading-alist)
  472. (push (cons head level) outline-heading-alist))
  473. (replace-match up-head nil t)))))
  474. (defun outline-demote (&optional which)
  475. "Demote headings lower down the tree.
  476. If transient-mark-mode is on, and mark is active, demote headings in
  477. the region (from a Lisp program, pass `region' for WHICH). Otherwise:
  478. without prefix argument, demote current heading and all headings in the
  479. subtree (from a Lisp program, pass `subtree' for WHICH); with prefix
  480. argument, demote just the current heading (from a Lisp program, pass
  481. nil for WHICH, or do not pass any argument)."
  482. (interactive
  483. (list (if (and transient-mark-mode mark-active) 'region
  484. (outline-back-to-heading)
  485. (if current-prefix-arg nil 'subtree))))
  486. (cond
  487. ((eq which 'region)
  488. (outline-map-region 'outline-demote (region-beginning) (region-end)))
  489. (which
  490. (outline-map-region 'outline-demote
  491. (point)
  492. (save-excursion (outline-get-next-sibling) (point))))
  493. (t
  494. (let* ((head (match-string-no-properties 0))
  495. (level (save-match-data (funcall outline-level)))
  496. (down-head
  497. (or (outline-head-from-level (1+ level) head)
  498. (save-excursion
  499. (save-match-data
  500. (while (and (progn (outline-next-heading) (not (eobp)))
  501. (<= (funcall outline-level) level)))
  502. (when (eobp)
  503. ;; Try again from the beginning of the buffer.
  504. (goto-char (point-min))
  505. (while (and (progn (outline-next-heading) (not (eobp)))
  506. (<= (funcall outline-level) level))))
  507. (unless (eobp)
  508. (looking-at outline-regexp)
  509. (match-string-no-properties 0))))
  510. ;; Bummer!! There is no higher-level heading in the buffer.
  511. (outline-invent-heading head nil))))
  512. (unless (rassoc level outline-heading-alist)
  513. (push (cons head level) outline-heading-alist))
  514. (replace-match down-head nil t)))))
  515. (defun outline-head-from-level (level head &optional alist)
  516. "Get new heading with level LEVEL from ALIST.
  517. If there are no such entries, return nil.
  518. ALIST defaults to `outline-heading-alist'.
  519. Similar to (car (rassoc LEVEL ALIST)).
  520. If there are several different entries with same new level, choose
  521. the one with the smallest distance to the association of HEAD in the alist.
  522. This makes it possible for promotion to work in modes with several
  523. independent sets of headings (numbered, unnumbered, appendix...)"
  524. (unless alist (setq alist outline-heading-alist))
  525. (let ((l (rassoc level alist))
  526. ll h hl l2 l2l)
  527. (cond
  528. ((null l) nil)
  529. ;; If there's no HEAD after L, any other entry for LEVEL after L
  530. ;; can't be much better than L.
  531. ((null (setq h (assoc head (setq ll (memq l alist))))) (car l))
  532. ;; If there's no other entry for LEVEL, just keep L.
  533. ((null (setq l2 (rassoc level (cdr ll)))) (car l))
  534. ;; Now we have L, L2, and H: see if L2 seems better than L.
  535. ;; If H is after L2, L2 is better.
  536. ((memq h (setq l2l (memq l2 (cdr ll))))
  537. (outline-head-from-level level head l2l))
  538. ;; Now we have H between L and L2.
  539. ;; If there's a separator between L and H, prefer L2.
  540. ((memq h (memq nil ll))
  541. (outline-head-from-level level head l2l))
  542. ;; If there's a separator between L2 and H, prefer L.
  543. ((memq l2 (memq nil (setq hl (memq h ll)))) (car l))
  544. ;; No separator between L and L2, check the distance.
  545. ((< (* 2 (length hl)) (+ (length ll) (length l2l)))
  546. (outline-head-from-level level head l2l))
  547. ;; If all else fails, just keep L.
  548. (t (car l)))))
  549. (defun outline-map-region (fun beg end)
  550. "Call FUN for every heading between BEG and END.
  551. When FUN is called, point is at the beginning of the heading and
  552. the match data is set appropriately."
  553. (save-excursion
  554. (setq end (copy-marker end))
  555. (goto-char beg)
  556. (when (re-search-forward (concat "^\\(?:" outline-regexp "\\)") end t)
  557. (goto-char (match-beginning 0))
  558. (funcall fun)
  559. (while (and (progn
  560. (outline-next-heading)
  561. (< (point) end))
  562. (not (eobp)))
  563. (funcall fun)))))
  564. ;; Vertical tree motion
  565. (defun outline-move-subtree-up (&optional arg)
  566. "Move the current subtree up past ARG headlines of the same level."
  567. (interactive "p")
  568. (outline-move-subtree-down (- arg)))
  569. (defun outline-move-subtree-down (&optional arg)
  570. "Move the current subtree down past ARG headlines of the same level."
  571. (interactive "p")
  572. (let ((movfunc (if (> arg 0) 'outline-get-next-sibling
  573. 'outline-get-last-sibling))
  574. (ins-point (make-marker))
  575. (cnt (abs arg))
  576. beg end folded)
  577. ;; Select the tree
  578. (outline-back-to-heading)
  579. (setq beg (point))
  580. (save-match-data
  581. (save-excursion (outline-end-of-heading)
  582. (setq folded (outline-invisible-p)))
  583. (outline-end-of-subtree))
  584. (if (= (char-after) ?\n) (forward-char 1))
  585. (setq end (point))
  586. ;; Find insertion point, with error handling
  587. (goto-char beg)
  588. (while (> cnt 0)
  589. (or (funcall movfunc)
  590. (progn (goto-char beg)
  591. (error "Cannot move past superior level")))
  592. (setq cnt (1- cnt)))
  593. (if (> arg 0)
  594. ;; Moving forward - still need to move over subtree
  595. (progn (outline-end-of-subtree)
  596. (if (= (char-after) ?\n) (forward-char 1))))
  597. (move-marker ins-point (point))
  598. (insert (delete-and-extract-region beg end))
  599. (goto-char ins-point)
  600. (if folded (hide-subtree))
  601. (move-marker ins-point nil)))
  602. (defun outline-end-of-heading ()
  603. (if (re-search-forward outline-heading-end-regexp nil 'move)
  604. (forward-char -1)))
  605. (defun outline-next-visible-heading (arg)
  606. "Move to the next visible heading line.
  607. With argument, repeats or can move backward if negative.
  608. A heading line is one that starts with a `*' (or that
  609. `outline-regexp' matches)."
  610. (interactive "p")
  611. (if (< arg 0)
  612. (beginning-of-line)
  613. (end-of-line))
  614. (let (found-heading-p)
  615. (while (and (not (bobp)) (< arg 0))
  616. (while (and (not (bobp))
  617. (setq found-heading-p
  618. (re-search-backward
  619. (concat "^\\(?:" outline-regexp "\\)")
  620. nil 'move))
  621. (outline-invisible-p)))
  622. (setq arg (1+ arg)))
  623. (while (and (not (eobp)) (> arg 0))
  624. (while (and (not (eobp))
  625. (setq found-heading-p
  626. (re-search-forward
  627. (concat "^\\(?:" outline-regexp "\\)")
  628. nil 'move))
  629. (outline-invisible-p (match-beginning 0))))
  630. (setq arg (1- arg)))
  631. (if found-heading-p (beginning-of-line))))
  632. (defun outline-previous-visible-heading (arg)
  633. "Move to the previous heading line.
  634. With argument, repeats or can move forward if negative.
  635. A heading line is one that starts with a `*' (or that
  636. `outline-regexp' matches)."
  637. (interactive "p")
  638. (outline-next-visible-heading (- arg)))
  639. (defun outline-mark-subtree ()
  640. "Mark the current subtree in an outlined document.
  641. This puts point at the start of the current subtree, and mark at the end."
  642. (interactive)
  643. (let ((beg))
  644. (if (outline-on-heading-p)
  645. ;; we are already looking at a heading
  646. (beginning-of-line)
  647. ;; else go back to previous heading
  648. (outline-previous-visible-heading 1))
  649. (setq beg (point))
  650. (outline-end-of-subtree)
  651. (push-mark (point) nil t)
  652. (goto-char beg)))
  653. (defvar outline-isearch-open-invisible-function nil
  654. "Function called if `isearch' finishes in an invisible overlay.
  655. The function is called with the overlay as its only argument.
  656. If nil, `show-entry' is called to reveal the invisible text.")
  657. (put 'outline 'reveal-toggle-invisible 'outline-reveal-toggle-invisible)
  658. (defun outline-flag-region (from to flag)
  659. "Hide or show lines from FROM to TO, according to FLAG.
  660. If FLAG is nil then text is shown, while if FLAG is t the text is hidden."
  661. (remove-overlays from to 'invisible 'outline)
  662. (when flag
  663. ;; We use `front-advance' here because the invisible text begins at the
  664. ;; very end of the heading, before the newline, so text inserted at FROM
  665. ;; belongs to the heading rather than to the entry.
  666. (let ((o (make-overlay from to nil 'front-advance)))
  667. (overlay-put o 'evaporate t)
  668. (overlay-put o 'invisible 'outline)
  669. (overlay-put o 'isearch-open-invisible
  670. (or outline-isearch-open-invisible-function
  671. 'outline-isearch-open-invisible))))
  672. ;; Seems only used by lazy-lock. I.e. obsolete.
  673. (run-hooks 'outline-view-change-hook))
  674. (defun outline-reveal-toggle-invisible (o hidep)
  675. (save-excursion
  676. (goto-char (overlay-start o))
  677. (if hidep
  678. ;; When hiding the area again, we could just clean it up and let
  679. ;; reveal do the rest, by simply doing:
  680. ;; (remove-overlays (overlay-start o) (overlay-end o)
  681. ;; 'invisible 'outline)
  682. ;;
  683. ;; That works fine as long as everything is in sync, but if the
  684. ;; structure of the document is changed while revealing parts of it,
  685. ;; the resulting behavior can be ugly. I.e. we need to make
  686. ;; sure that we hide exactly a subtree.
  687. (progn
  688. (let ((end (overlay-end o)))
  689. (delete-overlay o)
  690. (while (progn
  691. (hide-subtree)
  692. (outline-next-visible-heading 1)
  693. (and (not (eobp)) (< (point) end))))))
  694. ;; When revealing, we just need to reveal sublevels. If point is
  695. ;; inside one of the sublevels, reveal will call us again.
  696. ;; But we need to preserve the original overlay.
  697. (let ((o1 (copy-overlay o)))
  698. (overlay-put o 'invisible nil) ;Show (most of) the text.
  699. (while (progn
  700. (show-entry)
  701. (show-children)
  702. ;; Normally just the above is needed.
  703. ;; But in odd cases, the above might fail to show anything.
  704. ;; To avoid an infinite loop, we have to make sure that
  705. ;; *something* gets shown.
  706. (and (equal (overlay-start o) (overlay-start o1))
  707. (< (point) (overlay-end o))
  708. (= 0 (forward-line 1)))))
  709. ;; If still nothing was shown, just kill the damn thing.
  710. (when (equal (overlay-start o) (overlay-start o1))
  711. ;; I've seen it happen at the end of buffer.
  712. (delete-overlay o1))))))
  713. ;; Function to be set as an outline-isearch-open-invisible' property
  714. ;; to the overlay that makes the outline invisible (see
  715. ;; `outline-flag-region').
  716. (defun outline-isearch-open-invisible (_overlay)
  717. ;; We rely on the fact that isearch places point on the matched text.
  718. (show-entry))
  719. (defun hide-entry ()
  720. "Hide the body directly following this heading."
  721. (interactive)
  722. (save-excursion
  723. (outline-back-to-heading)
  724. (outline-end-of-heading)
  725. (outline-flag-region (point) (progn (outline-next-preface) (point)) t)))
  726. (defun show-entry ()
  727. "Show the body directly following this heading.
  728. Show the heading too, if it is currently invisible."
  729. (interactive)
  730. (save-excursion
  731. (outline-back-to-heading t)
  732. (outline-flag-region (1- (point))
  733. (progn (outline-next-preface) (point)) nil)))
  734. (defun hide-body ()
  735. "Hide all body lines in buffer, leaving all headings visible."
  736. (interactive)
  737. (hide-region-body (point-min) (point-max)))
  738. (defun hide-region-body (start end)
  739. "Hide all body lines in the region, but not headings."
  740. ;; Nullify the hook to avoid repeated calls to `outline-flag-region'
  741. ;; wasting lots of time running `lazy-lock-fontify-after-outline'
  742. ;; and run the hook finally.
  743. (let (outline-view-change-hook)
  744. (save-excursion
  745. (save-restriction
  746. (narrow-to-region start end)
  747. (goto-char (point-min))
  748. (if (outline-on-heading-p)
  749. (outline-end-of-heading)
  750. (outline-next-preface))
  751. (while (not (eobp))
  752. (outline-flag-region (point)
  753. (progn (outline-next-preface) (point)) t)
  754. (unless (eobp)
  755. (forward-char (if (looking-at "\n\n") 2 1))
  756. (outline-end-of-heading))))))
  757. (run-hooks 'outline-view-change-hook))
  758. (defun show-all ()
  759. "Show all of the text in the buffer."
  760. (interactive)
  761. (outline-flag-region (point-min) (point-max) nil))
  762. (defun hide-subtree ()
  763. "Hide everything after this heading at deeper levels."
  764. (interactive)
  765. (outline-flag-subtree t))
  766. (defun hide-leaves ()
  767. "Hide the body after this heading and at deeper levels."
  768. (interactive)
  769. (save-excursion
  770. (outline-back-to-heading)
  771. ;; Turned off to fix bug reported by Otto Maddox on 22 Nov 2005.
  772. ;; (outline-end-of-heading)
  773. (hide-region-body (point) (progn (outline-end-of-subtree) (point)))))
  774. (defun show-subtree ()
  775. "Show everything after this heading at deeper levels."
  776. (interactive)
  777. (outline-flag-subtree nil))
  778. (defun outline-show-heading ()
  779. "Show the current heading and move to its end."
  780. (outline-flag-region (- (point)
  781. (if (bobp) 0
  782. (if (and outline-blank-line
  783. (eq (char-before (1- (point))) ?\n))
  784. 2 1)))
  785. (progn (outline-end-of-heading) (point))
  786. nil))
  787. (defun hide-sublevels (levels)
  788. "Hide everything but the top LEVELS levels of headers, in whole buffer."
  789. (interactive (list
  790. (cond
  791. (current-prefix-arg (prefix-numeric-value current-prefix-arg))
  792. ((save-excursion (beginning-of-line)
  793. (looking-at outline-regexp))
  794. (funcall outline-level))
  795. (t 1))))
  796. (if (< levels 1)
  797. (error "Must keep at least one level of headers"))
  798. (save-excursion
  799. (let* (outline-view-change-hook
  800. (beg (progn
  801. (goto-char (point-min))
  802. ;; Skip the prelude, if any.
  803. (unless (outline-on-heading-p t) (outline-next-heading))
  804. (point)))
  805. (end (progn
  806. (goto-char (point-max))
  807. ;; Keep empty last line, if available.
  808. (if (bolp) (1- (point)) (point)))))
  809. (if (< end beg)
  810. (setq beg (prog1 end (setq end beg))))
  811. ;; First hide everything.
  812. (outline-flag-region beg end t)
  813. ;; Then unhide the top level headers.
  814. (outline-map-region
  815. (lambda ()
  816. (if (<= (funcall outline-level) levels)
  817. (outline-show-heading)))
  818. beg end)
  819. ;; Finally unhide any trailing newline.
  820. (goto-char (point-max))
  821. (if (and (bolp) (not (bobp)) (outline-invisible-p (1- (point))))
  822. (outline-flag-region (1- (point)) (point) nil))))
  823. (run-hooks 'outline-view-change-hook))
  824. (defun hide-other ()
  825. "Hide everything except current body and parent and top-level headings."
  826. (interactive)
  827. (hide-sublevels 1)
  828. (let (outline-view-change-hook)
  829. (save-excursion
  830. (outline-back-to-heading t)
  831. (show-entry)
  832. (while (condition-case nil (progn (outline-up-heading 1 t) (not (bobp)))
  833. (error nil))
  834. (outline-flag-region (1- (point))
  835. (save-excursion (forward-line 1) (point))
  836. nil))))
  837. (run-hooks 'outline-view-change-hook))
  838. (defun outline-toggle-children ()
  839. "Show or hide the current subtree depending on its current state."
  840. (interactive)
  841. (save-excursion
  842. (outline-back-to-heading)
  843. (if (not (outline-invisible-p (line-end-position)))
  844. (hide-subtree)
  845. (show-children)
  846. (show-entry))))
  847. (defun outline-flag-subtree (flag)
  848. (save-excursion
  849. (outline-back-to-heading)
  850. (outline-end-of-heading)
  851. (outline-flag-region (point)
  852. (progn (outline-end-of-subtree) (point))
  853. flag)))
  854. (defun outline-end-of-subtree ()
  855. (outline-back-to-heading)
  856. (let ((first t)
  857. (level (funcall outline-level)))
  858. (while (and (not (eobp))
  859. (or first (> (funcall outline-level) level)))
  860. (setq first nil)
  861. (outline-next-heading))
  862. (if (and (bolp) (not (eolp)))
  863. ;; We stopped at a nonempty line (the next heading).
  864. (progn
  865. ;; Go to end of line before heading
  866. (forward-char -1)
  867. (if (and outline-blank-line (bolp))
  868. ;; leave blank line before heading
  869. (forward-char -1))))))
  870. (defun show-branches ()
  871. "Show all subheadings of this heading, but not their bodies."
  872. (interactive)
  873. (show-children 1000))
  874. (defun show-children (&optional level)
  875. "Show all direct subheadings of this heading.
  876. Prefix arg LEVEL is how many levels below the current level should be shown.
  877. Default is enough to cause the following heading to appear."
  878. (interactive "P")
  879. (setq level
  880. (if level (prefix-numeric-value level)
  881. (save-excursion
  882. (outline-back-to-heading)
  883. (let ((start-level (funcall outline-level)))
  884. (outline-next-heading)
  885. (if (eobp)
  886. 1
  887. (max 1 (- (funcall outline-level) start-level)))))))
  888. (let (outline-view-change-hook)
  889. (save-excursion
  890. (outline-back-to-heading)
  891. (setq level (+ level (funcall outline-level)))
  892. (outline-map-region
  893. (lambda ()
  894. (if (<= (funcall outline-level) level)
  895. (outline-show-heading)))
  896. (point)
  897. (progn (outline-end-of-subtree)
  898. (if (eobp) (point-max) (1+ (point)))))))
  899. (run-hooks 'outline-view-change-hook))
  900. (defun outline-up-heading (arg &optional invisible-ok)
  901. "Move to the visible heading line of which the present line is a subheading.
  902. With argument, move up ARG levels.
  903. If INVISIBLE-OK is non-nil, also consider invisible lines."
  904. (interactive "p")
  905. (and (eq this-command 'outline-up-heading)
  906. (or (eq last-command 'outline-up-heading) (push-mark)))
  907. (outline-back-to-heading invisible-ok)
  908. (let ((start-level (funcall outline-level)))
  909. (when (<= start-level 1)
  910. (error "Already at top level of the outline"))
  911. (while (and (> start-level 1) (> arg 0) (not (bobp)))
  912. (let ((level start-level))
  913. (while (not (or (< level start-level) (bobp)))
  914. (if invisible-ok
  915. (outline-previous-heading)
  916. (outline-previous-visible-heading 1))
  917. (setq level (funcall outline-level)))
  918. (setq start-level level))
  919. (setq arg (- arg 1))))
  920. (looking-at outline-regexp))
  921. (defun outline-forward-same-level (arg)
  922. "Move forward to the ARG'th subheading at same level as this one.
  923. Stop at the first and last subheadings of a superior heading."
  924. (interactive "p")
  925. (outline-back-to-heading)
  926. (while (> arg 0)
  927. (let ((point-to-move-to (save-excursion
  928. (outline-get-next-sibling))))
  929. (if point-to-move-to
  930. (progn
  931. (goto-char point-to-move-to)
  932. (setq arg (1- arg)))
  933. (progn
  934. (setq arg 0)
  935. (error "No following same-level heading"))))))
  936. (defun outline-get-next-sibling ()
  937. "Move to next heading of the same level, and return point.
  938. If there is no such heading, return nil."
  939. (let ((level (funcall outline-level)))
  940. (outline-next-visible-heading 1)
  941. (while (and (not (eobp)) (> (funcall outline-level) level))
  942. (outline-next-visible-heading 1))
  943. (if (or (eobp) (< (funcall outline-level) level))
  944. nil
  945. (point))))
  946. (defun outline-backward-same-level (arg)
  947. "Move backward to the ARG'th subheading at same level as this one.
  948. Stop at the first and last subheadings of a superior heading."
  949. (interactive "p")
  950. (outline-back-to-heading)
  951. (while (> arg 0)
  952. (let ((point-to-move-to (save-excursion
  953. (outline-get-last-sibling))))
  954. (if point-to-move-to
  955. (progn
  956. (goto-char point-to-move-to)
  957. (setq arg (1- arg)))
  958. (progn
  959. (setq arg 0)
  960. (error "No previous same-level heading"))))))
  961. (defun outline-get-last-sibling ()
  962. "Move to previous heading of the same level, and return point.
  963. If there is no such heading, return nil."
  964. (let ((opoint (point))
  965. (level (funcall outline-level)))
  966. (outline-previous-visible-heading 1)
  967. (when (and (/= (point) opoint) (outline-on-heading-p))
  968. (while (and (> (funcall outline-level) level)
  969. (not (bobp)))
  970. (outline-previous-visible-heading 1))
  971. (if (< (funcall outline-level) level)
  972. nil
  973. (point)))))
  974. (defun outline-headers-as-kill (beg end)
  975. "Save the visible outline headers in region at the start of the kill ring.
  976. Text shown between the headers isn't copied. Two newlines are
  977. inserted between saved headers. Yanking the result may be a
  978. convenient way to make a table of contents of the buffer."
  979. (interactive "r")
  980. (save-excursion
  981. (save-restriction
  982. (narrow-to-region beg end)
  983. (goto-char (point-min))
  984. (let ((buffer (current-buffer))
  985. start end)
  986. (with-temp-buffer
  987. (with-current-buffer buffer
  988. ;; Boundary condition: starting on heading:
  989. (when (outline-on-heading-p)
  990. (outline-back-to-heading)
  991. (setq start (point)
  992. end (progn (outline-end-of-heading)
  993. (point)))
  994. (insert-buffer-substring buffer start end)
  995. (insert "\n\n")))
  996. (let ((temp-buffer (current-buffer)))
  997. (with-current-buffer buffer
  998. (while (outline-next-heading)
  999. (unless (outline-invisible-p)
  1000. (setq start (point)
  1001. end (progn (outline-end-of-heading) (point)))
  1002. (with-current-buffer temp-buffer
  1003. (insert-buffer-substring buffer start end)
  1004. (insert "\n\n"))))))
  1005. (kill-new (buffer-string)))))))
  1006. (provide 'outline)
  1007. (provide 'noutline)
  1008. ;;; outline.el ends here