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: Sun, 14 Feb 2021 14:30:33 +0100 Message-ID: <87y2fqepza.fsf_-_@gnus.org> References: <8ed9b43502ae1480e06b@heytings.org> <87wnvfenry.fsf@gnus.org> <87blcrdlqf.fsf@gnus.org> <87v9aydg3f.fsf@gnus.org> <83y2fuheph.fsf@gnu.org> <87im6yd4sz.fsf@gnus.org> <8735y2y44f.fsf@gnus.org> <87mtwajua4.fsf@telefonica.net> <87eehmwfeg.fsf@gnus.org> <87blcqjq45.fsf@telefonica.net> <875z2ywbvm.fsf@gnus.org> <87pn16mehu.fsf@gnus.jao.io> <87o8gpvdfd.fsf@gnus.org> <87a6s9mf87.fsf@gnus.jao.io> <87o8goryuj.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="33274"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Feb 14 14:33:14 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 1lBHWT-0008XD-Ae for ged-emacs-devel@m.gmane-mx.org; Sun, 14 Feb 2021 14:33:13 +0100 Original-Received: from localhost ([::1]:33790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBHWS-0001yP-AL for ged-emacs-devel@m.gmane-mx.org; Sun, 14 Feb 2021 08:33:12 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBHUB-00010t-AR for emacs-devel@gnu.org; Sun, 14 Feb 2021 08:30:51 -0500 Original-Received: from quimby.gnus.org ([2a01:4f9:2b:f0f::2]:48782) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBHU8-0005Zc-PO for emacs-devel@gnu.org; Sun, 14 Feb 2021 08:30:51 -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:To:From:Sender:Reply-To:Cc: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=g/NaQQQ6bFqj+6bpz9Uyh821sj/8VCSH5NfJsg0kw6o=; b=cRuTsASTNz47nIk1yLjfCiEtTJ xDvM/y2WgncLL8IpxYxgoMH9yZe3LlSBqQIKRvNuQKTKnpTOtcWyMNp3j/JzAv6rsjQt5Eh5zObPG XS+zAQWH7SCgFxGxVi3lqiDHhMIHKrKCQpo1L/NtBSyGWzUGtcRwCehTreOOnhtEPRbc=; 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 1lBHTw-0007TR-6o for emacs-devel@gnu.org; Sun, 14 Feb 2021 14:30:46 +0100 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAD1BMVEVONSCYbDjGnVzo w4/////FvwTCAAAAAWJLR0QEj2jZUQAAAAd0SU1FB+UCDg0XOUIcmw8AAAGiSURBVDjLZVSJccQw CASnAcE1YFADkdx/b1nQY/viyUQMK2BZ0BEVFilMhEP8VJ8ficE2YOkylfmR93pdHS4cMD4Bi7CQ WlzMv4ywvM8WuWl+UWwYhcKJC2XW6CNVFk+EVvG2WF0ZiWoohdo3kBGUxYNVUgijXkR3aUWkScao b/dgER0E40E1RJH4N5gISnvP2xytzVtxSWcNlkhbdjWU0Wt3KshII1sWG3cKF9YQcZCRHc1O2Yav CBoG1xp9X2e1slOFVa/0A0gKyZ6Q9cCcEmg+IrIn/6UDU+w5wAkEf5JPCaB5qzHx1YiTSzuq1waF VA6jHQFJDzuPBrsaPwDSzn6yCYosgHJ9xFhDEhCzpUTSdWG3GFMFUGjTZTlZ4wAVWxotEcVKyvDw L9Ei12MgW3Z9eOfsbxYPQNdewXwBsVvLLnu1ie9NjLXiaRWI/QAADQFZ2N8A1MzHIpD6DaDgSXvZ b+Do8RTjNX4BKrnNRnn4TVJyIR/HluENLPY8gTzs1gp+15kcB5jrouTz/X/R/fF/3+oaSSLRNyDx o2Mx9o39AQbITJimC/42AAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDIxLTAyLTE0VDEzOjIzOjU2KzAw OjAwhDk3IwAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMS0wMi0xNFQxMzoyMzo1NiswMDowMPVkj58A AAAASUVORK5CYII= X-Now-Playing: Bob Dylan's _Blonde On Blonde_: "Absolutely Sweet Marie" In-Reply-To: (Drew Adams's message of "Sun, 14 Feb 2021 02:40:38 +0000") 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:264698 Archived-At: I've now separated all the related changes into a series of hopefully sensible patches, and pushed to the trunk. To summarise: (defun foo () (interactive "p" foo-mode)) is now valid, and works for both major and minor modes. Using this is, of course, backwards incompatible, and moreover, produces bytecode that's not backwards compatible either. (If it's not used, the .elc file will still be backwards compatible.) The general form is: (defun foo () (declare (completion PREDICATE)) (interactive "p")) Where PREDICATE is a function, and can be pretty much anything. It's called with the symbol and the current buffer as predicates. So that can be used for mode filtering, too, but it's kinda cumbersome, so a short version is also provided: (defun foo () (declare (modes foo-mode)) (interactive "p")) This expands to the first version, and if you're writing code that should still work in older Emacs versions, these latter two forms has to be used. I've tagged up eww and gnus/gnus*.el, so to look at the effect, try emacs -Q -l eww M-x eww TAB in a version before and after this patch set. The new variable 'read-extended-command-predicate' controls what's included, and the default value is to filter out commands that's not applicable to the current buffer. Now go fortheth and marketh uppeth. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no