diff options
author | Stefan Kangas <stefankangas@gmail.com> | 2023-01-10 09:51:57 +0100 |
---|---|---|
committer | Stefan Kangas <stefankangas@gmail.com> | 2023-01-10 09:51:57 +0100 |
commit | 60240f54e5fed16a0522fb766ffef073db596f1f (patch) | |
tree | a8677abd38758e66c56900632756a39a0ebccb7b /lisp/simple.el | |
parent | 4d1d43e41fafaa5beecba57686f5d5f4146746c8 (diff) | |
parent | 55aabfea4accd04aed9424b5cdbe304d12be6224 (diff) | |
download | emacs-60240f54e5fed16a0522fb766ffef073db596f1f.tar.gz |
Merge from origin/emacs-29
55aabfea4ac Fix c-ts-mode comment indent
8377ed5298f Highlight identifier in import statements in js-ts-mode
aa9df1260c3 Don't print named tree-sitter nodes with parenthesizes (b...
e385c099b8c Improve fontification for import-statements in typescript...
28dd6021384 Fix c-ts-mode indentation for 2nd line in block comment (...
8a36a0f44aa ; xref.el: Bump version
f16cc7c49c7 ; project.el: Bump version
ebc5263667b ; * src/callint.c (Finteractive): Doc string clarification.
c1401d1c6c8 * lisp/vc/diff-mode.el (diff-font-lock-keywords): Check f...
1f8ad353d9f Minor improvement for tree-sitter explorer
ef87c755660 Make sure NODE is not the root node in tree-sitter indent...
1238fa8e49b Fix label indent of GNU and Linux style in c-ts-mode (bug...
dc911e4ba5c Improve go-ts-mode Imenu, navigation and electric pair (b...
20f36c8f6f9 ; ruby.rb: Fix pattern matching syntax and extend the exa...
d46f7f4edcc Revert "Add c-or-c++-ts-mode (bug#59613)"
1469aac20d8 ; * src/pgtkfns.c (parse_resource_key): Use recursive sch...
da96a1fd741 Add back renamed function 'font-lock-fontify-syntacticall...
b1aa720671e ; * lisp/progmodes/ruby-ts-mode.el: Fix compilation warni...
5cb01ac5d78 ; * src/callint.c (Finteractive): Fix the doc string (bug...
53e64cfb852 Improve options and docs of M-x command completion
fef4f18cc33 ; Fix NEWS
e04b3d41bb4 Update to Org 9.6-90-ga6523f
e3d806b4172 Fix string fontification on python-ts-mode (bug#60599)
800e15e3be0 Fix string-interpolation feature of python-ts-mode (bug#6...
38b63f4c3ce Add indentation rule for concatenated_string (bug#60572)
2cdd75a18ff Fix highlighting of variable-declarations in typescript-t...
73168793c01 Fix label indentation for Linux style in c-ts-mode (bug#6...
8575043f56b Remove duplicate entries in c-ts-mode's Imenu
ef7f3c6388b Fix use of treesit-ready-p in c/c++-ts-mode
cc1de953d4f ; * lisp/progmodes/gud.el (gud-tooltip-modes): Add ts- mo...
16f1e47ca8b ; * lisp/align.el (align-c++-modes): Add c/c++-ts-mode.
508389ad2bb Add documentation for c/c++-ts-mode (bug#60443)
ee3e8d3f927 (ruby-ts--font-lock-settings): Improve highlighting in pa...
614f8c431d3 Optionally include the namespace in c-ts-mode--declarator...
7c356934fbb Support namespaces in c++-ts-mode (bug#60397)
757c2c25922 Fix c-ts-mode--looking-at-star
1df2826639c Add c-or-c++-ts-mode (bug#59613)
0cb686ffb6b Document the 'definition-name' property.
7f855b5297b ; Fix description of etc/DOC
e9341119fe4 ; Fix documentation of etc/DOC
86a3462e3d2 (treesit-simple-indent-presets): Do that for 'or' as well.
e0fef510b00 ; Minor rewording of tree-sitter terminology
f58452e3ae7 Fix 'python-shell-buffer-substring' when START is in midd...
7f9588685a0 ; Fix last change
e8b85f225d9 Rearrange the "Saving Emacs Sessions" section of the user...
# Conflicts:
# etc/NEWS
# lisp/progmodes/c-ts-mode.el
Diffstat (limited to 'lisp/simple.el')
-rw-r--r-- | lisp/simple.el | 67 |
1 files changed, 62 insertions, 5 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index c8c5542caee..f5712177234 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -2207,15 +2207,39 @@ to get different commands to edit and resubmit." "Predicate to use to determine which commands to include when completing. If it's nil, include all the commands. If it's a function, it will be called with two parameters: the -symbol of the command and a buffer. The predicate should return -non-nil if the command should be present when doing \\`M-x TAB' -in that buffer." +symbol of the command and the current buffer. The predicate should +return non-nil if the command should be considered as a completion +candidate for \\`M-x' in that buffer. + +Several predicate functions suitable for various optional behaviors +are available: + + `command-completion-default-include-p' + This excludes from completion candidates those commands + which have been marked specific to modes other than the + current buffer's mode. Commands that are not specific + to any mode are included. + + `command-completion-using-modes-p' + This includes in completion candidates only commands + marked as specific to the current buffer's mode. + + `command-completion-using-modes-and-keymaps-p' + This includes commands marked as specific to the current + buffer's modes and commands that have keybindings in the + current buffer's active local keymaps. It also includes + several commands, like Cuztomize commands, which should + always be avaliable." :version "28.1" :group 'completion :type '(choice (const :tag "Don't exclude any commands" nil) (const :tag "Exclude commands irrelevant to current buffer's mode" command-completion-default-include-p) - (function :tag "Other function"))) + (const :tag "Include only commands relevant to current buffer's mode" + command-completion-using-modes-p) + (const :tag "Commands relevant to current buffer's mode or bound in its keymaps" + command-completion-using-modes-and-keymaps-p) + (function :tag "Other predicate function"))) (defun execute-extended-command-cycle () "Choose the next version of the extended command predicates. @@ -2401,6 +2425,35 @@ or (if one of MODES is a minor mode), if it is switched on in BUFFER." #'eq) (seq-intersection modes global-minor-modes #'eq))) +(defun command-completion-using-modes-and-keymaps-p (symbol buffer) + "Return non-nil if SYMBOL is marked for BUFFER's mode or bound in its keymaps." + (with-current-buffer buffer + (let ((keymaps + ;; The major mode's keymap and any active minor modes. + (nconc + (and (current-local-map) (list (current-local-map))) + (mapcar + #'cdr + (seq-filter + (lambda (elem) + (symbol-value (car elem))) + minor-mode-map-alist))))) + (or (command-completion-using-modes-p symbol buffer) + ;; Include commands that are bound in a keymap in the + ;; current buffer. + (and (where-is-internal symbol keymaps) + ;; But not if they have a command predicate that + ;; says that they shouldn't. (This is the case + ;; for `ignore' and `undefined' and similar + ;; commands commonly found in keymaps.) + (or (null (get symbol 'completion-predicate)) + (funcall (get symbol 'completion-predicate) + symbol buffer))) + ;; Include customize-* commands (do we need a list of such + ;; "always available" commands? customizable?) + (string-match-p "customize-" (symbol-name symbol)))))) + + (defun command-completion-button-p (category buffer) "Return non-nil if there's a button of CATEGORY at point in BUFFER." (with-current-buffer buffer @@ -2502,7 +2555,11 @@ Also see `suggest-key-bindings'." (defun execute-extended-command (prefixarg &optional command-name typed) "Read a command name, then read the arguments and call the command. To pass a prefix argument to the command you are -invoking, give a prefix argument to `execute-extended-command'." +invoking, give a prefix argument to `execute-extended-command'. + +This command provides completion when reading the command name. +Which completion candidates are shown can be controlled by +customizing `read-extended-command-predicate'." (declare (interactive-only command-execute)) ;; FIXME: Remember the actual text typed by the user before completion, ;; so that we don't later on suggest the same shortening. |