all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to pickle split window?
@ 2013-03-08 11:32 Haines Brown
  2013-03-08 15:32 ` jpkotta
  0 siblings, 1 reply; 11+ messages in thread
From: Haines Brown @ 2013-03-08 11:32 UTC (permalink / raw)
  To: help-gnu-emacs

I normally run emacs with split windows and so have 

   (split-window-horizontally)

in its initialization file. However, I periodically interrupt work
to run M-x gnus. When I close gnus, I am not returned to a split window,
but to a single window. 

What can I do to return to the split window that displays my prior state
automatically after closing gnus without having to do an emacs reload
command with:

  ;; Enable M-x reload
  (defun reload () "Reloads .emacs interactively."
    (interactive)
    (load "~/.emacs"))

Haines Brown



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

* Re: How to pickle split window?
  2013-03-08 11:32 How to pickle split window? Haines Brown
@ 2013-03-08 15:32 ` jpkotta
  2013-03-08 20:05   ` Haines Brown
  0 siblings, 1 reply; 11+ messages in thread
From: jpkotta @ 2013-03-08 15:32 UTC (permalink / raw)
  To: help-gnu-emacs

On Friday, March 8, 2013 5:32:17 AM UTC-6, Haines Brown wrote:
> I normally run emacs with split windows and so have 
> 
> 
> 
>    (split-window-horizontally)
> 
> 
> 
> in its initialization file. However, I periodically interrupt work
> 
> to run M-x gnus. When I close gnus, I am not returned to a split window,
> 
> but to a single window. 
> 
> 
> 
> What can I do to return to the split window that displays my prior state
> 
> automatically after closing gnus without having to do an emacs reload
> 
> command with:
> 
> 
> 
>   ;; Enable M-x reload
> 
>   (defun reload () "Reloads .emacs interactively."
> 
>     (interactive)
> 
>     (load "~/.emacs"))
> 
> 
> 
> Haines Brown

C-x r w <letter> saves the window configuration to the register specified with <letter> (e.g. "a" or "z").  C-x r j <letter> restores the window config stored in register <letter>.  

There are many packages that save window configurations, see http://emacswiki.org/emacs/CategoryWindows#toc4.  I like workgroups.el.


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

* Re: How to pickle split window?
  2013-03-08 15:32 ` jpkotta
@ 2013-03-08 20:05   ` Haines Brown
  2013-03-08 20:52     ` Lowell Gilbert
                       ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Haines Brown @ 2013-03-08 20:05 UTC (permalink / raw)
  To: help-gnu-emacs

jpkotta <jpkotta@gmail.com> writes:

> On Friday, March 8, 2013 5:32:17 AM UTC-6, Haines Brown wrote:
>> 
>> What can I do to return to the split window that displays my prior
>> state automatically after closing gnus without having to do an emacs
>> reload

> C-x r w <letter> saves the window configuration to the register
> specified with <letter> (e.g. "a" or "z").  C-x r j <letter> restores
> the window config stored in register <letter>.
>
> There are many packages that save window configurations, see
> http://emacswiki.org/emacs/CategoryWindows#toc4.  I like
> workgroups.el.

Sorry I was not clearer. I understand there are commands to restore
previous window layout, but my interest was for it to be automatic, so
that for example when I close gnus, emacs returns automatically to the
prior windows layout. It would even be nice to return automatically to
the the prior buffers displayed in those windows.

I suspect the answer to somehow to add a hook to gnus quit that
automatically runs (defun reload ()), perhaps calling back most recent
buffers for those windows.

Haines   


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

* Re: How to pickle split window?
  2013-03-08 20:05   ` Haines Brown
@ 2013-03-08 20:52     ` Lowell Gilbert
  2013-03-09 13:15       ` Haines Brown
  2013-03-08 20:59     ` Joost Kremers
                       ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Lowell Gilbert @ 2013-03-08 20:52 UTC (permalink / raw)
  To: help-gnu-emacs

Haines Brown <haines@histomat.net> writes:

