all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: recursive load case in openp
@ 2002-04-10 23:43 Kenichi Handa
  2002-04-11 13:01 ` Stefan Monnier
  2002-04-12  3:12 ` Richard Stallman
  0 siblings, 2 replies; 12+ messages in thread
From: Kenichi Handa @ 2002-04-10 23:43 UTC (permalink / raw)
  Cc: eliz, walters, emacs-devel

Richard Stallman <rms@gnu.org> writes:
>>  Why does encode_coding_string call
>> temp_output_buffer_setup?
>     To run post-read-conversion and pre-write-conversion
> functions of a coding system.  We must make a temporary
> working buffer for them.

> I don't see anything like that in the code of
> temp_output_buffer_setup.  What exactly in the code of
> temp_output_buffer_setup do you actually want to do here?

Here's a copy of temp_output_buffer_setup.  I just need
lines from Fset_buffer to Ferase_buffer (inclusive).

void
temp_output_buffer_setup (bufname)
    char *bufname;
{
  int count = specpdl_ptr - specpdl;
  register struct buffer *old = current_buffer;
  register Lisp_Object buf;

  record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ());

  Fset_buffer (Fget_buffer_create (build_string (bufname)));

  current_buffer->directory = old->directory;
  current_buffer->read_only = Qnil;
  current_buffer->filename = Qnil;
  current_buffer->undo_list = Qt;
  current_buffer->overlays_before = Qnil;
  current_buffer->overlays_after = Qnil;
  current_buffer->enable_multibyte_characters
    = buffer_defaults.enable_multibyte_characters;
  Ferase_buffer ();

  XSETBUFFER (buf, current_buffer);

  Frun_hooks (1, &Qtemp_buffer_setup_hook);

  unbind_to (count, Qnil);

  specbind (Qstandard_output, buf);
}

---
Ken'ichi HANDA
handa@etl.go.jp

^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: recursive load case in openp
@ 2002-04-12  6:48 Kenichi Handa
  0 siblings, 0 replies; 12+ messages in thread
From: Kenichi Handa @ 2002-04-12  6:48 UTC (permalink / raw)
  Cc: eliz, walters, emacs-devel

Richard Stallman <rms@gnu.org> writes:
> Does this do the job?

Yes at least with a few small tests.  We also have to change
Finsert_file_contents.

But, I think:

> !   buffer = Fget_buffer_create (build_string (" *code-converting-work*"));
> !   buf = XBUFFER (buffer);
> ! 
> !   buf->directory = current_buffer->directory;
> !   buf->read_only = Qnil;
> !   buf->filename = Qnil;
> !   buf->undo_list = Qt;
> !   buf->overlays_before = Qnil;
> !   buf->overlays_after = Qnil;
> ! 
> !   set_buffer_internal (buf);
[...]
>     Ferase_buffer ();

it is better that we keep this sequence in a separate
function (or macro), otherwise, for instance, we may forget
to set overlays_before/after to nil in the other place in
the future.

Then, we can call that function from coding.c,
Finsert_file_contents, and also from
temp_output_buffer_setup.

---
Ken'ichi HANDA
handa@etl.go.jp

