From: martin rudalics <rudalics@gmx.at>
To: rms@gnu.org
Cc: Kenichi Handa <handa@m17n.org>, emacs-devel@gnu.org
Subject: Re: insert-file-contents and format-decode
Date: Mon, 02 Jul 2007 10:27:09 +0200 [thread overview]
Message-ID: <4688B6DD.9030600@gmx.at> (raw)
In-Reply-To: <E1I4nKf-0002m7-JR@fencepost.gnu.org>
[-- Attachment #1: Type: text/plain, Size: 355 bytes --]
> So the only remaining change to be done is to inhibit execution of
> certain hooks in `format-decode' and around the calls to
> `after-insert-file-functions'.
Please have a look at the attached patch (my acquaintance with C code
is marginal). Handa-san could you please check whether such a patch
would introduce conflicts with the unicode-2 branch.
[-- Attachment #2: fileio.patch --]
[-- Type: text/plain, Size: 5664 bytes --]
*** fileio.c Mon Jul 2 07:27:56 2007
--- fileio.c Mon Jul 2 08:23:20 2007
***************
*** 3720,3727 ****
register int how_much;
register int unprocessed;
int count = SPECPDL_INDEX ();
! struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
! Lisp_Object handler, val, insval, orig_filename;
Lisp_Object p;
int total = 0;
int not_regular = 0;
--- 3720,3727 ----
register int how_much;
register int unprocessed;
int count = SPECPDL_INDEX ();
! struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
! Lisp_Object handler, val, insval, orig_filename, old_undo;
Lisp_Object p;
int total = 0;
int not_regular = 0;
***************
*** 3744,3751 ****
val = Qnil;
p = Qnil;
orig_filename = Qnil;
! GCPRO4 (filename, val, p, orig_filename);
CHECK_STRING (filename);
filename = Fexpand_file_name (filename, Qnil);
--- 3744,3752 ----
val = Qnil;
p = Qnil;
orig_filename = Qnil;
+ old_undo = Qnil;
! GCPRO5 (filename, val, p, orig_filename, old_undo);
CHECK_STRING (filename);
filename = Fexpand_file_name (filename, Qnil);
***************
*** 4704,4727 ****
/* Decode file format */
if (inserted > 0)
{
! int empty_undo_list_p = 0;
!
! /* If we're anyway going to discard undo information, don't
! record it in the first place. The buffer's undo list at this
! point is either nil or t when visiting a file. */
! if (!NILP (visit))
{
! empty_undo_list_p = NILP (current_buffer->undo_list);
! current_buffer->undo_list = Qt;
}
! insval = call3 (Qformat_decode,
! Qnil, make_number (inserted), visit);
! CHECK_NUMBER (insval);
! inserted = XFASTINT (insval);
!
! if (!NILP (visit))
! current_buffer->undo_list = empty_undo_list_p ? Qnil : Qt;
}
/* Call after-change hooks for the inserted text, aside from the case
--- 4705,4806 ----
/* Decode file format */
if (inserted > 0)
{
! /* Don't run point motion or modification hooks when decoding. */
! int count = SPECPDL_INDEX ();
! specbind (Qinhibit_point_motion_hooks, Qt);
! specbind (Qinhibit_modification_hooks, Qt);
!
! /* Save old undo list and don't record undo for decoding. */
! old_undo = current_buffer->undo_list;
! current_buffer->undo_list = Qt;
!
! if (NILP (replace))
{
! insval = call3 (Qformat_decode,
! Qnil, make_number (inserted), visit);
! CHECK_NUMBER (insval);
! inserted = XFASTINT (insval);
! }
! else
! {
! /* Suppose replace is non-nil and we succeeded in not replacing the
! beginning or end of the buffer text with the file's contents. In this
! case we neverthelss have to call format-decode with `point' positioned
! at the beginning of the buffer and `inserted' equalling the number of
! characters in the buffer. Otherwise, format-decode might fail to
! correctly analyze the beginning or end of the buffer. Hence we
! temporarily save `point' and `inserted' here and restore `point' iff
! format-decode didn't insert or delete any text. Otherwise we leave
! `point' at point-min. */
! int opoint = PT;
! int opoint_byte = PT_BYTE;
! int oinserted = ZV - BEGV;
!
! TEMP_SET_PT_BOTH (BEGV, BEGV_BYTE);
! insval = call3 (Qformat_decode,
! Qnil, make_number (oinserted), visit);
! CHECK_NUMBER (insval);
! if (insval = oinserted)
! SET_PT_BOTH (opoint, opoint_byte);
! inserted = XFASTINT (insval);
}
! /* For consistency with format-decode call these now iff inserted > 0
! (martin 2007-06-28) */
! p = Vafter_insert_file_functions;
! while (CONSP (p))
! {
! if (NILP (replace))
! {
! insval = call1 (XCAR (p), make_number (inserted));
! if (!NILP (insval))
! {
! CHECK_NUMBER (insval);
! inserted = XFASTINT (insval);
! }
! }
! else
! {
! /* For the rationale of this see the comment on format-decode above. */
! int opoint = PT;
! int opoint_byte = PT_BYTE;
! int oinserted = ZV - BEGV;
!
! TEMP_SET_PT_BOTH (BEGV, BEGV_BYTE);
! insval = call1 (XCAR (p), make_number (oinserted));
! if (!NILP (insval))
! {
! CHECK_NUMBER (insval);
! if (insval = oinserted)
! SET_PT_BOTH (opoint, opoint_byte);
! inserted = XFASTINT (insval);
! }
! }
!
! QUIT;
! p = XCDR (p);
! }
!
! if (NILP (visit))
! {
! Lisp_Object lbeg, lend;
! XSETINT (lbeg, PT);
! XSETINT (lend, PT + inserted);
! if (CONSP (old_undo))
! {
! Lisp_Object tem = XCAR (old_undo);
! if (CONSP (tem) && INTEGERP (XCAR (tem)) &&
! INTEGERP (XCDR (tem)) && (XCAR (tem)) == lbeg)
! /* In the non-visiting case record only the final insertion. */
! current_buffer->undo_list =
! Fcons (Fcons (lbeg, lend), Fcdr (old_undo));
! }
! }
! else
! /* In the visiting case restore the previous value. */
! current_buffer->undo_list = old_undo;
!
! unbind_to (count, Qnil);
}
/* Call after-change hooks for the inserted text, aside from the case
***************
*** 4734,4752 ****
update_compositions (PT, PT, CHECK_BORDER);
}
- p = Vafter_insert_file_functions;
- while (CONSP (p))
- {
- insval = call1 (XCAR (p), make_number (inserted));
- if (!NILP (insval))
- {
- CHECK_NUMBER (insval);
- inserted = XFASTINT (insval);
- }
- QUIT;
- p = XCDR (p);
- }
-
if (!NILP (visit)
&& current_buffer->modtime == -1)
{
--- 4813,4818 ----
[-- Attachment #3: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
next prev parent reply other threads:[~2007-07-02 8:27 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-06 14:06 insert-file-contents and format-decode martin rudalics
2007-06-08 7:12 ` Richard Stallman
2007-06-17 13:34 ` martin rudalics
2007-06-18 21:31 ` Richard Stallman
2007-06-19 7:50 ` martin rudalics
2007-06-23 18:26 ` Richard Stallman
2007-06-23 18:26 ` Richard Stallman
2007-06-24 10:30 ` martin rudalics
2007-06-25 13:19 ` Richard Stallman
2007-06-26 6:54 ` martin rudalics
2007-06-26 22:48 ` Richard Stallman
2007-06-27 6:33 ` martin rudalics
2007-06-27 19:50 ` Richard Stallman
2007-06-30 11:11 ` martin rudalics
2007-07-01 0:30 ` Richard Stallman
2007-07-02 8:14 ` martin rudalics
2007-07-03 4:24 ` Richard Stallman
2007-07-03 6:47 ` martin rudalics
2007-07-04 3:43 ` Richard Stallman
2007-06-26 22:48 ` Richard Stallman
2007-06-27 6:34 ` martin rudalics
2007-06-27 23:43 ` Richard Stallman
2007-06-30 11:32 ` martin rudalics
2007-07-01 0:30 ` Richard Stallman
2007-07-02 8:27 ` martin rudalics [this message]
2007-07-03 4:24 ` Richard Stallman
2007-07-03 6:43 ` martin rudalics
2007-08-06 14:22 ` Richard Stallman
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=4688B6DD.9030600@gmx.at \
--to=rudalics@gmx.at \
--cc=emacs-devel@gnu.org \
--cc=handa@m17n.org \
--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).