unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#6078: 23.1.90; switch-to-buffer does not redisplay until an event occurs
@ 2010-04-30 18:35 Dimitri Fontaine
       [not found] ` <handler.6078.B.127279835328349.ack@debbugs.gnu.org>
  2010-05-02 18:57 ` bug#6078: 23.1.90; switch-to-buffer does not redisplay until an event occurs martin rudalics
  0 siblings, 2 replies; 6+ messages in thread
From: Dimitri Fontaine @ 2010-04-30 18:35 UTC (permalink / raw)
  To: 6078

The following code, an attempt to have a visual window switching
facility, is failing to provide the visual clue it's meant to give. That
seems to be because switch-to-buffer won't redisplay until some event
occurred, and neither using sit-for nor redisplay helps.

Here's the code:

(defun dim:switch-window-display-number (win num)
  "prepare a temp buffer to diplay in the window while choosing"
  (let ((buf (get-buffer-create
	      (concat " *" (number-to-string num) "*"))))
    (with-current-buffer buf
      (insert (concat "\n\n    " (number-to-string num)))
      (text-scale-adjust 12))

    ;; when it works we'll choose one or the other
    (set-window-buffer win buf)
    (select-window win)
    (switch-to-buffer buf 'non-record)
    buf))

(defun dim:switch-window ()
  "Display an overlay in each window showing a unique key, then
ask user for the window where move to"
  (interactive)
  (let ((config (current-window-configuration))
        (num 1)
	(redisplay-dont-pause t)
	key
        buffers)
    
    (dolist (win (window-list))
      (setq buffers (cons (dim:switch-window-display-number win num) buffers))
      (setq num (1+ num)))

    ;(redisplay 1)
    (sit-for 0)
    (while (not key)
      (let ((input (event-basic-type (read-event "Move to window: " nil 5))))
	(when (and (not (symbolp input)) (<= 49 input) (>= 57 input))
	  (setq key (- input 48)))))
    (message "%S" key)

    (dolist (buf buffers)
      (kill-buffer buf))

    (set-window-configuration config)

    (setq num 1)
    (dolist (win (window-list))
      (when (eq num key)
	(select-window win))
      (setq num (1+ num)))))


In GNU Emacs 23.1.90.1 (x86_64-apple-darwin10.2.0, NS apple-appkit-1038.25)
 of 2010-03-25 on proton.local
Windowing system distributor `Apple', version 10.3.1038
configured using `configure  '--without-dbus' '--with-ns' 'CFLAGS=-pipe -O2 -march=nocona''

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
  value of $XMODIFIERS: nil
  locale-coding-system: nil
  default enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
  savehist-mode: t
  desktop-save-mode: t
  nxhtml-global-minor-mode: t
  iswitchb-mode: t
  diff-auto-refine-mode: t
  global-hl-line-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
  global-auto-composition-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
  auto-fill-mode: 1

Recent input:
a r y : : SPC t h e SPC o n y <backspace> l y SPC c 
h a n g e SPC i s SPC h o w SPC t o SPC d o SPC i t 
, SPC n o t SPC w h a t SPC e r <backspace> <backspace> 
w e C-a M-f M-f M-f SPC p r o p o s e d C-e SPC c u 
r r e n <M-backspace> d o . C-x C-s C-a C-c C-c q p 
<return> M-` M-` C-n n M-` c o l u m n s , SPC s o 
r r y <return> a h SPC o <backspace> y s <backspace> 
e s <return> C-c C-b <return> w g a t <backspace> <backspace> 
<backspace> h a t s <backspace> ' s SPC t h a t SPC 
l i n g SPC h a s M-b M-b M-b <M-backspace> <backspace> 
SPC h a s SPC C-e <M-backspace> <backspace> <backspace> 
k SPC t SPC <backspace> o SPC d o SPC h e r e ? SPC 
: ) <return> M-` M-` i <backspace> l k <backspace> 
i k e SPC q <backspace> a <M-backspace> <M-backspace> 
a SPC 1 0 SPC h o u r s SPC t <backspace> p l a n e 
SPC t r p <backspace> i p SPC f o r SPC t h a t ? SPC 
n o SPC t h a n s <backspace> k s SPC : ) <return> 
M-` SPC n SPC n M-1 M-` <S-right> <S-up> C-h C-g C-x 
h M-w M-x e m <tab> a s <tab> c s <backspace> <backspace> 
<backspace> c s <tab> - r e <tab> <M-backspace> <M-backspace> 
r e p o <tab> r <tab> e m <backspace> <backspace> b 
<tab> <return>

Recent messages:
Fetching headers for nnimap+hm.local:PostgreSQL.hackers...done
Generating summary...done
Auto-saving...
20:23 You were mentioned by yonkeltron in #emacs [2 times]
20:24 You were mentioned by yonkeltron in #emacs [2 times]
Mark set [2 times]
Saved text until "+ num)))))

(provide 'dim-switch-window)"
Making completion list... [2 times]

Load-path shadows:
/Users/dim/.emacs.d/elpa/emms-3.0/tq hides ~/.emacs.d/emms/lisp/tq
/Users/dim/.emacs.d/elpa/emms-3.0/ogg-comment hides ~/.emacs.d/emms/lisp/ogg-comment
/Users/dim/.emacs.d/elpa/emms-3.0/later-do hides ~/.emacs.d/emms/lisp/later-do
/Users/dim/.emacs.d/elpa/emms-3.0/jack hides ~/.emacs.d/emms/lisp/jack
/Users/dim/.emacs.d/elpa/emms-3.0/emms hides ~/.emacs.d/emms/lisp/emms
/Users/dim/.emacs.d/elpa/emms-3.0/emms-volume hides ~/.emacs.d/emms/lisp/emms-volume
/Users/dim/.emacs.d/elpa/emms-3.0/emms-volume-amixer hides ~/.emacs.d/emms/lisp/emms-volume-amixer
/Users/dim/.emacs.d/elpa/emms-3.0/emms-url hides ~/.emacs.d/emms/lisp/emms-url
/Users/dim/.emacs.d/elpa/emms-3.0/emms-tag-editor hides ~/.emacs.d/emms/lisp/emms-tag-editor
/Users/dim/.emacs.d/elpa/emms-3.0/emms-streams hides ~/.emacs.d/emms/lisp/emms-streams
/Users/dim/.emacs.d/elpa/emms-3.0/emms-stream-info hides ~/.emacs.d/emms/lisp/emms-stream-info
/Users/dim/.emacs.d/elpa/emms-3.0/emms-source-playlist hides ~/.emacs.d/emms/lisp/emms-source-playlist
/Users/dim/.emacs.d/elpa/emms-3.0/emms-source-file hides ~/.emacs.d/emms/lisp/emms-source-file
/Users/dim/.emacs.d/elpa/emms-3.0/emms-setup hides ~/.emacs.d/emms/lisp/emms-setup
/Users/dim/.emacs.d/elpa/emms-3.0/emms-score hides ~/.emacs.d/emms/lisp/emms-score
/Users/dim/.emacs.d/elpa/emms-3.0/emms-playlist-sort hides ~/.emacs.d/emms/lisp/emms-playlist-sort
/Users/dim/.emacs.d/elpa/emms-3.0/emms-playlist-mode hides ~/.emacs.d/emms/lisp/emms-playlist-mode
/Users/dim/.emacs.d/elpa/emms-3.0/emms-playing-time hides ~/.emacs.d/emms/lisp/emms-playing-time
/Users/dim/.emacs.d/elpa/emms-3.0/emms-player-xine hides ~/.emacs.d/emms/lisp/emms-player-xine
/Users/dim/.emacs.d/elpa/emms-3.0/emms-player-simple hides ~/.emacs.d/emms/lisp/emms-player-simple
/Users/dim/.emacs.d/elpa/emms-3.0/emms-player-mplayer hides ~/.emacs.d/emms/lisp/emms-player-mplayer
/Users/dim/.emacs.d/elpa/emms-3.0/emms-player-mpg321-remote hides ~/.emacs.d/emms/lisp/emms-player-mpg321-remote
/Users/dim/.emacs.d/elpa/emms-3.0/emms-player-mpd hides ~/.emacs.d/emms/lisp/emms-player-mpd
/Users/dim/.emacs.d/elpa/emms-3.0/emms-mode-line hides ~/.emacs.d/emms/lisp/emms-mode-line
/Users/dim/.emacs.d/elpa/emms-3.0/emms-mode-line-icon hides ~/.emacs.d/emms/lisp/emms-mode-line-icon
/Users/dim/.emacs.d/elpa/emms-3.0/emms-metaplaylist-mode hides ~/.emacs.d/emms/lisp/emms-metaplaylist-mode
/Users/dim/.emacs.d/elpa/emms-3.0/emms-mark hides ~/.emacs.d/emms/lisp/emms-mark
/Users/dim/.emacs.d/elpa/emms-3.0/emms-lyrics hides ~/.emacs.d/emms/lisp/emms-lyrics
/Users/dim/.emacs.d/elpa/emms-3.0/emms-lastfm hides ~/.emacs.d/emms/lisp/emms-lastfm
/Users/dim/.emacs.d/elpa/emms-3.0/emms-last-played hides ~/.emacs.d/emms/lisp/emms-last-played
/Users/dim/.emacs.d/elpa/emms-3.0/emms-info hides ~/.emacs.d/emms/lisp/emms-info
/Users/dim/.emacs.d/elpa/emms-3.0/emms-info-ogginfo hides ~/.emacs.d/emms/lisp/emms-info-ogginfo
/Users/dim/.emacs.d/elpa/emms-3.0/emms-info-ogg hides ~/.emacs.d/emms/lisp/emms-info-ogg
/Users/dim/.emacs.d/elpa/emms-3.0/emms-info-mp3info hides ~/.emacs.d/emms/lisp/emms-info-mp3info
/Users/dim/.emacs.d/elpa/emms-3.0/emms-info-libtag hides ~/.emacs.d/emms/lisp/emms-info-libtag
/Users/dim/.emacs.d/elpa/emms-3.0/emms-i18n hides ~/.emacs.d/emms/lisp/emms-i18n
/Users/dim/.emacs.d/elpa/emms-3.0/emms-history hides ~/.emacs.d/emms/lisp/emms-history
/Users/dim/.emacs.d/elpa/emms-3.0/emms-compat hides ~/.emacs.d/emms/lisp/emms-compat
/Users/dim/.emacs.d/elpa/emms-3.0/emms-cache hides ~/.emacs.d/emms/lisp/emms-cache
/Users/dim/.emacs.d/elpa/emms-3.0/emms-browser hides ~/.emacs.d/emms/lisp/emms-browser
/Users/dim/.emacs.d/elpa/emms-3.0/emms-bookmarks hides ~/.emacs.d/emms/lisp/emms-bookmarks
/Users/dim/.emacs.d/nxhtml/util/htmlfontify hides /Applications/Emacs.app/Contents/Resources/lisp/htmlfontify
/Users/dim/.emacs.d/elpa/emms-3.0/tq hides /Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/tq
/Users/dim/.emacs.d/nxhtml/util/chart hides /Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/chart

Features:
(shadow emacsbug flow-fill multi-isearch bbdb-hooks w3m-form w3m-symbol
w3m doc-view image-mode w3m-hist w3m-fb w3m-ems w3m-ccl ccl w3m-favicon
w3m-image w3m-proc w3m-util dim-switch-window bbdb-gui gnus-cite smiley
ansi-color gnus-agent gnus-srvr nnvirtual gnus-async gnus-bcklg
gnus-score score-mode sort gnus-ml gnus-msg tar-mode face-remap ffap
gnus-topic nndoc gnus-cache nnfolder utf-7 utf7 auth-source nnimap imap
nndraft nnmh bbdb-gnus bbdb-snarf mail-extr bbdb-com warnings nnnil nntp
bbdb-autoloads bbdb timezone gnus-art mm-uu mml2015 epg-config mm-view
smime dig gnus-sum nnoo gnus-group gnus-undo nnmail mail-source
format-spec dim-gnus-imap-count gnus-start gnus-spec gnus-int gnus-range
gnus-win gnus gnus-ems flyspell ispell hideshow mlinks rx nxml-uchnm
rng-nxml rng-xsd xsd-regexp rng-cmpct sgml-mode nxhtml-mumamo mumamo-fun
mumamo nxhtml-mode popcmp url-expand url-util url-methods url-parse
url-vars rngalt rng-valid rng-loc rng-uri rng-parse nxml-parse rng-match
rng-dt rng-util rng-pttrn nxml-ns nxml-mode nxml-outln nxml-rap
nxml-util nxml-glyph nxml-enc xmltok loadhist make-mode doc-mode sql
cc-mode cc-fonts cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars
cc-defs python-21 python muse-colors org-wl org-w3m org-vm org-rmail
org-mhe org-mew org-irc org-jsinfo org-infojs org-html org-exp
org-exp-blocks org-agenda org-info org-gnus org-bibtex org-bbdb bitlbee
conf-mode newcomment jka-compr savehist desktop dim-tels-pro dim-modes
dim-org org-clock org-remember org-datetree org byte-opt bytecomp
byte-compile org-footnote org-src org-list org-faces org-compat org-macs
noutline outline remember org-install dim-ack browse-kill-ring
tramp-multi-sshx dictionary link connection emms-cache emms-info-ogginfo
emms-info-mp3info emms-info later-do emms-playlist-mode
emms-player-mplayer emms-player-simple emms-source-playlist
emms-source-file emms-setup emms emms-compat dim-pgsql linum w3m-load
nxhtml-autoload majmodpri nxhtml-menu nxhtml-autostart rst compile
asciidoc apropos dim-keys dim-previous-message dim-mailrc message
ecomplete rfc822 mml mml-sec password-cache mm-decode mm-bodies
mm-encode mailcap mail-parse rfc2231 rfc2047 rfc2045 qp ietf-drums
mailabbrev nnheader gnus-util netrc mm-util mail-prsvr gmm-utils
mailheader canlock sha1 hex-util hashcash mail-utils dim-input-method
quail help-mode view dim-google browse-url hippie-exp comint iswitchb
dired-details dired-x dired-aux dired winner buffer-move windmove
dim-escreen escreen dim-splits dim-rcirc dim-rcirc-log growl
rcirc-late-fix rcirc-color advice help-fns advice-preload rcirc-groups
rcirc time-date dim-projects dim-projects-home projects ibuf-ext
dim-muse dim-muse-hack muse-context muse-journal muse-book muse-latex
muse-html muse-xml-common cus-edit cus-start cus-load muse-publish
muse-project muse-protocols muse-regexps muse muse-nested-tags muse-mode
dim-init-macosx dim-offlineimap magit diff-mode log-edit easy-mmode
pcvs-util add-log parse-time cssh derived term disp-table ehelp electric
ring ibuffer pcmpl-unix pcomplete woman man assoc
color-theme-emacs23-default color-theme edmacro kmacro wid-edit cl cl-19
sendmail regexp-opt dim-visual-common hl-line dim-ports dim-lib
dictionary-autoloads emms-autoloads full-ack-autoloads gist-autoloads
htmlize-autoloads lisppaste-autoloads magit-autoloads muse-autoloads
info xml-rpc-autoloads package reporter tooltip ediff-hook vc-hooks
lisp-float-type mwheel ns-win easymenu tool-bar dnd fontset image fringe
lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar
mldrag 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 loaddefs button minibuffer faces cus-face files text-properties
overlay md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process ns multi-tty
emacs)

-- 
Dimitri Fontaine






^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#6078: Acknowledgement (23.1.90; switch-to-buffer does not redisplay until an event occurs)
       [not found] ` <handler.6078.B.127279835328349.ack@debbugs.gnu.org>
@ 2010-05-02 16:00   ` Dimitri Fontaine
  0 siblings, 0 replies; 6+ messages in thread
From: Dimitri Fontaine @ 2010-05-02 16:00 UTC (permalink / raw)
  To: 6078

[-- Attachment #1: Type: text/plain, Size: 473 bytes --]

help-debbugs@gnu.org (GNU bug Tracking System) writes:
> If you wish to submit further information on this problem, please
> send it to 6078@debbugs.gnu.org.

It appears that the bug is in fact calling text-scale-adjust which
consumes one event. Calling text-scale-increase instead fixes it.

For the working version of the program, please see the following link,
or the attachment inline.

  http://www.emacswiki.org/emacs/switch-window.el

Regards,
-- 
Dimitri Fontaine


[-- Attachment #2: visual method for switching windows --]
[-- Type: application/emacs-lisp, Size: 2721 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#6078: 23.1.90; switch-to-buffer does not redisplay until an event occurs
  2010-04-30 18:35 bug#6078: 23.1.90; switch-to-buffer does not redisplay until an event occurs Dimitri Fontaine
       [not found] ` <handler.6078.B.127279835328349.ack@debbugs.gnu.org>
@ 2010-05-02 18:57 ` martin rudalics
  2010-05-02 19:52   ` Dimitri Fontaine
  2010-05-03 16:32   ` Stefan Monnier
  1 sibling, 2 replies; 6+ messages in thread
From: martin rudalics @ 2010-05-02 18:57 UTC (permalink / raw)
  To: Dimitri Fontaine; +Cc: 6078

 > The following code, an attempt to have a visual window switching
 > facility, is failing to provide the visual clue it's meant to give. That
 > seems to be because switch-to-buffer won't redisplay until some event
 > occurred, and neither using sit-for nor redisplay helps.

Your problem is with `text-scale-adjust' which should be used only
interactively.  (BTW, you need neither the `select-window' nor the
`switch-to-buffer' in your code, `set-window-buffer' is sufficient.)

martin






^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#6078: 23.1.90; switch-to-buffer does not redisplay until an event occurs
  2010-05-02 18:57 ` bug#6078: 23.1.90; switch-to-buffer does not redisplay until an event occurs martin rudalics
@ 2010-05-02 19:52   ` Dimitri Fontaine
  2010-05-03 16:32   ` Stefan Monnier
  1 sibling, 0 replies; 6+ messages in thread
From: Dimitri Fontaine @ 2010-05-02 19:52 UTC (permalink / raw)
  To: martin rudalics; +Cc: 6078

martin rudalics <rudalics@gmx.at> writes:
> Your problem is with `text-scale-adjust' which should be used only
> interactively.  (BTW, you need neither the `select-window' nor the
> `switch-to-buffer' in your code, `set-window-buffer' is sufficient.)

Yeah, I've been hinted to use toggle-debug-on-quit meantime, and sent
a follow-up with this finding. Thanks a lot for helping, though!

As far as set-window-buffer is concerned, yeah, the fixed version only
use that, what you saw was like maddened attempts at forcing the code
into producing what I expected :)

