emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Q: something like autoload for coding-systems?


From: Stefan Monnier
Subject: Re: Q: something like autoload for coding-systems?
Date: Tue, 06 Nov 2001 09:48:42 -0500

> "Eli Zaretskii" <address@hidden> writes:
> > It could be argued that find-coding-systems-region is mostly called
> > when we output text.  If that's so, in many cases the appropriate
> > coding tables would be already loaded, when that text was decoded
> > during input.
> 
> Ah!  That is a very persuasive argument.
> 
> > The alternative would be to load all the coding systems befor (or
> > inside) find-coding-systems-region, which would be wrong, to say the
> > least.
> 
> I agree.  We should avoid that.

I suspect you haven't seen Dave's patch that RMS was referring to.
So I attach it below for reference.
It probably needs a bit of cleanup before inclusion.


        Stefan


PS: actually, I tried to be more thorough this time.

        * international/mule.el (make-coding-system): Give coding-system
        a function definition for autoload purposes.

        * eval.c (Fautoload): Doc fix.

        * coding.c (setup_coding_system, Fcoding_system_p)
        (Fcheck_coding_system): Modify for autoloading coding systems.

 
Index: lisp/international/mule.el
===================================================================
RCS file: /cvs/emacs/lisp/international/mule.el,v
retrieving revision 1.123.2.1
retrieving revision 1.123
diff -u -r1.123.2.1 -r1.123
*** lisp/international/mule.el  2001/06/06 10:25:11     1.123.2.1
--- lisp/international/mule.el  2001/01/31 23:56:40     1.123
***************
*** 805,814 ****
  treated as a compiled CCL code.
  
  2. If PROPERTIES is just a list of character sets, the list is set as
! a value of `safe-charsets' in PLIST.
! 
! Kludgy feature for autoloading coding systems: CODING-SYSTEM and its
! variants are given a dummy function definition."
  
    ;; For compatiblity with XEmacs, we check the type of TYPE.  If it
    ;; is a symbol, perhaps, this function is called with XEmacs-style
--- 745,751 ----
  treated as a compiled CCL code.
  
  2. If PROPERTIES is just a list of character sets, the list is set as
! a value of `safe-charsets' in PLIST."
  
    ;; For compatiblity with XEmacs, we check the type of TYPE.  If it
    ;; is a symbol, perhaps, this function is called with XEmacs-style
***************
*** 1030,1037 ****
                                  (cons (append (car flags) '(t)) (cdr flags))
                                (cons (list (car flags) t) (cdr flags)))
                              properties))))
!   ;; We need to give it a function definition for autoloading to work.
!   (defalias coding-system 'ignore)
    coding-system)
  
  (defun define-coding-system-alias (alias coding-system)
--- 967,973 ----
                                  (cons (append (car flags) '(t)) (cdr flags))
                                (cons (list (car flags) t) (cdr flags)))
                              properties))))
