From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Samer Masterson Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] switch to file buffer from command line args regardless of `initial-buffer-choice' Date: Fri, 7 Aug 2015 10:42:09 -0700 Message-ID: References: <1425283676.2563.0@mail.samertm.com> <87fv7ge61j.fsf@f-box.i-did-not-set--mail-host-address--so-tickle-me> <87lhdsmndf.fsf@gmx.us> <874mkdjwt8.fsf@gmx.us> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7b6788bedb2749051cbc2814 X-Trace: ger.gmane.org 1438969373 26365 80.91.229.3 (7 Aug 2015 17:42:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 7 Aug 2015 17:42:53 +0000 (UTC) Cc: Rasmus , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Aug 07 19:42:47 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 1ZNlfL-0008Re-50 for ged-emacs-devel@m.gmane.org; Fri, 07 Aug 2015 19:42:47 +0200 Original-Received: from localhost ([::1]:50337 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNlfK-0003RV-C6 for ged-emacs-devel@m.gmane.org; Fri, 07 Aug 2015 13:42:46 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55713) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNlf5-0003RA-Ms for emacs-devel@gnu.org; Fri, 07 Aug 2015 13:42:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZNlf4-0001jA-3S for emacs-devel@gnu.org; Fri, 07 Aug 2015 13:42:31 -0400 Original-Received: from mail-pa0-x22e.google.com ([2607:f8b0:400e:c03::22e]:35764) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNlf3-0001i8-On for emacs-devel@gnu.org; Fri, 07 Aug 2015 13:42:30 -0400 Original-Received: by pabxd6 with SMTP id xd6so74456243pab.2 for ; Fri, 07 Aug 2015 10:42:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=+fXK1Lmp9LCWOpmsihl4RF65nCuOpNqPezJVUN9vXWQ=; b=M024R6dSbv9aazi8rSEPtpwmk+b1+czGLHfzlsrwlatCyQeGehc61n/jLPUIOjwiUG ky2w/OCyDFL5CGmsCLimGdkG7SkIZ30Mh7wPqmnXDxhbWerI1uksKOMirEqxRVOW4jPN 6TOLlqk4fgaStbebjxGj56nuwdBAfiQSi0X06PbNfj5+p8zcYsst98yNpBFWAF0RePnz vKoEHvxeBmSCUhuk4EXjSFW9y35JPA1ecQiItDUdfwtDZvJ6qQrUFni7n6yLAtPe7VrK Vi3drEdB2WOqvzsCXzefQ9h8gzbmu97jVw8a19GPzsBJk+k59Pq+0jTyyYy2GrQH/ijO ad+Q== X-Received: by 10.66.150.169 with SMTP id uj9mr16747471pab.125.1438969348431; Fri, 07 Aug 2015 10:42:28 -0700 (PDT) Original-Received: by 10.70.133.202 with HTTP; Fri, 7 Aug 2015 10:42:09 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c03::22e 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:188576 Archived-At: --047d7b6788bedb2749051cbc2814 Content-Type: text/plain; charset=UTF-8 The problem is that, for invocations like emacs --no-init-file --batch --file /tmp/foo --eval="(message \"%s\n\" (buffer-file-name))" the evaled statements prints "nil" instead of "/tmp/foo" because file buffer display was delayed until the end of the command line parsing in my previous patch. The patch above should return Emacs to its old behavior where files were opened as soon as they were seen on the command line. Is there a way of making the file buffer the current buffer without displaying it, though? That would be ideal, because there would be less overlap with the display logic at the bottom of the function that determines which buffers should be displayed, and in what order. With the patch above, if only a single file is given then it is first displayed with `find-file', and then it is displayed again because it was added to `displayable-buffers'. This is redundant, but probably not harmful. -s On Fri, Aug 7, 2015 at 8:33 AM, Stefan Monnier wrote: > > - (buf (find-file-noselect file))) > > + ;; Call `find-file' instead of > `find-file-noselect' > > + ;; so that the file buffer can be used with > "--eval". > > + (buf (find-file file))) > > Using find-file means the buffer is not only selected as current-buffer > but is also *displayed* in the selected window (which can have all kinds > of undesirable side-effects). > > Why do you think it's better? I can't seem to find the description of > the problem this is trying to solve. > > > Stefan > --047d7b6788bedb2749051cbc2814 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
The problem is that, for invocations like
=C2=A0 emacs --no-init-file --batch --file /tmp/foo --eval=3D"(m= essage \"%s\n\" (buffer-file-name))"

the evaled= statements prints "nil" instead of "/tmp/foo" because = file buffer display was delayed until the end of the command line parsing i= n my previous patch. The patch above should return Emacs to its old behavio= r where files were opened as soon as they were seen on the command line.
Is there a way of making the file buffer the current buffer with= out displaying it, though? That would be ideal, because there would be less= overlap with the display logic at the bottom of the function that determin= es which buffers should be displayed, and in what order. With the patch abo= ve, if only a single file is given then it is first displayed with `find-fi= le', and then it is displayed again because it was added to `displayabl= e-buffers'. This is redundant, but probably not harmful.

<= div>-s

On Fri, Aug 7, 2015 at 8:33 AM, Stefan Monnier <<= a href=3D"mailto:monnier@iro.umontreal.ca" target=3D"_blank">monnier@iro.um= ontreal.ca> wrote:
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(buf = (find-file-noselect file)))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0;; Call `find-file' instead of `find-file-n= oselect'
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0;; so that the file buffer can be used with &qu= ot;--eval".
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0(buf (find-file file)))

Using find-file means the buffer is not only selected as current-buf= fer
but is also *displayed* in the selected window (which can have all kinds of undesirable side-effects).

Why do you think it's better?=C2=A0 I can't seem to find the descri= ption of
the problem this is trying to solve.


=C2=A0 =C2=A0 =C2=A0 =C2=A0 Stefan

--047d7b6788bedb2749051cbc2814--