unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Kenichi Handa <handa@m17n.org>
Cc: emacs-devel@gnu.org, monnier@IRO.UMontreal.CA, rms@gnu.org
Subject: Re: question about frame local variable
Date: Tue, 11 Nov 2003 17:38:23 +0900 (JST)	[thread overview]
Message-ID: <200311110838.RAA01590@etlken.m17n.org> (raw)
In-Reply-To: <863ccwjysw.fsf@gerd.free-bsd.org> (gerd.moellmann@t-online.de)

In article <863ccwjysw.fsf@gerd.free-bsd.org>, gerd.moellmann@t-online.de (Gerd Moellmann) writes:
>>  Perhaps, we should call
>>  select_frame_internal_for_variables_only around there.

> I think the best place is in redisplay_internal, which redisplays
> frame by frame.  Otherwise, we'd end up doing this for each window
> on a frame again and again.

> I can't work on this, but maybe this is helpful:

> void
> select_frame_for_redisplay (Lisp_Object frame)
> {
>   Lisp_Object tail, sym, val;
[...]
  
Thank you very much for the help.  I'm now using the
attached patch.  It seems that frame-local variables are
handled correctly.

Richard, what do you think about this change.  Shall I
install it?

---
Ken'ichi HANDA
handa@m17n.org

*** xdisp.c.~1.849.~	Mon Oct 13 11:25:49 2003
--- xdisp.c	Tue Nov 11 17:24:48 2003
***************
*** 814,819 ****
--- 814,820 ----
  static void push_it P_ ((struct it *));
  static void pop_it P_ ((struct it *));
  static void sync_frame_with_window_matrix_rows P_ ((struct window *));
+ static void select_frame_for_redisplay P_ ((Lisp_Object));
  static void redisplay_internal P_ ((int));
  static int echo_area_display P_ ((int));
  static void redisplay_windows P_ ((Lisp_Object));
***************
*** 9542,9547 ****
--- 9543,9586 ----
      }
  }
  \f
+ 
+ /* Select FRAME to forward the values of frame-local variables into C
+    variables so that the redisplay routines can access those values
+    directly.  */
+ 
+ static void
+ select_frame_for_redisplay (frame)
+      Lisp_Object frame;
+ {
+   Lisp_Object tail, sym, val;
+   Lisp_Object old = selected_frame;
+   
+   selected_frame = frame;
+ 
+   for (tail = XFRAME (frame)->param_alist; CONSP (tail); tail = XCDR (tail))
+     if (CONSP (XCAR (tail))
+ 	&& (sym = XCAR (XCAR (tail)),
+ 	    SYMBOLP (sym))
+ 	&& (sym = indirect_variable (sym),
+ 	    val = SYMBOL_VALUE (sym),
+ 	    (BUFFER_LOCAL_VALUEP (val)
+ 	     || SOME_BUFFER_LOCAL_VALUEP (val)))
+ 	&& XBUFFER_LOCAL_VALUE (val)->check_frame)
+       Fsymbol_value (sym);
+ 
+   for (tail = XFRAME (old)->param_alist; CONSP (tail); tail = XCDR (tail))
+     if (CONSP (XCAR (tail))
+ 	&& (sym = XCAR (XCAR (tail)),
+ 	    SYMBOLP (sym))
+ 	&& (sym = indirect_variable (sym),
+ 	    val = SYMBOL_VALUE (sym),
+ 	    (BUFFER_LOCAL_VALUEP (val)
+ 	     || SOME_BUFFER_LOCAL_VALUEP (val)))
+ 	&& XBUFFER_LOCAL_VALUE (val)->check_frame)
+       Fsymbol_value (sym);
+ }
+ 
+ 
  #define STOP_POLLING					\
  do { if (! polling_stopped_here) stop_polling ();	\
         polling_stopped_here = 1; } while (0)
***************
*** 9607,9613 ****
    /* Record a function that resets redisplaying_p to its old value
       when we leave this function.  */
    count = SPECPDL_INDEX ();
!   record_unwind_protect (unwind_redisplay, make_number (redisplaying_p));
    ++redisplaying_p;
    specbind (Qinhibit_free_realized_faces, Qnil);
  
--- 9646,9653 ----
    /* Record a function that resets redisplaying_p to its old value
       when we leave this function.  */
    count = SPECPDL_INDEX ();
!   record_unwind_protect (unwind_redisplay,
! 			 Fcons (make_number (redisplaying_p), selected_frame));
    ++redisplaying_p;
    specbind (Qinhibit_free_realized_faces, Qnil);
  
***************
*** 10021,10026 ****
--- 10061,10071 ----
  
  	  if (FRAME_WINDOW_P (f) || f == sf)
  	    {
+ 	      if (! EQ (frame, selected_frame))
+ 		/* Select the frame, for the sake of frame-local
+ 		   variables.  */
+ 		select_frame_for_redisplay (frame);
+ 
  #ifdef HAVE_WINDOW_SYSTEM
  	      if (clear_face_cache_count % 50 == 0
  		  && FRAME_WINDOW_P (f))
***************
*** 10273,10285 ****
  /* Function registered with record_unwind_protect in
     redisplay_internal.  Reset redisplaying_p to the value it had
     before redisplay_internal was called, and clear
!    prevent_freeing_realized_faces_p.  */
  
  static Lisp_Object
! unwind_redisplay (old_redisplaying_p)
!      Lisp_Object old_redisplaying_p;
  {
    redisplaying_p = XFASTINT (old_redisplaying_p);
    return Qnil;
  }
  
--- 10318,10337 ----
  /* Function registered with record_unwind_protect in
     redisplay_internal.  Reset redisplaying_p to the value it had
     before redisplay_internal was called, and clear
!    prevent_freeing_realized_faces_p.  It also selects the previously
!    selected frame.  */
  
  static Lisp_Object
! unwind_redisplay (val)
!      Lisp_Object val;
  {
+   Lisp_Object old_redisplaying_p, old_frame;
+ 
+   old_redisplaying_p = XCAR (val);
    redisplaying_p = XFASTINT (old_redisplaying_p);
+   old_frame = XCDR (val);
+   if (! EQ (old_frame, selected_frame))
+     select_frame_for_redisplay (old_frame);
    return Qnil;
  }

  reply	other threads:[~2003-11-11  8:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-25  0:49 question about frame local variable Kenichi Handa
2003-10-26 11:46 ` Richard Stallman
2003-10-28  8:03   ` Kenichi Handa
2003-10-30  1:35     ` Kenichi Handa
2003-10-30  9:33       ` Gerd Moellmann
2003-10-30 10:46         ` Kenichi Handa
2003-10-30 16:27         ` Stefan Monnier
2003-10-30 19:33           ` Gerd Moellmann
2003-11-10  1:05             ` Kenichi Handa
2003-11-10 10:35               ` Gerd Moellmann
2003-11-11  8:38                 ` Kenichi Handa [this message]
2003-11-12 20:02                   ` Richard Stallman
2003-11-13  0:42                     ` Kenichi Handa
2003-11-13  4:14                       ` Richard Stallman
2003-11-13  4:32                         ` Kenichi Handa

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=200311110838.RAA01590@etlken.m17n.org \
    --to=handa@m17n.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@IRO.UMontreal.CA \
    --cc=rms@gnu.org \
    /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).