Function: hypb:assert-same-start-and-end-buffer

hypb:assert-same-start-and-end-buffer is a macro defined in hypb.el.

Signature

(hypb:assert-same-start-and-end-buffer &rest BODY)

Documentation

Assert that current buffer does not change following execution of BODY.

Trigger an error with traceback if the buffer is not live or its name differs at the start and end of BODY.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hypb.el
(defmacro hypb:assert-same-start-and-end-buffer (&rest body)
  "Assert that current buffer does not change following execution of BODY.
Trigger an error with traceback if the buffer is not live or its
name differs at the start and end of BODY."
  (declare (indent 0) (debug t))
  `(let ((debug-on-error t)
	 (start-buffer (current-buffer)))
     (unless (buffer-live-p start-buffer)
       (error "Start buffer, '%s', is not live" (current-buffer)))
     ;; `kill-buffer' can change current-buffer in some odd cases.
     (unwind-protect
	 (progn ,@body)
       (unless  (eq start-buffer (current-buffer))
	 (error "Start buffer, '%s', differs from end buffer, '%s'" start-buffer (current-buffer)))
       (unless (buffer-live-p start-buffer)
	 (error "End buffer, '%s', is not live" (current-buffer))))))