Misc changes and cleanup.

This commit is contained in:
2020-09-14 15:14:02 +02:00
parent 83e0538268
commit 662c04cada

View File

@@ -140,21 +140,23 @@ And it should be accessible with a quick keystroke:
(mapc load-it (directory-files dir nil "\\.el$")))) (mapc load-it (directory-files dir nil "\\.el$"))))
#+END_SRC #+END_SRC
* Theming * Theming
Load font from file. See [[https://github.com/rougier/elegant-emacs]] for more. Apply a nice looking theme.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
;; Light Theme ;; Light Theme
(use-package modus-operandi-theme) (use-package modus-operandi-theme)
(load-theme 'modus-operandi t) (load-theme 'modus-operandi t)
;; Dark Theme ;; Syntax highlighing
;(use-package modus-vivendi-theme) (setq modus-operandi-theme-faint-syntax t)
;(load-theme 'modus-vivendi t)
(setq modus-operandi-theme-org-blocks "greyscale")
(setq default-frame-alist (setq default-frame-alist
(append (list '(width . 90) '(height . 50) (append (list '(width . 90) '(height . 50)
'(vertical-scroll-bars . nil) '(vertical-scroll-bars . nil)
'(internal-border-width . 10) '(internal-border-width . 10)
'(font . "Roboto Mono Light 10")))) '(font . "Roboto Mono Light 11"))))
#+END_SRC #+END_SRC
Use a nice looking modeline package Use a nice looking modeline package
@@ -167,84 +169,53 @@ Use a nice looking modeline package
Use Ivy to make minibuf promts better. Adds the ability to sort and filter. Use Ivy to make minibuf promts better. Adds the ability to sort and filter.
** Use Ivy ** Use Ivy
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package ivy (use-package ivy
:init :diminish
(ivy-mode 1) :init
(unbind-key "S-SPC" ivy-minibuffer-map) (ivy-mode 1)
(setq ivy-height 30 (unbind-key "S-SPC" ivy-minibuffer-map)
ivy-use-virtual-buffers t (setq ivy-height 30
ivy-use-selectable-prompt t) ivy-use-virtual-buffers t
(defun swiper-at-point () ivy-use-selectable-prompt t)
(interactive) :bind (("C-x b" . ivy-switch-buffer)
(swiper (thing-at-point 'word))) ("C-c C-r" . ivy-resume)
:bind (("C-x b" . ivy-switch-buffer) ("C-s" . swiper)))
("C-c C-r" . ivy-resume)
("C-c s" . swiper-at-point)
("C-s" . swiper))
:diminish)
;; ivy-rich makes Ivy look a little bit more like Helm. ;; ivy-rich makes Ivy look a little bit more like Helm.
(use-package ivy-rich (use-package ivy-rich
:after counsel :after counsel
:custom :custom
(ivy-virtual-abbreviate 'full (ivy-virtual-abbreviate 'full
ivy-rich-switch-buffer-align-virtual-buffer t ivy-rich-switch-buffer-align-virtual-buffer t
ivy-rich-path-style 'abbrev) ivy-rich-path-style 'abbrev)
:init :init
(ivy-rich-mode)) (ivy-rich-mode))
(use-package ivy-hydra) (use-package ivy-hydra)
#+END_SRC #+END_SRC
** Smex ** Smex
Sort commands by recency in ivy windows Sort commands by recency in ivy windows
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package smex) (use-package smex)
#+END_SRC #+END_SRC
* Counsel * Counsel
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package counsel (use-package counsel
:ensure t :after ivy
:after ivy :init (counsel-mode 1)
:init :bind (("C-c ;" . counsel-M-x)
(counsel-mode 1) ("C-c U" . counsel-unicode-char)
("C-c i" . counsel-imenu)
:bind (("C-c ;" . counsel-M-x) ("C-x f" . counsel-find-file)
("C-c U" . counsel-unicode-char) ("C-c y" . counsel-yank-pop)
("C-c i" . counsel-imenu) ("C-c r" . counsel-recentf)
("C-x f" . counsel-find-file) :map ivy-minibuffer-map
("C-c y" . counsel-yank-pop) ("C-r" . counsel-minibuffer-history))
("C-c r" . counsel-recentf) :diminish)
:map ivy-minibuffer-map
("C-r" . counsel-minibuffer-history))
:diminish)
#+END_SRC #+END_SRC
* Undo Tree
Using the beauty that is undo-tree, we can easily navigate through history of a buffer.
This includes obviously going back in edit history, but also branching of end returning to previous states.
#+BEGIN_SRC emacs-lisp
(use-package undo-tree
:bind (("C-x u" . undo-tree-visualize)
("C-z" . undo-tree-undo)
("C-S-z" . undo-tree-redo))
:config
(global-undo-tree-mode +1)
(unbind-key "M-_" undo-tree-map)
:diminish)
;; Trying undo-propose, which seems to offer a better experience, as
;; undo tree is prone to losing data.
(use-package undo-propose
:disabled
:bind (("C-c _" . undo-propose)
:map undo-propose-mode-map
("<up>" . undo-only)))
#+END_SRC
With this we can use ~C-x u~ in any buffer to bring up the tree and navigate it using the arrow key.
Once in a state we agree with, just press ~q~ and we are done.
* Magit * Magit
Magit is THE go to package for using git in emacs. Magit is THE go to package for using git in emacs.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
@@ -314,7 +285,6 @@ I use a single file to dump all links I plan on viewing later.
(interactive) (interactive)
(find-file link-dump)) (find-file link-dump))
#+END_SRC #+END_SRC
** Configure org-mode ** Configure org-mode
This is the main configuration for the infamous org-mode. This is the main configuration for the infamous org-mode.
The most important parts are configuring key bindings to quickly access the files we have defined above. The most important parts are configuring key bindings to quickly access the files we have defined above.
@@ -347,7 +317,6 @@ The most important parts are configuring key bindings to quickly access the file
org-startup-with-inline-images t org-startup-with-inline-images t
org-pretty-entities t org-pretty-entities t
org-indent-mode t org-indent-mode t
org-ellipsis ""
org-footnote-section nil org-footnote-section nil
org-hide-leading-stars nil org-hide-leading-stars nil
org-link-file-path-type 'relative org-link-file-path-type 'relative
@@ -366,11 +335,10 @@ When archiving items in org files, the default ist to crate a separate file name
This clutters up my notes folder quite a bit, as I use a lot of separate files with thier respective archives. This clutters up my notes folder quite a bit, as I use a lot of separate files with thier respective archives.
All archives should be stored in a single ~.archive~ file per directory. All archives should be stored in a single ~.archive~ file per directory.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(setq org-archive-location "./.archive::* From %s") (setq org-archive-location "./.archive::* From %s")
#+END_SRC #+END_SRC
** Beautify org-mode ** Beautify org-mode
*** Icons for headline indentation *** Icons
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package org-bullets (use-package org-bullets
:init (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))) :init (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))))
@@ -378,7 +346,12 @@ All archives should be stored in a single ~.archive~ file per directory.
(setq org-bullets-bullet-list '("" "" "" "" "" "")) (setq org-bullets-bullet-list '("" "" "" "" "" ""))
#+END_SRC #+END_SRC
*** Replace checkmark with unicode icons Ellipsis icon:
#+BEGIN_SRC emacs-lisp
(setq org-ellipsis "")
#+END_SRC
Nice Icons for lists:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package pretty-mode (use-package pretty-mode
:init (global-pretty-mode t)) :init (global-pretty-mode t))
@@ -417,56 +390,44 @@ We also want them in exported HTML files
(0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "")))))) (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) ""))))))
#+END_SRC #+END_SRC
** Prettier Timestamps in Exports *** Prettier Timestamps in Exports
The default timestamps look pretty unintuitive, with all the angle brackets and all. Let's make them look better.
#+BEGIN_SRC emacs-lisp
;;(add-to-list 'org-export-filter-timestamp-functions
;; #'endless/filter-timestamp)
;;(defun endless/filter-timestamp (trans back _comm)
;; (pcase back
;; ((or `jekyll `html)
;; (replace-regexp-in-string "&[lg]t;" "" trans))
;; (`latex
;; (replace-regexp-in-string "[<>]" "" trans))))
#+END_SRC
Removed for now, this somehow breaks emacs
OK, no more brackets. Now for a better formatted display.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(setq-default org-display-custom-times t) (setq-default org-display-custom-times t)
(setq org-time-stamp-custom-formats (setq org-time-stamp-custom-formats
'("<%a %d.%m.%Y>" . "<%d.%m.%y %H:%M>")) '("<%a %d.%m.%Y>" . "<%d.%m.%y %H:%M>"))
#+END_SRC #+END_SRC
** Templates ** Templates
*** Babel *** Babel
Here we set custom templates to be used for structure expansion. Here we set custom templates to be used for structure expansion.
These are used when we type "<" folowed by the shortcut for a template and hit "TAB". These are used when we type "<" folowed by the shortcut for a template and hit "TAB".
e.g. "<s TAB" expands to ~#+BEGIN_SRC ?\n\n#+END_SRC~ e.g. "<s TAB" expands to ~#+BEGIN_SRC ?\n\n#+END_SRC~
Use ~org-tempo~ to quickly insert the structures
#+begin_src emacs-lisp
(require 'org-tempo)
#+end_src
**** emacs-lisp **** emacs-lisp
Shortcut for creating ~emacs-lisp~ code blocks. This is used extensively in this very file. Shortcut for creating ~emacs-lisp~ code blocks. This is used extensively in this very file.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(add-to-list 'org-structure-template-alist '("el" "#+BEGIN_SRC emacs-lisp\n?\n#+END_SRC")) (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
#+END_SRC #+END_SRC
*** Capture Support Functions *** Capture Support Functions
First we define a function to look the subheading under which we want to file captures: First we define a function to look the subheading under which we want to file captures:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defun org-get-target-headline (&optional targets prompt) (defun org-get-target-headline (&optional targets prompt)
"Prompt for a location in an org file and jump to it. "Prompt for a location in an org file and jump to it.
This is for promping for refile targets when doing captures. This is for promping for refile targets when doing captures.
Targets are selected from `org-refile-targets'. If TARGETS is Targets are selected from `org-refile-targets'. If TARGETS is
given it temporarily overrides `org-refile-targets'. PROMPT will given it temporarily overrides `org-refile-targets'. PROMPT will
replace the default prompt message. replace the default prompt message.
If CAPTURE-LOC is is given, capture to that location instead of If CAPTURE-LOC is is given, capture to that location instead of
prompting." prompting."
(let ((org-refile-targets (or targets org-refile-targets)) (let ((org-refile-targets (or targets org-refile-targets))
(prompt (or prompt "Capture Location"))) (prompt (or prompt "Capture Location")))
(org-refile t nil nil prompt)) (org-refile t nil nil prompt))
) )
#+END_SRC #+END_SRC
*** Org Capture *** Org Capture
@@ -592,24 +553,20 @@ Treemacs makes navigating folders and files much easier. This is the default con
(use-package elfeed (use-package elfeed
:bind ("C-x w" . 'elfeed)) :bind ("C-x w" . 'elfeed))
#+END_SRC #+END_SRC
** Hooks ** Hooks
elfeed can be extended with various hooks for ease of used elfeed can be extended with various hooks for ease of used
*** Auto tag youtube feeds *** Auto tag youtube feeds
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(add-hook 'elfeed-new-entry-hook (add-hook 'elfeed-new-entry-hook
(elfeed-make-tagger :feed-url "youtube\\.com" (elfeed-make-tagger :feed-url "youtube\\.com"
:add '(video youtube))) :add '(video youtube)))
#+END_SRC #+END_SRC
*** Do not spam unread tag *** Do not spam unread tag
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(add-hook 'elfeed-new-entry-hook (add-hook 'elfeed-new-entry-hook
(elfeed-make-tagger :before "2 weeks ago" (elfeed-make-tagger :before "2 weeks ago"
:remove 'unread)) :remove 'unread))
#+END_SRC #+END_SRC
* Additional Package Imports * Additional Package Imports
** All The Icons ** All The Icons
We want to have some nice looking icons We want to have some nice looking icons
@@ -809,7 +766,6 @@ Some customization for writing elisp
(add-hook 'emacs-lisp-mode-hook 'my-elisp-mode-hook) (add-hook 'emacs-lisp-mode-hook 'my-elisp-mode-hook)
#+END_SRC #+END_SRC
* Global Key Bindings * Global Key Bindings
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(bind-key "C-x k" 'kill-buffer-with-prejudice) (bind-key "C-x k" 'kill-buffer-with-prejudice)