outline-mode heading sibling
1. outline-mode
2. Emacsoutline-mode heading sibling
2
(defun last-sibling-heading-p ()
(save-excursion
(let ((start (point))
prev)
(ignore-errors (outline-forward-same-level 1))
(setq prev (point))
(ignore-errors (outline-forward-same-level 1))
(and (= prev (point))
(>= start (point))))))
;; M-x foosibling
(defun foo ()
(interactive)
(message (if (last-sibling-heading-p) "last" "butlast")))
* A
** a
** b
** c
* B
* C
c"last"
emacs-lisp