From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jeffrey Spencer Newsgroups: gmane.emacs.help Subject: Re: open recent file on startup Date: Wed, 8 Aug 2012 07:36:56 +1000 Message-ID: References: <116DF072-D45B-4BF2-B227-6904425D33D7@gmx.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=0016e6dd973f0f638604c6b3ccf9 X-Trace: dough.gmane.org 1344375445 18250 80.91.229.3 (7 Aug 2012 21:37:25 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 7 Aug 2012 21:37:25 +0000 (UTC) Cc: "help-gnu-emacs@gnu.org" To: Alp Aker Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Aug 07 23:37:25 2012 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 1SyrSr-0003Bk-U5 for geh-help-gnu-emacs@m.gmane.org; Tue, 07 Aug 2012 23:37:22 +0200 Original-Received: from localhost ([::1]:46530 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SyrSr-0001PU-7p for geh-help-gnu-emacs@m.gmane.org; Tue, 07 Aug 2012 17:37:21 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:35647) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SyrSk-0001J5-77 for help-gnu-emacs@gnu.org; Tue, 07 Aug 2012 17:37:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SyrSj-0002sI-18 for help-gnu-emacs@gnu.org; Tue, 07 Aug 2012 17:37:14 -0400 Original-Received: from mail-we0-f169.google.com ([74.125.82.169]:52117) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SyrSi-0002rv-O4 for help-gnu-emacs@gnu.org; Tue, 07 Aug 2012 17:37:12 -0400 Original-Received: by weys10 with SMTP id s10so63038wey.0 for ; Tue, 07 Aug 2012 14:37:12 -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=nO6xPSiTohi5Gzv2d1g2rewQGanvHgnaZs4bKS3imog=; b=s9R0Va/jLzsDk+7e2CGTTcAK0fQBoAcTBkGj93o99Xem6PTvz0oVP8dQKtIvBhFFfL sL7uqzYmJX6vMtl6vD6IrXJHp6WhNsJ3mUgXGhiCGm9IvYCkdcfsoMHAtc+a31Kwnq8K XAnd2WhFO5dLJ4XWoOPy/kYU+UzgfN39RwGs9A80GG2l9v9oe9hmPX2Ta6cCxGUXCotS jDQYb3KMbP4pzQKHBYY0xFkanSdFhQo1kPaCAlYaO623iKVqkA7YNh/DdVOT1arsLGz4 L0hz9h3DAvwa66PuBRMBCXsR5plJFQV30z3xAzBsYSL54bQwvYOlkpI8Dw2AuWL4Eskw yGHg== Original-Received: by 10.216.140.207 with SMTP id e57mr8906831wej.23.1344375431848; Tue, 07 Aug 2012 14:37:11 -0700 (PDT) Original-Received: by 10.216.72.79 with HTTP; Tue, 7 Aug 2012 14:36:56 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 74.125.82.169 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:86240 Archived-At: --0016e6dd973f0f638604c6b3ccf9 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Nevermind I ended up using, (if (file-readable-p recentf-save-file) (if (> (length recentf-list) 0) (if (< (length command-line-args) 2) (setq initial-buffer-choice (car (recentf-elements 1)))))) If there is a better way then this let me know. Not sure if command-line-args contains other commands sometimes besides files passed in as most switches seem to be removed from my testing. Cheers On Tue, Aug 7, 2012 at 5:02 PM, Jeffrey Spencer wro= te: > How do you check if emacs is opening from clicking a file or passing in a > file argument in the terminal. I had set the function above but if I doub= le > click a file or pass in a file on the terminal I'd prefer this to not be > activated. Instead the file clicked to be shown and to not set the > initial-buffer-choice. I figured there is a variable for the file passed = in > but couldn't figure it out. > > thanks > > > On Fri, Aug 3, 2012 at 12:44 PM, Alp Aker wrote= : > >> > I copied this in my .emacs file so that the recent file gets opened on >> startup: >> > >> > (recentf-mode 1) >> > (if (file-readable-p recentf-save-file) >> > (if (> (length recentf-list) 0) >> > (find-file (car (recentf-elements 1))))) >> > >> > It seems to work =96 when I start emacs I see my last opened file. >> > But then after a second, it switches the buffer back to the standard >> emacs start-screen. >> >> Setting `initial-buffer-choice' in your .emacs might be what you want. >> >> > --0016e6dd973f0f638604c6b3ccf9 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Nevermind I ended up using,

(if (file-readable-p recentf= -save-file)
=A0 =A0(if (> (length recentf-list) 0)
=A0 =A0= =A0 =A0(if (< (length command-line-args) 2)
=A0 =A0 =A0 (setq= initial-buffer-choice (car (recentf-elements 1))))))

If there is a better way then this let me know. Not sur= e if command-line-args contains other commands sometimes besides files pass= ed in as most switches seem to be removed from my testing.

Cheers

On Tue, Aug 7, 2012 a= t 5:02 PM, Jeffrey Spencer <jeffspencerd@gmail.com> wro= te:
How do you check if emacs is opening from cl= icking a file or passing in a file argument in the terminal. I had set the = function above but if I double click a file or pass in a file on the termin= al I'd prefer this to not be activated. Instead the file clicked to be = shown and to not set the initial-buffer-choice. I figured there is a variab= le for the file passed in but couldn't figure it out.

thanks


On Fri, Aug 3, 2012 at 12:44 PM, Alp Aker <alptekin.aker@gm= ail.com> wrote:
> I copied this in my .emacs file so= that the recent file gets opened on startup:
>
> (recentf-mode 1)
> (if (file-readable-p recentf-save-file)
> =A0 =A0(if (> (length recentf-list) 0)
> =A0 =A0 =A0 (find-file (car (recentf-elements 1)))))
>
> It seems to work =96 when I start emacs I see my last opened file.
> But then after a second, it switches the buffer back to the standard e= macs start-screen.

Setting `initial-buffer-choice' in your .emacs might be what you = want.



--0016e6dd973f0f638604c6b3ccf9--