set the window size of emacs on Window 7 - emacs

I want to set the window size (maybe it is the frame in emacs speaking). I use this for the config. It works, but something happened that confused me. for example, if I set the width 80 and the height 30. When I start the emacs. It initialize to wider than 80 and higher than 30 which I set previously, then in a flash, it shrinked to the width 80 and height 30.
What I want to ask is why it appeared like this? can I set the window size as soon as the emacs initialized? How?
a similar thing happened with the toolbar. I disable the toolbar like this
(tool-bar-mode 0)
when I initialize the emacs, the toolbar appears, but in a flash it disappeared. FYI, I put the (tool-bar-mode 0) in the very first line of the .emacs file.

For the strangely resizing window:
Basically, Emacs brings up its window (frame) before it reads your .emacs. Obviously it has to be some size. Of course, this is customizable. On Unix systems, you do this by setting an X resource, which works a bit like an environment variable: Emacs can check for the setting when it first runs before loading up all the elisp-parsing machinery and getting to work on your .emacs. On Windows, I think you can set these variables through the registry. See this EmacsWiki page for a description of how to set variables in the registry. You want the Emacs.Geometry key.
I don't know if it's possible to change tool-bar-mode as an X resource. I didn't bother, since the appearing and disappearing tool bar was much less irritating than a moving window!

Related

Windows Emacs 25.3 Cursor Type

I have issue changing cursor-type in Emacs 25.3 and 25.2 on Windows. Picture is worth thousand words, so here it is
No customization whatsoever.
I try to change cursor-type to a box directly or via frame parameters and it is always a bar. Even when cursor-type is set to t it is a bar
Is there a way to change it ?
It looks like w32-use-visible-system-caret is non-nil. This can happen by default if Emacs detects some application is using the Accessibility API to track the position of the cursor - most commonly screen readers, and screen magnifiers. Such software often relies on the default Windows cursor being used and visible, rather than the customizable internal Emacs implementation of a cursor.
You can manually force this variable to nil in your startup files if you wish to continue using whatever software is triggering this, but have Emacs use its own cursor drawing. The other software may not work well with Emacs in that case however.

Can I scroll the windows in emacs synchronously?

I mean if I type in c-x 2, then for comparasion I want it to scroll the other window synchronously when I scroll the temporary window.
Try Follow Mode:
M-x follow-mode
Follow mode is a minor mode that makes two windows, both showing the same buffer, scroll as a single tall “virtual window”.
Note that follow mode can only synchronize scrolling windows which content a same file. For scrolling windows with diffrent files synchronously, here's an answer for it.
Follow mode can only synchronize scrolling windows which content a
same file. Does it possible to scrolling windows with diffrent files
synchronously? – 9307420654
There is a minor mode to apply all scrolling commands to all visible
windows in the current frame. Check scroll-all-mode for that. Or else,
if you want to scroll together only 2 windows and only when you use a
specific keystroke, you can do something like a function that scrolls
the current window (scroll-up or scroll-down) and then the “other
window” (i.e., the next one in the list of windows), with
scroll-other-window (with argument '-, i.e., the symbol “minus”, for
scrolling down). Then you can assign this to a keystroke, e.g., C-M-up
/ down.
scroll-all-mode:
Use M-x scroll-all-mode to scroll multiple buffers together.
Very useful for visually comparing two files which are hard to diff
because of lots of trivial changes amongst the changes you are looking
for.
Another solution might be the scroll-all-mode:
M-x scroll-all-mode
Of course, if the windows you want to compare are somehow similar (like different versions of the same file), you probably would like to use a "diff" tool, like M-x ediff-buffers which compares the buffers with colors and keeps them scrolling in sync.

How to have an emacs function called when display size changes?

