How to check current emacs window position relative to other windows - emacs

I am using S-<up> and S-<down> to run (enlarge-window) and (shrink-window), respectively.
I would like these keys to be sensitive to the position of the current window relative to others. If my frame is split horizontally into two windows, and the current window is the top one, then I would like S-<up> to run (shrink-window) instead of (enlarge-window).
How do I check the position of the current window relative to the others?

See the function (window-edges). It returns a list of the window's coordinates. Just compare the y-axis value with the other visible windows.

You can use (window-tree). It will return not only the size of windows, but also their position , as a tree (in emacs' internals the windows of a frame are kept into a tree strucutre).

Related

Emacs - Preserve horizontal position when changing lines

Is there a way to make Emacs preserve my cursor's horizontal position, when going up and down between lines of varying widths in a file?
I'll explain what I mean by example. Say I have 3 lines of text:
1: ------a
2: --b
3: --c---d
Say the cursor is at the position marked above by a. If I move down a line, the cursor will be at b. If I move down again, it will be at c. But I actually want to end up at d.
Is there a way to make Emacs do that automatically, so that I can go from a to b to d just by pressing the down arrow twice? Emacs would have to remember my horizontal position from my most recent horizontal movement, and try to restore that horizontal position each time I move vertically.
Customize user option goal-column to nil.
(You can also use command set-goal-column anytime to set goal-column to the current column.)

AutoHotKey - Make image appear relative to a set of moving pixels?

Is it possible to create an AHK script that will position a given image (not changing) relative to a different "image" that will be moving constantly on the computer screen? I put the second "image" in quotations because the program would have to constantly search for that "image" or set of pixels that make up that "image" in order to correctly position the first image relative to the second "image".
If it's not possible to do this with AHK, how else can this be done?
The "image" would have to be placed always on top (or above all other programs).
Yes this can be achieved relatively easily.
You will need to create a Loop which performs:
Pixel Search/Image Search
Using the data retrieved from (1), depending on how the image is displayed using AHK, perform a image move function. If you use a borderless window (GUI), you will need WinMove function.
See all commands here: Commands

how to change the position of the output result in GUI

Does any one here have an idea about how to change the position of output in the GUI matlab to be to the right side of the box and not in the center ?
i think I have to change some properties of the result text box
Check this post out: Positioning of figures
The figure Position property controls the size and location of the figure window on the screen. Monitor screen size is a property of the root Handle Graphics object. At startup, the MATLAB software determines the size of your computer screen and defines a default value for Position. This default creates figures about one-quarter of the screen's minimum extent and places them centered left to right, in the top half of the screen.
The Position Vector
MATLAB defines the figure Position property as a vector. So you may use a figure and text into it, e.g.
figure(gcf)
text(offsetX1, offsetX1, ['result 1: ' num2str(result1)])
text(offsetX2, offsetX2, ['result 2: ' num2str(result2)])
Displaying analytical results in a MATLAB GUI
This post talks about adding a static textbox with your results and positioning it.
Move GUI figure to specified location on screen:
Syntax:
movegui(h,'position')
movegui(position)
movegui(h)
movegui
The answer is pretty much trying to cover up the vauge nature of the question

Determine/Save the position of text in matlab

I plotted few points using scatter and then label them using text. The position of these labels are same as the position of the points + some offset. Some of these text label overlap with each other and hence I moved them interactively (using mouse). I can check the new position of each of these text individually using property editor. However this is very time-consuming. Is there a better way to get the coordinates of all these text-label?
You can use findobj to get handles to text objects that are children of the current axes (or another handle... your choice):
text_handles = findobj('parent',gca,'type','text');
Then you can get the positions of these text objects:
positions = get(text_handles,'position');
You may need to do a bit more work to associate each text object with its data point - I suggest taking advantage of the property system, perhaps via the UserData field, for this, though there are many options.
If you want to do it easily later do this in your plots, for example:
h=text(2.9,7.5,'MyText');
This will put "MyText" at position 2.9, and 7.5.
Then to change the position use:
set(h,'Position',[2.5 7]);
This will change the position to 2.5 and 7.
Later if you need to see tthe position of text again use:
get(h);
Hope this helps.

How do I rearrange a split pane in Emacs?

In Vim I can move a split around. For example, if my window was split in two horizontally, with the topmost split split vertically (3 splits in total) I could move the top-right split to the right to become a vertical split taking up the entire vertical space.
Is this kind of rearrangement possible?
Update: I know resizing is possible, I'm looking to move though. I get the feeling this is not supported by Emacs.
You may be interested by C-x + when you have more than 2 windows. It rearranges equally the windows on the frame. It's convenient for example when you do two C-x 2 in a row and want to have the windows to occupy the same space on the frame.
No, not by default. What you have to play with is basically C-x 0, C-x 1, etc. Look in the Emacs Wiki for extensions that may or may not do what you're looking for.
FWIW, if you are running within a GUI, then you can precisely re-arrange window sizes quickly and easily with the mouse. This isn't quite the same thing as you're asking for, but may be a handy alternative in some cases.
You can click on any non-'active' area of the mode line (such as the buffer name) and then drag it up or down.
Dragging side to side is more fiddly. You must click on the exact border between the two mode lines, and then you can drag left/right.
For your specific example, I don't believe that is supported. AFAIK you can only reorganise the window splits within their existing 'parent' window (the upper split in this example). To make the upper-right window fill the vertical space you would either remove the bottom window with C-x 0, or use C-x 1 to remove all other windows, and then re-split them in the desired manner.
(Tangentially, I've often thought a custom library to 'rotate' the window splits would be a nice thing to have.)
I believe that the window resize commands are built in to window.el, from emacswiki the functions you want documented are:
shrink-window-horizontally ; C-x {
enlarge-window-horizontally ; C-x }
enlarge-window ; C-x ^
shrink-window ; not bound on my system
The comments are what they are bound to on my system, but I don't know if I did that myself.
All of them take a prefix argument, the number of lines to enlarge/shrink. The last two default to vertical.
As far as I know you cannot create a new window that runs the length or width of the screenfrom a window already split in that direction. Buffers remain open if you close the windows though so you can remove windows and then split them in the configuration you want. Then change which buffer is displayed in the window you are standing in by pressing C-x left arrow or right arrow.
I should add that this answer is regarding "vanilla" emacs, there is probably a way of doing what the OP asks if you really want to. It's emacs after all.