Better font managing.

This commit is contained in:
2020-09-30 14:06:59 +02:00
parent 58b14098c7
commit b3541a51a6

View File

@@ -16,8 +16,7 @@ State that we will need package support and define a macro for adding package re
;; add to the package repos ;; add to the package repos
(append-to-list package-archives (append-to-list package-archives
'(("melpa" . "http://melpa.org/packages/") '(("melpa" . "http://melpa.org/packages/")))
("org-elpa" . "https://orgmode.org/elpa/")))
(package-initialize) (package-initialize)
(unless (package-installed-p 'use-package) (unless (package-installed-p 'use-package)
(package-refresh-contents) (package-refresh-contents)
@@ -28,7 +27,7 @@ State that we will need package support and define a macro for adding package re
(use-package gnu-elpa-keyring-update) (use-package gnu-elpa-keyring-update)
#+END_SRC #+END_SRC
* Fix defaults * Fix Defaults
** Hide UI elements ** Hide UI elements
Remove all those UI elements. They do not look good and waste space. Remove all those UI elements. They do not look good and waste space.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
@@ -39,13 +38,13 @@ Remove all those UI elements. They do not look good and waste space.
(fringe-mode -1) (fringe-mode -1)
#+END_SRC #+END_SRC
** Disable file backups ** Disable file backups
Emacs, loves to clutter directories with backup files. Emacs sure loves to clutter directories with backup files.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(setq make-backup-files nil) (setq make-backup-files nil)
(setq auto-save-default nil) (setq auto-save-default nil)
(setq create-lockfiles nil) (setq create-lockfiles nil)
#+END_SRC #+END_SRC
** Other settings ** Other Settings
#+begin_src emacs-lisp #+begin_src emacs-lisp
;; The default encoding should be utf-8 everywhere ;; The default encoding should be utf-8 everywhere
(prefer-coding-system 'utf-8) (prefer-coding-system 'utf-8)
@@ -107,7 +106,7 @@ Unbind useless keys.
(unbind-key "C-x C-d") ;; list-directory is utterly useless given the existence of dired (unbind-key "C-x C-d") ;; list-directory is utterly useless given the existence of dired
(unbind-key "C-x C-r") ;; as is find-file-read-only (unbind-key "C-x C-r") ;; as is find-file-read-only
#+END_SRC #+END_SRC
* Useful functions * Useful Functions
** Edit the config file ** Edit the config file
A simple funtion to open this file for quick editing. A simple funtion to open this file for quick editing.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
@@ -147,24 +146,40 @@ Reindet the whole buffer with ~F12~
(interactive) (interactive)
(switch-to-buffer (other-buffer (current-buffer) 1))) (switch-to-buffer (other-buffer (current-buffer) 1)))
#+END_SRC #+END_SRC
** Quickly open the links file
The link dump is the file to throw all links for later reading in.
#+BEGIN_SRC emacs-lisp
(defvar lux/link-dump "")
(defun lux/open-link-dump ()
(interactive)
(find-file lux/link-dump))
#+END_SRC
* Theming * Theming
Apply a nice looking theme. 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)
;; Syntax highlighing ;; Syntax highlighing
(setq modus-operandi-theme-faint-syntax t) (setq modus-operandi-theme-faint-syntax t)
(setq modus-operandi-theme-org-blocks "greyscale") (load-theme 'modus-operandi t)
#+END_SRC
Set up the default frame look.
#+begin_src emacs-lisp
(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 . 5))))
'(font . "Roboto Mono Light 10")))) #+end_src
#+END_SRC
Configure the Fonts
#+begin_src emacs-lisp
(set-face-attribute 'default nil :font "Roboto Mono-11")
(set-face-attribute 'fixed-pitch nil :font "Roboto Mono-11")
(set-face-attribute 'variable-pitch nil :font "Roboto-11")
#+end_src
Use a nice looking modeline package Use a nice looking modeline package
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
@@ -281,45 +296,23 @@ Don't prompt to save unmodified buffers on exit.
#+END_SRC #+END_SRC
* Org Mode * Org Mode
** Define important files
*** The Link Dump
I use a single file to dump all links I plan on viewing later.
#+BEGIN_SRC emacs-lisp
(defvar link-dump "")
(defun open-link-dump ()
(interactive)
(find-file link-dump))
#+END_SRC
** 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.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package org (use-package org
;; Always get this from the GNU archive. ;; Always get this from the GNU archive.
:pin gnu
:bind (("C-c o c" . org-capture) :bind (("C-c o c" . org-capture)
("C-c o l" . open-link-dump) ("C-c o l" . lux/open-link-dump)
("C-c o s" . org-store-link) ("C-c o s" . org-store-link)
("C-c o a" . org-agenda) ("C-c o a" . org-agenda)
:map org-mode-map :map org-mode-map
("M-s-<return>" . org-insert-todo-heading) ("M-s-<return>" . org-insert-todo-heading)
("M-<return>" . org-insert-heading-respect-content) ("M-<return>" . org-insert-heading-respect-content)
("C-c c" . org-mode-insert-code)
("C-c a s" . org-emphasize) ("C-c a s" . org-emphasize)
("C-c a r" . org-ref)
("C-c a e" . outline-show-all)
("C-c a t" . unindent-by-four)
("C-c -" . org-edit-special)) ("C-c -" . org-edit-special))
:hook ((org-mode . visual-line-mode) :hook ((org-mode . visual-line-mode)
(org-mode . variable-pitch-mode)
(org-mode . org-indent-mode)) (org-mode . org-indent-mode))
:config :config
(let ((todo-path (expand-file-name "~/Notes/todo.org")))
(when (file-exists-p todo-path)
(setq org-agenda-files (list todo-path)
org-default-notes-file todo-path)))
(setq org-footnote-section "" (setq org-footnote-section ""
org-startup-with-inline-images t org-startup-with-inline-images t
org-pretty-entities t org-pretty-entities t
@@ -331,120 +324,32 @@ The most important parts are configuring key bindings to quickly access the file
org-display-inline-images t org-display-inline-images t
org-hide-emphasis-markers t org-hide-emphasis-markers t
) )
(setcar (nthcdr 4 org-emphasis-regexp-components) 4) (setcar (nthcdr 4 org-emphasis-regexp-components) 4))
(defun org-mode-insert-code ()
(interactive)
(org-emphasize ?~)))
#+END_SRC #+END_SRC
** Set default archive location ** Archive Location
When archiving items in org files, the default ist to crate a separate file named ~<filename>.org_archive~. When archiving items in org files, the default ist to crate a separate file named ~<filename>.org_archive~.
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
*** Icons
#+BEGIN_SRC emacs-lisp
(use-package org-bullets
:init (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))))
(setq org-bullets-bullet-list '("" "" "" "" "" "")) ** Export Location
This snippet will create a sub dir for exports from org-mode.
[[https://stackoverflow.com/questions/9559753/emacs-org-mode-export-to-another-directory][See the Stackoverflow question]]
#+BEGIN_SRC emacs-lisp
(defun org-export-output-file-name-modified (orig-fun extension &optional subtreep pub-dir)
(unless pub-dir
(setq pub-dir "Exports")
(unless (file-directory-p pub-dir)
(make-directory pub-dir)))
(apply orig-fun extension subtreep pub-dir nil))
(advice-add 'org-export-output-file-name :around #'org-export-output-file-name-modified)
#+END_SRC #+END_SRC
Ellipsis icon: ** Export HTML
#+BEGIN_SRC emacs-lisp
(setq org-ellipsis "")
#+END_SRC
Nice Icons for lists:
#+BEGIN_SRC emacs-lisp
(add-hook 'org-mode-hook
(lambda ()
"Beautify Org Checkbox Symbol"
(push '("[ ]" . "") prettify-symbols-alist)
(push '("[X]" . "" ) prettify-symbols-alist)
(push '("[-]" . "" ) prettify-symbols-alist)
(prettify-symbols-mode)))
#+END_SRC
We also want them in exported HTML files
#+BEGIN_SRC emacs-lisp
(setq org-html-checkbox-type 'html)
#+END_SRC
*** Strike out done ckeckbox items
#+BEGIN_SRC emacs-lisp
(defface org-checkbox-done-text
'((t (:foreground "#71696A" :strike-through t)))
"Face for the text part of a checked org-mode checkbox.")
(font-lock-add-keywords
'org-mode
`(("^[ \t]*\\(?:[-+*]\\|[0-9]+[).]\\)[ \t]+\\(\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?\\[\\(?:X\\|\\([0-9]+\\)/\\2\\)\\][^\n]*\n\\)"
1 'org-checkbox-done-text prepend))
'append)
#+END_SRC
*** Replace dash in bullet lists with unicode symbol
#+BEGIN_SRC emacs-lisp
(font-lock-add-keywords 'org-mode
'(("^ *\\([-]\\) "
(0 (prog1 () (compose-region (match-beginning 1) (match-end 1) ""))))))
#+END_SRC
*** Prettier Timestamps in Exports
#+BEGIN_SRC emacs-lisp
(setq-default org-display-custom-times t)
(setq org-time-stamp-custom-formats
'("<%a %d.%m.%Y>" . "<%d.%m.%y %H:%M>"))
#+END_SRC
** Templates
*** Babel
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".
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
Shortcut for creating ~emacs-lisp~ code blocks. This is used extensively in this very file.
#+BEGIN_SRC emacs-lisp
(add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
#+END_SRC
*** Capture Support Functions
First we define a function to look the subheading under which we want to file captures:
#+BEGIN_SRC emacs-lisp
(defun org-get-target-headline (&optional targets prompt)
"Prompt for a location in an org file and jump to it.
This is for promping for refile targets when doing captures.
Targets are selected from `org-refile-targets'. If TARGETS is
given it temporarily overrides `org-refile-targets'. PROMPT will
replace the default prompt message.
If CAPTURE-LOC is is given, capture to that location instead of
prompting."
(let ((org-refile-targets (or targets org-refile-targets))
(prompt (or prompt "Capture Location")))
(org-refile t nil nil prompt))
)
#+END_SRC
*** Org Capture
Here we define templates we want to use to quickly capture stuff and automatically file them away.
#+BEGIN_SRC emacs-lisp
(setq org-capture-templates
'(("l" "Link" entry (file link-dump)
"* NEW %?\n:PROPERTIES:\n:CREATED: %U\n:END:\n%i\n")
))
#+END_SRC
** CSS inlining
Auto inline a CSS theme for org HTML exports. Auto inline a CSS theme for org HTML exports.
This will make sure a self contained single HTML file is created. This will make sure a self contained single HTML file is created.
@@ -468,19 +373,92 @@ This will make sure a self contained single HTML file is created.
(add-hook 'org-export-before-processing-hook 'my-org-inline-css-hook) (add-hook 'org-export-before-processing-hook 'my-org-inline-css-hook)
#+END_SRC #+END_SRC
** Export to a subdirectory
This snippet will create a sub dir for exports from org-mode.
[[https://stackoverflow.com/questions/9559753/emacs-org-mode-export-to-another-directory][See the Stackoverflow question]]
** Org Mode Bling
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defun org-export-output-file-name-modified (orig-fun extension &optional subtreep pub-dir) (use-package org-bullets
(unless pub-dir :init (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))))
(setq pub-dir "Exports") (setq org-bullets-bullet-list '("" "" "" "" "" ""))
(unless (file-directory-p pub-dir)
(make-directory pub-dir))) ;; Ellipsis icon
(apply orig-fun extension subtreep pub-dir nil)) (setq org-ellipsis "")
(advice-add 'org-export-output-file-name :around #'org-export-output-file-name-modified)
;; Nice Icons for lists
(add-hook 'org-mode-hook
(lambda ()
"Beautify Org Checkbox Symbol"
(push '("[ ]" . "") prettify-symbols-alist)
(push '("[X]" . "" ) prettify-symbols-alist)
(push '("[-]" . "" ) prettify-symbols-alist)
(prettify-symbols-mode)))
;; We also want them in exported HTML files
(setq org-html-checkbox-type 'html)
;; Replace dash in bullet lists with unicode symbol
(font-lock-add-keywords 'org-mode
'(("^ *\\([-]\\) "
(0 (prog1 () (compose-region (match-beginning 1) (match-end 1) ""))))))
;; Strike out done ckeckbox items
(defface org-checkbox-done-text
'((t (:foreground "#71696A" :strike-through t)))
"Face for the text part of a checked org-mode checkbox.")
(font-lock-add-keywords
'org-mode
`(("^[ \t]*\\(?:[-+*]\\|[0-9]+[).]\\)[ \t]+\\(\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?\\[\\(?:X\\|\\([0-9]+\\)/\\2\\)\\][^\n]*\n\\)"
1 'org-checkbox-done-text prepend))
'append)
;; Prettier Timestamps in Exports
(setq-default org-display-custom-times t)
(setq org-time-stamp-custom-formats
'("<%a %d.%m.%Y>" . "<%d.%m.%y %H:%M>"))
#+END_SRC #+END_SRC
** Templates
*** Babel
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".
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
Shortcut for creating ~emacs-lisp~ code blocks. This is used extensively in this very file.
#+BEGIN_SRC emacs-lisp
(add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
#+END_SRC
*** Capture
First we define a function to look the subheading under which we want to file captures:
#+BEGIN_SRC emacs-lisp
(defun org-get-target-headline (&optional targets prompt)
"Prompt for a location in an org file and jump to it.
This is for promping for refile targets when doing captures.
Targets are selected from `org-refile-targets'. If TARGETS is
given it temporarily overrides `org-refile-targets'. PROMPT will
replace the default prompt message.
If CAPTURE-LOC is is given, capture to that location instead of
prompting."
(let ((org-refile-targets (or targets org-refile-targets))
(prompt (or prompt "Capture Location")))
(org-refile t nil nil prompt))
)
#+END_SRC
Here we define templates we want to use to quickly capture stuff and automatically file them away.
#+BEGIN_SRC emacs-lisp
(setq org-capture-templates
'(("l" "Link" entry (file lux/link-dump)
"* NEW %?\n:PROPERTIES:\n:CREATED: %U\n:END:\n%i\n")
))
#+END_SRC
* Treemacs * Treemacs
Treemacs makes navigating folders and files much easier. This is the default config from [[https://github.com/Alexander-Miller/treemacs][the offical repository]] as a base, with slight modifications to suite my config. Treemacs makes navigating folders and files much easier. This is the default config from [[https://github.com/Alexander-Miller/treemacs][the offical repository]] as a base, with slight modifications to suite my config.
@@ -568,7 +546,7 @@ elfeed can be extended with various hooks for ease of used
(elfeed-make-tagger :before "2 weeks ago" (elfeed-make-tagger :before "2 weeks ago"
:remove 'unread)) :remove 'unread))
#+END_SRC #+END_SRC
* Misc packages * Misc Packages
** All The Icons ** All The Icons
We want to have some nice looking icons We want to have some nice looking icons
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
@@ -652,7 +630,8 @@ A simple Emacs minor mode for a nice writing environment.
Auto enable it in text modes Auto enable it in text modes
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(add-hook 'text-mode-hook 'olivetti-mode) ;; Do not use for now
;;(add-hook 'text-mode-hook 'olivetti-mode)
#+END_SRC #+END_SRC
** Ag ** Ag
Ag.el allows you to search using ~ag~ from inside Emacs. You can filter by file type, edit results inline, or find files. Ag.el allows you to search using ~ag~ from inside Emacs. You can filter by file type, edit results inline, or find files.
@@ -688,5 +667,5 @@ This file is specific to the machine emacs runs on.
It conatins customizations and file locations that are machine dependend. It conatins customizations and file locations that are machine dependend.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(setq custom-file "~/.emacs.d/custom.el") (setq custom-file "~/.emacs.d/custom.el")
(load custom-file 'noerror) ;;(load custom-file 'noerror)
#+END_SRC #+END_SRC