[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
idleloader.el --- load files while Emacs is idle
From: |
address@hidden |
Subject: |
idleloader.el --- load files while Emacs is idle |
Date: |
8 Nov 2006 22:48:37 -0800 |
User-agent: |
G2/1.0 |
;;; idleloader.el --- load files while Emacs is idle
;; Copyright (C) 2006 Tamas Patrovics
;; Keywords: convenience
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; Dynamic abbrev is great, however in a big software project it's
;; more useful when lots of source files are loaded, because then lots
;; of symbols can be completed from various buffers.
;;
;; Idleloader takes the files from `idleloader-files' and loads them
;; one by one while Emacs is idle. This way relevant buffers can be
;; loaded conveniently in the background instead of loading all of
;; them at startup.
;;
;; Managing lots of open buffers efficiently is no problem with
;; iswitchb and it even makes it easier to open a needed file without
;; having to look for it in a specific directory. (Though with
;; globalff.el and similar tools it's not a big deal anyway.)
;;
;; Idleloader stops itself when all requested files are loaded, but it
;; can always be restarted with `idleloader-start' if more files are
;; added to `idleloader-files' while Emacs is running.
;;
;; Note that you can easily add multiple files to be loaded using
;; wildcards:
;;
;; (setq idleloader-files
;; (append (file-expand-wildcards "/project/src/*")
;; (file-expand-wildcards "/project/inc/*")))
;;
;;; Code:
(defvar idleloader-files nil
"List of files paths which are to be loaded when Emacs is idle")
(defvar idleloader-idle-time 15
"Idle time in seconds after files are started to get loaded.")
(defvar idleloader-timer nil
"Timer object.")
(defvar idleloader-remaining-files
"Remaining files to be loaded.")
(defun idleloader-load ()
"Load remaining files one by one while the user is idle."
(while (and idleloader-remaining-files
(sit-for 0))
(condition-case nil
(let ((file (pop idleloader-remaining-files)))
(message "Loading file %s..." file)
(find-file-noselect file))
(file-error nil)))
(unless idleloader-remaining-files
(cancel-timer idleloader-timer)
(setq idleloader-timer nil)
(message "All files are loaded.")))
(defun idleloader-start ()
"(Re)start the loader."
(interactive)
(setq idleloader-remaining-files idleloader-files)
(unless idleloader-timer
(setq idleloader-timer (run-with-idle-timer idleloader-idle-time
t 'idleloader-load))))
(idleloader-start)
(provide 'idleloader)
;;; idleloader.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- idleloader.el --- load files while Emacs is idle,
address@hidden <=