2018-03-20 11:40:26 -05:00
|
|
|
|
;;; use-package-tests.el --- Tests for use-package.el -*- lexical-binding: t; -*-
|
2014-02-12 22:30:12 +01:00
|
|
|
|
|
|
|
|
|
;; This program is free software; you can redistribute it and/or
|
|
|
|
|
;; modify it under the terms of the GNU General Public License as
|
2017-12-06 06:19:15 -08:00
|
|
|
|
;; published by the Free Software Foundation; either version 3, or (at
|
2014-02-12 22:30:12 +01:00
|
|
|
|
;; 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:
|
|
|
|
|
|
2017-12-04 21:21:54 +00:00
|
|
|
|
;;
|
2014-02-12 22:30:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
2018-01-27 11:11:40 -06:00
|
|
|
|
(require 'cl)
|
2014-02-12 22:30:12 +01:00
|
|
|
|
(require 'ert)
|
|
|
|
|
(require 'use-package)
|
|
|
|
|
|
2017-12-01 01:33:01 -08:00
|
|
|
|
(setq use-package-always-ensure nil
|
2017-12-03 03:07:30 -08:00
|
|
|
|
use-package-verbose 'errors
|
2017-12-01 11:07:08 -08:00
|
|
|
|
use-package-expand-minimally t
|
2017-12-06 10:31:47 -08:00
|
|
|
|
;; These are needed for certain tests below where the `pcase' match
|
|
|
|
|
;; expression is large and contains holes, such as the :after tests.
|
2017-12-03 03:07:30 -08:00
|
|
|
|
max-lisp-eval-depth 8000
|
|
|
|
|
max-specpdl-size 8000)
|
2017-12-01 01:33:01 -08:00
|
|
|
|
|
2017-12-03 10:33:12 -08:00
|
|
|
|
(unless (fboundp 'macroexpand-1)
|
|
|
|
|
(defun macroexpand-1 (form &optional environment)
|
|
|
|
|
"Perform (at most) one step of macroexpansion."
|
|
|
|
|
(cond
|
|
|
|
|
((consp form)
|
|
|
|
|
(let* ((head (car form))
|
|
|
|
|
(env-expander (assq head environment)))
|
|
|
|
|
(if env-expander
|
|
|
|
|
(if (cdr env-expander)
|
|
|
|
|
(apply (cdr env-expander) (cdr form))
|
|
|
|
|
form)
|
|
|
|
|
(if (not (and (symbolp head) (fboundp head)))
|
|
|
|
|
form
|
|
|
|
|
(let ((def (autoload-do-load (symbol-function head) head 'macro)))
|
|
|
|
|
(cond
|
|
|
|
|
;; Follow alias, but only for macros, otherwise we may end up
|
|
|
|
|
;; skipping an important compiler-macro (e.g. cl--block-wrapper).
|
|
|
|
|
((and (symbolp def) (macrop def)) (cons def (cdr form)))
|
|
|
|
|
((not (consp def)) form)
|
|
|
|
|
(t
|
|
|
|
|
(if (eq 'macro (car def))
|
|
|
|
|
(apply (cdr def) (cdr form))
|
|
|
|
|
form))))))))
|
|
|
|
|
(t form))))
|
|
|
|
|
|
2017-11-30 12:38:01 -08:00
|
|
|
|
(defmacro expand-minimally (form)
|
2017-12-03 03:07:30 -08:00
|
|
|
|
`(let ((use-package-verbose 'errors)
|
2017-11-30 12:38:01 -08:00
|
|
|
|
(use-package-expand-minimally t))
|
2017-12-03 03:07:30 -08:00
|
|
|
|
(macroexpand-1 ',form)))
|
2017-11-30 12:38:01 -08:00
|
|
|
|
|
2017-12-04 10:30:49 -08:00
|
|
|
|
(defmacro expand-maximally (form)
|
|
|
|
|
`(let ((use-package-verbose 'debug)
|
|
|
|
|
(use-package-expand-minimally nil))
|
|
|
|
|
(macroexpand-1 ',form)))
|
|
|
|
|
|
2017-11-30 19:40:54 -08:00
|
|
|
|
(defmacro match-expansion (form &rest value)
|
2017-11-30 12:38:01 -08:00
|
|
|
|
`(should (pcase (expand-minimally ,form)
|
2017-11-30 19:40:54 -08:00
|
|
|
|
,@(mapcar #'(lambda (x) (list x t)) value))))
|
2017-11-30 12:38:01 -08:00
|
|
|
|
|
2017-12-03 03:07:30 -08:00
|
|
|
|
(defun fix-expansion ()
|
|
|
|
|
(interactive)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(unless (looking-at "(match-expansion")
|
|
|
|
|
(backward-up-list))
|
|
|
|
|
(when (looking-at "(match-expansion")
|
2017-12-04 15:21:41 -08:00
|
|
|
|
(re-search-forward "(\\(use-package\\|bind-key\\)")
|
2017-12-03 03:07:30 -08:00
|
|
|
|
(goto-char (match-beginning 0))
|
|
|
|
|
(let ((decl (read (current-buffer))))
|
|
|
|
|
(kill-sexp)
|
2017-12-05 13:26:03 -08:00
|
|
|
|
(let (vars)
|
|
|
|
|
(catch 'exit
|
|
|
|
|
(save-excursion
|
|
|
|
|
(while (ignore-errors (backward-up-list) t)
|
|
|
|
|
(when (looking-at "(let\\s-+")
|
|
|
|
|
(goto-char (match-end 0))
|
|
|
|
|
(setq vars (read (current-buffer)))
|
|
|
|
|
(throw 'exit t)))))
|
|
|
|
|
(eval
|
|
|
|
|
`(let (,@ (append vars
|
|
|
|
|
'((use-package-verbose 'errors)
|
|
|
|
|
(use-package-expand-minimally t))))
|
|
|
|
|
(insert ?\n ?\` (pp-to-string (macroexpand-1 decl))))))))))
|
2017-12-03 03:07:30 -08:00
|
|
|
|
|
|
|
|
|
(bind-key "C-c C-u" #'fix-expansion emacs-lisp-mode-map)
|
|
|
|
|
|
2017-11-30 12:38:01 -08:00
|
|
|
|
(eval-when-compile
|
2017-11-30 18:36:45 -08:00
|
|
|
|
(defun plist-delete (plist property)
|
|
|
|
|
"Delete PROPERTY from PLIST"
|
|
|
|
|
(let (p)
|
|
|
|
|
(while plist
|
|
|
|
|
(if (not (eq property (car plist)))
|
|
|
|
|
(setq p (plist-put p (car plist) (nth 1 plist))))
|
|
|
|
|
(setq plist (cddr plist)))
|
|
|
|
|
p))
|
|
|
|
|
|
2017-12-01 01:33:01 -08:00
|
|
|
|
;; `cl-flet' does not work for some of the mocking we do below, while `flet'
|
|
|
|
|
;; always does.
|
2017-11-30 12:38:01 -08:00
|
|
|
|
(setplist 'flet (plist-delete (symbol-plist 'flet) 'byte-obsolete-info)))
|
|
|
|
|
|
2017-11-30 09:42:47 -08:00
|
|
|
|
(ert-deftest use-package-test-recognize-function ()
|
2017-12-03 11:00:41 -08:00
|
|
|
|
(should (use-package-recognize-function nil t))
|
|
|
|
|
(should-not (use-package-recognize-function nil))
|
|
|
|
|
(should (use-package-recognize-function t))
|
|
|
|
|
(should (use-package-recognize-function 'sym))
|
|
|
|
|
(should (use-package-recognize-function #'sym))
|
|
|
|
|
(should (use-package-recognize-function (lambda () ...)))
|
|
|
|
|
(should (use-package-recognize-function '(lambda () ...)))
|
|
|
|
|
(should (use-package-recognize-function #'(lambda () ...)))
|
|
|
|
|
|
|
|
|
|
(should-not (use-package-recognize-function 1))
|
|
|
|
|
(should-not (use-package-recognize-function "Hello"))
|
|
|
|
|
(should-not (use-package-recognize-function '(nil . nil))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
|
|
|
|
(ert-deftest use-package-test-normalize-function ()
|
2017-12-03 11:00:41 -08:00
|
|
|
|
(should (equal (use-package-normalize-function nil) nil))
|
|
|
|
|
(should (equal (use-package-normalize-function t) t))
|
|
|
|
|
(should (equal (use-package-normalize-function 'sym) 'sym))
|
|
|
|
|
(should (equal (use-package-normalize-function #'sym) 'sym))
|
2018-05-22 11:41:21 -05:00
|
|
|
|
(should (equal (use-package-normalize-function '(lambda () ...)) '(lambda () ...)))
|
|
|
|
|
(should (equal (use-package-normalize-function ''(lambda () ...)) '(lambda () ...)))
|
|
|
|
|
(should (equal (use-package-normalize-function '#'(lambda () ...)) '(lambda () ...)))
|
2017-12-03 11:00:41 -08:00
|
|
|
|
|
|
|
|
|
(should (equal (use-package-normalize-function 1) 1))
|
|
|
|
|
(should (equal (use-package-normalize-function "Hello") "Hello"))
|
|
|
|
|
(should (equal (use-package-normalize-function '(nil . nil)) '(nil . nil))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:disabled-1 ()
|
2017-12-01 01:33:01 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :disabled t)
|
|
|
|
|
`()))
|
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:preface-1 ()
|
2017-12-01 01:33:01 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :preface (t))
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(t))
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil))))
|
2017-12-01 01:33:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:preface-2 ()
|
2017-12-01 01:33:01 -08:00
|
|
|
|
(let ((byte-compile-current-file t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :preface (t))
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(with-demoted-errors
|
|
|
|
|
"Cannot load foo: %S" nil
|
|
|
|
|
(load "foo" nil t)))
|
|
|
|
|
(t))
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil)))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:preface-3 ()
|
2017-12-01 01:33:01 -08:00
|
|
|
|
(let ((byte-compile-current-file t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo
|
|
|
|
|
:preface (preface)
|
|
|
|
|
:init (init)
|
|
|
|
|
:config (config)
|
|
|
|
|
:functions func
|
|
|
|
|
:defines def)
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(defvar def)
|
|
|
|
|
(declare-function func "foo")
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(with-demoted-errors
|
|
|
|
|
"Cannot load foo: %S" nil
|
|
|
|
|
(load "foo" nil t)))
|
|
|
|
|
(preface))
|
|
|
|
|
(init)
|
2017-12-01 13:38:41 -08:00
|
|
|
|
(require 'foo nil nil)
|
2017-12-01 01:33:01 -08:00
|
|
|
|
(config)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
t))))
|
2017-12-01 01:33:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:preface-4 ()
|
2017-12-01 01:33:01 -08:00
|
|
|
|
(let ((byte-compile-current-file t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo
|
|
|
|
|
:preface (preface)
|
|
|
|
|
:init (init)
|
|
|
|
|
:config (config)
|
|
|
|
|
:functions func
|
|
|
|
|
:defines def
|
|
|
|
|
:defer t)
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(defvar def)
|
|
|
|
|
(declare-function func "foo")
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(with-demoted-errors
|
|
|
|
|
"Cannot load foo: %S" nil
|
|
|
|
|
(load "foo" nil t)))
|
|
|
|
|
(preface))
|
|
|
|
|
(init)
|
|
|
|
|
(eval-after-load 'foo
|
|
|
|
|
'(progn
|
|
|
|
|
(config)
|
|
|
|
|
t))))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:pin-1 ()
|
2017-12-01 11:16:19 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :pin foo)
|
|
|
|
|
`(progn
|
|
|
|
|
(use-package-pin-package 'foo "foo")
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil))))
|
2017-12-01 11:16:19 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:pin-2 ()
|
2017-12-01 11:16:19 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :pin "foo")
|
|
|
|
|
`(progn
|
|
|
|
|
(use-package-pin-package 'foo "foo")
|
2017-12-01 13:38:41 -08:00
|
|
|
|
(require 'foo nil nil))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
2017-11-30 18:37:27 -08:00
|
|
|
|
(ert-deftest use-package-test-normalize/:ensure ()
|
|
|
|
|
(flet ((norm (&rest args)
|
|
|
|
|
(apply #'use-package-normalize/:ensure
|
|
|
|
|
'foopkg :ensure args)))
|
2017-12-04 11:26:19 -08:00
|
|
|
|
(should (equal (norm '(t)) '(t)))
|
|
|
|
|
(should (equal (norm '(nil)) '(nil)))
|
|
|
|
|
(should (equal (norm '(sym)) '(sym)))
|
2017-11-30 18:37:27 -08:00
|
|
|
|
(should-error (norm '(1)))
|
|
|
|
|
(should-error (norm '("Hello")))))
|
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:ensure-1 ()
|
2017-11-30 12:38:01 -08:00
|
|
|
|
(let ((use-package-always-ensure nil))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :ensure t)
|
|
|
|
|
`(progn
|
2017-12-04 11:26:19 -08:00
|
|
|
|
(use-package-ensure-elpa 'foo '(t) 'nil)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil)))))
|
2017-11-30 12:38:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:ensure-2 ()
|
2017-11-30 12:38:01 -08:00
|
|
|
|
(let ((use-package-always-ensure t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :ensure t)
|
|
|
|
|
`(progn
|
2017-12-04 11:26:19 -08:00
|
|
|
|
(use-package-ensure-elpa 'foo '(t) 'nil)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil)))))
|
2017-11-30 12:38:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:ensure-3 ()
|
2017-11-30 12:38:01 -08:00
|
|
|
|
(let ((use-package-always-ensure nil))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :ensure nil)
|
|
|
|
|
`(progn
|
2017-12-04 11:26:19 -08:00
|
|
|
|
(use-package-ensure-elpa 'foo '(nil) 'nil)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil)))))
|
2017-11-30 12:38:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:ensure-4 ()
|
2017-11-30 12:38:01 -08:00
|
|
|
|
(let ((use-package-always-ensure t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :ensure nil)
|
|
|
|
|
`(progn
|
2017-12-04 11:26:19 -08:00
|
|
|
|
(use-package-ensure-elpa 'foo '(nil) 'nil)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil)))))
|
2017-11-30 12:38:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:ensure-5 ()
|
2017-11-30 12:38:01 -08:00
|
|
|
|
(let ((use-package-always-ensure nil))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :load-path "foo")
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(add-to-list 'load-path ,(pred stringp)))
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil)))))
|
2017-11-30 12:38:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:ensure-6 ()
|
2017-11-30 12:38:01 -08:00
|
|
|
|
(let ((use-package-always-ensure t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :load-path "foo")
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(add-to-list 'load-path ,(pred stringp)))
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil)))))
|
2017-11-30 12:38:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:ensure-7 ()
|
2017-11-30 12:38:01 -08:00
|
|
|
|
(let ((use-package-always-ensure nil))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :ensure nil :load-path "foo")
|
|
|
|
|
`(progn
|
2017-12-04 11:26:19 -08:00
|
|
|
|
(use-package-ensure-elpa 'foo '(nil) 'nil)
|
2017-11-30 12:38:01 -08:00
|
|
|
|
(eval-and-compile
|
|
|
|
|
(add-to-list 'load-path ,(pred stringp)))
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil)))))
|
2017-11-30 12:38:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:ensure-8 ()
|
2017-11-30 12:38:01 -08:00
|
|
|
|
(let ((use-package-always-ensure t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :ensure nil :load-path "foo")
|
|
|
|
|
`(progn
|
2017-12-04 11:26:19 -08:00
|
|
|
|
(use-package-ensure-elpa 'foo '(nil) 'nil)
|
2017-11-30 12:38:01 -08:00
|
|
|
|
(eval-and-compile
|
|
|
|
|
(add-to-list 'load-path ,(pred stringp)))
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil)))))
|
2017-11-30 12:38:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:ensure-9 ()
|
2017-11-30 12:38:01 -08:00
|
|
|
|
(let ((use-package-always-ensure nil))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :ensure t :load-path "foo")
|
|
|
|
|
`(progn
|
2017-12-04 11:26:19 -08:00
|
|
|
|
(use-package-ensure-elpa 'foo '(t) 'nil)
|
2017-11-30 12:38:01 -08:00
|
|
|
|
(eval-and-compile
|
|
|
|
|
(add-to-list 'load-path ,(pred stringp)))
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil)))))
|
2017-11-30 12:38:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:ensure-10 ()
|
2017-11-30 12:38:01 -08:00
|
|
|
|
(let ((use-package-always-ensure t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :ensure t :load-path "foo")
|
|
|
|
|
`(progn
|
2017-12-04 11:26:19 -08:00
|
|
|
|
(use-package-ensure-elpa 'foo '(t) 'nil)
|
2017-11-30 12:38:01 -08:00
|
|
|
|
(eval-and-compile
|
|
|
|
|
(add-to-list 'load-path ,(pred stringp)))
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil)))))
|
2017-11-30 12:38:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:ensure-11 ()
|
2017-11-30 12:39:04 -08:00
|
|
|
|
(let (tried-to-install)
|
|
|
|
|
(flet ((use-package-ensure-elpa
|
2017-12-01 11:42:40 -08:00
|
|
|
|
(name ensure state &optional no-refresh)
|
2017-11-30 12:39:04 -08:00
|
|
|
|
(when ensure
|
2017-12-01 01:33:01 -08:00
|
|
|
|
(setq tried-to-install name)))
|
|
|
|
|
(require (&rest ignore)))
|
|
|
|
|
(use-package foo :ensure t)
|
2017-11-30 12:38:01 -08:00
|
|
|
|
(should (eq tried-to-install 'foo)))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
2017-12-04 11:26:19 -08:00
|
|
|
|
(ert-deftest use-package-test/:ensure-12 ()
|
|
|
|
|
(let ((use-package-always-ensure t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :ensure bar)
|
|
|
|
|
`(progn
|
|
|
|
|
(use-package-ensure-elpa 'foo '(bar) 'nil)
|
|
|
|
|
(require 'foo nil nil)))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest use-package-test/:ensure-13 ()
|
|
|
|
|
(let ((use-package-always-ensure t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :ensure bar :ensure quux)
|
|
|
|
|
`(progn
|
|
|
|
|
(use-package-ensure-elpa 'foo '(bar quux) 'nil)
|
|
|
|
|
(require 'foo nil nil)))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest use-package-test/:ensure-14 ()
|
2017-12-04 15:39:31 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package ess-site
|
|
|
|
|
:ensure ess1
|
|
|
|
|
:ensure ess2
|
|
|
|
|
:ensure (ess3 :pin "melpa-unstable")
|
|
|
|
|
:pin melpa-stable)
|
|
|
|
|
`(progn
|
|
|
|
|
(use-package-pin-package 'ess-site "melpa-stable")
|
|
|
|
|
(use-package-ensure-elpa 'ess-site
|
|
|
|
|
'(ess1 ess2
|
|
|
|
|
(ess3 . "melpa-unstable"))
|
|
|
|
|
'nil)
|
|
|
|
|
(require 'ess-site nil nil))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest use-package-test/:ensure-15 ()
|
2017-12-04 11:26:19 -08:00
|
|
|
|
(let ((use-package-always-ensure t))
|
|
|
|
|
(match-expansion
|
2017-12-04 15:39:31 -08:00
|
|
|
|
(use-package foo
|
|
|
|
|
:pin "elpa"
|
|
|
|
|
:ensure bar
|
|
|
|
|
:ensure (quux :pin "melpa"))
|
2017-12-04 11:26:19 -08:00
|
|
|
|
`(progn
|
2017-12-04 15:39:31 -08:00
|
|
|
|
(use-package-pin-package 'foo "elpa")
|
|
|
|
|
(use-package-ensure-elpa 'foo
|
|
|
|
|
'(bar
|
|
|
|
|
(quux . "melpa"))
|
|
|
|
|
'nil)
|
2017-12-04 11:26:19 -08:00
|
|
|
|
(require 'foo nil nil)))))
|
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:if-1 ()
|
2017-12-01 01:33:01 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :if t)
|
2017-12-03 03:07:30 -08:00
|
|
|
|
`(when t
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil))))
|
2017-12-01 01:33:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:if-2 ()
|
2017-12-01 01:33:01 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :if (and t t))
|
2017-12-03 03:07:30 -08:00
|
|
|
|
`(when (and t t)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil))))
|
2017-12-01 01:33:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:if-3 ()
|
2017-12-01 01:33:01 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :if nil)
|
2017-12-03 03:07:30 -08:00
|
|
|
|
`(when nil
|
|
|
|
|
(require 'foo nil nil))))
|
2017-12-01 01:33:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:when-1 ()
|
2017-12-01 01:33:01 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :when t)
|
2017-12-03 03:07:30 -08:00
|
|
|
|
`(when t
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil))))
|
2017-12-01 01:33:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:when-2 ()
|
2017-12-01 01:33:01 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :when (and t t))
|
2017-12-03 03:07:30 -08:00
|
|
|
|
`(when (and t t)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil))))
|
2017-12-01 01:33:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:when-3 ()
|
2017-12-01 01:33:01 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :when nil)
|
2017-12-03 03:07:30 -08:00
|
|
|
|
`(when nil
|
|
|
|
|
(require 'foo nil nil))))
|
2017-12-01 01:33:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:unless-1 ()
|
2017-12-01 01:33:01 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :unless t)
|
2017-12-03 03:07:30 -08:00
|
|
|
|
`(when (not t)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil))))
|
2017-12-01 01:33:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:unless-2 ()
|
2017-12-01 01:33:01 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :unless (and t t))
|
2017-12-03 03:07:30 -08:00
|
|
|
|
`(when (not (and t t))
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil))))
|
2017-12-01 01:33:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:unless-3 ()
|
2017-12-01 01:33:01 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :unless nil)
|
2017-12-03 03:07:30 -08:00
|
|
|
|
`(unless nil
|
|
|
|
|
(require 'foo nil nil))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:requires-1 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :requires bar)
|
2017-12-03 03:07:30 -08:00
|
|
|
|
`(when (featurep 'bar)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil))))
|
2017-12-03 03:07:30 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:requires-2 ()
|
2017-12-03 03:07:30 -08:00
|
|
|
|
(let ((byte-compile-current-file t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :requires bar)
|
|
|
|
|
`(when (featurep 'bar)
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(with-demoted-errors
|
|
|
|
|
"Cannot load foo: %S" nil
|
|
|
|
|
(load "foo" nil t))))
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil)))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:requires-3 ()
|
2017-12-03 03:07:30 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :requires (bar quux))
|
|
|
|
|
`(when (not (member nil (mapcar #'featurep '(bar quux))))
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil))))
|
2017-12-03 03:07:30 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:requires-4 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(let ((byte-compile-current-file t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :requires bar)
|
2017-12-03 03:07:30 -08:00
|
|
|
|
`(when (featurep 'bar)
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(with-demoted-errors "Cannot load foo: %S" nil
|
|
|
|
|
(load "foo" nil t))))
|
|
|
|
|
(require 'foo nil nil)))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:load-path-1 ()
|
2017-12-01 01:33:01 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :load-path "bar")
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(add-to-list 'load-path
|
|
|
|
|
,(pred (apply-partially
|
|
|
|
|
#'string=
|
|
|
|
|
(expand-file-name
|
|
|
|
|
"bar" user-emacs-directory)))))
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil))))
|
2017-12-01 01:33:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:load-path-2 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(let ((byte-compile-current-file t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :load-path "bar")
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(add-to-list 'load-path
|
|
|
|
|
,(pred (apply-partially
|
|
|
|
|
#'string=
|
|
|
|
|
(expand-file-name
|
|
|
|
|
"bar" user-emacs-directory)))))
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(with-demoted-errors "Cannot load foo: %S" nil
|
|
|
|
|
(load "foo" nil t))))
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil)))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:load-path-3 ()
|
2017-12-01 01:33:01 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :load-path ("bar" "quux"))
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(add-to-list 'load-path
|
|
|
|
|
,(pred (apply-partially
|
|
|
|
|
#'string=
|
|
|
|
|
(expand-file-name
|
|
|
|
|
"bar" user-emacs-directory)))))
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(add-to-list 'load-path
|
|
|
|
|
,(pred (apply-partially
|
|
|
|
|
#'string=
|
|
|
|
|
(expand-file-name
|
|
|
|
|
"quux" user-emacs-directory)))))
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil))))
|
2017-12-01 01:33:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:load-path-4 ()
|
2017-12-01 01:33:01 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :load-path (lambda () (list "bar" "quux")))
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(add-to-list 'load-path
|
|
|
|
|
,(pred (apply-partially
|
|
|
|
|
#'string=
|
|
|
|
|
(expand-file-name
|
|
|
|
|
"bar" user-emacs-directory)))))
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(add-to-list 'load-path
|
|
|
|
|
,(pred (apply-partially
|
|
|
|
|
#'string=
|
|
|
|
|
(expand-file-name
|
|
|
|
|
"quux" user-emacs-directory)))))
|
2017-12-01 13:38:41 -08:00
|
|
|
|
(require 'foo nil nil))))
|
2017-12-01 01:33:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:no-require-1 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :no-require t)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
`nil))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:no-require-2 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :no-require t :config (config))
|
|
|
|
|
`(progn
|
|
|
|
|
(config)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
t)))
|
2017-12-01 01:40:58 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:no-require-3 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(let ((byte-compile-current-file t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :no-require t)
|
2017-12-03 03:07:30 -08:00
|
|
|
|
`(eval-and-compile
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(with-demoted-errors "Cannot load foo: %S" nil nil))))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
2017-12-05 13:11:30 -08:00
|
|
|
|
(defun use-package-test-normalize-bind (&rest args)
|
|
|
|
|
(apply #'use-package-normalize-binder 'foo :bind args))
|
|
|
|
|
|
|
|
|
|
(ert-deftest use-package-test-normalize/:bind-1 ()
|
|
|
|
|
(should (equal (use-package-test-normalize-bind
|
|
|
|
|
'(("C-a" . alpha)))
|
|
|
|
|
'(("C-a" . alpha)))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest use-package-test-normalize/:bind-2 ()
|
|
|
|
|
(should (equal (use-package-test-normalize-bind
|
|
|
|
|
'(("C-a" . alpha)
|
|
|
|
|
:map foo-map
|
|
|
|
|
("C-b" . beta)))
|
|
|
|
|
'(("C-a" . alpha)
|
|
|
|
|
:map foo-map
|
|
|
|
|
("C-b" . beta)))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest use-package-test-normalize/:bind-3 ()
|
|
|
|
|
(should (equal (use-package-test-normalize-bind
|
|
|
|
|
'(:map foo-map
|
|
|
|
|
("C-a" . alpha)
|
|
|
|
|
("C-b" . beta)))
|
|
|
|
|
'(:map foo-map
|
|
|
|
|
("C-a" . alpha)
|
|
|
|
|
("C-b" . beta)))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:bind-1 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
2017-12-05 13:11:30 -08:00
|
|
|
|
(use-package foo :bind ("C-k" . key1) ("C-u" . key2))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
`(progn
|
2017-12-05 13:11:30 -08:00
|
|
|
|
(unless
|
|
|
|
|
(fboundp 'key1)
|
|
|
|
|
(autoload #'key1 "foo" nil t))
|
|
|
|
|
(unless
|
|
|
|
|
(fboundp 'key2)
|
|
|
|
|
(autoload #'key2 "foo" nil t))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(bind-keys :package foo
|
|
|
|
|
("C-k" . key1)
|
|
|
|
|
("C-u" . key2)))))
|
2017-12-05 13:11:30 -08:00
|
|
|
|
|
|
|
|
|
(ert-deftest use-package-test/:bind-2 ()
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :bind (("C-k" . key1) ("C-u" . key2)))
|
|
|
|
|
`(progn
|
|
|
|
|
(unless (fboundp 'key1)
|
|
|
|
|
(autoload #'key1 "foo" nil t))
|
|
|
|
|
(unless (fboundp 'key2)
|
|
|
|
|
(autoload #'key2 "foo" nil t))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(bind-keys :package foo
|
|
|
|
|
("C-k" . key1)
|
|
|
|
|
("C-u" . key2)))))
|
2017-12-05 13:11:30 -08:00
|
|
|
|
|
|
|
|
|
(ert-deftest use-package-test/:bind-3 ()
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :bind (:map my-map ("C-k" . key1) ("C-u" . key2)))
|
|
|
|
|
`(progn
|
|
|
|
|
(unless
|
|
|
|
|
(fboundp 'key1)
|
|
|
|
|
(autoload #'key1 "foo" nil t))
|
|
|
|
|
(unless
|
|
|
|
|
(fboundp 'key2)
|
|
|
|
|
(autoload #'key2 "foo" nil t))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(bind-keys :package foo :map my-map
|
|
|
|
|
("C-k" . key1)
|
|
|
|
|
("C-u" . key2)))))
|
2017-12-05 13:11:30 -08:00
|
|
|
|
|
|
|
|
|
(ert-deftest use-package-test/:bind-4 ()
|
|
|
|
|
(should-error
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :bind :map my-map ("C-k" . key1) ("C-u" . key2))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
`(bind-keys :package foo))))
|
2017-12-05 13:11:30 -08:00
|
|
|
|
|
|
|
|
|
(ert-deftest use-package-test/:bind-5 ()
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :bind ("C-k" . key1) (:map my-map ("C-u" . key2)))
|
|
|
|
|
`(progn
|
|
|
|
|
(unless (fboundp 'key1)
|
|
|
|
|
(autoload #'key1 "foo" nil t))
|
|
|
|
|
(unless (fboundp 'key2)
|
|
|
|
|
(autoload #'key2 "foo" nil t))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(bind-keys :package foo
|
|
|
|
|
("C-k" . key1)
|
|
|
|
|
:map my-map
|
|
|
|
|
("C-u" . key2)))))
|
2017-12-05 13:11:30 -08:00
|
|
|
|
|
|
|
|
|
(ert-deftest use-package-test/:bind-6 ()
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo
|
|
|
|
|
:bind
|
|
|
|
|
("C-k" . key1)
|
|
|
|
|
(:map my-map ("C-u" . key2))
|
|
|
|
|
(:map my-map2 ("C-u" . key3)))
|
|
|
|
|
`(progn
|
|
|
|
|
(unless (fboundp 'key1)
|
|
|
|
|
(autoload #'key1 "foo" nil t))
|
|
|
|
|
(unless (fboundp 'key2)
|
|
|
|
|
(autoload #'key2 "foo" nil t))
|
|
|
|
|
(unless (fboundp 'key3)
|
|
|
|
|
(autoload #'key3 "foo" nil t))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(bind-keys :package foo
|
|
|
|
|
("C-k" . key1)
|
|
|
|
|
:map my-map ("C-u" . key2)
|
|
|
|
|
:map my-map2 ("C-u" . key3)))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
2017-12-06 08:30:47 -08:00
|
|
|
|
(ert-deftest use-package-test/:bind-7 ()
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo
|
|
|
|
|
:ensure
|
|
|
|
|
:bind ("C-c r" . browse-at-remote))
|
|
|
|
|
`(progn
|
|
|
|
|
(use-package-ensure-elpa 'foo '(t) 'nil)
|
|
|
|
|
(unless (fboundp 'browse-at-remote)
|
|
|
|
|
(autoload #'browse-at-remote "foo" nil t))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(bind-keys :package foo ("C-c r" . browse-at-remote)))))
|
2017-12-06 08:30:47 -08:00
|
|
|
|
|
2017-12-07 22:04:24 -08:00
|
|
|
|
(ert-deftest use-package-test/:bind-8 ()
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo
|
|
|
|
|
:ensure
|
|
|
|
|
:bind (:map foo-map
|
|
|
|
|
(("C-c r" . foo)
|
|
|
|
|
("C-c r" . bar))))
|
|
|
|
|
`(progn
|
|
|
|
|
(use-package-ensure-elpa 'foo '(t) 'nil)
|
|
|
|
|
(unless (fboundp 'foo)
|
|
|
|
|
(autoload #'foo "foo" nil t))
|
|
|
|
|
(unless (fboundp 'bar)
|
|
|
|
|
(autoload #'bar "foo" nil t))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(bind-keys :package foo :map foo-map
|
|
|
|
|
("C-c r" . foo)
|
|
|
|
|
("C-c r" . bar)))))
|
2017-12-07 22:04:24 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:bind*-1 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :bind* ("C-k" . key))
|
|
|
|
|
`(progn
|
|
|
|
|
(unless (fboundp 'key)
|
|
|
|
|
(autoload #'key "foo" nil t))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(bind-keys* :package foo ("C-k" . key)))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:bind-keymap-1 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :bind-keymap ("C-k" . key))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
`(bind-key "C-k"
|
|
|
|
|
#'(lambda nil
|
|
|
|
|
(interactive)
|
|
|
|
|
(use-package-autoload-keymap 'key 'foo nil)))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:bind-keymap*-1 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :bind-keymap* ("C-k" . key))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
`(bind-key* "C-k"
|
|
|
|
|
#'(lambda ()
|
|
|
|
|
(interactive)
|
|
|
|
|
(use-package-autoload-keymap 'key 'foo t)))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:interpreter-1 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :interpreter "interp")
|
|
|
|
|
`(progn
|
|
|
|
|
(unless (fboundp 'foo)
|
2017-12-03 23:05:43 -08:00
|
|
|
|
(autoload #'foo "foo" nil t))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(add-to-list 'interpreter-mode-alist '("interp" . foo)))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:interpreter-2 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :interpreter ("interp" . fun))
|
|
|
|
|
`(progn
|
|
|
|
|
(unless (fboundp 'fun)
|
2017-12-03 23:05:43 -08:00
|
|
|
|
(autoload #'fun "foo" nil t))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(add-to-list 'interpreter-mode-alist '("interp" . fun)))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
|
|
|
|
(ert-deftest use-package-test-normalize/:mode ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(flet ((norm (&rest args)
|
|
|
|
|
(apply #'use-package-normalize/:mode
|
|
|
|
|
'foopkg :mode args)))
|
|
|
|
|
(should (equal (norm '(".foo"))
|
|
|
|
|
'((".foo" . foopkg))))
|
|
|
|
|
(should (equal (norm '(".foo" ".bar"))
|
|
|
|
|
'((".foo" . foopkg) (".bar" . foopkg))))
|
|
|
|
|
(should (equal (norm '((".foo" ".bar")))
|
|
|
|
|
'((".foo" . foopkg) (".bar" . foopkg))))
|
|
|
|
|
(should (equal (norm '((".foo")))
|
|
|
|
|
'((".foo" . foopkg))))
|
|
|
|
|
(should (equal (norm '((".foo" . foo) (".bar" . bar)))
|
|
|
|
|
'((".foo" . foo) (".bar" . bar))))))
|
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:mode-1 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :mode "interp")
|
|
|
|
|
`(progn
|
|
|
|
|
(unless (fboundp 'foo)
|
2017-12-03 23:05:43 -08:00
|
|
|
|
(autoload #'foo "foo" nil t))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(add-to-list 'auto-mode-alist '("interp" . foo)))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:mode-2 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :mode ("interp" . fun))
|
|
|
|
|
`(progn
|
|
|
|
|
(unless (fboundp 'fun)
|
2017-12-03 23:05:43 -08:00
|
|
|
|
(autoload #'fun "foo" nil t))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(add-to-list 'auto-mode-alist '("interp" . fun)))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:magic-1 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :magic "interp")
|
|
|
|
|
`(progn
|
|
|
|
|
(unless (fboundp 'foo)
|
2017-12-03 23:05:43 -08:00
|
|
|
|
(autoload #'foo "foo" nil t))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(add-to-list 'magic-mode-alist '("interp" . foo)))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:magic-2 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :magic ("interp" . fun))
|
|
|
|
|
`(progn
|
|
|
|
|
(unless (fboundp 'fun)
|
2017-12-03 23:05:43 -08:00
|
|
|
|
(autoload #'fun "foo" nil t))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(add-to-list 'magic-mode-alist '("interp" . fun)))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:magic-fallback-1 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :magic-fallback "interp")
|
|
|
|
|
`(progn
|
|
|
|
|
(unless (fboundp 'foo)
|
2017-12-03 23:05:43 -08:00
|
|
|
|
(autoload #'foo "foo" nil t))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(add-to-list 'magic-fallback-mode-alist '("interp" . foo)))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:magic-fallback-2 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :magic-fallback ("interp" . fun))
|
|
|
|
|
`(progn
|
|
|
|
|
(unless (fboundp 'fun)
|
2017-12-03 23:05:43 -08:00
|
|
|
|
(autoload #'fun "foo" nil t))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(add-to-list 'magic-fallback-mode-alist '("interp" . fun)))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:commands-1 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :commands bar)
|
2017-12-03 03:07:30 -08:00
|
|
|
|
`(unless (fboundp 'bar)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(autoload #'bar "foo" nil t))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:commands-2 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :commands (bar quux))
|
|
|
|
|
`(progn
|
|
|
|
|
(unless (fboundp 'bar)
|
|
|
|
|
(autoload #'bar "foo" nil t))
|
|
|
|
|
(unless (fboundp 'quux)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(autoload #'quux "foo" nil t)))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:commands-3 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(let ((byte-compile-current-file t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :commands (bar quux))
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(with-demoted-errors "Cannot load foo: %S" nil
|
|
|
|
|
(load "foo" nil t))))
|
|
|
|
|
(unless (fboundp 'bar)
|
|
|
|
|
(autoload #'bar "foo" nil t))
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(declare-function bar "foo"))
|
|
|
|
|
(unless (fboundp 'quux)
|
|
|
|
|
(autoload #'quux "foo" nil t))
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(declare-function quux "foo"))))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
2017-12-04 09:03:13 -08:00
|
|
|
|
(ert-deftest use-package-test/:commands-4 ()
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :commands bar :init (bar))
|
|
|
|
|
`(progn
|
|
|
|
|
(unless
|
|
|
|
|
(fboundp 'bar)
|
|
|
|
|
(autoload #'bar "foo" nil t))
|
|
|
|
|
(bar))))
|
|
|
|
|
|
2017-12-05 15:47:41 -08:00
|
|
|
|
(ert-deftest use-package-test/:commands-5 ()
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package gnus-harvest
|
|
|
|
|
:load-path "foo"
|
|
|
|
|
:commands gnus-harvest-install
|
|
|
|
|
:demand t
|
|
|
|
|
:config
|
|
|
|
|
(if (featurep 'message-x)
|
|
|
|
|
(gnus-harvest-install 'message-x)
|
|
|
|
|
(gnus-harvest-install)))
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(add-to-list 'load-path ,(pred stringp)))
|
|
|
|
|
(require 'gnus-harvest nil nil)
|
|
|
|
|
(if (featurep 'message-x)
|
|
|
|
|
(gnus-harvest-install 'message-x)
|
|
|
|
|
(gnus-harvest-install))
|
|
|
|
|
t)))
|
|
|
|
|
|
|
|
|
|
(ert-deftest use-package-test/:commands-6 ()
|
|
|
|
|
(let ((byte-compile-current-file t))
|
2017-12-05 14:36:56 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package gnus-harvest
|
2017-12-05 15:47:41 -08:00
|
|
|
|
:load-path "foo"
|
2017-12-05 14:36:56 -08:00
|
|
|
|
:commands gnus-harvest-install
|
|
|
|
|
:demand t
|
|
|
|
|
:config
|
|
|
|
|
(if (featurep 'message-x)
|
|
|
|
|
(gnus-harvest-install 'message-x)
|
|
|
|
|
(gnus-harvest-install)))
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
2017-12-05 15:47:41 -08:00
|
|
|
|
(add-to-list 'load-path ,(pred stringp)))
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(with-demoted-errors "Cannot load gnus-harvest: %S" nil
|
|
|
|
|
(load "gnus-harvest" nil t))))
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(declare-function gnus-harvest-install "gnus-harvest"))
|
2017-12-05 14:36:56 -08:00
|
|
|
|
(require 'gnus-harvest nil nil)
|
2017-12-05 15:47:41 -08:00
|
|
|
|
(if
|
|
|
|
|
(featurep 'message-x)
|
2017-12-05 14:36:56 -08:00
|
|
|
|
(gnus-harvest-install 'message-x)
|
|
|
|
|
(gnus-harvest-install))
|
2017-12-05 15:47:41 -08:00
|
|
|
|
t))))
|
2017-12-04 11:05:11 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:defines-1 ()
|
2017-12-01 01:33:01 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :defines bar)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
`(require 'foo nil nil)))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:defines-2 ()
|
2017-12-01 01:33:01 -08:00
|
|
|
|
(let ((byte-compile-current-file t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :defines bar)
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(defvar bar)
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(with-demoted-errors
|
|
|
|
|
"Cannot load foo: %S" nil
|
|
|
|
|
(load "foo" nil t))))
|
2017-12-01 13:38:41 -08:00
|
|
|
|
(require 'foo nil nil)))))
|
2017-12-01 01:33:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:functions-1 ()
|
2017-12-01 01:33:01 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :functions bar)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
`(require 'foo nil nil)))
|
2017-12-01 01:33:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:functions-2 ()
|
2017-12-01 01:33:01 -08:00
|
|
|
|
(let ((byte-compile-current-file t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :functions bar)
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(declare-function bar "foo")
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(with-demoted-errors
|
|
|
|
|
"Cannot load foo: %S" nil
|
|
|
|
|
(load "foo" nil t))))
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil)))))
|
2017-12-01 01:33:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:functions-3 ()
|
2017-12-01 01:33:01 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :defer t :functions bar)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
`nil))
|
2017-12-01 01:33:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:functions-4 ()
|
2017-12-01 10:23:06 -08:00
|
|
|
|
(let ((byte-compile-current-file t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :defer t :functions bar)
|
2017-12-03 03:07:30 -08:00
|
|
|
|
`(eval-and-compile
|
|
|
|
|
(declare-function bar "foo")
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(with-demoted-errors "Cannot load foo: %S" nil
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(load "foo" nil t)))))))
|
2017-12-01 01:33:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:functions-5 ()
|
2017-12-01 01:33:01 -08:00
|
|
|
|
(let ((byte-compile-current-file t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :defer t :config (config) :functions bar)
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(declare-function bar "foo")
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(with-demoted-errors
|
|
|
|
|
"Cannot load foo: %S" nil
|
|
|
|
|
(load "foo" nil t))))
|
|
|
|
|
(eval-after-load 'foo
|
|
|
|
|
'(progn
|
|
|
|
|
(config)
|
|
|
|
|
t))))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:defer-1 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
`(require 'foo nil nil)))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:defer-2 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(let ((byte-compile-current-file t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo)
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(with-demoted-errors "Cannot load foo: %S" nil
|
|
|
|
|
(load "foo" nil t))))
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil)))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:defer-3 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :defer t)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
`nil))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:defer-4 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(let ((byte-compile-current-file t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :defer t)
|
2017-12-03 03:07:30 -08:00
|
|
|
|
`(eval-and-compile
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(with-demoted-errors "Cannot load foo: %S" nil
|
|
|
|
|
(load "foo" nil t)))))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
2017-11-30 10:38:01 -08:00
|
|
|
|
(ert-deftest use-package-test-normalize/:hook ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(flet ((norm (&rest args)
|
|
|
|
|
(apply #'use-package-normalize/:hook
|
|
|
|
|
'foopkg :hook args)))
|
|
|
|
|
(should-error (norm nil))
|
|
|
|
|
(should (equal (norm '(bar))
|
|
|
|
|
'((bar . foopkg))))
|
|
|
|
|
(should (equal (norm '((bar . baz)))
|
|
|
|
|
'((bar . baz))))
|
|
|
|
|
(should (equal (norm '(((bar baz) . quux)))
|
|
|
|
|
'(((bar baz) . quux))))
|
|
|
|
|
(should (equal (norm '(bar baz))
|
|
|
|
|
'(((bar baz) . foopkg))))
|
|
|
|
|
(should (equal (norm '((bar baz) (quux bow)))
|
|
|
|
|
'(((bar baz) . foopkg) ((quux bow) . foopkg))))
|
|
|
|
|
(should (equal (norm '((bar . baz) (quux . bow)))
|
|
|
|
|
'((bar . baz) (quux . bow))))
|
|
|
|
|
(should (equal (norm '(((bar1 bar2) . baz) ((quux1 quux2) . bow)))
|
|
|
|
|
'(((bar1 bar2) . baz) ((quux1 quux2) . bow))))))
|
2017-11-30 10:38:01 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:hook-1 ()
|
2017-12-01 01:33:01 -08:00
|
|
|
|
(let ((byte-compile-current-file t))
|
2017-12-07 13:14:32 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo
|
|
|
|
|
:bind (("C-a" . key))
|
|
|
|
|
:hook (hook . fun))
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(with-demoted-errors
|
|
|
|
|
"Cannot load foo: %S" nil
|
|
|
|
|
(load "foo" nil t))))
|
|
|
|
|
(unless
|
|
|
|
|
(fboundp 'key)
|
|
|
|
|
(autoload #'key "foo" nil t))
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(declare-function key "foo"))
|
|
|
|
|
(unless
|
|
|
|
|
(fboundp 'fun)
|
|
|
|
|
(autoload #'fun "foo" nil t))
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(declare-function fun "foo"))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(add-hook 'hook-hook #'fun)
|
|
|
|
|
(bind-keys :package foo ("C-a" . key))))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
2017-12-04 12:04:20 -08:00
|
|
|
|
(ert-deftest use-package-test/:hook-2 ()
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo
|
|
|
|
|
:hook (hook . fun))
|
|
|
|
|
`(progn
|
|
|
|
|
(unless (fboundp 'fun)
|
|
|
|
|
(autoload #'fun "foo" nil t))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(add-hook 'hook-hook #'fun))))
|
2017-12-04 12:04:20 -08:00
|
|
|
|
|
|
|
|
|
(ert-deftest use-package-test/:hook-3 ()
|
|
|
|
|
(let ((use-package-hook-name-suffix nil))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo
|
|
|
|
|
:hook (hook . fun))
|
|
|
|
|
`(progn
|
|
|
|
|
(unless (fboundp 'fun)
|
|
|
|
|
(autoload #'fun "foo" nil t))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(add-hook 'hook #'fun)))))
|
2017-12-04 12:04:20 -08:00
|
|
|
|
|
|
|
|
|
(ert-deftest use-package-test/:hook-4 ()
|
|
|
|
|
(let ((use-package-hook-name-suffix "-special"))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo
|
|
|
|
|
:hook (hook . fun))
|
|
|
|
|
`(progn
|
|
|
|
|
(unless (fboundp 'fun)
|
|
|
|
|
(autoload #'fun "foo" nil t))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(add-hook 'hook-special #'fun)))))
|
2017-12-04 12:04:20 -08:00
|
|
|
|
|
2017-12-05 15:47:53 -08:00
|
|
|
|
(ert-deftest use-package-test/:hook-5 ()
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package erefactor
|
|
|
|
|
:load-path "foo"
|
|
|
|
|
:after elisp-mode
|
|
|
|
|
:load t
|
|
|
|
|
:hook (emacs-lisp-mode
|
|
|
|
|
. (lambda ()
|
|
|
|
|
(bind-key "\C-c\C-v" erefactor-map emacs-lisp-mode-map))))
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(add-to-list 'load-path ,(pred stringp)))
|
|
|
|
|
(eval-after-load 'elisp-mode
|
|
|
|
|
'(progn
|
|
|
|
|
(require 'erefactor nil nil)
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(add-hook
|
|
|
|
|
'emacs-lisp-mode-hook
|
|
|
|
|
#'(lambda nil
|
|
|
|
|
(bind-key "" erefactor-map emacs-lisp-mode-map))))))))
|
2017-12-05 15:47:53 -08:00
|
|
|
|
|
2017-12-07 13:14:32 -08:00
|
|
|
|
(ert-deftest use-package-test/:hook-6 ()
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package erefactor
|
|
|
|
|
:load-path "foo"
|
|
|
|
|
:after elisp-mode
|
|
|
|
|
:hook (emacs-lisp-mode . function))
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
2017-12-07 13:23:36 -08:00
|
|
|
|
(add-to-list 'load-path ,(pred stringp)))
|
2017-12-07 13:14:32 -08:00
|
|
|
|
(eval-after-load 'elisp-mode
|
|
|
|
|
'(progn
|
|
|
|
|
(unless (fboundp 'function)
|
|
|
|
|
(autoload #'function "erefactor" nil t))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(add-hook 'emacs-lisp-mode-hook #'function))))))
|
2017-12-07 13:14:32 -08:00
|
|
|
|
|
|
|
|
|
(ert-deftest use-package-test/:hook-7 ()
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package erefactor
|
|
|
|
|
:load-path "foo"
|
|
|
|
|
:after elisp-mode
|
|
|
|
|
:hook (emacs-lisp-mode . (lambda () (function))))
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
2017-12-07 13:23:36 -08:00
|
|
|
|
(add-to-list 'load-path ,(pred stringp)))
|
2017-12-07 13:14:32 -08:00
|
|
|
|
(eval-after-load 'elisp-mode
|
|
|
|
|
'(progn
|
|
|
|
|
(require 'erefactor nil nil)
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(add-hook 'emacs-lisp-mode-hook #'(lambda nil (function))))))))
|
2017-12-07 13:14:32 -08:00
|
|
|
|
|
2017-11-30 10:38:01 -08:00
|
|
|
|
(ert-deftest use-package-test-normalize/:custom ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(flet ((norm (&rest args)
|
|
|
|
|
(apply #'use-package-normalize/:custom
|
|
|
|
|
'foopkg :custom args)))
|
|
|
|
|
(should-error (norm nil))
|
|
|
|
|
(should-error (norm '(bar)))
|
|
|
|
|
;; (should-error (norm '((foo bar baz quux))))
|
|
|
|
|
(should (equal (norm '(foo bar)) '((foo bar))))
|
|
|
|
|
;; (should-error (norm '(foo bar baz)))
|
|
|
|
|
;; (should (equal (norm '(foo bar "baz"))
|
|
|
|
|
;; '((foo bar baz))))
|
|
|
|
|
))
|
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:custom-1 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :custom (foo bar))
|
|
|
|
|
`(progn
|
|
|
|
|
(customize-set-variable 'foo bar "Customized with use-package foo")
|
2017-12-01 13:38:41 -08:00
|
|
|
|
(require 'foo nil nil))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:custom-face-1 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :custom-face (foo ((t (:background "#e4edfc")))))
|
|
|
|
|
`(progn
|
2019-05-29 16:04:35 +08:00
|
|
|
|
(custom-set-faces (backquote (foo ((t (:background "#e4edfc"))))))
|
2017-12-01 13:38:41 -08:00
|
|
|
|
(require 'foo nil nil))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:init-1 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :init (init))
|
|
|
|
|
`(progn
|
|
|
|
|
(init)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:init-2 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(let ((byte-compile-current-file t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :init (init))
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(with-demoted-errors "Cannot load foo: %S" nil
|
|
|
|
|
(load "foo" nil t))))
|
|
|
|
|
(init)
|
2017-12-01 13:38:41 -08:00
|
|
|
|
(require 'foo nil nil)))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
2017-12-04 11:00:05 -08:00
|
|
|
|
(ert-deftest use-package-test/:catch-1 ()
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :catch t)
|
2017-12-05 11:10:16 -08:00
|
|
|
|
`(progn
|
|
|
|
|
(defvar ,_
|
2017-12-06 05:50:16 +00:00
|
|
|
|
#'(lambda (keyword err)
|
|
|
|
|
(let ((msg (format "%s/%s: %s" 'foo keyword
|
|
|
|
|
(error-message-string err))))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(display-warning 'use-package msg :error))))
|
2017-12-04 11:00:05 -08:00
|
|
|
|
(condition-case-unless-debug err
|
|
|
|
|
(require 'foo nil nil)
|
|
|
|
|
(error
|
|
|
|
|
(funcall ,_ :catch err))))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest use-package-test/:catch-2 ()
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :catch nil)
|
|
|
|
|
`(require 'foo nil nil)))
|
|
|
|
|
|
|
|
|
|
(ert-deftest use-package-test/:catch-3 ()
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :catch (lambda (keyword error)))
|
2017-12-05 11:10:16 -08:00
|
|
|
|
`(progn
|
|
|
|
|
(defvar ,_ (lambda (keyword error)))
|
2017-12-04 11:00:05 -08:00
|
|
|
|
(condition-case-unless-debug err
|
|
|
|
|
(require 'foo nil nil)
|
|
|
|
|
(error
|
|
|
|
|
(funcall ,_ :catch err))))))
|
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:after-1 ()
|
2017-11-30 12:38:01 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :after bar)
|
2017-12-03 03:07:30 -08:00
|
|
|
|
`(eval-after-load 'bar
|
2017-12-03 10:49:33 -08:00
|
|
|
|
'(require 'foo nil nil))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:after-2 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(let ((byte-compile-current-file t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :after bar)
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(with-demoted-errors "Cannot load foo: %S" nil
|
|
|
|
|
(load "foo" nil t))))
|
|
|
|
|
(eval-after-load 'bar
|
2017-12-03 10:49:33 -08:00
|
|
|
|
'(require 'foo nil nil))))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:after-3 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :after (bar quux))
|
2017-12-03 03:07:30 -08:00
|
|
|
|
`(eval-after-load 'quux
|
|
|
|
|
'(eval-after-load 'bar
|
2017-12-03 10:49:33 -08:00
|
|
|
|
'(require 'foo nil nil)))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:after-4 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :after (:all bar quux))
|
2017-12-03 03:07:30 -08:00
|
|
|
|
`(eval-after-load 'quux
|
|
|
|
|
'(eval-after-load 'bar
|
2017-12-03 10:49:33 -08:00
|
|
|
|
'(require 'foo nil nil)))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:after-5 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :after (:any bar quux))
|
2017-12-06 20:59:10 -08:00
|
|
|
|
`(progn
|
|
|
|
|
(defvar ,_ nil)
|
|
|
|
|
(defvar ,_ nil)
|
|
|
|
|
(defvar ,_
|
|
|
|
|
#'(lambda nil
|
|
|
|
|
(if ,_ ,_
|
|
|
|
|
(setq ,_ t ,_
|
|
|
|
|
(require 'foo nil nil)))))
|
2017-12-06 05:50:16 +00:00
|
|
|
|
(eval-after-load 'bar
|
2017-12-06 20:59:10 -08:00
|
|
|
|
'(funcall ,_))
|
2017-12-06 05:50:16 +00:00
|
|
|
|
(eval-after-load 'quux
|
2017-12-06 20:59:10 -08:00
|
|
|
|
'(funcall ,_)))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:after-6 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :after (:all (:any bar quux) bow))
|
2017-12-06 20:59:10 -08:00
|
|
|
|
`(progn
|
|
|
|
|
(defvar ,_ nil)
|
|
|
|
|
(defvar ,_ nil)
|
|
|
|
|
(defvar ,_
|
|
|
|
|
#'(lambda nil
|
|
|
|
|
(if ,_ ,_
|
|
|
|
|
(setq ,_ t ,_
|
|
|
|
|
(require 'foo nil nil)))))
|
2017-12-05 11:10:16 -08:00
|
|
|
|
(eval-after-load 'bow
|
|
|
|
|
'(progn
|
|
|
|
|
(eval-after-load 'bar
|
2017-12-06 20:59:10 -08:00
|
|
|
|
'(funcall ,_))
|
2017-12-05 11:10:16 -08:00
|
|
|
|
(eval-after-load 'quux
|
2017-12-06 20:59:10 -08:00
|
|
|
|
'(funcall ,_)))))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:after-7 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :after (:any (:all bar quux) bow))
|
2017-12-06 20:59:10 -08:00
|
|
|
|
`(progn
|
|
|
|
|
(defvar ,_ nil)
|
|
|
|
|
(defvar ,_ nil)
|
|
|
|
|
(defvar ,_
|
|
|
|
|
#'(lambda nil
|
|
|
|
|
(if ,_ ,_
|
|
|
|
|
(setq ,_ t ,_
|
|
|
|
|
(require 'foo nil nil)))))
|
2017-12-06 05:50:16 +00:00
|
|
|
|
(eval-after-load 'quux
|
|
|
|
|
'(eval-after-load 'bar
|
2017-12-06 20:59:10 -08:00
|
|
|
|
'(funcall ,_)))
|
2017-12-06 05:50:16 +00:00
|
|
|
|
(eval-after-load 'bow
|
2017-12-06 20:59:10 -08:00
|
|
|
|
'(funcall ,_)))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:after-8 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :after (:all (:any bar quux) (:any bow baz)))
|
2017-12-06 20:59:10 -08:00
|
|
|
|
`(progn
|
|
|
|
|
(defvar ,_ nil)
|
|
|
|
|
(defvar ,_ nil)
|
|
|
|
|
(defvar ,_
|
|
|
|
|
#'(lambda nil
|
|
|
|
|
(if ,_ ,_
|
|
|
|
|
(setq ,_ t ,_
|
|
|
|
|
(require 'foo nil nil)))))
|
2017-12-06 05:50:16 +00:00
|
|
|
|
(eval-after-load 'bow
|
|
|
|
|
'(progn
|
|
|
|
|
(eval-after-load 'bar
|
2017-12-06 20:59:10 -08:00
|
|
|
|
'(funcall ,_))
|
2017-12-06 05:50:16 +00:00
|
|
|
|
(eval-after-load 'quux
|
2017-12-06 20:59:10 -08:00
|
|
|
|
'(funcall ,_))))
|
2017-12-06 05:50:16 +00:00
|
|
|
|
(eval-after-load 'baz
|
|
|
|
|
'(progn
|
|
|
|
|
(eval-after-load 'bar
|
2017-12-06 20:59:10 -08:00
|
|
|
|
'(funcall ,_))
|
2017-12-06 05:50:16 +00:00
|
|
|
|
(eval-after-load 'quux
|
2017-12-06 20:59:10 -08:00
|
|
|
|
'(funcall ,_)))))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:after-9 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :after (:any (:all bar quux) (:all bow baz)))
|
2017-12-06 20:59:10 -08:00
|
|
|
|
`(progn
|
|
|
|
|
(defvar ,_ nil)
|
|
|
|
|
(defvar ,_ nil)
|
|
|
|
|
(defvar ,_
|
|
|
|
|
#'(lambda nil
|
|
|
|
|
(if ,_ ,_
|
|
|
|
|
(setq ,_ t ,_
|
|
|
|
|
(require 'foo nil nil)))))
|
2017-12-06 05:50:16 +00:00
|
|
|
|
(eval-after-load 'quux
|
|
|
|
|
'(eval-after-load 'bar
|
2017-12-06 20:59:10 -08:00
|
|
|
|
'(funcall ,_)))
|
2017-12-06 05:50:16 +00:00
|
|
|
|
(eval-after-load 'baz
|
|
|
|
|
'(eval-after-load 'bow
|
2017-12-06 20:59:10 -08:00
|
|
|
|
'(funcall ,_))))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:after-10 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :after (:any (:all bar quux) (:any bow baz)))
|
2017-12-06 20:59:10 -08:00
|
|
|
|
`(progn
|
|
|
|
|
(defvar ,_ nil)
|
|
|
|
|
(defvar ,_ nil)
|
|
|
|
|
(defvar ,_
|
|
|
|
|
#'(lambda nil
|
|
|
|
|
(if ,_ ,_
|
|
|
|
|
(setq ,_ t ,_
|
|
|
|
|
(require 'foo nil nil)))))
|
2017-12-06 05:50:16 +00:00
|
|
|
|
(eval-after-load 'quux
|
|
|
|
|
'(eval-after-load 'bar
|
2017-12-06 20:59:10 -08:00
|
|
|
|
'(funcall ,_)))
|
2017-12-06 05:50:16 +00:00
|
|
|
|
(eval-after-load 'bow
|
2017-12-06 20:59:10 -08:00
|
|
|
|
'(funcall ,_))
|
2017-12-06 05:50:16 +00:00
|
|
|
|
(eval-after-load 'baz
|
2017-12-06 20:59:10 -08:00
|
|
|
|
'(funcall ,_)))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:demand-1 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :demand t)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
`(require 'foo nil nil)))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:demand-2 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(let ((byte-compile-current-file t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :demand t)
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(with-demoted-errors "Cannot load foo: %S" nil
|
|
|
|
|
(load "foo" nil t))))
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(require 'foo nil nil)))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:demand-3 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :demand t :config (config))
|
|
|
|
|
`(progn
|
2017-12-01 13:38:41 -08:00
|
|
|
|
(require 'foo nil nil)
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(config)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
t)))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:demand-4 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(let ((byte-compile-current-file t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :demand t :config (config))
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(with-demoted-errors "Cannot load foo: %S" nil
|
|
|
|
|
(load "foo" nil t))))
|
2017-12-01 13:38:41 -08:00
|
|
|
|
(require 'foo nil nil)
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(config)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
t))))
|
2017-12-01 11:30:11 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:demand-5 ()
|
2017-12-01 11:30:11 -08:00
|
|
|
|
;; #529 - :demand should not override an explicit use of :after
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :demand t :after bar)
|
2017-12-03 03:07:30 -08:00
|
|
|
|
`(eval-after-load 'bar
|
2017-12-03 10:49:33 -08:00
|
|
|
|
'(require 'foo nil nil))))
|
2017-12-01 11:30:11 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:demand-6 ()
|
2017-12-01 11:30:11 -08:00
|
|
|
|
(let ((byte-compile-current-file t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :demand t :after bar)
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(with-demoted-errors "Cannot load foo: %S" nil
|
|
|
|
|
(load "foo" nil t))))
|
|
|
|
|
(eval-after-load 'bar
|
2017-12-03 10:49:33 -08:00
|
|
|
|
'(require 'foo nil nil))))))
|
2017-12-03 03:07:30 -08:00
|
|
|
|
|
2017-12-05 15:47:41 -08:00
|
|
|
|
(ert-deftest use-package-test/:demand-7 ()
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package counsel
|
|
|
|
|
:load-path "foo"
|
|
|
|
|
:after ivy
|
|
|
|
|
:demand t
|
|
|
|
|
:diminish
|
|
|
|
|
:bind (("C-*" . counsel-org-agenda-headlines)
|
|
|
|
|
("M-x" . counsel-M-x))
|
|
|
|
|
:commands (counsel-minibuffer-history
|
|
|
|
|
counsel-find-library
|
|
|
|
|
counsel-unicode-char)
|
|
|
|
|
:preface (preface-code)
|
|
|
|
|
:init
|
|
|
|
|
;; This is actually wrong, but it's just part of the example.
|
|
|
|
|
(define-key minibuffer-local-map (kbd "M-r")
|
|
|
|
|
'counsel-minibuffer-history))
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(add-to-list 'load-path ,(pred stringp)))
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(preface-code))
|
|
|
|
|
(eval-after-load 'ivy
|
|
|
|
|
'(progn
|
|
|
|
|
(define-key minibuffer-local-map (kbd "M-r")
|
|
|
|
|
'counsel-minibuffer-history)
|
|
|
|
|
(require 'counsel nil nil)
|
|
|
|
|
(if (fboundp 'diminish)
|
|
|
|
|
(diminish 'counsel-mode))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(bind-keys :package counsel
|
|
|
|
|
("C-*" . counsel-org-agenda-headlines)
|
|
|
|
|
("M-x" . counsel-M-x)))))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:config-1 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :config (config))
|
|
|
|
|
`(progn
|
2017-12-01 13:38:41 -08:00
|
|
|
|
(require 'foo nil nil)
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(config)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
t)))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:config-2 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(let ((byte-compile-current-file t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :config (config))
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(with-demoted-errors "Cannot load foo: %S" nil
|
|
|
|
|
(load "foo" nil t))))
|
2017-12-01 13:38:41 -08:00
|
|
|
|
(require 'foo nil nil)
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(config)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
t))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:config-3 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :defer t :config (config))
|
2017-12-03 03:07:30 -08:00
|
|
|
|
`(eval-after-load 'foo
|
|
|
|
|
'(progn
|
|
|
|
|
(config)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
t))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:config-4 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(let ((byte-compile-current-file t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :defer t :config (config))
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(with-demoted-errors "Cannot load foo: %S" nil
|
|
|
|
|
(load "foo" nil t))))
|
|
|
|
|
(eval-after-load 'foo
|
|
|
|
|
'(progn
|
|
|
|
|
(config)
|
|
|
|
|
t))))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
|
|
|
|
(ert-deftest use-package-test-normalize/:diminish ()
|
|
|
|
|
(should (equal (use-package-normalize-diminish 'foopkg :diminish nil)
|
|
|
|
|
'(foopkg-mode)))
|
|
|
|
|
(should (equal (use-package-normalize-diminish 'foopkg :diminish 'bar)
|
|
|
|
|
'(bar)))
|
|
|
|
|
(should (equal (use-package-normalize-diminish 'foopkg :diminish "bar")
|
|
|
|
|
'((foopkg-mode . "bar"))))
|
|
|
|
|
(should (equal (use-package-normalize-diminish 'foopkg :diminish 'foo-mode)
|
|
|
|
|
'(foo-mode)))
|
|
|
|
|
(should (equal (use-package-normalize-diminish 'foopkg :diminish '(foo . "bar"))
|
|
|
|
|
'((foo . "bar")))))
|
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:diminish-1 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :diminish nil)
|
|
|
|
|
`(progn
|
2017-12-01 13:38:41 -08:00
|
|
|
|
(require 'foo nil nil)
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(if (fboundp 'diminish)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(diminish 'foo-mode)))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:diminish-2 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :diminish bar)
|
|
|
|
|
`(progn
|
2017-12-01 13:38:41 -08:00
|
|
|
|
(require 'foo nil nil)
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(if (fboundp 'diminish)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(diminish 'bar)))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:diminish-3 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :diminish "bar")
|
|
|
|
|
`(progn
|
2017-12-01 13:38:41 -08:00
|
|
|
|
(require 'foo nil nil)
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(if (fboundp 'diminish)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(diminish 'foo-mode "bar")))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:diminish-4 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :diminish (foo . "bar"))
|
|
|
|
|
`(progn
|
2017-12-01 13:38:41 -08:00
|
|
|
|
(require 'foo nil nil)
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(if (fboundp 'diminish)
|
|
|
|
|
(diminish 'foo "bar")))))
|
2017-11-30 09:42:47 -08:00
|
|
|
|
|
|
|
|
|
(ert-deftest use-package-test-normalize/:delight ()
|
2017-07-02 16:20:01 +02:00
|
|
|
|
(should (equal `((foo-mode nil foo))
|
|
|
|
|
(use-package-normalize/:delight 'foo :delight nil)))
|
|
|
|
|
(should (equal `((foo-mode nil foo-mode))
|
|
|
|
|
(use-package-normalize/:delight 'foo-mode :delight nil)))
|
|
|
|
|
(should (equal `((bar-mode nil foo))
|
|
|
|
|
(use-package-normalize/:delight 'foo :delight '(bar-mode))))
|
2017-07-02 17:45:26 +02:00
|
|
|
|
(should (equal `((bar-mode nil :major))
|
|
|
|
|
(use-package-normalize/:delight 'foo :delight '((bar-mode nil :major)))))
|
2017-07-02 16:20:01 +02:00
|
|
|
|
(should (equal `((foo-mode "abc" foo))
|
|
|
|
|
(use-package-normalize/:delight 'foo :delight '("abc"))))
|
2017-07-02 17:45:26 +02:00
|
|
|
|
(should (equal `((foo-mode (:eval 1) foo))
|
2017-07-02 16:20:01 +02:00
|
|
|
|
(use-package-normalize/:delight 'foo :delight '('(:eval 1)))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(should (equal (use-package-normalize/:delight 'foo :delight '((a-mode) (b-mode " b")))
|
|
|
|
|
`((a-mode nil foo) (b-mode " b" foo))))
|
2017-11-29 16:44:11 -08:00
|
|
|
|
(should-error (use-package-normalize/:delight 'foo :delight '((:eval 1)))))
|
2017-07-02 16:20:01 +02:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:delight-1 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :delight)
|
|
|
|
|
`(progn
|
2017-12-01 13:38:41 -08:00
|
|
|
|
(require 'foo nil nil)
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(if (fboundp 'delight)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(delight '((foo-mode nil foo)))))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:delight-2 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(should-error
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :delight nil)
|
|
|
|
|
`(progn
|
2017-12-01 13:38:41 -08:00
|
|
|
|
(require 'foo nil nil)
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(if (fboundp 'diminish)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(diminish 'foo-mode))))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:delight-3 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :delight bar)
|
|
|
|
|
`(progn
|
2017-12-01 13:38:41 -08:00
|
|
|
|
(require 'foo nil nil)
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(if (fboundp 'delight)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(delight '((bar nil foo)))))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:delight-4 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :delight "bar")
|
|
|
|
|
`(progn
|
2017-12-01 13:38:41 -08:00
|
|
|
|
(require 'foo nil nil)
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(if (fboundp 'delight)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(delight '((foo-mode "bar" foo)))))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:delight-5 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(should-error
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :delight (foo . "bar"))
|
|
|
|
|
`(progn
|
2017-12-01 13:38:41 -08:00
|
|
|
|
(require 'foo nil nil)
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(if (fboundp 'diminish)
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(diminish 'foo "bar"))))))
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2017-12-03 10:49:33 -08:00
|
|
|
|
(ert-deftest use-package-test/:delight-6 ()
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package foo :delight (foo "bar"))
|
|
|
|
|
`(progn
|
2017-12-01 13:38:41 -08:00
|
|
|
|
(require 'foo nil nil)
|
2017-12-01 11:07:08 -08:00
|
|
|
|
(if (fboundp 'delight)
|
|
|
|
|
(delight '((foo "bar" foo)))))))
|
2017-11-29 14:41:12 -08:00
|
|
|
|
|
2017-12-04 15:21:41 -08:00
|
|
|
|
(ert-deftest use-package-test/334-1 ()
|
|
|
|
|
(let (foo1-map foo2-map
|
|
|
|
|
bar1-func1
|
|
|
|
|
bar1-func2
|
|
|
|
|
bar2-func1
|
|
|
|
|
bar2-func2
|
|
|
|
|
bar3-func1
|
|
|
|
|
bar3-func2
|
|
|
|
|
bar4-func1
|
|
|
|
|
bar4-func2)
|
|
|
|
|
(match-expansion
|
|
|
|
|
(bind-keys :map foo1-map
|
|
|
|
|
("Y" . foo1)
|
|
|
|
|
:prefix "y"
|
|
|
|
|
:prefix-map bar1-prefix-map
|
|
|
|
|
("y" . bar1-func1)
|
|
|
|
|
("f" . bar1-func2)
|
|
|
|
|
:prefix "y"
|
|
|
|
|
:prefix-map bar2-prefix-map
|
|
|
|
|
("y" . bar2-func1)
|
|
|
|
|
("f" . bar2-func2)
|
|
|
|
|
:map foo2-map
|
|
|
|
|
("Y" . foo2)
|
|
|
|
|
:prefix "y"
|
|
|
|
|
:prefix-map bar3-prefix-map
|
|
|
|
|
("y" . bar3-func1)
|
|
|
|
|
("f" . bar3-func2)
|
|
|
|
|
:prefix "y"
|
|
|
|
|
:prefix-map bar4-prefix-map
|
|
|
|
|
("y" . bar4-func1)
|
|
|
|
|
("f" . bar4-func2))
|
|
|
|
|
`(progn
|
|
|
|
|
(bind-key "Y" #'foo1 foo1-map nil)
|
|
|
|
|
(defvar bar1-prefix-map)
|
|
|
|
|
(define-prefix-command 'bar1-prefix-map)
|
|
|
|
|
(bind-key "y" 'bar1-prefix-map foo1-map nil)
|
|
|
|
|
(bind-key "y" #'bar1-func1 bar1-prefix-map nil)
|
|
|
|
|
(bind-key "f" #'bar1-func2 bar1-prefix-map nil)
|
|
|
|
|
(defvar bar2-prefix-map)
|
|
|
|
|
(define-prefix-command 'bar2-prefix-map)
|
|
|
|
|
(bind-key "y" 'bar2-prefix-map foo1-map nil)
|
|
|
|
|
(bind-key "y" #'bar2-func1 bar2-prefix-map nil)
|
|
|
|
|
(bind-key "f" #'bar2-func2 bar2-prefix-map nil)
|
|
|
|
|
(bind-key "Y" #'foo2 foo2-map nil)
|
|
|
|
|
(defvar bar3-prefix-map)
|
|
|
|
|
(define-prefix-command 'bar3-prefix-map)
|
|
|
|
|
(bind-key "y" 'bar3-prefix-map foo2-map nil)
|
|
|
|
|
(bind-key "y" #'bar3-func1 bar3-prefix-map nil)
|
|
|
|
|
(bind-key "f" #'bar3-func2 bar3-prefix-map nil)
|
|
|
|
|
(defvar bar4-prefix-map)
|
|
|
|
|
(define-prefix-command 'bar4-prefix-map)
|
|
|
|
|
(bind-key "y" 'bar4-prefix-map foo2-map nil)
|
|
|
|
|
(bind-key "y" #'bar4-func1 bar4-prefix-map nil)
|
|
|
|
|
(bind-key "f" #'bar4-func2 bar4-prefix-map nil)))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest use-package-test/334-2 ()
|
|
|
|
|
(let (w3m-lnum-mode-map
|
|
|
|
|
w3m-print-current-url
|
|
|
|
|
w3m-lnum-print-this-url
|
|
|
|
|
w3m-print-this-url)
|
|
|
|
|
(match-expansion
|
|
|
|
|
(bind-keys :map w3m-lnum-mode-map
|
|
|
|
|
:prefix "y"
|
|
|
|
|
:prefix-map w3m-y-prefix-map
|
|
|
|
|
("y" . w3m-print-current-url)
|
|
|
|
|
("f" . w3m-lnum-print-this-url)
|
|
|
|
|
("t" . w3m-print-this-url))
|
|
|
|
|
`(progn
|
|
|
|
|
(defvar w3m-y-prefix-map)
|
|
|
|
|
(define-prefix-command 'w3m-y-prefix-map)
|
|
|
|
|
(bind-key "y" 'w3m-y-prefix-map w3m-lnum-mode-map nil)
|
|
|
|
|
(bind-key "y" #'w3m-print-current-url w3m-y-prefix-map nil)
|
|
|
|
|
(bind-key "f" #'w3m-lnum-print-this-url w3m-y-prefix-map nil)
|
|
|
|
|
(bind-key "t" #'w3m-print-this-url w3m-y-prefix-map nil)))))
|
|
|
|
|
|
2017-12-10 21:25:37 -08:00
|
|
|
|
(ert-deftest use-package-test/482-1 ()
|
2017-12-10 09:53:13 -08:00
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package simple
|
|
|
|
|
:bind-keymap ("C-t " . my/transpose-map)
|
|
|
|
|
:bind (:map my/transpose-map
|
|
|
|
|
("w" . transpose-words)))
|
|
|
|
|
`(progn
|
|
|
|
|
(unless (fboundp 'transpose-words)
|
|
|
|
|
(autoload #'transpose-words "simple" nil t))
|
|
|
|
|
(bind-key "C-t "
|
|
|
|
|
#'(lambda nil
|
|
|
|
|
(interactive)
|
|
|
|
|
(use-package-autoload-keymap 'my/transpose-map 'simple nil)))
|
|
|
|
|
(bind-keys :package simple :map my/transpose-map
|
|
|
|
|
("w" . transpose-words)))))
|
|
|
|
|
|
2017-12-10 21:25:37 -08:00
|
|
|
|
(ert-deftest use-package-test/482-2 ()
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package simple
|
|
|
|
|
:bind (:prefix-map my/transpose-map
|
|
|
|
|
:prefix "C-t"
|
|
|
|
|
("w" . transpose-words)))
|
|
|
|
|
`(progn
|
|
|
|
|
(unless (fboundp 'transpose-words)
|
|
|
|
|
(autoload #'transpose-words "simple" nil t))
|
|
|
|
|
(bind-keys :package simple
|
|
|
|
|
:prefix-map my/transpose-map
|
|
|
|
|
:prefix "C-t"
|
|
|
|
|
("w" . transpose-words)))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest use-package-test/482-3 ()
|
|
|
|
|
(match-expansion
|
|
|
|
|
(bind-keys :package simple
|
|
|
|
|
:prefix-map my/transpose-map
|
|
|
|
|
:prefix "C-t"
|
|
|
|
|
("w" . transpose-words))
|
|
|
|
|
`(progn
|
|
|
|
|
(defvar my/transpose-map)
|
|
|
|
|
(define-prefix-command 'my/transpose-map)
|
|
|
|
|
(bind-key "C-t" 'my/transpose-map nil nil)
|
|
|
|
|
(bind-key "w" #'transpose-words my/transpose-map nil))))
|
|
|
|
|
|
2017-12-04 09:33:18 -08:00
|
|
|
|
(ert-deftest use-package-test/538 ()
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package mu4e
|
|
|
|
|
:commands (mu4e)
|
|
|
|
|
:bind (("<f9>" . mu4e))
|
|
|
|
|
:init
|
|
|
|
|
:config
|
|
|
|
|
(config))
|
|
|
|
|
`(progn
|
2017-12-04 15:39:31 -08:00
|
|
|
|
(unless (fboundp 'mu4e)
|
2017-12-04 09:33:18 -08:00
|
|
|
|
(autoload #'mu4e "mu4e" nil t))
|
|
|
|
|
(eval-after-load 'mu4e
|
2017-12-04 15:39:31 -08:00
|
|
|
|
'(progn (config) t))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(bind-keys :package mu4e ("<f9>" . mu4e)))))
|
2017-12-04 09:33:18 -08:00
|
|
|
|
|
2017-12-04 16:46:46 -08:00
|
|
|
|
(ert-deftest use-package-test/543 ()
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package hydra
|
|
|
|
|
:ensure)
|
|
|
|
|
`(progn
|
|
|
|
|
(use-package-ensure-elpa 'hydra '(t) 'nil)
|
|
|
|
|
(require 'hydra nil nil))))
|
|
|
|
|
|
2017-12-05 13:11:30 -08:00
|
|
|
|
(ert-deftest use-package-test/545 ()
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package spacemacs-theme
|
|
|
|
|
:ensure t
|
|
|
|
|
:init ; or :config
|
|
|
|
|
(load-theme 'spacemacs-dark t)
|
|
|
|
|
)
|
|
|
|
|
`(progn
|
|
|
|
|
(use-package-ensure-elpa 'spacemacs-theme '(t) 'nil)
|
|
|
|
|
(load-theme 'spacemacs-dark t)
|
|
|
|
|
(require 'spacemacs-theme nil nil))
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
(ert-deftest use-package-test/550 ()
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package company-try-hard
|
|
|
|
|
:ensure t
|
|
|
|
|
:bind
|
|
|
|
|
("C-c M-/" . company-try-hard)
|
|
|
|
|
(:map company-active-map
|
|
|
|
|
("C-c M-/" . company-try-hard)))
|
|
|
|
|
`(progn
|
|
|
|
|
(use-package-ensure-elpa 'company-try-hard
|
|
|
|
|
'(t)
|
|
|
|
|
'nil)
|
|
|
|
|
(unless
|
|
|
|
|
(fboundp 'company-try-hard)
|
|
|
|
|
(autoload #'company-try-hard "company-try-hard" nil t))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(bind-keys :package company-try-hard
|
|
|
|
|
("C-c M-/" . company-try-hard)
|
|
|
|
|
:map company-active-map
|
|
|
|
|
("C-c M-/" . company-try-hard)))))
|
2017-12-05 13:11:30 -08:00
|
|
|
|
|
2017-12-05 10:29:04 -08:00
|
|
|
|
(ert-deftest use-package-test/558 ()
|
|
|
|
|
(match-expansion
|
|
|
|
|
(bind-keys* :package org-ref
|
|
|
|
|
("C-c C-r" . org-ref-helm-insert-cite-link))
|
|
|
|
|
`(bind-key "C-c C-r" #'org-ref-helm-insert-cite-link override-global-map nil)))
|
|
|
|
|
|
2017-12-05 15:47:41 -08:00
|
|
|
|
(ert-deftest use-package-test/560 ()
|
|
|
|
|
(flet ((executable-find (name)))
|
|
|
|
|
(let (notmuch-command)
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package notmuch
|
|
|
|
|
:preface (setq-default notmuch-command (executable-find "notmuch"))
|
|
|
|
|
:if notmuch-command
|
|
|
|
|
:requires foo
|
|
|
|
|
:load-path "foo"
|
|
|
|
|
:defines var)
|
|
|
|
|
`(progn
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(add-to-list 'load-path ,(pred stringp)))
|
|
|
|
|
(when (featurep 'foo)
|
2017-12-05 14:36:56 -08:00
|
|
|
|
(eval-and-compile
|
2017-12-05 15:47:41 -08:00
|
|
|
|
(setq-default notmuch-command
|
|
|
|
|
(executable-find "notmuch")))
|
|
|
|
|
(when (symbol-value 'notmuch-command)
|
|
|
|
|
(require 'notmuch nil nil))))))))
|
2017-12-05 13:26:32 -08:00
|
|
|
|
|
2017-12-13 17:02:55 -08:00
|
|
|
|
(ert-deftest use-package-test/572-1 ()
|
2017-12-07 14:34:51 -08:00
|
|
|
|
(let ((use-package-always-defer t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package auth-password-store
|
|
|
|
|
:after auth-source
|
|
|
|
|
:init
|
|
|
|
|
(setq auth-sources '(password-store)))
|
|
|
|
|
`(eval-after-load 'auth-source
|
|
|
|
|
'(setq auth-sources '(password-store))))))
|
|
|
|
|
|
2017-12-13 17:02:55 -08:00
|
|
|
|
(ert-deftest use-package-test/572-2 ()
|
|
|
|
|
(let ((use-package-always-defer t))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package ivy-hydra :after ivy)
|
|
|
|
|
`nil)))
|
|
|
|
|
|
|
|
|
|
(ert-deftest use-package-test/572-3 ()
|
|
|
|
|
(let ((use-package-always-defer t)
|
|
|
|
|
(use-package-defaults
|
|
|
|
|
(let ((defaults (copy-alist use-package-defaults)))
|
|
|
|
|
(setcdr (assq :defer defaults)
|
|
|
|
|
'(use-package-always-defer
|
|
|
|
|
(lambda (name args)
|
|
|
|
|
(and use-package-always-defer
|
|
|
|
|
(not (plist-member args :after))
|
|
|
|
|
(not (plist-member args :defer))
|
|
|
|
|
(not (plist-member args :demand))))))
|
|
|
|
|
defaults)))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package ivy-hydra :after ivy)
|
|
|
|
|
`(eval-after-load 'ivy
|
|
|
|
|
'(require 'ivy-hydra nil nil)))))
|
|
|
|
|
|
2017-12-07 14:34:51 -08:00
|
|
|
|
(ert-deftest use-package-test/575-1 ()
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package helm
|
|
|
|
|
:defer t
|
|
|
|
|
:after (:any ido dired)
|
|
|
|
|
:config
|
|
|
|
|
(message "test. helm start"))
|
|
|
|
|
`(progn
|
|
|
|
|
(defvar ,_ nil)
|
|
|
|
|
(defvar ,_ nil)
|
|
|
|
|
(defvar ,_
|
|
|
|
|
#'(lambda nil
|
|
|
|
|
(if ,_ ,_
|
|
|
|
|
(setq ,_ t ,_
|
|
|
|
|
(eval-after-load 'helm
|
|
|
|
|
'(progn
|
|
|
|
|
(message "test. helm start")
|
|
|
|
|
t))))))
|
|
|
|
|
(eval-after-load 'ido
|
|
|
|
|
'(funcall ,_))
|
|
|
|
|
(eval-after-load 'dired
|
|
|
|
|
'(funcall ,_)))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest use-package-test/575-2 ()
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package helm
|
|
|
|
|
:defer t
|
|
|
|
|
:bind ("C-c d" . helm-mini)
|
|
|
|
|
:config
|
|
|
|
|
(message "test. helm start"))
|
|
|
|
|
`(progn
|
|
|
|
|
(unless (fboundp 'helm-mini)
|
|
|
|
|
(autoload #'helm-mini "helm" nil t))
|
|
|
|
|
(eval-after-load 'helm
|
|
|
|
|
'(progn
|
|
|
|
|
(message "test. helm start")
|
|
|
|
|
t))
|
2017-12-07 22:40:48 -08:00
|
|
|
|
(bind-keys :package helm ("C-c d" . helm-mini)))))
|
2017-12-07 14:34:51 -08:00
|
|
|
|
|
2017-12-09 16:28:49 -08:00
|
|
|
|
(ert-deftest use-package-test/585 ()
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package bug
|
|
|
|
|
:bind (:map bug-map ("C-a" . alpha))
|
|
|
|
|
:bind (("C-b" . beta)))
|
|
|
|
|
`(progn
|
|
|
|
|
(unless (fboundp 'alpha)
|
|
|
|
|
(autoload #'alpha "bug" nil t))
|
|
|
|
|
(unless (fboundp 'beta)
|
|
|
|
|
(autoload #'beta "bug" nil t))
|
|
|
|
|
(bind-keys :package bug :map bug-map
|
|
|
|
|
("C-a" . alpha))
|
|
|
|
|
(bind-keys :package bug
|
|
|
|
|
("C-b" . beta)))))
|
|
|
|
|
|
2017-12-13 17:03:05 -08:00
|
|
|
|
(ert-deftest use-package-test/589 ()
|
|
|
|
|
(let ((use-package-verbose t)
|
|
|
|
|
(use-package-expand-minimally t)
|
|
|
|
|
debug-on-error
|
|
|
|
|
warnings)
|
|
|
|
|
(flet ((display-warning (_ msg _) (push msg warnings)))
|
|
|
|
|
(progn
|
|
|
|
|
(macroexpand-1
|
|
|
|
|
'(use-package ediff :defer t (setq my-var t)))
|
|
|
|
|
(should (= (and (> (length warnings) 0)
|
|
|
|
|
(string-match ":defer wants exactly one argument"
|
|
|
|
|
(car warnings))) 44))))))
|
|
|
|
|
|
2017-12-15 22:48:42 -08:00
|
|
|
|
(ert-deftest use-package-test/591 ()
|
|
|
|
|
(let ((use-package-defaults
|
|
|
|
|
(cons '(:if (lambda (name _) `(locate-library ,name)) t)
|
|
|
|
|
use-package-defaults)))
|
|
|
|
|
(match-expansion
|
|
|
|
|
(use-package nonexistent
|
|
|
|
|
:hook lisp-mode)
|
|
|
|
|
`(when (locate-library nonexistent)
|
|
|
|
|
(unless (fboundp 'nonexistent)
|
|
|
|
|
(autoload #'nonexistent "nonexistent" nil t))
|
|
|
|
|
(add-hook 'lisp-mode-hook #'nonexistent)))))
|
|
|
|
|
|
2017-12-04 15:43:10 -08:00
|
|
|
|
(ert-deftest bind-key/:prefix-map ()
|
|
|
|
|
(match-expansion
|
|
|
|
|
(bind-keys :prefix "<f1>"
|
|
|
|
|
:prefix-map my/map)
|
|
|
|
|
`(progn
|
|
|
|
|
(defvar my/map)
|
|
|
|
|
(define-prefix-command 'my/map)
|
|
|
|
|
(bind-key "<f1>" 'my/map nil nil))))
|
|
|
|
|
|
2014-02-12 22:30:12 +01:00
|
|
|
|
;; Local Variables:
|
|
|
|
|
;; indent-tabs-mode: nil
|
2016-02-25 15:21:49 -08:00
|
|
|
|
;; no-byte-compile: t
|
|
|
|
|
;; no-update-autoloads: t
|
2014-02-12 22:30:12 +01:00
|
|
|
|
;; End:
|
2017-12-01 11:07:08 -08:00
|
|
|
|
|
2014-02-12 22:30:12 +01:00
|
|
|
|
;;; use-package-tests.el ends here
|