> jpkotta <jpkotta@gmail.com> writes:
>
>> On Friday, March 8, 2013 5:32:17 AM UTC-6, Haines Brown wrote:
>>> 
>>> What can I do to return to the split window that displays my prior
>>> state automatically after closing gnus without having to do an emacs
>>> reload
>
>> C-x r w <letter> saves the window configuration to the register
>> specified with <letter> (e.g. "a" or "z").  C-x r j <letter> restores
>> the window config stored in register <letter>.
>>
>> There are many packages that save window configurations, see
>> http://emacswiki.org/emacs/CategoryWindows#toc4.  I like
>> workgroups.el.
>
> Sorry I was not clearer. I understand there are commands to restore
> previous window layout, but my interest was for it to be automatic, so
> that for example when I close gnus, emacs returns automatically to the
> prior windows layout. It would even be nice to return automatically to
> the the prior buffers displayed in those windows.
>
> I suspect the answer to somehow to add a hook to gnus quit that
> automatically runs (defun reload ()), perhaps calling back most recent
> buffers for those windows.

It sounds like you're not running with any 'window-system'. 
If you were, the obvious answer would be to open a new window 
for your temporary distractions.

Your idea makes sense, but perhaps you should consider
creating a function to provide your preferred setup for what
you consider your normal state. That way, you could invoke it
not just as a matter of restoring state, but of configuring it
in the first place.

But not understanding quite what you're after, I could easily
be far off base here.


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

* Re: How to pickle split window?
  2013-03-08 20:05   ` Haines Brown
  2013-03-08 20:52     ` Lowell Gilbert
@ 2013-03-08 20:59     ` Joost Kremers
  2013-03-09  0:35     ` Eric Abrahamsen
  2013-03-09  8:24     ` Ivan Kanis
  3 siblings, 0 replies; 11+ messages in thread
From: Joost Kremers @ 2013-03-08 20:59 UTC (permalink / raw)
  To: help-gnu-emacs

Haines Brown wrote:
> Sorry I was not clearer. I understand there are commands to restore
> previous window layout, but my interest was for it to be automatic, so
> that for example when I close gnus, emacs returns automatically to the
> prior windows layout. It would even be nice to return automatically to
> the the prior buffers displayed in those windows.
>
> I suspect the answer to somehow to add a hook to gnus quit that
> automatically runs (defun reload ()), perhaps calling back most recent
> buffers for those windows.

you can store the current window configuration in a variable using
`current-window-configuration' and restore it with
`set-window-configuration'.

IMHO any package that takes over the window configuration (such as gnus
does) should do that...

-- 
Joost Kremers                                      joostkremers@yahoo.com
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)


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

* Re: How to pickle split window?
  2013-03-08 20:05   ` Haines Brown
  2013-03-08 20:52     ` Lowell Gilbert
  2013-03-08 20:59     ` Joost Kremers
@ 2013-03-09  0:35     ` Eric Abrahamsen
  2013-03-09  8:24     ` Ivan Kanis
  3 siblings, 0 replies; 11+ messages in thread
From: Eric Abrahamsen @ 2013-03-09  0:35 UTC (permalink / raw)
  To: help-gnu-emacs

Haines Brown <haines@histomat.net> writes:

> jpkotta <jpkotta@gmail.com> writes:
>
>> On Friday, March 8, 2013 5:32:17 AM UTC-6, Haines Brown wrote:
>>> 
>>> What can I do to return to the split window that displays my prior
>>> state automatically after closing gnus without having to do an emacs
>>> reload
>
>> C-x r w <letter> saves the window configuration to the register
>> specified with <letter> (e.g. "a" or "z").  C-x r j <letter> restores
>> the window config stored in register <letter>.
>>
>> There are many packages that save window configurations, see
>> http://emacswiki.org/emacs/CategoryWindows#toc4.  I like
>> workgroups.el.
>
> Sorry I was not clearer. I understand there are commands to restore
> previous window layout, but my interest was for it to be automatic, so
> that for example when I close gnus, emacs returns automatically to the
> prior windows layout. It would even be nice to return automatically to
> the the prior buffers displayed in those windows.
>
> I suspect the answer to somehow to add a hook to gnus quit that
> automatically runs (defun reload ()), perhaps calling back most recent
> buffers for those windows.

It looks like there's no hook that runs before gnus starts munging
buffers. So you'd probably want to advise the gnus command (before),
store (current-window-configuration) in a variable, and then as you say
add a hook to gnus-exit-gnus-hook that checks if there's a valid
window-config in that variable, and if so read it with
(set-window-configuration).

