[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/command 0791494 5/5: Also make the mode predicate work on minor
From: |
Lars Ingebrigtsen |
Subject: |
scratch/command 0791494 5/5: Also make the mode predicate work on minor modes |
Date: |
Sat, 13 Feb 2021 17:13:38 -0500 (EST) |
branch: scratch/command
commit 0791494d4c42fc47e0e656d08988b82139344444
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Also make the mode predicate work on minor modes
---
lisp/emacs-lisp/seq.el | 1 +
lisp/simple.el | 11 +++++++----
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el
index 31c15fe..55ce6d9 100644
--- a/lisp/emacs-lisp/seq.el
+++ b/lisp/emacs-lisp/seq.el
@@ -455,6 +455,7 @@ negative integer or 0, nil is returned."
(setq sequence (seq-drop sequence n)))
(nreverse result))))
+;;;###autoload
(cl-defgeneric seq-intersection (sequence1 sequence2 &optional testfn)
"Return a list of the elements that appear in both SEQUENCE1 and SEQUENCE2.
Equality is defined by TESTFN if non-nil or by `equal' if nil."
diff --git a/lisp/simple.el b/lisp/simple.el
index ede6c6b..e01ac33 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1900,11 +1900,11 @@ to get different commands to edit and resubmit."
(defvar extended-command-history nil)
(defvar execute-extended-command--last-typed nil)
-(defcustom read-extended-command-predicate #'completion-major-mode-p
+(defcustom read-extended-command-predicate #'completion-in-mode-p
"Predicate to use to determine which commands to include when completing."
:version "28.1"
:type '(choice (const :tag "Exclude commands not relevant to this mode"
- #'completion-major-mode-p)
+ #'completion-in-mode-p)
(const :tag "All commands" (lambda (_ _) t))
(function :tag "Other function")))
@@ -1966,14 +1966,17 @@ to get different commands to edit and resubmit."
(funcall read-extended-command-predicate sym buffer))))
t nil 'extended-command-history))))
-(defun completion-major-mode-p (symbol buffer)
+(defun completion-in-mode-p (symbol buffer)
"Say whether SYMBOL should be offered as a completion.
This is true if the command is applicable to the major mode in
BUFFER."
(or (null (command-modes symbol))
+ ;; It's derived from a major mode.
(apply #'provided-mode-derived-p
(buffer-local-value 'major-mode buffer)
- (command-modes symbol))))
+ (command-modes symbol))
+ ;; It's a minor mode.
+ (seq-intersection (command-modes symbol) minor-modes #'eq)))
(defun completion-with-mode-p (modes buffer)
(apply #'provided-mode-derived-p