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,

3
  • 1
    See the section of the manual describing set-window-configuration, current-window-configuration, etc.: gnu.org/software/emacs/manual/html_node/elisp/… See also the section of the manual describing saving window configurations to the register: gnu.org/software/emacs/manual/html_node/emacs/… 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 7 at 0:03
  • What @lawlist said. And yes, you can let-bind a variable whose value is a window config. – Drew Feb 7 at 1: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 7 at 10:05
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.

2
  • Ok, thanks! I was sure I searched for the windows stuff in the manual. Anyway, save.window-escursion is what I was searching for. – Gabriele Nicolardi Feb 7 at 15:50
  • Finally I found that current-frame-configuration/set-frame-configuration is what I need, – Gabriele Nicolardi Feb 7 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.