* delete window help
@ 2008-11-04 17:57 bbrady
2008-11-04 20:42 ` Xah
0 siblings, 1 reply; 13+ messages in thread
From: bbrady @ 2008-11-04 17:57 UTC (permalink / raw
To: help-gnu-emacs
Hi,
I want to use the delete-window function to delete a certain window
without having to switch to that window first. Here is an example:
I start a fresh emacs session. Then I do split-window-horizontally
( \C-x 3 ). In the left most window, I then do, split-window ( \C-x
2 ). Now I have the following window configuration:
----------------------
| | |
| a | |
| _____| b |
| | |
| c | |
| | |
----------------------
Now I want to change that configuration to:
----------------------
| | |
| | |
| a | b |
| | |
| | |
| | |
----------------------
There are 2 ways I know of to do this:
1) switch to window 'c' and call delete-window
2) switch to either window 'a' or 'b' and call delete-other-windows,
then split-window-horizontally, and switch to the appropriate buffer
('b' or 'a', respectively)
I want to do this without switching away from window 'a'. Is this
possible? I think it is, but I'm not sure how to do it. The delete-
window function takes an optional argument 'window'. So, I should be
able to delete whatever window I want, just as long as I have the
correct 'window'. Any ideas on how I can get the correct 'window'? Or
any other solutions to this?
Thanks for any help,
bbrady
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: delete window help
2008-11-04 17:57 delete window help bbrady
@ 2008-11-04 20:42 ` Xah
2008-11-04 21:41 ` bbrady
0 siblings, 1 reply; 13+ messages in thread
From: Xah @ 2008-11-04 20:42 UTC (permalink / raw
To: help-gnu-emacs
On Nov 4, 9:57 am, bbrady <bryan.br...@gmail.com> wrote:
> Hi,
>
> I want to use the delete-window function to delete a certain window
> without having to switch to that window first. Here is an example:
>
> I start a fresh emacs session. Then I do split-window-horizontally
> ( \C-x 3 ). In the left most window, I then do, split-window ( \C-x
> 2 ). Now I have the following window configuration:
>
> ----------------------
> | | |
> | a | |
> | _____| b |
> | | |
> | c | |
> | | |
> ----------------------
>
> Now I want to change that configuration to:
> ----------------------
> | | |
> | | |
> | a | b |
> | | |
> | | |
> | | |
> ----------------------
>
> There are 2 ways I know of to do this:
> 1) switch to window 'c' and call delete-window
> 2) switch to either window 'a' or 'b' and call delete-other-windows,
> then split-window-horizontally, and switch to the appropriate buffer
> ('b' or 'a', respectively)
>
> I want to do this without switching away from window 'a'. Is this
> possible? I think it is, but I'm not sure how to do it. The delete-
> window function takes an optional argument 'window'. So, I should be
> able to delete whatever window I want, just as long as I have the
> correct 'window'. Any ideas on how I can get the correct 'window'? Or
> any other solutions to this?
give it a argument of 2. Type this:
Ctrl+u 2 Ctrl+x 0
in general, if you want to give a argument to a command, just type Ctrl
+u first then argument, then call the command.
Xah
∑ http://xahlee.org/
☄
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: delete window help
2008-11-04 20:42 ` Xah
@ 2008-11-04 21:41 ` bbrady
2008-11-04 22:47 ` aartist
2008-11-05 1:47 ` Xah
0 siblings, 2 replies; 13+ messages in thread
From: bbrady @ 2008-11-04 21:41 UTC (permalink / raw
To: help-gnu-emacs
> give it a argument of 2. Type this:
>
> Ctrl+u 2 Ctrl+x 0
>
> in general, if you want to give a argument to a command, just type Ctrl
> +u first then argument, then call the command.
Thanks for the info, I didn't know how to give arguments to a
command.
I've tried what you mentioned above and its not working. I also tried
giving delete-window arguments 0 and 1. The behavior is the same. That
is, window 'c' becomes the entire left side. Which is the same thing
that happens when I run Ctrl+x 0 without arguments. (Note, I was in
window 'a' when I did Ctrl+u 2 Ctrl+x 0)
To make sure we're on the same page, executing the elisp code below
should bring you to the same state I'm in when I want to delete window
'c'.
(split-window-horizontally)
(split-window)
(find-file "a")
(other-window 1)
(find-file "c")
(other-window 1)
(find-file "b")
(other-window 1)
I tried eval-expression on (delete-window 2) and I got the following
error trace:
Debugger entered--Lisp error: (wrong-type-argument windowp 2)
delete-window(2)
eval((delete-window 2))
eval-expression((delete-window 2) nil)
call-interactively(eval-expression)
execute-extended-command(nil)
call-interactively(execute-extended-command)
It looks like delete-window wants a pointer to a window object,
instead of an integer.
bbrady
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: delete window help
2008-11-04 21:41 ` bbrady
@ 2008-11-04 22:47 ` aartist
2008-11-05 1:47 ` Xah
1 sibling, 0 replies; 13+ messages in thread
From: aartist @ 2008-11-04 22:47 UTC (permalink / raw
To: help-gnu-emacs
On Nov 4, 4:41 pm, bbrady <bryan.br...@gmail.com> wrote:
> > give it a argument of 2. Type this:
>
> > Ctrl+u 2 Ctrl+x 0
>
> > in general, if you want to give a argument to a command, just type Ctrl
> > +u first then argument, then call the command.
>
> Thanks for the info, I didn't know how to give arguments to a
> command.
>
> I've tried what you mentioned above and its not working. I also tried
> giving delete-window arguments 0 and 1. The behavior is the same. That
> is, window 'c' becomes the entire left side. Which is the same thing
> that happens when I run Ctrl+x 0 without arguments. (Note, I was in
> window 'a' when I did Ctrl+u 2 Ctrl+x 0)
>
> To make sure we're on the same page, executing the elisp code below
> should bring you to the same state I'm in when I want to delete window
> 'c'.
>
> (split-window-horizontally)
> (split-window)
> (find-file "a")
> (other-window 1)
> (find-file "c")
> (other-window 1)
> (find-file "b")
> (other-window 1)
>
> I tried eval-expression on (delete-window 2) and I got the following
> error trace:
>
> Debugger entered--Lisp error: (wrong-type-argument windowp 2)
> delete-window(2)
> eval((delete-window 2))
> eval-expression((delete-window 2) nil)
> call-interactively(eval-expression)
> execute-extended-command(nil)
> call-interactively(execute-extended-command)
>
> It looks like delete-window wants a pointer to a window object,
> instead of an integer.
>
> bbrady
Yes,.
==================================================
C-x 0 runs the command delete-window
which is an interactive built-in function in `C source code'.
It is bound to C-x 0.
(delete-window &optional window)
=================================================
Of course, you can use macro.
Remove window from the display. Default is selected windo
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: delete window help
2008-11-04 21:41 ` bbrady
2008-11-04 22:47 ` aartist
@ 2008-11-05 1:47 ` Xah
2008-11-05 2:20 ` bbrady
1 sibling, 1 reply; 13+ messages in thread
From: Xah @ 2008-11-05 1:47 UTC (permalink / raw
To: help-gnu-emacs
Xah wrote:
> > give it a argument of 2. Type this:
>
> > Ctrl+u 2 Ctrl+x 0
>
> > in general, if you want to give a argument to a command, just type Ctrl
> > +u first then argument, then call the command.
bbrady wrote:
> I've tried what you mentioned above and its not working. I also tried
> giving delete-window arguments 0 and 1. The behavior is the same. That
> is, window 'c' becomes the entire left side. Which is the same thing
> that happens when I run Ctrl+x 0 without arguments. (Note, I was in
> window 'a' when I did Ctrl+u 2 Ctrl+x 0)
you are right it didn't work. I didn't pay close attention when
testing it.
easiest way to do what u want is probably with a macro though.
Q: How to record a sequence of keystrokes?
To record keystrokes, type “Ctrl+x (” then start typing your
keystrokes. When done, type “Ctrl+x )”. This records your keystrokes.
To run the keystrokes you've recorded, type “Ctrl+x e”.
Here are the command names and their shortcuts:
start-kbd-macro Ctrl+x (
end-kbd-macro Ctrl+x )
call-last-kbd-macro Ctrl+x e
If you want to use your keyboard macro for future use, you can save
it. To save the macro, first type “Alt+x name-last-kbd-macro”, then
type “Alt+x insert-kbd-macro”, which will insert the lisp code for the
keyboard macro at the cursor point. Put the code in your emacs init
file (usually at “~/.emacs”). Then, you can execute your keyboard
macro like this: “Alt+x yourMacroName” the next time you start emacs.
the above is from this tutorial page:
http://xahlee.org/emacs/emacs_adv_tips.html
here's the macro i got using the above, and tested it works.
(fset 'remove-next-pane
(lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-
exec-ring-item (quote ([134217825 111 116 104 101 114 45 119 105 110
tab return 134217825 100 101 108 101 116 tab 119 105 110 tab return] 0
"%d")) arg)))
once you have this, you can call it with Alt+x or assign a keyboard
shortcut to it. (see “How to Define Keyboard Shortcuts in Emacs” at
http://xahlee.org/emacs/keyboard_shortcuts.html )
You might be interested to simply define a easy kbd shortcuts for
spliting window and moving cursor to other pane. That way, you might
not need what you asked. For example, for qwerty keyboard, i have:
Alt+s = move cursor to next pane
Alt+2 = split window
Alt+Shift+2 = split window side by side
http://xahlee.org/emacs/ergonomic_emacs_keybinding.html
Xah
\xAD\xF4 http://xahlee.org/
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: delete window help
2008-11-05 1:47 ` Xah
@ 2008-11-05 2:20 ` bbrady
2008-11-05 6:39 ` Xah
2008-11-05 22:41 ` Chetan
0 siblings, 2 replies; 13+ messages in thread
From: bbrady @ 2008-11-05 2:20 UTC (permalink / raw
To: help-gnu-emacs
Xah, Thanks for your in-depth response.
I am familiar with macros and am not opposed to using a macro for this
problem. In fact, I have keyboard macros defined for splitting/
switching windows similar to yours (I stumbled across your website
some time ago). However, my original question was slightly more
complicated than the one I posted -- I came up with simplified version
in order to explain it more easily.
So, here's the more complicated part:
The window configuration isn't always the same as the one I gave in
the first post. A lot of times I'll split a window temporarily and
work in one of them, while refering to the other. Then, that other
window will no longer be useful for me, and I want to kill it without
switching from the current window. The problem I have is, how do I
figure out what that 'other' window is? Depending on the order in
which I created the windows, and which window I'm in, using Ctrl-x o
(or Alt+s) might not put me in the correct window. So, I'm looking for
a way to not have to cycle through all the windows.
Going back to my original example, lets say I'm in window 'c' and I
want to delete-window 'a' (whereas before I was in window 'a' and
wanted to delete window 'c'). I can't just switch-window, because
that'll take me to window 'b'. I have to cycle through (in this case,
its only one window, but in general, it can be a lot of windows). So,
is there a way to find a "parent window" so that I know what to pass
to the delete-window function?
bbrady
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: delete window help
2008-11-05 2:20 ` bbrady
@ 2008-11-05 6:39 ` Xah
2008-11-05 16:56 ` aartist
2008-11-05 22:41 ` Chetan
1 sibling, 1 reply; 13+ messages in thread
From: Xah @ 2008-11-05 6:39 UTC (permalink / raw
To: help-gnu-emacs
On Nov 4, 6:20 pm, bbrady <bryan.br...@gmail.com> wrote:
> Xah, Thanks for your in-depth response.
>
> I am familiar with macros and am not opposed to using a macro for this
> problem. In fact, I have keyboard macros defined for splitting/
> switching windows similar to yours (I stumbled across your website
> some time ago). However, my original question was slightly more
> complicated than the one I posted -- I came up with simplified version
> in order to explain it more easily.
>
> So, here's the more complicated part:
>
> The window configuration isn't always the same as the one I gave in
> the first post. A lot of times I'll split a window temporarily and
> work in one of them, while refering to the other. Then, that other
> window will no longer be useful for me, and I want to kill it without
> switching from the current window. The problem I have is, how do I
> figure out what that 'other' window is? Depending on the order in
> which I created the windows, and which window I'm in, using Ctrl-x o
> (or Alt+s) might not put me in the correct window. So, I'm looking for
> a way to not have to cycle through all the windows.
>
> Going back to my original example, lets say I'm in window 'c' and I
> want to delete-window 'a' (whereas before I was in window 'a' and
> wanted to delete window 'c'). I can't just switch-window, because
> that'll take me to window 'b'. I have to cycle through (in this case,
> its only one window, but in general, it can be a lot of windows). So,
> is there a way to find a "parent window" so that I know what to pass
> to the delete-window function?
i don't think emacs records which pane a pane is splitted from. Though
i haven't done any elisp related to display so i might be wrong.
you might be able to write your function so that when a win is split,
it records the newly created pane with the pane it splitted from...
Xah
∑ http://xahlee.org/
☄
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: delete window help
2008-11-05 6:39 ` Xah
@ 2008-11-05 16:56 ` aartist
2008-11-05 21:15 ` bbrady
0 siblings, 1 reply; 13+ messages in thread
From: aartist @ 2008-11-05 16:56 UTC (permalink / raw
To: help-gnu-emacs
On Nov 5, 1:39 am, Xah <xah...@gmail.com> wrote:
> On Nov 4, 6:20 pm, bbrady <bryan.br...@gmail.com> wrote:
>
>
>
> > Xah, Thanks for your in-depth response.
>
> > I am familiar with macros and am not opposed to using a macro for this
> > problem. In fact, I have keyboard macros defined for splitting/
> > switching windows similar to yours (I stumbled across your website
> > some time ago). However, my original question was slightly more
> > complicated than the one I posted -- I came up with simplified version
> > in order to explain it more easily.
>
> > So, here's the more complicated part:
>
> > The window configuration isn't always the same as the one I gave in
> > the first post. A lot of times I'll split a window temporarily and
> > work in one of them, while refering to the other. Then, that other
> > window will no longer be useful for me, and I want to kill it without
> > switching from the current window. The problem I have is, how do I
> > figure out what that 'other' window is? Depending on the order in
> > which I created the windows, and which window I'm in, using Ctrl-x o
> > (or Alt+s) might not put me in the correct window. So, I'm looking for
> > a way to not have to cycle through all the windows.
>
> > Going back to my original example, lets say I'm in window 'c' and I
> > want to delete-window 'a' (whereas before I was in window 'a' and
> > wanted to delete window 'c'). I can't just switch-window, because
> > that'll take me to window 'b'. I have to cycle through (in this case,
> > its only one window, but in general, it can be a lot of windows). So,
> > is there a way to find a "parent window" so that I know what to pass
> > to the delete-window function?
>
> i don't think emacs records which pane a pane is splitted from. Though
> i haven't done any elisp related to display so i might be wrong.
>
> you might be able to write your function so that when a win is split,
> it records the newly created pane with the pane it splitted from...
>
> Xah
> ∑http://xahlee.org/
>
> ☄
Can you add the hook to the split window function. That hook is going
to store whatever necessary information, which can be called from the
parent/original window.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: delete window help
2008-11-05 16:56 ` aartist
@ 2008-11-05 21:15 ` bbrady
0 siblings, 0 replies; 13+ messages in thread
From: bbrady @ 2008-11-05 21:15 UTC (permalink / raw
To: help-gnu-emacs
> Can you add the hook to the split window function. That hook is going
> to store whatever necessary information, which can be called from the
> parent/original window.
I'll give it a look and post any info I find.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: delete window help
2008-11-05 2:20 ` bbrady
2008-11-05 6:39 ` Xah
@ 2008-11-05 22:41 ` Chetan
2008-11-06 0:48 ` bbrady
2008-11-06 16:30 ` Drew Adams
1 sibling, 2 replies; 13+ messages in thread
From: Chetan @ 2008-11-05 22:41 UTC (permalink / raw
To: help-gnu-emacs
bbrady <bryan.brady@gmail.com> writes:
> Xah, Thanks for your in-depth response.
>
> I am familiar with macros and am not opposed to using a macro for this
> problem. In fact, I have keyboard macros defined for splitting/
> switching windows similar to yours (I stumbled across your website
> some time ago). However, my original question was slightly more
> complicated than the one I posted -- I came up with simplified version
> in order to explain it more easily.
>
> So, here's the more complicated part:
>
> The window configuration isn't always the same as the one I gave in
> the first post. A lot of times I'll split a window temporarily and
> work in one of them, while refering to the other. Then, that other
> window will no longer be useful for me, and I want to kill it without
> switching from the current window. The problem I have is, how do I
> figure out what that 'other' window is? Depending on the order in
> which I created the windows, and which window I'm in, using Ctrl-x o
> (or Alt+s) might not put me in the correct window. So, I'm looking for
> a way to not have to cycle through all the windows.
>
> Going back to my original example, lets say I'm in window 'c' and I
> want to delete-window 'a' (whereas before I was in window 'a' and
> wanted to delete window 'c'). I can't just switch-window, because
> that'll take me to window 'b'. I have to cycle through (in this case,
> its only one window, but in general, it can be a lot of windows). So,
> is there a way to find a "parent window" so that I know what to pass
> to the delete-window function?
>
> bbrady
I was working on something similar for myself. It is for doing stuff
visually with emacs windows. There are other things that I wanted to
do, but it can choose a window using arrow keys (or programmatically)
and then delete it or do something else. It works, but it hasn't had
much testing. I could post it if it would be of interest. It would
help me iron out any bugs as well.
Chetan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: delete window help
2008-11-05 22:41 ` Chetan
@ 2008-11-06 0:48 ` bbrady
[not found] ` <u3ai5389e.fsf@myhost.sbcglobal.net>
2008-11-06 16:30 ` Drew Adams
1 sibling, 1 reply; 13+ messages in thread
From: bbrady @ 2008-11-06 0:48 UTC (permalink / raw
To: help-gnu-emacs
> I was working on something similar for myself. It is for doing stuff
> visually with emacs windows. There are other things that I wanted to
> do, but it can choose a window using arrow keys (or programmatically)
> and then delete it or do something else. It works, but it hasn't had
> much testing. I could post it if it would be of interest. It would
> help me iron out any bugs as well.
I am interested in seeing what you have. Although, I can't promise
I'll use it or find any bugs :)
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: delete window help
2008-11-05 22:41 ` Chetan
2008-11-06 0:48 ` bbrady
@ 2008-11-06 16:30 ` Drew Adams
1 sibling, 0 replies; 13+ messages in thread
From: Drew Adams @ 2008-11-06 16:30 UTC (permalink / raw
To: 'Chetan', help-gnu-emacs
> > The problem I have is, how do I figure out what that 'other'
> > window is? ... So, I'm looking for a way to not have to cycle
> > through all the windows.
> >
> > Going back to my original example, lets say I'm in window 'c' and I
> > want to delete-window 'a' (whereas before I was in window 'a' and
> > wanted to delete window 'c')....
>
> I was working on something similar for myself. It is for doing stuff
> visually with emacs windows. There are other things that I wanted to
> do, but it can choose a window using arrow keys (or programmatically)
> and then delete it or do something else. It works, but it hasn't had
> much testing. I could post it if it would be of interest. It would
> help me iron out any bugs as well.
FWIW, in Icicles, by default:
1. `C-x 0' is bound to a command that does this:
a. With no prefix arg, same as vanilla Emacs:
delete selected window.
b. With a prefix arg, prompt for a (displayed) buffer name;
delete its window(s).
2. `C-x o' is bound to a command that does this:
a. With no prefix arg, like vanilla Emacs: `other-window',
but if the frame has only one window, then `other-frame'.
b. With a prefix arg, prompt for a window or frame name
(+ [N]) to select.
For 2b (`C-u C-x o'):
* If the current frame has only one window, then you choose a
frame to select, not a window (`C-x 5 o' also does this).
* Otherwise, you choose among the frame's windows.
With a zero prefix arg, choose windows in all frames.
A window name is its buffer name plus, if needed, a unique index: `foo',
`foo[2]', `foo[3]'. Similarly, a frame name is its `name' parameter plus, if
needed, an index.
With a prefix arg, these (`C-x 0' and `C-x o') are multi-commands, which means
you can act on (delete or select) any number of windows or frames. Completion,
cycling, and direct choice are available. Completion and cycling work together,
so you need not cycle through all windows to get to the one you want: your input
filters the choices to cycle.
http://www.emacswiki.org/cgi-bin/wiki/Icicles
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: delete window help
[not found] ` <u3ai5389e.fsf@myhost.sbcglobal.net>
@ 2008-11-06 17:29 ` bbrady
0 siblings, 0 replies; 13+ messages in thread
From: bbrady @ 2008-11-06 17:29 UTC (permalink / raw
To: help-gnu-emacs
> I have put it up athttp://netdesigns.us/emacs/wimex.el
> I am not sure how long I can kepp it there, but it should be available
> for sometime now.
The link above doesn't work. I get a 404 not found error.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2008-11-06 17:29 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-04 17:57 delete window help bbrady
2008-11-04 20:42 ` Xah
2008-11-04 21:41 ` bbrady
2008-11-04 22:47 ` aartist
2008-11-05 1:47 ` Xah
2008-11-05 2:20 ` bbrady
2008-11-05 6:39 ` Xah
2008-11-05 16:56 ` aartist
2008-11-05 21:15 ` bbrady
2008-11-05 22:41 ` Chetan
2008-11-06 0:48 ` bbrady
[not found] ` <u3ai5389e.fsf@myhost.sbcglobal.net>
2008-11-06 17:29 ` bbrady
2008-11-06 16:30 ` Drew Adams
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.