unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to persist registers across sessions?
@ 2022-06-27  3:24 Pankaj Jangid
  2022-06-27 12:01 ` Michael Heerdegen
                   ` (2 more replies)
  0 siblings, 3 replies; 30+ messages in thread
From: Pankaj Jangid @ 2022-06-27  3:24 UTC (permalink / raw)
  To: help-gnu-emacs

Especially, I want to save a particular window configuration for a
project that I am working on. Then when I switch project, I want use a
different window configuration.

Is there a way to save the window configuration to use across Emacs
sessions?




^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  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
  2 siblings, 0 replies; 30+ messages in thread
From: Michael Heerdegen @ 2022-06-27 12:01 UTC (permalink / raw)
  To: help-gnu-emacs

Pankaj Jangid <pankaj@codeisgreat.org> writes:

> Is there a way to save the window configuration to use across Emacs
> sessions?

I dunno - could be there is none directly.  If not you might need to
pick pieces together from desktop.el and frameset.el, e.g. as a start
try

#+begin_src emacs-lisp
(progn
  (defvar saved)
  (let ((saved (frameset-save (list (selected-frame))
			      :app desktop--app-id
			      :name (concat user-login-name "@" (system-name))
			      :predicate #'desktop--check-dont-save)))
    (desktop-outvar 'saved)))
#+end_src

Evaluating this will insert a readable expression that describes the
layout of the selected frame into the current buffer.

Michael.




^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  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
  2 siblings, 0 replies; 30+ messages in thread
From: Jean Louis @ 2022-06-28 18:03 UTC (permalink / raw)
  To: help-gnu-emacs

* Pankaj Jangid <pankaj@codeisgreat.org> [2022-06-27 06:25]:
> Especially, I want to save a particular window configuration for a
> project that I am working on. Then when I switch project, I want use a
> different window configuration.
> 
> Is there a way to save the window configuration to use across Emacs
> sessions?

https://melpa.org/packages/session-20120511.0.el

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  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
  2 siblings, 1 reply; 30+ messages in thread
From: Visuwesh @ 2022-06-29 15:35 UTC (permalink / raw)
  To: help-gnu-emacs

[திங்கள் ஜூன் 27, 2022] Pankaj Jangid wrote:

> Especially, I want to save a particular window configuration for a
> project that I am working on. Then when I switch project, I want use a
> different window configuration.
>
> Is there a way to save the window configuration to use across Emacs
> sessions?

I know of at least three packages that do this or something very
similar:

    1. project-x: https://github.com/karthink/project-x
    2. Burly: https://github.com/alphapapa/burly.el
    3. bookmark-view: https://github.com/minad/bookmark-view

There's also the builtin desktop.el library.

HTH.



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  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
  0 siblings, 2 replies; 30+ messages in thread
From: Jean Louis @ 2022-06-30 12:50 UTC (permalink / raw)
  To: Visuwesh; +Cc: help-gnu-emacs

If somebody tells me how to `read' window configuration then I can
provide function to save and load it.

However, I do not know how to save/read #<window-configuration> as
object

It looks like this:
(current-window-configuration) ⇒ #<window-configuration>

That is not enough data. 

For example in my window configuration I have 2 windows, but data I
get from register is just this:

(get-register (read-key "Key: ")) ⇒ (#<window-configuration> #<marker at 1921 in *helm-system-packages-eshell*>)

Data shows only one window buffer, not the other one, while I have
saved window configuration of two buffers.

How do I get full data of window configuration?

Manual says:
============

,----
| 2.5.6 Window Configuration Type
| -------------------------------
| 
| A “window configuration” stores information about the positions, sizes,
| and contents of the windows in a frame, so you can recreate the same
| arrangement of windows later.
| 
|    Window configurations do not have a read syntax; their print syntax
| looks like ‘#<window-configuration>’.  *Note Window Configurations::,
| for a description of several functions related to window configurations.
`----

And I am worried if it does not have "read syntax" then how do I save
it and load it? Is that some data so internal that user cannot access
it?

More from manual:
=================

,----
|    Other primitives to look inside of window configurations would make
| sense, but are not implemented because we did not need them.  See the
| file ‘winner.el’ for some more operations on windows configurations.
`----

So you did not need them, alright, but some people obviously would
need them. If it would make sense then people will need it. Subjective
anonymous comments do not really belong to professional Emacs Lisp
manual.

Anyway this function is key to reading and saving window configuration, but I do not know how to access the window configuration.

(window-state-get (get-register (read-key "Key: ")))

Error I get is:
===============

window-state-get: (#<window-configuration> #<marker at 538029 in file.org>) is not a live or internal window

Function description:

   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::.

If somebody can help me get the Lisp object for window
configuration from register then it will be easy to save it.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  2022-06-30 12:50   ` Jean Louis
@ 2022-06-30 13:55     ` Michael Heerdegen
  2022-06-30 14:00     ` Eli Zaretskii
  1 sibling, 0 replies; 30+ messages in thread
From: Michael Heerdegen @ 2022-06-30 13:55 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis <bugs@gnu.support> writes:

> How do I get full data of window configuration?

I had tried to give a start in message <875ykmz56q.fsf@web.de> in this
thread.

Michael.




^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  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
                         ` (2 more replies)
  1 sibling, 3 replies; 30+ messages in thread
From: Eli Zaretskii @ 2022-06-30 14:00 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Thu, 30 Jun 2022 15:50:36 +0300
> From: Jean Louis <bugs@gnu.support>
> Cc: help-gnu-emacs@gnu.org
> 
> If somebody tells me how to `read' window configuration then I can
> provide function to save and load it.
> 
> However, I do not know how to save/read #<window-configuration> as
> object
> 
> It looks like this:
> (current-window-configuration) ⇒ #<window-configuration>
> 
> That is not enough data. 

Any reason you are insisting on reinventing the wheel, when we already
have desktop.el?  It does all that, and is ready to be used (I use it
all the time).

Is anything wrong with using desktop-save-mode?



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  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-07-02 11:00       ` Pankaj Jangid
  2 siblings, 1 reply; 30+ messages in thread
From: Michael Heerdegen @ 2022-06-30 14:23 UTC (permalink / raw)
  To: help-gnu-emacs

Eli Zaretskii <eliz@gnu.org> writes:

> Is anything wrong with using desktop-save-mode?

I thought it was not able to save a window configuration of one single
frame...or is it?

Michael.




^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  2022-06-30 14:00     ` Eli Zaretskii
  2022-06-30 14:23       ` Michael Heerdegen
@ 2022-06-30 14:33       ` Jean Louis
  2022-06-30 16:01         ` Eli Zaretskii
  2022-07-02 11:00       ` Pankaj Jangid
  2 siblings, 1 reply; 30+ messages in thread
From: Jean Louis @ 2022-06-30 14:33 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

* Eli Zaretskii <eliz@gnu.org> [2022-06-30 17:02]:
> > Date: Thu, 30 Jun 2022 15:50:36 +0300
> > From: Jean Louis <bugs@gnu.support>
> > Cc: help-gnu-emacs@gnu.org
> > 
> > If somebody tells me how to `read' window configuration then I can
> > provide function to save and load it.
> > 
> > However, I do not know how to save/read #<window-configuration> as
> > object
> > 
> > It looks like this:
> > (current-window-configuration) ⇒ #<window-configuration>
> > 
> > That is not enough data. 
> 
> Any reason you are insisting on reinventing the wheel, when we already
> have desktop.el?  It does all that, and is ready to be used (I use it
> all the time).
> 
> Is anything wrong with using desktop-save-mode?

For me that is so little useful. Imagine having 2-3 windows and
particular flow, but also other 100 buffers. User may wish to save
that visible window configuration and not all of the buffers
available inside of Emacs.

I would not call it reinventing the wheel as desktop-save is so much
complex in its operation. I do not use it for that reason. 

Saving just few files related to windows on screen and the register of
its configuration could be simplifying solution.

Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/




^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  2022-06-30 14:23       ` Michael Heerdegen
@ 2022-06-30 15:50         ` Eli Zaretskii
  0 siblings, 0 replies; 30+ messages in thread
From: Eli Zaretskii @ 2022-06-30 15:50 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Michael Heerdegen <michael_heerdegen@web.de>
> Date: Thu, 30 Jun 2022 16:23:29 +0200
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > Is anything wrong with using desktop-save-mode?
> 
> I thought it was not able to save a window configuration of one single
> frame...or is it?

It saves (and can later restore) the configuration of all the frames
that exist in the session.  But if for some reason there's a need to
save just one frame, it should much easier to extend desktop.el to do
that than reinvent this wheel from scratch.




^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  2022-06-30 14:33       ` Jean Louis
@ 2022-06-30 16:01         ` Eli Zaretskii
  2022-06-30 21:55           ` Jean Louis
  0 siblings, 1 reply; 30+ messages in thread
From: Eli Zaretskii @ 2022-06-30 16:01 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Thu, 30 Jun 2022 17:33:47 +0300
> From: Jean Louis <bugs@gnu.support>
> Cc: help-gnu-emacs@gnu.org
> 
> > Is anything wrong with using desktop-save-mode?
> 
> For me that is so little useful. Imagine having 2-3 windows and
> particular flow, but also other 100 buffers. User may wish to save
> that visible window configuration and not all of the buffers
> available inside of Emacs.

Knock yourself out, if you want, but I think you underestimate the
problem before you.  E.g., how can you save just the window
configuration without also saving which files were visited by each of
the window, where was the point in each buffer, what were your local
variables and minor modes, perhaps the mark position in each buffer,
maybe the last search string etc.?  desktop.el has all of that already
figured out, and gives you useful customization variables to decide
what you'd like to save/restore.

> desktop-save is so much complex in its operation. I do not use it
> for that reason.

I wonder why it matters how complex the software is if it does the
job.  Emacs itself is orders of magnitude more complex than
desktop.el, but you still use it to your benefit, as do I and everyone
else on this list.



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  2022-06-30 16:01         ` Eli Zaretskii
@ 2022-06-30 21:55           ` Jean Louis
  2022-07-01  6:02             ` Eli Zaretskii
  0 siblings, 1 reply; 30+ messages in thread
From: Jean Louis @ 2022-06-30 21:55 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

* Eli Zaretskii <eliz@gnu.org> [2022-06-30 19:06]:
> Knock yourself out, if you want, but I think you underestimate the
> problem before you.  E.g., how can you save just the window
> configuration without also saving which files were visited by each of
> the window, where was the point in each buffer, what were your local
> variables and minor modes, perhaps the mark position in each buffer,
> maybe the last search string etc.?  desktop.el has all of that already
> figured out, and gives you useful customization variables to decide
> what you'd like to save/restore.

That is good to extend desktop.el

Can you in parallel with that good idea, give some clue how to obtain
window configuration as lisp object?

Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  2022-06-30 21:55           ` Jean Louis
@ 2022-07-01  6:02             ` Eli Zaretskii
  2022-07-01  7:03               ` Jean Louis
  0 siblings, 1 reply; 30+ messages in thread
From: Eli Zaretskii @ 2022-07-01  6:02 UTC (permalink / raw)
  To: help-gnu-emacs

> 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.

Another possibility is to use frameset-save.  (Not surprisingly,
desktop.el already uses it.)



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  2022-07-01  6:02             ` Eli Zaretskii
@ 2022-07-01  7:03               ` Jean Louis
  2022-07-01  7:19                 ` Eli Zaretskii
                                   ` (2 more replies)
  0 siblings, 3 replies; 30+ messages in thread
From: Jean Louis @ 2022-07-01  7:03 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

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



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  2022-07-01  7:03               ` Jean Louis
@ 2022-07-01  7:19                 ` Eli Zaretskii
  2022-07-01 12:27                   ` Jean Louis
  2022-07-01 14:29                 ` Stefan Monnier via Users list for the GNU Emacs text editor
  2022-07-01 16:07                 ` [External] : " Drew Adams
  2 siblings, 1 reply; 30+ messages in thread
From: Eli Zaretskii @ 2022-07-01  7:19 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Fri, 1 Jul 2022 10:03:13 +0300
> From: Jean Louis <bugs@gnu.support>
> Cc: help-gnu-emacs@gnu.org
> 
> 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:

I don't think you described what exactly you'd like to do with the
window config information.  So the answers you get don't satisfy your
needs, because you didn't describe those needs in sufficient detail.

> > 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:

If you want to restore the configuration recorded by frameset-save,
you should use frameset-restore.

> 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.

Windows belong to frames.  Any window-configuration data is
meaningless without the corresponding frame data.



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  2022-07-01  7:19                 ` Eli Zaretskii
@ 2022-07-01 12:27                   ` Jean Louis
  2022-07-02  5:54                     ` Eli Zaretskii
  0 siblings, 1 reply; 30+ messages in thread
From: Jean Louis @ 2022-07-01 12:27 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

* Eli Zaretskii <eliz@gnu.org> [2022-07-01 10:20]:
> I don't think you described what exactly you'd like to do with the
> window config information.  So the answers you get don't satisfy your
> needs, because you didn't describe those needs in sufficient detail.

I wish to save window configuration as Lisp object. I wish to be able
to transform window configuration by using prin1-to-string so that I
can later read-from-string and store it back to register.


Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  2022-07-01  7:03               ` Jean Louis
  2022-07-01  7:19                 ` 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
  2 siblings, 0 replies; 30+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2022-07-01 14:29 UTC (permalink / raw)
  To: help-gnu-emacs

>> 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.

I think that's why you'd be better off trying to use the `desktop.el`
code, which has already worked through those problems.
Then again, maybe `desktop.el` suffers from the same problem, of course.


        Stefan




^ permalink raw reply	[flat|nested] 30+ messages in thread

* RE: [External] : Re: How to persist registers across sessions?
  2022-07-01  7:03               ` Jean Louis
  2022-07-01  7:19                 ` Eli Zaretskii
  2022-07-01 14:29                 ` Stefan Monnier via Users list for the GNU Emacs text editor
@ 2022-07-01 16:07                 ` Drew Adams
  2 siblings, 0 replies; 30+ messages in thread
From: Drew Adams @ 2022-07-01 16:07 UTC (permalink / raw)
  To: Jean Louis; +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))) ⇒ "...
> (parameters (clone-of . #<window 2515 on mutt-protected-1001-4153-
> 16793396821956371330>)) (buffer #<buffer mutt-protected-1001-4153-
> 16793396821956371330> ... (point . #<marker at 1892 in...>) ..."
> 
> 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 "#")


FYI: from bug #14964, this message:

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=14964

  We have `window-state-(get|put)', but I would also like
  to see Lisp-readable window configurations.  IOW, wrap
  with (window-configuration...) what `window-state-get'
  with non-nil WRITABLE arg returns.  E.g.:

  (window-configuration
    (((min-height . 4)
      (min-width . 10)
      (min-height-ignore . 2)
      (min-width-ignore . 5)
      (min-height-safe . 1)
      (min-width-safe . 2))
     leaf
     (last . t)
     (total-height . 63)
     (total-width . 112)
     (normal-height . 1.0)
     (normal-width . 1.0)
     (buffer "foobar.el"
             (selected . t)
             (hscroll . 0)
             (fringes 0 0 nil)
             (margins nil)
             (scroll-bars 21 3 t nil)
             (vscroll . 0)
             (dedicated)
             (point . 426354)
             (start . 424331))))

And from this message:

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=14964#23

  The form of the result would be similar to the non Lisp-readable frame
  config: a list with `frame-configuration' as car, a nil FRAME as cadr
  (for example), an ALIST of the traditional or standard frame parameters
  (i.e., the same ones), and a readable version of the frame's window
  configuration.

  That would (if we think it is important to separate these) be followed
  by any additional frame parameters that are not recorded for the non
  Lisp-readable frame config.  Or alternatively, if it is not important to
  keep those separate (identifiable as such), then just include them in
  ALIST.  If all recorded frame parameters are in ALIST, then the only
  differences from a non-readable frame config are (a) a nil FRAME (or
  some other convention for FRAME) and (b) the fact that each component
  is readable.

  ... an optional parameter 'WRITABLE, for instance, similar to what
  Martin did for `window-state-get'.  (WRITABLE is actually READABLE,
  in my book, but either name is OK.)

  ... the `window-state-*' functions do not explicitly provide for
  readable window configurations.  Consider something like this, for
  example:

  (defun readable-window-config (window-configuration)
    "Return a Lisp-readable representation of WINDOW-CONFIGURATION.
  The form is (window-configuration FRAME-NAME . ROOT-WINDOW-STATE)."
    ;; Record the name of the frame and its root window state.
    (let ((winfr  (window-configuration-frame window-configuration)))
      `(window-configuration
        ,(frame-parameter winfr 'name)
        . ,(window-state-get (frame-root-window winfr) 'WRITABLE))))

  Just one possibility, as an illustration of what I mean.

  ... the point is to have a standard structure that code can use and
  manipulate.  That is already the case currently, with the exception
  that the structure components are not readable/writable.

  ... In sum, provide alternative, Lisp-readable representations of
  both frame configs and window configs, and update the functions
  that use/create such configs to also use/create the readable form
  (creating a readable config would be optional via an optional
  `WRITABLE parameter)....

  (defun readable-frame (frame)
    "Return a Lisp-readable representation of FRAME.
  Form is (frame . FRAME-PARAMETERS)."
      `(frame . ,(desktop--filter-frame-parms (frame-parameters frame) t)))

  Probably if we did that then we would want to let you specify the
  frame parameters to record via one or more parameters to the function
  rather than using `desktop--filter-frame-parms' inside the function body.

  And for a readable window also, we might want to have a (window...)
  structure (list), which would just involve putting a wrapper around
  what is already provided by `window-state-get' (with non-nil WRITABLE).

This message talks about "workgroups":

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=14964#29

And there's a lot more food for thought in that bug thread.



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  2022-07-01 12:27                   ` Jean Louis
@ 2022-07-02  5:54                     ` Eli Zaretskii
  2022-07-02  8:46                       ` Jean Louis
  0 siblings, 1 reply; 30+ messages in thread
From: Eli Zaretskii @ 2022-07-02  5:54 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Fri, 1 Jul 2022 15:27:20 +0300
> From: Jean Louis <bugs@gnu.support>
> Cc: help-gnu-emacs@gnu.org
> 
> * Eli Zaretskii <eliz@gnu.org> [2022-07-01 10:20]:
> > I don't think you described what exactly you'd like to do with the
> > window config information.  So the answers you get don't satisfy your
> > needs, because you didn't describe those needs in sufficient detail.
> 
> I wish to save window configuration as Lisp object. I wish to be able
> to transform window configuration by using prin1-to-string so that I
> can later read-from-string and store it back to register.

For what purpose? how would you like to use the stored Lisp object in
your Emacs sessions?



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  2022-07-02  5:54                     ` Eli Zaretskii
@ 2022-07-02  8:46                       ` Jean Louis
  2022-07-02  9:04                         ` Eli Zaretskii
  0 siblings, 1 reply; 30+ messages in thread
From: Jean Louis @ 2022-07-02  8:46 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

* Eli Zaretskii <eliz@gnu.org> [2022-07-02 08:55]:
> > Date: Fri, 1 Jul 2022 15:27:20 +0300
> > From: Jean Louis <bugs@gnu.support>
> > Cc: help-gnu-emacs@gnu.org
> > 
> > * Eli Zaretskii <eliz@gnu.org> [2022-07-01 10:20]:
> > > I don't think you described what exactly you'd like to do with the
> > > window config information.  So the answers you get don't satisfy your
> > > needs, because you didn't describe those needs in sufficient detail.
> > 
> > I wish to save window configuration as Lisp object. I wish to be able
> > to transform window configuration by using prin1-to-string so that I
> > can later read-from-string and store it back to register.
> 
> For what purpose? how would you like to use the stored Lisp object in
> your Emacs sessions?

I am Hyperbole user so this is how I store within session a named
window configuration: {C-h h w a My-Conf RET} and this is how I
restore it {C-h h w r My-Conf RET}, and it does not last over
sessions. There is plan by Hyperbole author to make it.

Compare that flow to desktop.el and you will understand that there is
speed and efficiency in saving window configuration and restoring
it. There can be multiple window configurations. With few keys I may
get access to it.

However, all what I can see in there is #<window-configuration> so I
do not know how to get Lisp data where it will be said which window
belongs to which file, and how windows are split. That is why I am
asking you about it. 

Maybe such Lisp data about window configuration does not exist.

In desktop.el I can see that it generates lisp as string pieces to
write it to desktop.el and I would prefer not that but Lisp data.

Purpose is to isolate that information and become able to store it on
file or inside of the database, so that I can use a key to set some of
preset window configurations from session to session and in quick
manner.

Desktop.el saves everything, and offers directory to user to save
it. Saving hundreds of buffers takes long time and loading desktop
again simply does not work on my side. My buffers are many, like now
there is 795 buffers. Then it starts first that I have to confirm
variables, then I see million messages how some directories do not
exist as Dired was accessing mounted disks, it really takes long
time. From 795 buffers, I get 294 buffers.

It is definitely NOT that what I want, it is not practical.

What I want is:

1) Having 3-5 buffers in specific window configuration. Regardless of
   other buffers, I wish to be able to restore such window
   configuration. 

2) Having possibility to save multiple such window configurations and
   quickly with minimum keys or with menu get access to it.

If at least I get clue how to get the split parameters of a frame,
modes, its sizes of windows, as Lisp data, then I would be fine with
it, and then I can myself assign something to those buffers. My
buffers are too often buffers related to database, table, column and
ID and do not have files attached.

Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/








^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  2022-07-02  8:46                       ` Jean Louis
@ 2022-07-02  9:04                         ` Eli Zaretskii
  2022-07-02 17:19                           ` Jean Louis
  0 siblings, 1 reply; 30+ messages in thread
From: Eli Zaretskii @ 2022-07-02  9:04 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Sat, 2 Jul 2022 11:46:49 +0300
> From: Jean Louis <bugs@gnu.support>
> Cc: help-gnu-emacs@gnu.org
> 
> Purpose is to isolate that information and become able to store it on
> file or inside of the database, so that I can use a key to set some of
> preset window configurations from session to session and in quick
> manner.

"Use" it how?  To do what with those "preset window configurations"?
That was my question, and you didn't really answer it.

> Desktop.el saves everything, and offers directory to user to save
> it. Saving hundreds of buffers takes long time and loading desktop
> again simply does not work on my side. My buffers are many, like now
> there is 795 buffers. Then it starts first that I have to confirm
> variables, then I see million messages how some directories do not
> exist as Dired was accessing mounted disks, it really takes long
> time. From 795 buffers, I get 294 buffers.
> 
> It is definitely NOT that what I want, it is not practical.
> 
> What I want is:
> 
> 1) Having 3-5 buffers in specific window configuration. Regardless of
>    other buffers, I wish to be able to restore such window
>    configuration. 
> 
> 2) Having possibility to save multiple such window configurations and
>    quickly with minimum keys or with menu get access to it.

I pointed to frameset.el, which is a lower-level infrastructure used
by desktop.el.  It should allow you to save and restore windows of a
single frame, if that suits your needs better.

> If at least I get clue how to get the split parameters of a frame,
> modes, its sizes of windows, as Lisp data, then I would be fine with
> it, and then I can myself assign something to those buffers. My
> buffers are too often buffers related to database, table, column and
> ID and do not have files attached.

The clues, as you were told, are in frameset.el and in desktop.el.  If
their high-level interfaces don't suit your needs, my suggestion would
be to study their implementations, and derive your own code from what
they do.



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  2022-06-30 14:00     ` Eli Zaretskii
  2022-06-30 14:23       ` Michael Heerdegen
  2022-06-30 14:33       ` Jean Louis
@ 2022-07-02 11:00       ` Pankaj Jangid
  2022-07-02 11:48         ` Eli Zaretskii
  2 siblings, 1 reply; 30+ messages in thread
From: Pankaj Jangid @ 2022-07-02 11:00 UTC (permalink / raw)
  To: help-gnu-emacs

Eli Zaretskii <eliz@gnu.org> writes:

> Any reason you are insisting on reinventing the wheel, when we already
> have desktop.el?  It does all that, and is ready to be used (I use it
> all the time).
>
> Is anything wrong with using desktop-save-mode?

I am a user of desktop-save-mode. And I have set desktop-restore-frames
to 't'. But that isn't related to my use-case. As of now what
desktop-restore-frames does is launches Emacs with the same height and
width dimensions apart from loading the same buffers that were open when
I closed Emacs.

Can I do this (below) with desktop-save-mode?

Save window configuration for a project and reload the same window
configuration at will, when I switch to that project.

Michael pointed at some low-level methods that I can use *or* I can use
the packages shared by others. But I still prefer a builtin fascility if
that already exist.




^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  2022-07-02 11:00       ` Pankaj Jangid
@ 2022-07-02 11:48         ` Eli Zaretskii
  2022-07-04  3:26           ` Pankaj Jangid
  0 siblings, 1 reply; 30+ messages in thread
From: Eli Zaretskii @ 2022-07-02 11:48 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Pankaj Jangid <pankaj@codeisgreat.org>
> Date: Sat, 02 Jul 2022 16:30:17 +0530
> 
> Can I do this (below) with desktop-save-mode?
> 
> Save window configuration for a project and reload the same window
> configuration at will, when I switch to that project.

desktop-read is a command, and you can invoke it whenever you want.
So yes, I think you can do this.



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  2022-07-02  9:04                         ` Eli Zaretskii
@ 2022-07-02 17:19                           ` Jean Louis
  2022-07-02 17:40                             ` Eli Zaretskii
  0 siblings, 1 reply; 30+ messages in thread
From: Jean Louis @ 2022-07-02 17:19 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

* Eli Zaretskii <eliz@gnu.org> [2022-07-02 12:05]:
> > Date: Sat, 2 Jul 2022 11:46:49 +0300
> > From: Jean Louis <bugs@gnu.support>
> > Cc: help-gnu-emacs@gnu.org
> > 
> > Purpose is to isolate that information and become able to store it on
> > file or inside of the database, so that I can use a key to set some of
> > preset window configurations from session to session and in quick
> > manner.
> 
> "Use" it how?  To do what with those "preset window configurations"?
> That was my question, and you didn't really answer it.

I would do:

1. Get string of Lisp data by using prin1-to-string

2. Store it in the database or file, but I do not prefer files.

3. In future, choose specific window configuration, or select it, and
   invoke it by loading it from database, or in case of other users from
   file.

It would enable me to have several buffers and workflow in such window
setup that is favorable for work.

> I pointed to frameset.el, which is a lower-level infrastructure used
> by desktop.el.  It should allow you to save and restore windows of a
> single frame, if that suits your needs better.

It looks similar, but I cannot know why it does not work. I get error:

Debugger entered--Lisp error: (error "Undefined color" "unspecified-bg")
  frameset--restore-frame(((minibuffer . t) (display-type . mono)
  (background-mode . dark) (cursor-color . "white")
  (scroll-bar-foreground) (scroll-bar-background)
  (hyperb:window-system) (vertical-scroll-bars) (foreground-color
  . "unspecified-fg") (background-color . "unspecified-bg") (font
  . "tty") (height . 24) (width . 80) (modeline . t) (unsplittable)
  (menu-bar-lines . 1) (tab-bar-lines . 0) (fullscreen . maximized)
  (hywconfig-ring 0 0 . [nil nil nil nil nil nil nil nil nil nil])
  (border-color . "#888a85") (tool-bar-lines . 1) (frameset--id
  . "CD5C-B723-3EA6-2157") (frameset--mini t) (nil)) (((min-height
  . 4) (min-width . 10) (min-height-ignore . 2) (min-width-ignore . 2)
  (min-height-safe . 1) (min-width-safe . 2) (min-pixel-height . 4)
  (min-pixel-width . 10) (min-pixel-height-ignore . 2)
  (min-pixel-width-ignore . 2) (min-pixel-height-safe . 1)
  (min-pixel-width-safe . 2)) leaf (pixel-width . 80) (pixel-height
  . 23) (total-width . 80) (total-height . 23) (normal-height . 1.0)
  (normal-width . 1.0) (buffer "*scratch*" (selected) (hscroll . 0)
  (fringes 0 0 nil nil) (margins nil) (scroll-bars nil 0 t nil 0 t
  nil) (vscroll . 0) (dedicated) (point . 1) (start . 1))) ((tabs
  . frameset-filter-tabs) (background-color
  . frameset-filter-sanitize-color) (bottom
  . frameset-filter-shelve-param) (buffer-list . :never)
  (buffer-predicate . :never) (buried-buffer-list . :never) (client
  . :never) (delete-before . :never) (font
  . frameset-filter-font-param) (font-backend . :never)
  (foreground-color . frameset-filter-sanitize-color)
  (frameset--text-pixel-height . :save) (frameset--text-pixel-width
  . :save) (fullscreen . frameset-filter-shelve-param) (GUI:bottom
  . frameset-filter-unshelve-param) (GUI:font
  . frameset-filter-unshelve-param) (GUI:fullscreen
  . frameset-filter-unshelve-param) (GUI:height
  . frameset-filter-unshelve-param) (GUI:left
  . frameset-filter-unshelve-param) (GUI:right
  . frameset-filter-unshelve-param) (GUI:top
  . frameset-filter-unshelve-param) (GUI:width
  . frameset-filter-unshelve-param) (height
  . frameset-filter-shelve-param) (left
  . frameset-filter-shelve-param) (parent-frame . :never)
  (mouse-wheel-frame . :never) (right . frameset-filter-shelve-param)
  (top . frameset-filter-shelve-param) (tty
  . frameset-filter-tty-to-GUI) (tty-type
  . frameset-filter-tty-to-GUI) (width . frameset-filter-shelve-param)
  (window-system . :never) (left . frameset-filter-iconified)
  (minibuffer . frameset-filter-minibuffer) (top
  . frameset-filter-iconified) (name . :never) (parent-id . :never)
  (window-id . :never) (outer-window-id . :never)) nil 0 0)


This test shall pass, then I know it may read what prin1-to-string
prints:

(read-from-string (prin1-to-string (frameset-save (frame-list))))

Then this is how I think, I may be wrong, how it shall restore itself:

(frameset-restore (car (read-from-string (prin1-to-string
(frameset-save (frame-list))))))

But then I get in same Emacs session this error, and I cannot know if
it is bug or not.

Debugger entered--Lisp error: (error "Undefined color"
"unspecified-bg")

What would be useful is not specification of colors, as I may change
theme and colors, but just window sizes and their buffers and
modes. More than that is only making it more complex and changes
issues.

> > If at least I get clue how to get the split parameters of a frame,
> > modes, its sizes of windows, as Lisp data, then I would be fine with
> > it, and then I can myself assign something to those buffers. My
> > buffers are too often buffers related to database, table, column and
> > ID and do not have files attached.
> 
> The clues, as you were told, are in frameset.el and in desktop.el.  If
> their high-level interfaces don't suit your needs, my suggestion would
> be to study their implementations, and derive your own code from what
> they do.

Then I may assume there is no window configuration Lisp data that may
exist.


Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/




^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  2022-07-02 17:19                           ` Jean Louis
@ 2022-07-02 17:40                             ` Eli Zaretskii
  2022-07-02 18:03                               ` Jean Louis
  0 siblings, 1 reply; 30+ messages in thread
From: Eli Zaretskii @ 2022-07-02 17:40 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Sat, 2 Jul 2022 20:19:51 +0300
> From: Jean Louis <bugs@gnu.support>
> Cc: help-gnu-emacs@gnu.org
> 
> > I pointed to frameset.el, which is a lower-level infrastructure used
> > by desktop.el.  It should allow you to save and restore windows of a
> > single frame, if that suits your needs better.
> 
> It looks similar, but I cannot know why it does not work. I get error:

With what code did you get this error?  It's impossible to tell
anything intelligent without seeing the code you used.



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  2022-07-02 17:40                             ` Eli Zaretskii
@ 2022-07-02 18:03                               ` Jean Louis
  2022-07-02 18:42                                 ` Eli Zaretskii
  0 siblings, 1 reply; 30+ messages in thread
From: Jean Louis @ 2022-07-02 18:03 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs, hyperbole-users

* Eli Zaretskii <eliz@gnu.org> [2022-07-02 20:42]:
> > Date: Sat, 2 Jul 2022 20:19:51 +0300
> > From: Jean Louis <bugs@gnu.support>
> > Cc: help-gnu-emacs@gnu.org
> > 
> > > I pointed to frameset.el, which is a lower-level infrastructure used
> > > by desktop.el.  It should allow you to save and restore windows of a
> > > single frame, if that suits your needs better.
> > 
> > It looks similar, but I cannot know why it does not work. I get error:
> 
> With what code did you get this error?  It's impossible to tell
> anything intelligent without seeing the code you used.

(frameset-restore (car (read-from-string (prin1-to-string (frameset-save (frame-list))))))

However, it is interesting what is happening when one evaluates
the above code in `emacs -Q', many frames are appearing
exponentially.

Actually, I need window configuration, not really frames, and
definitely there must be system to recognize that frame set
configuration was restored, and is there and existing before new
same frames start appearing.

In general the function that Hyperbole has {C-h h w a My-Windows RET} 
is what I need, just that it may be saved over sessions.


Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/




^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  2022-07-02 18:03                               ` Jean Louis
@ 2022-07-02 18:42                                 ` Eli Zaretskii
  2022-07-02 18:52                                   ` Jean Louis
  0 siblings, 1 reply; 30+ messages in thread
From: Eli Zaretskii @ 2022-07-02 18:42 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Sat, 2 Jul 2022 21:03:28 +0300
> From: Jean Louis <bugs@gnu.support>
> Cc: help-gnu-emacs@gnu.org, hyperbole-users@gnu.org
> 
> > > It looks similar, but I cannot know why it does not work. I get error:
> > 
> > With what code did you get this error?  It's impossible to tell
> > anything intelligent without seeing the code you used.
> 
> (frameset-restore (car (read-from-string (prin1-to-string (frameset-save (frame-list))))))

frameset-restore is supposed to be called with a valid frameset
object.



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  2022-07-02 18:42                                 ` Eli Zaretskii
@ 2022-07-02 18:52                                   ` Jean Louis
  2022-07-03  5:02                                     ` Eli Zaretskii
  0 siblings, 1 reply; 30+ messages in thread
From: Jean Louis @ 2022-07-02 18:52 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

* Eli Zaretskii <eliz@gnu.org> [2022-07-02 21:43]:
> > Date: Sat, 2 Jul 2022 21:03:28 +0300
> > From: Jean Louis <bugs@gnu.support>
> > Cc: help-gnu-emacs@gnu.org, hyperbole-users@gnu.org
> > 
> > > > It looks similar, but I cannot know why it does not work. I get error:
> > > 
> > > With what code did you get this error?  It's impossible to tell
> > > anything intelligent without seeing the code you used.
> > 
> > (frameset-restore (car (read-from-string (prin1-to-string (frameset-save (frame-list))))))
> 
> frameset-restore is supposed to be called with a valid frameset
> object.

That was the way I expected it to return valid frameset object, as if
it saved, then it should be possible to restore it by reading from
string as well.

Need more clues why it does not work.

Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/






^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  2022-07-02 18:52                                   ` Jean Louis
@ 2022-07-03  5:02                                     ` Eli Zaretskii
  0 siblings, 0 replies; 30+ messages in thread
From: Eli Zaretskii @ 2022-07-03  5:02 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Sat, 2 Jul 2022 21:52:03 +0300
> From: Jean Louis <bugs@gnu.support>
> Cc: help-gnu-emacs@gnu.org
> 
> > > (frameset-restore (car (read-from-string (prin1-to-string (frameset-save (frame-list))))))
> > 
> > frameset-restore is supposed to be called with a valid frameset
> > object.
> 
> That was the way I expected it to return valid frameset object, as if
> it saved, then it should be possible to restore it by reading from
> string as well.
> 
> Need more clues why it does not work.

I suggest to look in desktop.el how it loads the frameset from a file.



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: How to persist registers across sessions?
  2022-07-02 11:48         ` Eli Zaretskii
@ 2022-07-04  3:26           ` Pankaj Jangid
  0 siblings, 0 replies; 30+ messages in thread
From: Pankaj Jangid @ 2022-07-04  3:26 UTC (permalink / raw)
  To: help-gnu-emacs

Eli Zaretskii <eliz@gnu.org> writes:

>> Can I do this (below) with desktop-save-mode?
>> 
>> Save window configuration for a project and reload the same window
>> configuration at will, when I switch to that project.
>
> desktop-read is a command, and you can invoke it whenever you want.
> So yes, I think you can do this.

desktop-change-dir
desktop-restore
desktop-save
desktop-read

are serving my purpose as of now.

Thanks.





^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2022-07-04  3:26 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).