mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-25 07:28:20 +00:00
(outline-level): New var. Everything funcalls this
instead of calling outline-level.
This commit is contained in:
parent
6e301d2449
commit
476731da98
@ -1,6 +1,6 @@
|
|||||||
;;; outline.el --- outline mode commands for Emacs
|
;;; outline.el --- outline mode commands for Emacs
|
||||||
|
|
||||||
;; Copyright (C) 1986 Free Software Foundation, Inc.
|
;; Copyright (C) 1986, 1993 Free Software Foundation, Inc.
|
||||||
|
|
||||||
;; Maintainer: FSF
|
;; Maintainer: FSF
|
||||||
|
|
||||||
@ -196,6 +196,10 @@ See the command `outline-mode' for more information on this mode."
|
|||||||
(run-hooks 'outline-minor-mode-hook))
|
(run-hooks 'outline-minor-mode-hook))
|
||||||
(setq selective-display nil)))
|
(setq selective-display nil)))
|
||||||
|
|
||||||
|
(defvar outline-level 'outline-level
|
||||||
|
"Function of no args to compute a header's nesting level in an outline.
|
||||||
|
It can assume point is at the beginning of a header line.")
|
||||||
|
|
||||||
(defun outline-level ()
|
(defun outline-level ()
|
||||||
"Return the depth to which a statement is nested in the outline.
|
"Return the depth to which a statement is nested in the outline.
|
||||||
Point must be at the beginning of a header line. This is actually
|
Point must be at the beginning of a header line. This is actually
|
||||||
@ -337,9 +341,9 @@ while if FLAG is `\\^M' (control-M) the text is hidden."
|
|||||||
(outline-back-to-heading)
|
(outline-back-to-heading)
|
||||||
(let ((opoint (point))
|
(let ((opoint (point))
|
||||||
(first t)
|
(first t)
|
||||||
(level (outline-level)))
|
(level (funcall outline-level)))
|
||||||
(while (and (not (eobp))
|
(while (and (not (eobp))
|
||||||
(or first (> (outline-level) level)))
|
(or first (> (funcall outline-level) level)))
|
||||||
(setq first nil)
|
(setq first nil)
|
||||||
(outline-next-heading))
|
(outline-next-heading))
|
||||||
(forward-char -1)
|
(forward-char -1)
|
||||||
@ -360,13 +364,13 @@ Default is enough to cause the following heading to appear."
|
|||||||
(if level (prefix-numeric-value level)
|
(if level (prefix-numeric-value level)
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
(let ((start-level (outline-level)))
|
(let ((start-level (funcall outline-level)))
|
||||||
(outline-next-heading)
|
(outline-next-heading)
|
||||||
(max 1 (- (outline-level) start-level))))))
|
(max 1 (- (funcall outline-level) start-level))))))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(save-restriction
|
(save-restriction
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
(setq level (+ level (outline-level)))
|
(setq level (+ level (funcall outline-level)))
|
||||||
(narrow-to-region (point)
|
(narrow-to-region (point)
|
||||||
(progn (outline-end-of-subtree) (1+ (point))))
|
(progn (outline-end-of-subtree) (1+ (point))))
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
@ -374,7 +378,7 @@ Default is enough to cause the following heading to appear."
|
|||||||
(progn
|
(progn
|
||||||
(outline-next-heading)
|
(outline-next-heading)
|
||||||
(not (eobp))))
|
(not (eobp))))
|
||||||
(if (<= (outline-level) level)
|
(if (<= (funcall outline-level) level)
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(outline-flag-region (save-excursion
|
(outline-flag-region (save-excursion
|
||||||
(forward-char -1)
|
(forward-char -1)
|
||||||
@ -389,13 +393,13 @@ Default is enough to cause the following heading to appear."
|
|||||||
With argument, move up ARG levels."
|
With argument, move up ARG levels."
|
||||||
(interactive "p")
|
(interactive "p")
|
||||||
(outline-back-to-heading)
|
(outline-back-to-heading)
|
||||||
(if (eq (outline-level) 1)
|
(if (eq (funcall outline-level) 1)
|
||||||
(error ""))
|
(error ""))
|
||||||
(while (and (> (outline-level) 1)
|
(while (and (> (funcall outline-level) 1)
|
||||||
(> arg 0)
|
(> arg 0)
|
||||||
(not (bobp)))
|
(not (bobp)))
|
||||||
(let ((present-level (outline-level)))
|
(let ((present-level (funcall outline-level)))
|
||||||
(while (not (< (outline-level) present-level))
|
(while (not (< (funcall outline-level) present-level))
|
||||||
(outline-previous-visible-heading 1))
|
(outline-previous-visible-heading 1))
|
||||||
(setq arg (- arg 1)))))
|
(setq arg (- arg 1)))))
|
||||||
|
|
||||||
@ -418,12 +422,12 @@ present one. It stops at the first and last subheadings of a superior heading."
|
|||||||
(defun outline-get-next-sibling ()
|
(defun outline-get-next-sibling ()
|
||||||
"Position the point at the next heading of the same level,
|
"Position the point at the next heading of the same level,
|
||||||
and return that position or nil if it cannot be found."
|
and return that position or nil if it cannot be found."
|
||||||
(let ((level (outline-level)))
|
(let ((level (funcall outline-level)))
|
||||||
(outline-next-visible-heading 1)
|
(outline-next-visible-heading 1)
|
||||||
(while (and (> (outline-level) level)
|
(while (and (> (funcall outline-level) level)
|
||||||
(not (eobp)))
|
(not (eobp)))
|
||||||
(outline-next-visible-heading 1))
|
(outline-next-visible-heading 1))
|
||||||
(if (< (outline-level) level)
|
(if (< (funcall outline-level) level)
|
||||||
nil
|
nil
|
||||||
(point))))
|
(point))))
|
||||||
|
|
||||||
@ -446,12 +450,12 @@ present one. It stops at the first and last subheadings of a superior heading."
|
|||||||
(defun outline-get-last-sibling ()
|
(defun outline-get-last-sibling ()
|
||||||
"Position the point at the previous heading of the same level,
|
"Position the point at the previous heading of the same level,
|
||||||
and return that position or nil if it cannot be found."
|
and return that position or nil if it cannot be found."
|
||||||
(let ((level (outline-level)))
|
(let ((level (funcall outline-level)))
|
||||||
(outline-previous-visible-heading 1)
|
(outline-previous-visible-heading 1)
|
||||||
(while (and (> (outline-level) level)
|
(while (and (> (funcall outline-level) level)
|
||||||
(not (bobp)))
|
(not (bobp)))
|
||||||
(outline-previous-visible-heading 1))
|
(outline-previous-visible-heading 1))
|
||||||
(if (< (outline-level) level)
|
(if (< (funcall outline-level) level)
|
||||||
nil
|
nil
|
||||||
(point))))
|
(point))))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user