help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Trying to right-align my window on startup


From: Drew Adams
Subject: RE: Trying to right-align my window on startup
Date: Fri, 10 Jan 2014 15:09:36 -0800 (PST)

> >Just use a negative integer (e.g. -1) to set the number of pixels
> >from the right or bottom edge of your >screen.
> 
> The problem is not that I can't get the code to make the window move
> to the right position.  I've got the align-window function (below)
> working just fine.  The problem is that I can't get it to execute
> automatically upon emacs startup.

And yet clearly you did get it to execute automatically, since it
sent the message "Ran align-window-right".

> I can't figure out how or where to place it so that it executes
> _and works properly_.  I put it my MF-Init.el file that is loaded
> upon startup.

Replace that file with one that does _only_ what you are testing.
Adding something untested to a giant sack of eels is not the way
to test that something.  (No, I cannot know that MF-Init.el is a
sack of eels.  Just a hunch.)

> In the load of that library, it automatically sets the desired
> font and calls align-window.

You are doing too much to find out about your problem.  Why throw
this test in with changing the font, checking the phase of the
moon, and mailing your mom her horoscope? ;-)

> If I just start up emacs, I see the message "Ran align-
> window-right" in the message area of the window, but it isn't right-
> aligned.

According to your code, that could happen if the `selected-frame'
is not what you think it is.  Try adding a`message' call that tells
you what the selected frame is, and its displayed buffer etc.
IOW, find out what is going on.

> If I do a M-x load-library of that same file, it loads it
> (again), but this time it really does move the window to right
> alignment.

When?  Via the command-line switch -l?  Or using M-x load-file?
Emacs startup is a whole sequence of events.  Only at a particular
point is anything displayed.  At that point there is a frame to
be selected and aligned, but not before.

> Any clues what I'm doing wrong, or how to solve it?
> 
> (defun align-window-right ()
>   "align window to right window edge"
>   (interactive)
>   (set-frame-position (selected-frame) -1 0)
>   (message "Ran align-window-right"))

I do not see the problem here (on MS Windows).

I put just (align-window-right) in an otherwise empty file foo.el
(so I don't have to set the environment var), and I ran
emacs -Q -l "c:\path\to\foo.el".  That should be pretty much
equivalent to loading foo.el as an init file.

The frame was right-aligned, and I got the message
"Ran align-window-right".  No problem.

Try that: get rid of everything extraneous from your .emacs
(comment it out).  If that works, then bisect your .emacs
recursively, to find out what was interfering with the right
behavior.

FWIW, the fact that the code you showed here includes a comment,
a key binding, and a function that picks up an environment
var, all of which are extraneous, is indicative of not trying
to pare this down, to debug it.  (You can do that before asking
here, for instance.)

`M-x comment-region', with a numeric and with a plain prefix arg,
is your friend.  Use it to locate a problem in any file you load,
including your init file.  I bind it to `C-x C-;', and I use it
all the time, to comment and uncomment a block of code.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]