Hope that's useful,

Eric




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

* Re: How to pickle split window?
  2013-03-08 20:05   ` Haines Brown
                       ` (2 preceding siblings ...)
  2013-03-09  0:35     ` Eric Abrahamsen
@ 2013-03-09  8:24     ` Ivan Kanis
  3 siblings, 0 replies; 11+ messages in thread
From: Ivan Kanis @ 2013-03-09  8:24 UTC (permalink / raw)
  To: Haines Brown; +Cc: help-gnu-emacs

March, 08 at 15:05 Haines Brown wrote:

> I suspect the answer to somehow to add a hook to gnus quit that
> automatically runs (defun reload ()), perhaps calling back most recent
> buffers for those windows.

If you have fixed it please share your solution. I want it too.
-- 
The xy axis in the trackball is coordinated with the summer solstice.
    -- BOFH excuse #40



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

* Re: How to pickle split window?
  2013-03-08 20:52     ` Lowell Gilbert
@ 2013-03-09 13:15       ` Haines Brown
  2013-03-09 14:19         ` Lowell Gilbert
                           ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Haines Brown @ 2013-03-09 13:15 UTC (permalink / raw)
  To: help-gnu-emacs

Lowell Gilbert <lgusenet@be-well.ilk.org> writes:

> Haines Brown <haines@histomat.net> writes:

>> Sorry I was not clearer. I understand there are commands to restore
>> previous window layout, but my interest was for it to be automatic,
>> so that for example when I close gnus, emacs returns automatically to
>> the prior windows layout. It would even be nice to return
>> automatically to the the prior buffers displayed in those windows.

Several well-meaning replies assume that I'm up to lisp encoding, but
I'm a historian by trade and lack the skill. Earlier suggestions to
pickle the layout in a variable and restore it by command are equivalent
(in terms of number of key strokes required) to what I now do, which is
simply to reload emacs. This recovers the split window. But the real
problem is that I have also to take the further steps to recover the
previous buffers to display them in the two windows, and that is an
annoyance.

> Your idea makes sense, but perhaps you should consider creating a
> function to provide your preferred setup for what you consider your
> normal state. That way, you could invoke it not just as a matter of
> restoring state, but of configuring it in the first place.

Ideally I would redefine the reload command to recall the most recent
buffer that had been displayed in each window before running gnus, but
don't know how to do it:

  (defun reload () "Reloads .emacs interactively."
    (interactive)
    (load "~/.emacs" <with the prior buffers in each window>))

> It sounds like you're not running with any 'window-system'.  If you
> were, the obvious answer would be to open a new window for your
> temporary distractions.

I run a window system (fluxbox), but no desktop environment (gnome,
etc). As things are now I run a five applications constantly on virtual
desktops, mutt, jabref, conkeror, and two instances of emacs, one for
writing and other for research. Since I'm used to jumping from one
virtual desktop to another I could simply run gnus permanently in yet
another instance of emacs on a new virtual desktop. It had occurred to
me to do this, but I was looking for a more lighweight solution.

Another approach might be to run a dedicated instance of emacs that
calls gnus automatically. For example, I presently have a fluxbox key
command that employs a script to run a small simple instance of emacs in
lieu of opening a terminal for running nano. This script has emacs
create an empty temporary file in text mode rather than start with a
scratch buffer in lisp mode. I need to improve this by a) running it as
an emacs client, and b) have it act like scratch buffer in that it
redefines C-x C-s command to "write-named-file" (I want to avoid saving
the temporary file). Howevever, this line in init file returns error
that the function definition is void:

     (global-set-key (kbd "C-x C-s") 'write-named-file)

Perhaps I could have a key command start a script that starts an
instance of emacs client that automatically runs gnus, but I don't know
how to start emacs running a function rather than create/open a file.

Am I fantasizing here?

Haines




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

* Re: How to pickle split window?
  2013-03-09 13:15       ` Haines Brown
