From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.devel Subject: Smarter M-x that filters on major-mode Date: Wed, 10 Feb 2021 20:50:10 -0600 Message-ID: References: <8ed9b43502ae1480e06b@heytings.org> <83r1lohqoc.fsf@gnu.org> <87wnvfenry.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7520"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , emacs-devel@gnu.org, gregory@heytings.org, bugs@gnu.support, "Alfred M. Szmidt" To: Lars Ingebrigtsen , Matt Armstrong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Feb 11 03:51:39 2021 Return-path: Envelope-to: ged-emacs-devel@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 1lA24w-0001qD-T2 for ged-emacs-devel@m.gmane-mx.org; Thu, 11 Feb 2021 03:51:38 +0100 Original-Received: from localhost ([::1]:38110 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lA24v-00026C-VV for ged-emacs-devel@m.gmane-mx.org; Wed, 10 Feb 2021 21:51:37 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lA23b-0001MY-Si for emacs-devel@gnu.org; Wed, 10 Feb 2021 21:50:15 -0500 Original-Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:52410) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lA23a-0008FI-5r; Wed, 10 Feb 2021 21:50:15 -0500 Original-Received: by mail-pj1-x102c.google.com with SMTP id q72so2472129pjq.2; Wed, 10 Feb 2021 18:50:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:in-reply-to:references:mime-version:date:message-id:subject:to :cc; bh=CWHAdum0X6rWdFOB49b19YHEWeDl+2msY4G7DX4TeLo=; b=H1PT0443tGsjb3zJnRx9zJqoEEA1DreP+rqM7o0xGdrvDnuhACHxOPKKlK/91+i5ni m03ZCG6QA85Dq/BVyihQqQBZAz1o1gpZKjr9dU0cOrz85aRkCh8561BgCy5rrhYBXFl+ WHT06b37IfYktxH3k+BfMh3wgCRUBIirmj1+lxVqi/CYrYPQ27Je4xBGPG7BDUW+WLSm w3Tta95yKApqvHEPlV0Zi5//Z4B1JtHM/E98qxLTYLfI3t/sZkM4Oc2kg0deSDxwYw/j Aqf2BzEha4wIlb2gT0RJ2rIIgYD+tBiiq7AIx1MBUY/RZ5x1Bzwc8kBfmiPLPXLdWM6l fRcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:in-reply-to:references:mime-version:date :message-id:subject:to:cc; bh=CWHAdum0X6rWdFOB49b19YHEWeDl+2msY4G7DX4TeLo=; b=OUMA51Y+66Spfp76HJUzJRR99w2HJJZua3Cl1db9AV57DBm1IW0mISdEwNb5t1a95F oi3UygreO3JK93ctgETd7j7P7xFV9R8WJ3L+prAjpcBhJMXThfb7pTAdS8K0U/ATIro8 dI9LM9+60dyPoPnYgIByn+UlO2WxbZth3vBEqbXlhGrqnlNjVMU8R89BsozZLWOg7pS3 b8Kkf4Fu67uikIwNVZ4ZjuzmInjQYyUah02ObUxSJtwuSm7c21lMkqoSdxZoGzn6UEUC wneAvaW+rBFOpGz7V0xKHxHYNiznkv/A3Wm9ul2YUHT+VdKh+iNlQ0m/KvtX5dsL4nwu Tbuw== X-Gm-Message-State: AOAM532HTmnnQKEc/fyttdbsYfRSKXEPYMjwsxdRx80dnwfkICRIBn9j zp2d5LiERCB3Ez+2mrLUIopMCU1dD3bn6KkL2jE= X-Google-Smtp-Source: ABdhPJxEHI73dIzKEMYU02gg0icrHh0eeEb+4owLDL14xKS0H+MZZuxMbgvKW+pE6icf+B0UtTxe8xD+9leQkiSeZpY= X-Received: by 2002:a17:903:31c4:b029:e1:8840:8ab9 with SMTP id v4-20020a17090331c4b02900e188408ab9mr5763644ple.70.1613011811496; Wed, 10 Feb 2021 18:50:11 -0800 (PST) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Wed, 10 Feb 2021 20:50:10 -0600 In-Reply-To: <87wnvfenry.fsf@gnus.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=stefankangas@gmail.com; helo=mail-pj1-x102c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:264346 Archived-At: Lars Ingebrigtsen writes: > Matt Armstrong writes: > >> What if instead help showed all the interactive commands provided by >> the mode? What if M-x were smarter about highlighting mode specific >> commands? > > It's been discussed before -- somebody just has to implement one of the > various possibilities here. The problem is that commands are only tied > very loosely to modes: > > (defun foo-thing () > (interactive) > ...) > > will make `M-x fTAB' show `foo-thing' even if it's useless outside of > all other modes than `foo-mode'. Conversely, `C-h m' in `foo-mode' > won't, as you mention, list `foo-thing' unless there's a binding for it. > > My suggestion is to introduce a new form: > > (defun foo-thing () > (command foo-mode) > ...) > > This would be just like `interactive', but will do the right thing in > `M-x fTAB' and `C-h m' in modes derived from `foo-mode'. (It could also > be a list of mode, of course, but that'd be more rare, is my guess.) It would indeed be very useful to provide a mechanism to exclude commands from M-x that are useless outside of their major mode. I've had a related idea to make `M-X' (a.k.a. `M-S-x') run a version of `M-x' that *includes* only commands that are specifically relevant to the current major mode. This would be used when I specifically want to do something in my major mode, as opposed to looking at the gazillion different entry points for things like calendar, gnus, or tetris. I only just now discovered that my completion framework (ivy) has had the exact same idea for M-S-x. It filters all commands according to some heuristics, seemingly only showing commands beginning with whatever package prefix your mode is using. It is not perfect, as it seems to show commands not relevant to the current major mode, if they share the prefix. For example, when replying to emails I'm in notmuch-message-mode and don't need to see commands used for navigating my list of emails (notmuch-search-mode). Anyways, these are just my thoughts. I would encourage anyone to start working on this. The blacklisting for normal M-x discussed by Lars above seems like a good starting point.