all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Marcin Borkowski <mbork@mbork.pl>
Cc: help-gnu-emacs@gnu.org
Subject: Re: How to define a (derived) minor mode inaccessible to the user
Date: Thu, 28 Jan 2021 09:31:31 -0500	[thread overview]
Message-ID: <jwvy2gdw30y.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87v9bhik1x.fsf@mbork.pl> (Marcin Borkowski's message of "Thu, 28 Jan 2021 08:42:50 +0100")

>> 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.




  reply	other threads:[~2021-01-28 14:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-22  5:11 How to define a (derived) minor mode inaccessible to the user Marcin Borkowski
2021-01-22  5:34 ` [External] : " Drew Adams
2021-01-22 15:01   ` Marcin Borkowski
2021-01-22 14:19 ` Stefan Monnier
2021-01-22 15:23   ` Marcin Borkowski
2021-01-22 15:38     ` Stefan Monnier
2021-01-28  7:42       ` Marcin Borkowski
2021-01-28 14:31         ` Stefan Monnier [this message]
2021-01-23 13:08 ` Michael Heerdegen
2021-01-28  7:45   ` Marcin Borkowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvy2gdw30y.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=help-gnu-emacs@gnu.org \
    --cc=mbork@mbork.pl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.