From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Oleh Krehel Newsgroups: gmane.emacs.devel Subject: Re: Questions about the `completing-read-function' interface Date: Fri, 17 Apr 2015 16:47:20 +0200 Message-ID: <87oammn75z.fsf@gmail.com> References: <87lhhrxeg2.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1429282405 29766 80.91.229.3 (17 Apr 2015 14:53:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 17 Apr 2015 14:53:25 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Apr 17 16:53:21 2015 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 1Yj7dw-00017t-OM for ged-emacs-devel@m.gmane.org; Fri, 17 Apr 2015 16:53:20 +0200 Original-Received: from localhost ([::1]:41912 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yj7dr-0000du-BJ for ged-emacs-devel@m.gmane.org; Fri, 17 Apr 2015 10:53:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39164) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yj7dZ-0000Zb-N3 for emacs-devel@gnu.org; Fri, 17 Apr 2015 10:52:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yj7dU-0005xY-BU for emacs-devel@gnu.org; Fri, 17 Apr 2015 10:52:57 -0400 Original-Received: from mail-wg0-x236.google.com ([2a00:1450:400c:c00::236]:36514) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yj7dU-0005xL-2C for emacs-devel@gnu.org; Fri, 17 Apr 2015 10:52:52 -0400 Original-Received: by wgsk9 with SMTP id k9so115623813wgs.3 for ; Fri, 17 Apr 2015 07:52:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=wvbBg7HreQqoPg3zlrNzIVSRwv8cjfsthR53N+YQnYM=; b=TTKboPN64B3KjGyvwQmj2KBqzDLq+MFxuTXWfmzgF7H/I9RH0CHLKMevPCpNd08bCW B+Zi1qC21PJIBbIjsdIC29vJxWgozV6byBl9fe1AkXuOiHLRD+40NEdTHDM9Yrt8xxAW bHGKIQcURDiRMkLrBcTFEhWcAd/a9tpg2O/epaC+IkUg5xvZJM/JdK1qi6898GhmwUTp Uz5i0eFkLp54GJt9DE0760++FyFm3Fel0LBok3EsBPOJT0Bt8qCNtsqBh5djcVRAWfh5 xUAZ8A7gvzd58ssWs4UAT8sykxo8v5JkBdfrUPGT3EdA9hn5K5Q6V2mNu01n7KN+X3sf 8WmQ== X-Received: by 10.194.77.230 with SMTP id v6mr6892812wjw.25.1429282370645; Fri, 17 Apr 2015 07:52:50 -0700 (PDT) Original-Received: from firefly (dyn069045.nbw.tue.nl. [131.155.69.45]) by mx.google.com with ESMTPSA id dg8sm14985741wjc.9.2015.04.17.07.52.50 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 17 Apr 2015 07:52:50 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Fri, 17 Apr 2015 10:18:35 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c00::236 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:185527 Archived-At: Stefan Monnier writes: >> I'd like to know, if a function calls `completing-read', should the >> members of DEF be inside COLLECTION? I haven't found info on this in the >> doc, and `completing-read-default' doesn't seem to handle DEF not being >> in COLLECTION. > > So far we haven't tried to enforce this and if require-match is not set, > then I don't think we should require it. I agree for the case of (memq require-match '(nil confirm confirm-after-completion)) What about the other cases? >> As second question is about this interface: >> (setq completing-read-function 'foo) >> We've accumulated a bunch of packages that call this: icomplete-mode, >> helm-mode, icy-mode, ivy-mode. > > Actually, icomplete-mode does not touch completing-read-function. Oops, I forgot. It does some weird thing with the hook instead. >> If these functions are called in succession, each of them will think >> that they are on, however, the resource (`completing-read-function') >> will belong only to the last one. > > Indeed. > >> Maybe we could have this type of interface: >> (set-completing-read-function 'foo callback) >> So that each time `set-completing-read-function' is called, the current >> minor mode is properly shut down in the callback. > > I don't think it's worth the trouble. `completing-read-function' should > reflect the user's explicit choice, and if the user enables > several of those modes at the same time, she gets what she deserves. I think it could be handled better without any disadvantage: 1. all minor modes subscribe with `set-completing-read-function' 2. user calls M-x mode-1. mode-1 is active and subscribes. 3. user calls M-x mode-2. Emacs sends a message to mode-1 to shut down. mode-2 is active and subscribes. 4. and so on. There's no way to end up in a worse state than is now. And the modes that don't subscribe simply don't get the benefit of knowing that they don't own the resource any more. Just like it is now. > IOW I think it's OK if ivy-mode thinks it's enabled and yet it is not > active because some other mode has overridden completing-read-function. It's harmless in this case. It just causes an annoyance for the user to do M-x ivy-mode twice before it's actually active. There are other contested resources besides `completing-read-function', like keymaps or windows. For example, hydra messes with `input-method-function', a resource that belongs to `key-chord-mode'. > I agree that there are potential for actual problems if the > completing-read-function is not properly reverted when the modes are > disabled. For that reason I recommend you use `add-function' and > `remove-function' rather than `setq'. I don't understand. Can you give an example? Oleh