84 lines
3.2 KiB
Org Mode
84 lines
3.2 KiB
Org Mode
:PROPERTIES:
|
|
:ID: cce/emacs_session
|
|
:END:
|
|
#+TITLE: Emacs Session Startup
|
|
#+filetags: :CCE:Emacs:Code:
|
|
#+PROPERTY: header-args :mkdirp yes :results none
|
|
#+PROPERTY: header-args:emacs-lisp :tangle startup.el
|
|
#+ARROYO_EMACS_MODULE: startup
|
|
#+ARCOLOGY_KEY: cce/startup
|
|
#+ARCOLOGY_ALLOW_CRAWL: t
|
|
#+CCE_PRIORITY: 01
|
|
#+CCE_PREDICATE: t
|
|
#+ARROYO_MODULE_WANTS: cce/configure_packaging.org
|
|
|
|
#+begin_src emacs-lisp
|
|
(provide 'cce/startup)
|
|
#+end_src
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
(setq custom-file "~/.emacs.d/custom.el")
|
|
#+END_SRC
|
|
|
|
I almost always want Emacs's =server= running. There's no reason not to, especially when I am using =EXWM=. The ability to be able to attach to Emacs to edit files from the command line, or to rescue a broken X11 session, or to do batch operations using Emacs's text-processing libraries are all super powerful, and it makes little sense to not use this.
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
(unless (boundp 'server-process)
|
|
(server-start))
|
|
#+END_SRC
|
|
|
|
[[http://www.gnu.org/software/emacs/manual/html_node/elisp/Desktop-Save-Mode.html][Desktop Save Mode]] is the session management system for Emacs; it holds state of open buffers and session variables across instantiation of Emacs, which is super useful in mobile setups like laptops which reboot a lot. To make startup sane, I'm choosing to eagerly restore the 10 most recently used buffers on startup, and then in Idle the system will restore the remaining buffers.
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
(desktop-save-mode 1)
|
|
(setq desktop-restore-eager 25)
|
|
(setq desktop-load-locked-desktop t)
|
|
(setq desktop-files-not-to-save "\\(^/[^/:]*:\\|(ftp)$\\|KILL\\)")
|
|
(setq desktop-restore-frames nil)
|
|
(setq desktop-lazy-verbose nil)
|
|
#+END_SRC
|
|
|
|
Emacs should automatically save my state, and does so every five minutes.
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
(defun cce/desktop-save ()
|
|
"Write the desktop save file to ~/.emacs.d"
|
|
(desktop-save user-emacs-directory))
|
|
(if (not (boundp 'cce/desktop-save-timer))
|
|
(setq cce/desktop-save-timer
|
|
(run-with-idle-timer 300 t 'cce/desktop-save)))
|
|
#+END_SRC
|
|
|
|
The splashscreen is useful if you've never used Emacs before, but I'd rather just drop straight in to the Scratch buffer.
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
(setq inhibit-splash-screen t)
|
|
#+END_SRC
|
|
|
|
[[http://www.emacswiki.org/emacs/SaveHist][=savehist=]] mode simply persists the state of a bunch of user-input fields, allowing history of minibuffer input, my kill ring, etc. This is a simple quality of life fix.
|
|
|
|
#+begin_src emacs-lisp
|
|
(require 'savehist)
|
|
(setq savehist-file (concat user-emacs-directory "savehist"))
|
|
(setq savehist-save-minibuffer-history 1)
|
|
(setq savehist-additional-variables
|
|
'(kill-ring
|
|
search-ring
|
|
regexp-search-ring))
|
|
(savehist-mode 1)
|
|
#+end_src
|
|
=recentf= gives me a "Recent Files" menu and also some pretty neat Projectile integration. =consult-recentf= in my [[id:cce/selectrum_etc][Consult configuration]] benefits from this thing well.
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
(recentf-mode 1)
|
|
#+END_SRC
|
|
|
|
Use =ibuffer= instead of =list-buffers=; someday I'd like to move this to use sbuffer.el
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
(global-set-key (kbd "C-x C-b") 'ibuffer)
|
|
(with-eval-after-load "ibuffer"
|
|
(add-to-list 'ibuffer-hook #'ibuffer-set-filter-groups-by-mode))
|
|
#+END_SRC
|