Regards,
-- 
Dimitri Fontaine






^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#6078: 23.1.90; switch-to-buffer does not redisplay until an event occurs
  2010-05-02 18:57 ` bug#6078: 23.1.90; switch-to-buffer does not redisplay until an event occurs martin rudalics
  2010-05-02 19:52   ` Dimitri Fontaine
@ 2010-05-03 16:32   ` Stefan Monnier
  2010-05-03 17:17     ` martin rudalics
  1 sibling, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2010-05-03 16:32 UTC (permalink / raw)
  To: martin rudalics; +Cc: Dimitri Fontaine, 6078

> (BTW, you need neither the `select-window' nor the `switch-to-buffer'
> in your code, `set-window-buffer' is sufficient.)

OTOH, you'll want to pay attention to dedicated windows
(i.e. save&restore the window-dedicated-p value).


        Stefan








^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#6078: 23.1.90; switch-to-buffer does not redisplay until an event occurs
  2010-05-03 16:32   ` Stefan Monnier
@ 2010-05-03 17:17     ` martin rudalics
  0 siblings, 0 replies; 6+ messages in thread
From: martin rudalics @ 2010-05-03 17:17 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Dimitri Fontaine, 6078

 >> (BTW, you need neither the `select-window' nor the `switch-to-buffer'
 >> in your code, `set-window-buffer' is sufficient.)
 >
 > OTOH, you'll want to pay attention to dedicated windows
 > (i.e. save&restore the window-dedicated-p value).

Dimitri already saves and restores the window configuration.  This
should handle "weakly" dedicated windows.  If he also wants to handle
strongly dedicated windows, `set-window-buffer' will barf anyway - he
has to reset the status manually for each window and have the restore
step take care of setting it again.

martin






^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-05-03 17:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-30 18:35 bug#6078: 23.1.90; switch-to-buffer does not redisplay until an event occurs Dimitri Fontaine
     [not found] ` <handler.6078.B.127279835328349.ack@debbugs.gnu.org>
2010-05-02 16:00   ` bug#6078: Acknowledgement (23.1.90; switch-to-buffer does not redisplay until an event occurs) Dimitri Fontaine
2010-05-02 18:57 ` bug#6078: 23.1.90; switch-to-buffer does not redisplay until an event occurs martin rudalics
2010-05-02 19:52   ` Dimitri Fontaine
2010-05-03 16:32   ` Stefan Monnier
2010-05-03 17:17     ` martin rudalics

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).