[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to define a (derived) minor mode inaccessible to the user
From: |
Stefan Monnier |
Subject: |
Re: How to define a (derived) minor mode inaccessible to the user |
Date: |
Thu, 28 Jan 2021 09:31:31 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
>> No, and I don't recommend it.
>> E.g `C-h m` will then fail to show the proper docstring of the major mode.
>
> I see. Still interesting.
I think removing the major mode from the completions offered by `M-x` is
the best option, and adding that possibility would be a useful
improvement to `M-x` for other purposes as well, so I'd welcome a patch
that does that.
The patch below installed a few months back should get you started: it
removed a functionality by which M-x refrained from completing
obsolete commands.
So you could get what you want by reverting that patch and changing it
so it hides commands marked with some new property instead of commands
marked as obsolete.
Stefan
diff --git a/lisp/simple.el b/lisp/simple.el
index b5002dd189..16ff8637b9 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1881,22 +1881,17 @@ read-extended-command
'(metadata
(annotation-function . read-extended-command--annotation)
(category . command))
- (let ((pred
- (if (memq action '(nil t))
- ;; Exclude obsolete commands from completions.
- (lambda (sym)
- (and (funcall pred sym)
- (or (equal string (symbol-name sym))
- (not (get sym 'byte-obsolete-info)))))
- pred)))
- (complete-with-action action obarray string pred))))
+ (complete-with-action action obarray string pred)))
#'commandp t nil 'extended-command-history)))
(defun read-extended-command--annotation (command-name)
- (let* ((function (and (stringp command-name) (intern-soft command-name)))
- (binding (where-is-internal function overriding-local-map t)))
- (when (and binding (not (stringp binding)))
- (format " (%s)" (key-description binding)))))
+ (let* ((fun (and (stringp command-name) (intern-soft command-name)))
+ (binding (where-is-internal fun overriding-local-map t))
+ (obsolete (get fun 'byte-obsolete-info)))
+ (cond (obsolete
+ (format " (%s)" (car obsolete)))
+ ((and binding (not (stringp binding)))
+ (format " (%s)" (key-description binding))))))
(defcustom suggest-key-bindings t
"Non-nil means show the equivalent key-binding when M-x command has one.
Re: How to define a (derived) minor mode inaccessible to the user, Michael Heerdegen, 2021/01/23