! 
    coding-system)
  
  (defun define-coding-system-alias (alias coding-system)
Index: src/eval.c
===================================================================
RCS file: /cvs/emacs/src/eval.c,v
retrieving revision 1.155.2.2
retrieving revision 1.155
diff -u -r1.155.2.2 -r1.155
*** src/eval.c  2001/06/06 10:59:39     1.155.2.2
--- src/eval.c  2001/01/31 14:48:31     1.155
***************
*** 1769,1776 ****
  Fourth arg INTERACTIVE if non-nil says function can be called 
interactively.\n\
  Fifth arg TYPE indicates the type of the object:\n\
     nil or omitted says FUNCTION is a function,\n\
!    `keymap' says FUNCTION is really a keymap,\n\
!    `coding-system' says FUNCTION is really a coding-says, and\n\
     `macro' or t says FUNCTION is really a macro.\n\
  Third through fifth args give info about the real definition.\n\
  They default to nil.\n\
--- 1748,1754 ----
  Fourth arg INTERACTIVE if non-nil says function can be called 
interactively.\n\
  Fifth arg TYPE indicates the type of the object:\n\
     nil or omitted says FUNCTION is a function,\n\
!    `keymap' says FUNCTION is really a keymap, and\n\
     `macro' or t says FUNCTION is really a macro.\n\
  Third through fifth args give info about the real definition.\n\
  They default to nil.\n\
Index: src/coding.c
===================================================================
RCS file: /cvs/emacs/src/coding.c,v
retrieving revision 1.211.2.1
retrieving revision 1.211
diff -u -r1.211.2.1 -r1.211
*** src/coding.c        2001/06/06 10:46:58     1.211.2.1
--- src/coding.c        2001/01/26 06:10:21     1.211
***************
*** 3402,3432 ****
    if (NILP (coding_system))
      goto label_invalid_coding_system;
  
-  label_retry:
    coding_spec = Fget (coding_system, Qcoding_system);
  
    if (!VECTORP (coding_spec)
        || XVECTOR (coding_spec)->size != 5
        || !CONSP (XVECTOR (coding_spec)->contents[3]))
!     {
!       /* Should we do an autoload?  Autoload function forms for coding
!        systems have Qcoding_system as their fifth element.  */
!       coding_spec = XSYMBOL (coding_spec)->function;
!       if (CONSP (coding_spec)
!         && EQ (XCAR (coding_spec), Qautoload)
!         && EQ (Fnth (make_number (4), coding_spec), Qcoding_system))
!       {
!         struct gcpro gcpro1, gcpro2;
! 
!         GCPRO2 (coding_spec, coding_system);
!         do_autoload (coding_spec, coding_system);
!         UNGCPRO;
! 
!         goto label_retry;
!       }
!       else
!       goto label_invalid_coding_system;
!     }
  
    eol_type = inhibit_eol_conversion ? Qnil : Fget (coding_system, Qeol_type);
    if (VECTORP (eol_type))
--- 3401,3412 ----
    if (NILP (coding_system))
      goto label_invalid_coding_system;
  
    coding_spec = Fget (coding_system, Qcoding_system);
  
    if (!VECTORP (coding_spec)
        || XVECTOR (coding_spec)->size != 5
        || !CONSP (XVECTOR (coding_spec)->contents[3]))
!     goto label_invalid_coding_system;
  
    eol_type = inhibit_eol_conversion ? Qnil : Fget (coding_system, Qeol_type);
    if (VECTORP (eol_type))
***************
*** 6101,6123 ****
    (obj)
       Lisp_Object obj;
  {
-   Lisp_Object prop;
- 
    if (NILP (obj))
      return Qt;
    if (!SYMBOLP (obj))
      return Qnil;
    /* Get coding-spec vector for OBJ.  */
!   prop = Fget (obj, Qcoding_system);
!   if (VECTORP (prop) && XVECTOR (prop)->size == 5)
!     return Qt;
!   prop = XSYMBOL (obj)->function;
!   if (CONSP (prop)
!       && EQ (XCAR (prop), Qautoload)
!       && EQ (Fnth (make_number (4), prop), Qcoding_system))
!     return Qt;
!   else
!     return Qnil;
  }
  
  DEFUN ("read-non-nil-coding-system", Fread_non_nil_coding_system,
--- 6063,6076 ----
    (obj)
       Lisp_Object obj;
  {
    if (NILP (obj))
      return Qt;
    if (!SYMBOLP (obj))
      return Qnil;
    /* Get coding-spec vector for OBJ.  */
!   obj = Fget (obj, Qcoding_system);
!   return ((VECTORP (obj) && XVECTOR (obj)->size == 5)
!         ? Qt : Qnil);
  }
  
  DEFUN ("read-non-nil-coding-system", Fread_non_nil_coding_system,
***************
*** 6162,6179 ****
  {
    CHECK_SYMBOL (coding_system, 0);
    if (!NILP (Fcoding_system_p (coding_system)))
!     {
!       if (!NILP (coding_system)
!         && NILP (Fget (coding_system, Qcoding_system)))
!       {
!         struct gcpro gcpro1;
! 
!         GCPRO1 (coding_system);
!         do_autoload (XSYMBOL (coding_system)->function, coding_system);
!         UNGCPRO;
!       }
!       return coding_system;
!     }
    while (1)
      Fsignal (Qcoding_system_error, Fcons (coding_system, Qnil));
  }
--- 6115,6121 ----
  {
    CHECK_SYMBOL (coding_system, 0);
    if (!NILP (Fcoding_system_p (coding_system)))
!     return coding_system;
    while (1)
      Fsignal (Qcoding_system_error, Fcons (coding_system, Qnil));
  }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]