Subject: bug#14056: closed (Re: bug#14049: 24.3; set-frame-width didn't work in daemon mode)

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 22 Sep 2017 08:11:03 +0000

Your bug report

#14049: 24.3; set-frame-height/width don't work when called first time on daemon mode

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
14049: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=14049
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#14049: 24.3; set-frame-width didn't work in daemon mode
From: martin rudalics <[email-masked]>
To: 涂坚 <[email-masked]>, [email-masked]
Date: Fri, 22 Sep 2017 10:10:02 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

 > 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

I have been looking into this (and the related 14056) now.  With a more
simple scenario using

(defun my-set-frame-size (&optional frame)
   (tool-bar-mode -1)
   (set-frame-width frame 30)
   (set-frame-height frame 10))

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

(server-start)

in the server Emacs, I can reproduce the bug for a 24.2.92.1 native
Windows build I happen to have around here.  For that build, the client
frame indeed does not support the requested height but uses the default
initial height instead.  I cannot reproduce the bug for any later build
I have here including one of 24.5.50.1.  So I suppose that the bug has
been fixed somewhere in between these two builds and mark this bug as
done.

Very belated thanks for the report, martin

Subject: 24.3; set-frame-height/width don't work when called first time on daemon mode
From: Arthur Tu <[email-masked]>
To: [email-masked]
Date: Tue, 26 Mar 2013 20:05:26 +0800
List-Id: <debbugs-submit.debbugs.gnu.org>

Sorry I come up with this bug again.
I found that i can't reply to my previous bug report.

I have the following function added to after-frame-created-functions.
(defun my:set-frame-size (&optional frame)
   (interactive)
   (unless frame
     (setq (selected-frame) frame))
   (if (display-graphic-p)
       (progn
     (tool-bar-mode -1)
     (message "set frame size")

     ;; This should be an emacs bug.
     ;; i have to add a fake operation on frame here.
     ;; (set-frame-height frame 29)

     ;; 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 frame
               (/ (- (x-display-pixel-height) 200)
                  (frame-char-height)))
     ;; 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 frame 120)
       (set-frame-width frame 80))
     )))
(add-hook after-frame-created-functions my:set-frame-size)

I have serveral experiments.

1. If i use the code shown before, after 'emacsclient -c -a ""', every
emacsclient frame can set width corrently and its height stay unchanged.

2. If i move the part of set width code before set height code, height can
be changed correctly while width can't.

3. If i add a fake (set-frame-height(or width) whatever), like that
commented by me, I can set both height and width.

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: Lisp Interaction

Minor modes in effect:
   shell-dirtrack-mode: t
   cygwin-terminal-clipboard-mode: t
   yas-global-mode: t
   yas-minor-mode: t
   global-auto-complete-mode: t
   auto-complete-mode: t
   global-semanticdb-minor-mode: t
   global-semantic-idle-scheduler-mode: t
   semantic-mode: t
   global-ede-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