Emacs from Scratch #5 - Org Mode Basics
- Add README org mode file with configuration in src blocks - Add org mode packages and configuration - Fix some typos - Whitespace changes
This commit is contained in:
349
README.org
Normal file
349
README.org
Normal file
@@ -0,0 +1,349 @@
|
||||
#+title: Personal Emacs Configuration
|
||||
#+author: Sravan Balaji
|
||||
|
||||
* Sravan Balaji's Emacs Configuration
|
||||
|
||||
My personal configuration of Emacs, written as an [[https://orgmode.org][Org Mode]] document.
|
||||
|
||||
* Configuration
|
||||
|
||||
** UI Changes
|
||||
|
||||
*** Disable Unnecessary Visual Elements
|
||||
|
||||
Disable some visual elements that are not necessary like startup message, scrollbar, toolbar, tooltips, menu bar, etc.
|
||||
Turn on the visual bell and add some breathing room.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(setq inhibit-startup-message t) ; Disable startup message
|
||||
|
||||
(scroll-bar-mode -1) ; Disable visible scrollbar
|
||||
(tool-bar-mode -1) ; Disable the toolbar
|
||||
(tooltip-mode -1) ; Disable tooltips
|
||||
(set-fringe-mode 10) ; Give some breathing room
|
||||
|
||||
(menu-bar-mode -1) ; Disable the menu bar
|
||||
|
||||
(setq visible-bell t) ; Set up the visible bell
|
||||
#+end_src
|
||||
|
||||
*** Modeline
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; Doom Modeline
|
||||
(use-package doom-modeline
|
||||
:ensure t
|
||||
:init (doom-modeline-mode 1)
|
||||
:custom (doom-modeline-height 15)
|
||||
)
|
||||
#+end_src
|
||||
|
||||
*** Theme
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; ;; Doom Themes
|
||||
;; (use-package doom-themes
|
||||
;; :init (load-theme 'doom-dracula t)
|
||||
;; )
|
||||
|
||||
;; Dracula Pro Theme
|
||||
(add-to-list 'custom-theme-load-path "~/.config/emacs/themes")
|
||||
(load-theme 'dracula-pro t)
|
||||
#+end_src
|
||||
|
||||
*** Line Numbers
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; Line Numbers
|
||||
(column-number-mode)
|
||||
(global-display-line-numbers-mode t)
|
||||
;; Disable line numbers for some modes
|
||||
(dolist (mode '(
|
||||
org-mode-hook
|
||||
term-mode-hook
|
||||
shell-mode-hook
|
||||
eshell-mode-hook
|
||||
)
|
||||
)
|
||||
(add-hook mode (lambda () (display-line-numbers-mode 0))))
|
||||
#+end_src
|
||||
|
||||
*** Rainbow Delimeters
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; Rainbow Delimiters
|
||||
(use-package rainbow-delimiters
|
||||
:hook (prog-mode . rainbow-delimiters-mode))
|
||||
#+end_src
|
||||
|
||||
** Fonts
|
||||
|
||||
Setup FiraCode font with specified size.
|
||||
|
||||
NOTE: The first time you load your configuration on a new machine, you'll
|
||||
need to run the following command interactively so that mode line icons
|
||||
display correctly:
|
||||
|
||||
M-X all-the-icons-install-fonts
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; Font setup
|
||||
(set-face-attribute 'default nil :font "FiraCode Nerd Font" :height 120)
|
||||
|
||||
;; Icon Fonts
|
||||
(use-package all-the-icons)
|
||||
#+end_src
|
||||
|
||||
** Keybindings
|
||||
|
||||
Evil mode keybindings.
|
||||
|
||||
*** General
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; Make ESC quit prompts
|
||||
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
|
||||
|
||||
;; General (for easy keybindings)
|
||||
(use-package general
|
||||
:config
|
||||
(general-create-definer sb/leader-keys
|
||||
:keymaps '(normal insert visual emacs)
|
||||
:prefix "SPC"
|
||||
:global-prefix "C-SPC")
|
||||
|
||||
(sb/leader-keys
|
||||
"t" '(:ignore t :which-key "toggles")
|
||||
"tc" '(comment-line :which-key "toggle comment")
|
||||
"s" '(:ignore s :which-key "settings")
|
||||
"st" '(counsel-load-theme :which-key "choose theme")
|
||||
"ss" '(hydra-text-scale/body :which-key "scale text")
|
||||
)
|
||||
)
|
||||
|
||||
(general-define-key
|
||||
"C-M-j" 'counsel-switch-buffer
|
||||
)
|
||||
#+end_src
|
||||
|
||||
*** Evil Keybindings
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; Evil Keybindings
|
||||
(use-package evil
|
||||
:init
|
||||
(setq evil-want-integration t)
|
||||
(setq evil-want-keybinding nil)
|
||||
(setq evil-want-C-u-scroll t)
|
||||
(setq evil-want-C-i-jump nil)
|
||||
:config
|
||||
(evil-mode 1)
|
||||
(define-key evil-insert-state-map (kbd "C-g") 'evil-normal-state)
|
||||
(define-key evil-insert-state-map (kbd "C-h") 'evil-delete-backward-char-and-join)
|
||||
|
||||
;; Use visual line motoins even outside of visual-line-mode buffers
|
||||
(evil-global-set-key 'motion "j" 'evil-next-visual-line)
|
||||
(evil-global-set-key 'motion "k" 'evil-previous-visual-line)
|
||||
|
||||
(evil-set-initial-state 'messages-buffer-mode 'normal)
|
||||
(evil-set-initial-state 'dashboard-mode 'normal)
|
||||
)
|
||||
|
||||
(use-package evil-collection
|
||||
:after evil
|
||||
:config
|
||||
(evil-collection-init)
|
||||
)
|
||||
#+end_src
|
||||
|
||||
*** Hydra
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; Hydra
|
||||
(use-package hydra)
|
||||
|
||||
(defhydra hydra-text-scale (:timeout 4)
|
||||
"scale text"
|
||||
("j" text-scale-increase "in")
|
||||
("k" text-scale-decrease "out")
|
||||
("f" nil "finished" :exit t)
|
||||
)
|
||||
#+end_src
|
||||
|
||||
** Package Sources
|
||||
|
||||
Package sources and initialization.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; Initialize package sources
|
||||
(require 'package)
|
||||
|
||||
(setq package-archives
|
||||
'(("melpa" . "https://melpa.org/packages/")
|
||||
("org" . "https://orgmode.org/elpa/")
|
||||
("elpa" . "https://elpa.gnu.org/packages/")
|
||||
)
|
||||
)
|
||||
|
||||
(package-initialize)
|
||||
(unless package-archive-contents
|
||||
(package-refresh-contents))
|
||||
|
||||
;; Initialize use-package on non-Linux platforms
|
||||
(unless (package-installed-p 'use-package)
|
||||
(package-install 'use-package))
|
||||
|
||||
(require 'use-package)
|
||||
(setq use-package-always-ensure t)
|
||||
#+end_src
|
||||
|
||||
** Autocompletion
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; Ivy Autocompletion
|
||||
(use-package ivy
|
||||
:diminish
|
||||
:bind (("C-s" . swiper)
|
||||
:map ivy-minibuffer-map
|
||||
("TAB" . ivy-alt-done)
|
||||
("C-l" . ivy-alt-done)
|
||||
("C-j" . ivy-next-line)
|
||||
("C-k" . ivy-previous-line)
|
||||
:map ivy-switch-buffer-map
|
||||
("C-k" . ivy-previous-line)
|
||||
("C-l" . ivy-done)
|
||||
("C-d" . ivy-switch-buffer-kill)
|
||||
:map ivy-reverse-i-search-map
|
||||
("C-k" . ivy-previous-line)
|
||||
("C-d" . ivy-reverse-i-search-kill))
|
||||
:config
|
||||
(ivy-mode 1)
|
||||
)
|
||||
|
||||
;; Ivy Rich
|
||||
(use-package ivy-rich
|
||||
:init
|
||||
(ivy-rich-mode 1))
|
||||
|
||||
;; Counsel
|
||||
(use-package counsel
|
||||
:bind (("M-x" . counsel-M-x)
|
||||
("C-x b" . counsel-ibuffer)
|
||||
("C-x C-f" . counsel-find-file)
|
||||
:map minibuffer-local-map
|
||||
("C-r" . 'counsel-minibuffer-history)))
|
||||
|
||||
;; Helpful
|
||||
(use-package helpful
|
||||
:custom
|
||||
(counsel-describe-function-function #'helpful-callable)
|
||||
(counsel-describe-variable-function #'helpful-variable)
|
||||
:bind
|
||||
([remap describe-function] . counsel-describe-function)
|
||||
([remap describe-command] . helpful-command)
|
||||
([remap describe-variable] . counsel-describe-variable)
|
||||
([remap describe-key] . helpful-key))
|
||||
#+end_src
|
||||
|
||||
** Projectile
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; Projectile
|
||||
(use-package projectile
|
||||
:diminish projectile-mode
|
||||
:config (projectile-mode)
|
||||
:custom ((projectile-completion-system 'ivy))
|
||||
:bind-keymap
|
||||
("C-c p" . projectile-command-map)
|
||||
:init
|
||||
(when (file-directory-p "~/Projects")
|
||||
(setq projectile-project-search-path '("~/Projects/Personal" "~/Projects/UMICH"))
|
||||
)
|
||||
(when (file-directory-p "~/.config")
|
||||
(setq projectile-project-search-path '("~/.config"))
|
||||
)
|
||||
(setq projectile-switch-project-action #'projectile-dired)
|
||||
)
|
||||
|
||||
(use-package counsel-projectile
|
||||
:config (counsel-projectile-mode)
|
||||
)
|
||||
#+end_src
|
||||
|
||||
** Git Integration
|
||||
|
||||
*** Magit
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; Magit
|
||||
(use-package magit
|
||||
;; :commands (magit-status magit-get-current-branch)
|
||||
:custom
|
||||
(magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1)
|
||||
)
|
||||
|
||||
;; NOTE: evil-magit was removed from MELPA and now a part of evil-collection
|
||||
;; (use-package evil-magit
|
||||
;; :after magit
|
||||
;; )
|
||||
#+end_src
|
||||
|
||||
*** Forge
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; OPTIONAL: This will add GitHub integration to magit, but requires some token setup
|
||||
;; (use-package forge)
|
||||
#+end_src
|
||||
|
||||
** Org Mode
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(defun sb/org-mode-setup ()
|
||||
(org-indent-mode)
|
||||
;; (variable-pitch-mode 1)
|
||||
(auto-fill-mode 0)
|
||||
(visual-line-mode 1)
|
||||
(setq evil-auto-indent nil)
|
||||
)
|
||||
|
||||
;; Replace list hyphen with dot
|
||||
(font-lock-add-keywords 'org-mode
|
||||
'(("^ *\\([-]\\) "
|
||||
(0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•"))))))
|
||||
|
||||
;; ;; Set faces for heading levels
|
||||
;; (dolist (face '((org-level-1 . 1.2)
|
||||
;; (org-level-2 . 1.1)
|
||||
;; (org-level-3 . 1.05)
|
||||
;; (org-level-4 . 1.0)
|
||||
;; (org-level-5 . 1.1)
|
||||
;; (org-level-6 . 1.1)
|
||||
;; (org-level-7 . 1.1)
|
||||
;; (org-level-8 . 1.1)))
|
||||
;; (set-face-attribute (car face) nil :font "Cantarell" :weight 'regular :height (cdr face)))
|
||||
|
||||
(use-package org
|
||||
:hook (org-mode . sb/org-mode-setup)
|
||||
:config
|
||||
(setq org-ellipsis " ")
|
||||
(sb/org-font-setup)
|
||||
)
|
||||
|
||||
(use-package org-bullets
|
||||
:after org
|
||||
:hook (org-mode . org-bullets-mode)
|
||||
:custom
|
||||
(org-bullets-bullet-list '("◉" "○" "●" "○" "●" "○" "●"))
|
||||
)
|
||||
|
||||
;; ;; Add visual fill (padding)
|
||||
;; (defun sb/org-mode-visual-fill ()
|
||||
;; (setq visual-fill-column-width 100
|
||||
;; visual-fill-column-center-text t)
|
||||
;; (visual-fill-column-mode 1)
|
||||
;; )
|
||||
|
||||
;; (use-package visual-fill-column
|
||||
;; :hook (org-mode . sb/org-mode-visual-fill)
|
||||
;; )
|
||||
#+end_src
|
65
init.el
65
init.el
@@ -1,6 +1,6 @@
|
||||
(setq inhibit-startup-message t) ; Disable startup message
|
||||
|
||||
(scroll-bar-mode -1) ; Diable visible scrollbar
|
||||
(scroll-bar-mode -1) ; Disable visible scrollbar
|
||||
(tool-bar-mode -1) ; Disable the toolbar
|
||||
(tooltip-mode -1) ; Disable tooltips
|
||||
(set-fringe-mode 10) ; Give some breathing room
|
||||
@@ -19,12 +19,10 @@
|
||||
(require 'package)
|
||||
|
||||
(setq package-archives
|
||||
'(
|
||||
("melpa" . "https://melpa.org/packages/")
|
||||
; ("melpa-stable" . "https://stable.melpa.org/packages/")
|
||||
("org" . "https://orgmode.org/elpa/")
|
||||
("elpa" . "https://elpa.gnu.org/packages/")
|
||||
)
|
||||
'(("melpa" . "https://melpa.org/packages/")
|
||||
("org" . "https://orgmode.org/elpa/")
|
||||
("elpa" . "https://elpa.gnu.org/packages/")
|
||||
)
|
||||
)
|
||||
|
||||
(package-initialize)
|
||||
@@ -65,7 +63,7 @@
|
||||
:ensure t
|
||||
:init (doom-modeline-mode 1)
|
||||
:custom (doom-modeline-height 15)
|
||||
)
|
||||
)
|
||||
|
||||
;; ;; Doom Themes
|
||||
;; (use-package doom-themes
|
||||
@@ -98,7 +96,7 @@
|
||||
'(jdee-db-spec-breakpoint-face-colors (cons "#1E2029" "#565761"))
|
||||
'(objed-cursor-color "#ff5555")
|
||||
'(package-selected-packages
|
||||
'(autothemer forge evil-magit magit counsel-projectile projectile hydra evil-collection evil general helpful counsel ivy-rich which-key rainbow-delimiters doom-modeline use-package ivy command-log-mode))
|
||||
'(visual-fill-column org-bullets autothemer forge evil-magit magit counsel-projectile projectile hydra evil-collection evil general helpful counsel ivy-rich which-key rainbow-delimiters doom-modeline use-package ivy command-log-mode))
|
||||
'(pdf-view-midnight-colors (cons "#f8f8f2" "#282a36"))
|
||||
'(rustic-ansi-faces
|
||||
["#282a36" "#ff5555" "#50fa7b" "#f1fa8c" "#61bfff" "#ff79c6" "#8be9fd" "#f8f8f2"])
|
||||
@@ -272,3 +270,52 @@
|
||||
|
||||
;; OPTIONAL: This will add GitHub integration to magit, but requires some token setup
|
||||
;; (use-package forge)
|
||||
|
||||
(defun sb/org-mode-setup ()
|
||||
(org-indent-mode)
|
||||
;; (variable-pitch-mode 1)
|
||||
(auto-fill-mode 0)
|
||||
(visual-line-mode 1)
|
||||
(setq evil-auto-indent nil)
|
||||
)
|
||||
|
||||
;; Replace list hyphen with dot
|
||||
(font-lock-add-keywords 'org-mode
|
||||
'(("^ *\\([-]\\) "
|
||||
(0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•"))))))
|
||||
|
||||
;; ;; Set faces for heading levels
|
||||
;; (dolist (face '((org-level-1 . 1.2)
|
||||
;; (org-level-2 . 1.1)
|
||||
;; (org-level-3 . 1.05)
|
||||
;; (org-level-4 . 1.0)
|
||||
;; (org-level-5 . 1.1)
|
||||
;; (org-level-6 . 1.1)
|
||||
;; (org-level-7 . 1.1)
|
||||
;; (org-level-8 . 1.1)))
|
||||
;; (set-face-attribute (car face) nil :font "Cantarell" :weight 'regular :height (cdr face)))
|
||||
|
||||
(use-package org
|
||||
:hook (org-mode . sb/org-mode-setup)
|
||||
:config
|
||||
(setq org-ellipsis " ")
|
||||
(sb/org-font-setup)
|
||||
)
|
||||
|
||||
(use-package org-bullets
|
||||
:after org
|
||||
:hook (org-mode . org-bullets-mode)
|
||||
:custom
|
||||
(org-bullets-bullet-list '("◉" "○" "●" "○" "●" "○" "●"))
|
||||
)
|
||||
|
||||
;; ;; Add visual fill (padding)
|
||||
;; (defun sb/org-mode-visual-fill ()
|
||||
;; (setq visual-fill-column-width 100
|
||||
;; visual-fill-column-center-text t)
|
||||
;; (visual-fill-column-mode 1)
|
||||
;; )
|
||||
|
||||
;; (use-package visual-fill-column
|
||||
;; :hook (org-mode . sb/org-mode-visual-fill)
|
||||
;; )
|
||||
|
Reference in New Issue
Block a user