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 20:15:23 +0200 Message-ID: <878udqbozo.fsf@gmail.com> References: <87lhhrxeg2.fsf@gmail.com> <87oammn75z.fsf@gmail.com> <87bnimn4pp.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1429294879 24323 80.91.229.3 (17 Apr 2015 18:21:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 17 Apr 2015 18:21:19 +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 20:21:12 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 1YjAt5-0003Ya-Kd for ged-emacs-devel@m.gmane.org; Fri, 17 Apr 2015 20:21:11 +0200 Original-Received: from localhost ([::1]:42988 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YjAt4-00055n-Tn for ged-emacs-devel@m.gmane.org; Fri, 17 Apr 2015 14:21:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38429) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YjAsu-0004tS-3p for emacs-devel@gnu.org; Fri, 17 Apr 2015 14:21:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YjAsp-0004Fm-11 for emacs-devel@gnu.org; Fri, 17 Apr 2015 14:21:00 -0400 Original-Received: from mail-wg0-x235.google.com ([2a00:1450:400c:c00::235]:36844) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YjAso-0004FT-Qm for emacs-devel@gnu.org; Fri, 17 Apr 2015 14:20:54 -0400 Original-Received: by wgsk9 with SMTP id k9so121334635wgs.3 for ; Fri, 17 Apr 2015 11:20:54 -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=B4yR0Zb65xSSKw4U9Iht4ewE8wR1yPx6PVmKSZCCEbU=; b=E+7jEAKi7h/mpUxP/Fb/yggXzGtY5App+Cy8cvjuym9CH7KgXLUzBd7XV7ETl0DmqJ mlWtwRmH0CJPgZ6ZYaCJhXE1toMixdsS5VwiTbNbJIg2XDmJnaj4Y72WW5mfxHjmh4sE SyWW5p0QY3Qf4v0xeX71l/4hOtVWC5WCtsUiceJdSdQYA6odhdaEE9MdrADVPlxZfwYP BBQDk+y8V3s+mpB9NbYkSmxZAvCOlAYnsY1cnxbrYT5T/6NBE1rp+2t+a41R0z6wftp5 Sh+79pgAHOV+eVHnVsIu8U+QBV5lp7QnRGsYTgmSufCyhz4XUW/zq1DTZ9evDuQb+Znu aoHQ== X-Received: by 10.194.185.68 with SMTP id fa4mr8115581wjc.111.1429294854218; Fri, 17 Apr 2015 11:20:54 -0700 (PDT) Original-Received: from firefly (dyn069045.nbw.tue.nl. [131.155.69.45]) by mx.google.com with ESMTPSA id dx11sm15672038wjb.23.2015.04.17.11.20.53 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 17 Apr 2015 11:20:53 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Fri, 17 Apr 2015 14:04:13 -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::235 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:185535 Archived-At: Stefan Monnier writes: >>> M-x ivy-mode RET >>> M-x helm-mode RET >>> M-x ivy-mode RET >>> >>> You should now have helm-mode active and working properly, yet with your >>> current code, helm-mode will be "enabled by inactive". If you use >>> add/remove-function this case will be handled correctly. >> I meant to give an example of how `add-function' helps here. > > That's exactly what the example does, AFAIK. > >> Also, with your sequence of commands, starting from nothing, we have >> ivy-mode set to "t" and having the `completing-read-function' > > No, the idea of this example is that after the second line ivy-mode is > still t but completing-read-function is now set to use the helm version. > After the 3rd line, with `setq' completing-read-function would be reset > to the default value, whereas with remove-function > completing-read-function would still continue using the helm version. > >> I've also seen this type of code: ido-vertical-mode stores the variable >> `ido-decorations' of ido-mode and modifies it. When you turn off >> ido-vertical-mode, it restores `ido-decorations'. But what if other >> code has changed `ido-decorations' in the meantime, while >> ido-vertical-mode is still on? Any way you put it, the result is >> incorrect. Unless there's a robust system behind it all that manages the >> `ido-decorations' variable. > > That's exactly what add-function aims to solve. You mean to use code like this: (if ivy-mode (add-function :override completing-read-function 'ivy-completing-read) (remove-function completing-read-function 'ivy-completing-read)) This can solve the problem if all packages adhere to this rule simultaneously. I mean that now this sequence works: - helm-mode - ivy-mode - ivy-mode But this sequence doesn't: - ivy-mode - helm-mode - helm-mode Since which Emacs version is `add-function` available? Would you recommend the above approach, possibly in the manual? Oleh