unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Christopher Schmidt <christopher@ch.ristopher.com>
To: 13021@debbugs.gnu.org
Cc: Michael Heerdegen <michael_heerdegen@web.de>
Subject: bug#13021: 24.2.90; compile eval-after-load form
Date: Wed, 28 Nov 2012 15:05:56 +0000 (GMT)	[thread overview]
Message-ID: <87624p4vjd@ch.ristopher.com> (raw)

severity: wishlist

I think it is a good idea to compile the form that is passed to
eval-after-load.  The advantage is that one gets compiler warnings and
errors and the form itself is executed faster.

This is what I use:

    (defmacro eal (package &rest forms)
      (declare (indent 1) (debug t))
      `(,(if (if (symbolp package)
                 (require package nil t)
               (load package t t))
             'progn
           (message "eal: cannot find %s" package)
           'with-no-warnings)
        (eval-after-load ',package
          `(funcall (function ,(lambda () ,@forms))))))

This is what Michael (Heerdegen) uses:

    (defun-safe init-file-eval-after-load (file &rest forms)
      "Like `eval-after-load', but byte-compile FORMS before eval."
      (eval-after-load file `(let ((byte-compile-log-buffer "*Warnings*")
                                   (byte-compile-current-form
                                    (format "`init-file-eval-after-load': %s" ',file)))
                               (funcall (byte-compile (lambda () ,@forms))))))

Could vanilla eval-after-load be modified so it compiles the form?  I am
thinking of an optional third parameter, one that allows to either keep
the current behaviour (default), load the package & compile the form at
compile time or compile the form at run-time before evaling.

WDYT?

        Christopher





             reply	other threads:[~2012-11-28 15:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-28 15:05 Christopher Schmidt [this message]
2012-11-29  4:27 ` bug#13021: 24.2.90; compile eval-after-load form Stefan Monnier
2012-11-29 11:31   ` Juanma Barranquero
2013-06-19 23:55 ` Christopher Schmidt
2013-06-20 22:55   ` Michael Heerdegen
2013-06-21  1:08     ` Michael Heerdegen

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=87624p4vjd@ch.ristopher.com \
    --to=christopher@ch.ristopher.com \
    --cc=13021@debbugs.gnu.org \
    --cc=michael_heerdegen@web.de \
    /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).