unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: Eli Zaretskii <eliz@gnu.org>
Cc: p.stephani2@gmail.com, 25380@debbugs.gnu.org
Subject: bug#25380: 25.1; save-window-excursion problem in batch mode
Date: Mon, 09 Jan 2017 17:19:29 +0100	[thread overview]
Message-ID: <5873B811.4000404@gmx.at> (raw)
In-Reply-To: <83pojwi7qc.fsf@gnu.org>

 >> IIUC the pixel comes from a menubar line which gets spuriously added.
 >
 > I believe you are right, see the backtrace below from the place which
 > changes the value from 0 to 1 (it's not pixel units, btw, it's
 > character units, AFAIU).

At the time the comparison fails in ‘compare-window-configurations’ it's
at !EQ (sw1->pixel_top, sw2->pixel_top) so it's off by one pixel.  It
probably would fail later at !EQ (sw1->top_line, sw2->top_line) as well.

 > More accurately, the initial current-window-configuration call happens
 > so early that the basic geometry of the "windows" is not yet set, and
 > in particular the menu bar is not yet computed and accounted for.
 > This is indeed where Emacs 25 behaves differently from previous
 > versions, and for a very good reason.

Does the basic geometry of the "windows" ever get set?  Would I have to
create a frame manually for that?

 >> If someone told me how to debug this, I might be able to tell more.
 >
 > I just ran Emacs under a debugger with a breakpoint in
 > Fcurrent_window_configuration, then put a watchpoint on every top_line
 > member of every window that got saved there, and waited for it to
 > break.

That's obvious.  But how do I find out where that menubar line gets set?

 >> I have no idea how the frame seen by ‘current-window-configuration’
 >> gets created in batch mode.
 >
 > It comes from temacs, AFAIR.

Hmm... the normal "F1" frame made by ‘make_initial_frame’.  Still: Who
adds the menubar line?  AFAIK neither NS nor GTK should.

 > I'm not actually certain we should try fixing this, unless Martin can
 > do that in some easy and safe way.  The code involved in this is quite
 > fragile, because Emacs creates its first frame without knowing
 > anything about its geometry and the window-system.  That code took a
 > long time to get right on all systems; I'd hate to break it to cater
 > to (IMO) much less important use cases.  I'd rather people wouldn't
 > count on anything related to "frames" and "windows" in the batch
 > session, except that they exist.  (They must exist because some
 > functions will simply not work without a frame or a window.)

So far I can't do anything here - this is code I cannot debug.  At the
time ‘compare-window-configurations’ gets called it's already much too
late :-(

 > IOW, I think unit tests that must compare windows cannot be naïvely
 > run in batch mode; you need to use tricks.  For example:
 >
 >    emacs -batch -eval "(progn (save-window-excursion (current-window-configuration)) (print (equal (save-window-excursion (current-window-configuration)) (current-window-configuration))))" => t

emacs -batch -eval "(progn (menu-bar-mode -1) (print (equal (save-window-excursion (current-window-configuration)) (current-window-configuration))))"

works here too.

martin






  reply	other threads:[~2017-01-09 16:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-06 23:05 bug#25380: 25.1; save-window-excursion problem in batch mode Philipp Stephani
2017-01-08 18:37 ` Glenn Morris
2017-01-08 23:38   ` Philipp Stephani
2017-01-09  9:39   ` martin rudalics
2017-01-09 15:16     ` Eli Zaretskii
2017-01-09 16:19       ` martin rudalics [this message]
2017-01-09 16:44         ` Eli Zaretskii
2017-01-10  8:22           ` martin rudalics
2017-01-10 17:11           ` Eli Zaretskii
2017-01-10 18:06             ` martin rudalics
2017-01-10 18:26               ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5873B811.4000404@gmx.at \
    --to=rudalics@gmx.at \
    --cc=25380@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=p.stephani2@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).