Last active
July 6, 2022 19:26
-
-
Save belak/ca1c9ae75e53324ee16e2e5289a9c4bc to your computer and use it in GitHub Desktop.
Simple Emacs Starter Kit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| README.el | |
| backups/ | |
| elpa/ | |
| projectile-bookmarks.eld | |
| recentf | |
| smex-items |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| * Settings | |
| ** Package stuff | |
| Add melpa to the package list and initialize our packages | |
| #+begin_src emacs-lisp | |
| (require 'package) | |
| (add-to-list 'package-archives | |
| '("melpa" . "https://melpa.org/packages/")) | |
| (package-initialize) | |
| #+end_src | |
| Set up =use-package= which is a nicer way of organizing config. | |
| #+begin_src emacs-lisp | |
| ;; Ensure use-package is installed | |
| (unless (package-installed-p 'use-package) | |
| (package-refresh-contents) | |
| (package-install 'use-package)) | |
| ;; Configure and load use-package | |
| (setq use-package-always-ensure t) | |
| (require 'diminish) | |
| (eval-when-compile | |
| (defvar use-package-verbose t) | |
| (require 'use-package)) | |
| #+end_src | |
| ** Appearance | |
| Load a theme | |
| #+begin_src emacs-lisp | |
| (load-theme 'tango-dark) | |
| (use-package monokai-theme | |
| :disabled t | |
| :config | |
| (load-theme 'monokai t)) | |
| #+end_src | |
| Set a font if we're in a gui. | |
| #+begin_src emacs-lisp | |
| (if (window-system) | |
| (set-frame-font "Source Code Pro 10")) | |
| #+end_src | |
| Add column and line numbers to the modeline | |
| #+begin_src emacs-lisp | |
| (column-number-mode 1) | |
| (line-number-mode 1) | |
| #+end_src | |
| This simply changes the name of some of the major modes in the | |
| modeline so we don't need to see the whole thing. | |
| #+begin_src emacs-lisp | |
| (defmacro diminish-major-mode (mode new-name) | |
| `(add-hook (intern (concat (symbol-name ,mode) "-hook")) | |
| '(lambda () (setq mode-name ,new-name)))) | |
| (diminish-major-mode 'lisp-interaction-mode "λ»") | |
| (diminish-major-mode 'emacs-lisp-mode "Eλ") | |
| (diminish-major-mode 'lisp-mode "λ") | |
| #+end_src | |
| Disable all the extra menus and crap | |
| #+begin_src emacs-lisp | |
| (menu-bar-mode -1) | |
| (tool-bar-mode -1) | |
| (scroll-bar-mode -1) | |
| #+end_src | |
| =smart-mode-line= is a simple modeline which is a huge improvement | |
| over the default | |
| #+begin_src emacs-lisp | |
| (use-package smart-mode-line | |
| :config | |
| (setq sml/no-confirm-load-theme t | |
| sml/theme 'dark) | |
| (sml/setup)) | |
| #+end_src | |
| ** Navigation | |
| ido, or interactively-do, is a nice replacement for most internal | |
| prompts. | |
| #+begin_src emacs-lisp | |
| (use-package ido | |
| :config | |
| ;; smex is a better replacement for M-x | |
| (use-package smex | |
| :bind | |
| ("M-x" . smex) | |
| ("M-X" . smex-major-mode-commands)) | |
| ;; Use ido everywhere we can | |
| (use-package ido-ubiquitous | |
| :config | |
| (ido-ubiquitous-mode 1)) | |
| ;; This makes ido work vertically | |
| (use-package ido-vertical-mode | |
| :config | |
| (setq ido-vertical-define-keys 'C-n-C-p-up-down-left-right | |
| ido-vertical-show-count t) | |
| (ido-vertical-mode 1)) | |
| ;; This adds flex matching to ido | |
| (use-package flx-ido | |
| :config | |
| (flx-ido-mode 1) | |
| (setq ido-enable-flex-matching t | |
| flx-ido-threshold 1000)) | |
| ;; Turn on ido everywhere we can | |
| (ido-mode 1) | |
| (ido-everywhere 1) | |
| (setq resize-mini-windows t | |
| ido-use-virtual-buffers t | |
| ido-auto-merge-work-directories-length -1)) | |
| #+end_src | |
| Project based navigation is really nice. All key binds for projectile | |
| are prefixed with C-p p. | |
| #+begin_src emacs-lisp | |
| (use-package projectile | |
| :diminish projectile-mode | |
| :config (projectile-global-mode)) | |
| #+end_src | |
| This makes it so when you get to the top or the bottom it will only | |
| scroll by a few lines, rather than a page at a time. | |
| #+begin_src emacs-lisp | |
| (use-package smooth-scrolling | |
| :config | |
| (setq smooth-scroll-margin 5 | |
| scroll-conservatively 101 | |
| scroll-preserve-screen-position t | |
| auto-window-vscroll nil | |
| scroll-margin 5) | |
| (smooth-scrolling-mode 1)) | |
| #+end_src | |
| =undo-tree= improves undos so you can actually undo more than the | |
| directly previous action. | |
| #+begin_src emacs-lisp | |
| (use-package undo-tree | |
| :diminish undo-tree-mode | |
| :config | |
| (global-undo-tree-mode 1)) | |
| #+end_src | |
| Which-key will make it easier to find commands when they're partially | |
| typed in. | |
| #+begin_src emacs-lisp | |
| (use-package which-key | |
| :diminish which-key-mode | |
| :config | |
| (which-key-mode 1) | |
| (setq which-key-idle-delay 0.5 | |
| which-key-popup-type 'side-window | |
| which-key-side-window-location 'right)) | |
| #+end_src | |
| ** Programming | |
| VCS stuff, like status in the gutter and reverting of buffers if | |
| they've changed on disk (like during a checkout) and haven't been | |
| modified in emacs. | |
| #+begin_src emacs-lisp | |
| (use-package diff-hl | |
| :config | |
| ;; We only need diff-hl-margin-mode if we're in a terminal. | |
| (global-diff-hl-mode 1) | |
| (unless (window-system) | |
| (diff-hl-margin-mode 1))) | |
| ;; Revert buffers if they've changed on disk | |
| (global-auto-revert-mode 1) | |
| (setq auto-revert-verbose nil) | |
| #+end_src | |
| General programming settings and hooks | |
| #+begin_src emacs-lisp | |
| ;;; Programming stuff | |
| (which-function-mode 1) | |
| ;; Most programming modes are derived from prog-mode, so common hooks | |
| ;; can go here | |
| (add-hook 'prog-mode-hook | |
| (lambda () | |
| (linum-mode 1) | |
| (setq show-trailing-whitespace))) | |
| ;; We only want to set the linum-format if we're in a terminal. | |
| (unless (window-system) | |
| (setq linum-format "%4d\u2502")) | |
| #+end_src | |
| This will make sure things like TODO, FIXME, and XXX are noticed | |
| #+begin_src emacs-lisp | |
| (use-package fic-mode | |
| :diminish fic-mode | |
| :config | |
| (add-hook 'prog-mode-hook 'fic-mode)) | |
| #+end_src | |
| Random syntax things | |
| #+begin_src emacs-lisp | |
| (use-package web-mode | |
| :mode | |
| "\\.jinja\\'" | |
| "\\.html\\'") | |
| (use-package less-css-mode | |
| :mode "\\.less\\'") | |
| (use-package js2-mode | |
| :mode "\\.js\\'") | |
| (use-package cmake-mode | |
| :mode | |
| "CMakeLists\\.txt\\'" | |
| "\\.cmake\\'") | |
| (use-package json-mode | |
| :mode "\\.json\\'") | |
| (use-package lua-mode | |
| :mode "\\.lua\\'") | |
| (use-package markdown-mode | |
| :mode ("\\.md\\'" . gfm-mode)) | |
| (use-package php-mode | |
| :mode "\\.php\\'") | |
| (use-package racket-mode | |
| :mode "\\.rkt\\'") | |
| (use-package ruby-mode | |
| :mode | |
| "Rakefile" | |
| "\\.rb\\'") | |
| (use-package systemd | |
| :mode ("\\.service\'" . systemd-mode)) | |
| #+end_src | |
| ** Random Stuff | |
| General annoyances. (salute) | |
| #+begin_src emacs-lisp | |
| ;; Ensure backups make it to a different folder so we don't litter all | |
| ;; our directories with them. | |
| (setq save-place-file (concat user-emacs-directory "places") | |
| backup-directory-alist `(("." . ,(concat user-emacs-directory | |
| "backups")))) | |
| ;; Improve buffer names when duplicate files are opened | |
| (require 'uniquify) | |
| (setq uniquify-buffer-name-style 'forward) | |
| ;; Show parens | |
| (show-paren-mode 1) | |
| ;; Make it so you only need to type 'y' or 'n' not 'yes' or 'no' | |
| (fset 'yes-or-no-p 'y-or-n-p) | |
| ;; Damn visual bell | |
| (setq ring-bell-function 'ignore) | |
| ;; Support the mouse and colors in the terminal | |
| (xterm-mouse-mode 1) | |
| ;; We don't care about the startup screen. Just give us a scratch buffer. | |
| (setq initial-buffer-choice t | |
| inhibit-startup-screen t) | |
| #+end_src | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; init -- belak's emacs init.el | |
| ;; | |
| ;;; Commentary: | |
| ;; This file is only to bootstrap into README.org and set up some | |
| ;; basic timing. | |
| ;; | |
| ;;; Code: | |
| ;; Define the start time so we can measure how long loading took later. | |
| (defconst emacs-start-time (current-time)) | |
| ;; Turn on debugging. This is for ensuring we get decent errors when | |
| ;; the startup is messed up. | |
| (setq debug-on-error t | |
| debug-on-quit t) | |
| ;; Load the org-mode file. This has everything aside from the timing. | |
| (require 'org) | |
| (org-babel-load-file | |
| (expand-file-name "README.org" user-emacs-directory)) | |
| ;; Now that we're done loading, we disable debugging since we don't | |
| ;; need it any more | |
| (setq debug-on-error nil | |
| debug-on-quit nil) | |
| ;; Now that we're done loading everything, print how long it took. | |
| (when window-system | |
| (let ((elapsed (float-time (time-subtract (current-time) emacs-start-time)))) | |
| (message "Loading %s...done (%.3fs)" load-file-name elapsed)) | |
| (add-hook 'after-init-hook | |
| `(lambda () | |
| (let ((elapsed (float-time (time-subtract (current-time) emacs-start-time)))) | |
| (message "Loading %s...done (%.3fs) [after-init]" | |
| ,load-file-name elapsed))) | |
| t)) | |
| ;;; init.el ends here |
Author
No problem! I honestly forgot about this until I got the notification. My current setup has gotten a bit more complex... maybe I should come back to basics at some point.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks