GNU bug report logs - #51
frame-title-format is built with wrong selected-frame

Previous Next

Package: emacs;

Reported by: Damon Permezel <permezel <at> mac.com>

Date: Tue, 11 Mar 2008 17:55:03 UTC

Severity: normal

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 51 in the body.
You can then email your comments to 51 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#51; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Damon Permezel <permezel <at> mac.com>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Damon Permezel <permezel <at> mac.com>
To: emacs-pretest-bug <at> gnu.org
Subject: difficulty creating unique frame names
Date: Tue, 11 Mar 2008 13:41:55 +1000
The default naming scheme for certain emacs implementations is to use
the string in the frame-title-format which defaults to "%b".  It is
thus quite easy to create many frames with the same name.  Just start
emacs and hit ^x-5-2 repeatedly.

The Buffers>Frames menu thus presents a list of buffers many with the
same names.  Also, any command for manipulating frames by frame names
really cannot use the name to distinguish between the frames.  Note that
the Buffers>Frames cannot be used to select all the frames with the same
name when there are more than 2 with the same name.  This is a bug!

In order to avoid this bug, one has to have unique frame names.

I wish to retain the "%b" functionality in the frame-title-format, so
I have attempted to construct a FORM that will be evaluated when the
frame title is desired to provide some unique element --- in this case
a F%d where the %d is the index of the frame within the (frame-list),  
say.

I find that it is not possible to calculate this correctly, as I have
no means, from elisp, at the time the FORM is being evaluated, to
obtain the frame in question.

I have also tried setting a :zz-count property on the frames to
uniquely identify them, however there is no means I know of to
retrieve this property again as the frame in question is not available
to me.

I do not want to set the 'name property for the frame, as I wish to
retain the "%b" functionality, and I note that this does not work.
IE: I could arrange to set each frame's 'name to "<unique> %b" readily
enough, but then the %b is not expanded.  Also, cannot set name to
anything by a string.

I have tried setting the 'frame-title-format property in a frame,
given that this is rumoured to create frame-local-variables, but this
does not seem to influence the global frame-title-format.

(setq zz-frame-count 0)

;;
;; this will put a unique :zz-count in each frame's properties
;;
(add-hook 'after-make-frame-functions
	  '(lambda (frame)
	     (progn
	       (modify-frame-parameters frame (list (cons :zz-count (setq zz- 
frame-count (1+ zz-frame-count)))))
	       (message "%S" (frame-parameters frame)))))

;;
;; this attempts to set F%d to the index of the frame in the
;; frame-list, but it just does so for the current frame.
;;

(setq frame-title-format
      (cons :eval
	    '((let ((f (next-frame (previous-frame)))
		    (x nil))
		(format "F%d:%%b - %%F"
			(apply '+ (mapcar
				   (lambda (_)
				     (if x 0
				       (setq x (eq _ f))
				       1))
				   (frame-list))))))

;; try the above, and then a a slew of ^x-5-2 and then cycle thru the  
frames and look at the names.


I would either like to be able to have (current-frame) return the
frame for which the frame-title-format is being expanded, or I would
like to have a '%Z[pname]' (or something less revolting) expand out to  
a named property for
the implicit frame, just as '%F' expands the implicit frame's name.

(setq frame-title-format "F%Z[:zz-count]:%b")

would give me "F1:*scratch*", "F2:*scratch*", ... for example.

Another solution would be to use the per-frame frame-title-format.


In GNU Emacs 22.1.50.1 (i386-apple-darwin8.11.1, Carbon Version 1.6.0)
 of 2008-01-18 on seijiz.local
Windowing system distributor `Apple Inc.', version 10.5.2
configured using `configure  '--prefix=/Applications/Emacs.app/ 
Contents/Resources' '--with-carbon' '--without-x' '--libexecdir=/ 
Volumes/Emacs/Emacs.app/Contents/MacOS/libexec' 'CFLAGS=-Os -arch i386  
-arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -DUSE_ATSUI - 
DUSE_MAC_TSM''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: nil
  locale-coding-system: iso-8859-1
  default-enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
  shell-dirtrack-mode: t
  encoded-kbd-mode: t
  show-paren-mode: t
  mac-key-mode: t
  display-time-mode: t
  mac-print-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
