From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chris Seberino Newsgroups: gmane.emacs.help Subject: Re: How automatically answer same 2 questions that always pop up for a certain Emacs command (python-mode's python-shell-send-region command) Date: Thu, 18 Dec 2014 04:53:57 -0800 (PST) Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1418907331 12904 80.91.229.3 (18 Dec 2014 12:55:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 18 Dec 2014 12:55:31 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Dec 18 13:55:24 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 1Y1abz-00005d-2Q for geh-help-gnu-emacs@m.gmane.org; Thu, 18 Dec 2014 13:55:23 +0100 Original-Received: from localhost ([::1]:53670 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1aby-0000HU-8i for geh-help-gnu-emacs@m.gmane.org; Thu, 18 Dec 2014 07:55:22 -0500 X-Received: by 10.236.22.106 with SMTP id s70mr1618850yhs.7.1418907237728; Thu, 18 Dec 2014 04:53:57 -0800 (PST) X-Received: by 10.182.76.70 with SMTP id i6mr207obw.35.1418907237552; Thu, 18 Dec 2014 04:53:57 -0800 (PST) Original-Path: usenet.stanford.edu!s7no8855543qap.1!news-out.google.com!h6ni559igv.0!nntp.google.com!h15no24976846igd.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=74.193.13.167; posting-account=VkuUtQkAAADKqMjRUmZTNs7a8uCSNNy2 Original-NNTP-Posting-Host: 74.193.13.167 User-Agent: G2/1.0 Injection-Date: Thu, 18 Dec 2014 12:53:57 +0000 Original-Xref: usenet.stanford.edu gnu.emacs.help:209379 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:101658 Archived-At: I tried to run the function below in Python mode after binding it to F2 as shown below... (global-set-key [f2] (lambda () (interactive) (python-shell-get-or-create-process-noask) (switch-to-buffer "*Python*"))) When I tried it I got the following error... Wrong number of arguments: (lambda (old &optional _cmd _dedicated show) (funcall old (python-shell-parse-command) t show)), 0 On Wednesday, December 10, 2014 3:18:05 PM UTC-6, John Mastro wrote: > Hi, > > Chris Seberino wrote: > > How automatically answer same 2 questions that always pop up for > > python-mode's python-shell-send-region command? > > > > python-shell-send-region asks for python interpreter to use and > > question about separate processes. I don't want to always answer that. > > > > Thanks! > > > > cs > > If I understand correctly, I think this will do what you want. > > (defun python-shell-get-or-create-process-noask > (old &optional _cmd _dedicated show) > (funcall old (python-shell-parse-command) t show)) > > (advice-add 'python-shell-get-or-create-process > :around > #'python-shell-get-or-create-process-noask) > > Hope that helps! > > -- > john