From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.help Subject: RE: Trying to right-align my window on startup Date: Fri, 10 Jan 2014 15:09:36 -0800 (PST) Message-ID: <65e69797-8a7c-4d94-99c3-87d5a3c3ade6@default> References: <83r48idw6z.fsf@gnu.org> <83mwj5ekrs.fsf@gnu.org> <28ab7799-fdc5-47c4-9ac0-f7db66771e7e@default> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1389395403 20326 80.91.229.3 (10 Jan 2014 23:10:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 10 Jan 2014 23:10:03 +0000 (UTC) To: Mickey Ferguson , "Emacs Help (help-gnu-emacs@gnu.org)" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jan 11 00:10:08 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1W1lDL-00038q-Ru for geh-help-gnu-emacs@m.gmane.org; Sat, 11 Jan 2014 00:10:08 +0100 Original-Received: from localhost ([::1]:59408 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W1lDL-0001TT-DS for geh-help-gnu-emacs@m.gmane.org; Fri, 10 Jan 2014 18:10:07 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40078) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W1lD2-0001SN-Uq for help-gnu-emacs@gnu.org; Fri, 10 Jan 2014 18:09:57 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W1lCt-0004uV-KV for help-gnu-emacs@gnu.org; Fri, 10 Jan 2014 18:09:48 -0500 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:25760) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W1lCt-0004u6-E0 for help-gnu-emacs@gnu.org; Fri, 10 Jan 2014 18:09:39 -0500 Original-Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id s0AN9YdD021469 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 10 Jan 2014 23:09:35 GMT Original-Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s0AN9YdW018834 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 10 Jan 2014 23:09:34 GMT Original-Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userz7022.oracle.com (8.14.5+Sun/8.14.4) with ESMTP id s0AN9Xfk003299; Fri, 10 Jan 2014 23:09:33 GMT In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.8 (707110) [OL 12.0.6680.5000 (x86)] X-Source-IP: ucsinet21.oracle.com [156.151.31.93] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 141.146.126.69 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:95346 Archived-At: > >Just use a negative integer (e.g. -1) to set the number of pixels > >from the right or bottom edge of your >screen. >=20 > 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? >=20 > (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.