@ 2013-03-09 14:19         ` Lowell Gilbert
  2013-03-10  2:47         ` Eric Abrahamsen
       [not found]         ` <mailman.21792.1362883346.855.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 11+ messages in thread
From: Lowell Gilbert @ 2013-03-09 14:19 UTC (permalink / raw)
  To: help-gnu-emacs

Haines Brown <haines@histomat.net> writes:

> I run a window system (fluxbox), but no desktop environment (gnome,
> etc). As things are now I run a five applications constantly on virtual
> desktops, mutt, jabref, conkeror, and two instances of emacs, one for
> writing and other for research. Since I'm used to jumping from one
> virtual desktop to another I could simply run gnus permanently in yet
> another instance of emacs on a new virtual desktop. It had occurred to
> me to do this, but I was looking for a more lighweight solution.

I could suggest what I do, which is certainly lighter weight:
I open up a new windows (C-x 5) and run gnus in that. 
The window configuration of the previous emacs frame is untouched.


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

* Re: How to pickle split window?
  2013-03-09 13:15       ` Haines Brown
  2013-03-09 14:19         ` Lowell Gilbert
@ 2013-03-10  2:47         ` Eric Abrahamsen
       [not found]         ` <mailman.21792.1362883346.855.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 11+ messages in thread
From: Eric Abrahamsen @ 2013-03-10  2:47 UTC (permalink / raw)
  To: help-gnu-emacs

Haines Brown <haines@histomat.net> writes:

> Lowell Gilbert <lgusenet@be-well.ilk.org> writes:
>
>> Haines Brown <haines@histomat.net> writes:
>
>>> Sorry I was not clearer. I understand there are commands to restore
>>> previous window layout, but my interest was for it to be automatic,
>>> so that for example when I close gnus, emacs returns automatically to
>>> the prior windows layout. It would even be nice to return
>>> automatically to the the prior buffers displayed in those windows.
>
> Several well-meaning replies assume that I'm up to lisp encoding, but
> I'm a historian by trade and lack the skill. Earlier suggestions to
> pickle the layout in a variable and restore it by command are equivalent
> (in terms of number of key strokes required) to what I now do, which is
> simply to reload emacs. This recovers the split window. But the real
> problem is that I have also to take the further steps to recover the
> previous buffers to display them in the two windows, and that is an
> annoyance.

Hi,

I'll bet your best solution is to use `gnus-other-frame' rather than
plain old `gnus'. That will start a new frame for you, run or visit
gnus, and then delete the frame when you quit gnus.

If you don't want another frame, then saving a window configuration is
definitely the way to go: window confs not only save the window
structure of your frame, but also which buffers are displayed, and even
the location of point in those buffers. Here's the code for what I
mentioned earlier:


(defvar my-pre-gnus-wconf nil
  "A place to store window configuration before starting gnus.")

(defadvice gnus (before save-wconf-start-gnus activate)
  "Save current window configuration before starting gnus."
  (setq my-pre-gnus-wconf (current-window-configuration)))

(defun my-post-gnus-restore ()
  (when (window-configuration-p my-pre-gnus-wconf)
    (set-window-configuration my-pre-gnus-wconf)))

(add-hook 'gnus-exit-gnus-hook 'my-post-gnus-restore)


Untested, but ought to work.

Yours,
Eric




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

* Re: How to pickle split window?
       [not found]         ` <mailman.21792.1362883346.855.help-gnu-emacs@gnu.org>
@ 2013-03-10 14:00           ` Haines Brown
  0 siblings, 0 replies; 11+ messages in thread
From: Haines Brown @ 2013-03-10 14:00 UTC (permalink / raw)
  To: help-gnu-emacs

Eric, I was unaware of gnus-other frame. I find it does just what I
want. Thank you.

It us good to know that saving window configuration always saves the
displayed buffers. I have other reasons to implement this.

Haines


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

end of thread, other threads:[~2013-03-10 14:00 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-08 11:32 How to pickle split window? Haines Brown
2013-03-08 15:32 ` jpkotta
2013-03-08 20:05   ` Haines Brown
2013-03-08 20:52     ` Lowell Gilbert
2013-03-09 13:15       ` Haines Brown
2013-03-09 14:19         ` Lowell Gilbert
2013-03-10  2:47         ` Eric Abrahamsen
     [not found]         ` <mailman.21792.1362883346.855.help-gnu-emacs@gnu.org>
2013-03-10 14:00           ` Haines Brown
2013-03-08 20:59     ` Joost Kremers
2013-03-09  0:35     ` Eric Abrahamsen
2013-03-09  8:24     ` Ivan Kanis

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.