Subject: 24.3; set-frame-width didn't work in daemon mode

From: 涂坚 <[email-masked]>
Date: Sun, 24 Mar 2013 20:58:45 +0800

I have the following lines in my .emacs file.

(defun my:set-frame-size (&optional frame)
   (interactive)
   (if frame
     (select-frame frame))
   (if (display-graphic-p)
       (progn
     (tool-bar-mode -1)
     ;; use 120 char wide window for largeish displays
     ;; and smaller 80 column windows for smaller displays
     ;; pick whatever numbers make sense for you
     (if (> (x-display-pixel-width) 1280)
         (set-frame-width (selected-frame) 120)
       (set-frame-width (selected-frame) 80))
     ;; for the height, subtract a couple hundred pixels
     ;; from the screen height (for panels, menubars and
     ;; whatnot), then divide by the height of a char to
     ;; get the height we want
     (set-frame-height (selected-frame)
               (/ (- (x-display-pixel-height) 200)
                  (frame-char-height)))
     )))

(add-hook 'after-make-frame-functions 'my:set-frame-size frame)

However, if i invoke a normal emacs, and create a new frame, both
set-frame-width and set-frame-height work well.

But if i invoke emacs from 'emacsclient -c -a ""', set-frame-width
didn't work. Width should be 120 instead of staying 80. (I have
"server-start in the end of my .emacs")

I tried to debug it and use message to print width out. Under both
conditions, x-display-pixel-width is 1366 and (set-frame-width
(selected-frame) 120) is excuted.

