[Top][All Lists]

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

Re: Loading souce Elisp faster

From: Kenichi Handa
Subject: Re: Loading souce Elisp faster
Date: Wed, 27 Feb 2013 13:18:16 +0900

In article <address@hidden>, Stefan Monnier <address@hidden> writes:

> > Why not assuming it is utf-8? ;-)
> > Unless there is a "-*- coding: ..." comment.

> Hmm... that's very appealing, but what about those Elisp files that have
> a "coding:" tag at the end of the file?  Or are these so rare it's not
> worth the trouble to worry about them?

Isn't it ok to make it faster to load only such a file that
has "-*- coding: utf-8-unix -*-", and document it clearly.

The following is just an quick idea.

(defun load-source-file-internal (fullname file &optional noerror nomessage)
  (let (need-decoding)
      (let ((coding-system-for-read 'no-conversion))
        (insert-file-contents fullname nil 0 256)  ; or 512, 1024?
        (or (coding-tag-is-utf-8-unix-p) ; this function must be implemented.
            (setq need-decoding t))))
    (if need-decoding
        (load-with-code-conversion fullname file noerror nomessage)
      (load fullname noerror nomessage nil nil
            t           ; new optional argument to tell Fopen to load
                        ; this file without through code-conversion.

(setq load-source-file-function 'load-source-file-internal)

Kenichi Handa

reply via email to

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