From de3705f5d130e7af4d49c30d6facbc592a6ddecc Mon Sep 17 00:00:00 2001 From: Marc Pohling Date: Sat, 24 Feb 2018 22:48:34 +0100 Subject: [PATCH] Config now in babel org --- config.org | 253 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 253 insertions(+) create mode 100644 config.org diff --git a/config.org b/config.org new file mode 100644 index 0000000..a616832 --- /dev/null +++ b/config.org @@ -0,0 +1,253 @@ +#+TITLE: Emacs Configuration +#+AUTHOR: Marc Pohling + +* Personal Information + +#+begin_src emacs-lisp + (setq user-full-name "Marc Pohling" + user-mail-address "marc.pohling@googlemail.com") +#+end_src + + +* Update config in a running config +Two options: + - reload the open file: M-x load-file, then press twice to accept + the default filename, which is the currently opened + - Point at the end of any sexp and press C-x C-e + + +* Customize settings + +Move the customize settings to its own file, instead of saving +customize settings in [[file:init.el][init.el]]. + +#+begin_src emacs-lisp + (setq custom-file (expand-file-name "custom.el" user-emacs-directory)) + (load custom-file) +#+end_src + + +* Theme +** Material Theme +The [[https://github.com/cpaulik/emacs-material-theme][Material Theme]] comes in a dark and a light variant. Not too dark +to be strenious though. + +#+begin_src emacs-lisp + (use-package material-theme + :if (window-system) + :defer t + :ensure t + :init + (load-theme 'material t) + ) +#+end_src + + +* Sane defaults +Sources for this section include [[https://github.com/magnars/.emacs.d/blob/master/settings/sane-defaults.el][Magnars Sveen]] and [[http://pages.sachachua.com/.emacs.d/Sacha.html][Sacha Chua]] + +These functions are useful. Activate them. +#+begin_src emacs-lisp + (put 'downcase-region 'disabled nil) + (put 'upcase-region 'disabled nil) + (put 'narrow-to-region 'disabled nil) + (put 'dired-find-alternate-file 'disabled nil) +#+end_src +Answering just 'y' or 'n' should be enough. +#+begin_src emacs-lisp + (defalias 'yes-or-no-p 'y-or-n-p) +#+end_src +Keep all backup and auto-save files in one directory +#+begin_src emacs-lisp + (setq backup-directory-alist '(("." . "~/.emacs.d/backups"))) + (setq auto-save-file-name-transforms '((".*" "~/.emacs.d/auto-save-list/" t))) +#+end_src +UTF-8 please +#+begin_src emacs-lisp + (setq locale-coding-system 'utf-8) + (set-terminal-coding-system 'utf-8) + (set-keyboard-coding-system 'utf-8) + (set-selection-coding-system 'utf-8) + (prefer-coding-system 'utf-8) +#+end_src + +Avoid tabs in place of multiple spaces (they look bad in TeX) +and show empty lines +#+begin_src emacs-lisp + (setq-default indent-tabs-mode nil) + (setq-default indicate-empty-lines t) +#+end_src + +Turn off blinking cursor +#+begin_src emacs-lisp + (blink-cursor-mode -1) +#+end_src + +Don't count two spaces after a period as the end of a sentence. +Just one space is needed +#+begin_src emacs-lisp + (setq sentence-end-double-space nil) +#+end_src + +Delete the region when typing, just like as we expect nowadays. +#+begin_src emacs-lisp + (delete-selection-mode t) +#+end_src + +Various stuff +#+begin_src emacs-lisp + (show-paren-mode t) + (column-number-mode t) + + (global-visual-line-mode) + (diminish 'visual-line-mode) + + (setq uniquify-buffer-name-style 'forward) +#+end_src + + +* List buffers +Ibuffer is the improved version of list-buffers. +Make ibuffer the default buffer lister. [[http://ergoemacs.org/emacs/emacs_buffer_management.html][Source]] +#+begin_src emacs-lisp + (defalias 'list-buffers 'ibuffer) +#+end_src + +Also auto refresh dired, but be quiet about it. [[http://whattheemacsd.com/sane-defaults.el-01.html][Source]] +#+begin_src emacs-lisp + (add-hook 'dired-mode-hook 'auto-revert-mode) + (setq global-auto-revert-non-file-buffers t) + (setq auto-revert-verbose nil) +#+end_src + + +* Recentf +#+begin_src emacs-lisp + (use-package recentf + :bind ("C-x C-r" . helm-recentf) + :config + (recentf-mode t) + (setq recentf-max-saved-items 200) + ) +#+end_src + + +* Org Mode +** Installation +Although org mode ships with Emacs, the latest version can be installed externally. The configuration here follows the [[http://orgmode.org/elpa.html][Org mode ELPA Installation instructions.]] + +#+begin_src emacs-lisp + (use-package org + :ensure org-plus-contrib) +#+end_src + +To avoid problems executing source blocks out of the box. [[https://emacs.stackexchange.com/a/28604][Others have the same problem, too]]. The solution is to remove the .elc files form the package directory: + +#+begin_src sh:var ORG_DIR=(let* ((org-v (cadr (split-string (org-version nil t) "@"))) (len (length org-v))) (substring org-v 1 (- len 2))) + rm ${ORG_DIR}/*.elc +#+end_src + +*** Org activation bindings +Set up some global key bindings that integrate with Org mode features + +#+begin_src emacs-lisp + (bind-key "C-c l" 'org-store-link) + (bind-key "C-c c" 'org-capture) + (bind-key "C-c a" 'org-agenda) +#+end_src + +*** Org agenda +For a more detailed example [[https://github.com/sachac/.emacs.d/blob/83d21e473368adb1f63e582a6595450fcd0e787c/Sacha.org#org-agenda][see here]]. + +#+begin_src emacs-lisp + (setq org-agenda-files + (delq nil + (mapcar (lambda (x) (and (file-exists-p x) x)) + '("~/Archiv/Dokumente/Agenda")) + ) + ) +#+end_src + +*** Org capture +#+begin_src emacs-lisp + (bind-key "C-c c" 'org-capture) + (setq org-default-notes-file "~/Archiv/Dokumente/Notizen/notes.org") +#+end_src + +** Org Setup +Speed commands are a nice and quick way to perform certain actions while at the beginning of a heading. It's not activated by default. + +See the doc for speed keys by checking out the documentation for speed keys in Org mode. + +#+begin_src emacs-lisp + (setq org-use-speed-commands t) + (setq org-image-actual-width 550) + (setq org-highlight-latex-and-related '(latex script entities)) +#+end_src + +** Org tags +The default value is -77, which is weird for smaller width windows. I'd rather have the tags align horizontally with the header. +45 is a good column number to do that. + +#+begin_src emacs-lisp + (setq org-tags-column 45) +#+end_src + +** Org babel languages + +#+begin_src emacs-lisp + (org-babel-do-load-languages + 'org-babel-load-languages + '((python . t) + (C . t) + (calc . t) + (latex . t) + (java . t) + (ruby . t) + (lisp . t) + (scheme . t) + (shell . t) + (sqlite . t) + (js . t))) + + (defun my-org-confirm-babel-evaluate (lang body) + "Do not confirm evaluation for these languages." + (not (or (string= lang "C") + (string= lang "java") + (string= lang "python") + (string= lang "emacs-lisp") + (string= lang "sqlite")))) + (setq org-confirm-babel-evaluate 'my-org-confirm-babel-evaluate) +#+end_src + +** Org babel/source blocks +I like to have source blocks properly syntax highlighted and with the editing popup window staying within the same window so all the windows don't jump around. Also, having the top and bottom trailing lines in the block is a waste of space, so we can remove them + +I noticed that fontification doesn't work with markdown mode when the block is indented after editing it in the org src buffer - the leading #s for headers don't get fontified properly because they apppear as Org comments. Setting ~org-src-preserve-identation~ makes things consistent as it doesn't pad source blocks with leading spaces + +#+begin_src emacs-lisp + (setq org-src-fontify-natively t + org-src-window-setup 'current-window + org-src-strip-leading-and-trailing-blank-lines t + org-src-preserve-indentation t + org-src-tab-acts-natively t) +#+end_src + + +* which-key +Greatly increases discovery of functions! +Click [[https://github.com/justbur/emacs-which-key][here]] for source and more info. +Info in Emacs: M-x customize-group which-key + +#+begin_src emacs-lisp + (use-package which-key + :ensure t + :diminish which-key-mode + :config + (which-key-mode) + (which-key-setup-side-window-right-bottom) + (which-key-setup-minibuffer) + (setq which-key-idle-delay 0.5) + ) +#+end_src +