23 changed files with 3651 additions and 1757 deletions
@ -1,2 +0,0 @@
|
||||
;;; -*- no-byte-compile: t -*- |
||||
(define-package "bind-key" "20171129.2144" "A simple way to manage personal keybindings" 'nil :commit "fe5d8a9f501d9151efd633c0e16f42932969f1fc" :url "https://github.com/jwiegley/use-package" :keywords '("keys" "keybinding" "config" "dotemacs")) |
@ -0,0 +1,2 @@
|
||||
;;; -*- no-byte-compile: t -*- |
||||
(define-package "bind-key" "20171210.2125" "A simple way to manage personal keybindings" 'nil :commit "33e9a4b74042e46161bff70e19b87317b1781fc5" :url "https://github.com/jwiegley/use-package" :keywords '("keys" "keybinding" "config" "dotemacs")) |
@ -1,2 +0,0 @@
|
||||
;;; -*- no-byte-compile: t -*- |
||||
(define-package "page-break-lines" "20171020.108" "Display ^L page breaks as tidy horizontal lines" '((emacs "24.4")) :commit "ae1c0065984429c7364a667abb9180e80134c4c0" :url "https://github.com/purcell/page-break-lines" :keywords '("convenience" "faces")) |
@ -0,0 +1,2 @@
|
||||
;;; -*- no-byte-compile: t -*- |
||||
(define-package "page-break-lines" "20171210.31" "Display ^L page breaks as tidy horizontal lines" '((emacs "24.4")) :commit "fd3b7e38ad8747cd009ead7ef1bb150849ccc693" :url "https://github.com/purcell/page-break-lines" :keywords '("convenience" "faces")) |
@ -1,2 +0,0 @@
|
||||
;;; -*- no-byte-compile: t -*- |
||||
(define-package "use-package" "20171201.1339" "A use-package declaration for simplifying your .emacs" '((emacs "24.3") (bind-key "2.4")) :commit "e8a3fdcc2e4c1557b64df25bec26851ec319d912" :url "https://github.com/jwiegley/use-package" :keywords '("dotemacs" "startup" "speed" "config" "package")) |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,169 @@
|
||||
;;; use-package-bind-key.el --- Support for the :bind/:bind-keymap keywords |
||||
|
||||
;; Copyright (C) 2012-2017 John Wiegley |
||||
|
||||
;; Author: John Wiegley <johnw@newartisans.com> |
||||
;; Maintainer: John Wiegley <johnw@newartisans.com> |
||||
;; Created: 17 Jun 2012 |
||||
;; Modified: 4 Dec 2017 |
||||
;; Version: 1.0 |
||||
;; Package-Requires: ((emacs "24.3") (use-package "2.4") (bind-key "2.4")) |
||||
;; Keywords: dotemacs startup speed config package |
||||
;; URL: https://github.com/jwiegley/use-package |
||||
|
||||
;; This program 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 3, or (at |
||||
;; your option) any later version. |
||||
|
||||
;; This program 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: |
||||
|
||||
;; Provides support for the :bind, :bind*, :bind-keymap and :bind-keymap* |
||||
;; keywords. Note that these are currently still baked into |
||||
;; `use-package-keywords' and `use-package-deferring-keywords', although this |
||||
;; is harmless if they are never used. |
||||
|
||||
;;; Code: |
||||
|
||||
(require 'use-package-core) |
||||
(require 'bind-key) |
||||
|
||||
;;;###autoload |
||||
(defun use-package-autoload-keymap (keymap-symbol package override) |
||||
"Loads PACKAGE and then binds the key sequence used to invoke |
||||
this function to KEYMAP-SYMBOL. It then simulates pressing the |
||||
same key sequence a again, so that the next key pressed is routed |
||||
to the newly loaded keymap. |
||||
|
||||
This function supports use-package's :bind-keymap keyword. It |
||||
works by binding the given key sequence to an invocation of this |
||||
function for a particular keymap. The keymap is expected to be |
||||
defined by the package. In this way, loading the package is |
||||
deferred until the prefix key sequence is pressed." |
||||
(if (not (require package nil t)) |
||||
(use-package-error (format "Cannot load package.el: %s" package)) |
||||
(if (and (boundp keymap-symbol) |
||||
(keymapp (symbol-value keymap-symbol))) |
||||
(let* ((kv (this-command-keys-vector)) |
||||
(key (key-description kv)) |
||||
(keymap (symbol-value keymap-symbol))) |
||||
(if override |
||||
(bind-key* key keymap) |
||||
(bind-key key keymap)) |
||||
(setq unread-command-events |
||||
(listify-key-sequence kv))) |
||||
(use-package-error |
||||
(format "package.el %s failed to define keymap %s" |
||||
package keymap-symbol))))) |
||||
|
||||
;;;###autoload |
||||
(defun use-package-normalize-binder (name keyword args) |
||||
(let ((arg args) |
||||
args*) |
||||
(while arg |
||||
(let ((x (car arg))) |
||||
(cond |
||||
;; (KEY . COMMAND) |
||||
((and (consp x) |
||||
(or (stringp (car x)) |
||||
(vectorp (car x))) |
||||
(or (use-package-recognize-function (cdr x) t #'stringp))) |
||||
(setq args* (nconc args* (list x))) |
||||
(setq arg (cdr arg))) |
||||
;; KEYWORD |
||||
;; :map KEYMAP |
||||
;; :prefix-docstring STRING |
||||
;; :prefix-map SYMBOL |
||||
;; :prefix STRING |
||||
;; :filter SEXP |
||||
;; :menu-name STRING |
||||
((or (and (eq x :map) (symbolp (cadr arg))) |
||||
(and (eq x :prefix) (stringp (cadr arg))) |
||||
(and (eq x :prefix-map) (symbolp (cadr arg))) |
||||
(and (eq x :prefix-docstring) (stringp (cadr arg))) |
||||
(eq x :filter) |
||||
(and (eq x :menu-name) (stringp (cadr arg)))) |
||||
(setq args* (nconc args* (list x (cadr arg)))) |
||||
(setq arg (cddr arg))) |
||||
((listp x) |
||||
(setq args* |
||||
(nconc args* (use-package-normalize-binder name keyword x))) |
||||
(setq arg (cdr arg))) |
||||
(t |
||||
;; Error! |
||||
(use-package-error |
||||
(concat (symbol-name name) |
||||
" wants arguments acceptable to the `bind-keys' macro," |
||||
" or a list of such values")))))) |
||||
args*)) |
||||
|
||||
;;;; :bind, :bind* |
||||
|
||||
;;;###autoload |
||||
(defalias 'use-package-normalize/:bind 'use-package-normalize-binder) |
||||
;;;###autoload |
||||
(defalias 'use-package-normalize/:bind* 'use-package-normalize-binder) |
||||
|
||||
;; jww (2017-12-07): This is too simplistic. It will fail to determine |
||||
;; autoloads in this situation: |
||||
;; (use-package foo |
||||
;; :bind (:map foo-map (("C-a" . func)))) |
||||
;;;###autoload |
||||
(defalias 'use-package-autoloads/:bind 'use-package-autoloads-mode) |
||||
;;;###autoload |
||||
(defalias 'use-package-autoloads/:bind* 'use-package-autoloads-mode) |
||||
|
||||
;;;###autoload |
||||
(defun use-package-handler/:bind |
||||
(name keyword args rest state &optional bind-macro) |
||||
(use-package-concat |
||||
(use-package-process-keywords name rest state) |
||||
`(,@(mapcar |
||||
#'(lambda (xs) |
||||
`(,(if bind-macro bind-macro 'bind-keys) |
||||
:package ,name ,@(use-package-normalize-commands xs))) |
||||
(use-package-split-list-at-keys :break args))))) |
||||
|
||||
(defun use-package-handler/:bind* (name keyword arg rest state) |
||||
(use-package-handler/:bind name keyword arg rest state 'bind-keys*)) |
||||
|
||||
;;;; :bind-keymap, :bind-keymap* |
||||
|
||||
;;;###autoload |
||||
(defalias 'use-package-normalize/:bind-keymap 'use-package-normalize-binder) |
||||
;;;###autoload |
||||
(defalias 'use-package-normalize/:bind-keymap* 'use-package-normalize-binder) |
||||
|
||||
;;;###autoload |
||||
(defun use-package-handler/:bind-keymap |
||||
(name keyword args rest state &optional override) |
||||
(use-package-concat |
||||
(use-package-process-keywords name rest state) |
||||
(mapcar |
||||
#'(lambda (binding) |
||||
`(,(if override 'bind-key* 'bind-key) |
||||
,(car binding) |
||||
#'(lambda () |
||||
(interactive) |
||||
(use-package-autoload-keymap |
||||
',(cdr binding) ',(use-package-as-symbol name) |
||||
,override)))) |
||||
args))) |
||||
|
||||
;;;###autoload |
||||
(defun use-package-handler/:bind-keymap* (name keyword arg rest state) |
||||
(use-package-handler/:bind-keymap name keyword arg rest state t)) |
||||
|
||||
(provide 'use-package-bind-key) |
||||
|
||||
;;; use-package-bind-key.el ends here |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,91 @@
|
||||
;;; use-package-delight.el --- Support for the :delight keyword |
||||
|
||||
;; Copyright (C) 2012-2017 John Wiegley |
||||
|
||||
;; Author: John Wiegley <johnw@newartisans.com> |
||||
;; Maintainer: John Wiegley <johnw@newartisans.com> |
||||
;; Created: 17 Jun 2012 |
||||
;; Modified: 3 Dec 2017 |
||||
;; Version: 1.0 |
||||
;; Package-Requires: ((emacs "24.3") (use-package "2.4")) |
||||
;; Keywords: dotemacs startup speed config package |
||||
;; URL: https://github.com/jwiegley/use-package |
||||
|
||||
;; This program 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 3, or (at |
||||
;; your option) any later version. |
||||
|
||||
;; This program 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: |
||||
|
||||
;; Provides support for the :delight keyword, which is made available by |
||||
;; default by requiring `use-package'. |
||||
|
||||
;;; Code: |
||||
|
||||
(require 'use-package-core) |
||||
|
||||
(defun use-package-normalize-delight (name args) |
||||
"Normalize ARGS for a single call to `delight'." |
||||
(when (eq :eval (car args)) |
||||
;; Handle likely common mistake. |
||||
(use-package-error ":delight mode line constructs must be quoted")) |
||||
(cond ((and (= (length args) 1) |
||||
(use-package-non-nil-symbolp (car args))) |
||||
`(,(nth 0 args) nil ,name)) |
||||
((= (length args) 2) |
||||
`(,(nth 0 args) ,(nth 1 args) ,name)) |
||||
((= (length args) 3) |
||||
args) |
||||
(t |
||||
(use-package-error |
||||
":delight expects `delight' arguments or a list of them")))) |
||||
|
||||
;;;###autoload |
||||
(defun use-package-normalize/:delight (name keyword args) |
||||
"Normalize arguments to delight." |
||||
(cond ((null args) |
||||
`((,(use-package-as-mode name) nil ,name))) |
||||
((and (= (length args) 1) |
||||
(use-package-non-nil-symbolp (car args))) |
||||
`((,(car args) nil ,name))) |
||||
((and (= (length args) 1) |
||||
(stringp (car args))) |
||||
`((,(use-package-as-mode name) ,(car args) ,name))) |
||||
((and (= (length args) 1) |
||||
(listp (car args)) |
||||
(eq 'quote (caar args))) |
||||
`((,(use-package-as-mode name) ,@(cdar args) ,name))) |
||||
((and (= (length args) 2) |
||||
(listp (nth 1 args)) |
||||
(eq 'quote (car (nth 1 args)))) |
||||
`((,(car args) ,@(cdr (nth 1 args)) ,name))) |
||||
(t (mapcar |
||||
(apply-partially #'use-package-normalize-delight name) |
||||
(if (use-package-non-nil-symbolp (car args)) |
||||
(list args) |
||||
args))))) |
||||
|
||||
;;;###autoload |
||||
(defun use-package-handler/:delight (name keyword args rest state) |
||||
(let ((body (use-package-process-keywords name rest state))) |
||||
(use-package-concat |
||||
body |
||||
`((if (fboundp 'delight) |
||||
(delight '(,@args))))))) |
||||
|
||||
(add-to-list 'use-package-keywords :delight t) |
||||
|
||||
(provide 'use-package-delight) |
||||
|
||||
;;; use-package-delight.el ends here |
@ -0,0 +1,80 @@
|
||||
;;; use-package-diminish.el --- Support for the :diminish keyword |
||||
|
||||
;; Copyright (C) 2012-2017 John Wiegley |
||||
|
||||
;; Author: John Wiegley <johnw@newartisans.com> |
||||
;; Maintainer: John Wiegley <johnw@newartisans.com> |
||||
;; Created: 17 Jun 2012 |
||||
;; Modified: 3 Dec 2017 |
||||
;; Version: 1.0 |
||||
;; Package-Requires: ((emacs "24.3") (use-package "2.4")) |
||||
;; Keywords: dotemacs startup speed config package |
||||
;; URL: https://github.com/jwiegley/use-package |
||||
|
||||
;; This program 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 3, or (at |
||||
;; your option) any later version. |
||||
|
||||
;; This program 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: |
||||
|
||||
;; Provides support for the :diminish keyword, which is made available by |
||||
;; default by requiring `use-package'. |
||||
|
||||
;;; Code: |
||||
|
||||
(require 'use-package-core) |
||||
|
||||
(defun use-package-normalize-diminish (name label arg &optional recursed) |
||||
"Normalize the arguments to diminish down to a list of one of two forms: |
||||
SYMBOL |
||||
(SYMBOL . STRING)" |
||||
(cond |
||||
((not arg) |
||||
(list (use-package-as-mode name))) |
||||
((use-package-non-nil-symbolp arg) |
||||
(list arg)) |
||||
((stringp arg) |
||||
(list (cons (use-package-as-mode name) arg))) |
||||
((and (consp arg) (stringp (cdr arg))) |
||||
(list arg)) |
||||
((and (not recursed) (listp arg) (listp (cdr arg))) |
||||
(mapcar #'(lambda (x) (car (use-package-normalize-diminish |
||||
name label x t))) arg)) |
||||
(t |
||||
(use-package-error |
||||
(concat label " wants a string, symbol, " |
||||
"(symbol . string) or list of these"))))) |
||||
|
||||
;;;###autoload |
||||
(defun use-package-normalize/:diminish (name keyword args) |
||||
(use-package-as-one (symbol-name keyword) args |
||||
(apply-partially #'use-package-normalize-diminish name) t)) |
||||
|
||||
;;;###autoload |
||||
(defun use-package-handler/:diminish (name keyword arg rest state) |
||||
(let ((body (use-package-process-keywords name rest state))) |
||||
(use-package-concat |
||||
(mapcar #'(lambda (var) |
||||
`(if (fboundp 'diminish) |
||||
,(if (consp var) |
||||
`(diminish ',(car var) ,(cdr var)) |
||||
`(diminish ',var)))) |
||||
arg) |
||||
body))) |
||||
|
||||
(add-to-list 'use-package-keywords :diminish t) |
||||
|
||||
(provide 'use-package-diminish) |
||||
|
||||
;;; use-package-diminish.el ends here |
@ -0,0 +1,214 @@
|
||||
;;; use-package-ensure.el --- Support for the :ensure and :pin keywords |
||||
|
||||
;; Copyright (C) 2012-2017 John Wiegley |
||||
|
||||
;; Author: John Wiegley <johnw@newartisans.com> |
||||
;; Maintainer: John Wiegley <johnw@newartisans.com> |
||||
;; Created: 17 Jun 2012 |
||||
;; Modified: 3 Dec 2017 |
||||
;; Version: 1.0 |
||||
;; Package-Requires: ((emacs "24.3") (use-package "2.4")) |
||||
;; Keywords: dotemacs startup speed config package |
||||
;; URL: https://github.com/jwiegley/use-package |
||||
|
||||
;; This program 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 3, or (at |
||||
;; your option) any later version. |
||||
|
||||
;; This program 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: |
||||
|
||||
;; Provides support for the :ensure and :pin keywords, which is made available |
||||
;; by default by requiring `use-package'. |
||||
|
||||
;;; Code: |
||||
|
||||
(require 'cl-lib) |
||||
(require 'use-package-core) |
||||
|
||||
(defgroup use-package-ensure nil |
||||
"Support for :ensure and :pin keywords in use-package declarations." |
||||
:group 'use-package) |
||||
|
||||
(eval-when-compile |
||||
(declare-function package-installed-p "package") |
||||
(declare-function package-read-all-archive-contents "package" ())) |
||||
|
||||
(defcustom use-package-always-ensure nil |
||||
"Treat every package as though it had specified using `:ensure SEXP'. |
||||
See also `use-package-defaults', which uses this value." |
||||
:type 'sexp |
||||
:group 'use-package-ensure) |
||||
|
||||
(defcustom use-package-always-pin nil |
||||
"Treat every package as though it had specified using `:pin SYM'. |
||||
See also `use-package-defaults', which uses this value." |
||||
:type 'symbol |
||||
:group 'use-package-ensure) |
||||
|
||||
(defcustom use-package-ensure-function 'use-package-ensure-elpa |
||||
"Function that ensures a package is installed. |
||||
This function is called with three arguments: the name of the |
||||
package declared in the `use-package' form; the arguments passed |
||||
to all `:ensure' keywords (always a list, even if only one); and |
||||
the current `state' plist created by previous handlers. |
||||
|
||||
Note that this function is called whenever `:ensure' is provided, |
||||
even if it is nil. It is up to the function to decide on the |
||||
semantics of the various values for `:ensure'. |
||||
|
||||
This function should return non-nil if the package is installed. |
||||
|
||||
The default value uses package.el to install the package." |
||||
:type '(choice (const :tag "package.el" use-package-ensure-elpa) |
||||
(function :tag "Custom")) |
||||
:group 'use-package-ensure) |
||||
|
||||
;;;; :pin |
||||
|
||||
(defun use-package-normalize/:pin (name keyword args) |
||||
(use-package-only-one (symbol-name keyword) args |
||||
#'(lambda (label arg) |
||||
(cond |
||||
((stringp arg) arg) |
||||
((use-package-non-nil-symbolp arg) (symbol-name arg)) |
||||
(t |
||||
(use-package-error |
||||
":pin wants an archive name (a string)")))))) |
||||
|
||||
(eval-when-compile |
||||
(defvar package-pinned-packages) |
||||
(defvar package-archives)) |
||||
|
||||
(defun use-package-archive-exists-p (archive) |
||||
"Check if a given ARCHIVE is enabled. |
||||
|
||||
ARCHIVE can be a string or a symbol or 'manual to indicate a |
||||
manually updated package." |
||||
(if (member archive '(manual "manual")) |
||||
't |
||||
(let ((valid nil)) |
||||
(dolist (pa package-archives) |
||||
(when (member archive (list (car pa) (intern (car pa)))) |
||||
(setq valid 't))) |
||||
valid))) |
||||
|
||||
(defun use-package-pin-package (package archive) |
||||
"Pin PACKAGE to ARCHIVE." |
||||
(unless (boundp 'package-pinned-packages) |
||||
(setq package-pinned-packages ())) |
||||
(let ((archive-symbol (if (symbolp archive) archive (intern archive))) |
||||
(archive-name (if (stringp archive) archive (symbol-name archive)))) |
||||
(if (use-package-archive-exists-p archive-symbol) |
||||
(add-to-list 'package-pinned-packages (cons package archive-name)) |
||||
(error "Archive '%s' requested for package '%s' is not available." |
||||
archive-name package)) |
||||
(unless (bound-and-true-p package--initialized) |
||||
(package-initialize t)))) |
||||
|
||||
(defun use-package-handler/:pin (name keyword archive-name rest state) |
||||
(let ((body (use-package-process-keywords name rest state)) |
||||
(pin-form (if archive-name |
||||
`(use-package-pin-package ',(use-package-as-symbol name) |
||||
,archive-name)))) |
||||
;; Pinning should occur just before ensuring |
||||
;; See `use-package-handler/:ensure'. |
||||
(if (bound-and-true-p byte-compile-current-file) |
||||
(eval pin-form) ; Eval when byte-compiling, |
||||
(push pin-form body)) ; or else wait until runtime. |
||||
body)) |
||||
|
||||
;;;; :ensure |
||||
|
||||
(defvar package-archive-contents) |
||||
|
||||
;;;###autoload |
||||
(defun use-package-normalize/:ensure (name keyword args) |
||||
(if (null args) |
||||
(list t) |
||||
(use-package-only-one (symbol-name keyword) args |
||||
#'(lambda (label arg) |
||||
(cond |
||||
((symbolp arg) |
||||
(list arg)) |
||||
((and (listp arg) (= 3 (length arg)) |
||||
(symbolp (nth 0 arg)) |
||||
(eq :pin (nth 1 arg)) |
||||
(or (stringp (nth 2 arg)) |
||||
(symbolp (nth 2 arg)))) |
||||
(list (cons (nth 0 arg) (nth 2 arg)))) |
||||
(t |
||||
(use-package-error |
||||
(concat ":ensure wants an optional package name " |
||||
"(an unquoted symbol name), or (<symbol> :pin <string>)")))))))) |
||||
|
||||
(defun use-package-ensure-elpa (name args state &optional no-refresh) |
||||
(dolist (ensure args) |
||||
(let ((package |
||||
(or (and (eq ensure t) (use-package-as-symbol name)) |
||||
ensure))) |
||||
(when package |
||||
(require 'package) |
||||
(when (consp package) |
||||
(use-package-pin-package (car package) (cdr package)) |
||||
(setq package (car package))) |
||||
(unless (package-installed-p package) |
||||
(condition-case-unless-debug err |
||||
(progn |
||||
(when (assoc package (bound-and-true-p |
||||
package-pinned-packages)) |
||||
(package-read-all-archive-contents)) |
||||
(if (assoc package package-archive-contents) |
||||
(package-install package) |
||||
(package-refresh-contents) |
||||
(when (assoc package (bound-and-true-p |
||||
package-pinned-packages)) |
||||
(package-read-all-archive-contents)) |
||||
(package-install package)) |
||||
t) |
||||
(error |
||||
(display-warning 'use-package |
||||
(format "Failed to install %s: %s" |
||||
name (error-message-string err)) |
||||
:error)))))))) |
||||
|
||||
;;;###autoload |
||||
(defun use-package-handler/:ensure (name keyword ensure rest state) |
||||
(let* ((body (use-package-process-keywords name rest state))) |
||||
;; We want to avoid installing packages when the `use-package' macro is |
||||
;; being macro-expanded by elisp completion (see `lisp--local-variables'), |
||||
;; but still install packages when byte-compiling, to avoid requiring |
||||
;; `package' at runtime. |
||||
(if (bound-and-true-p byte-compile-current-file) |
||||
;; Eval when byte-compiling, |
||||
(funcall use-package-ensure-function name ensure state) |
||||
;; or else wait until runtime. |
||||
(push `(,use-package-ensure-function ',name ',ensure ',state) |
||||
body)) |
||||
body)) |
||||
|
||||
(add-to-list 'use-package-defaults |
||||
'(:ensure (list use-package-always-ensure) |
||||
(lambda (name args) |
||||
(and use-package-always-ensure |
||||
(not (plist-member args :load-path))))) t) |
||||
|
||||
(add-to-list 'use-package-defaults |
||||
'(:pin use-package-always-pin use-package-always-pin) t) |
||||
|
||||
(add-to-list 'use-package-keywords :ensure) |
||||
(add-to-list 'use-package-keywords :pin) |
||||
|
||||
(provide 'use-package-ensure) |
||||
|
||||
;;; use-package-ensure.el ends here |
@ -0,0 +1,79 @@
|
||||
;;; use-package-jump.el --- Attempt to jump to a use-package declaration |
||||
|
||||
;; Copyright (C) 2012-2017 John Wiegley |
||||
|
||||
;; Author: John Wiegley <johnw@newartisans.com> |
||||
;; Maintainer: John Wiegley <johnw@newartisans.com> |
||||
;; Created: 17 Jun 2012 |
||||
;; Modified: 3 Dec 2017 |
||||
;; Version: 1.0 |
||||
;; Package-Requires: ((emacs "24.3") (use-package "2.4")) |
||||
;; Keywords: dotemacs startup speed config package |
||||
;; URL: https://github.com/jwiegley/use-package |
||||
|
||||
;; This program 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 3, or (at |
||||
;; your option) any later version. |
||||
|
||||
;; This program 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: |
||||
|
||||
;; Provides the command `M-x use-package-jump-to-package-form', however it |
||||
;; only works if the package being jumped to was required during |
||||
;; initialization. If it was delay-loaded, it will not work. Improvements are |
||||
;; needed. |
||||
|
||||
;;; Code: |
||||
|
||||
(require 'use-package-core) |
||||
|
||||
(defun use-package-find-require (package) |
||||
"Find file that required PACKAGE by searching `load-history'. |
||||
Returns an absolute file path or nil if none is found." |
||||
(catch 'suspect |
||||
(dolist (filespec load-history) |
||||
(dolist (entry (cdr filespec)) |
||||
(when (equal entry (cons 'require package)) |
||||
(throw 'suspect (car filespec))))))) |
||||
|
||||
;;;###autoload |
||||
(defun use-package-jump-to-package-form (package) |
||||
"Attempt to find and jump to the `use-package' form that loaded |
||||
PACKAGE. This will only find the form if that form actually |
||||
required PACKAGE. If PACKAGE was previously required then this |
||||
function will jump to the file that originally required PACKAGE |
||||
instead." |
||||
(interactive (list (completing-read "Package: " features))) |
||||
(let* ((package (if (stringp package) (intern package) package)) |
||||
(requiring-file (use-package-find-require package)) |
||||
file location) |
||||
(if (null requiring-file) |
||||
(user-error "Can't find file requiring file; may have been autoloaded") |
||||
(setq file (if (string= (file-name-extension requiring-file) "elc") |
||||
(concat (file-name-sans-extension requiring-file) ".el") |
||||
requiring-file)) |
||||
(when (file-exists-p file) |
||||
(find-file-other-window file) |
||||
(save-excursion |
||||
(goto-char (point-min)) |
||||
(setq location |
||||
(re-search-forward |
||||
(format (eval use-package-form-regexp-eval) package) nil t))) |
||||
(if (null location) |
||||
(message "No use-package form found.") |
||||
(goto-char location) |
||||
(beginning-of-line)))))) |
||||
|
||||
(provide 'use-package-jump) |
||||
|
||||
;;; use-package-jump.el ends here |
@ -0,0 +1,84 @@
|
||||
;;; use-package-lint.el --- Attempt to find errors in use-package declarations |
||||
|
||||
;; Copyright (C) 2012-2017 John Wiegley |
||||
|
||||
;; Author: John Wiegley <johnw@newartisans.com> |
||||
;; Maintainer: John Wiegley <johnw@newartisans.com> |
||||
;; Created: 17 Jun 2012 |
||||
;; Modified: 3 Dec 2017 |
||||
;; Version: 1.0 |
||||
;; Package-Requires: ((emacs "24.3") (use-package "2.4")) |
||||
;; Keywords: dotemacs startup speed config package |
||||
;; URL: https://github.com/jwiegley/use-package |
||||
|
||||
;; This program 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 3, or (at |
||||
;; your option) any later version. |
||||
|
||||
;; This program 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: |
||||
|
||||
;; Provides the command `M-x use-package-lint'. |
||||
|
||||
;;; Code: |
||||
|
||||
(require 'cl-lib) |
||||
(require 'use-package-core) |
||||
|
||||
(defun use-package-lint-declaration (name plist) |
||||
(dolist (path (plist-get plist :load-path)) |
||||
(unless (file-exists-p path) |
||||
(display-warning |
||||
'use-package |
||||
(format "%s :load-path does not exist: %s" |
||||
name path) :error))) |
||||
|
||||
(unless (or (plist-member plist :disabled) |
||||
(plist-get plist :no-require) |
||||
(locate-library (use-package-as-string name) nil |
||||
(plist-get plist :load-path))) |
||||
(display-warning |
||||
'use-package |
||||
(format "%s module cannot be located" name) :error)) |
||||
|
||||
;; (dolist (command (plist-get plist :commands)) |
||||
;; (unless (string= (find-lisp-object-file-name command nil) |
||||
;; (locate-library (use-package-as-string name) nil |
||||
;; (plist-get plist :load-path))) |
||||
;; (display-warning |
||||
;; 'use-package |
||||
;; (format "%s :command is from different path: %s" |
||||
;; name (symbol-name command)) :error))) |
||||
) |
||||
|
||||
;;;###autoload |
||||
(defun use-package-lint () |
||||
"Check for errors in use-package declarations. |
||||
For example, if the module's `:if' condition is met, but even |
||||
with the specified `:load-path' the module cannot be found." |
||||
(interactive) |
||||
(save-excursion |
||||
(goto-char (point-min)) |
||||
(let ((re (eval use-package-form-regexp-eval))) |
||||
(while (re-search-forward re nil t) |
||||
(goto-char (match-beginning 0)) |
||||
(let ((decl (read (current-buffer)))) |
||||
(when (eq (car decl) 'use-package) |
||||
(use-package-lint-declaration |
||||
(use-package-as-string (cadr decl)) |
||||
(use-package-normalize-keywords |
||||
(cadr decl) (cddr decl))))))))) |
||||
|
||||
(provide 'use-package-lint) |
||||
|
||||
;;; use-package-lint.el ends here |
@ -0,0 +1,8 @@
|
||||
(define-package "use-package" "20171215.2248" "A configuration macro for simplifying your .emacs" |
||||
'((emacs "24.3") |
||||
(bind-key "2.4")) |
||||
:url "https://github.com/jwiegley/use-package" :keywords |
||||
'("dotemacs" "startup" "speed" "config" "package")) |
||||
;; Local Variables: |
||||
;; no-byte-compile: t |
||||
;; End: |
@ -0,0 +1,54 @@
|
||||
;;; use-package.el --- A configuration macro for simplifying your .emacs |
||||
|
||||
;; Copyright (C) 2012-2017 John Wiegley |
||||
|
||||
;; Author: John Wiegley <johnw@newartisans.com> |
||||
;; Maintainer: John Wiegley <johnw@newartisans.com> |
||||
;; Created: 17 Jun 2012 |
||||
;; Modified: 29 Nov 2017 |
||||
;; Version: 2.4 |
||||
;; Package-Requires: ((emacs "24.3") (bind-key "2.4")) |
||||
;; Keywords: dotemacs startup speed config package |
||||
;; URL: https://github.com/jwiegley/use-package |
||||
|
||||
;; This program 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 3, or (at |
||||
;; your option) any later version. |
||||
|
||||
;; This program 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: |
||||
|
||||
;; The `use-package' declaration macro allows you to isolate package |
||||
;; configuration in your ".emacs" in a way that is performance-oriented and, |
||||
;; well, just tidy. I created it because I have over 80 packages that I use |
||||
;; in Emacs, and things were getting difficult to manage. Yet with this |
||||
;; utility my total load time is just under 1 second, with no loss of |
||||
;; functionality! |
||||
;; |
||||
;; Please see README.md from the same repository for documentation. |
||||
|
||||
;;; Code: |
||||
|
||||
(require 'use-package-core) |
||||
|
||||
(require 'use-package-bind-key) |
||||
(require 'use-package-diminish) |
||||
(require 'use-package-delight) |
||||
(require 'use-package-ensure) |
||||
|
||||
(declare-function use-package-jump-to-package-form "use-package-jump") |
||||
(autoload #'use-package-jump-to-package-form "use-package-jump" nil t) |
||||
|
||||
(provide 'use-package) |
||||
|
||||
;;; use-package.el ends here |
Loading…
Reference in new issue