From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: John Wiegley Newsgroups: gmane.emacs.devel Subject: Making `interactive' conditional (was: Leaving out non-applicable commands on Mx) Date: Sat, 09 Jan 2016 12:55:28 -0800 Message-ID: References: <87mvszdp6b.fsf@gnus.org> <8737u9kv6f.fsf@russet.org.uk> <87fuy7hdc6.fsf_-_@wanadoo.es> <87bn8vh8q4.fsf@wanadoo.es> <4002fc97-5629-4367-8b8f-48b659fefdce@default> Reply-To: John Wiegley NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Trace: ger.gmane.org 1452372952 11957 80.91.229.3 (9 Jan 2016 20:55:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 9 Jan 2016 20:55:52 +0000 (UTC) Cc: =?utf-8?Q?=C3=93scar?= Fuentes , Drew Adams , Emacs developers To: Yuri Khan Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jan 09 21:55:44 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aI0Y4-0008Na-1o for ged-emacs-devel@m.gmane.org; Sat, 09 Jan 2016 21:55:44 +0100 Original-Received: from localhost ([::1]:42964 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aI0Y3-0007fL-3L for ged-emacs-devel@m.gmane.org; Sat, 09 Jan 2016 15:55:43 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50636) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aI0Xy-0007f3-NH for emacs-devel@gnu.org; Sat, 09 Jan 2016 15:55:39 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aI0Xv-00036y-H3 for emacs-devel@gnu.org; Sat, 09 Jan 2016 15:55:38 -0500 Original-Received: from mail-pa0-x22d.google.com ([2607:f8b0:400e:c03::22d]:35908) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aI0Xv-00036s-8d for emacs-devel@gnu.org; Sat, 09 Jan 2016 15:55:35 -0500 Original-Received: by mail-pa0-x22d.google.com with SMTP id yy13so207986887pab.3 for ; Sat, 09 Jan 2016 12:55:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:in-reply-to:date:message-id:references :user-agent:reply-to:mail-followup-to:mime-version:content-type; bh=F7gtn8j5qAJ+fiwq3PRIfs+Pc8b9SIAy60R0mujB1ks=; b=i4RC+wkYblLa7otgyy1ECAAROzuyvBqVoyMB44ZLYZfKo9Mizd5hV7hFG3l0CQRyfM F2PqF917em1bggVGdQfBmNt6Y9DUAA0g35kRjRBd8I2cHk7CoYfKoFE7ycmq6Ollp25K bwI24rZBp3ukhVMjlkjeLLkmMAmh+WT+CqFKU/HWwECMVMK6cuB949x754Jk/kOu36n3 P5Kn3l+rc76HF+ZyddDKqPwGx5mqaN55trNvK3gBBFeOhUQYArqTmVIhkQI/ESMA43KX LhA9GfLTjEetb57XSuBUw9CiBSuC9DgYn9ghBtcUtLXH3Cran/utqQJjzrFSx0pF7sxP sowQ== X-Received: by 10.66.218.225 with SMTP id pj1mr164891225pac.40.1452372934485; Sat, 09 Jan 2016 12:55:34 -0800 (PST) Original-Received: from Vulcan.local (76-234-68-79.lightspeed.frokca.sbcglobal.net. [76.234.68.79]) by smtp.gmail.com with ESMTPSA id qz9sm22927165pab.39.2016.01.09.12.55.32 (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jan 2016 12:55:32 -0800 (PST) X-Google-Original-From: "John Wiegley" Original-Received: by Vulcan.local (Postfix, from userid 501) id 0FC5B1232B70B; Sat, 9 Jan 2016 12:55:32 -0800 (PST) In-Reply-To: (Yuri Khan's message of "Sat, 9 Jan 2016 15:05:50 +0600") User-Agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/24.5 (darwin) Mail-Followup-To: Yuri Khan , Drew Adams , =?utf-8?Q?=C3=93scar?= Fuentes , Emacs developers X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c03::22d X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:197932 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable >>>>> Yuri Khan writes: > Emacs already contains a feature that filters out many defined functions > from M-x. It=E2=80=99s called (interactive). Functions that are not decla= red > interactive are not offered as completion candidates, and in fact cannot = be > executed with M-x. OK Yuri, now you've got me excited. Let's not talk about "filtering M-x"; let's talk about making `interactive' conditional. The former is a UI conce= rn, while the latter I consider a core API issue. Right now, functions are interactive if declared with `interactive', and not otherwise. The suggestion at hand is to allow `interactive' forms to become conditional -- possibly in multiple ways. I like this concept, and think the right place for it is indeed in core. The question is how to declare such conditionality. We can do this rather easily by accepting new keyword arguments to `interactive': (interactive "sDirectory: " [:mode foo-mode] [:when ]) This way, all new modes can take advantage of this support as it becomes available. I've already tested on 24.5, and keyword arguments are silently ignored by present-day GNU Emacs. This gives us transparent compatibility in both directions. We could also do it with (declare); I'm open to that too, = and it also gives us such compatibility. At first, I imagine nothing delivered with Emacs will be conditional, becau= se it requires annotating packages retroactively. We could alleviate some of t= hat by writing code to automatically consider every interactive function *witho= ut an autoload token* as being conditional on any modes defined in the same package (likely determined by prefix matching). The use of such automation would be configurable and off by default, at least until we believe it's re= ady for prime-time. Thus, proper UI behavior for M-x falls out by design, and we get to make use of conditionality for other purposes, such as better errors when command functions are called outside their expected environment. I'm open to a feature branch implementing such conditionality, as a candida= te for merging to master. As described above, I expect the C code impact to be fairly minimal, and the changes to `M-x' to also be minor. The automation logic seems like the trickiest part, as it would have to happen whenever a feature is loaded. =2D-=20 John Wiegley GPG fingerprint =3D 4710 CF98 AF9B 327B B80F http://newartisans.com 60E1 46C4 BD1A 7AC1 4BA2 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGcBAEBCgAGBQJWkXPAAAoJEMFE2PTxn+YwdgMMAM9BIvgRGnHLPEKffdv8oLKF SijO9oUngV+K1/0wlT3V+VBU41iJgJX6Pt5D0010iKbsi7cJRvEBYDMN+d6V5Fie GWuTbxskp/YVg1TxhFd7uUdWkbmltTu9ZFDim1IE6yx0i+3u9Nggryd50dMB6qoQ GNBh5EgSkne7LhXYA8GDPN2+HrnT2ekqbPoDNEK+LhDZFOGcAhzL1zhGxktjdB4f Lehw9SJn5MUSFhZ1cv44srQdXdFzwgqijx5T7XrQKMB7wb7qE+hHBVWWzewCKJzz KK4My77qeeamH/meo3MQ5qEtaHMDj2JAlatsBsS8iSmh+J5KluoNsFduxOfPcj0/ V/+TET2XdtpqKppODVhX/F6fvRws2VOhVjutFAaPoNbt7U2mkU2P0hdLqjEoSo60 0DdAd4kaVIdne1NDTOYJVPFxvQEePN40LVjJMGTJV+Zt3ZrH8JYsFwOU/Z0tsaWc s/30Iqk9qo8Tk0hQmdDJv3vd+UMS0erzLF4s2t1t3Q== =Kn8M -----END PGP SIGNATURE----- --=-=-=--