Subject: RE: bug#32790: 27.0.50; point jumps unexpectedly after delete-window

From: Drew Adams <[email-masked]>
Date: Fri, 2 Nov 2018 07:36:34 -0700 (PDT)

FWIW -

I distinguish interactive use of `kill-buffer' from
programmatic use.  Interactively I want any windows
showing the buffer to disappear too.  Interactively
I substitute `kill-buffer-and-its-windows'.  I've
been doing this at least since the mid-90s.  

Dunno whether I'm alone in this preference, or would
be even if it were offered more widely.

Just for reference, here's the definition I'm still
using, but you can no doubt come up with something
better or more recent.

(defun kill-buffer-and-its-windows (buffer)
  "Kill BUFFER and delete its windows."
  (interactive (list (read-buffer "Kill buffer: "
                                  (current-buffer)
                                  'existing)))
  (setq buffer  (get-buffer buffer))
  (if (buffer-live-p buffer)
      (let ((wins  (get-buffer-window-list buffer nil t)))
        (when (kill-buffer buffer)
          (dolist (win  wins)
            (when (window-live-p win)
              (condition-case nil
                  (delete-window win)
                (error nil))))))
    (when (interactive-p)
      (error "Cannot kill buffer. Not a live buffer: `%s'"
             buffer))))