I'm trying to define an emacs function that will be called when the display size changes, currently I'm not finding any hooks that I can use for this.
I an NOT trying to notice when the emacs window changes size.
My use case is that I have emacs open on my laptop, then I close it and bring it to work and plug it into a bigger monitor and turn it on via the keyboard. After logging in my windows are all in the top left corner.
I want emacs to notice the screen size change and call my function allow me to reposition the window and change the font size.
yes, I know about stay but I also want to change the font size.
I'm running emacs 24.3.1 from emacsformacosx.com under OSX Mavericks
AFAIK, Emacs currently does not catch such screen-size-change events, and even if it does internally, it doesn't expose this in any way to ELisp. So your two best bets might be:
Use a timer that checks the screen size to detect change.
Ask for the feature via M-x report-emacs-bug.

Emacs scrolling behaviour after changing font size

Emacs23 GUI in Ubuntu 10.04 LTS. I've previously not changed any settings relating to Emacs scrolling behaviour. However, today I noticed a peculiar jumping behaviour when scrolling down in a buffer -- the cursor down key would scroll down as normal to a point and then the next keypress down would sometimes scroll the buffer down instead or sometimes appear to scroll the buffer up and then move the selected line down. It appeared to be more buggy behaviour rather than the normal or predictable jumping of the buffer. If I held down the down cursor the screen would jump and scroll and stutter and then lurch forward and then stutter.
I searched for some answers and tried a few mentioned here, but nothing solved the problem. Only then did I realize that this behaviour is new -- it only appeared after I changed the font in the buffer with C-x C--. When I returned the font to the "default" with C-x C-+, the scrolling behaviour returned to normal (the point moves to the last line, then the next press scrolls a few lines and moves the point up and displays the lines below; this is the default I think and I'm happy with it). Ideas?
Edit: Scrolling up works fine (as expected/default) regardless of font-size changes. Changing the font smaller a second time only makes the scrolling more bizarre.
Edit: Temporary workaround: return to using emacs -nw
Update: Tested on another Ubuntu 10.04 machine (desktop). Launched Emacs 23 and loaded a log file. Maximized Emacs. Help down cursor and scrolling worked as normal -- the cursor gets to the bottom, the buffer scrolls and the cursor moves to the middle of the screen. C-x C-- to reduce font size. Scroll down again. Same strange jerky behaviour, where some jumps don't seem to even move the buffer properly. Enlarge font once, and scrolling returns to normal. Scrolling up is fine regardless of font size. I searched the Emacs bug tracker briefly but did not find a bug which matched.
I've had this problem (or something very similar) for a long time. I finally found something (on EmacsWiki) that's working:
(setq auto-window-vscroll nil)
Without this, the buffer will not scroll down correctly when I've altered the font size, regardless of my scroll settings, which are, for what it's worth,
(setq scroll-conservatively 10)
(setq scroll-margin 7)
Consider filing an Emacs bug: M-x report-emacs-bug.

Emacs mouse focus stuck in one frame

Twice in the past two days, I've had a problem with my emacs sessions. Somehow emacs is keeping the focus within one frame. So, if I mouse over another frame and click in it, the cursor in the new frame stays put and the cursor in frame 1 moves as if I clicked in the corresponding position in it. Same happens with mouse-wheel scrolling. But not keyboard input.
Killing the hogging frame just causes another frame to become the hoarder.
My solution yesterday was to quit and restart emacs.
Some googling pointed me towards the variable focus-follows-mouse, but that appears to be set correctly (i.e. "t").
Any ideas what caused it and how to reset it?
(I'm using Ubuntu intrepid's package of emacs 22.2-0ubuntu2.)
I have
(setq focus-follows-mouse t)
(setq mouse-autoselect-window t)
in my .emacs file, and find that this makes focus follow mouse work correctly. Maybe there's something else in your config that's changing emacs' behaviour, do you have your elisp in version control? Can you identify when this started happening, and look at changes to your elisp around then ?
Try starting emacs with --no-init-file and seeing if the undesired behaviour persists.
I have discovered that switching to another tty (eg crtl-alt-1) then back to whatever tty you were on before will reset your focus.
Not a general solution, but at least you don't have to kill X (which is what I've been doing until now).