c o u n t ) 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 o n s SPC C-e C-x C-e C-] C-p C-p C-p C-p
C-p C-p C-x C-e C-n C-n C-n C-n C-n C-n C-e C-x C-e
) C-n C-n C-b C-b C-x C-e C-] C-e C-x C-e C-x C-e C-x
5 2 <switch-frame> <down-mouse-1> <mouse-movement>
<mouse-1> C-h f <return> <help-echo> C-x 1 C-x C-b
C-n SPC <down-mouse-1> <mouse-1> ( l i s t SPC C-e
) b x C-e <backspace> <backspace> C-x C-e C-] C-b C-x
C-e C-n C-n C-x C-e C-p C-p C-p C-p C-p C-p C-a C-k
C-k C-y C-y C-p C-p C-d C-d C-d C-d C-d C-d C-d C-d
C-d C-d C-d ( s e t q SPC C-e SPC n i l ) C-a ; C-e
C-x C-e C-n C-n C-n C-n C-n C-n C-n C-n C-p C-x C-e
C-x 5 2 <switch-frame> <switch-frame> <help-echo> <down-mouse-1>
<mouse-movement> <mouse-1> 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 ( s r t q <backspace>
<backspace> <backspace> e t q SPC <backspace> <backspace>
<backspace> <backspace> <backspace> C-f C-f C-f C-f
C-f C-f C-f C-f C-f C-f ( s e t q SPC C-k C-y <backspace>
<backspace> <backspace> SPC ( 1 + SPC C-y <backspace>
<backspace> C-x C-e ) ) ) ) C-x C-e <down-mouse-1>
<mouse-1> <backspace> C-e C-b C-x C-e C-x C-e C-n C-n
C-p C-p C-p C-p C-p C-p C-p C-x C-e C-n C-n C-n C-n
C-n C-n C-n C-x C-e C-n C-n C-n C-n C-n C-n C-] <down-mouse-1>
<mouse-movement> <mouse-movement> <drag-mouse-1> C-x
C-x A-c <menu-bar> <help-menu> <send-emacs-bug-rep
ort>

Recent messages:
1
Entering debugger...
((:zz-count . 1))
((:zz-count . 2))
nil
((lambda (frame) (progn (select-frame-set-input-focus frame) (modify- 
frame-parameters frame (list (cons :zz-count (setq zz-frame-count (1+  
zz-frame-count))))) (message "%S" (frame-parameters frame)) (mwm))))
Auto-saving...done
Quit
Auto-saving...
Loading emacsbug...done





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#51; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #10 received at 51 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: 51 <at> debbugs.gnu.org
Subject: Re: difficulty creating unique frame names
Date: Tue, 11 Mar 2008 17:35:09 -0400
retitle 51 frame-title-format run with wrong selected-frame
thanks

> The Buffers>Frames menu thus presents a list of buffers many with the
> same names.

Indeed.  I don't think there's much we can do about that for now.

> Also, any command for manipulating frames by frame names
> really cannot use the name to distinguish between the frames.  Note that
> the Buffers>Frames cannot be used to select all the frames with the same
> name when there are more than 2 with the same name.  This is a bug!

Indeed, thanks.  Should be fixed now on the trunk.

> I wish to retain the "%b" functionality in the frame-title-format, so
> I have attempted to construct a FORM that will be evaluated when the
> frame title is desired to provide some unique element --- in this case
> a F%d where the %d is the index of the frame within the (frame-list), say.

> I find that it is not possible to calculate this correctly, as I have
> no means, from elisp, at the time the FORM is being evaluated, to
> obtain the frame in question.

Indeed, I expected `selected-frame' to return the right frame, but
it doesn't.  That's also a bug.  But it's not fixed yet.


        Stefan




Changed bug title to `frame-title-format is built with wrong selected-frame' from `difficulty creating unique frame names'. Request was from Stefan Monnier <monnier <at> iro.umontreal.ca> to control <at> emacsbugs.donarmstrong.com. (Wed, 19 Mar 2008 02:35:03 GMT) Full text and rfc822 format available.

Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. Full text and rfc822 format available.

Notification sent to Damon Permezel <permezel <at> mac.com>:
bug acknowledged by developer. Full text and rfc822 format available.

Message #17 received at 51-done <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: 51-done <at> debbugs.gnu.org
Subject: frame-title-format is built with wrong selected-frame
Date: Wed, 19 Mar 2008 11:04:00 -0400
I believe this is now fixed for Emacs-23, so you can use
`selected-window' and `selected-frame' in your `frame-title-format' and
get the right window/frame out of it.

2008-03-19  Stefan Monnier  <monnier <at> iro.umontreal.ca>

	* xdisp.c (format_mode_line_unwind_data): Add window argument.
	(unwind_format_mode_line): Restore selected window.
	(x_consider_frame_title, Fformat_mode_line): Set selected window.


-- Stefan




bug archived. Request was from Debbugs Internal Request <don <at> donarmstrong.com> to internal_control <at> emacsbugs.donarmstrong.com. (Thu, 17 Apr 2008 14:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 17 years and 118 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.