mirror of
https://github.com/larstvei/dot-emacs.git
synced 2024-11-26 07:28:31 +00:00
Update packages every nth day! (Very hacky)
This commit is contained in:
parent
6f947ae1de
commit
56eaeac4a2
33
init.el
33
init.el
@ -35,7 +35,35 @@ PACKAGE is installed and the current version is deleted."
|
|||||||
(package-desc-vers (cdr pkg-desc)))))
|
(package-desc-vers (cdr pkg-desc)))))
|
||||||
(package-install package))))
|
(package-install package))))
|
||||||
|
|
||||||
(package-refresh-contents)
|
(defvar days-between-updates 1)
|
||||||
|
(defvar do-package-update-on-init t)
|
||||||
|
|
||||||
|
(require 'time-stamp)
|
||||||
|
;; Open the 'user-init-file' and write any changes.
|
||||||
|
(with-temp-file user-init-file
|
||||||
|
;; Insert it's original content's.
|
||||||
|
(insert-file-contents user-init-file)
|
||||||
|
(forward-line time-stamp-line-limit)
|
||||||
|
(let ((bound (point)))
|
||||||
|
(goto-char (point-min))
|
||||||
|
;; We search for the time-stamp.
|
||||||
|
(let ((start (re-search-forward time-stamp-start bound t))
|
||||||
|
(end (re-search-forward time-stamp-end bound t)))
|
||||||
|
(when (and start end)
|
||||||
|
;; Assuming we have found a time-stamp, we check determine if it's
|
||||||
|
;; time to update.
|
||||||
|
(setq do-package-update-on-init
|
||||||
|
(<= days-between-updates
|
||||||
|
(days-between
|
||||||
|
(current-time-string)
|
||||||
|
(buffer-substring-no-properties start end))))
|
||||||
|
;; Remember to update the time-stamp.
|
||||||
|
(when do-package-update-on-init
|
||||||
|
(time-stamp))))))
|
||||||
|
|
||||||
|
(when do-package-update-on-init
|
||||||
|
(package-refresh-contents))
|
||||||
|
|
||||||
(dolist (package
|
(dolist (package
|
||||||
'(ac-geiser ; Auto-complete backend for geiser
|
'(ac-geiser ; Auto-complete backend for geiser
|
||||||
ac-slime ; An auto-complete source using slime completions
|
ac-slime ; An auto-complete source using slime completions
|
||||||
@ -59,7 +87,8 @@ PACKAGE is installed and the current version is deleted."
|
|||||||
pretty-lambdada ; the word `lambda' as the Greek letter.
|
pretty-lambdada ; the word `lambda' as the Greek letter.
|
||||||
smex ; M-x interface with Ido-style fuzzy matching.
|
smex ; M-x interface with Ido-style fuzzy matching.
|
||||||
))
|
))
|
||||||
(upgrade-or-install-package package))
|
(when do-package-update-on-init
|
||||||
|
(upgrade-or-install-package package)))
|
||||||
|
|
||||||
(dolist (feature
|
(dolist (feature
|
||||||
'(auto-compile ; auto-compile .el files
|
'(auto-compile ; auto-compile .el files
|
||||||
|
62
init.org
62
init.org
@ -83,12 +83,57 @@
|
|||||||
(package-install package))))
|
(package-install package))))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
The =package-refresh-contents= function downloads archive descriptions,
|
||||||
|
this is a major bottleneck in this configuration. To avoid this we can
|
||||||
|
try to only check for updates once every day or so. Here are to
|
||||||
|
variables. The first specifies how often we should check for updates. The
|
||||||
|
second specifies wither one should update during the initialization.
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp :tangle yes
|
||||||
|
(defvar days-between-updates 1)
|
||||||
|
(defvar do-package-update-on-init t)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
The tricky part is figuring out when the last time the Emacs was updated!
|
||||||
|
Here is a hacky way of doing it, using [[http://www.gnu.org/software/emacs/manual/html_node/emacs/Time-Stamps.html][time-stamps]]. By adding a
|
||||||
|
time-stamp to the init file, we can search for it and determine wither or
|
||||||
|
not to do an update. After that we must run the =time-stamp=-function to
|
||||||
|
update the time-stamp. Note that if there is no time-stamp in the
|
||||||
|
init-file then packages will be updated every time you start Emacs.
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp :tangle yes
|
||||||
|
(require 'time-stamp)
|
||||||
|
;; Open the 'user-init-file' and write any changes.
|
||||||
|
(with-temp-file user-init-file
|
||||||
|
;; Insert it's original content's.
|
||||||
|
(insert-file-contents user-init-file)
|
||||||
|
(forward-line time-stamp-line-limit)
|
||||||
|
(let ((bound (point)))
|
||||||
|
(goto-char (point-min))
|
||||||
|
;; We search for the time-stamp.
|
||||||
|
(let ((start (re-search-forward time-stamp-start bound t))
|
||||||
|
(end (re-search-forward time-stamp-end bound t)))
|
||||||
|
(when (and start end)
|
||||||
|
;; Assuming we have found a time-stamp, we check determine if it's
|
||||||
|
;; time to update.
|
||||||
|
(setq do-package-update-on-init
|
||||||
|
(<= days-between-updates
|
||||||
|
(days-between
|
||||||
|
(current-time-string)
|
||||||
|
(buffer-substring-no-properties start end))))
|
||||||
|
;; Remember to update the time-stamp.
|
||||||
|
(when do-package-update-on-init
|
||||||
|
(time-stamp))))))
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
Now we can use the function above to make sure packages are installed and
|
Now we can use the function above to make sure packages are installed and
|
||||||
up to date. Here are some packages I find useful (some of these
|
up to date. Here are some packages I find useful (some of these
|
||||||
configurations are also dependent on them).
|
configurations are also dependent on them).
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp :tangle yes
|
#+BEGIN_SRC emacs-lisp :tangle yes
|
||||||
(package-refresh-contents)
|
(when do-package-update-on-init
|
||||||
|
(package-refresh-contents))
|
||||||
|
|
||||||
(dolist (package
|
(dolist (package
|
||||||
'(ac-geiser ; Auto-complete backend for geiser
|
'(ac-geiser ; Auto-complete backend for geiser
|
||||||
ac-slime ; An auto-complete source using slime completions
|
ac-slime ; An auto-complete source using slime completions
|
||||||
@ -112,7 +157,8 @@
|
|||||||
pretty-lambdada ; the word `lambda' as the Greek letter.
|
pretty-lambdada ; the word `lambda' as the Greek letter.
|
||||||
smex ; M-x interface with Ido-style fuzzy matching.
|
smex ; M-x interface with Ido-style fuzzy matching.
|
||||||
))
|
))
|
||||||
(upgrade-or-install-package package))
|
(when do-package-update-on-init
|
||||||
|
(upgrade-or-install-package package)))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
** Require
|
** Require
|
||||||
@ -371,11 +417,11 @@
|
|||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp :tangle yes
|
#+BEGIN_SRC emacs-lisp :tangle yes
|
||||||
(defvar load-mail-setup nil)
|
(defvar load-mail-setup nil)
|
||||||
|
|
||||||
(when load-mail-setup
|
(when load-mail-setup
|
||||||
;; We need mu4e
|
;; We need mu4e
|
||||||
(require 'mu4e)
|
(require 'mu4e)
|
||||||
|
|
||||||
;; Some basic mu4e settings.
|
;; Some basic mu4e settings.
|
||||||
(setq mu4e-maildir "~/.ifimail" ; top-level Maildir
|
(setq mu4e-maildir "~/.ifimail" ; top-level Maildir
|
||||||
mu4e-sent-folder "/INBOX.Sent" ; folder for sent messages
|
mu4e-sent-folder "/INBOX.Sent" ; folder for sent messages
|
||||||
@ -390,7 +436,7 @@
|
|||||||
mu4e-html2text-command
|
mu4e-html2text-command
|
||||||
"html2text -utf8" ; use utf-8
|
"html2text -utf8" ; use utf-8
|
||||||
)
|
)
|
||||||
|
|
||||||
;; Setup for sending mail.
|
;; Setup for sending mail.
|
||||||
(setq user-full-name
|
(setq user-full-name
|
||||||
"Lars Tveito" ; Your full name
|
"Lars Tveito" ; Your full name
|
||||||
@ -403,11 +449,11 @@
|
|||||||
send-mail-function 'smtpmail-send-it ; Use smpt to send
|
send-mail-function 'smtpmail-send-it ; Use smpt to send
|
||||||
mail-user-agent 'mu4e-user-agent ; Use mu4e!
|
mail-user-agent 'mu4e-user-agent ; Use mu4e!
|
||||||
)
|
)
|
||||||
|
|
||||||
;; Register file types that can be handled by ImageMagick.
|
;; Register file types that can be handled by ImageMagick.
|
||||||
(when (fboundp 'imagemagick-register-types)
|
(when (fboundp 'imagemagick-register-types)
|
||||||
(imagemagick-register-types))
|
(imagemagick-register-types))
|
||||||
|
|
||||||
;; A wrapper function to start (if necessary), fetch mail and delete other
|
;; A wrapper function to start (if necessary), fetch mail and delete other
|
||||||
;; windows.
|
;; windows.
|
||||||
(defun show-mu4e ()
|
(defun show-mu4e ()
|
||||||
@ -415,7 +461,7 @@
|
|||||||
(mu4e)
|
(mu4e)
|
||||||
(mu4e-update-mail-and-index t)
|
(mu4e-update-mail-and-index t)
|
||||||
(delete-other-windows))
|
(delete-other-windows))
|
||||||
|
|
||||||
;; Overwrite the native 'compose-mail' binding to 'show-mu4e'.
|
;; Overwrite the native 'compose-mail' binding to 'show-mu4e'.
|
||||||
(global-set-key (kbd "C-x m") 'show-mu4e))
|
(global-set-key (kbd "C-x m") 'show-mu4e))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
Loading…
Reference in New Issue
Block a user