• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/emacs-93/emacs/lisp/obsolete/

Lines Matching +defs:outline +defs:back +defs:to +defs:heading

1 ;;; ooutline.el --- outline mode commands for Emacs
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
28 ;; This package is a major mode for editing outline-format documents.
29 ;; An outline can be `abstracted' to show headers at any given level,
38 :prefix "outline-"
42 (defcustom outline-regexp nil
43 "*Regular expression to match the beginning of a heading.
44 Any line whose beginning matches this regexp is considered to start a heading.
45 The recommended way to set this is with a Local Variables: list
46 in the file it applies to. See also outline-heading-end-regexp."
51 ;; already assigned a local value to it.
52 (or (default-value 'outline-regexp)
53 (setq-default outline-regexp "[*\^L]+"))
55 (defcustom outline-heading-end-regexp "[\n\^M]"
56 "*Regular expression to match the end of a heading line.
57 You can assume that point is at the beginning of a heading when this
58 regexp is searched for. The heading ends at the end of the match.
59 The recommended way to set this is with a \"Local Variables:\" list
60 in the file it applies to."
64 (defvar outline-mode-prefix-map nil)
66 (if outline-mode-prefix-map
68 (setq outline-mode-prefix-map (make-sparse-keymap))
69 (define-key outline-mode-prefix-map "\C-n" 'outline-next-visible-heading)
70 (define-key outline-mode-prefix-map "\C-p" 'outline-previous-visible-heading)
71 (define-key outline-mode-prefix-map "\C-i" 'show-children)
72 (define-key outline-mode-prefix-map "\C-s" 'show-subtree)
73 (define-key outline-mode-prefix-map "\C-d" 'hide-subtree)
74 (define-key outline-mode-prefix-map "\C-u" 'outline-up-heading)
75 (define-key outline-mode-prefix-map "\C-f" 'outline-forward-same-level)
76 (define-key outline-mode-prefix-map "\C-b" 'outline-backward-same-level)
77 (define-key outline-mode-prefix-map "\C-t" 'hide-body)
78 (define-key outline-mode-prefix-map "\C-a" 'show-all)
79 (define-key outline-mode-prefix-map "\C-c" 'hide-entry)
80 (define-key outline-mode-prefix-map "\C-e" 'show-entry)
81 (define-key outline-mode-prefix-map "\C-l" 'hide-leaves)
82 (define-key outline-mode-prefix-map "\C-k" 'show-branches)
83 (define-key outline-mode-prefix-map "\C-q" 'hide-sublevels)
84 (define-key outline-mode-prefix-map "\C-o" 'hide-other))
86 (defvar outline-mode-menu-bar-map nil)
87 (if outline-mode-menu-bar-map
89 (setq outline-mode-menu-bar-map (make-sparse-keymap))
91 (define-key outline-mode-menu-bar-map [hide]
94 (define-key outline-mode-menu-bar-map [hide hide-other]
96 (define-key outline-mode-menu-bar-map [hide hide-sublevels]
98 (define-key outline-mode-menu-bar-map [hide hide-subtree]
100 (define-key outline-mode-menu-bar-map [hide hide-entry]
102 (define-key outline-mode-menu-bar-map [hide hide-body]
104 (define-key outline-mode-menu-bar-map [hide hide-leaves]
107 (define-key outline-mode-menu-bar-map [show]
110 (define-key outline-mode-menu-bar-map [show show-subtree]
112 (define-key outline-mode-menu-bar-map [show show-children]
114 (define-key outline-mode-menu-bar-map [show show-branches]
116 (define-key outline-mode-menu-bar-map [show show-entry]
118 (define-key outline-mode-menu-bar-map [show show-all]
121 (define-key outline-mode-menu-bar-map [headings]
124 (define-key outline-mode-menu-bar-map [headings outline-backward-same-level]
125 '("Previous Same Level" . outline-backward-same-level))
126 (define-key outline-mode-menu-bar-map [headings outline-forward-same-level]
127 '("Next Same Level" . outline-forward-same-level))
128 (define-key outline-mode-menu-bar-map [headings outline-previous-visible-heading]
129 '("Previous" . outline-previous-visible-heading))
130 (define-key outline-mode-menu-bar-map [headings outline-next-visible-heading]
131 '("Next" . outline-next-visible-heading))
132 (define-key outline-mode-menu-bar-map [headings outline-up-heading]
133 '("Up" . outline-up-heading)))
135 (defvar outline-mode-map nil "")
137 (if outline-mode-map
139 (setq outline-mode-map (nconc (make-sparse-keymap) text-mode-map))
140 (define-key outline-mode-map "\C-c" outline-mode-prefix-map)
141 (define-key outline-mode-map [menu-bar] outline-mode-menu-bar-map))
143 (defcustom outline-minor-mode nil
147 (make-variable-buffer-local 'outline-minor-mode)
148 (put 'outline-minor-mode 'permanent-local t)
149 (or (assq 'outline-minor-mode minor-mode-alist)
151 (list '(outline-minor-mode " Outl")))))
153 (defvar outline-font-lock-keywords
154 '(;; Highlight headings according to the level.
165 "Additional expressions to highlight in Outline mode.")
167 (defun outline-mode ()
172 Body text or subheadings under a heading can be made temporarily
173 invisible, or visible again. Invisible lines are attached to the end
174 of the heading, so they move with it, if the line is killed and yanked
175 back. A heading with text hidden under it is marked with an ellipsis (...).
177 Commands:\\<outline-mode-map>
178 \\[outline-next-visible-heading] outline-next-visible-heading move by visible headings
179 \\[outline-previous-visible-heading] outline-previous-visible-heading
180 \\[outline-forward-same-level] outline-forward-same-level similar but skip subheadings
181 \\[outline-backward-same-level] outline-backward-same-level
182 \\[outline-up-heading] outline-up-heading move from subheading to heading
187 The remaining commands are used when point is on a heading line.
188 They apply to some of the body or subheadings of that heading.
196 \\[hide-leaves] make body under heading and under its subheadings invisible.
200 The variable `outline-regexp' can be changed to control what is a heading.
201 A line is a heading if `outline-regexp' matches something at the
204 Turning on outline mode calls the value of `text-mode-hook' and then of
205 `outline-mode-hook', if they are non-nil."
209 (use-local-map outline-mode-map)
211 (setq major-mode 'outline-mode)
217 outline-regexp "\\)"))
220 (setq auto-fill-inhibit-regexp outline-regexp)
223 outline-regexp "\\)"))
225 (setq font-lock-defaults '(outline-font-lock-keywords t))
228 (run-mode-hooks 'text-mode-hook 'outline-mode-hook))
230 (defcustom outline-minor-mode-prefix "\C-c@"
231 "*Prefix key to use for Outline commands in Outline minor mode.
237 (defvar outline-minor-mode-map nil)
238 (if outline-minor-mode-map
240 (setq outline-minor-mode-map (make-sparse-keymap))
241 (define-key outline-minor-mode-map [menu-bar]
242 outline-mode-menu-bar-map)
243 (define-key outline-minor-mode-map outline-minor-mode-prefix
244 outline-mode-prefix-map))
246 (or (assq 'outline-minor-mode minor-mode-map-alist)
248 (cons (cons 'outline-minor-mode outline-minor-mode-map)
251 (defun outline-minor-mode (&optional arg)
254 See the command `outline-mode' for more information on this mode."
256 (setq outline-minor-mode
257 (if (null arg) (not outline-minor-mode)
259 (if outline-minor-mode
262 (run-hooks 'outline-minor-mode-hook))
264 ;; When turning off outline mode, get rid of any ^M's.
265 (or outline-minor-mode
266 (outline-flag-region (point-min) (point-max) ?\n))
270 (defvar outline-level 'outline-level
271 "Function of no args to compute a header's nesting level in an outline.
274 ;; This used to count columns rather than characters, but that made ^L
275 ;; appear to be at level 2 instead of 1. Columns would be better for
277 ;; who changes the regexp can also redefine the outline-level variable
279 (defun outline-level ()
280 "Return the depth to which a statement is nested in the outline.
282 the number of characters that `outline-regexp' matches."
284 (looking-at outline-regexp)
287 (defun outline-next-preface ()
288 "Skip forward to just before the next heading line.
289 If there's no following heading line, stop before the newline
291 (if (re-search-forward (concat "[\n\^M]\\(" outline-regexp "\\)")
297 (defun outline-next-heading ()
298 "Move to the next (possibly invisible) heading line."
300 (if (re-search-forward (concat "[\n\^M]\\(" outline-regexp "\\)")
304 (defun outline-back-to-heading ()
305 "Move to previous heading line, or beg of this line if it's a heading.
306 Only visible heading lines are considered."
308 (or (outline-on-heading-p)
309 (re-search-backward (concat "^\\(" outline-regexp "\\)") nil t)
310 (error "before first heading")))
312 (defun outline-on-heading-p ()
313 "Return t if point is on a (visible) heading line."
317 (looking-at outline-regexp))))
319 (defun outline-end-of-heading ()
320 (if (re-search-forward outline-heading-end-regexp nil 'move)
323 (defun outline-next-visible-heading (arg)
324 "Move to the next visible heading line.
326 A heading line is one that starts with a `*' (or that
327 `outline-regexp' matches)."
332 (or (re-search-forward (concat "^\\(" outline-regexp "\\)") nil t arg)
336 (defun outline-previous-visible-heading (arg)
337 "Move to the previous heading line.
339 A heading line is one that starts with a `*' (or that
340 `outline-regexp' matches)."
342 (outline-next-visible-heading (- arg)))
344 (defun outline-flag-region (from to flag)
345 "Hides or shows lines from FROM to TO, according to FLAG.
349 (subst-char-in-region from to
355 "Hide the body directly following this heading."
357 (outline-back-to-heading)
358 (outline-end-of-heading)
360 (outline-flag-region (point) (progn (outline-next-preface) (point)) ?\^M)))
363 "Show the body directly following this heading."
366 (outline-flag-region (point) (progn (outline-next-preface) (point)) ?\n)))
377 (narrow-to-region start end)
379 (if (outline-on-heading-p)
380 (outline-end-of-heading))
382 (outline-flag-region (point)
383 (progn (outline-next-preface) (point)) ?\^M)
389 (outline-end-of-heading)))))))
394 (outline-flag-region (point-min) (point-max) ?\n))
397 "Hide everything after this heading at deeper levels."
399 (outline-flag-subtree ?\^M))
402 "Hide all body after this heading at deeper levels."
404 (outline-back-to-heading)
405 (outline-end-of-heading)
406 (hide-region-body (point) (progn (outline-end-of-subtree) (point))))
409 "Show everything after this heading at deeper levels."
411 (outline-flag-subtree ?\n))
421 ;; Keep advancing to the next top-level heading.
422 (while (or (and (bobp) (outline-on-heading-p))
423 (outline-next-heading))
424 (let ((end (save-excursion (outline-end-of-subtree) (point))))
426 (outline-flag-region (point) end ?\^M)
430 ;; Move to the next, since we already found it.
446 (outline-next-heading)
447 (outline-flag-region last (point) ?\n))
451 (defun outline-flag-subtree (flag)
453 (outline-back-to-heading)
454 (outline-end-of-heading)
455 (outline-flag-region (point)
456 (progn (outline-end-of-subtree) (point))
459 (defun outline-end-of-subtree ()
460 (outline-back-to-heading)
463 (level (funcall outline-level)))
465 (or first (> (funcall outline-level) level)))
467 (outline-next-heading))
470 ;; Go to end of line before heading
473 ;; leave blank line before heading
478 "Show all subheadings of this heading, but not their bodies."
483 "Show all direct subheadings of this heading.
485 Default is enough to cause the following heading to appear."
490 (outline-back-to-heading)
491 (let ((start-level (funcall outline-level)))
492 (outline-next-heading)
495 (max 1 (- (funcall outline-level) start-level)))))))
498 (outline-back-to-heading)
499 (setq level (+ level (funcall outline-level)))
500 (narrow-to-region (point)
501 (progn (outline-end-of-subtree)
506 (outline-next-heading)
508 (if (<= (funcall outline-level) level)
510 (outline-flag-region (save-excursion
515 (progn (outline-end-of-heading) (point))
519 (defun outline-up-heading (arg)
520 "Move to the heading line of which the present line is a subheading.
523 (outline-back-to-heading)
524 (if (eq (funcall outline-level) 1)
526 (while (and (> (funcall outline-level) 1)
529 (let ((present-level (funcall outline-level)))
530 (while (not (< (funcall outline-level) present-level))
531 (outline-previous-visible-heading 1))
534 (defun outline-forward-same-level (arg)
535 "Move forward to the ARG'th subheading at same level as this one.
536 Stop at the first and last subheadings of a superior heading."
538 (outline-back-to-heading)
540 (let ((point-to-move-to (save-excursion
541 (outline-get-next-sibling))))
542 (if point-to-move-to
544 (goto-char point-to-move-to)
550 (defun outline-get-next-sibling ()
551 "Move to next heading of the same level, and return point or nil if none."
552 (let ((level (funcall outline-level)))
553 (outline-next-visible-heading 1)
554 (while (and (> (funcall outline-level) level)
556 (outline-next-visible-heading 1))
557 (if (< (funcall outline-level) level)
561 (defun outline-backward-same-level (arg)
562 "Move backward to the ARG'th subheading at same level as this one.
563 Stop at the first and last subheadings of a superior heading."
565 (outline-back-to-heading)
567 (let ((point-to-move-to (save-excursion
568 (outline-get-last-sibling))))
569 (if point-to-move-to
571 (goto-char point-to-move-to)
577 (defun outline-get-last-sibling ()
578 "Move to next heading of the same level, and return point or nil if none."
579 (let ((level (funcall outline-level)))
580 (outline-previous-visible-heading 1)
581 (while (and (> (funcall outline-level) level)
583 (outline-previous-visible-heading 1))
584 (if (< (funcall outline-level) level)
588 (provide 'outline)