all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Pascal Bourguignon <pjb@informatimago.com>
To: help-gnu-emacs@gnu.org
Subject: Re: How to halt a loading file
Date: Sat, 29 Mar 2008 17:25:52 +0100	[thread overview]
Message-ID: <878x01pkdr.fsf@thalassa.informatimago.com> (raw)
In-Reply-To: mailman.9577.1206803738.18990.help-gnu-emacs@gnu.org

Kevin Rodgers <kevin.d.rodgers@gmail.com> writes:

> orium wrote:
>> Hi, everybody.
>> I am not a lisp coder, so this may have a obvious answer.
>> I need to halt .emacs in its execution:
>> (defun compile-emacs-config-file ()
>>   "Compiles ~/.emacs"
>>   (if (file-newer-than-file-p "~/.emacs" "~/.emacs.elc")
>>       (progn
>> 	(setq byte-compile-warnings nil)
>> 	(byte-compile-file "~/.emacs" t) ; Compile and load
>> 	(setq byte-compile-warnings t)
>> 	;HALT - I need the loading of this file to halt and don't execute
>> anything else of this file
>> 	)))
>> (compile-emacs-config-file)
>
> (error "~/.emacs compiled, load terminated")

Indeed, an error is a good way to break out of loading the current
file, but this is probably not what the OP wants.

I would suggest:

(defun compile-emacs-config-file ()
  "Compiles ~/.emacs
Returns: true if we did the compilation."
  (if (file-newer-than-file-p "~/.emacs" "~/.emacs.elc")
      (let ((byte-compile-warnings nil))
        (unwind-protect
             (progn (byte-compile-file "~/.emacs" t)
                    t)
          nil))
      nil))

(if (compile-emacs-config-file)
    (load "~/.emacs") ;; actually loads ~/.emacs.elc
    (progn

      ;; The rest of this file goes here.
      
      ))

You'll have to put all the contents of ~/.emacs in the else branch of
that if.


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

COMPONENT EQUIVALENCY NOTICE: The subatomic particles (electrons,
protons, etc.) comprising this product are exactly the same in every
measurable respect as those used in the products of other
manufacturers, and no claim to the contrary may legitimately be
expressed or implied.


      parent reply	other threads:[~2008-03-29 16:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-28  2:43 How to halt a loading file orium
2008-03-29 15:15 ` Kevin Rodgers
     [not found] ` <mailman.9577.1206803738.18990.help-gnu-emacs@gnu.org>
2008-03-29 16:25   ` Pascal Bourguignon [this message]

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878x01pkdr.fsf@thalassa.informatimago.com \
    --to=pjb@informatimago.com \
    --cc=help-gnu-emacs@gnu.org \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.