mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-27 15:40:47 -08:00
Merge pull request from tarsius/master
some small cleanups GitHub-reference: https://github.com/jwiegley/use-package/issues/24
This commit is contained in:
commit
9741bdb189
2 changed files with 49 additions and 41 deletions
|
|
@ -219,5 +219,7 @@
|
||||||
(display-buffer (current-buffer))))
|
(display-buffer (current-buffer))))
|
||||||
|
|
||||||
(provide 'bind-key)
|
(provide 'bind-key)
|
||||||
|
;; Local Variables:
|
||||||
|
;; indent-tabs-mode: nil
|
||||||
|
;; End:
|
||||||
;;; bind-key.el ends here
|
;;; bind-key.el ends here
|
||||||
|
|
|
||||||
|
|
@ -284,8 +284,11 @@
|
||||||
(eval-when-compile
|
(eval-when-compile
|
||||||
(require 'cl))
|
(require 'cl))
|
||||||
|
|
||||||
|
(declare-function package-installed-p 'package)
|
||||||
|
(declare-function el-get-read-recipe 'el-get)
|
||||||
|
|
||||||
(defgroup use-package nil
|
(defgroup use-package nil
|
||||||
"A use-package declaration for simplifying your .emacs"
|
"A use-package declaration for simplifying your `.emacs'."
|
||||||
:group 'startup)
|
:group 'startup)
|
||||||
|
|
||||||
(defcustom use-package-verbose t
|
(defcustom use-package-verbose t
|
||||||
|
|
@ -294,15 +297,14 @@
|
||||||
:group 'use-package)
|
:group 'use-package)
|
||||||
|
|
||||||
(defcustom use-package-debug nil
|
(defcustom use-package-debug nil
|
||||||
"Whether to report more information, mostly regarding el-get"
|
"Whether to report more information, mostly regarding el-get."
|
||||||
:type 'boolean
|
:type 'boolean
|
||||||
:group 'use-package)
|
:group 'use-package)
|
||||||
|
|
||||||
(defcustom use-package-minimum-reported-time 0.01
|
(defcustom use-package-minimum-reported-time 0.01
|
||||||
"Minimal load time that will be reported"
|
"Minimal load time that will be reported"
|
||||||
:type 'number
|
:type 'number
|
||||||
:group 'use-package
|
:group 'use-package)
|
||||||
)
|
|
||||||
|
|
||||||
(defmacro with-elapsed-timer (text &rest forms)
|
(defmacro with-elapsed-timer (text &rest forms)
|
||||||
`(let ((now ,(if use-package-verbose
|
`(let ((now ,(if use-package-verbose
|
||||||
|
|
@ -346,7 +348,7 @@
|
||||||
(defvar use-package-idle-forms nil)
|
(defvar use-package-idle-forms nil)
|
||||||
|
|
||||||
(defun use-package-start-idle-timer ()
|
(defun use-package-start-idle-timer ()
|
||||||
"Ensure that the idle timer is running"
|
"Ensure that the idle timer is running."
|
||||||
(unless use-package-idle-timer
|
(unless use-package-idle-timer
|
||||||
(setq use-package-idle-timer
|
(setq use-package-idle-timer
|
||||||
(run-with-idle-timer
|
(run-with-idle-timer
|
||||||
|
|
@ -354,16 +356,15 @@
|
||||||
'use-package-idle-eval))))
|
'use-package-idle-eval))))
|
||||||
|
|
||||||
(defun use-package-init-on-idle (form)
|
(defun use-package-init-on-idle (form)
|
||||||
"Add a new form to the idle queue"
|
"Add a new form to the idle queue."
|
||||||
(use-package-start-idle-timer)
|
(use-package-start-idle-timer)
|
||||||
(if use-package-idle-forms
|
(if use-package-idle-forms
|
||||||
(add-to-list 'use-package-idle-forms
|
(add-to-list 'use-package-idle-forms
|
||||||
form t)
|
form t)
|
||||||
(setq use-package-idle-forms (list form))
|
(setq use-package-idle-forms (list form))))
|
||||||
))
|
|
||||||
|
|
||||||
(defun use-package-idle-eval()
|
(defun use-package-idle-eval()
|
||||||
"Start to eval idle-commands from the idle queue"
|
"Start to eval idle-commands from the idle queue."
|
||||||
(let ((next (pop use-package-idle-forms)))
|
(let ((next (pop use-package-idle-forms)))
|
||||||
(if next
|
(if next
|
||||||
(progn
|
(progn
|
||||||
|
|
@ -376,9 +377,9 @@
|
||||||
(message
|
(message
|
||||||
"Failure on use-package idle. Form: %s, Error: %s"
|
"Failure on use-package idle. Form: %s, Error: %s"
|
||||||
next e)))
|
next e)))
|
||||||
;; recurse after a bit
|
;; recurse after a bit
|
||||||
(when (sit-for 3)
|
(when (sit-for 3)
|
||||||
(use-package-idle-eval)))
|
(use-package-idle-eval)))
|
||||||
;; finished (so far!)
|
;; finished (so far!)
|
||||||
(cancel-timer use-package-idle-timer)
|
(cancel-timer use-package-idle-timer)
|
||||||
(setq use-package-idle-timer nil))))
|
(setq use-package-idle-timer nil))))
|
||||||
|
|
@ -410,8 +411,7 @@ For full documentation. please see commentary.
|
||||||
:defines Define vars to silence byte-compiler.
|
:defines Define vars to silence byte-compiler.
|
||||||
:load-path Add to `load-path' before loading.
|
:load-path Add to `load-path' before loading.
|
||||||
:diminish Support for diminish package (if it's installed).
|
:diminish Support for diminish package (if it's installed).
|
||||||
:idle adds a form to run on an idle timer
|
:idle adds a form to run on an idle timer"
|
||||||
"
|
|
||||||
(let* ((commands (plist-get args :commands))
|
(let* ((commands (plist-get args :commands))
|
||||||
(pre-init-body (plist-get args :pre-init))
|
(pre-init-body (plist-get args :pre-init))
|
||||||
(init-body (plist-get args :init))
|
(init-body (plist-get args :init))
|
||||||
|
|
@ -448,6 +448,7 @@ For full documentation. please see commentary.
|
||||||
ensure)))
|
ensure)))
|
||||||
|
|
||||||
(when package-name
|
(when package-name
|
||||||
|
(require 'package)
|
||||||
(use-package-ensure-elpa package-name)))
|
(use-package-ensure-elpa package-name)))
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -482,35 +483,38 @@ For full documentation. please see commentary.
|
||||||
,init-body)))
|
,init-body)))
|
||||||
|
|
||||||
|
|
||||||
(flet ((init-for-commands
|
(let ((init-for-commands
|
||||||
(func sym-or-list)
|
(lambda (func sym-or-list)
|
||||||
(let ((cons-list (if (and (consp sym-or-list)
|
(let ((cons-list (if (and (consp sym-or-list)
|
||||||
(stringp (car sym-or-list)))
|
(stringp (car sym-or-list)))
|
||||||
(list sym-or-list)
|
(list sym-or-list)
|
||||||
sym-or-list)))
|
sym-or-list)))
|
||||||
(if cons-list
|
(if cons-list
|
||||||
(setq init-body
|
(setq init-body
|
||||||
`(progn
|
`(progn
|
||||||
,init-body
|
,init-body
|
||||||
,@(mapcar #'(lambda (elem)
|
,@(mapcar #'(lambda (elem)
|
||||||
(push (cdr elem) commands)
|
(push (cdr elem) commands)
|
||||||
(funcall func elem))
|
(funcall func elem))
|
||||||
cons-list)))))))
|
cons-list))))))))
|
||||||
|
|
||||||
(init-for-commands #'(lambda (binding)
|
(funcall init-for-commands
|
||||||
`(bind-key ,(car binding)
|
#'(lambda (binding)
|
||||||
(quote ,(cdr binding))))
|
`(bind-key ,(car binding)
|
||||||
(plist-get args :bind))
|
(quote ,(cdr binding))))
|
||||||
|
(plist-get args :bind))
|
||||||
|
|
||||||
(init-for-commands #'(lambda (mode)
|
(funcall init-for-commands
|
||||||
`(add-to-list 'auto-mode-alist
|
#'(lambda (mode)
|
||||||
(quote ,mode)))
|
`(add-to-list 'auto-mode-alist
|
||||||
(plist-get args :mode))
|
(quote ,mode)))
|
||||||
|
(plist-get args :mode))
|
||||||
|
|
||||||
(init-for-commands #'(lambda (interpreter)
|
(funcall init-for-commands
|
||||||
`(add-to-list 'interpreter-mode-alist
|
#'(lambda (interpreter)
|
||||||
(quote ,interpreter)))
|
`(add-to-list 'interpreter-mode-alist
|
||||||
(plist-get args :interpreter)))
|
(quote ,interpreter)))
|
||||||
|
(plist-get args :interpreter)))
|
||||||
|
|
||||||
`(progn
|
`(progn
|
||||||
,@(mapcar
|
,@(mapcar
|
||||||
|
|
@ -605,5 +609,7 @@ For full documentation. please see commentary.
|
||||||
(put 'use-package 'lisp-indent-function 1)
|
(put 'use-package 'lisp-indent-function 1)
|
||||||
|
|
||||||
(provide 'use-package)
|
(provide 'use-package)
|
||||||
|
;; Local Variables:
|
||||||
|
;; indent-tabs-mode: nil
|
||||||
|
;; End:
|
||||||
;;; use-package.el ends here
|
;;; use-package.el ends here
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue