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: Mickey Ferguson
Subject: RE: Trying to right-align my window on startup
Date: Fri, 10 Jan 2014 22:31:46 +0000

>> The problem here is that I want a generic file that will work for 
>> multiple screen dimensions.  A while ago I had tried going down the 
>> path you have suggested here and just didn't know all of the screen 
>> parameters, nor how to convert from one unit type to another.
>> That's why the -1 was used, as an attempt at using emacs' knowledge of 
>> the screen's right edge location.
>
>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. 
 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.  In the 
load of that library, it automatically sets the desired font and calls 
align-window.  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.  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.

Any clues what I'm doing wrong, or how to solve it?

(defun align-window ()
  "fix window positioning"
  (interactive)
  (if (equal (getenv "emacs_alignment") "right")
      (align-window-right)
    (align-window-left))
  )

;;;set C-x \ (backslash) to align-window
(global-set-key "\C-x\\" 'align-window)

(defun align-window-left ()
  "align window to left window edge"
  (interactive)
  (set-frame-position (selected-frame) 0 0)
  (message "Ran align-window-left")
  )

(defun align-window-right ()
  "align window to right window edge"
  (interactive)
  (set-frame-position (selected-frame) -1 0)
  (message "Ran align-window-right")
  )




reply via email to

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