comparison lisp/textmodes/outline.el @ 37920:abf444fe5166

(outline-mode): Fix font-lock-defaults. (outline-invisible-p): New function. (hide-leaves): Save excursion. (hide-other): Stop looping when reaching bobp.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 28 May 2001 12:21:59 +0000
parents ac83181a33d0
children 7370effcd55c
comparison
equal deleted inserted replaced
37919:3584834cad02 37920:abf444fe5166
224 ;; Inhibit auto-filling of header lines. 224 ;; Inhibit auto-filling of header lines.
225 (set (make-local-variable 'auto-fill-inhibit-regexp) outline-regexp) 225 (set (make-local-variable 'auto-fill-inhibit-regexp) outline-regexp)
226 (set (make-local-variable 'paragraph-separate) 226 (set (make-local-variable 'paragraph-separate)
227 (concat paragraph-separate "\\|\\(" outline-regexp "\\)")) 227 (concat paragraph-separate "\\|\\(" outline-regexp "\\)"))
228 (set (make-local-variable 'font-lock-defaults) 228 (set (make-local-variable 'font-lock-defaults)
229 '(outline-font-lock-keywords t nil nil 'backward-paragraph)) 229 '(outline-font-lock-keywords t nil nil backward-paragraph))
230 (setq imenu-generic-expression 230 (setq imenu-generic-expression
231 (list (list nil (concat outline-regexp ".*$") 0))) 231 (list (list nil (concat outline-regexp ".*$") 0)))
232 (add-hook 'change-major-mode-hook 'show-all nil t)) 232 (add-hook 'change-major-mode-hook 'show-all nil t))
233 233
234 (defcustom outline-minor-mode-prefix "\C-c@" 234 (defcustom outline-minor-mode-prefix "\C-c@"
301 "Move to the previous (possibly invisible) heading line." 301 "Move to the previous (possibly invisible) heading line."
302 (interactive) 302 (interactive)
303 (re-search-backward (concat "^\\(" outline-regexp "\\)") 303 (re-search-backward (concat "^\\(" outline-regexp "\\)")
304 nil 'move)) 304 nil 'move))
305 305
306 (defsubst outline-visible () 306 (defsubst outline-invisible-p ()
307 "Non-nil if the character after point is visible." 307 "Non-nil if the character after point is invisible."
308 (not (get-char-property (point) 'invisible))) 308 (get-char-property (point) 'invisible))
309 (defun outline-visible ()
310 "Obsolete. Use `outline-invisible-p'."
311 (not (outline-invisible-p)))
309 312
310 (defun outline-back-to-heading (&optional invisible-ok) 313 (defun outline-back-to-heading (&optional invisible-ok)
311 "Move to previous heading line, or beg of this line if it's a heading. 314 "Move to previous heading line, or beg of this line if it's a heading.
312 Only visible heading lines are considered, unless INVISIBLE-OK is non-nil." 315 Only visible heading lines are considered, unless INVISIBLE-OK is non-nil."
313 (beginning-of-line) 316 (beginning-of-line)
473 (if (outline-on-heading-p) 476 (if (outline-on-heading-p)
474 (outline-end-of-heading)) 477 (outline-end-of-heading))
475 (while (not (eobp)) 478 (while (not (eobp))
476 (outline-flag-region (point) 479 (outline-flag-region (point)
477 (progn (outline-next-preface) (point)) t) 480 (progn (outline-next-preface) (point)) t)
478 (if (not (eobp)) 481 (unless (eobp)
479 (progn 482 (forward-char (if (looking-at "\n\n") 2 1))
480 (forward-char 483 (outline-end-of-heading))))))
481 (if (looking-at "\n\n")
482 2 1))
483 (outline-end-of-heading)))))))
484 (run-hooks 'outline-view-change-hook)) 484 (run-hooks 'outline-view-change-hook))
485 485
486 (defun show-all () 486 (defun show-all ()
487 "Show all of the text in the buffer." 487 "Show all of the text in the buffer."
488 (interactive) 488 (interactive)
495 495
496 (defun hide-leaves () 496 (defun hide-leaves ()
497 "Hide all body after this heading at deeper levels." 497 "Hide all body after this heading at deeper levels."
498 (interactive) 498 (interactive)
499 (outline-back-to-heading) 499 (outline-back-to-heading)
500 (outline-end-of-heading) 500 (save-excursion
501 (hide-region-body (point) (progn (outline-end-of-subtree) (point)))) 501 (outline-end-of-heading)
502 (hide-region-body (point) (progn (outline-end-of-subtree) (point)))))
502 503
503 (defun show-subtree () 504 (defun show-subtree ()
504 "Show everything after this heading at deeper levels." 505 "Show everything after this heading at deeper levels."
505 (interactive) 506 (interactive)
506 (outline-flag-subtree nil)) 507 (outline-flag-subtree nil))
533 (hide-sublevels 1) 534 (hide-sublevels 1)
534 (let (outline-view-change-hook) 535 (let (outline-view-change-hook)
535 (save-excursion 536 (save-excursion
536 (outline-back-to-heading t) 537 (outline-back-to-heading t)
537 (show-entry) 538 (show-entry)
538 (while (condition-case nil (progn (outline-up-heading 1) t) 539 (while (condition-case nil (progn (outline-up-heading 1) (not (bobp)))
539 (error nil)) 540 (error nil))
540 (outline-flag-region (1- (point)) 541 (outline-flag-region (1- (point))
541 (save-excursion (forward-line 1) (point)) 542 (save-excursion (forward-line 1) (point))
542 nil)))) 543 nil))))
543 (run-hooks 'outline-view-change-hook)) 544 (run-hooks 'outline-view-change-hook))