When debugging some code, I learned that if you call pop-to-buffer and pop-to-buffer-same-window inside save-excursion or save-current-buffer, the original buffer will not be restored at the end of the save-. You can get around this by using save-window-excursion; however, I still feel like save-excursion ought to work. Does anyone know why it doesn’t?

(You can check this by eval-ing the following in any buffer other than *Messages*: (save-excursion (pop-to-buffer-same-window "*Messages*")).