From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.devel Subject: Re: Smarter M-x that filters on major-mode Date: Thu, 11 Feb 2021 14:46:11 +0100 Message-ID: <87r1lmd8f0.fsf@gnus.org> References: <8ed9b43502ae1480e06b@heytings.org> <83r1lohqoc.fsf@gnu.org> <87wnvfenry.fsf@gnus.org> <87blcrdlqf.fsf@gnus.org> <87v9aydg3f.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34389"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Andrea Corallo , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Feb 11 15:06:44 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 1lACcG-0008r4-TM for ged-emacs-devel@m.gmane-mx.org; Thu, 11 Feb 2021 15:06:44 +0100 Original-Received: from localhost ([::1]:51152 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lACcF-0005a9-Ue for ged-emacs-devel@m.gmane-mx.org; Thu, 11 Feb 2021 09:06:43 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44876) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lACIc-0007Le-1t for emacs-devel@gnu.org; Thu, 11 Feb 2021 08:46:27 -0500 Original-Received: from quimby.gnus.org ([2a01:4f9:2b:f0f::2]:44688) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lACIZ-0002IB-Df for emacs-devel@gnu.org; Thu, 11 Feb 2021 08:46:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=f4M6JXywaRB4M+MNsyxhXcc00+izpIaMZXDIJABsAhs=; b=SFrd4dLdFUCgGsqBEEsGkiFzEP 5oikHM2P/2BadlfoHanJ0YEpnAQKOSfV8aOZWSmFfC2lRZEeT9uSZKMJKUJWb1D4u4n8MOypeelXM M4aJWU72rnwWgpeAKatk2tNe4cyrTK857CdblaDf+zXKoUKuhY3nTur/5KOMx54MLZnQ=; Original-Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lACIQ-0003Qz-4o; Thu, 11 Feb 2021 14:46:16 +0100 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAD1BMVEUXExBSPiumc7Wa XlH///+spZNTAAAAAWJLR0QEj2jZUQAAAAd0SU1FB+UCCw0lGaPcH4QAAAFkSURBVDjLrZNRooQg CEUhNwC6gSdtIHP/e3sgatZMf+NHJkcRLgjwk8Gvi3VEegHooBZfoE0FgloN4CmSfZ+7t+12SRQd NEG/nZDNLvsDAPLZgBweJNpsH45ub7cYKA4Yu735WtIajtQVrSDIMVxZEjzD3QRkAallC+HQFA43 e+5putokm6u9S5bWy2MPFXABzATfgP2yqmJZswl6gSB7ITg94Qu4n712NXi5XEFJkrFnxtNVbBIR tkougILIjAPx0opVw7HQkl0AmUvKY0W0ys7s5W5lXduMOebZfLf+w9TK3c7cGxPP/TtQXah35bOV Yx2pPADu3rsdLOdy1cKoph8nBIttZ3zahewE5LsrObPJoY46sLdh6mgahDeQKtdaSauKxdxPgLUm 1k7b/lQxWIDJ3p7fkORwE9lr4qAkdGlmYdtUq2be/o5ZMd+nQsU8w1cnGqO1KKTSCskfimisY8Dr +AelXyYxJcVJ2wAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMS0wMi0xMVQxMzozNzoyNSswMDowMA0o hgsAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjEtMDItMTFUMTM6Mzc6MjUrMDA6MDB8dT63AAAAAElF TkSuQmCC X-Now-Playing: Jay Glass Dubs vs Guerilla Toss's _Vs_: "Can I Get The Real Dub?" In-Reply-To: <87v9aydg3f.fsf@gnus.org> (Lars Ingebrigtsen's message of "Thu, 11 Feb 2021 12:00:20 +0100") Received-SPF: pass client-ip=2a01:4f9:2b:f0f::2; envelope-from=larsi@gnus.org; helo=quimby.gnus.org 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, 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:264373 Archived-At: Lars Ingebrigtsen writes: > Would extending the object (and stash it in the seventh slot) make > sense? It'd make the bytecode massively incompatible with previous > versions, but it generally is pretty incompatible. That was a rabbit hole I don't really want to go down -- `make-byte-code' has a (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INTERACTIVE-SPEC &rest ELEMENTS) signature, which makes it non-trivial to extend with another parameter, especially with how it's called. So instead I made INTERACTIVE-SPEC be a cons cell, where the first element is the spec itself and the second is the modes list. With that, I've now got a functioning Emacs, and I'm using gnus-summary-mode as the test subject: `M-x gnusTAB' now gives me 200 fewer things to read through when issues in the Gnus group buffer. :-) I guess I could take this to a branch... but... the changes seem kinda straighforward, so I'm not sure that's worth it, and by pushing directly to the trunk, people can get started with `C-M-% ^ (interactive RET (command the-correct-mode RET'-ing as they want, and then see `M-x TAB' grow progressively shorter each time... Two things: 1) I'm slightly worried that this change will affect the native branch (so I've added Andrea to the CCs), and 2) I'm not sure whether to use `derived-mode-p' or not in the `M-x' default predicate: (defun command-for-mode (symbol) "Say whether SYMBOL should be offered as a completion. This is true if it's a command and the command modes match the current major mode." (and (commandp symbol) (or (null (command-modes symbol)) (member major-mode (command-modes symbol))))) `derived-mode-p' would be more accurate, but is also kind of slow? Hm... pre-compute stuff? Cache? Hm... -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no