With the help of recentf I am able to open recently open files from its buffer list. As an example when I execute icicle-buffer, I can see the buffer list.

I was wondering can I do this operation automatically where the most recent file (buffer) will be open with the help of a function instead of manually selecting.

Basically my main goal is: when I open emacsclient I want to start it with the most recently file, which is I belive the first index file on the buffer list.

  • The question is a bit unclear, so far. Is it really about Icicles and/or Helm, or is it just about how to have emacslient automatically start up with the most recent file? If the former, add tags icicles and/or helm, and say how they are related to the emacsclient part. If the latter, remove the Icicles and Helm part. – Drew Jul 16 at 15:43
  • It is not related to Icicles and/or Helm. Yes just about: how emacsclient automatically startup with the most recent file and I removed Icicles and Helm part – alper Jul 16 at 17:30
  • Thanks! ________ – Drew Jul 16 at 17:34
  • emacsclient -e '(recentf-open-most-recent-file 1)' perhaps? – NickD Jul 17 at 6:15
  • @NickD: this keeps return #<buffer recentf> on my end, i think it keeps opening a buffer called recentf – alper Jul 21 at 14:18

In your .emacs file add the following

(desktop-save-mode 1)

Emacs will open back up exactly like it was sans any buffers not tied to files

| improve this answer | |
  • I already have it but I believe it does something else – alper Jul 16 at 18:29
  • You don't have it or you don't have it right because I have that and Emacs always comes right back up with the same set of files and remembers where I was. If you are working with buffers that aren't tied to files, then no, nothing will work as those do not get saved so there is nothing to restore. – user3450148 Jul 31 at 12:10
  • (desktop-save-mode 1) does not open the most recent file – alper Jul 31 at 17:01
  • It does for me on 3 different machines. Two of them running Ubuntu 20.04 and one running KDE Neon. It even worked in Windows 10 running in a VM. – user3450148 Aug 1 at 22:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.