Emacs: Is it possible to install one specific window, which will always be used as a "different window"?

There are many useful emacs commands that do things in a "different window" (for example, Cx Cb to view a list of buffers or Ch a to view available commands or many others).

My problem. This does not seem to work very well using several carefully organized windows in a single frame, each of which shows specific content.

At any time when I use one of these “other window” commands, it replaces the contents of some other window, which (1) may be too narrow to clearly display the displayed information, and (2) may be required manually "after which will clear it by returning it to the correct buffer. (And you better not check the list of buffers at the same time, otherwise you will ruin another window!)

(Emacs does not always use the same “different window” even when commands are issued from one window. For example, Cx Cb output can go to one “different” window, and Ch a shows it leads to another “different” window. Similarly, CMv sometimes scrolls another “different” window from the one in which the output just appeared.)

I need a way to solve or work around this problem, for example:

  • I would very much like to indicate a specific window, which should always be used as a "different window" for any window in this frame.

  • Otherwise, there may be a way to change the order of the window and / or use invisible windows (if any) to get the effect of solution 1 by doing a lot of window shuffling frame by frame, you may need an additional command to enter before or preferably after the command that recorded in the "other window".

  • Otherwise, I need a command that undoes the most recent buffer change in any window, so any window used will return to what it showed before it was used.

(I am currently using workgroups.el, and I am using a separate workgroup to check the documentation, but this is clearly suboptimal. "Updating" the workgroup does not reach solution 3, as it seems to only return the buffer back if it was normal file.)

EDIT: I see this question is very similar to this similar question , but this question did not get the answer it was looking for. Since the ideal solution may not exist, I am also clearly interested in workarounds.

+5
source share
3 answers

Otherwise, I need a command that undoes the most recent buffer change in any window, so any used window goes back to what it showed before it was used.

A possible solution is to use winner-mode . Activate it by adding

 (winner-mode 1) 

It provides two commands, winner-undo and winner-redo , which undo and restore window configurations accordingly.

Also, since you specify workgroups.el , try workgroups2 , fork workgroups.el. It provides similar commands ( wg-undo-wconfig-change and wg-redo-wconfig-change ) to restore window configurations

+2
source

All people will disagree with my answer. But someone might think this is productive.

Make all one window per frame.

 ;;Disable split-window (defun split-window-below () (interactive) ;;do nothing ) (defun split-window-right () (interactive) ;;do nothing ) 

Then you can no longer split the window. If you need to display a different buffer, use a different frame ( Cx 5 2 ).

0
source

The solution for No. 1 came to me last week. The idea is to select all the windows, but your concern. This way you can lock the window. That sounds a bit opposite.

 (defvar window-locked-p nil) (defun lockon-window () "Set a target window to be used when calls `other-window'. To set the target window, first put point to the window, then call this. Technically this sets all window dedicated but the target window. Call again to free windows." (interactive) (walk-windows (lambda (win) (set-window-dedicated-p win (not window-locked-p)))) (if window-locked-p (message "All windows are free") (set-window-dedicated-p (selected-window) nil) (message "Window is locked on")) (setq window-locked-p (not window-locked-p))) 

The solution for No. 3 came to me when I listened to Stevie Ray Vaughan's Slide Street and Double Problem. The popup buffer is located at the same level as the other buffers.

 (winner-mode 1) (defun slide-window () "This slides a buffer, in an unexpected window, to next-window. Call this with point on the window. This only works soon after a buffer was popped by `other-window' to an unexpected window. Technically this recalls previous buffer-set by (winner-undo) then shows the buffer to next-window. This is complementary to `lockon-window'." (interactive) (let ((buf (buffer-name))) (winner-undo) (set-window-buffer (next-window) buf) (message "Window is slided") (other-window 1))) 
0
source

Source: https://habr.com/ru/post/956289/


All Articles