1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-26 07:33:47 +00:00
Commit Graph

41 Commits

Author SHA1 Message Date
Shynur
93134bb9c2 Make key-translate actually work
* lisp/keymap.el (key-translate): Use the first element of the parsed
keys rather than the whole vector.  (Bug#65735)
2023-09-18 10:19:49 +02:00
Stefan Kangas
9aab258b80 Add missing builtin package declarations
* lisp/finder.el (finder--builtins-alist): Add new package
directories 'leim' and 'obsolete' as part of the 'emacs' package.
Add new package directory 'use-package' as part of the
'use-package' package.
* lisp/net/eudc-capf.el:
* lisp/net/eudcb-ecomplete.el:
* lisp/net/eudcb-macos-contacts.el:
* lisp/net/eudcb-mailabbrev.el: Declare library as part of the
'eudc' package.
* lisp/mail/ietf-drums-date.el: Declare library as part of the
'ietf-drums' package.
* lisp/image/image-dired-dired.el:
* lisp/image/image-dired-external.el:
* lisp/image/image-dired-tags.el:
* lisp/image/image-dired-util.el: Declare library as part of the
'image-dired' package.
* lisp/emacs-lisp/oclosure.el:
* lisp/keymap.el:
* lisp/progmodes/c-ts-common.el: Declare library as part of the
'emacs' package.  (Bug#62751)

(cherry picked from commit 94b1de2774)
2023-09-18 01:55:28 +02:00
Thomas Voss
3712e8bc38 ; Fix typos in lisp/keymap.el doc strings (bug#65329).
Copyright-paper-exempt: yes
2023-08-16 15:24:21 +03:00
Eli Zaretskii
a30ebe7a55 ; Improve documentation of key-binding commands
* doc/lispref/keymaps.texi (Key Binding Commands): Improve the
documentation of arguments expected by key binding commands.

* lisp/keymap.el (keymap-set, keymap-global-set)
(keymap-local-set, keymap-global-unset, keymap-local-unset)
(keymap-unset, key-parse): Doc fixes.
2023-07-06 11:42:01 +03:00
Robert Pluim
eed240bc02 Improve defvar-keymap docstring.
* lisp/keymap.el (defvar-keymap): Improve description of ':enter' and
':exit' usage for ':repeat' keyword.
2023-03-20 09:47:32 +01:00
Robert Pluim
e444115d02 Improve keymap-global-set and keymap-local-set interactive use fix
* lisp/keymap.el (keymap-global-set, keymap-local-set): Add optional
`interactive' arg and use it to decide when to convert the key
specification to a string.  Add `advertised-calling-convention'
declarations.  (Bug#61149)
2023-02-03 10:14:43 +01:00
Eli Zaretskii
2de0ab5cbd ; Doc fixes in keymap.el
* lisp/keymap.el (key-valid-p, key-translate, keymap-lookup)
(define-keymap): Doc fixes.
2023-02-02 16:14:15 +02:00
Robert Pluim
47ab9ba55d * lisp/keymap.el (keymap-global-unset): Correct prompt 2023-01-31 18:18:50 +01:00
Robert Pluim
f67a9a12b7 Fix interactive use of keymap-local-set' and keymap-global-set'
* lisp/keymap.el (keymap-global-set, keymap-local-set): Convert the
read key sequence to a string when called interactively.  Based on a
patch from Stephen Berman <stephen.berman@gmx.net>.  (Bug#61149)
2023-01-30 13:44:39 +01:00
Robert Pluim
06953fc8e1 Make `keymap-set-after' work for menus
It still doesn't work for an AFTER that's a key, though, since
`key-parse' produces vectors, and keymaps contain integers.

* lisp/keymap.el (keymap-set-after): Only parse AFTER as a key if it's
a string.  For consistency, use `key-parse' on the definition if it's
a string, just like `keymap-set'.
* test/src/keymap-tests.el (keymap-tests--command-3): New dummy command.
(keymap-set-after-menus): New test.  Check that we can insert a menu
item after a specific entry.
2023-01-20 15:14:45 +01:00
Robert Pluim
dcd59457b4 Use key-parse' in keymap-lookup'
It's stricter than `kbd', and doesn't try to do anything with key
sequences that look like macros.

* lisp/keymap.el (keymap-lookup): Use `key-parse' instead of `kbd'.
* test/src/keymap-tests.el (keymap-set-after-menus): Test the
`keymap-set-after' API.
2023-01-20 15:14:45 +01:00
Robert Pluim
c7e02eaa3d Handle after arg correctly in `keymap-set-after'
* lisp/keymap.el (keymap-set-after): AFTER: t means the same as nil,
so just change it to nil.  (Bug#60867)
2023-01-20 15:14:44 +01:00
Eli Zaretskii
cae528457c ; Add 2023 to copyright years. 2023-01-01 05:31:12 -05:00
Juri Linkov
05d8310fb5 Use the new keyword ':repeat' in repeatable keymaps.
* lisp/bindings.el (undo-repeat-map)
(buffer-navigation-repeat-map, next-error-repeat-map)
(page-navigation-repeat-map):
* lisp/comint.el (comint-repeat-map):
* lisp/dired.el (dired-jump-map):
* lisp/outline.el (outline-navigation-repeat-map)
(outline-editing-repeat-map):
* lisp/shell.el (shell-repeat-map):
* lisp/tab-bar.el (tab-bar-switch-repeat-map)
(tab-bar-move-repeat-map):
* lisp/window.el (other-window-repeat-map)
(resize-window-repeat-map):
* lisp/winner.el (winner-repeat-map):
* lisp/eshell/em-prompt.el (eshell-prompt-repeat-map):
* lisp/eshell/esh-mode.el (eshell-command-repeat-map):
Add the keyword ':repeat' to 'defvar-keymap' instead of
setting the symbol property 'repeat-map' explicitly.

* lisp/keymap.el (defvar-keymap): Check for 'props'
that is used in 'defvar-form'.
2022-12-22 10:03:09 +02:00
Stefan Kangas
33e0a10464 ; * lisp/keymap.el (keymap-substitute): Doc fix. (Bug#60059)
(cherry picked from commit 1568123196)
2022-12-14 06:39:40 +01:00
Robert Pluim
4506b005ab Improve 'defvar-keymap' docstring
* etc/NEWS: Improve ':repeat' entry for 'defvar-keymap'.
* lisp/keymap.el (defvar-keymap): Improve description of ':repeat'
keyword.
2022-11-18 16:09:05 +01:00
Juri Linkov
783c335623 * lisp/keymap.el (defvar-keymap): Don't use pcase. 2022-11-17 09:38:59 +02:00
Juri Linkov
ddbc33343c * lisp/keymap.el (defvar-keymap): Add support for repeat-mode.
Put symbol properties 'repeat-map' on commands from the keymap
when a ':repeat' keyword is non-nil.  Also include/exclude commands
according to ':repeat (:enter (commands ...) :exit (commands ...))'.
https://lists.gnu.org/archive/html/emacs-devel/2022-11/msg00968.html
2022-11-17 09:28:32 +02:00
Lars Ingebrigtsen
450d94920f Revert "keymap.el: Ease up support for non-kbd formats."
This reverts commit 570a11052b.

We do not want to support several keymap formats in
`keymap-set' and friends -- the point is to have an
interface with easy-to-understand semantics that
give good feedback on valid/invalid key sequences.
2022-10-03 11:04:16 +02:00
Stefan Monnier
570a11052b keymap.el: Ease up support for non-kbd formats.
While we want to standardize on the `kbd` syntax for user-facing code,
the internal vector representation of key sequences is not going away,
so let's not impose silly `key-description + key-parse` roundtrips.
Also, provide some support for packages stuck with user configs defined
to hold old-style key formats.

* lisp/keymap.el (keymap-set): Allow vectors as `key`.
(key-parse-old-format): New function, which stands out better than
`key-description` when searching for uses of the old syntax.

* list/outline.el (outline-minor-mode): Use it.
2022-10-02 14:07:24 -04:00
Robert Pluim
bf47851e08 Signal error on duplicate key definitions
* lisp/keymap.el (define-keymap, defvar-keymap): Signal error if the
same key is specified twice.  (Bug#56873)

* doc/lispref/keymaps.texi (Creating Keymaps): Document error
signaling behaviour.

* test/src/keymap-tests.el (keymap-test-duplicate-definitions): Test
duplicate definition detection.
2022-08-02 14:29:43 +02:00
Mattias Engdegård
f5cd6b730d Declare key-valid-p and readablep as error-free
* lisp/keymap.el (key-valid-p):
* lisp/subr.el (readablep): These functions are effect-free; declare
them correspondingly.  Note that readablep is not pure since its
return value depends on ambient state.
2022-07-31 18:29:02 +02:00
Lars Ingebrigtsen
0dc75daf11 Filter out NS non-key events from `where-is-internal'
* doc/lispref/keymaps.texi (Scanning Keymaps): Document it.
* lisp/keymap.el (make-non-key-event): New function.

* lisp/term/common-win.el (x-setup-function-keys): Mark ns events
as not being keys (bug#55940).

* src/keymap.c (Fwhere_is_internal): Filter out key sequences that
are marked as being non-keys.
2022-06-18 14:06:30 +02:00
Mattias Engdegård
e321f87aa7 Avoid "control-control-KEY" (bug#55738)
Constructs such as ?\C-^@ or ?\C-\C-m literally apply a Control
modifier twice which doesn't make sense at all.  What is really meant
is a C0 base character with the Control modifier bit set.
This change is only stylistic in nature.

* lisp/edmacro.el (edmacro-format-keys):
* lisp/keymap.el (key-parse):
* lisp/subr.el (event-modifiers, event-basic-type):
* test/lisp/subr-tests.el (subr-test-kbd):
Use \0 and \r instead of ^@ and \C-m to represent NUL and RET
when combined with other modifiers.
2022-06-18 11:22:58 +02:00
Lars Ingebrigtsen
41e946f46e Fix key-parse problem with C-x ( ... sequences
* lisp/keymap.el (key-parse): Move the read-kbd-macro compat code
from here...
* lisp/subr.el (kbd): ... to here.  (And fix the logic, too.)
This allows `key-parse' to have a less puzzling result while
maintaining backwards compatibility (bug#38775).
2022-05-03 16:19:50 +02:00
Lars Ingebrigtsen
bbf389ea6d Audit quoting the quote character in doc strings
* test/src/regex-emacs-tests.el (regex-tests-compare):
(regex-tests-compare):
(regex-tests-match):
* test/lisp/xml-tests.el (xml-parse-tests--qnames):
* test/lisp/mh-e/mh-thread-tests.el (mh-thread-tests-before-from):
* test/lisp/cedet/srecode-utest-template.el (srecode-utest-map-reset):
* test/lisp/calc/calc-tests.el (calc-tests-equal):
* lisp/window.el (get-lru-window):
(get-mru-window):
(get-largest-window):
(quit-restore-window):
(display-buffer):
* lisp/vc/vc-rcs.el (vc-rcs-consult-headers):
* lisp/url/url-auth.el (url-digest-auth-build-response):
* lisp/tutorial.el (tutorial--find-changed-keys):
* lisp/transient.el (transient-suffix-object):
* lisp/textmodes/rst.el (rst-insert-list-new-item):
* lisp/textmodes/bibtex.el (bibtex-clean-entry):
* lisp/tab-bar.el (tab-bar--key-to-number):
(toggle-frame-tab-bar):
* lisp/ses.el (ses-recalculate-cell):
(ses-define-local-printer):
(ses-prin1):
* lisp/progmodes/xref.el (xref--find-ignores-arguments):
* lisp/progmodes/verilog-mode.el (verilog-single-declaration-end):
* lisp/progmodes/tcl.el (tcl-mode-hook):
* lisp/progmodes/gdb-mi.el (gdb-get-buffer-create):
* lisp/progmodes/elisp-mode.el (elisp--xref-make-xref):
* lisp/play/dunnet.el (dun-room-objects):
* lisp/outline.el (outline--cycle-state):
* lisp/org/ox-publish.el (org-publish-find-property):
* lisp/org/ox-html.el (org-html--unlabel-latex-environment):
* lisp/org/org-table.el (org-table-collapse-header):
* lisp/org/org-plot.el (org--plot/prime-factors):
* lisp/org/org-agenda.el (org-agenda--mark-blocked-entry):
(org-agenda-set-restriction-lock):
* lisp/org/ob-lua.el (org-babel-lua-read-string):
* lisp/org/ob-julia.el (org-babel-julia-evaluate-external-process):
(org-babel-julia-evaluate-session):
* lisp/org/ob-core.el (org-babel-default-header-args):
* lisp/obsolete/mouse-sel.el (mouse-select):
(mouse-select-secondary):
* lisp/net/tramp.el (tramp-methods):
* lisp/net/eww.el (eww-accept-content-types):
* lisp/net/dictionary-connection.el (dictionary-connection-status):
* lisp/minibuffer.el (completion-flex--make-flex-pattern):
* lisp/mh-e/mh-mime.el (mh-have-file-command):
* lisp/mh-e/mh-limit.el (mh-subject-to-sequence):
(mh-subject-to-sequence-threaded):
(mh-subject-to-sequence-unthreaded):
* lisp/mail/feedmail.el (feedmail-queue-buffer-file-name):
(feedmail-vm-mail-mode):
* lisp/ls-lisp.el (ls-lisp--sanitize-switches):
* lisp/keymap.el (key-valid-p):
* lisp/international/ccl.el (ccl-compile-branch-blocks):
* lisp/image/image-converter.el (image-convert):
* lisp/gnus/spam.el (spam-backend-check):
* lisp/gnus/nnselect.el (nnselect-generate-artlist):
* lisp/gnus/nnmairix.el (nnmairix-widget-other):
* lisp/gnus/message.el (message-mailto):
* lisp/gnus/gnus-sum.el (gnus-collect-urls-from-article):
* lisp/gnus/gnus-search.el (gnus-search-prepare-query):
* lisp/frame.el (frame-size-history):
* lisp/eshell/esh-var.el (eshell-parse-variable-ref):
* lisp/eshell/em-dirs.el (eshell-expand-multiple-dots):
* lisp/erc/erc-backend.el (erc-bounds-of-word-at-point):
* lisp/emulation/cua-rect.el (cua--rectangle-operation):
* lisp/emacs-lisp/text-property-search.el (text-property-search-forward):
* lisp/emacs-lisp/package.el (package-desc-suffix):
* lisp/emacs-lisp/faceup.el (faceup-test-explain):
* lisp/emacs-lisp/comp.el (comp-curr-allocation-class):
(comp-alloc-class-to-container):
(comp-add-cstrs):
(comp-remove-type-hints-func):
(batch-byte+native-compile):
* lisp/emacs-lisp/cl-macs.el (cl--optimize):
* lisp/elec-pair.el (electric-pair--syntax-ppss):
* lisp/doc-view.el (doc-view-doc-type):
* lisp/cedet/semantic/symref.el (semantic-symref-tool-alist):
(semantic-symref-hit-to-tag-via-db):
(semantic-symref-hit-to-tag-via-buffer):
* lisp/cedet/semantic/lex-spp.el (semantic-lex-spp-get-overlay):
* lisp/cedet/semantic/java.el (semantic-java-doc-keywords-map):
* lisp/cedet/semantic/find.el (semantic-brute-find-tag-by-function):
* lisp/cedet/semantic/db.el (semanticdb-project-predicate-functions):
* lisp/cedet/semantic.el (semantic-working-type):
* lisp/cedet/ede/files.el (ede-flush-directory-hash):
* lisp/calc/calc.el (calc--header-line):
* lisp/auth-source.el (auth-source-pick-first-password):
(auth-source--decode-octal-string):
* etc/themes/modus-themes.el (modus-themes--paren):
(modus-themes--agenda-habit):
* admin/cus-test.el (cus-test-vars-with-changed-state): Fix
quoting in doc strings.  In code examples, the ' character is
quoted with \\=, and regularize 'foo to `foo', and quote strings
like "foo" instead of 'foo'.
2022-04-22 16:17:22 +02:00
Alan Mackenzie
14d64a8adc Merge branch 'master' into scratch/correct-warning-pos 2022-01-22 11:02:50 +00:00
Alan Mackenzie
bdd9b5b8a0 Miscellaneous amendments to the scratch/correct-warning-pos branch
* lisp/cedet/semantic/fw.el (semantic-alias-obsolete)
(semantic-varalias-obsolete): Replace calls to byte-compile-warn with calls to
byte-compile-warn-x (when it exists).

* lisp/emacs-lisp/bytecomp.el (byte-compile-log-warning-function)
(byte-compile--log-warning-for-byte-compile): Make the POSITION parameter no
longer &optional (for the benefit of flymake on *.el).
(byte-compile-log-warning): Replace a nil POSITION argument with an actual
position.
(byte-compile-file-form-require): Push the required symbol onto
byte-compile-form-stack, for the benefit of `do-after-load-evaluation'.

* lisp/keymap.el (define-keymap--compile): Replace four calls to
byte-compile-warn with byte-compile-warn-x.

* doc/lispref/elisp.texi (master menu): Add entries for Shorthands and Symbols
with position.

* doc/lispref/streams.texi (Input Functions): Document
read-positioning-symbols.

* doc/lispref/symbols.texi (Symbols): Add new menu entry.
(Symbols with Position): New @section.
2022-01-22 09:59:05 +00:00
Lars Ingebrigtsen
3eb1b2a115 Make key-valid-p work in Turkey
* lisp/keymap.el (key-valid-p): Inhibit case folding, otherwise
(key-valid-p "I") would return nil in tr_TR environments.
2022-01-20 10:19:23 +01:00
Robert Pluim
a0263cfee3 Remove ambiguity from key-valid-p docstring
* lisp/keymap.el (key-valid-p): Be explicit about the separator
being one and only one space.
2022-01-04 16:43:03 +01:00
Stefan Kangas
7ddfe1cab2 Move define-keymap and defvar-keymap to keymap.el
These functions deal with the "new" keymap binding interface, so they
belong in keymap.el rather than in subr.el.
* lisp/subr.el (define-keymap--compile, define-keymap)
(defvar-keymap): Move from here ...
* lisp/keymap.el (define-keymap--compile, define-keymap)
(defvar-keymap): ... to here.
2022-01-02 23:33:41 +01:00
Eli Zaretskii
823b6b8d26 ; Add 2022 to copyright years. 2022-01-01 07:07:15 -05:00
Eli Zaretskii
8276605efb ; * lisp/keymap.el (key-valid-p): Fix wording of doc string. 2021-12-28 20:07:54 +02:00
Stefan Kangas
8df3a71c52 Doc fix; fix terminology in key binding functions
* lisp/keymap.el (keymap-set, key-valid-p):
* lisp/subr.el (define-keymap): Doc fix; improve terminology.
2021-12-27 16:24:18 +01:00
Lars Ingebrigtsen
79825f724f Make keymap-lookup work for keymap results, too
* lisp/keymap.el (keymap-lookup): Make this function work for
non-symbol lookups, too (bug#52374).
2021-12-10 13:11:26 +01:00
Lars Ingebrigtsen
55ff91e822 Fix keymap-lookup implementation
* lisp/keymap.el (keymap-lookup): Make this actually work for
looking up keys.
2021-12-04 05:24:54 +01:00
Lars Ingebrigtsen
1bd7b5dd51 Fix some of the argument handling in keymap-set and keymap-substitute
* lisp/keymap.el (keymap-set): Fix handling of binding one key to
another key.
(keymap-substitute): Fix confusion in implementation -- the args
are definitions, not keys.
2021-11-30 00:13:47 +01:00
Mattias Engdegård
d50e0bdbac Use compiler macros for the key syntax checks
Compile-time key string syntax checks are better written using
compiler macros than with byte-hunk-handlers inside the compiler
proper.

* lisp/emacs-lisp/bytecomp.el (byte-compile-define-keymap)
(byte-compile-define-keymap--define): Remove.
* lisp/keymap.el (keymap--compile-check): New.
(keymap-set, keymap-global-set, keymap-local-set, keymap-global-unset)
(keymap-local-unset, keymap-unset, keymap-substitute)
(keymap-set-after, key-translate, keymap-lookup, keymap-local-lookup)
(keymap-global-lookup): Use compiler-macro for argument checks.
* lisp/subr.el (define-keymap--compile): New.
(define-keymap--define): Fold into define-keymap.
(define-keymap): Use compiler-macro.
(defvar-keymap): Use define-keymap.
2021-11-28 18:10:23 +01:00
Lars Ingebrigtsen
cde5dcd441 Change the call signature to keymap-substitute
* lisp/keymap.el (keymap-substitute): Make the keymap the first
parameter for symmetry with the other functions.
* lisp/emacs-lisp/shortdoc.el (keymaps):
* lisp/emacs-lisp/bytecomp.el (lambda): Adjust.
2021-11-17 08:34:35 +01:00
Lars Ingebrigtsen
97c23204b9 Make keymap-unset work
* lisp/keymap.el (keymap-unset): Fix key syntax (bug#51897).
2021-11-16 19:42:09 +01:00
Lars Ingebrigtsen
de477ec683 Add new 'keymap-*' functions
* lisp/keymap.el: New file with all the new keymap-* functions.

* lisp/loadup.el ("keymap"): Load.

* lisp/subr.el (kbd): Refactor out all the code to key-parse.
(define-key-after, keyboard-translate, global-set-key)
(local-set-key, global-unset-key, local-unset-key)
(local-key-binding, global-key-binding)
(substitute-key-definition): Note in doc strings that these are
legacy functions.
(define-keymap--define): Use keymap-set.

* lisp/emacs-lisp/byte-opt.el: Remove the optimizations for
defvar-keymap and define-keymap since the macros now only
understand the kbd syntax.
* lisp/emacs-lisp/bytecomp.el (byte-compile-define-keymap)
(byte-compile-define-keymap--define): Warn about invalid key
definitions in all keymap-* functions.

* lisp/emacs-lisp/shortdoc.el (keymaps): Add shortdocs form
keymap* functions.

* src/keymap.c (possibly_translate_key_sequence): Adjust callers
to key-valid-p and key-parse.
(syms_of_keymap): Adjust defs.
2021-11-16 08:26:24 +01:00