I want to move the point to the end of a window using elisp. The following code snippet:
(set-buffer "buffer-name")
(goto-char (point-min))
does not visually change the location of the cursor on the window visiting the buffer "buffer-name". This is because windows and buffers are separate concepts.
I found the function set-window-point
documented at https://www.gnu.org/software/emacs/manual/html_node/elisp/Window-Point.html, but I am not able to use it. Its signature is:
set-window-point window position
What does the first argument, window
mean?
I tried running the command (set-window-point "buffer-name" (point-min))
, but it returns the error Wrong type argument: window-live-p, "buffer-name"
, which I guess, means that the window named "buffer-name" is not showing on the screen.
Purpose: I have multiple eshell
windows on the screen that are logged in via ssh
to remote machines and I have written an elisp function to run a single command on all the eshell buffers. I am able to run the command, but can't see the output because the windows do not auto-scroll. I have to switch to the windows and scroll down.
eshell-scroll-to-bottom-on-output
toall
?The default for window is the selected window.
default means if you providenil
as argument.eshell-scroll-to-bottom-on-output
toall
solves the problem. Also, I didn't know that providingnil
will pass the default argument. That works too.nil
inset-window-point
means that the current (selected) window will be used, even if it doesn't display the current buffer (as set e.g. byset-buffer
). As you found out yourself, usingget-buffer-window
will return an actual window displaying the given buffer (There might be others, the whole list can be obtaid viaget-buffer-window-list
).