Minor style edits

This commit is contained in:
John Wiegley 2015-03-13 03:13:31 -05:00
parent f334f230eb
commit f8bf1b0986

View file

@ -23,7 +23,7 @@
;; along with GNU Emacs; see the file COPYING. If not, write to the ;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA. ;; Boston, MA 02111-1307, USA.
;;; Commentary: ;;; Commentary:
;; The `use-package' declaration macro allows you to isolate package ;; The `use-package' declaration macro allows you to isolate package
@ -34,7 +34,7 @@
;; functionality! ;; functionality!
;; ;;
;; Please see README.md from the same repository for documentation. ;; Please see README.md from the same repository for documentation.
;;; Code: ;;; Code:
(require 'bind-key) (require 'bind-key)
@ -156,6 +156,10 @@ Return nil when the queue is empty."
(cancel-timer use-package-idle-timer) (cancel-timer use-package-idle-timer)
(setq use-package-idle-timer nil)))) (setq use-package-idle-timer nil))))
(eval-when-compile
(defvar package-pinned-packages)
(defvar package-archives))
(defun use-package-pin-package (package archive) (defun use-package-pin-package (package archive)
"Pin PACKAGE to ARCHIVE." "Pin PACKAGE to ARCHIVE."
(unless (boundp 'package-pinned-packages) (unless (boundp 'package-pinned-packages)
@ -164,13 +168,15 @@ Return nil when the queue is empty."
(archive-name (if (stringp archive) archive (symbol-name archive)))) (archive-name (if (stringp archive) archive (symbol-name archive))))
(if (use-package--archive-exists-p archive-symbol) (if (use-package--archive-exists-p archive-symbol)
(add-to-list 'package-pinned-packages (cons package archive-name)) (add-to-list 'package-pinned-packages (cons package archive-name))
(error (message "Archive '%s' requested for package '%s' is not available." archive-name package))) (error "Archive '%s' requested for package '%s' is not available."
archive-name package))
(package-initialize t))) (package-initialize t)))
(defun use-package--archive-exists-p (archive) (defun use-package--archive-exists-p (archive)
"Check if a given ARCHIVE is enabled. "Check if a given ARCHIVE is enabled.
ARCHIVE can be a string or a symbol or 'manual to indicate a manually updated package." ARCHIVE can be a string or a symbol or 'manual to indicate a
manually updated package."
(if (member archive '(manual "manual")) (if (member archive '(manual "manual"))
't 't
(let ((valid nil)) (let ((valid nil))
@ -332,7 +338,8 @@ For full documentation. please see commentary.
(keybindings-alist (use-package-plist-get args :bind t t)) (keybindings-alist (use-package-plist-get args :bind t t))
(overriding-keybindings-alist (use-package-plist-get args :bind* t t)) (overriding-keybindings-alist (use-package-plist-get args :bind* t t))
(keymap-alist (use-package-plist-get args :bind-keymap t t)) (keymap-alist (use-package-plist-get args :bind-keymap t t))
(overriding-keymap-alist (use-package-plist-get args :bind-keymap* t t)) (overriding-keymap-alist
(use-package-plist-get args :bind-keymap* t t))
(mode (use-package-plist-get args :mode t t)) (mode (use-package-plist-get args :mode t t))
(mode-alist (mode-alist
(if (stringp mode) (cons mode name) mode)) (if (stringp mode) (cons mode name) mode))
@ -375,24 +382,26 @@ For full documentation. please see commentary.
(if diminish-var (if diminish-var
(setq config-body (setq
`(progn config-body
,config-body `(progn
(ignore-errors ,config-body
,@(cond (ignore-errors
((stringp diminish-var) ,@(cond
`((diminish (quote ,(intern (concat name-string "-mode"))) ((stringp diminish-var)
,diminish-var))) `((diminish (quote ,(intern (concat name-string "-mode")))
((symbolp diminish-var) ,diminish-var)))
`((diminish (quote ,diminish-var)))) ((symbolp diminish-var)
((and (consp diminish-var) (stringp (cdr diminish-var))) `((diminish (quote ,diminish-var))))
`((diminish (quote ,(car diminish-var)) ,(cdr diminish-var)))) ((and (consp diminish-var) (stringp (cdr diminish-var)))
(t ; list of symbols or (symbol . "string") pairs `((diminish (quote ,(car diminish-var))
(mapcar (lambda (var) ,(cdr diminish-var))))
(if (listp var) (t ; list of symbols or (symbol . "string") pairs
`(diminish (quote ,(car var)) ,(cdr var)) (mapcar (lambda (var)
`(diminish (quote ,var)))) (if (listp var)
diminish-var))))))) `(diminish (quote ,(car var)) ,(cdr var))
`(diminish (quote ,var))))
diminish-var)))))))
(if (and commands (symbolp commands)) (if (and commands (symbolp commands))
(setq commands (list commands))) (setq commands (list commands)))
@ -404,7 +413,8 @@ For full documentation. please see commentary.
(setq init-body (setq init-body
`(progn `(progn
(require 'use-package) (require 'use-package)
(use-package-init-on-idle (lambda () ,idle-body) ,idle-priority) (use-package-init-on-idle (lambda () ,idle-body)
,idle-priority)
,init-body))) ,init-body)))
(let ((init-for-commands-or-keymaps (let ((init-for-commands-or-keymaps
@ -512,7 +522,8 @@ For full documentation. please see commentary.
`(,(lambda () `(,(lambda ()
(if ,requires-test (if ,requires-test
(use-package-with-elapsed-timer (use-package-with-elapsed-timer
,(format "Configuring package %s" name-string) ,(format "Configuring package %s"
name-string)
,config-body)))))) ,config-body))))))
t)) t))
`(if (and ,(or predicate t) `(if (and ,(or predicate t)
@ -544,7 +555,8 @@ pressed."
(keymap (symbol-value keymap-symbol))) (keymap (symbol-value keymap-symbol)))
(progn (progn
(if override (if override
`(eval `(bind-key* ,key ,keymap)) ; eval form is necessary to avoid compiler error ;; eval form is necessary to avoid compiler error
`(eval `(bind-key* ,key ,keymap))
(bind-key key keymap)) (bind-key key keymap))
(setq unread-command-events (setq unread-command-events
(listify-key-sequence (this-command-keys-vector))))) (listify-key-sequence (this-command-keys-vector)))))
@ -563,7 +575,9 @@ pressed."
(font-lock-add-keywords 'emacs-lisp-mode use-package-font-lock-keywords) (font-lock-add-keywords 'emacs-lisp-mode use-package-font-lock-keywords)
(provide 'use-package) (provide 'use-package)
;; Local Variables: ;; Local Variables:
;; indent-tabs-mode: nil ;; indent-tabs-mode: nil
;; End: ;; End:
;;; use-package.el ends here ;;; use-package.el ends here