In GNU Emacs 24.3.1 (i686-pc-cygwin)
  of 2013-03-11 on fiona
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
  `configure
  '--srcdir=/home/kbrown/src/cygemacs/emacs-24.3-1/src/emacs-24.3'
  '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin'
  '--sbindir=/usr/sbin' '--libexecdir=/usr/lib' '--datadir=/usr/share'
  '--localstatedir=/var' '--sysconfdir=/etc' '--datarootdir=/usr/share'
  '--docdir=/usr/share/doc/emacs' '-C' '--with-w32' 'CC=gcc'
  'CFLAGS=-ggdb -O2 -pipe
  -fdebug-prefix-map=/home/kbrown/src/cygemacs/emacs-24.3-1/build=/usr/src/debug/emacs-24.3-1
  -fdebug-prefix-map=/home/kbrown/src/cygemacs/emacs-24.3-1/src/emacs-24.3=/usr/src/debug/emacs-24.3-1'
  'LDFLAGS=-L/usr/lib/ncursesw' 'LIBS='
  'CPPFLAGS=-I/usr/include/ncursesw''

Important settings:
   value of $LANG: en_US.UTF-8
   locale-coding-system: utf-8-unix
   default enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
   yas-global-mode: t
   yas-minor-mode: t
   google-this-mode: t
   global-auto-complete-mode: t
   auto-complete-mode: t
   cygwin-terminal-clipboard-mode: t
   global-semanticdb-minor-mode: t
   global-semantic-idle-scheduler-mode: t
   semantic-mode: t
   global-ede-mode: t
   ede-minor-mode: t
   show-paren-mode: t
   global-linum-mode: t
   linum-mode: t
   tooltip-mode: t
   mouse-wheel-mode: t
   menu-bar-mode: t
   file-name-shadow-mode: t
   global-font-lock-mode: t
   font-lock-mode: t
   auto-composition-mode: t
   auto-encryption-mode: t
   auto-compression-mode: t
   column-number-mode: t
   line-number-mode: t
   transient-mark-mode: t

Recent input:
C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b
C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b
C-b C-b C-n C-n C-b C-b C-b C-b C-b C-b <backspace>
4 C-x C-s C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p
C-p C-p C-p C-p C-p C-p C-n C-n C-n C-n C-n C-n C-a
C-k C-k C-x C-s C-n C-n C-n C-n C-n C-n C-n C-n C-n
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p
C-p C-p C-p C-p C-p C-p C-p C-p C-n C-n C-n C-n C-n
C-n C-k C-k C-x C-s C-n C-n C-n C-n C-n C-n C-n C-n
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n
C-n C-n C-n C-n C-n C-n C-p C-p C-p C-p C-p C-p C-p
C-k C-k C-x C-s C-p C-n C-e C-p C-a C-k C-k C-e <backspace>
C-x C-s C-n C-p C-x C-s C-n C-n C-n C-n C-n C-n C-n
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p
C-a C-k C-k C-x C-s C-n C-n C-e C-n C-n C-b M-^ C-x
C-s C-n C-n C-n C-n C-n C-n C-n C-e C-p C-p C-p C-p
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-n C-n C-n C-n
C-n C-n C-n C-n C-p C-p C-p C-e C-n C-p C-p C-p C-a
C-k C-k C-x C-s C-n C-n C-n C-n C-n C-n C-n C-n C-n
C-n C-n C-n C-n C-n C-n C-n M-x r e p o r <tab> <r
eturn>

Recent messages:
Wrote /home/Arthur/.emacs
Saving file /home/Arthur/.emacs...
Wrote /home/Arthur/.emacs
(No changes need to be saved)
Saving file /home/Arthur/.emacs...
Wrote /home/Arthur/.emacs
Saving file /home/Arthur/.emacs...
Wrote /home/Arthur/.emacs
Saving file /home/Arthur/.emacs...
Wrote /home/Arthur/.emacs

Load-path shadows:
/home/Arthur/.emacs.d/el-get/el-get/.dir-locals hides 
/usr/share/emacs/24.3/lisp/gnus/.dir-locals

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils thingatpt find-func flymake compile comint
ansi-color ring server yasnippet google-this auto-complete-config
auto-complete popup auto-complete-autoloads flymake-css-autoloads
flymake-cursor-autoloads flymake-hlint-autoloads flymake-php-autoloads
flymake-python-pyflakes-autoloads flymake-shell-autoloads
flymake-easy-autoloads google-this-autoloads google-translate-autoloads
guess-offset-autoloads haskell-mode-autoloads mmm-mode-autoloads
php-mode-autoloads popup-autoloads w32-browser-autoloads
yasnippet-autoloads cygwin-terminal-clipboard easy-mmode flex-mode
derived semantic/db-mode semantic/db semantic/idle semantic/ctxt
semantic/sb semantic/sort semantic/format semantic/tag-ls semantic/find
semantic/util-modes semantic/util semantic semantic/tag semantic/lex
semantic/fw mode-local ede/cpp-root ede/emacs ede/speedbar ede/files ede
ede/base ede/auto ede/source eieio-base eieio-speedbar speedbar sb-image
ezimage dframe eieio-custom wid-edit eieio cedet tsdh-dark-theme edmacro
kmacro avoid time-date paren uniquify byte-opt warnings linum ido advice
advice-preload .loaddefs el-get el-get-autoloads el-get-list-packages
el-get-notify help-mode easymenu el-get-dependencies el-get-build
el-get-status pp el-get-recipes el-get-byte-compile el-get-methods
el-get-fossil el-get-svn el-get-pacman el-get-github-zip
el-get-github-tar el-get-http-zip el-get-http-tar el-get-hg
el-get-git-svn el-get-fink el-get-emacswiki el-get-http
el-get-emacsmirror el-get-github el-get-git el-get-elpa package cl-macs
gv el-get-darcs el-get-cvs el-get-bzr el-get-brew el-get-builtin
el-get-apt-get el-get-custom el-get-core autoload help-fns bytecomp
byte-compile cconv cl cl-lib dired tooltip ediff-hook vc-hooks
lisp-float-type mwheel w32-common-fns disp-table w32-win w32-vars
tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment
lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer loaddefs button faces cus-face macroexp files text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind w32
multi-tty emacs)