From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: Any exceptions for the 15-line rule? Date: Sun, 05 May 2013 11:31:10 +0400 Message-ID: <51860ABE.8090003@yandex.ru> References: <87d2tgu0ad.fsf@yandex.ru> <51849C29.2040201@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1367739087 30628 80.91.229.3 (5 May 2013 07:31:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 5 May 2013 07:31:27 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun May 05 09:31:26 2013 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 1UYtPq-0006DR-1H for ged-emacs-devel@m.gmane.org; Sun, 05 May 2013 09:31:26 +0200 Original-Received: from localhost ([::1]:38082 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UYtPp-0004MJ-Ks for ged-emacs-devel@m.gmane.org; Sun, 05 May 2013 03:31:25 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:35251) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UYtPi-0004L6-Gb for emacs-devel@gnu.org; Sun, 05 May 2013 03:31:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UYtPd-0004ne-MT for emacs-devel@gnu.org; Sun, 05 May 2013 03:31:18 -0400 Original-Received: from mail-la0-x229.google.com ([2a00:1450:4010:c03::229]:40270) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UYtPd-0004nO-FI for emacs-devel@gnu.org; Sun, 05 May 2013 03:31:13 -0400 Original-Received: by mail-la0-f41.google.com with SMTP id fn20so2550080lab.14 for ; Sun, 05 May 2013 00:31:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding:x-antivirus:x-antivirus-status; bh=6G9ct8+8JdD0+o/BFdAcdJRocVd8CE/ADSk/BBZn4EQ=; b=DC+AoVHXnkcX+2oraxaFWmTr2AhD8SqHVzC0AEIA2s7oQOJwDEjp6CbOzSl/Puo12P aiVeWkFIHOVujOHevQi6qZ4mmSP6qR6WMO8YqTmVTDdEMlZVQW9uupVRxiymxjIJcX9W sL0G+6QsnniKKrTAD/2VrborweR3G+hKIasDb+wj45VEap7kDT6uXXkbQ8/3k+6b/bbt TnzaObspOfqOvoL3NxUdqoB2Mpu+Y2+FmSaU8xbSGKGsQpGRH6lEDIcA7jNQ+vfGXEGs 5+hIeYEjlFJRdg2pvd9OCN9A3Ce+FxaAveOj8R/tXgq0cqBPOHNffBNZPYYp/CseIw+r PE4g== X-Received: by 10.112.160.226 with SMTP id xn2mr6328445lbb.16.1367739072446; Sun, 05 May 2013 00:31:12 -0700 (PDT) Original-Received: from [127.0.0.1] ([178.252.98.87]) by mx.google.com with ESMTPSA id r9sm6652931lbr.3.2013.05.05.00.31.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 05 May 2013 00:31:11 -0700 (PDT) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 In-Reply-To: X-Antivirus: avast! (VPS 130504-1, 04.05.2013), Outbound message X-Antivirus-Status: Clean X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::229 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:159322 Archived-At: On 05.05.2013 9:02, Stefan Monnier wrote: >>> - (with-temp-buffer >>> + (buf (get-buffer-create "*clang-output*")) >>> + (with-current-buffer buf (erase-buffer)) >>> + (with-current-buffer buf >> So, I've merged the patch into Git repo with some modifications, but looks >> like the above change is perfectly justified: the new code uses >> call-process-region', which takes the region from the current buffer, so >> using it with `with-temp-buffer' doesn't seem possible. > > I must be missing something because I don't see why that > changes anything. Before, we were just calling `call-process', which uses one buffer, for stdout. So we created a temp buffer, collected program output in it, parsed that into our data structures and the buffer could be discarded. Now, `call-process-region' needs two buffers, for stdin and stdout. That means that the current buffer has to be the buffer the user's editing, or at least contain its contents. So we could, I guess, save (buffer-string) to a local var, switch to a temp buffer, insert it and then call `call-process-region' with non-nil DELETE argument (or save the current point value to start parsing output from it), but this may be slow for large files (not sure), and using a separate names buffer for output is more natural. And using `with-temp-buffer' to create a non-current buffer (for output) is trickier: save current buffer to a local var, `with-temp-buffer', save *that* buffer in another `let', use `with-current-buffer' with the first var, and then pass the second var to `call-process-region'.