unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to halt a loading file
@ 2008-03-28  2:43 orium
  2008-03-29 15:15 ` Kevin Rodgers
       [not found] ` <mailman.9577.1206803738.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 3+ messages in thread
From: orium @ 2008-03-28  2:43 UTC (permalink / raw)
  To: help-gnu-emacs

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)


I can't put everything else in the else part of that if because I have
variables set by emacs customize browser, which probably only work if
it is not inside a function (my guess).

Thank you


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to halt a loading file
  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>
  1 sibling, 0 replies; 3+ messages in thread
From: Kevin Rodgers @ 2008-03-29 15:15 UTC (permalink / raw)
  To: help-gnu-emacs

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")

-- 
Kevin Rodgers
Denver, Colorado, USA





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to halt a loading file
       [not found] ` <mailman.9577.1206803738.18990.help-gnu-emacs@gnu.org>
@ 2008-03-29 16:25   ` Pascal Bourguignon
  0 siblings, 0 replies; 3+ messages in thread
From: Pascal Bourguignon @ 2008-03-29 16:25 UTC (permalink / raw)
  To: help-gnu-emacs

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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-03-29 16:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).