1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-25 15:00:45 -08:00

Revert "Merge pull request from edvorg/master"

This reverts commit 38b213c6c382f87b7f6e60d0c97d37f2951c2482, reversing
changes made to 7d34df4f5dd26b6d8b0899e6508c9af5dedf2dc4.
GitHub-reference: https://github.com/jwiegley/use-package/issues/247
This commit is contained in:
John Wiegley 2015-09-06 20:51:31 -07:00
parent 9c1156dbf8
commit 3e2747f174

View file

@ -165,10 +165,10 @@ convert it to a string and return that."
(if (stringp string-or-symbol) string-or-symbol
(symbol-name string-or-symbol)))
(defun use-package-load-name (name)
(defun use-package-load-name (name &optional noerror)
"Return a form which will load or require NAME depending on
whether it's a string or symbol."
(if (stringp name) `(use-package-load ,name) `(use-package-require ',name)))
(if (stringp name) `(load ,name 'noerror) `(require ',name nil 'noerror)))
(defun use-package-expand (name label form)
"FORM is a list of forms, so `((foo))' if only `foo' is being called."
@ -292,24 +292,6 @@ This is in contrast to merely setting it to 0."
(setq result (cons (car x) (cons (cdr x) result))))
result)))
(defun use-package-require (package)
"Require a package and handle any error from it."
(condition-case e
(require package)
(error (progn (use-package-require-error-handler package e)
nil))))
(defun use-package-load (name)
"Load a file and handle any error from it."
(condition-case e
(load name)
(error (progn (use-package-require-error-handler name e)
nil))))
(defun use-package-require-error-handler (package error)
"Main use package error handler for package loading."
(use-package-error (format "Could not load package.el: %s error: %s" package error)))
(defsubst use-package-concat (&rest elems)
"Delete all empty lists from ELEMS (nil or (list nil)), and append them."
(apply #'nconc (delete nil (delete (list nil) elems))))
@ -715,20 +697,21 @@ 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 (use-package-require 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 "use-package: package.el %s failed to define keymap %s"
package keymap-symbol)))))
(if (not (require package nil t))
(use-package-error (format "Could not 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 "use-package: package.el %s failed to define keymap %s"
package keymap-symbol)))))
(defun use-package-handler/:bind-keymap
(name keyword arg rest state &optional override)
@ -853,7 +836,7 @@ deferred until the prefix key sequence is pressed."
;; Load the package after a set amount of idle time, if the argument to
;; `:defer' was a number.
(when (numberp arg)
`((run-with-idle-timer ,arg nil #'use-package-require ',(use-package-as-symbol name))))
`((run-with-idle-timer ,arg nil #'require ',(use-package-as-symbol name) nil t)))
;; Since we deferring load, establish any necessary autoloads, and also
;; keep the byte-compiler happy.
@ -925,8 +908,10 @@ deferred until the prefix key sequence is pressed."
(use-package-concat
(list (use-package-load-name name))
config-body)
`((if (not (null ,(use-package-load-name name)))
,@config-body)))))))
`((if (not ,(use-package-load-name name t))
(ignore
(message (format "Could not load %s" ',name)))
,@config-body)))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;