How to programatically resize main emacs window?

How to programatically resize main emacs window?

Post by Kavk » Fri, 11 Jul 2003 23:00:29



I normally use an 81-column window to edit my files.  However, if I want to,
say, compare two similar files, I maximize the emacs window and split the
window into two vertical ones.  But, I then end up with more then 81-columns
in each window since I have a larger monitor.

So, is there a way to create a command to enlarge my screen + split the
window into two vertical parts + and have exactly 81-columns in each part.

Thanks
Bora E.

 
 
 

How to programatically resize main emacs window?

Post by Daniel Jense » Fri, 11 Jul 2003 23:43:44



> So, is there a way to create a command to enlarge my screen + split the
> window into two vertical parts + and have exactly 81-columns in each part.

How about something like this:

(defun double-and-split (&optional width)
  "Double the frame size and split window, creating two equally sized windows.
If WIDTH argument is supplied, use it instead of current frame width."
  (interactive "P")
  (set-frame-width (selected-frame) (+ (* (or width (frame-width)) 2) 3))
  (split-window-horizontally))

--
Daniel Jensen
Editing is a rewording activity.

 
 
 

How to programatically resize main emacs window?

Post by Jesper Harde » Fri, 11 Jul 2003 23:53:07



> So, is there a way to create a command to enlarge my screen + split
> the window into two vertical parts + and have exactly 81-columns in
> each part.

I assume you mean two _horizontal_ windows side by side?

You can do something like this:

  (require 'cl)
  (setf (frame-width) 162)
  (split-window-horizontally)

You might have to adjust the number 162 a bit depending on if you're
displaying the scrollbar and left and right fringes.

 
 
 

How to programatically resize main emacs window?

Post by Kavk » Sat, 12 Jul 2003 00:15:51


Thanks for the answer.

How do I call this command with an optional argument?
M-x double-and-split ??????

Bora



> > So, is there a way to create a command to enlarge my screen + split the
> > window into two vertical parts + and have exactly 81-columns in each
part.

> How about something like this:

> (defun double-and-split (&optional width)
>   "Double the frame size and split window, creating two equally sized
windows.
> If WIDTH argument is supplied, use it instead of current frame width."
>   (interactive "P")
>   (set-frame-width (selected-frame) (+ (* (or width (frame-width)) 2) 3))
>   (split-window-horizontally))

> --
> Daniel Jensen
> Editing is a rewording activity.

 
 
 

How to programatically resize main emacs window?

Post by Daniel Jense » Sat, 12 Jul 2003 00:47:00





>> How about something like this:

>> (defun double-and-split (&optional width)
>>   "Double the frame size and split window, creating two equally sized windows.
>> If WIDTH argument is supplied, use it instead of current frame width."
>>   (interactive "P")
>>   (set-frame-width (selected-frame) (+ (* (or width (frame-width)) 2) 3))
>>   (split-window-horizontally))

> How do I call this command with an optional argument?
> M-x double-and-split ??????

Just do `C-u <some numbers> M-x double-and-split'. And I should
clarify that you might want to change the 3 in the addition above to
something else, because of reasons Jesper Harder wrote about.

--
Daniel Jensen
Editing is a rewording activity.

 
 
 

How to programatically resize main emacs window?

Post by Bruce Ingall » Sat, 12 Jul 2003 02:00:29


Hmm.
This sounds like a good ediff-mode-hook to write:
If the desktop is at least 160 columns wide, then do a
side-by-side ediff.
Else, perform the default.

I've been busy with EMacro, which has a
desktop-height-approx() defun, which should be easy to
adapt; I'll have to see, when I can get around to this.

The rest calls for User Opinions:
I'd be satisfied with side-by-side comparisons, with as
few as 140 columns, which means most GUI desktops.
How about you?

Does it make sense to temporarily enable horizontal scrollbars
for the lifetime of the compare?

I'm not sure, how one writes code, which detects that an ediff
session has closed, to return horizontal scrollbars to their
previous or default state (likely off)?

Perhaps this ediff-mode-hook is as simple as defaulting to
the horizontal compare Customize option, when run in a
windowing system, and expanding up to 163 columns, or the width
of the desktop, whichever is smaller?

 
 
 

How to programatically resize main emacs window?

Post by Chris McMaha » Sat, 12 Jul 2003 02:16:00


I have such a function hooked into ediff. Rather than just doubling
the width, however, I check the current display resolution and resize
the emacs window to fill a percentage of that screen, width and height.

It comes in quite handy for ediff (I always split the windows to be
side-by-side).

I can post the code again if anyone's interested.

 - Chris


> Hmm.
> This sounds like a good ediff-mode-hook to write:
> If the desktop is at least 160 columns wide, then do a
> side-by-side ediff.
> Else, perform the default.

> I've been busy with EMacro, which has a
> desktop-height-approx() defun, which should be easy to
> adapt; I'll have to see, when I can get around to this.

> The rest calls for User Opinions:
> I'd be satisfied with side-by-side comparisons, with as
> few as 140 columns, which means most GUI desktops.
> How about you?

> Does it make sense to temporarily enable horizontal scrollbars
> for the lifetime of the compare?

> I'm not sure, how one writes code, which detects that an ediff
> session has closed, to return horizontal scrollbars to their
> previous or default state (likely off)?

> Perhaps this ediff-mode-hook is as simple as defaulting to
> the horizontal compare Customize option, when run in a
> windowing system, and expanding up to 163 columns, or the width
> of the desktop, whichever is smaller?

--
     (.   .)
  =ooO=(_)=Ooo========================
  Chris McMahan | cmcmahan-AT-one.net
  ====================================
 
 
 

1. problem with (ancient) xterm, emacs windows resizing

when i use the xterminal on my desk (tek xp23, X11R4 server (!) other
details available on req.) dragging the modeline when there are more
than one windows in a frame leads to, er, erratic results: sometimes i
can move the modeline by a couples of lines, mostly i cannot move it

when i use any console, it works very nicely

anyone experienced the same misbehaviour? anyone has a solution? is it
a feature?

tia for any reply, ciao
                                gb

XEmacs 19.13 of Fri Sep  1 1995 on hp700 (hpux) [formerly Lucid Emacs]

2. Piano

3. resizing the emacs window

4. Default Route not added on start-up

5. speedbar in main window instead of frame

6. Security: Controlling access based on IP programmatically

7. attempt to resize split window causes buffer to scroll

8. postscpript file output

9. window resize for tty frame

10. resizing side-by-side windows

11. CDE 1.0 window resizing problem

12. Detecting resize of a frame or a window

13. resizing windows with the mouse