I have a lisp function that relies on other-buffer which refers to buffer-list. Calling previous-buffer on a window does not update the buffer-list so it breaks the function.
How do make it so previous-buffer updates buffer-list?
I have the following lisp function that toggles to eshell with current directory set to the file I am viewing and from eshell back to the previous file.
(defun eshell-here () "Go to eshell and set current directory to the buffer's directory. If already on eshell, go to last buffer" (interactive) (if (equal major-mode 'eshell-mode) (switch-to-buffer (other-buffer (current-buffer) nil)) (let ((dir (file-name-directory (or (buffer-file-name) default-directory)))) (eshell) (if (not (equal (expand-file-name (concat (eshell/pwd) "/")) (expand-file-name dir))) (progn (eshell/pushd ".") (cd dir) (goto-char (point-max)) (eshell-kill-input) (eshell-send-input)))))) (global-set-key (kbd "<f1>") 'eshell-here)
The call to other-buffer relies on the most recently viewed buffer which is stored in the buffer-list.
previous-buffer and next-buffer does not update the buffer-list so I lose the ability to get back to the file I was viewing from eshell.
The solution I have come up with is to call switch-to-buffer after previous-buffer/next-buffer to indirectly update the buffer list.
Do you think there is a better solution?