^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: recursive load case in openp
@ 2002-04-09 12:34 Kenichi Handa
  2002-04-10 20:17 ` Richard Stallman
  0 siblings, 1 reply; 12+ messages in thread
From: Kenichi Handa @ 2002-04-09 12:34 UTC (permalink / raw)
  Cc: eliz, walters, emacs-devel

Richard Stallman <rms@gnu.org> writes:
> Why does encode_coding_string call temp_output_buffer_setup?

To run post-read-conversion and pre-write-conversion
functions of a coding system.  We must make a temporary
working buffer for them.

> That is meant for buffers that are going to be displayed.
> It should not be used for temporary buffers used for internal
> purposes.

I didn't know that.

> I don't think encode_coding_string should call it.

Ok.  Then, let's make a function which does almost the same
thing as temp_output_buffer_setup.  That function doesn't
run temp-buffer-setup-hook, and instead of binding
Qstandard_output, it returns a working buffer.

And, change run_pre_post_conversion_on_str and
Finsert_file_contents to call it.

---
Ken'ichi HANDA
handa@etl.go.jp

^ permalink raw reply	[flat|nested] 12+ messages in thread
* recursive load case in openp
@ 2002-04-08  2:55 Colin Walters
  2002-04-08  6:50 ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Colin Walters @ 2002-04-08  2:55 UTC (permalink / raw)


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

Hi, 

I found a bug (or rather my init files did) in the current CVS.  It
appears to have been introduced by the following change:

2002-03-29  Eli Zaretskii  <eliz@is.elta.co.il>

	* lread.c (openp, Fload): Encode the file name before passing it
	to `stat', `access', and `emacs_open'.
	(openp): GCPRO the encoded file name.  Don't recompute Lisp
	strings unnecessarily.

The problem is reproducible on my system by starting emacs like:

emacs -q --no-site-file --eval '(set-language-environment "utf-8")'

What seems to be happening is that openp eventually calls
encode_coding_string, which eventually calls temp_output_buffer_setup,
which then runs the hook variable `temp-buffer-setup-hook', whose value
defaults to the single symbol `help-mode-setup'.  Therefore, since
help-mode is autoloaded, emacs will attempt to load it, and enter Fload,
and therefore reenter openp, try to load help-mode again...

The following patch fixes the problem on my system; Does anyone have any
objections to fixing the problem in this way?



[-- Attachment #2: emacs.patch --]
[-- Type: text/x-patch, Size: 3202 bytes --]

Index: bytecode.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/bytecode.c,v
retrieving revision 1.68
diff -u -r1.68 bytecode.c
--- bytecode.c	20 Mar 2002 07:44:54 -0000	1.68
+++ bytecode.c	8 Apr 2002 02:54:42 -0000
@@ -896,7 +896,7 @@
 	case Btemp_output_buffer_setup:
 	  BEFORE_POTENTIAL_GC ();
 	  CHECK_STRING (TOP);
-	  temp_output_buffer_setup (XSTRING (TOP)->data);
+	  temp_output_buffer_setup (XSTRING (TOP)->data, 1);
 	  AFTER_POTENTIAL_GC ();
 	  TOP = Vstandard_output;
 	  break;
Index: coding.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/coding.c,v
retrieving revision 1.240
diff -u -r1.240 coding.c
--- coding.c	11 Mar 2002 19:21:09 -0000	1.240
+++ coding.c	8 Apr 2002 02:54:43 -0000
@@ -5801,7 +5801,7 @@
   record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
   record_unwind_protect (code_convert_region_unwind, Qnil);
   GCPRO1 (str);
-  temp_output_buffer_setup (" *code-converting-work*");
+  temp_output_buffer_setup (" *code-converting-work*", 0);
   set_buffer_internal (XBUFFER (Vstandard_output));
   /* We must insert the contents of STR as is without
      unibyte<->multibyte conversion.  For that, we adjust the
Index: lisp.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/lisp.h,v
retrieving revision 1.415
diff -u -r1.415 lisp.h
--- lisp.h	21 Mar 2002 12:17:51 -0000	1.415
+++ lisp.h	8 Apr 2002 02:54:43 -0000
@@ -2424,7 +2424,7 @@
 EXFUN (Ferror_message_string, 1);
 extern Lisp_Object Vstandard_output, Qstandard_output;
 extern Lisp_Object Qexternal_debugging_output;
-extern void temp_output_buffer_setup P_ ((char *));
+extern void temp_output_buffer_setup P_ ((char *, int));
 extern int print_level, print_escape_newlines;
 extern Lisp_Object Qprint_escape_newlines;
 extern void write_string P_ ((char *, int));
Index: print.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/print.c,v
retrieving revision 1.174
diff -u -r1.174 print.c
--- print.c	16 Mar 2002 06:53:35 -0000	1.174
+++ print.c	8 Apr 2002 02:54:44 -0000
@@ -577,8 +577,9 @@
 
 
 void
-temp_output_buffer_setup (bufname)
+temp_output_buffer_setup (bufname, hooks)
     char *bufname;
+    int hooks;
 {
   int count = specpdl_ptr - specpdl;
   register struct buffer *old = current_buffer;
@@ -599,7 +600,8 @@
   Ferase_buffer ();
   XSETBUFFER (buf, current_buffer);
 
-  Frun_hooks (1, &Qtemp_buffer_setup_hook);
+  if (hooks)
+    Frun_hooks (1, &Qtemp_buffer_setup_hook);
 
   unbind_to (count, Qnil);
 
@@ -618,7 +620,7 @@
 
   GCPRO1 (args);
   record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
-  temp_output_buffer_setup (bufname);
+  temp_output_buffer_setup (bufname, 1);
   buf = Vstandard_output;
   UNGCPRO;
 
@@ -663,7 +665,7 @@
   GCPRO1(args);
   name = Feval (Fcar (args));
   CHECK_STRING (name);
-  temp_output_buffer_setup (XSTRING (name)->data);
+  temp_output_buffer_setup (XSTRING (name)->data, 1);
   buf = Vstandard_output;
   UNGCPRO;
 

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

end of thread, other threads:[~2002-04-12  9:35 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-10 23:43 recursive load case in openp Kenichi Handa
2002-04-11 13:01 ` Stefan Monnier
2002-04-12  3:13   ` Richard Stallman
2002-04-12  4:03     ` Stefan Monnier
2002-04-12  9:35       ` Kim F. Storm
2002-04-12  3:12 ` Richard Stallman
  -- strict thread matches above, loose matches on Subject: below --
2002-04-12  6:48 Kenichi Handa
2002-04-09 12:34 Kenichi Handa
2002-04-10 20:17 ` Richard Stallman
2002-04-08  2:55 Colin Walters
2002-04-08  6:50 ` Eli Zaretskii
2002-04-09 12:07   ` Richard Stallman

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.