From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: How to persist registers across sessions? Date: Fri, 1 Jul 2022 10:03:13 +0300 Message-ID: References: <87leti6b6e.fsf@codeisgreat.org> <871qv7a3ey.fsf@gmail.com> <83y1xe45ga.fsf@gnu.org> <83bkuaf8e5.fsf@gnu.org> <83zghte5gl.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8937"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/+ () (2022-05-21) Cc: help-gnu-emacs@gnu.org To: Eli Zaretskii Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 01 09:08:27 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o7AlP-0002Cv-6y for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 01 Jul 2022 09:08:27 +0200 Original-Received: from localhost ([::1]:54652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o7AlN-0007H2-L5 for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 01 Jul 2022 03:08:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7Ajl-0006qh-D8 for help-gnu-emacs@gnu.org; Fri, 01 Jul 2022 03:06:45 -0400 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:41997) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7Ajj-0000iC-Gu; Fri, 01 Jul 2022 03:06:45 -0400 Original-Received: from localhost ([::ffff:154.230.66.106]) (AUTH: PLAIN admin, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 0000000000087C4D.0000000062BE9D00.00005C91; Fri, 01 Jul 2022 00:06:39 -0700 Mail-Followup-To: Eli Zaretskii , help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: <83zghte5gl.fsf@gnu.org> Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:138246 Archived-At: * Eli Zaretskii [2022-07-01 09:03]: > > Date: Fri, 1 Jul 2022 00:55:42 +0300 > > From: Jean Louis > > Cc: help-gnu-emacs@gnu.org > >=20 > > Can you in parallel with that good idea, give some clue how to obtain > > window configuration as lisp object? >=20 > People already told you: current-window-configuration does that. If I wish to get Lisp object of window configuration I get some result whic= h does not give data: (current-window-configuration) =E2=87=92 # and no matter if I have 3 windows, I get same result: (current-window-configuration) =E2=87=92 # I think this is function which should do that: The objects returned by =E2=80=98current-window-configuration=E2=80=99 d= ie 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 (=E2=80=98set-window-configuration=E2=80=99 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-=E2=80=98nil=E2=80=99, this m= eans to not use markers for sampling positions like =E2=80=98window-point=E2=80=99= or =E2=80=98window-start=E2=80=99. This argument should be non-=E2=80=98= nil=E2=80=99 when the state will be written to disk and read back in another session. Together, the argument WRITABLE and the variable =E2=80=98window-persistent-parameters=E2=80=99 specify which window pa= rameters are saved by this function. *Note Window Parameters::. So I try this way: (prin1-to-string (window-state-get (get-buffer-window))) =E2=87=92 "(((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-pi= xel-width . 100) (min-pixel-height-ignore . 57) (min-pixel-width-ignore . 6= 0) (min-pixel-height-safe . 19) (min-pixel-width-safe . 20)) leaf (pixel-wi= dth . 1592) (pixel-height . 779) (total-width . 159) (total-height . 41) (n= ormal-height . 1.0) (normal-width . 1.0) (parameters (clone-of . #)) (buffer # (selected . t) (hscroll . 0) (= fringes 8 8 nil nil) (margins nil) (scroll-bars nil 2 t nil 0 t nil) (vscro= ll . 0) (dedicated) (point . #) (start . #)) (prev-buffers (# # #) (# # #)))" 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-w= indow))))) eval((progn (read-from-string (prin1-to-string (window-state-get (get-buf= fer-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))=20 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 thi= s: (hywconfig-names (\"new1\" . #) Thus I think that (frameset-save (frame-list)) cannot reliably produce Lisp object that I can read back if there is # 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/