Skip to content

Commit ff8c572

Browse files
committed
Merge code changes from emacs.git
1 parent ff2b0fd commit ff8c572

11 files changed

+153
-90
lines changed

bind-key.el

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,29 @@
1010
;; Keywords: keys keybinding config dotemacs extensions
1111
;; URL: https://github.com/jwiegley/use-package
1212

13-
;; This program is free software; you can redistribute it and/or modify
13+
;; This file is part of GNU Emacs.
14+
15+
;; GNU Emacs is free software: you can redistribute it and/or modify
1416
;; it under the terms of the GNU General Public License as published by
1517
;; the Free Software Foundation, either version 3 of the License, or
1618
;; (at your option) any later version.
1719

18-
;; This program is distributed in the hope that it will be useful,
20+
;; GNU Emacs is distributed in the hope that it will be useful,
1921
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
2022
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2123
;; GNU General Public License for more details.
2224

2325
;; You should have received a copy of the GNU General Public License
24-
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
26+
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
2527

2628
;;; Commentary:
2729

28-
;; If you have lots of keybindings set in your .emacs file, it can be hard to
29-
;; know which ones you haven't set yet, and which may now be overriding some
30-
;; new default in a new Emacs version. This module aims to solve that
31-
;; problem.
32-
;;
33-
;; Bind keys as follows in your .emacs:
30+
;; If you have lots of keybindings set in your init file, it can be
31+
;; hard to know which ones you haven't set yet, and which may now be
32+
;; overriding some new default in a new Emacs version. This module
33+
;; aims to solve that problem.
3434
;;
35-
;; (require 'bind-key)
35+
;; Bind keys as follows in your init file:
3636
;;
3737
;; (bind-key "C-c x" 'my-ctrl-c-x-command)
3838
;;
@@ -95,6 +95,8 @@
9595
;; This display will tell you if you've overridden a default keybinding, and
9696
;; what the default was. Also, it will tell you if the key was rebound after
9797
;; your binding it with `bind-key', and what it was rebound it to.
98+
;;
99+
;; See the `use-package' info manual for more information.
98100

99101
;;; Code:
100102

@@ -103,7 +105,10 @@
103105

104106
(defgroup bind-key nil
105107
"A simple way to manage personal keybindings."
106-
:group 'emacs)
108+
:group 'keyboard
109+
:group 'convenience
110+
:link '(emacs-commentary-link :tag "Commentary" "bind-key.el")
111+
:version "29.1")
107112

108113
(defcustom bind-key-column-widths '(18 . 40)
109114
"Width of columns in `describe-personal-keybindings'."
@@ -112,8 +117,7 @@
112117

113118
(defcustom bind-key-segregation-regexp
114119
"\\`\\(\\(C-[chx] \\|M-[gso] \\)\\([CM]-\\)?\\|.+-\\)"
115-
"Regular expression used to divide key sets in the output from
116-
\\[describe-personal-keybindings]."
120+
"Regexp used by \\[describe-personal-keybindings] to divide key sets."
117121
:type 'regexp
118122
:group 'bind-key)
119123

@@ -128,7 +132,18 @@
128132
"Keymap for `override-global-mode'.")
129133

130134
(define-minor-mode override-global-mode
131-
"A minor mode so that keymap settings override other modes."
135+
"A minor mode for allowing keybindings to override other modes.
136+
The main purpose of this mode is to simplify bindings keys in
137+
such a way that they take precedence over other modes.
138+
139+
To achieve this, the keymap `override-global-map' is added to
140+
`emulation-mode-map-alists', which makes it take precedence over
141+
keymaps in `minor-mode-map-alist'. Thereby, key bindings get an
142+
even higher precedence than global key bindings defined with
143+
`keymap-global-set' (or, in Emacs 28 or older, `global-set-key').
144+
145+
The macro `bind-key*' (which see) provides a convenient way to
146+
add keys to that keymap."
132147
:init-value t
133148
:lighter "")
134149

@@ -147,9 +162,9 @@ Elements have the form ((KEY . [MAP]) CMD ORIGINAL-CMD)")
147162
"Bind KEY-NAME to COMMAND in KEYMAP (`global-map' if not passed).
148163
149164
KEY-NAME may be a vector, in which case it is passed straight to
150-
`define-key'. Or it may be a string to be interpreted as
151-
spelled-out keystrokes, e.g., `C-c C-z'. See documentation of
152-
`edmacro-mode' for details.
165+
`define-key'. Or it may be a string to be interpreted as
166+
spelled-out keystrokes, e.g., \"C-c C-z\". See the documentation
167+
of `edmacro-mode' for details.
153168
154169
COMMAND must be an interactive function or lambda form.
155170
@@ -425,6 +440,11 @@ function symbol (unquoted)."
425440

426441
;;;###autoload
427442
(defmacro bind-keys* (&rest args)
443+
"Bind multiple keys at once, in `override-global-map'.
444+
Accepts the same keyword arguments as `bind-keys' (which see).
445+
446+
This binds keys in such a way that bindings are not overridden by
447+
other modes. See `override-global-mode'."
428448
(macroexp-progn (bind-keys-form args 'override-global-map)))
429449

430450
(defun get-binding-description (elem)

use-package-bind-key.el

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,31 @@
55
;; Author: John Wiegley <[email protected]>
66
;; Maintainer: John Wiegley <[email protected]>
77

8-
;; This program is free software; you can redistribute it and/or modify
8+
;; This file is part of GNU Emacs.
9+
10+
;; GNU Emacs is free software: you can redistribute it and/or modify
911
;; it under the terms of the GNU General Public License as published by
1012
;; the Free Software Foundation, either version 3 of the License, or
1113
;; (at your option) any later version.
1214

13-
;; This program is distributed in the hope that it will be useful,
15+
;; GNU Emacs is distributed in the hope that it will be useful,
1416
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
1517
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1618
;; GNU General Public License for more details.
1719

1820
;; You should have received a copy of the GNU General Public License
19-
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
21+
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
2022

2123
;;; Commentary:
2224

2325
;; Provides support for the :bind, :bind*, :bind-keymap and :bind-keymap*
2426
;; keywords. Note that these are currently still baked into
2527
;; `use-package-keywords' and `use-package-deferring-keywords', although this
2628
;; is harmless if they are never used.
29+
;;
30+
;; These keywords are made available by default by requiring `use-package'.
31+
;;
32+
;; See the `use-package' info manual for more information.
2733

2834
;;; Code:
2935

@@ -32,15 +38,14 @@
3238

3339
;;;###autoload
3440
(defun use-package-autoload-keymap (keymap-symbol package override)
35-
"Loads PACKAGE and then binds the key sequence used to invoke
36-
this function to KEYMAP-SYMBOL. It then simulates pressing the
37-
same key sequence a again, so that the next key pressed is routed
38-
to the newly loaded keymap.
41+
"Load PACKAGE and bind key sequence invoking this function to KEYMAP-SYMBOL.
42+
Then simulate pressing the same key sequence a again, so that the
43+
next key pressed is routed to the newly loaded keymap.
3944
40-
This function supports use-package's :bind-keymap keyword. It
45+
This function supports use-package's :bind-keymap keyword. It
4146
works by binding the given key sequence to an invocation of this
42-
function for a particular keymap. The keymap is expected to be
43-
defined by the package. In this way, loading the package is
47+
function for a particular keymap. The keymap is expected to be
48+
defined by the package. In this way, loading the package is
4449
deferred until the prefix key sequence is pressed."
4550
(if (not (require package nil t))
4651
(use-package-error (format "Cannot load package.el: %s" package))

use-package-core.el

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,27 @@
55
;; Author: John Wiegley <[email protected]>
66
;; Maintainer: John Wiegley <[email protected]>
77

8-
;; This program is free software; you can redistribute it and/or modify
8+
;; This file is part of GNU Emacs.
9+
10+
;; GNU Emacs is free software: you can redistribute it and/or modify
911
;; it under the terms of the GNU General Public License as published by
1012
;; the Free Software Foundation, either version 3 of the License, or
1113
;; (at your option) any later version.
1214

13-
;; This program is distributed in the hope that it will be useful,
15+
;; GNU Emacs is distributed in the hope that it will be useful,
1416
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
1517
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1618
;; GNU General Public License for more details.
1719

1820
;; You should have received a copy of the GNU General Public License
19-
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
21+
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
2022

2123
;;; Commentary:
2224

23-
;; The `use-package' declaration macro allows you to isolate package
24-
;; configuration in your ".emacs" in a way that is performance-oriented and,
25-
;; well, just tidy. I created it because I have over 80 packages that I use
26-
;; in Emacs, and things were getting difficult to manage. Yet with this
27-
;; utility my total load time is just under 1 second, with no loss of
28-
;; functionality!
25+
;; This file contains the core implementation of the `use-package'
26+
;; macro.
2927
;;
30-
;; Please see README.md from the same repository for documentation.
28+
;; See the `use-package' info manual for more information.
3129

3230
;;; Code:
3331

@@ -63,7 +61,9 @@
6361

6462
(defgroup use-package nil
6563
"A `use-package' declaration for simplifying your `.emacs'."
66-
:group 'startup)
64+
:group 'initialization
65+
:link '(custom-manual "(use-package) Top")
66+
:version "29.1")
6767

6868
(defconst use-package-version "2.4.4"
6969
"This version of `use-package'.")
@@ -1609,8 +1609,8 @@ no keyword implies `:all'."
16091609
(defmacro use-package (name &rest args)
16101610
"Declare an Emacs package by specifying a group of configuration options.
16111611
1612-
For full documentation, please see the README file that came with
1613-
this file. Usage:
1612+
For the full documentation, see Info node `(use-package) top'.
1613+
Usage:
16141614
16151615
(use-package package-name
16161616
[:keyword [option]]...)
@@ -1647,12 +1647,15 @@ this file. Usage:
16471647
`:magic-fallback', or `:interpreter'. This can be an integer,
16481648
to force loading after N seconds of idle time, if the package
16491649
has not already been loaded.
1650-
:after Delay the use-package declaration until after the named modules
1651-
have loaded. Once load, it will be as though the use-package
1652-
declaration (without `:after') had been seen at that moment.
16531650
:demand Prevent the automatic deferred loading introduced by constructs
16541651
such as `:bind' (see `:defer' for the complete list).
16551652
1653+
:after Delay the effect of the use-package declaration
1654+
until after the named libraries have loaded.
1655+
Before they have been loaded, no other keyword
1656+
has any effect at all, and once they have been
1657+
loaded it is as if `:after' was not specified.
1658+
16561659
:if EXPR Initialize and load only if EXPR evaluates to a non-nil value.
16571660
:disabled The package is ignored completely if this keyword is present.
16581661
:defines Declare certain variables to silence the byte-compiler.

use-package-delight.el

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,28 @@
55
;; Author: John Wiegley <[email protected]>
66
;; Maintainer: John Wiegley <[email protected]>
77

8-
;; This program is free software; you can redistribute it and/or modify
8+
;; This file is part of GNU Emacs.
9+
10+
;; GNU Emacs is free software: you can redistribute it and/or modify
911
;; it under the terms of the GNU General Public License as published by
1012
;; the Free Software Foundation, either version 3 of the License, or
1113
;; (at your option) any later version.
1214

13-
;; This program is distributed in the hope that it will be useful,
15+
;; GNU Emacs is distributed in the hope that it will be useful,
1416
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
1517
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1618
;; GNU General Public License for more details.
1719

1820
;; You should have received a copy of the GNU General Public License
19-
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
21+
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
2022

2123
;;; Commentary:
2224

23-
;; Provides support for the :delight keyword, which is made available by
24-
;; default by requiring `use-package'.
25+
;; Provides support for the :delight keyword, which is made available
26+
;; by default by requiring `use-package'. Using it requires the
27+
;; `delight' package to be installed (available on GNU ELPA).
28+
;;
29+
;; See the `use-package' info manual for more information.
2530

2631
;;; Code:
2732

use-package-diminish.el

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,28 @@
55
;; Author: John Wiegley <[email protected]>
66
;; Maintainer: John Wiegley <[email protected]>
77

8-
;; This program is free software; you can redistribute it and/or modify
8+
;; This file is part of GNU Emacs.
9+
10+
;; GNU Emacs is free software: you can redistribute it and/or modify
911
;; it under the terms of the GNU General Public License as published by
1012
;; the Free Software Foundation, either version 3 of the License, or
1113
;; (at your option) any later version.
1214

13-
;; This program is distributed in the hope that it will be useful,
15+
;; GNU Emacs is distributed in the hope that it will be useful,
1416
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
1517
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1618
;; GNU General Public License for more details.
1719

1820
;; You should have received a copy of the GNU General Public License
19-
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
21+
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
2022

2123
;;; Commentary:
2224

23-
;; Provides support for the :diminish keyword, which is made available by
24-
;; default by requiring `use-package'.
25+
;; Provides support for the :diminish keyword, which is made available
26+
;; by default by requiring `use-package'. Using it requires the
27+
;; `diminish' package to be installed (available on GNU ELPA).
28+
;;
29+
;; See the `use-package' info manual for more information.
2530

2631
;;; Code:
2732

use-package-ensure-system-package.el

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,29 @@
99
;; Package-Requires: ((use-package "2.1") (system-packages "1.0.4"))
1010
;; Filename: use-package-ensure-system-package.el
1111

12-
;; This program is free software; you can redistribute it and/or modify
12+
;; This file is part of GNU Emacs.
13+
14+
;; GNU Emacs is free software: you can redistribute it and/or modify
1315
;; it under the terms of the GNU General Public License as published by
1416
;; the Free Software Foundation, either version 3 of the License, or
1517
;; (at your option) any later version.
1618

17-
;; This program is distributed in the hope that it will be useful,
19+
;; GNU Emacs is distributed in the hope that it will be useful,
1820
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
1921
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2022
;; GNU General Public License for more details.
2123

2224
;; You should have received a copy of the GNU General Public License
23-
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
25+
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
2426

2527
;;; Commentary:
26-
;;
28+
2729
;; The `:ensure-system-package` keyword allows you to ensure system
28-
;; binaries exist alongside your `use-package` declarations.
30+
;; binaries exist alongside your `use-package` declarations. Using it
31+
;; requires the `system-packages' package to be installed (available
32+
;; on GNU ELPA).
2933
;;
34+
;; See the `use-package' info manual for more information.
3035

3136
;;; Code:
3237

@@ -37,10 +42,10 @@
3742
(declare-function system-packages-get-command "system-packages"))
3843

3944
(defvar use-package-ensure-system-package--custom-packages '()
40-
"List of custom packages installed.")
45+
"List of commands used to install custom packages.")
4146

4247
(defun use-package-ensure-system-package-consify (arg)
43-
"Turn ARG into a cons of (`package-name' . `install-command')."
48+
"Turn ARG into a cons of the form (PACKAGE-NAME . INSTALL-COMMAND')."
4449
(cond
4550
((stringp arg)
4651
(cons arg `(system-packages-install ,arg)))
@@ -59,13 +64,15 @@
5964
`(system-packages-install ,(symbol-name (cdr arg)))))))))
6065

6166
(defun use-package-ensure-system-package-update-custom-packages ()
67+
"Update custom packages (not installed by system package manager).
68+
Run the same commands used for installing them."
6269
(interactive)
6370
(dolist (cmd use-package-ensure-system-package--custom-packages)
6471
(async-shell-command cmd)))
6572

6673
;;;###autoload
6774
(defun use-package-normalize/:ensure-system-package (_name-symbol keyword args)
68-
"Turn ARGS into a list of conses of (`package-name' . `install-command')."
75+
"Turn ARGS into a list of conses of the form (PACKAGE-NAME . INSTALL-COMMAND)."
6976
(use-package-as-one (symbol-name keyword) args
7077
(lambda (_label arg)
7178
(cond
@@ -75,7 +82,7 @@
7582
(list (use-package-ensure-system-package-consify arg)))))))
7683

7784
(defun use-package-ensure-system-package-exists? (file-or-exe)
78-
"If variable is a string, ensure the file path exists.
85+
"If FILE-OR-EXE is a string, ensure the file path exists.
7986
If it is a symbol, ensure the binary exist."
8087
(if (stringp file-or-exe)
8188
(file-exists-p file-or-exe)

0 commit comments

Comments
 (0)