From 1e9f087c35019bb20b4ecfa209592c2041a9a813 Mon Sep 17 00:00:00 2001 From: brettlangdon Date: Sun, 24 Jan 2021 09:11:15 -0500 Subject: [PATCH] Squashed 'emacs.d/use-package/' changes from 2b8f8a3f..0eccc701 caa92f1d Update version to 2.4.1 4fb1f9a6 Merge pull request #846 from wyuenho/patch-1 42010472 Merge branch 'master' into patch-1 7d925367 Merge pull request #855 from tzz/custom-set-default 22fe0004 Update the documentation for :custom as per #850 0f405ac8 Fix broken test due to #850 93ec6bd4 better tests b42acfde add test for #845 26405e39 Support keymap symbol in bind-key. Fix #845 bfc5ecd6 Merge pull request #847 from wyuenho/fix-travis b9f1fe64 Merge pull request #850 from tzz/custom-set-default c697e621 use-package-core.el: use the Emacs set-default function to avoid saving :custom vars twice bc959a22 Merge branch 'master' into fix-travis 478a1611 Fix Travis git-subtree-dir: emacs.d/use-package git-subtree-split: 0eccc701e7183837ed8d37174428106f3e6c03de --- .travis.yml | 3 +- NEWS.md | 83 ++++++++++++++++++++++++++++++++++++++++++++ README.md | 8 +++-- bind-key.el | 13 ++++--- default.mk | 4 +-- use-package-core.el | 12 ++++--- use-package-tests.el | 18 +++++++++- use-package.el | 2 +- use-package.org | 4 +-- use-package.texi | 4 +-- 10 files changed, 131 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2c8f3ab..9928239 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,11 +15,12 @@ install: - tar xf emacs-bin-${EMACS_VERSION}.tar.gz -C / - export EMACS=/tmp/emacs/bin/emacs - $EMACS --version -dist: trusty +dist: bionic addons: apt: packages: - texinfo + - libgnutls30 script: - make - make test diff --git a/NEWS.md b/NEWS.md index 3b39c01..1f51696 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,88 @@ # Changes +## 2.4.1 + +This is mostly a bug-fix release: + +- Update the documentation for :custom as per #850 + +- Fix broken test due to #850 + +- better tests + +- add test for #845 + +- Support keymap symbol in bind-key. Fix #845 + +- use-package-core.el: use the Emacs set-default function to avoid saving :custom vars twice + +- Fix Travis + +- typo, should be a vector, not a bytecode object + + Solves https://github.com/jwiegley/use-package/issues/842 + +- Add special value back again, in case needed for backwards compat + + I don't know why this special value exists, but perhaps old client code uses it. + + The additional `t' in the macro expansion is accidental but not harmful I guess. + +- Even when there's no :config, run any pre/post config hooks + + i.e., following the existing docs for use-package-inject-hooks, these hooks are + run: + + use-package--foo--pre-config-hook + use-package--foo--post-config-hook + + This should make config customisations more predictable (for example, spacemacs + uses these hooks extensively to allow 'layers' to be customised). + + I got rid of the "special" default value for :config, because it doesn't seem to + be treated any differently than nil. + + Fixes #785 + +- Clarify the documentation for :after + +- add table of contents to README + +- Fix typos + + Typos found with codespell. + +- Fix typos + +- Attempt to explain omit "-hook" better + +- Update tests + +- Switch from `require' to `load' + `featurep' + +- Use `require', not `load', when byte-compiling + +- Make custom-face evaluate elisp. + + Fix #696. + +- Add a line of documentation for (use-pacakage ... :hook). + +- Fix typo in README + +- Fix documentation for defer + +- Add no-query option for pdf-tools-install + +- Fix typo in README + +- Fix all notes in README + +- Mention use-package-ensure in README + + Without requiring `use-package-ensure`, setting `use-package-always-ensure` + did not actually work for me. + ## 2.4 ### Breaking changes diff --git a/README.md b/README.md index 3f26dda..15f3d4b 100644 --- a/README.md +++ b/README.md @@ -376,8 +376,12 @@ The documentation string is not mandatory. **NOTE**: these are only for people who wish to keep customizations with their accompanying use-package declarations. Functionally, the only benefit over using `setq` in a `:config` block is that customizations might execute code -when values are assigned. If you currently use `M-x customize-option` and save -to a settings file, you do not want to use this option. +when values are assigned. + +**NOTE**: The customized values are **not** saved in the Emacs `custom-file`. +Thus you should either use the `:custom` option **or** you should use `M-x +customize-option` which will save customized values in the Emacs `custom-file`. +Do not use both. ### Customizing faces diff --git a/bind-key.el b/bind-key.el index 01e1d4d..fef2374 100644 --- a/bind-key.el +++ b/bind-key.el @@ -154,11 +154,13 @@ spelled-out keystrokes, e.g., \"C-c C-z\". See documentation of COMMAND must be an interactive function or lambda form. -KEYMAP, if present, should be a keymap and not a quoted symbol. +KEYMAP, if present, should be a keymap variable or symbol. For example: (bind-key \"M-h\" #'some-interactive-function my-mode-map) + (bind-key \"M-h\" #'some-interactive-function 'my-mode-map) + If PREDICATE is non-nil, it is a form evaluated to determine when a key should be bound. It must return non-nil in such cases. Emacs can evaluate this form at any time that it does redisplay @@ -171,10 +173,11 @@ can safely be called at any time." `(let* ((,namevar ,key-name) (,keyvar (if (vectorp ,namevar) ,namevar (read-kbd-macro ,namevar))) + (kmap (if (and ,keymap (symbolp ,keymap)) (symbol-value ,keymap) ,keymap)) (,kdescvar (cons (if (stringp ,namevar) ,namevar (key-description ,namevar)) - (quote ,keymap))) - (,bindingvar (lookup-key (or ,keymap global-map) ,keyvar))) + (if (symbolp ,keymap) ,keymap (quote ,keymap)))) + (,bindingvar (lookup-key (or kmap global-map) ,keyvar))) (let ((entry (assoc ,kdescvar personal-keybindings)) (details (list ,command (unless (numberp ,bindingvar) @@ -183,11 +186,11 @@ can safely be called at any time." (setcdr entry details) (add-to-list 'personal-keybindings (cons ,kdescvar details)))) ,(if predicate - `(define-key (or ,keymap global-map) ,keyvar + `(define-key (or kmap global-map) ,keyvar '(menu-item "" nil :filter (lambda (&optional _) (when ,predicate ,command)))) - `(define-key (or ,keymap global-map) ,keyvar ,command))))) + `(define-key (or kmap global-map) ,keyvar ,command))))) ;;;###autoload (defmacro unbind-key (key-name &optional keymap) diff --git a/default.mk b/default.mk index 5b25721..b7ef111 100644 --- a/default.mk +++ b/default.mk @@ -63,9 +63,9 @@ ELGS = ## Versions ########################################################## -VERSION = 2.4 +VERSION = 2.4.1 -USE_PACKAGE_VERSION = 2.4 +USE_PACKAGE_VERSION = 2.4.1 EMACS_VERSION = 24.3 diff --git a/use-package-core.el b/use-package-core.el index e81e229..cd5b907 100644 --- a/use-package-core.el +++ b/use-package-core.el @@ -6,7 +6,7 @@ ;; Maintainer: John Wiegley ;; Created: 17 Jun 2012 ;; Modified: 29 Nov 2017 -;; Version: 2.4 +;; Version: 2.4.1 ;; Package-Requires: ((emacs "24.3")) ;; Keywords: dotemacs startup speed config package ;; URL: https://github.com/jwiegley/use-package @@ -56,7 +56,7 @@ "A use-package declaration for simplifying your `.emacs'." :group 'startup) -(defconst use-package-version "2.4" +(defconst use-package-version "2.4.1" "This version of use-package.") (defcustom use-package-keywords @@ -1394,7 +1394,9 @@ no keyword implies `:all'." (comment (nth 2 def))) (unless (and comment (stringp comment)) (setq comment (format "Customized with use-package %s" name))) - `(customize-set-variable (quote ,variable) ,value ,comment))) + `(funcall (or (get (quote ,variable) 'custom-set) #'set-default) + (quote ,variable) + ,value))) args) (use-package-process-keywords name rest state))) @@ -1561,7 +1563,9 @@ this file. Usage: :load-path Add to the `load-path' before attempting to load the package. :diminish Support for diminish.el (if installed). :delight Support for delight.el (if installed). -:custom Call `customize-set-variable' with each variable definition. +:custom Call `custom-set' or `set-default' with each variable + definition without modifying the Emacs `custom-file'. + (compare with `custom-set-variables'). :custom-face Call `customize-set-faces' with each face definition. :ensure Loads the package using package.el if necessary. :pin Pin the package to an archive." diff --git a/use-package-tests.el b/use-package-tests.el index 6143818..42bf074 100644 --- a/use-package-tests.el +++ b/use-package-tests.el @@ -1133,7 +1133,11 @@ (match-expansion (use-package foo :custom (foo bar)) `(progn - (customize-set-variable 'foo bar "Customized with use-package foo") + (funcall + (or + (get 'foo 'custom-set) + (function set-default)) + 'foo bar) (require 'foo nil nil)))) (ert-deftest use-package-test/:custom-face-1 () @@ -1936,6 +1940,18 @@ (define-prefix-command 'my/map) (bind-key "" 'my/map nil nil)))) + +(ert-deftest bind-key/845 () + (defvar test-map (make-keymap)) + (bind-key "" 'ignore 'test-map) + (should (eq (lookup-key test-map (kbd "")) 'ignore)) + (let ((binding (cl-find "" personal-keybindings :test 'string= :key 'caar))) + (message "test-map %s" test-map) + (message "binding %s" binding) + (should (eq (cdar binding) 'test-map)) + (should (eq (nth 1 binding) 'ignore)) + (should (eq (nth 2 binding) nil)))) + ;; Local Variables: ;; indent-tabs-mode: nil ;; no-byte-compile: t diff --git a/use-package.el b/use-package.el index 1a8fff8..0e194d5 100644 --- a/use-package.el +++ b/use-package.el @@ -6,7 +6,7 @@ ;; Maintainer: John Wiegley ;; Created: 17 Jun 2012 ;; Modified: 29 Nov 2017 -;; Version: 2.4 +;; Version: 2.4.1 ;; Package-Requires: ((emacs "24.3") (bind-key "2.4")) ;; Keywords: dotemacs startup speed config package ;; URL: https://github.com/jwiegley/use-package diff --git a/use-package.org b/use-package.org index cff3ccc..5e5c0b6 100644 --- a/use-package.org +++ b/use-package.org @@ -11,7 +11,7 @@ #+TEXINFO_DIR_CATEGORY: Emacs #+TEXINFO_DIR_TITLE: use-package: (use-package). #+TEXINFO_DIR_DESC: Declarative package configuration for Emacs. -#+SUBTITLE: for version 2.4 +#+SUBTITLE: for version 2.4.1 #+TEXINFO_DEFFN: t #+OPTIONS: H:4 num:3 toc:2 creator:t @@ -171,7 +171,7 @@ doing so, to make sure you are not using an outdated value for ~load-path~. should display something like #+BEGIN_EXAMPLE - use-package-version’s value is "2.4" + use-package-version’s value is "2.4.1" #+END_EXAMPLE If you are completely new to use-package then see {{{link-jump(Getting diff --git a/use-package.texi b/use-package.texi index 63ed295..cad42bd 100644 --- a/use-package.texi +++ b/use-package.texi @@ -30,7 +30,7 @@ General Public License for more details. @finalout @titlepage @title use-package User Manual -@subtitle for version 2.4 +@subtitle for version 2.4.1 @author John Wiegley @page @vskip 0pt plus 1filll @@ -262,7 +262,7 @@ C-h v use-package-version RET should display something like @example -use-package-version’s value is "2.4" +use-package-version’s value is "2.4.1" @end example If you are completely new to use-package then see @ref{Getting Started}.