From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.help Subject: Re: How to avoid y-or-n-p in a program? Date: Wed, 12 Mar 2014 17:14:28 +0100 Message-ID: <87zjkvz95n.fsf@gnu.org> References: <87y50fqvh2.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1394640897 11343 80.91.229.3 (12 Mar 2014 16:14:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 12 Mar 2014 16:14:57 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Thorsten Jolitz Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Mar 12 17:15:04 2014 Return-path: Envelope-to: geh-help-gnu-emacs@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 1WNlo7-0005v6-Q6 for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Mar 2014 17:15:03 +0100 Original-Received: from localhost ([::1]:33437 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNlo7-0003SW-BE for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Mar 2014 12:15:03 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46482) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNlnn-0003NM-Tt for help-gnu-emacs@gnu.org; Wed, 12 Mar 2014 12:14:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WNlng-0005xl-GK for help-gnu-emacs@gnu.org; Wed, 12 Mar 2014 12:14:43 -0400 Original-Received: from deliver.uni-koblenz.de ([141.26.64.15]:52286) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNlng-0005vo-BN for help-gnu-emacs@gnu.org; Wed, 12 Mar 2014 12:14:36 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by deliver.uni-koblenz.de (Postfix) with ESMTP id A40CB1A85DD; Wed, 12 Mar 2014 17:14:34 +0100 (CET) X-Virus-Scanned: amavisd-new at uni-koblenz.de Original-Received: from deliver.uni-koblenz.de ([127.0.0.1]) by localhost (deliver.uni-koblenz.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LUmbpiCgwrTv; Wed, 12 Mar 2014 17:14:34 +0100 (CET) X-CHKRCPT: Envelopesender noch tsdh@gnu.org Original-Received: from thinkpad-t61 (tsdh.uni-koblenz.de [141.26.67.142]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by deliver.uni-koblenz.de (Postfix) with ESMTPSA id 4C8F41A85DC; Wed, 12 Mar 2014 17:14:34 +0100 (CET) In-Reply-To: <87y50fqvh2.fsf@gmail.com> (Thorsten Jolitz's message of "Wed, 12 Mar 2014 16:37:13 +0100") User-Agent: Gnus/5.13001 (Ma Gnus v0.10) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 141.26.64.15 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:96460 Archived-At: Thorsten Jolitz writes: Hi Thorsten, > when in a program function A calls another (external) function B that > asks the user a y-or-n-p question, and you want to avoid that and > instead code in function A that the answer is always Y, so that the > prompt never shows up - how do you do that? In very recent emacs versions, you can use `cl-letf' for that purpose: --8<---------------cut here---------------start------------->8--- (defun b () (if (y-or-n-p "do it?") :done :not-done)) (defun a () (cl-letf (((symbol-function #'y-or-n-p) (lambda (&rest ignore) t))) (b))) (a) ;; C-x C-e => :done (and no query) --8<---------------cut here---------------end--------------->8--- Bye, Tassilo