help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: open recent file on startup


From: Jeffrey Spencer
Subject: Re: open recent file on startup
Date: Wed, 8 Aug 2012 07:36:56 +1000

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 <jeffspencerd@gmail.com> wrote:
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 double 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 <alptekin.aker@gmail.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)
>    (if (> (length recentf-list) 0)
>       (find-file (car (recentf-elements 1)))))
>
> It seems to work – 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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]