0

I'm using Aquamacs on OS X and have multiple monitors in my setup. I'd like for all my Aquamacs frames to open with a certain position and size. In fact, my problem is rather similar to this one on StackOverflow. This solution of using modify-frame-parameters seems to have worked for setting the initial frame to my preferred position and size, but any additional frames open on my main monitor with a certain size and position, which are not the ones I want. I've tried many and varied solutions for fixing this including setting default-frame-alist, setting smart-frame-positioning-mode to nil, setting user-position to t, and even more. Yet, I'm still stuck with any additional frames opening in my main monitor with dimensions that I didn't specify. I even have this same problem in vanilla Emacs, so I guess this isn't specific to Aquamacs. Additionally, my version of OS X is 10.11.4 Beta, in case the OS / windowing system is causing this. Can someone specify a surefire way to have all frames open in a certain position and size on Emacs / Aquamacs for OS X?

  • Feature request 21415 (a couple of months ago) -- debbugs.gnu.org/cgi/bugreport.cgi?bug=21415 -- implemented perfect pixel frame positioning and sizing at the time a frame is created on OSX. I don't know if the Aquamacs maintainer has incorporated Emacs 25 or the master branch, or what version of Aquamacs you are using. If you are not using a newer version of Emacs that incorporates feature request 21415, then you will need to fix the frame after it is created. If you still need help after obtaining an Emacs version that includes feature request 21415, please update your question. – lawlist Feb 10 '16 at 17:58
  • As to selecting a particular monitor to display a frame, see this related thread -- Determine whether a frame is shown on primary display -- emacs.stackexchange.com/questions/14618/… – lawlist Feb 10 '16 at 18:35
  • @lawlist So, Aquamacs seems to have just recently merged with Emacs 25. Upon downloading their source tree, I couldn't get it to compile without crashing. So instead, I downloaded the source tree for Emacs 25, compiled the files, and ran the binary. It says I'm on 25.1.50 (9.0), so I think, according to the link you shared, that I have feature request 21415. However, I'm still seeing additional frames pop up in the same spot as before. Now that I have this feature, how do I actually use it? – GDP2 Feb 10 '16 at 21:19
0

The following is an example usage of feature request 21415 for OSX and a couple of different versions of Windows. [FYI: feature request 21415 increased in scope to include several bug fixes affecting frame sizes and positioning, menu-bar, etc.] I have already figured out my display width/height ahead of time using display-pixel-width and display-pixel-height for my various computers, and incorporated those known values into the example below. For example, I already know that my desktop computer running OSX is 1920 x 1080, my MacBook Pro 17 inch laptop is 1920 by 1200 and my MacBookAir 13 inch laptop is 1280 x 800. Run some tests ahead of time using M-x eval-expression RET (display-pixel-width) RET and M-x eval-expression RET (display-pixel-height RET and adjust the code based on your monotor. I use top 0 and left 0. The original poster will probably end up using different values for top and left along with incorporating a test similar to what Drew suggested as an answer in the related link to target a particular display -- e.g., using the function display-monitor-attributes-list to return a list containing values such as ".DISPLAY1".

Here is a make-frame example:

(make-frame '(
 (name . "HELLO-WORLD")
 (font . "-*-Courier-normal-normal-normal-*-18-*-*-*-m-0-iso10646-1")
 (top . 100)
 (left . 100)
 (left-fringe . 8)
 (right-fringe . 8)
 (vertical-scroll-bars)
 (cursor-color . "yellow")
 (cursor-type . (bar . 1))
 (background-color . "black")
 (foreground-color . "white")
 (tool-bar-lines . 0)
 (menu-bar-lines . 0)
 (width . (text-pixels . 400))
 (height . (text-pixels . 400)) ))

Here is an example using the default-frame-alist, which works for the initial frame and subsequently created frames that do not contain specific parameters that trump the default setting.

(when (eq system-type 'darwin)
  (setq ns-auto-hide-menu-bar t))

(let* (
    (display-pixel-width (display-pixel-width))
    (display-pixel-height (display-pixel-height))
    (font
      (cond
        ((eq system-type 'darwin)
          '(font . "-*-Courier-normal-normal-normal-*-18-*-*-*-m-0-iso10646-1"))
        ((eq system-type 'windows-nt)
          '(font . "-outline-Courier New-normal-normal-normal-mono-18-*-*-*-c-*-iso10646-1"))))
    (top '(top . 0))
    (left '(left . 0))
    (left-fringe '(left-fringe . 8))
    (right-fringe '(right-fringe . 8))
    (vertical-scroll-bars '(vertical-scroll-bars . nil))
    (cursor-color '(cursor-color . "yellow"))
    (cursor-type '(cursor-type . (bar . 1)))
    (background-color '(background-color . "black"))
    (foreground-color '(foreground-color . "white"))
    (tool-bar-lines '(tool-bar-lines . 0))
    (menu-bar-lines '(menu-bar-lines . 0))
    width
    height)
  (cond
    ((eq system-type 'darwin)
      (cond
        ((and
            (= 1920 display-pixel-width)
            (= 1080 display-pixel-height))
          (setq width '(width . (text-pixels . 1900)))
          (setq height '(height . (text-pixels . 1054))))
        ((and
            (= 1920 display-pixel-width)
            (= 1200 display-pixel-height))
          (setq width '(width . (text-pixels . 1900)))
          (setq height '(height . (text-pixels . 1174))))
        ((and
            (= 1280 display-pixel-width)
            (= 800 display-pixel-height))
          (setq width '(width . (text-pixels . 1259)))
          (setq height '(height . (text-pixels . 771))))))
    ((and
        (eq system-type 'windows-nt)
        (equal (w32-version) '(5 1 2600)))
      (cond
        ((and
            (= 1920 display-pixel-width)
            (= 1002 display-pixel-height))
          (setq width '(width . (text-pixels . 1896)))
          (setq height '(height . (text-pixels . 938))))
        ((and
            (= 1920 display-pixel-width)
            (= 1122 display-pixel-height))
          (setq width '(width . 172))
          (setq height '(height . 52)))
        ((and
            (= 1280 display-pixel-width)
            (= 722 display-pixel-height))
          (setq width '(width . 114))
          (setq height '(height . 32)))))
    ((and
        (eq system-type 'windows-nt)
        (equal (w32-version) '(6 1 7601)))
      (cond
        ((and
            (= 1920 display-pixel-width)
            (= 1080 display-pixel-height))
          (setq width '(width . 172))
          (setq height '(height . 52)))
        ((and
            (= 1920 display-pixel-width)
            (= 1200 display-pixel-height))
          (setq width '(width . 172))
          (setq height '(height . 58)))
        (t
                (message "Not yet contemplated.")))) )
  (setq default-frame-alist (list
    font
    top
    left
    left-fringe
    right-fringe
    vertical-scroll-bars
    cursor-color
    cursor-type
    background-color
    foreground-color
    tool-bar-lines
    menu-bar-lines
    width
    height)) )
  • Thanks! Setting default-frame-alist in Emacs 25 seems to have fixed my problem for both the initial frame and additional frames. Hopefully Aquamacs will have a working version of 25 soon, as well. – GDP2 Feb 12 '16 at 21:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.