Mercurial > emacs
comparison lisp/textmodes/ooutline.el @ 6298:4f65581e0972
(outline-mode, outline-level): Doc fix.
(outline-on-heading-p): Use bolp, not bobp.
(outline-hide-other): Rename from hide-other.
(outline-hide-sublevels): Rename from hide-sublevels.
(outline-back-to-heading): Error if no previous heading.
(outline-next-visible-heading): Check for search failure.
(outline-hide-sublevels): Ignore text before first outline heading.
(outline-level): Count characters, not columns, so ^L is level 1.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Thu, 10 Mar 1994 23:49:00 +0000 |
parents | ec7e22ebd6b3 |
children | d0a9fa0d0a8d |
comparison
equal
deleted
inserted
replaced
6297:b44907fd0ff0 | 6298:4f65581e0972 |
---|---|
75 (define-key outline-mode-map "\C-c\C-o" 'outline-hide-other) | 75 (define-key outline-mode-map "\C-c\C-o" 'outline-hide-other) |
76 | 76 |
77 (define-key outline-mode-map [menu-bar hide] | 77 (define-key outline-mode-map [menu-bar hide] |
78 (cons "Hide" (make-sparse-keymap "Hide"))) | 78 (cons "Hide" (make-sparse-keymap "Hide"))) |
79 | 79 |
80 (define-key outline-mode-map [menu-bar hide hide-other] | 80 (define-key outline-mode-map [menu-bar hide outline-hide-other] |
81 '("Hide Other" . outline-hide-other)) | 81 '("Hide Other" . outline-hide-other)) |
82 (define-key outline-mode-map [menu-bar hide hide-sublevels] | 82 (define-key outline-mode-map [menu-bar hide outline-hide-sublevels] |
83 '("Hide Sublevels" . outline-hide-sublevels)) | 83 '("Hide Sublevels" . outline-hide-sublevels)) |
84 (define-key outline-mode-map [menu-bar hide hide-subtree] | 84 (define-key outline-mode-map [menu-bar hide hide-subtree] |
85 '("Hide Subtree" . hide-subtree)) | 85 '("Hide Subtree" . hide-subtree)) |
86 (define-key outline-mode-map [menu-bar hide hide-entry] | 86 (define-key outline-mode-map [menu-bar hide hide-entry] |
87 '("Hide Entry" . hide-entry)) | 87 '("Hide Entry" . hide-entry)) |
142 \\[outline-previous-visible-heading] outline-previous-visible-heading | 142 \\[outline-previous-visible-heading] outline-previous-visible-heading |
143 \\[outline-forward-same-level] outline-forward-same-level similar but skip subheadings | 143 \\[outline-forward-same-level] outline-forward-same-level similar but skip subheadings |
144 \\[outline-backward-same-level] outline-backward-same-level | 144 \\[outline-backward-same-level] outline-backward-same-level |
145 \\[outline-up-heading] outline-up-heading move from subheading to heading | 145 \\[outline-up-heading] outline-up-heading move from subheading to heading |
146 | 146 |
147 M-x hide-body make all text invisible (not headings). | 147 \\[hide-body] make all text invisible (not headings). |
148 M-x show-all make everything in buffer visible. | 148 \\[show-all] make everything in buffer visible. |
149 | 149 |
150 The remaining commands are used when point is on a heading line. | 150 The remaining commands are used when point is on a heading line. |
151 They apply to some of the body or subheadings of that heading. | 151 They apply to some of the body or subheadings of that heading. |
152 \\[hide-subtree] hide-subtree make body and subheadings invisible. | 152 \\[hide-subtree] hide-subtree make body and subheadings invisible. |
153 \\[show-subtree] show-subtree make body and subheadings visible. | 153 \\[show-subtree] show-subtree make body and subheadings visible. |
154 \\[show-children] show-children make direct subheadings visible. | 154 \\[show-children] show-children make direct subheadings visible. |
155 No effect on body, or subheadings 2 or more levels down. | 155 No effect on body, or subheadings 2 or more levels down. |
156 With arg N, affects subheadings N levels down. | 156 With arg N, affects subheadings N levels down. |
157 M-x hide-entry make immediately following body invisible. | 157 \\[hide-entry] make immediately following body invisible. |
158 M-x show-entry make it visible. | 158 \\[show-entry] make it visible. |
159 M-x hide-leaves make body under heading and under its subheadings invisible. | 159 \\[hide-leaves] make body under heading and under its subheadings invisible. |
160 The subheadings remain visible. | 160 The subheadings remain visible. |
161 M-x show-branches make all subheadings at all levels visible. | 161 \\[show-branches] make all subheadings at all levels visible. |
162 | 162 |
163 The variable `outline-regexp' can be changed to control what is a heading. | 163 The variable `outline-regexp' can be changed to control what is a heading. |
164 A line is a heading if `outline-regexp' matches something at the | 164 A line is a heading if `outline-regexp' matches something at the |
165 beginning of the line. The longer the match, the deeper the level. | 165 beginning of the line. The longer the match, the deeper the level. |
166 | 166 |
228 It can assume point is at the beginning of a header line.") | 228 It can assume point is at the beginning of a header line.") |
229 | 229 |
230 (defun outline-level () | 230 (defun outline-level () |
231 "Return the depth to which a statement is nested in the outline. | 231 "Return the depth to which a statement is nested in the outline. |
232 Point must be at the beginning of a header line. This is actually | 232 Point must be at the beginning of a header line. This is actually |
233 the column number of the end of what `outline-regexp matches'." | 233 the number of characters that `outline-regexp' matches." |
234 (save-excursion | 234 (save-excursion |
235 (looking-at outline-regexp) | 235 (looking-at outline-regexp) |
236 (save-excursion (goto-char (match-end 0)) (current-column)))) | 236 (- (match-end 0) (match-beginning 0)))) |
237 | 237 |
238 (defun outline-next-preface () | 238 (defun outline-next-preface () |
239 "Skip forward to just before the next heading line." | 239 "Skip forward to just before the next heading line." |
240 (if (re-search-forward (concat "[\n\^M]\\(" outline-regexp "\\)") | 240 (if (re-search-forward (concat "[\n\^M]\\(" outline-regexp "\\)") |
241 nil 'move) | 241 nil 'move) |
254 (defun outline-back-to-heading () | 254 (defun outline-back-to-heading () |
255 "Move to previous heading line, or beg of this line if it's a heading. | 255 "Move to previous heading line, or beg of this line if it's a heading. |
256 Only visible heading lines are considered." | 256 Only visible heading lines are considered." |
257 (beginning-of-line) | 257 (beginning-of-line) |
258 (or (outline-on-heading-p) | 258 (or (outline-on-heading-p) |
259 (re-search-backward (concat "^\\(" outline-regexp "\\)") nil 'move))) | 259 (re-search-backward (concat "^\\(" outline-regexp "\\)") nil t) |
260 (error "before first heading"))) | |
260 | 261 |
261 (defun outline-on-heading-p () | 262 (defun outline-on-heading-p () |
262 "Return T if point is on a (visible) heading line." | 263 "Return T if point is on a (visible) heading line." |
263 (save-excursion | 264 (save-excursion |
264 (beginning-of-line) | 265 (beginning-of-line) |
265 (and (bobp) | 266 (and (bolp) |
266 (looking-at outline-regexp)))) | 267 (looking-at outline-regexp)))) |
267 | 268 |
268 (defun outline-end-of-heading () | 269 (defun outline-end-of-heading () |
269 (if (re-search-forward outline-heading-end-regexp nil 'move) | 270 (if (re-search-forward outline-heading-end-regexp nil 'move) |
270 (forward-char -1))) | 271 (forward-char -1))) |
276 `outline-regexp' matches)." | 277 `outline-regexp' matches)." |
277 (interactive "p") | 278 (interactive "p") |
278 (if (< arg 0) | 279 (if (< arg 0) |
279 (beginning-of-line) | 280 (beginning-of-line) |
280 (end-of-line)) | 281 (end-of-line)) |
281 (re-search-forward (concat "^\\(" outline-regexp "\\)") nil nil arg) | 282 (or (re-search-forward (concat "^\\(" outline-regexp "\\)") nil t arg) |
283 (error "")) | |
282 (beginning-of-line)) | 284 (beginning-of-line)) |
283 | 285 |
284 (defun outline-previous-visible-heading (arg) | 286 (defun outline-previous-visible-heading (arg) |
285 "Move to the previous heading line. | 287 "Move to the previous heading line. |
286 With argument, repeats or can move forward if negative. | 288 With argument, repeats or can move forward if negative. |
355 (defun show-subtree () | 357 (defun show-subtree () |
356 "Show everything after this heading at deeper levels." | 358 "Show everything after this heading at deeper levels." |
357 (interactive) | 359 (interactive) |
358 (outline-flag-subtree ?\n)) | 360 (outline-flag-subtree ?\n)) |
359 | 361 |
360 (defun hide-sublevels (levels) | 362 (defun outline-hide-sublevels (levels) |
361 "Hide everything except the top LEVELS levels of headers." | 363 "Hide everything except the top LEVELS levels of headers." |
362 (interactive "p") | 364 (interactive "p") |
363 (if (< levels 1) | 365 (if (< levels 1) |
364 (error "Must keep at least one level of headers")) | 366 (error "Must keep at least one level of headers")) |
365 (setq levels (1- levels)) | 367 (setq levels (1- levels)) |
366 (save-excursion | 368 (save-excursion |
367 (goto-char (point-min)) | 369 (goto-char (point-min)) |
370 (or (outline-on-heading-p) | |
371 (outline-next-heading)) | |
368 (hide-subtree) | 372 (hide-subtree) |
369 (show-children levels) | 373 (show-children levels) |
370 (condition-case err | 374 (condition-case err |
371 (while (outline-get-next-sibling) | 375 (while (outline-get-next-sibling) |
372 (hide-subtree) | 376 (hide-subtree) |
373 (show-children levels)) | 377 (show-children levels)) |
374 (error nil)))) | 378 (error nil)))) |
375 | 379 |
376 (defun hide-other () | 380 (defun outline-hide-other () |
377 "Hide everything except for the current body and the parent headings." | 381 "Hide everything except for the current body and the parent headings." |
378 (interactive) | 382 (interactive) |
379 (outline-hide-sublevels 1) | 383 (outline-hide-sublevels 1) |
380 (let ((last (point)) | 384 (let ((last (point)) |
381 (pos (point))) | 385 (pos (point))) |
410 (outline-next-heading)) | 414 (outline-next-heading)) |
411 (if (eobp) | 415 (if (eobp) |
412 nil | 416 nil |
413 ;; go to end of line before heading | 417 ;; go to end of line before heading |
414 (forward-char -1) | 418 (forward-char -1) |
415 ;; skip preceding balnk line, if there is one | 419 ;; skip preceding blank line, if there is one |
416 (if (memq (preceding-char) '(?\n ?\^M)) | 420 (if (memq (preceding-char) '(?\n ?\^M)) |
417 (forward-char -1))))) | 421 (forward-char -1))))) |
418 | 422 |
419 (defun show-branches () | 423 (defun show-branches () |
420 "Show all subheadings of this heading, but not their bodies." | 424 "Show all subheadings of this heading, but not their bodies." |
462 With argument, move up ARG levels." | 466 With argument, move up ARG levels." |
463 (interactive "p") | 467 (interactive "p") |
464 (outline-back-to-heading) | 468 (outline-back-to-heading) |
465 (if (eq (funcall outline-level) 1) | 469 (if (eq (funcall outline-level) 1) |
466 (error "")) | 470 (error "")) |
467 (while (and (> (funcall outline-level) 1) | 471 (while (and (> (funcall outline-level) 1) |
468 (> arg 0) | 472 (> arg 0) |
469 (not (bobp))) | 473 (not (bobp))) |
470 (let ((present-level (funcall outline-level))) | 474 (let ((present-level (funcall outline-level))) |
471 (while (not (< (funcall outline-level) present-level)) | 475 (while (not (< (funcall outline-level) present-level)) |
472 (outline-previous-visible-heading 1)) | 476 (outline-previous-visible-heading 1)) |
473 (setq arg (- arg 1))))) | 477 (setq arg (- arg 1))))) |
474 | 478 |
475 (defun outline-forward-same-level (arg) | 479 (defun outline-forward-same-level (arg) |
476 "Move forward to the ARG'th subheading from here of the same level as the | 480 "Move forward to the ARG'th subheading from here of the same level as the |
477 present one. It stops at the first and last subheadings of a superior heading." | 481 present one. It stops at the first and last subheadings of a superior heading." |
478 (interactive "p") | 482 (interactive "p") |