Last active
February 3, 2022 23:50
-
-
Save mtekman/09ef535a0a44fa49ca482e84c5e9399d to your computer and use it in GitHub Desktop.
public emacs.d
This file contains 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
(setenv "LANG" "en_GB.UTF8") | |
;; Check this out: https://github.com/rememberYou/.emacs.d/blob/master/config.org | |
;; ----- BEGIN: Package Initialisation ----- | |
(setq package-archives | |
'(("melpa" . "https://melpa.org/packages/") | |
("gnu" . "https://elpa.gnu.org/packages/") | |
("org" . "https://orgmode.org/elpa/"))) | |
;; Fresh install? Initialise | |
;;(unless (file-directory-p (expand-file-name "~/.emacs.d/elpa")) | |
;;(unless package--initialized | |
(require 'package) | |
(package-initialize) | |
;; ----- END: Package Initialisation ----- | |
;; ----- BEGIN: Use-Package customizations ----- | |
(unless (package-installed-p 'use-package) | |
(package-refresh-contents) | |
(package-install 'use-package)) | |
;;(use-package delight) ;; from elpa | |
;; Redirect Emacs auto loads to junk file to load later | |
(setq-default auto-save-list-file-name "~/.emacs.d/auto-save-list" | |
custom-file "~/.emacs.d/custom.el") | |
(if (file-exists-p custom-file) | |
(load custom-file t)) | |
;; ----- END: Use-Package customizations ----- | |
;; -- TO SORT | |
(use-package gif-screencast | |
:bind (("<C-f9>" . gif-screencast) | |
("<f8>" . gif-screencast-toggle-pause) | |
("<f9>" . gif-screencast-stop))) | |
(use-package dumb-jump | |
:bind (("M-g a" . dumb-jump-go) | |
("M-g g" . dumb-jump-quick-look)) | |
:config (setq dumb-jump-selector 'company) | |
:ensure) | |
(use-package pomidor | |
:bind (("<f10>" . pomidor)) | |
:config (setq pomidor-sound-tick nil | |
pomidor-sound-tack nil | |
pomidor-time-format "") | |
:hook | |
(pomidor-mode . (lambda () | |
(display-line-numbers-mode -1) ; Emacs 26.1+ | |
(setq left-fringe-width 0 right-fringe-width 0) | |
(setq left-margin-width 2 right-margin-width 0) | |
;; force fringe update | |
(set-window-buffer nil (current-buffer))))) | |
(use-package nix-mode | |
:mode "\\.nix\\'" | |
:config | |
(add-hook 'before-save-hook 'nix-mode-format)) | |
(use-package company-nixos-options | |
:after (nix-mode nixos-options) | |
:config | |
(add-to-list 'company-backends 'company-nixos-options)) | |
;; ----- BEGIN: Theme Change ----- | |
(use-package monokai-theme :ensure :defer) | |
;;(use-package nyx-theme :ensure :defer) | |
(use-package leuven-theme :ensure :defer) | |
(use-package ample-zen-theme :ensure :defer) | |
(use-package gruvbox-theme :ensure :defer) | |
;; -- Rotate-themes -- | |
(load-theme 'leuven) | |
(defun rotate-themes () | |
"Rotate the themes." | |
(interactive) | |
(let ((theme-list '(nil leuven gruvbox ample-zen monokai misterioso)) | |
(current-theme (nth 0 custom-enabled-themes))) | |
(let* ((theme-index (position current-theme theme-list)) | |
(next-index (mod (+ theme-index 1) (length theme-list))) | |
(next-theme (nth next-index theme-list))) | |
(disable-theme current-theme) | |
(message "theme: %s" next-theme) | |
(if next-theme | |
(condition-case err | |
;; Enable the theme if emacs already has it | |
(enable-theme next-theme) | |
;; Otherwise load it | |
(error (load-theme next-theme))))))) | |
(global-set-key (kbd "C-c c") 'rotate-themes) | |
;; ----- END: Theme Change ----- | |
;; ----- BEGIN: Helper Functions for ~/.emacs/init.el | |
(defun get-paths (filePath) | |
"Return FILEPATH file content." | |
(with-temp-buffer | |
(insert-file-contents filePath) | |
(seq-filter | |
(lambda (p) | |
;; filter out any paths starting with ";;" | |
(not(string-prefix-p ";;" p))) | |
(split-string (buffer-string))))) | |
(defun debug-list (list) | |
"Print out LIST elements on a newline." | |
(interactive) | |
(insert (mapconcat 'identity list "\n"))) | |
;; (defun require-from-git (name author) | |
;; "Name of package (lowercase without the .el) and author on github" | |
;; (let* ((local-dir (concat "~/.emacs.d/custom/" name "/")) | |
;; (remote-file (concat "https://raw.githubusercontent.com/" author "/" name ".el/master/" name ".el")) | |
;; (local-file (concat local-dir (concat name ".el")))) | |
;; (add-to-list 'load-path local-dir) | |
;; (make-directory local-dir t) | |
;; (unless (file-exists-p local-file) | |
;; (require 'url) | |
;; (url-copy-file remote-file local-file nil) | |
;; (byte-recompile-file local-file)) | |
;; (let ((symb (intern-soft name))) | |
;; `(require ',symb)))) | |
;; | |
;; ----- END: Helper Functions for ~/.emacs/init.el | |
;; ---- My external customizations -- | |
;; | |
(global-set-key (kbd "C-c u") 'comment-or-uncomment-region) | |
(global-set-key (kbd "C--") 'undo) | |
(global-set-key (kbd "C-c t") 'toggle-truncate-lines) | |
(global-set-key (kbd "M-f") 'forward-whitespace) | |
;; (global-set-key (kbd "C-c o O") 'org-drill) | |
;; (global-set-key (kbd "C-c o o") 'org-drill-resume) | |
(global-set-key (kbd "C-c k") 'kill-buffer-and-window) | |
(global-set-key (kbd "M-d") 'delete-trailing-whitespace) | |
(global-set-key (kbd "M-r") 'revert-buffer) | |
;; Bookmarking | |
;; Default text-sizes | |
;;(set-face-attribute 'default nil :font "Source Code Pro") | |
(set-fontset-font t 'latin "Noto Sans") | |
;;(set-face-attributes 'default nil :height 100) | |
;; Init.el | |
(global-set-key (kbd "C-c o p") (lambda () (interactive) (find-file org-capture-projects))) | |
(global-set-key (kbd "C-c o s") (lambda () (interactive) (find-file "~/.stumpwm.d/init.lisp"))) | |
(global-set-key (kbd "C-c o n") (lambda () (interactive) (find-file "/sudo::/etc/nixos/configuration.nix"))) | |
(global-set-key (kbd "C-c o e") (lambda () (interactive) (find-file "~/.emacs.d/init.el"))) | |
(global-set-key (kbd "C-c o c") (lambda () (interactive) (find-file "~/repos/_mtekman/_configs/conf/conf.org"))) | |
(global-set-key (kbd "C-c o d") (lambda () (interactive) (switch-to-buffer "*dashboard*"))) | |
(setq-default | |
ad-redefinition-action 'accept ; Silence warnings for redefinition | |
cursor-in-non-selected-windows t ; Hide the cursor in inactive windows | |
display-time-default-load-average nil ; Don't display load average | |
;;fill-column nil ; Set width for automatic line breaks | |
help-window-select t ; Focus new help windows when opened | |
indent-tabs-mode nil ; Prefers spaces over tabs | |
inhibit-startup-screen t ; Disable start-up screen | |
initial-scratch-message "" ; Empty the initial *scratch* buffer | |
kill-ring-max 128 ; Maximum length of kill ring | |
load-prefer-newer t ; Prefers the newest version of a file | |
mark-ring-max 128 ; Maximum length of mark ring | |
scroll-conservatively most-positive-fixnum ; Always scroll by one line | |
select-enable-clipboard t ; Merge system's and Emacs' clipboard | |
tab-width 4 ; Set width for tabs | |
use-package-always-ensure t ; Avoid the :ensure keyword for each package | |
vc-follow-symlinks t ; Always follow the symlinks | |
tramp-default-method "ssh" | |
tramp-login-prompt-regexp "> .*" | |
view-read-only t ; Always open read-only buffers in view-mode | |
mode-require-final-newline nil | |
require-final-newline nil | |
) | |
(column-number-mode 1) ; Show the column number | |
(fset 'yes-or-no-p 'y-or-n-p) ; Replace yes/no prompts with y/n | |
(set-default-coding-systems 'utf-8) ; Default to utf-8 encoding | |
(show-paren-mode 1) ; Show the parent | |
(scroll-bar-mode -1) | |
(tool-bar-mode -1) | |
(tooltip-mode -1) | |
(menu-bar-mode -1) | |
(global-visual-line-mode 1) | |
(global-prettify-symbols-mode +1) | |
(desktop-save-mode 1) | |
(setq backup-directory-alist | |
`(("." . ,(concat user-emacs-directory "backups")))) | |
;; ----- BEGIN: Startup Views ----- | |
(use-package dashboard | |
;; Regex to match all bindings in this file | |
;; (re-search-forward "\"\( ?[CM]\\([- ][<>a-zA-Z]+\\)+\)\"[ \.]+\(['a-z-]+\)") | |
:if (< (length command-line-args) 2) | |
:ensure t | |
:config | |
(dashboard-setup-startup-hook) | |
(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*"))) | |
:custom | |
(dashboard-set-heading-icons t) | |
(dashboard-set-file-icons t) | |
(dashboard-set-init-info t) | |
(dashboard-set-navigator t) | |
(dashboard-set-footer nil) | |
(dashboard-center-content t) | |
(dashboard-items '(;;(custom . 10) | |
;;(bookmarks . 10) | |
(projects . 10) | |
(recents . 10)))) | |
;; -- Cursor -- | |
(setq cursor-type 'bar) | |
(setq blink-cursor-alist '((bar . hbar) (bar . nil))) | |
(use-package multiple-cursors | |
:bind (("C-S-c C-S-c" . mc/edit-lines) | |
("C-c >" . mc/mark-next-like-this) | |
("C-c <" . mc/mark-previous-like-this) | |
("C-c |" . mc/mark-all-like-this))) | |
(use-package all-the-icons | |
:ensure t | |
:init | |
(unless (file-exists-p | |
(concat (or (getenv "XDG_DATA_HOME") | |
(concat (getenv "HOME") "/.local/share")) | |
"/fonts/")) | |
(all-the-icons-install-fonts)) | |
:after dashboard) | |
(use-package all-the-icons-dired | |
:after all-the-icons | |
:hook dired) | |
;; ----- END: Startup Views ----- | |
;; ----- BEGIN: Buffer Navigation ----- | |
;; (use-package bm ;; Visual bookmarks | |
;; :bind | |
;; ("<C-f2>" . bm-toggle) | |
;; ("<f2>" . bm-next) | |
;; ("<S-f2>" . bm-previous)) | |
(use-package dired | |
:ensure nil | |
:delight "Dired " | |
:custom | |
(dired-auto-revert-buffer t) | |
(dired-dwim-target t) | |
(dired-hide-details-hide-symlink-targets nil) | |
(dired-listing-switches "-alh") | |
(dired-ls-F-marks-symlinks nil) | |
(dired-recursive-copies 'always)) | |
(use-package dired-narrow | |
:bind (("C-c C-n" . dired-narrow) | |
("C-c C-f" . dired-narrow-fuzzy) | |
("C-c C-r" . dired-narrow-regexp))) | |
(use-package dired-subtree | |
:bind (:map dired-mode-map | |
("<backtab>" . dired-subtree-cycle) | |
("<tab>" . dired-subtree-toggle))) | |
(use-package peep-dired | |
:ensure t | |
:defer t ; don't access `dired-mode-map' until `peep-dired' is loaded | |
:bind (:map dired-mode-map | |
("P" . peep-dired))) | |
(use-package dired-sidebar | |
:bind (("C-x C-n" . dired-sidebar-toggle-sidebar)) | |
:ensure t | |
:commands (dired-sidebar-toggle-sidebar) | |
:init | |
(add-hook 'dired-sidebar-mode-hook | |
(lambda () | |
(unless (file-remote-p default-directory) | |
(auto-revert-mode)) | |
(if (file-remote-p buffer-file-name) | |
(setq dired-sidebar-theme 'ascii) | |
(setq dired-sidebar-theme 'icons)))) | |
:config | |
(push 'toggle-window-split dired-sidebar-toggle-hidden-commands) | |
(push 'rotate-windows dired-sidebar-toggle-hidden-commands) | |
(setq dired-sidebar-subtree-line-prefix "--") | |
(setq dired-sidebar-theme 'icons) | |
(setq dired-sidebar-use-term-integration nil) | |
(setq dired-sidebar-use-custom-font t)) | |
;; (use-package shackle | |
;; :ensure t | |
;; :config | |
;; (shackle-mode t) | |
;; (setq shackle-rules | |
;; '((magit-popup-mode :select t :align right :size 0.4) | |
;; (flycheck-error-list-mode :select nil :align below :size 0.25) | |
;; (compilation-mode :select nil :align below :size 0.25) | |
;; (messages-buffer-mode :select t :align below :size 0.25) | |
;; (inferior-emacs-lisp-mode :select t :align below :size 0.25) | |
;; (ert-results-mode :select t :align below :size 0.5) | |
;; (calendar-mode :select t :align below :size 0.25) | |
;; (racer-help-mode :select t :align right :size 0.5) | |
;; (help-mode :select t :align right :size 0.5) | |
;; (helpful-mode :select t :align right :size 0.5) | |
;; (" *Deletions*" :select t :align below :size 0.25) | |
;; (" *Marked Files*" :select t :align below :size 0.25) | |
;; ("*Org Select*" :select t :align below :size 0.33) | |
;; ("*Org Note*" :select t :align below :size 0.33) | |
;; ("*Org Links*" :select t :align below :size 0.2) | |
;; (" *Org todo*" :select t :align below :size 0.2) | |
;; ("*Man.*" :select t :align below :size 0.5 :regexp t) | |
;; ("*Org Src.*" :select t :align right :size 0.5 :regexp t)))) | |
;; ----- END: Buffer Navigation ----- | |
;; ----- BEGIN: Completion ---- | |
(use-package company | |
:defer 0.5 | |
:delight "¢ø" | |
:custom | |
(company-begin-commands '(self-insert-command)) | |
(company-idle-delay .1) | |
(company-minimum-prefix-length 3) | |
(company-show-numbers t) | |
(company-tooltip-align-annotations 't) | |
(global-company-mode t)) | |
(use-package company-prescient | |
:custom | |
(company-prescient-mode 1) | |
(prescient-persist-mode 1)) | |
(use-package company-box | |
:after company | |
:diminish | |
:hook (company-mode . company-box-mode)) | |
;(use-package slime-company) | |
;; ----- END: Completion ----- | |
;; ----- BEGIN: Fun! ----- | |
;; (use-package omni-quotes) | |
;; -- Gives logging error | |
;; ----- END: Fun! ----- | |
;; ----- BEGIN: Global Mode Enhancers ----- | |
(use-package rainbow-delimiters :hook (prog-mode . rainbow-delimiters-mode)) | |
(use-package hideshow | |
:ensure nil | |
:delight "ħ" | |
:bind (("<s-tab>" . hs-toggle-hiding) | |
("<C-tab>" . hs-hide-all)) | |
:init (add-to-list 'hs-special-modes-alist | |
'(nxml-mode | |
"<!--\\|<[^/>]*[^/]>" "-->\\|</[^/>]*[^/]>" "<!--" | |
sgml-skip-tag-forward | |
nil)) | |
:hook ((prog-mode text-mode) . hs-minor-mode)) | |
(use-package vlf | |
:ensure t) | |
(use-package move-text | |
:bind (("<M-up>" . move-text-up) | |
("<M-down>" . move-text-down)) | |
:config (move-text-default-bindings)) | |
(use-package swiper | |
:ensure t | |
:config | |
(setq ivy-ignore-buffers '("\\` " "\\`\\*" "magit*")) | |
:bind (("C-S-s" . swiper) | |
("C-x C-b" . ivy-switch-buffer) | |
("C-x b" . list-buffers))) | |
;; (use-package bufler | |
;; :ensure t | |
;; :hook ((prog-mode text-mode) . bufler-mode) ;; global | |
;; :bind (("C-x C-b" . bufler-switch-buffer) | |
;; ("C-x C-S-b" . bufler-list))) | |
(use-package projectile | |
:ensure t | |
:delight "þ" | |
:diminish projectile-mode | |
:commands (projectile-mode projectile-switch-project projectile-find-file) | |
:bind (("C-c f" . projectile-find-file) | |
("C-c M-f" . projectile-switch-project) | |
("C-c s" . projectile-ripgrep)) | |
:config | |
(projectile-global-mode t) | |
(setq projectile-enable-caching t) | |
;;(setq projectile-switch-project-action #'projectile-dired) | |
(setq projectile-project-search-path (get-paths "~/.projectile_paths"))) | |
(use-package flx-ido | |
:ensure t | |
:after projectile) | |
(use-package ripgrep | |
:ensure t | |
:after projectile) | |
(use-package alert | |
:defer 1 | |
:custom (alert-default-style 'libnotify)) | |
(use-package powerline | |
:init | |
(with-eval-after-load 'after-init 'powerline-reset) ;; maybe just :defer t? | |
(powerline-default-theme) | |
;; required for minions to be compatible | |
(defpowerline powerline-major-mode "") | |
(defpowerline powerline-process "") | |
(defpowerline powerline-minor-modes minions-mode-line-modes) | |
:ensure t) | |
(use-package minions | |
:after (powerline) | |
:config | |
(setq minions-mode-line-lighter "[@]") | |
(setq minions-mode-line-delimiters nil) | |
(minions-mode 1)) | |
;; ----- END: Global Mode Enhancers ----- | |
(use-package biblio :disabled) ;; for searching and pulling paper refs | |
(use-package academic-phrases :disabled);; for speeeding up the bs | |
(use-package google-translate :disabled | |
:config | |
(setq google-translate-default-source-language "German" | |
google-translate-default-target-language "English" | |
google-translate-output-destination "echo-area") | |
:bind (("C-c G" . google-translate-at-point))) | |
;; ----- BEGIN: Development Packages ----- | |
(use-package magit | |
:bind (("C-c g" . magit-status) | |
("C-c -" . magit-diff-toggle-refine-hunk)) | |
:init | |
(setq vc-follow-symlinks t) ;; remove "Follow gc symlink" prompt | |
:config | |
;; Auto commit on emacs exit | |
(defun magit-projects-areyousure () | |
(interactive) | |
(require 'magit) | |
(let ((default-directory org-directory)) | |
;; (and (get-buffer "projects.org") (magit-anything-modified-p) | |
(if (magit-anything-modified-p) | |
(if (y-or-n-p "You have uncommitted changes in your Org, view changes? ") | |
(progn (switch-to-buffer "projects.org") (magit-status)))))) | |
(defun magit-projects-pull () | |
(interactive) | |
(require 'magit) | |
(if (string= | |
(concat (file-name-base buffer-file-name) "." | |
(file-name-extension buffer-file-name)) | |
"projects.org") | |
(let ((default-directory org-directory)) | |
(magit-call-git "pull")))) | |
:hook | |
(kill-emacs-query-functions . magit-projects-areyousure) | |
(save-buffer-kill-terminal . magit-projects-pull)) | |
;; (use-package nameless | |
;; :hook (emacs-lisp-mode . nameless)) | |
;;(use-package package-lint) | |
;; (use-package slime | |
;; :ensure t | |
;; :init | |
;; (setq inferior-lisp-program "ros -Q run") | |
;; (load (expand-file-name "~/.roswell/helper.el")) | |
;; (load (expand-file-name "~/.roswell/lisp/quicklisp/slime-helper.el"))) | |
;; ----- END: Development Packages ----- | |
;; ----- BEGIN: Window Enhancements section ----- | |
(use-package windmove | |
:commands windmove | |
:ensure nil | |
:init | |
(with-eval-after-load 'prog-mode) | |
(with-eval-after-load 'text-mode) | |
(define-minor-mode resize-mode | |
"Toggle resizing of current window" | |
:init-value nil | |
:lighter " resize" | |
:keymap | |
'(([left] . shrink-window-horizontally) | |
([right] . enlarge-window-horizontally) | |
([up] . enlarge-window) | |
([down] . shrink-window) | |
([return] . resize-mode))) | |
:bind (("<H-M-left>" . windmove-left) | |
("<H-M-up>" . windmove-up) | |
("<H-M-right>" . windmove-right) | |
("<H-M-down>" . windmove-down) | |
("H-M-r" . 'resize-mode))) | |
(use-package winner | |
:ensure nil | |
:config | |
(winner-mode 1) | |
:init | |
(defun window-conf (num retrieve) | |
"Set or RETRIEVE a window config saved in register NUM" | |
(if retrieve (jump-to-register num) | |
(window-configuration-to-register num)) | |
(message "Window Config %d %s." num | |
(if retrieve "retrieved" "set"))) | |
(defun window-conf-set () | |
(interactive) | |
(let ((num (read-number "Window Conf to: "))) | |
(window-conf num nil))) | |
(defun window-conf-get () | |
(interactive) | |
(let ((num (read-number "Window Conf from: "))) | |
(window-conf num t))) | |
;; ((Buffer-Position) list), popping and jumping | |
(setq marklist '()) | |
(defun find-overlays-specifying (prop pos) | |
(let ((overlays (overlays-at pos)) found) | |
(while overlays | |
(let ((overlay (car overlays))) | |
(if (overlay-get overlay prop) | |
(setq found (cons overlay found)))) | |
(setq overlays (cdr overlays))) found)) | |
(defun highlight-or-dehighlight-line (highl) | |
(interactive) | |
(let* ((lbeg (line-beginning-position)) (lend (+ 1 lbeg)) | |
(hlines (find-overlays-specifying 'line-highlight-overlay-marker lbeg))) | |
(if (not highl) | |
(if hlines | |
(remove-overlays lbeg lend)) | |
(unless hlines | |
(let ((overlay-highlight (make-overlay lbeg lend))) | |
(overlay-put overlay-highlight 'face '(:background "lightblue")) | |
(overlay-put overlay-highlight 'line-highlight-overlay-marker t)))))) | |
(defun push-to-marklist () | |
(interactive) | |
(let* ((npoint (point)) | |
(buff (current-buffer)) | |
(tmp (list (cons buff npoint)))) | |
(pushnew | |
tmp marklist | |
:test (lambda (x y) | |
(let ((b1 (car (car x))) (p1 (cdr (car x))) | |
(b2 (car (car y))) (p2 (cdr (car y)))) | |
(and (eq b1 b2) (eq p1 p2))))) | |
(highlight-or-dehighlight-line t) | |
(message "%d → (%s)" npoint | |
(mapconcat (lambda (x) (format "%d" (cdr (car x)))) | |
(cdr marklist) " ")))) | |
(defun pop-from-marklist () | |
(interactive) | |
(let ((bufind (pop marklist))) | |
(if bufind | |
(let ((buff (car (car bufind))) | |
(pos (cdr (car bufind)))) | |
(switch-to-buffer buff) | |
(goto-char pos) | |
(highlight-or-dehighlight-line nil) | |
(message "Jumping: %s (%d)" (buffer-name buff) pos)) | |
(message "Empty marker list")))) | |
:bind (("C-c <left>" . winner-undo) | |
("C-c <right>" . winner-redo) | |
("C-S-c w" . window-conf-set) | |
("C-c w" . window-conf-get) | |
("C-S-p" . pop-from-marklist) | |
("C-p" . push-to-marklist))) | |
;; ----- END: Window Enhancements section ----- | |
;; ----- BEGIN: Terminals Section ----- | |
(use-package popwin | |
:ensure t | |
:init | |
;; Terminal-Toggle (waiting on MELPA to make this a package) | |
;; (require-from-git "terminal-toggle" "mtekman") | |
:custom | |
(popwin:popup-window-height 30)) | |
;;(push '("magit.*" :regexp t :width 100 :height 100) popwin:special-display-config) | |
;;:bind ("C-t" . terminal-toggle)) | |
;; ----- END: Terminals Section ----- | |
;; ----- BEGIN: Native package delighters ----- | |
(use-package flycheck | |
:delight "_ " | |
:ensure nil | |
:init | |
(with-eval-after-load 'prog-mode)) | |
(use-package eldoc | |
:delight | |
:ensure nil) | |
;; ----- END: Native package delighters ----- | |
;; ----- BEGIN: Language Specific Packages ----- | |
(use-package python-mode :ensure :defer) | |
(use-package elpy | |
:ensure t | |
:commands elpy-enable | |
:delight "π " | |
:mode "\\.py" | |
:init | |
(advice-add 'python-mode :before 'elpy-enable) | |
;; Function to allow python3 to work in Elpy | |
(with-eval-after-load 'python | |
(defun python-shell-completion-native-try () | |
"Return non-nil if can trigger native completion." | |
(let ((python-shell-completion-native-enable t) | |
(python-shell-completion-native-output-timeout | |
python-shell-completion-native-try-output-timeout)) | |
(python-shell-completion-native-get-completions | |
(get-buffer-process (current-buffer)) | |
nil "_")))) | |
;; Fix to ESS mode which uses outdated flymake instead of flycheck | |
:config | |
(remove-hook 'elpy-modules 'elpy-module-flymake) | |
:custom | |
(elpy-rpc-python-command "python3") | |
;;(flycheck-checker 'python-flake8) | |
(flycheck-mode 1)) | |
;; un-tested | |
(use-package flycheck-pyflakes | |
:delight "Flakes" | |
:mode "\\.py") | |
(use-package ess | |
:delight "ESS" | |
:defer 2 | |
:init | |
;; Fix to ESS mode which uses outdated flymake instead of flycheck | |
:hook (ess-mode . (lambda () (flymake-mode -1) (flycheck-mode t)))) ;; un-tested | |
(use-package snakemake-mode :magic ("%.snakemake" . snakemake-mode)) | |
(use-package markdown-mode | |
:delight "μ " | |
:magic ("%.md" . markdown-mode) | |
:custom (markdown-command "/usr/bin/pandoc")) | |
(use-package yaml-mode ) | |
(use-package config-general-mode ) | |
(use-package flyspell | |
; need to have hunspell-en_GB installed | |
:ensure nil | |
:delight "ϝ " | |
:hook (;;((markdown-mode text-mode) . flyspell-mode) ;; this enables for all org buffers... | |
;; Only enable for small org files | |
(org-mode . (lambda () (unless (string= buffer-file-name | |
(expand-file-name org-capture-projects)) | |
(flyspell-mode t)))) | |
(prog-mode . flyspell-prog-mode)) | |
:custom | |
(flyspell-abbrev-p t) | |
(ispell-program-name "hunspell") | |
(flyspell-default-dictionary "en_GB") | |
(flyspell-issue-message-flag nil) | |
(flyspell-issue-welcome-flag nil) | |
:bind | |
(("C-c C-SPC" . flyspell-correct-word-before-point))) | |
(use-package nxml-mode | |
:ensure nil | |
:custom | |
(nxml-child-indent 4)) | |
(use-package emmet-mode | |
:delight "EM" | |
:hook ((nxml-mode))) | |
;; ----- END: Language Specific Packages ----- | |
;; ----- BEGIN: Bookmark Syncing ----- | |
(use-package bookmark | |
:ensure nil | |
:init | |
:bind | |
(("C-c b s" . bookmark-set) | |
("C-c b S" . bookmark-save) | |
("C-c b j" . bookmark-jump) | |
("C-c b l" . bookmark-bmenu-list))) | |
;; ----- END: Bookmark Syncing ----- | |
;; ----- BEGIN: Org-Mode Section ----- | |
(let ((org-location "~/.org_location")) | |
(unless (file-exists-p org-location) | |
(message "Org root directory not set") | |
(append-to-file | |
(read-directory-name "Enter org-root directory (ssh or other): ") | |
nil org-location))) | |
(setq org-directory (car (get-paths "~/.org_location"))) | |
;;(setq org-capture-tickler (concat org-directory "/gtd/tickler.org")) | |
;;(setq org-capture-gmail "~/gmail_inbox.org") | |
(use-package org | |
:ensure org-plus-contrib ;; use org-plus version of org-mode, not vanilla shipped with emacs | |
:mode ("\\.org\\'" . org-mode) | |
:bind (("C-c C-w" . org-refile) | |
;; ("C-c l" . org-store-link) | |
;; ("C-c c" . org-capture) | |
("C-c a" . org-agenda) | |
;; ("C-c s" . org-iswitchb) | |
;; ("C-c C-x C-o" . org-clock-out) | |
;; ("C-c j" . org-clock-goto) | |
;; ("C-c e e" . (lambda () (interactive) (export-todos))) | |
) | |
:init | |
;; General org configs | |
(setq org-modules '(org-bbdb org-bibtex org-docview org-gnus org-info org-mhe org-drill) | |
org-hide-emphasis-markers t | |
org-babel-load-languages '((python . t) (R . t) (awk . t) (shell . t) (emacs-lisp . t) (latex . t)) | |
;; The GTD part of this config is heavily inspired by | |
;; https://emacs.cafe/emacs/orgmode/gtd/2017/06/30/orgmode-gtd.html | |
org-capture-projects (concat org-directory "/gtd/projects.org")) | |
(require 'cl) | |
;;(require 'org-drill) | |
:config | |
(setq org-agenda-files (list org-capture-projects) | |
org-refile-target-names org-capture-projects | |
org-refile-targets | |
'((nil :maxlevel . 10) | |
(org-refile-target-names :maxlevel . 10)) | |
org-log-done 'time | |
org-src-window-setup 'current-window | |
org-src-fontify-natively t | |
org-src-tab-acts-natively t ;; indenting in tabs | |
org-use-speed-commands t | |
org-highlight-sparse-tree-matches nil | |
org-use-fast-todo-selection 'expert | |
org-todo-keywords | |
'((sequence "SOMEDAY" "TODO(t)" "DOING(d!)" "PAUSED(p@/!)" "WAITING(w@/!)" "|" "DONE" "CANCELLED")) | |
org-todo-keyword-faces | |
'(("TODO" . (:foreground "DodgerBlue" :weight ultra-bold)) | |
("DOING" . (:foreground "Red" :weight ultra-bold)) | |
("PAUSED" . (:foreground "DarkSlateGray" :weight extra-bold)) | |
("SOMEDAY" . (:foreground "FireBrick4" :weight extra-bold)) | |
("WAITING" . (:foreground "LightBlue4" :weight extra-bold))) | |
;;org-agenda-hide-tags-regexp "@.*" ;; hide @contexts tags in the tags column | |
atypical-format " %i %-12:T" | |
org-refile-use-outline-path t ;; full refile paths | |
outline-path-complete-in-steps nil) ;; Show full path when autocompleting | |
;; ----- Custom Functions ----- ;; | |
;; (defun place-agenda-tags () | |
;; (setq org-agenda-tags-column 0) | |
;; (setq org-tags-column 0) | |
;; (org-agenda-align-tags)) | |
;; Exporting todos | |
(defun export-todos () | |
(with-current-buffer "projects.org" | |
(progn (org-html-export-as-html nil nil t nil) | |
(with-current-buffer "*Org HTML Exort*" | |
(write-file "/tmp/test.html"))))) | |
;; Always embed images directly within HTML | |
(defun org-html--format-image (source attributes info) | |
(progn | |
(setq source (replace-regexp-in-string | |
(regexp-quote "%20") " " source nil 'literal)) | |
(format "<img src=\"data:image/%s;base64,%s\"%s />" | |
(or (file-name-extension source) "") | |
(base64-encode-string | |
(with-temp-buffer | |
(insert-file-contents-literally source) | |
(buffer-string))) | |
(file-name-nondirectory source)))) | |
;; clock settings | |
;;(setq org-clock-persist t) | |
;;(org-clock-persistence-insinuate) | |
;;(setq org-time-clocksum-format '(:hours "%d" :require-hours t :minutes ":%02d" :require-minutes t)) | |
) | |
;; Quick code templates | |
(use-package org-tempo :ensure org-plus-contrib :after org) | |
;; Nice bullet points. Retires org-bullets. | |
(use-package org-superstar :after org :hook (org-mode . org-superstar-mode)) | |
(use-package org-super-agenda | |
:ensure t | |
:after org | |
:config | |
(org-super-agenda-mode 1) | |
(setq org-super-agenda-groups | |
'(;; Each group has an implicit boolean OR operator between its selectors. | |
(:name "Work" | |
;; :time-grid t | |
:tag ("galaxy" "projects" "talks" "@teaching")) | |
(:name "Personal" | |
:tag ("life" "recreation") | |
:order 9) | |
(:name "Someday" | |
:todo "SOMEDAY" | |
:date nil | |
:order 10) | |
;; Set order of multiple groups at once | |
(:order-multi (2 (:name "Shopping in town" | |
;; Boolean AND group matches items that match all subgroups | |
:and (:tag "shopping" :tag "@town")) | |
(:name "Food-related" | |
;; Multiple args given in list with implicit OR | |
:tag ("food" "dinner")) | |
(:name "Personal" | |
:habit t | |
:tag "personal") | |
(:name "Space-related (non-moon-or-planet-related)" | |
;; Regexps match case-insensitively on the entire entry | |
:and (:regexp ("" "") | |
;; Boolean NOT also has implicit OR between selectors | |
:not (:regexp "moon" :tag "planet"))))) | |
;; Groups supply their own section names when none are given | |
(:todo "WAITING" :order 8) ; Set order of this section | |
(:todo ("SOMEDAY" "TO-READ" "CHECK" "TO-WATCH" "WATCHING") | |
;; Show this group at the end of the agenda (since it has the | |
;; highest number). If you specified this group last, items | |
;; with these todo keywords that e.g. have priority A would be | |
;; displayed in that group instead, because items are grouped | |
;; out in the order the groups are listed. | |
:order 9) | |
(:priority<= "B" | |
;; Show this section after "Today" and "Important", because | |
;; their order is unspecified, defaulting to 0. Sections | |
;; are displayed lowest-number-first. | |
:order 1) | |
;; After the last group, the agenda will display items that didn't | |
;; match any of these groups, with the default order position of 99 | |
)) | |
:bind ("C-c a" . (lambda ()(interactive)(org-agenda nil "a")))) | |
;; ---- BEGIN: Org macros ---- | |
(defun sparse-todo-all () | |
(interactive) | |
(with-current-buffer "projects.org" | |
(org-match-sparse-tree t "TODO={TODO\\|DOING\\|WAITING\\|PAUSED}"))) | |
(defun sparse-todo-doing-waiting () | |
(interactive) | |
(with-current-buffer "projects.org" | |
(org-match-sparse-tree t "TODO={DOING\\|WAITING}"))) | |
(defun sparse-optional () | |
(interactive) | |
(with-current-buffer "projects.org" | |
(org-match-sparse-tree t "TODO=\"OPTIONAL\""))) | |
(defun sparse-todo-deadline-week () | |
(interactive) | |
(with-current-buffer "projects.org" | |
;; TODO + SCHEDULED or DEADLINE before <+7d> | |
;; see here: https://www.gnu.org/software/emacs/manual/html_node/org/Matching-tags-and-properties.html | |
(org-match-sparse-tree t "TODO={TODO\\|DOING\\|WAITING\\|PAUSED}&DEADLINE<=\"<+1w>\""))) | |
(defun sparse-todo-deadline-month () | |
(interactive) | |
(with-current-buffer "projects.org" | |
;; TODO + SCHEDULED or DEADLINE before <+7d> | |
(org-match-sparse-tree t "TODO={TODO\\|DOING\\|WAITING\\|PAUSED}&DEADLINE<=\"<+1m>\""))) | |
(defun sparse-todo-after () | |
(interactive) | |
(with-current-buffer "projects.org" | |
(org-match-sparse-tree t "TODO={TODO\\|DOING\\|WAITING\\|PAUSED}&PRIORITY>\"D\""))) | |
(defun sparse-todo-donelast () | |
(interactive) | |
(with-current-buffer "projects.org" | |
(org-match-sparse-tree nil "CLOSED>=\"<-1w>\""))) | |
(global-set-key (kbd "C-c v d") 'sparse-todo-doing-waiting) | |
(global-set-key (kbd "C-c v t") 'sparse-todo-all) | |
(global-set-key (kbd "C-c v o") 'sparse-optional) | |
(global-set-key (kbd "C-c v w") 'sparse-todo-deadline-week) | |
(global-set-key (kbd "C-c v m") 'sparse-todo-deadline-month) | |
(global-set-key (kbd "C-c v a") 'sparse-todo-after) | |
(global-set-key (kbd "C-c v f") 'sparse-todo-donelast) | |
;; My packages | |
(use-package org-tanglesync | |
:delight " sync" | |
:load-path ("~/repos/_mtekman/_elisp/org-tanglesync.el") | |
:hook (;;(org-mode . org-tanglesync-mode) | |
((prog-mode text-mode) . org-tanglesync-watch-mode)) | |
:custom | |
(org-tanglesync-watch-files '("~/repos/_mtekman/_configs/conf/conf.org")) | |
:bind | |
(( "C-c M-i" . org-tanglesync-process-buffer-interactive) | |
( "C-c M-a" . org-tanglesync-process-buffer-automatic))) | |
(use-package org-treescope | |
:delight " scope" | |
:load-path ("~/repos/_mtekman/_elisp/org-treescope.el") | |
:bind | |
(( "C-c M-s" . org-treescope-mode))) | |
(use-package org-treeusage | |
:bind ("C-c d" . org-treeusage-mode) | |
:custom | |
;; Below two settings recreate the above image | |
((org-treescope-overlay-header nil) | |
(org-treeusage-overlay-usecolorbands nil))) | |
(use-package org-calories | |
:load-path ("~/repos/_mtekman/_elisp/org-calories.el") | |
:bind (("C-c l" . org-calories-log) | |
("C-c e" . org-calories-entry) | |
("C-c j" . org-calories-macros-printlast) | |
("C-c 1" . org-calories-log-show) | |
("C-c 2" . org-calories-db-show)) | |
:custom | |
(org-calories-db-file "~/repos/_mtekman/myorg/gtd/database.org") | |
(org-calories-log-file "~/repos/_mtekman/myorg/gtd/logbook.org")) | |
(use-package elisp-depmap | |
:load-path ("~/repos/_mtekman/_elisp/elisp-depmap.el") | |
:bind (("C-c M-d" . elisp-depmap-graphviz-digraph) | |
("C-c M-g" . elisp-depmap-graphviz) | |
("C-c M-s" . elisp-depmap-makesummarytable)) | |
:custom ((elisp-depmap-exec-file "~/graphviz2.dot"))) | |
(use-package remind-bindings | |
:hook | |
(after-init-hook . remind-bindings-initialise) | |
:bind | |
(("C-c C-d" . remind-bindings-togglebuffer))) | |
;; ---- END: Org Macros | |
;; (use-package org-ehtml | |
;; :requires web-server | |
;; :config | |
;; (setq org-ehtml-docroot (expand-file-name "~/public_org")) | |
;; (setq org-ehtml-everything-editable t) | |
;; :init | |
;; (require 'org-ehtml) | |
;; (ws-start org-ehtml-handler 9000)) | |
;; ----- END: Org-Mode section ----- | |
(put 'downcase-region 'disabled nil) ;; command to downcase a string, disabled by default | |
(put 'dired-find-alternate-file 'disabled nil) | |
(use-package wiki-summary :disabled | |
:bind ("M-a" . wiki-summary)) | |
;; Retired | |
;; -- Unused org modules -- | |
;; (use-package org-inlinetask :disabled | |
;; :after org | |
;; :bind (:map org-mode-map | |
;; ("C-c C-x t" . org-inlinetask-insert-task)) | |
;; :after (org) | |
;; :commands (org-inlinetask-insert-task)) | |
;; (use-package org-bullets :disabled | |
;; :init | |
;; (with-eval-after-load 'org-mode) | |
;; :hook (org-mode . org-bullets-mode) | |
;; :custom | |
;; (org-bullets-bullet-list '("○" "●" "►" "▸" "♪" "♫" "♬"))) | |
;; (use-package org-fancy-priorities :disabled | |
;; :ensure t | |
;; :hook (org-mode . org-fancy-priorities-mode) | |
;; :config | |
;; (setq org-fancy-priorities-list '("Now" "Today" "3Days" "Week" "2Weeks" | |
;; "Month" "3Months" "6Months" "9Months" | |
;; "Year" "Whenever")) | |
;; (setq org-highest-priority 65) | |
;; (setq org-lowest-priority 75) | |
;; (setq org-default-priority 66)) | |
;; (use-package org-journal :disabled | |
;; :after org | |
;; :bind (("C-c j" . org-journal-new-entry)) | |
;; :config | |
;; (setq org-journal-dir (concat org-directory "/Notes/Journal"))) | |
;; (use-package org-drill-table :disabled | |
;; :ensure t | |
;; :bind (("C-c C-d g" . org-drill-table-generate) | |
;; ("C-c C-d u" . org-drill-table-update) | |
;; ("C-c C-d a" . org-drill-table-update-all))) | |
;; -- Syncing bookmarks is dumb. Too many different local bookmarks to sync | |
;; Set remote bookmark location in | |
;; (defun sync-bookmarks () | |
;; (interactive) | |
;; (let ((remote-bookmarks-location "~/.emacs.d/remote_bookmarks_location")) | |
;; (unless (file-exists-p remote-bookmarks-location) | |
;; (message "Remote bookmarks not set") | |
;; (append-to-file | |
;; (read-string "Enter remote bookmarks file (ssh:/etc): ") | |
;; nil remote-bookmarks-location)) | |
;; (let ((local-bookmarks-file "~/.emacs.d/bookmarks") | |
;; (remote-bookmarks-file (car (get-paths remote-bookmarks-location)))) | |
;; (unless (file-exists-p local-bookmarks-file) | |
;; (write-region "" nil local-bookmarks-file)) | |
;; (setq bookmark-default-file local-bookmarks-file) | |
;; (setq bookmark-save-flag 1) ;; save bookmarks on every bookmark added | |
;; ;; -- Sync :: update remote | |
;; (when (or (file-newer-than-file-p remote-bookmarks-file local-bookmarks-file) | |
;; (file-newer-than-file-p local-bookmarks-file remote-bookmarks-file)) | |
;; (diff remote-bookmarks-file local-bookmarks-file))))) | |
;; (defun insert-with-face (string color) | |
;; (insert (propertize string 'font-lock-face `'(:foreground ,color)))) | |
;; (defun dashboard-show-shortcuts (list-size) | |
;; (insert-with-face "Shortcuts you need to practice:\n" "Green") | |
;; (insert-with-face "[General]\n" "Red") | |
;; (insert "M-r revert-buffer\n" | |
;; "C-S-s swiper\n" | |
;; "C-c f projectile-find-file\n" | |
;; "C-S-c f projectile-switch-project\n" | |
;; "C-S-c s projectile-ripgrep\n") | |
;; (insert-with-face "[Bookmarking]\n" "Red") | |
;; (insert "C-c b l (bookmarks)\n" | |
;; "C-c b s (add bookmark)\n" | |
;; "C-c b j (jump to bookmark)\n")) | |
;; ;;(insert "Play around with [[HABITS]https://orgmode.org/manual/Tracking-your-habits.html#Tracking-your-habits]") | |
;;(add-to-list 'dashboard-item-generators '(custom . dashboard-show-shortcuts)) | |
;;(add-to-list 'dashboard-items '(custom) t) | |
;; | |
;; Bookmark + | |
;; (setq bookmarkplus-dir "~/.emacs.d/custom/bookmark-plus/") | |
;; (use-package bookmark+ | |
;; :load-path bookmarkplus-dir | |
;; :init | |
;; (let ((emacswiki-base "https://www.emacswiki.org/emacs/download/") | |
;; (bookmark-files '("bookmark+.el" "bookmark+-mac.el" "bookmark+-bmu.el" "bookmark+-key.el" "bookmark+-lit.el" "bookmark+-1.el"))) | |
;; (add-to-list 'load-path bookmarkplus-dir) | |
;; (make-directory bookmarkplus-dir t) | |
;; (mapcar (lambda (arg) | |
;; (let ((local-file (concat bookmarkplus-dir arg))) | |
;; (unless (file-exists-p local-file) | |
;; (progn (require 'url) | |
;; (url-copy-file (concat emacswiki-base arg) local-file t))))) | |
;; bookmark-files) | |
;; (byte-recompile-directory bookmarkplus-dir 0) | |
;; (global-unset-key (kbd "C-b"))) | |
;; :config | |
;; (setq bookmark-default-file "~/.emacs.d/bookmarks" | |
;; bookmark-version-control t | |
;; bookmark-save-flag 2 | |
;; bmkp-count-multi-mods-as-one-flag t | |
;; bookmark-automatically-show-annotations t | |
;; bmkp-bmenu-state-file t) | |
;; :bind (("C-b s" . bmkp-bookmark-set-confirm-overwrite) | |
;; ("C-b f" . bmkp-find-file) | |
;; ("C-b l" . bookmark-bmenu-list)) | |
;; :hook (emacs-startup . bookmark-bmenu-list)) | |
;; Force tramp to respect remote PATH vars | |
;; (add-to-list 'tramp-remote-path 'tramp-own-remote-path) | |
;; ;; Enable the new eshell prompt | |
;; (setq eshell-prompt-function 'esh-prompt-func) | |
(put 'erase-buffer 'disabled nil) | |
(put 'list-timers 'disabled nil) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment