0

Can I let-bind diplayed windows and their size/posizion? Is there a variable that stores these infos?

I need to run a script that will change the diplayed windows, opening some help temp buffers. At the end of the script I'd like to restore the starting layout (displayed windows and their size/posizion).

Edit. Finally I found that current-frame-configuration/set-frame-configuration is what I need,

Gabriele Nicolardi
  • 1,199
  • 8
  • 17
  • 1
    See the section of the manual describing `set-window-configuration`, `current-window-configuration`, etc.: https://www.gnu.org/software/emacs/manual/html_node/elisp/Window-Configurations.html See also the section of the manual describing saving window configurations to the register: https://www.gnu.org/software/emacs/manual/html_node/emacs/Configuration-Registers.html Odds are that there are similar and perhaps even duplicate threads regarding these issues ..., but I haven't done any Googling in that regard. – lawlist Feb 07 '21 at 00:03
  • What @lawlist said. And yes, you can let-bind a variable whose value is a window config. – Drew Feb 07 '21 at 01:08
  • @lawlist I googled and searched for this info but I was not able to find it. I still think that the manual lacks of pratical examples. But that's my opinion and maybe this is not hte case. – Gabriele Nicolardi Feb 07 '21 at 10:05

1 Answers1

1

In the manual, browse through the top level table of content. You're interested in windows, so go to the chapter on windows. Browse through its table of contents until you find “Saving and restoring the state of the screen”, which is the section window configurations. Now you know how Emacs calls what you're looking for and you know what functions are available.

(save-window-excursion
  ;; your code goes here
  )

Furthermore, as noted in the documentation, there's a related macro save-selected-window with similar usage but which does something slightly different.

(save-selected-window
  ;; your code goes here
  )

save-window-excursion saves the exact window arrangement (sizes, positions, displayed buffer) of the current frame only. save-selected-window does not save window arrangements, but remembers which window is selected in each frame. Given what you want to do, which involves displaying (and therefore making room for) extra windows, I think save-window-excursion is the right one.