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: Wed, 5 Aug 2015 13:46:06 -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=001a11c2337611d502051c967f29 X-Trace: ger.gmane.org 1438817096 31568 80.91.229.3 (5 Aug 2015 23:24:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 5 Aug 2015 23:24:56 +0000 (UTC) To: Rasmus , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Aug 06 01:24: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 1ZN83A-0001Q8-QW for ged-emacs-devel@m.gmane.org; Thu, 06 Aug 2015 01:24:45 +0200 Original-Received: from localhost ([::1]:42733 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZN835-0005xd-1F for ged-emacs-devel@m.gmane.org; Wed, 05 Aug 2015 19:24:39 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44267) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZN5a1-0006OK-DC for emacs-devel@gnu.org; Wed, 05 Aug 2015 16:46:30 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZN5Zz-0000JA-MJ for emacs-devel@gnu.org; Wed, 05 Aug 2015 16:46:29 -0400 Original-Received: from mail-pd0-x229.google.com ([2607:f8b0:400e:c02::229]:34016) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZN5Zz-0000Iy-BI for emacs-devel@gnu.org; Wed, 05 Aug 2015 16:46:27 -0400 Original-Received: by pdber20 with SMTP id er20so22842457pdb.1 for ; Wed, 05 Aug 2015 13:46:26 -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 :content-type; bh=yRThLCHy3O56KIzglK6nP8XLQYVE8dQzp7dRP+NHBQg=; b=yBWPjPAeFqNW4J79WgqJJmjj4dmmZi3NeQ2mUCk7OjbfQSls7niFMvu9Ij2qRs7F0c t54ekOjIc6D79C8dKBRutdJ4uoHKcjmLvYNnNQ5kouYtlL2YcjKRsrnG6OHwx/GXEFVJ oVirYVz2YwL+y+HOkAG6WnRc3jQ4wtLmGvH8+KOm8Hf9iwS9iwktg3f0jUO+3pRrnfdj xXH1eDKQuDQhonBNsjD1o27/yszuZuF16OZq10O8cBJOoJi5Ft9jf3K00uscFvt1qojQ P9SsQvQzBVDEeQ9hdR4I2KxlT5vmklComAaU3cJ1B96aKdMYDHPwi8hhQcsuU3sV5KLq A0Ng== X-Received: by 10.70.90.230 with SMTP id bz6mr22922107pdb.120.1438807586098; Wed, 05 Aug 2015 13:46:26 -0700 (PDT) Original-Received: by 10.70.133.202 with HTTP; Wed, 5 Aug 2015 13:46:06 -0700 (PDT) In-Reply-To: <874mkdjwt8.fsf@gmx.us> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c02::229 X-Mailman-Approved-At: Wed, 05 Aug 2015 19:24:19 -0400 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:188469 Archived-At: --001a11c2337611d502051c967f29 Content-Type: text/plain; charset=UTF-8 The patch below works for me. I think the formatting is off because we're using spaces instead of tabs for indentation now. Do you want to test and install it? Otherwise, I can do that later tonight. Thanks, Samer Modified lisp/startup.el diff --git a/lisp/startup.el b/lisp/startup.el index cfe2269..40f8be8 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -2160,9 +2160,12 @@ A fancy display is used on graphic displays, normal otherwise." ;; which includes files parsed from the command line arguments and ;; `initial-buffer-choice'. All of the display logic happens at the ;; end of this `let'. As files as processed from the command line - ;; arguments, their buffers are prepended to `displayable-buffers' - ;; but they are not displayed until command line parsing has - ;; finished. + ;; arguments, their buffers are prepended to `displayable-buffers'. + ;; In order for options like "--eval" to work with the "--file" arg, + ;; the file buffers are switched to as they are seen on the command + ;; line (so "emacs --file a --file b --eval='(message "%s" + ;; (buffer-name))'" will print "b"), but this does not affect the + ;; final displayed state of the buffers. (let ((displayable-buffers nil)) ;; This `let' processes the command line arguments. (let ((command-line-args-left args-left)) @@ -2194,10 +2197,10 @@ A fancy display is used on graphic displays, normal otherwise." (line 0) (column 0) ;; `process-file-arg' opens a file buffer for `name' - ;; without switching to the buffer, adds the buffer to - ;; `displayable-buffers', and puts the point at - ;; `line':`column'. `line' and `column' are both reset - ;; to zero when `process-file-arg' returns. + ;; and adds the buffer to `displayable-buffers', and + ;; puts the point at `line':`column'. `line' and + ;; `column' are both reset to zero when + ;; `process-file-arg' returns. (process-file-arg (lambda (name) ;; This can only happen if PWD is deleted. @@ -2207,7 +2210,9 @@ nil default-directory" name) (let* ((file (expand-file-name (command-line-normalize-file-name name) dir)) - (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))) (setq displayable-buffers (cons buf displayable-buffers)) (with-current-buffer buf (unless (zerop line) On Wed, Aug 5, 2015 at 1:37 PM, Rasmus wrote: > Samer Masterson writes: > > > The issue here is that my patch uses `find-file-noselect' on the arg for > > --file and delays switching to the file buffer to the end of the > function, > > but all of the other commands, like --eval, execute immediately... My > first > > reaction is to use `find-file' instead of `find-file-noselect', so that > the > > "found" file is selected immediately, and then have the display logic at > > the end, which may be redundant if there is only a single displayable > > buffer. I'll submit a patch later today. > > I actually tried to change it to find-file in my local version of the > file, but it didn't solve the problem. But perhaps I forgot to > byte-compile it. > > Let me know. > > Thanks, > Rasmus > > -- > Evidence suggests Snowden used a powerful tool called monospaced fonts > --001a11c2337611d502051c967f29 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
The patch below works for me. I think the format= ting is off because we're using spaces instead of tabs for indentation = now. Do you want to test and install it? Otherwise, I can do that later ton= ight.

Thanks,
Samer


=C2=A0=C2=A0= =C2=A0 Modified=C2=A0=C2=A0 lisp/startup.el
diff --git a/lisp/startup.el= b/lisp/startup.el
index cfe2269..40f8be8 100644
--- a/lisp/startup.e= l
+++ b/lisp/startup.el
@@ -2160,9 +2160,12 @@ A fancy display is use= d on graphic displays, normal otherwise."
=C2=A0=C2=A0 ;; which inc= ludes files parsed from the command line arguments and
=C2=A0=C2=A0 ;; `= initial-buffer-choice'.=C2=A0 All of the display logic happens at the=C2=A0=C2=A0 ;; end of this `let'.=C2=A0 As files as processed from t= he command line
-=C2=A0 ;; arguments, their buffers are prepended to `di= splayable-buffers'
-=C2=A0 ;; but they are not displayed until comma= nd line parsing has
-=C2=A0 ;; finished.
+=C2=A0 ;; arguments, their = buffers are prepended to `displayable-buffers'.
+=C2=A0 ;; In order = for options like "--eval" to work with the "--file" arg= ,
+=C2=A0 ;; the file buffers are switched to as they are seen on the co= mmand
+=C2=A0 ;; line (so "emacs --file a --file b --eval=3D'(m= essage "%s"
+=C2=A0 ;; (buffer-name))'" will print &q= uot;b"), but this does not affect the
+=C2=A0 ;; final displayed st= ate of the buffers.
=C2=A0=C2=A0 (let ((displayable-buffers nil))
=C2= =A0=C2=A0=C2=A0=C2=A0 ;; This `let' processes the command line argument= s.
=C2=A0=C2=A0=C2=A0=C2=A0 (let ((command-line-args-left args-left))@@ -2194,10 +2197,10 @@ A fancy display is used on graphic displays, norma= l otherwise."
=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=C2=A0 (line 0)
=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=C2=A0 (colu= mn 0)
=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=C2=A0 ;; `process-file-arg' opens a file buffer for = `name'
-=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 ;; without switching to the buffer, adds the buffe= r to
-=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 ;; `displayable-buffers', and puts the point at
-= =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 ;; `line':`column'. `line' and `column' are both = reset
-=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 ;; to zero when `process-file-arg' returns.
+= =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 ;; and adds the buffer to `displayable-buffers', and
+=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 ;; puts the point at `line':`column'. `line' and
+=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 ;; `column' are both reset to zero when
+=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 ;; `proc= ess-file-arg' returns.
=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=C2=A0 (process-file-arg
=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=C2=A0=C2=A0 (lambda (name)
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0 ;; This can only happen if PWD is deleted.
@@ -2207,7 +2210,9= @@ nil default-directory" name)
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2= =A0=C2=A0 =C2=A0=C2=A0=C2=A0 (let* ((file (expand-file-name
=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 (command-line-normalize-file-name name)
=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 dir))
-=C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 (buf (fi= nd-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=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 `fi= nd-file-noselect'
+=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=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 wi= th "--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=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)))
=C2=A0=C2=A0= =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (setq displa= yable-buffers (cons buf displayable-buffers))
=C2=A0=C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (with-current-buffer buf<= br>=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 (unless (= zerop line)



On Wed, Aug 5, 2015 at 1:37 PM, Rasmus = <rasmus@gmx.us>= ; wrote:
Samer Masterson <= ;nosefrog@gmail.com= > writes:

> The issue here is that my patch uses `find-file-noselect' on the a= rg for
> --file and delays switching to the file buffer to the end of the funct= ion,
> but all of the other commands, like --eval, execute immediately... My = first
> reaction is to use `find-file' instead of `find-file-noselect'= , so that the
> "found" file is selected immediately, and then have the disp= lay logic at
> the end, which may be redundant if there is only a single displayable<= br> > buffer. I'll submit a patch later today.

I actually tried to change it to find-file in my local version of th= e
file, but it didn't solve the problem.=C2=A0 But perhaps I forgot to byte-compile it.

Let me know.

Thanks,
Rasmus

--
Evidence suggests Snowden used a powerful tool called monospaced fonts

--001a11c2337611d502051c967f29--