Function: lm-section-end

lm-section-end is a byte-compiled function defined in lisp-mnt.el.gz.

Signature

(lm-section-end HEADER)

Documentation

Return the buffer location of the end of a given section.

The HEADER is the section string marking the beginning of the section. If the given section does not exist, return nil.

The section ends before the first non-comment text or the next section of the same level or lower; whatever comes first. The function lisp-outline-level is used to compute the level of a section.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/lisp-mnt.el.gz
(defun lm-section-end (header)
  "Return the buffer location of the end of a given section.
The HEADER is the section string marking the beginning of the
section.  If the given section does not exist, return nil.

The section ends before the first non-comment text or the next
section of the same level or lower; whatever comes first.  The
function `lisp-outline-level' is used to compute the level of
a section."
  (require 'outline)   ;; for outline-regexp.
  (let ((start (lm-section-start header)))
    (when start
      (save-excursion
        (goto-char start)
        (looking-at outline-regexp)
        (let ((level (lisp-outline-level))
              (case-fold-search t)
              next-section-found)
          (beginning-of-line 2)
          (while (and (setq next-section-found
                            (re-search-forward
                             (lm-get-header-re lm-any-header 'section)
                             nil t))
                      (> (save-excursion
                           (beginning-of-line)
                           (looking-at outline-regexp)
                           (lisp-outline-level))
                         level)))
	  (min (if next-section-found
		   (progn (beginning-of-line 0)
			  (unless (looking-at "")
			    (beginning-of-line 2))
			  (point))
		 (point-max))
	       (progn (goto-char start)
		      (while (forward-comment 1))
		      (point))))))))