emacs-devel
[Top][All Lists]
Advanced

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

Re: Changing load-suffixes


From: Chong Yidong
Subject: Re: Changing load-suffixes
Date: Sun, 19 Feb 2006 00:21:29 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

"Richard M. Stallman" <address@hidden> writes:

> We decided to change how load-suffixes would work,
> but it looks like that change has not been installed.

Since this issue seems to have gotten stalled, I looked into it.  How
about the following patch?

*** emacs/src/lread.c.~1.349.~  2006-02-18 18:19:03.000000000 -0500
--- emacs/src/lread.c   2006-02-19 00:13:13.000000000 -0500
***************
*** 99,104 ****
--- 99,105 ----
  
  /* Search path and suffixes for files to be loaded. */
  Lisp_Object Vload_path, Vload_suffixes, default_suffixes;
+ Lisp_Object Vload_file_rep_suffixes;
  
  /* File name of user's init file.  */
  Lisp_Object Vuser_init_file;
***************
*** 727,732 ****
--- 728,734 ----
    if (SCHARS (file) > 0)
      {
        int size = SBYTES (file);
+       Lisp_Object tail, stail, reps, rep, suffixes, all_suffixes;
        Lisp_Object tmp[2];
  
        found = Qnil;
***************
*** 747,759 ****
            must_suffix = Qnil;
        }
  
!       fd = openp (Vload_path, file,
!                 (!NILP (nosuffix) ? Qnil
!                  : !NILP (must_suffix) ? Vload_suffixes
!                  : Fappend (2, (tmp[0] = Vload_suffixes,
!                                 tmp[1] = default_suffixes,
!                                 tmp))),
!                 &found, Qnil);
        UNGCPRO;
      }
  
--- 749,779 ----
            must_suffix = Qnil;
        }
  
!       all_suffixes = suffixes = (!NILP (nosuffix) ? default_suffixes
!                                : !NILP (must_suffix) ? Vload_suffixes
!                                : Fappend (2, (tmp[0] = Vload_suffixes,
!                                               tmp[1] = default_suffixes,
!                                               tmp)));
! 
!       for (tail = Vload_file_rep_suffixes; CONSP (tail); tail = XCDR (tail))
!       {
!         rep = XCAR (tail);
! 
!         if (!GC_STRINGP (rep))
!           continue;
! 
!         reps = Fcopy_sequence (suffixes);
!         for (stail = reps; CONSP (stail); stail = XCDR (stail))
!           if (GC_STRINGP (XCAR (stail)))
!             XSETCAR (stail, Fconcat (2, (tmp[0] = XCAR (stail),
!                                          tmp[1] = rep, tmp)));
! 
!         all_suffixes = Fappend (2, (tmp[0] = all_suffixes,
!                                     tmp[1] = reps, tmp));
!       }
! 
!       fd = openp (Vload_path, file, all_suffixes, &found, Qnil);
! 
        UNGCPRO;
      }
  
***************
*** 3909,3914 ****
--- 3929,3944 ----
    default_suffixes = Fcons (build_string (""), Qnil);
    staticpro (&default_suffixes);
  
+   DEFVAR_LISP ("load-file-rep-suffixes", &Vload_file_rep_suffixes,
+              doc: /* List of additional suffixes to try for files to load.
+ These suffixes stand for different ways of representing the same file.
+ 
+ For example, if `load-suffixes' is '(\".elc\" \".el\") and
+ `load-file-rep-suffixes' is '(\"gz\"), then (load \"foo\") will look
+ for \"foo.elc\", \"foo.el\", \"foo\", \"foo.elc.gz\", \"foo.el.gz\",
+ and \"foo.gz\", in that order. */);
+   Vload_file_rep_suffixes = Qnil;
+ 
    DEFVAR_BOOL ("load-in-progress", &load_in_progress,
               doc: /* Non-nil iff inside of `load'.  */);
  
*** emacs/lisp/jka-cmpr-hook.el.~1.9.~  2006-02-06 23:43:16.000000000 -0500
--- emacs/lisp/jka-cmpr-hook.el 2006-02-18 23:46:23.000000000 -0500
***************
*** 216,229 ****
        (append auto-mode-alist jka-compr-mode-alist-additions))
  
    ;; Make sure that (load "foo") will find /bla/foo.el.gz.
!   (setq load-suffixes
!       (apply 'append
!              (append (mapcar (lambda (suffix)
!                                (cons suffix
!                                      (mapcar (lambda (ext) (concat suffix 
ext))
!                                              jka-compr-load-suffixes)))
!                              load-suffixes)
!                        (list jka-compr-load-suffixes)))))
  
  
  (defun jka-compr-installed-p ()
--- 216,223 ----
        (append auto-mode-alist jka-compr-mode-alist-additions))
  
    ;; Make sure that (load "foo") will find /bla/foo.el.gz.
!   (setq load-file-rep-suffixes
!       (append jka-compr-load-suffixes load-file-rep-suffixes)))
  
  
  (defun jka-compr-installed-p ()
*** emacs/lisp/jka-compr.el.~1.89.~     2006-02-06 23:43:16.000000000 -0500
--- emacs/lisp/jka-compr.el     2006-02-18 23:47:57.000000000 -0500
***************
*** 703,712 ****
    ;; Remove the suffixes that were added by jka-compr.
    (let ((suffixes nil)
        (re (jka-compr-build-file-regexp)))
!     (dolist (suffix load-suffixes)
        (unless (string-match re suffix)
        (push suffix suffixes)))
!     (setq load-suffixes (nreverse suffixes))))
  
  (provide 'jka-compr)
  
--- 703,712 ----
    ;; Remove the suffixes that were added by jka-compr.
    (let ((suffixes nil)
        (re (jka-compr-build-file-regexp)))
!     (dolist (suffix load-file-rep-suffixes)
        (unless (string-match re suffix)
        (push suffix suffixes)))
!     (setq load-file-rep-suffixes (nreverse suffixes))))
  
  (provide 'jka-compr)
  




reply via email to

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