[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
prevent function execution on Emacs startup if not connected to internet
From: |
Brady Trainor |
Subject: |
prevent function execution on Emacs startup if not connected to internet |
Date: |
Fri, 18 Apr 2014 00:27:01 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 |
Hi, I have the following lines of code in my my init files:
if an uninstalled package is not in the list, refresh list
#+BEGIN_SRC emacs-lisp
(setq n 0) ; set n as 0
(dolist (pkg pkgs-2b-present) ; for each pkg in list
(unless (or ; unless
(package-installed-p pkg) ; pkg is installed or
(assoc pkg ; pkg is in the archive list
package-archive-contents))
(setq n (+ n 1)))) ; add one to n
(when (> n 0) ; if n > 0,
(package-refresh-contents)) ; refresh packages
#+END_SRC
install any uninstalled packages that are in the list
#+BEGIN_SRC emacs-lisp
(dolist (pkg pkgs-2b-present) ; for each pkg in list
(when ; if pkg is
(and
(not (package-installed-p pkg)) ; not installed
(assoc pkg package-archive-contents) ; and in the archive list
)
(package-install pkg))) ; then install it
#+END_SRC
I think the `package-refresh-contents' or the `package-install'
functions will create an error and prevent my init files from finishing
loading.
I would guess that I am not the first one to have this problem, or
someone can tell me what would fix this.
Brady
- prevent function execution on Emacs startup if not connected to internet,
Brady Trainor <=