From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: How to define a (derived) minor mode inaccessible to the user Date: Thu, 28 Jan 2021 09:31:31 -0500 Message-ID: References: <87eeidlfmw.fsf@mbork.pl> <875z3pknav.fsf@mbork.pl> <87v9bhik1x.fsf@mbork.pl> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27263"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: help-gnu-emacs@gnu.org To: Marcin Borkowski Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 28 15:33:08 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l58M6-0006ss-5g for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 28 Jan 2021 15:33:06 +0100 Original-Received: from localhost ([::1]:55314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l58M5-00013o-78 for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 28 Jan 2021 09:33:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l58Kf-000129-14 for help-gnu-emacs@gnu.org; Thu, 28 Jan 2021 09:31:37 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:9205) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l58Kc-0003tX-RW for help-gnu-emacs@gnu.org; Thu, 28 Jan 2021 09:31:36 -0500 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id CBBAF440536; Thu, 28 Jan 2021 09:31:33 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 78B6F440533; Thu, 28 Jan 2021 09:31:32 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1611844292; bh=V9SowEHFqP9LIeZ1r0hHpd3PWpIYvOCFK4rAbs+tFaY=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=DYzaulsqIfmbZeG1C5maLLrnbXhsma6ncnWFApPq4egh5besmKnAhHXvjEnT4XiVh d56WJ/030SOx+HNdQjrfLR+5eyGUuad7holQmkWNLn8Ea8fTuBNjUrMq+xODU5yBic RhfgWoejdSMqnDxJWGmO0/jXS/cCUKkLdg0eb/4Ahk4FWtaxhu9bxS/rccsh9Hy/HH prazDTBjWT6PfW7tvEF0ItKWOAGUNCUa+jn6mkW8yb56eTpTeDyBPbT7FtDk+I2tBB uS2qOIhsvKxESnqbPMj45V/6MQVJep0LSteUpYmPj3lkLJAobxaGC+vlnZxGgwVU0c EPLQFykZOMaWw== Original-Received: from alfajor (69-196-141-46.dsl.teksavvy.com [69.196.141.46]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 4AC7F12027B; Thu, 28 Jan 2021 09:31:32 -0500 (EST) In-Reply-To: <87v9bhik1x.fsf@mbork.pl> (Marcin Borkowski's message of "Thu, 28 Jan 2021 08:42:50 +0100") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:127400 Archived-At: >> 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.