unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Eli Zaretskii <eliz@gnu.org>
Cc: help-gnu-emacs@gnu.org
Subject: Re: How to persist registers across sessions?
Date: Fri, 1 Jul 2022 10:03:13 +0300	[thread overview]
Message-ID: <Yr6cMeXyQtrcQ+B7@protected.localdomain> (raw)
In-Reply-To: <83zghte5gl.fsf@gnu.org>

* 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/



  reply	other threads:[~2022-07-01  7:03 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-27  3:24 How to persist registers across sessions? Pankaj Jangid
2022-06-27 12:01 ` Michael Heerdegen
2022-06-28 18:03 ` Jean Louis
2022-06-29 15:35 ` Visuwesh
2022-06-30 12:50   ` Jean Louis
2022-06-30 13:55     ` Michael Heerdegen
2022-06-30 14:00     ` Eli Zaretskii
2022-06-30 14:23       ` Michael Heerdegen
2022-06-30 15:50         ` Eli Zaretskii
2022-06-30 14:33       ` Jean Louis
2022-06-30 16:01         ` Eli Zaretskii
2022-06-30 21:55           ` Jean Louis
2022-07-01  6:02             ` Eli Zaretskii
2022-07-01  7:03               ` Jean Louis [this message]
2022-07-01  7:19                 ` Eli Zaretskii
2022-07-01 12:27                   ` Jean Louis
2022-07-02  5:54                     ` Eli Zaretskii
2022-07-02  8:46                       ` Jean Louis
2022-07-02  9:04                         ` Eli Zaretskii
2022-07-02 17:19                           ` Jean Louis
2022-07-02 17:40                             ` Eli Zaretskii
2022-07-02 18:03                               ` Jean Louis
2022-07-02 18:42                                 ` Eli Zaretskii
2022-07-02 18:52                                   ` Jean Louis
2022-07-03  5:02                                     ` Eli Zaretskii
2022-07-01 14:29                 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-07-01 16:07                 ` [External] : " Drew Adams
2022-07-02 11:00       ` Pankaj Jangid
2022-07-02 11:48         ` Eli Zaretskii
2022-07-04  3:26           ` Pankaj Jangid

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yr6cMeXyQtrcQ+B7@protected.localdomain \
    --to=bugs@gnu.support \
    --cc=eliz@gnu.org \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).