From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Shift selection using interactive spec Date: Sun, 30 Mar 2008 00:12:43 -0400 Message-ID: References: <87k5k69p92.fsf@stupidchicken.com> <87od9e9gnx.fsf@stupidchicken.com> <87skyo5bvk.fsf@stupidchicken.com> <87skynrin5.fsf@stupidchicken.com> <87iqzju0lq.fsf@kfs-lx.rd.rdm> <851w5xx5ya.fsf@lola.goethe.zz> <87ve3993dt.fsf@jurta.org> <47EA37C7.7080502@gmail.com> <878x050yp0.fsf@jurta.org> <878x03ybyg.fsf@jurta.org> <871w5upcsc.fsf@jurta.org> <871w5t3svo.fsf@jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1206850382 23075 80.91.229.12 (30 Mar 2008 04:13:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 30 Mar 2008 04:13:02 +0000 (UTC) Cc: lennart.borgman@gmail.com, jared@hpalace.com, rms@gnu.org, emacs-devel@gnu.org To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Mar 30 06:13:33 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JfovE-0004lE-PX for ged-emacs-devel@m.gmane.org; Sun, 30 Mar 2008 06:13:33 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jfouc-0000n5-Uc for ged-emacs-devel@m.gmane.org; Sun, 30 Mar 2008 00:12:54 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JfouZ-0000n0-4f for emacs-devel@gnu.org; Sun, 30 Mar 2008 00:12:51 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JfouW-0000ml-PB for emacs-devel@gnu.org; Sun, 30 Mar 2008 00:12:49 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JfouW-0000mi-JW for emacs-devel@gnu.org; Sun, 30 Mar 2008 00:12:48 -0400 Original-Received: from ironport2-out.pppoe.ca ([206.248.154.182] helo=ironport2-out.teksavvy.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JfouS-00085q-Sx; Sun, 30 Mar 2008 00:12:45 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApsEAKKw7kfO+LLN/2dsb2JhbACBWqZf X-IronPort-AV: E=Sophos;i="4.25,576,1199682000"; d="scan'208";a="17145606" Original-Received: from smtp.pppoe.ca (HELO smtp.teksavvy.com) ([65.39.196.238]) by ironport2-out.teksavvy.com with ESMTP; 30 Mar 2008 00:12:44 -0400 Original-Received: from pastel.home ([206.248.178.205]) by smtp.teksavvy.com (Internet Mail Server v1.0) with ESMTP id KHQ31244; Sun, 30 Mar 2008 00:12:44 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id D281F7FDF; Sun, 30 Mar 2008 00:12:43 -0400 (EDT) In-Reply-To: <871w5t3svo.fsf@jurta.org> (Juri Linkov's message of "Sun, 30 Mar 2008 04:05:31 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:93868 Archived-At: >> As I understand the purpose of this feature is practically to move >> the last expression of the command's body that usually is written as >> >> (if (interactive-p) >> (message "Result of this command is %.0f" return-value) >> (format "%.0f" return-value)) >> >> You have the right idea in mind for what the code would be trying to >> do. But code like that would be a strange way to write it, and in >> practice does seem to occur much if at all. The way I would envision >> this is more like >> >> (if interactive-call >> (message "Result of this command is %.0f" return-value)) >> return-value) >> >> where `interactive-call' is an argument initialized to non-nil >> for an interactive call. >> >> The job of the second arg to `interactive', that I've proposed, would >> be to control how to generate the message in the interactive case. > Then the second arg to `interactive' could be just a lambda > with one argument with the value this function returns, e.g. Yes, and if the use of `lambda' turns out to be a bit heavy, we can provide a handy alternative: if the return-spec is a list but not a function, then take the list as a function call with a missing argument: (defun command () (interactive nil (lambda (ret-val) (message "Result of this command is %.0f" ret-val))) ... (let ((return-value ...)) ... return-value)) => (defun command () (interactive nil (message "Result of this command is %.0f")) ... (let ((return-value ...)) ... return-value)) -- Stefan