The splash screen is useful in the beginning, but now I want something more useful: I want to have list of recently opened files presented when starting emacs if there is no predefined file to open. Even better, if it can be the helm-recentf
window (I use helm
package)
3 Answers
There's also a package on MELPA for this now: dashboard: https://github.com/rakanalh/emacs-dashboard. The package allows you to have a splash screen as in the image below:
Here's the use-package
snippet from my config to set it up with a custom banner image and line of text, as well as a list of recent files and bookmarks:
(use-package dashboard
:ensure t
:diminish dashboard-mode
:config
(setq dashboard-banner-logo-title "your custom text")
(setq dashboard-startup-banner "/path/to/image")
(setq dashboard-items '((recents . 10)
(bookmarks . 10)))
(dashboard-setup-startup-hook))
Manomagically :D, after posting the question I got the working solution by removing one single quote below in my .emacs
(setq initial-buffer-choice '(helm-recentf)) ;; Does not work
To this:
(setq initial-buffer-choice (helm-recentf)) ;; Works!!!
;; I still haven't tried doing with the built-in recentf only
Or this:
(setq initial-buffer-choice 'helm-recentf) ;; Works!!!
Update
It still doesn't work with the solution above actually. I got the file open but emacs switches to scratch
buffer right afterward. I have to jump to the buffer of the file I want. So still need more help on this.
Update 2
After some wrestling with elisp
, I got this one really works now:
(require 'recentf) ;; Provided for the whole picture
(require 'helm)
(require 'helm-config)
(defun startwithrecentf()
(buffer-name (find-file (car (helm-recentf))))
)
(setq initial-buffer-choice (startwithrecentf))
Update 3
The following is more compact. It also roughly handle the case emacs is called with additional arguments, i.e emacs somefile
(require 'recentf) ;; Provided for the whole picture
(require 'helm)
(require 'helm-config)
(if (< (length command-line-args) 2)
(setq initial-buffer-choice (car (helm-recentf)))
)
-
2I believe your initial attempt should be
(setq initial-buffer-choice 'helm-recentf)
. Theinitial-buffer-choice
can have a function as a value, which the quoted form without parantheses will give. Commented Jul 28, 2015 at 8:30 -
-
We're here to learn :). With that form I get the
helm-recentf
buffer on start, so your update 2 solution shouldn't be needed. Commented Jul 28, 2015 at 9:19 -
@MeaningfulUsername I made Update 3 :D it handles the case where you call emacs with a file name or something already. Commented Jul 28, 2015 at 10:06
-
And as you already noted, the quoted version does not switch to the buffer, so it seems your (car (helm-recentf)) is the correct solution. (I thought it should be a lambda expression instead of just a list, but that did not work...) Commented Aug 10, 2015 at 8:08
Here's a package that shows recentf-open-files
when starting Emacs without a file to open:
https://github.com/zonuexe/init-open-recentf.el
Configuration with use-package:
(recentf-mode 1)
(setq recentf-max-menu-items 25)
(use-package init-open-recentf
:config
(init-open-recentf))
startup.el.
You can nullify all that stuff and then have your own startup order.