Article View: gnu.emacs.bug
Article #722Re: emacs should be able to load compressed files,
From: Darryl Okahata
Date: Thu, 27 Aug 1992 05:34
Date: Thu, 27 Aug 1992 05:34
183 lines
6996 bytes
6996 bytes
In gnu.emacs.bug, nickel@cs.tu-berlin.DE (Juergen Nickelsen)s writes:
> Has anyone implemented *loading* (as opposed to editing) compressed
> files yet? I'm not *too* eager to re-implement yet another wheel.
The wheel was invented a long time ago, by Michael Meissner of the
OSF. I added his changes to the "unofficial HP GNU Emacs", and so here
are the pertinent diffs (relative to the virginal FSF 18.58 Emacs). You
must #define READ_COMPRESSED_BYTE_COMPILED_FILES in config.h to turn on
the code; otherwise the old code remains in place.
-- Darryl Okahata
Internet: darrylo@sr.hp.com
DISCLAIMER: this message is the author's personal opinion and does not
constitute the support, opinion or policy of Hewlett-Packard or of the
little green men that have been following him all day.
===============================================================================
*** /tmp/emacs-18.58/src/lread.c Mon Jan 27 17:29:18 1992
--- lread.c Tue Mar 3 13:15:32 1992
***************
*** 159,164
static void readevalloop ();
static Lisp_Object load_unwind ();
DEFUN ("load", Fload, Sload, 1, 4, 0,
"Execute a file of Lisp code named FILE.\n\
First tries FILE with .elc appended, then tries with .el,\n\
--- 160,189 -----
static Lisp_Object load_unwind ();
Lisp_Object Vload_hooks;
+ #ifdef READ_COMPRESSED_BYTE_COMPILED_FILES
+ /*
+ * Read compressed byte-compiled files.
+ *
+ ******************************************************************************
+ * From meissner@osf.org Wed Mar 20 10:42:04 1991
+ * From: meissner@osf.org
+ * Date: Wed, 20 Mar 1991 18:42:04 GMT
+ * Subject: Loading compressed .el's
+ * Organization: Gatewayed from the GNU Project mailing list help-gnu-emacs@prep.ai.mit.edu
+ * Newsgroups: gnu.emacs.help,comp.emacs
+ * Followup-to: gnu.emacs.help
+ * Xref: hplabs gnu.emacs.help:1449 comp.emacs:2045
+ *
+ * | I'm using Gnu Emacs 18.55 on a machine with VERY little spare
+ * | disk space. I've managed to persuade info to read compressed
+ * | info files, but am at a loss as to how to get emacs to read
+ * | /load compressed *.el or *.elc files. Has anyone managed to do
+ * | this?
+ *
+ * Sure, you have to modify Fload, and then add a new function to create
+ * a filter on a file descriptor:
+ ******************************************************************************
+ */
DEFUN ("load", Fload, Sload, 1, 4, 0,
"Execute a file of Lisp code named FILE.\n\
First tries FILE with .elc appended, then tries with .elc.Z,\n\
***************
*** 161,166
DEFUN ("load", Fload, Sload, 1, 4, 0,
"Execute a file of Lisp code named FILE.\n\
First tries FILE with .elc appended, then tries with .el,\n\
then tries FILE unmodified. Searches directories in load-path.\n\
If optional second arg NOERROR is non-nil,\n\
--- 186,280 -----
*/
DEFUN ("load", Fload, Sload, 1, 4, 0,
"Execute a file of Lisp code named FILE.\n\
+ First tries FILE with .elc appended, then tries with .elc.Z,\n\
+ then tries with .el, then tries with .el.Z,\n\
+ then tries FILE unmodified. Searches directories in load-path.\n\
+ If a .elc.Z or .el.Z file is found, it is uncompressed.\n\
+ If optional second arg MISSING-OK is non-nil,\n\
+ report no error if FILE doesn't exist.\n\
+ Print messages at start and end of loading unless\n\
+ optional third arg NOMESSAGE is non-nil.\n\
+ If optional fourth arg NOSUFFIX is non-nil, don't try adding\n\
+ suffixes .elc, .elc.Z, .el or .el.Z to the specified name FILE.\n\
+ Return t if file exists.")
+ (str, missing_ok, nomessage, nosuffix)
+ Lisp_Object str, missing_ok, nomessage, nosuffix;
+ {
+ register FILE *stream;
+ register int fd = -1;
+ register Lisp_Object lispstream;
+ register FILE **ptr;
+ int count = specpdl_ptr - specpdl;
+ struct gcpro gcpro1, gcpro2;
+ Lisp_Object name = Qnil;
+ register int len;
+ register char *msg = "Loading %s...";
+
+ CHECK_STRING (str, 0);
+ str = Fsubstitute_in_file_name (str);
+
+ /* Avoid weird lossage with null string as arg,
+ since it would try to load a directory as a Lisp file */
+ if (XSTRING (str)->size > 0)
+ {
+ fd = openp (Vload_path, str, !NULL (nosuffix) ? "" : ".elc:.elc.Z:.el:.el.Z:", &name, 0);
+ }
+
+ if (fd < 0)
+ if (NULL (missing_ok))
+ while (1)
+ Fsignal (Qfile_error, Fcons (build_string ("Cannot open load file"),
+ Fcons (str, Qnil)));
+ else return Qnil;
+
+ #ifndef standalone
+ if (XTYPE (name) == Lisp_String
+ && (len = XSTRING (name)->size) > 2
+ && strcmp ((char *)&XSTRING (name)->data[len-2], ".Z") == 0)
+ {
+ char *new_argv[3];
+
+ msg = "Decompressing and loading %s...";
+ new_argv[0] = "zcat";
+ new_argv[1] = (char *)XSTRING (name)->data;
+ new_argv[2] = (char *)0;
+
+ fd = create_filter (fd, new_argv);
+ }
+ #endif /* standalone */
+
+ stream = fdopen (fd, "r");
+ if (stream == 0)
+ {
+ close (fd);
+ error ("Failure to create stdio stream for %s", XSTRING (str)->data);
+ }
+
+ if (NULL (nomessage))
+ message (msg, XSTRING (name)->data);
+
+ GCPRO2 (str, name);
+ ptr = (FILE **) xmalloc (sizeof (FILE *));
+ *ptr = stream;
+ XSET (lispstream, Lisp_Internal_Stream, (int) ptr);
+ record_unwind_protect (load_unwind, lispstream);
+ load_in_progress++;
+ readevalloop (Qget_file_char, stream, Feval, 0);
+ unbind_to (count);
+ UNGCPRO;
+
+ if (!noninteractive && NULL (nomessage))
+ message ("Loading %s...done", XSTRING (name)->data);
+ return Qt;
+ }
+
+ #else
+ /*
+ * Original function
+ */
+
+ DEFUN ("load", Fload, Sload, 1, 4, 0,
+ "Execute a file of Lisp code named FILE.\n\
First tries FILE with .elc appended, then tries with .el,\n\
then tries FILE unmodified. Searches directories in load-path.\n\
If optional second arg NOERROR is non-nil,\n\
***************
*** 221,226
message ("Loading %s...done", XSTRING (str)->data);
return Qt;
}
static Lisp_Object
load_unwind (stream) /* used as unwind-protect function in load */
--- 343,349 -----
message ("Loading %s...done", XSTRING (str)->data);
return Qt;
}
+ #endif
static Lisp_Object
load_unwind (stream) /* used as unwind-protect function in load */
Technical Details
Message-ID:
<9208271934.AA11136@hpnmdla.sr.hp.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!hpnmdla.sr.hp.com!darryloReferences:
<NICKEL.92Aug26214805@desaster.cs.tu-berlin.de>Show Full Headers
Complete Article Headers
Newsgroups: gnu.emacs.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!hpnmdla.sr.hp.com!darrylo From: darrylo@hpnmdla.sr.hp.com (Darryl Okahata) Subject: Re: emacs should be able to load compressed files, Message-ID: <9208271934.AA11136@hpnmdla.sr.hp.com> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet References: <NICKEL.92Aug26214805@desaster.cs.tu-berlin.de> Distribution: gnu Date: Thu, 27 Aug 1992 05:34:20 GMT Approved: bug-gnu-emacs@prep.ai.mit.edu Lines: 184