[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to persist registers across sessions?
From: |
Jean Louis |
Subject: |
Re: How to persist registers across sessions? |
Date: |
Fri, 1 Jul 2022 10:03:13 +0300 |
User-agent: |
Mutt/+ () (2022-05-21) |
* Eli Zaretskii <eliz@gnu.org> [2022-07-01 09:03]:
> > Date: Fri, 1 Jul 2022 00:55:42 +0300
> > From: Jean Louis <bugs@gnu.support>
> > Cc: help-gnu-emacs@gnu.org
> >
> > Can you in parallel with that good idea, give some clue how to obtain
> > window configuration as lisp object?
>
> People already told you: current-window-configuration does that.
If I wish to get Lisp object of window configuration I get some result which
does not give data:
(current-window-configuration) ⇒ #<window-configuration>
and no matter if I have 3 windows, I get same result:
(current-window-configuration) ⇒ #<window-configuration>
I think this is function which should do that:
The objects returned by ‘current-window-configuration’ die together
with the Emacs process. In order to store a window configuration on
disk and read it back in another Emacs session, you can use the
functions described next. These functions are also useful to clone the
state of a frame into an arbitrary live window
(‘set-window-configuration’ effectively clones the windows of a frame
into the root window of that very frame only).
-- Function: window-state-get &optional window writable
This function returns the state of WINDOW as a Lisp object. The
argument WINDOW must be a valid window and defaults to the root
window of the selected frame.
If the optional argument WRITABLE is non-‘nil’, this means to not
use markers for sampling positions like ‘window-point’ or
‘window-start’. This argument should be non-‘nil’ when the state
will be written to disk and read back in another session.
Together, the argument WRITABLE and the variable
‘window-persistent-parameters’ specify which window parameters are
saved by this function. *Note Window Parameters::.
So I try this way:
(prin1-to-string (window-state-get (get-buffer-window))) ⇒ "(((min-height . 4)
(min-width . 10) (min-height-ignore . 3) (min-width-ignore . 6)
(min-height-safe . 1) (min-width-safe . 2) (min-pixel-height . 76)
(min-pixel-width . 100) (min-pixel-height-ignore . 57) (min-pixel-width-ignore
. 60) (min-pixel-height-safe . 19) (min-pixel-width-safe . 20)) leaf
(pixel-width . 1592) (pixel-height . 779) (total-width . 159) (total-height .
41) (normal-height . 1.0) (normal-width . 1.0) (parameters (clone-of . #<window
2515 on mutt-protected-1001-4153-16793396821956371330>)) (buffer #<buffer
mutt-protected-1001-4153-16793396821956371330> (selected . t) (hscroll . 0)
(fringes 8 8 nil nil) (margins nil) (scroll-bars nil 2 t nil 0 t nil) (vscroll
. 0) (dedicated) (point . #<marker at 1892 in
mutt-protected-1001-4153-16793396821956371330>) (start . #<marker at 1065 in
mutt-protected-1001-4153-16793396821956371330>)) (prev-buffers (#<buffer
mutt-protected-1001-4153-16793396821956371330> #<marker at 1 in
mutt-protected-1001-4153-16793396821956371330> #<marker at 2287 in
mutt-protected-1001-4153-16793396821956371330>) (#<buffer Downloads> #<marker
at 1164 in Downloads> #<marker at 1715 in Downloads>)))"
But I cannot read it back:
(read-from-string (prin1-to-string (window-state-get (get-buffer-window)))) as
I get error:
Debugger entered--Lisp error: (invalid-read-syntax "#")
read-from-string("(((min-height . 4) (min-width . 10) (min-height-ig...")
(progn (read-from-string (prin1-to-string (window-state-get
(get-buffer-window)))))
eval((progn (read-from-string (prin1-to-string (window-state-get
(get-buffer-window))))) t)
elisp--eval-last-sexp(nil)
eval-last-sexp(nil)
funcall-interactively(eval-last-sexp nil)
call-interactively(eval-last-sexp nil nil)
command-execute(eval-last-sexp)
How would I read it back properly?
> Another possibility is to use frameset-save. (Not surprisingly,
> desktop.el already uses it.)
I have been testing, I see the output of below command, and it looks
like it does what it says, saving frameset.
(frameset-save (frame-list))
It should be possible to "read" back from there:
(read-from-string (prin1-to-string (frameset-save (frame-list))))
However, I get this error:
eval: Invalid read syntax: "#" probably because somewhere inside I find this:
(hywconfig-names (\"new1\" . #<window-configuration>)
Thus I think that (frameset-save (frame-list)) cannot reliably
produce Lisp object that I can read back if there is
#<window-configuration> somewhere inside, as such is not readable.
However, frame set is not what I meant, as it also contains many
variables and what other not necessary information.
I meant window set, not a frame set.
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
- Re: How to persist registers across sessions?, Eli Zaretskii, 2022/07/01
- Re: How to persist registers across sessions?,
Jean Louis <=
- Re: How to persist registers across sessions?, Eli Zaretskii, 2022/07/01
- Re: How to persist registers across sessions?, Jean Louis, 2022/07/01
- Re: How to persist registers across sessions?, Eli Zaretskii, 2022/07/02
- Re: How to persist registers across sessions?, Jean Louis, 2022/07/02
- Re: How to persist registers across sessions?, Eli Zaretskii, 2022/07/02
- Re: How to persist registers across sessions?, Jean Louis, 2022/07/02
- Re: How to persist registers across sessions?, Eli Zaretskii, 2022/07/02
- Re: How to persist registers across sessions?, Jean Louis, 2022/07/02
- Re: How to persist registers across sessions?, Eli Zaretskii, 2022/07/02
- Re: How to persist registers across sessions?, Jean Louis, 2022/07/02