My Emacs configuration.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
.emacs.d/init.el

1675 lines
60 KiB

5 years ago
;;; Init.el --- Daniel's Emacs Configuration
;;; Commentary:
;;; Code:
;; * Packages
(defconst emacs-d (file-name-directory
(file-chase-links load-file-name))
"The giant turtle on which the world rests.")
(require 'package)
(setq package-user-dir (expand-file-name "elpa" emacs-d))
(setq package-archives
'(("melpa" . "https://melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/")
("melpa-stable" . "https://stable.melpa.org/packages/")
("org" . "http://orgmode.org/elpa/")))
(setq package-enable-at-startup nil)
(package-initialize)
(dolist (package '(diminish use-package bind-key))
(unless (package-installed-p package)
(package-install package))
(require package))
(put 'use-package 'common-lisp-indent-function 1)
(use-package auto-compile
:ensure t)
;; * Mode activation
(defun db/run-init ()
"Run main initialization after everything is set up."
;; Activate modes
(show-paren-mode 1)
(transient-mark-mode 1)
(global-font-lock-mode 1)
(column-number-mode 1)
;; (display-time)
(delete-selection-mode 1)
(dolist (mode '(tool-bar-mode
scroll-bar-mode
menu-bar-mode
blink-cursor-mode))
(when (fboundp mode)
(funcall mode 0)))
(when (<= 24 emacs-major-version)
(electric-indent-mode -1))
(appt-activate +1)
(savehist-mode 1)
(midnight-mode +1)
(quietly-read-abbrev-file)
(global-undo-tree-mode 1)
(ace-window-display-mode +1)
(electric-pair-mode +1)
(electric-quote-mode +1)
(key-chord-mode +1)
(size-indication-mode 1)
(display-battery-mode -1)
(sml/setup)
(ivy-mode +1)
(recentf-mode t)
(which-key-mode 1)
(winner-mode 1)
(global-auto-revert-mode -1)
(projectile-mode +1)
(which-function-mode +1)
;; setting this in `custom-file’ does not work, so we set it here
(custom-set-variables
'(custom-enabled-themes (quote (exot-main
solarized-dark
smart-mode-line-dark))))
5 years ago
;; Hooks
(add-hook 'minibuffer-setup-hook #'conditionally-enable-lispy)
(add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)
(add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p)
(add-hook 'text-mode-hook #'turn-on-auto-fill)
(add-hook 'before-save-hook #'db/delete-trailing-whitespace-maybe)
(add-hook 'prog-mode-hook #'turn-on-page-break-lines-mode)
(when (<= 24 emacs-major-version)
(add-hook 'prog-mode-hook #'electric-indent-local-mode))
(add-hook 'lisp-mode-hook #'lispy-mode)
;; Keybindings
(bind-key "<XF86Back>" #'winner-undo)
(bind-key "<XF86Forward>" #'winner-redo)
(bind-key "<f1>" #'db/run-or-hide-eshell)
(bind-key "<f2> i" #'counsel-info-lookup-symbol)
(bind-key "<f2> u" #'counsel-unicode-char)
(bind-key "<f5>" #'counsel-ag)
(bind-key "<f6>" #'hydra-zoom/body)
(bind-key "<f7>" #'dictcc)
(bind-key "<f8>" #'counsel-locate)
(bind-key "<f9>" #'counsel-org-goto-all)
(bind-key "<f10>" #'magit-status)
5 years ago
(bind-key "<f11>" #'org-capture)
5 years ago
(bind-key "<f12>" #'db/helm-shortcuts)
(bind-key "C-<" #'mc/mark-previous-like-this)
(bind-key "C->" #'mc/mark-next-like-this)
(bind-key "C-@" #'er/expand-region)
(bind-key "C-M-\\" #'crux-cleanup-buffer-or-region)
(bind-key "C-S-c C-S-c" #'mc/edit-lines)
(bind-key "C-Z" #'undo-tree-redo)
(bind-key "C-c C-<" #'mc/mark-all-like-this)
(bind-key "C-c C-r" #'ivy-resume)
(bind-key "C-c D" #'define-word)
(bind-key "C-c J" #'avy-goto-word-or-subword-1)
(bind-key "C-c P" #'ivy-pages)
(bind-key "C-c a" #'org-agenda)
(bind-key "C-c c" #'org-capture)
(bind-key "C-c d" #'define-word-at-point)
(bind-key "C-c e" #'crux-eval-and-replace)
(bind-key "C-c h" #'helm-command-prefix)
(bind-key "C-c h #" #'helm-emms)
5 years ago
(bind-key "C-c i" #'hydra-ispell/body)
(bind-key "C-c j" #'avy-goto-char-timer)
(bind-key "C-c l" #'org-store-link)
(bind-key "C-c m" #'emms-control/body)
(bind-key "C-c o" #'hydra-org-clock/body)
5 years ago
(bind-key "C-c r" #'ivy-recentf)
5 years ago
(bind-key "C-c s" #'synonyms)
(bind-key "C-h C-f" #'find-function)
(bind-key "C-h C-k" #'find-function-on-key)
(bind-key "C-h f" #'counsel-describe-function)
(bind-key "C-h v" #'counsel-describe-variable)
(bind-key "C-s" #'isearch-forward)
(bind-key "C-S-s" #'counsel-grep-or-swiper)
(bind-key "M-i" #'swiper-from-isearch isearch-mode-map)
(bind-key "C-x C-d" #'dired)
(bind-key "C-x C-f" #'counsel-find-file)
(bind-key "C-x C-r" #'revert-buffer)
(bind-key "C-x g" #'db/helm-shortcuts)
5 years ago
(bind-key "C-x SPC" #'hydra-rectangle/body)
(bind-key "C-x o" #'ace-window)
(bind-key "C-x r v" #'list-registers)
(bind-key "C-x t" #'hydra-toggle/body)
(bind-key "C-z" #'undo)
(bind-key "M-/" #'hippie-expand)
(bind-key "M-:" #'pp-eval-expression)
(bind-key "M-=" #'count-words)
(bind-key "M-SPC" #'cycle-spacing)
(bind-key "M-Z" #'zap-to-char)
(bind-key "M-g M-g" #'avy-goto-line)
(bind-key "M-g g" #'avy-goto-line)
(bind-key "M-g j b" #'dumb-jump-back)
(bind-key "M-g j g" #'dumb-jump-go)
(bind-key "M-j" #'(lambda () (interactive) (join-line -1)))
(bind-key "M-o" nil)
(bind-key "M-x" #'counsel-M-x) ; gets nicer sorting with smex installed
(bind-key "M-y" #'helm-show-kill-ring)
(bind-key "M-z" #'zap-up-to-char)
(bind-key [insert] nil)
(bind-key [kp-insert] nil)
(bind-key [remap fill-paragraph] #'endless/fill-or-unfill)
(bind-key [remap kill-whole-line] #'crux-kill-whole-line)
(bind-key [remap open-line] #'crux-smart-open-line-above)
;; Timers
(run-with-timer 0 3600 #'org-clock-save)
(run-with-timer 0 3600 #'recentf-save-list)
(run-with-timer 0 3600 #'bbdb-save)
(run-with-timer 0 3600 #'emms-cache-save)
(run-with-idle-timer 1200 t #'db/export-diary)
(run-at-time "00:01" 86400 #'db/org-agenda-to-appt)
;; Environment Variables
(exec-path-from-shell-copy-envs '("SSH_AUTH_SOCK"
"SSH_AGENT_PID"
"PATH"
"TEXMFHOME"
"PERL5LIB"
"PERL_LOCAL_LIB_ROOT"
"PERL_MB_OPT"
"PERL_MM_OPT"))
5 years ago
t)
(add-hook 'after-init-hook #'db/run-init)
;; * Builtin Variables
(use-package db-private
:load-path "site-lisp"
:defines (db/personal-mail-address
db/work-mail-address
db/jabber-id
db/smtp-accounts
db/work-gnus-filter-rules
db/personal-gnus-filter-rules))
(setq user-full-name "Daniel Borchmann"
user-mail-address db/personal-mail-address)
(setq explicit-shell-file-name "/usr/bin/zsh"
shell-file-name "/usr/bin/zsh")
(setq custom-file (expand-file-name "private/custom.el" emacs-d))
5 years ago
(load-file custom-file)
(use-package cl-lib)
(use-package warnings
:config (cl-pushnew '(undo discard-info) warning-suppress-types
:test #'equal))
(set-default-coding-systems 'utf-8)
(prefer-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(setq buffer-file-coding-system 'utf-8)
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))
(setq inhibit-startup-message t
initial-scratch-message nil
initial-major-mode 'org-mode
ring-bell-function #'ignore
garbage-collection-messages nil
load-prefer-newer nil) ; t breaks `org-reload'
(fset 'yes-or-no-p 'y-or-n-p)
(setq-default fill-column 80)
(setq-default indent-tabs-mode nil)
(setq frame-title-format "emacs")
(setq select-enable-clipboard t
select-enable-primary t
save-interprogram-paste-before-kill t
mouse-yank-at-point t
require-final-newline nil
sentence-end-double-space t
recenter-positions '(top middle bottom)
scroll-conservatively 10
message-log-max t
inhibit-eol-conversion nil
tab-always-indent 'complete
enable-recursive-minibuffers t
set-mark-command-repeat-pop t
large-file-warning-threshold 100000000
echo-keystrokes 0.1
delete-by-moving-to-trash t
delete-trailing-lines nil
x-underline-at-descent-line t
search-whitespace-regexp "[ \t\r\n]+"
apropos-sort-by-scores 'verbose)
(setq-default cursor-type 'bar)
5 years ago
(setq visual-line-fringe-indicators '(left-curly-arrow right-curly-arrow))
5 years ago
;; don't let the cursor go into minibuffer prompt
(setq minibuffer-prompt-properties '(read-only t
face minibuffer-prompt
cursor-intangible t))
;; Make M-v undo C-v
(setq scroll-preserve-screen-position 'always)
;; Backups and Autosave
(defvar backup-dir (expand-file-name "ebackup/" emacs-d))
(defvar autosave-dir (expand-file-name "eautosave/" emacs-d))
(setq make-backup-files t
backup-directory-alist (list (cons ".*" backup-dir))
auto-save-list-file-prefix autosave-dir
auto-save-file-name-transforms `((".*" ,autosave-dir t))
version-control t
kept-old-versions 2
kept-new-versions 4
delete-old-versions t
vc-make-backup-files t)
(setq-default async-shell-command-buffer 'new-buffer)
(add-to-list 'display-buffer-alist
'("^\*Async Shell Command*" . (display-buffer-no-window)))
(put 'set-goal-column 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(put 'narrow-to-region 'disabled nil)
(require 'time)
(require 'calendar)
(setq display-time-24hr-format t
calendar-date-style 'iso
calendar-view-diary-initially-flag t
diary-show-holidays-flag nil
holiday-hebrew-holidays nil
holiday-islamic-holidays nil
holiday-bahai-holidays nil
holiday-oriental-holidays nil
holiday-solar-holidays nil
holiday-general-holidays nil
holiday-other-holidays '((holiday-fixed 5 1 "Labour Day")
(holiday-fixed 10 3 "German Unity Day")
(holiday-fixed 10 31 "Reformation Day")
(holiday-float 11 3 -1 "Day of Repentance and Prayer" 22)))
(setq-default font-lock-maximum-decoration '((t . t)))
(setq-default savehist-file (expand-file-name "savehist" emacs-d))
(require 'tramp)
(setq tramp-save-ad-hoc-proxies t)
(require 'bookmark)
(setq bookmark-default-file (concat user-emacs-directory "bookmarks"))
(require 'browse-url)
(setq browse-url-browser-function 'browse-url-generic
browse-url-generic-program "start-tor-browser")
(require 're-builder)
(setq reb-re-syntax 'string)
(setq lisp-indent-function 'common-lisp-indent-function)
;; * Basic Builtin Packages
(use-package misc
:commands (zap-up-to-char zap-to-char))
(use-package grep
:commands (rgrep zrgrep)
:config (progn
(bind-key "C-x C-q" #'wgrep-change-to-wgrep-mode grep-mode-map)
(bind-key "C-c C-c" #'wgrep-finish-edit grep-mode-map)))
(use-package winner
:commands (winner-mode winner-undo winner-redo))
(use-package abbrev
:commands (quitely-read-abbrev-file)
:config (progn
(setq-default abbrev-mode t)
(setq save-abbrevs 'silently))
:diminish abbrev-mode)
(use-package appt
:commands (appt-activate)
:config (setq appt-display-mode-line nil))
(use-package ediff
:config (progn
(setq ediff-diff-options "-w"
ediff-window-setup-function 'ediff-setup-windows-plain
ediff-split-window-function 'split-window-horizontally)
(add-hook 'ediff-keymap-setup-hook
'(lambda ()
(bind-key "j" 'ediff-next-difference ediff-mode-map)
(bind-key "k" 'ediff-previous-difference ediff-mode-map)))
(add-hook 'ediff-after-quit-hook-internal 'winner-undo)))
(use-package ispell
:commands (ispell-change-directory)
:init (progn
(setq ispell-dictionary "en_US"
ispell-really-hunspell t)))
(use-package mailcap
:config (progn
;;Remove doc-view so pdf will open with ocular
(setcdr
(assoc "application" mailcap-mime-data)
(remove '("pdf"
(viewer . doc-view-mode)
(type . "application/pdf")
(test eq window-system 'x))
(cdr (assoc "application" mailcap-mime-data))))))
(use-package quail
:defer t
:config (progn
(defun db/add-symbols-to-TeX-input-method ()
(when (string= current-input-method "TeX")
(let ((quail-current-package (assoc "TeX" quail-package-alist)))
(quail-define-rules
((append . t))
("\\land" ?∧)
("\\lor" ?∨)
("\\lnot" )
("\\implies" ?⇒)
("\\powerset" ?𝔓)
("\\mathbbK" ?𝕂)
("\\mathbbR" ?ℝ)
("\\mathbbN" ?ℕ)
("\\mathbbZ" ?ℤ)
("\\mathbbP" ?ℙ)
("\\mathcalA" ?𝒜)
("\\mathcalB" ?ℬ)
("\\mathcalC" ?𝒞)
("\\mathcalD" ?𝒟)
("\\mathcalE" ?ℰ)
("\\mathcalH" ?ℋ)
("\\mathcalI" ?ℐ)
("\\mathcalJ" ?𝒥)
("\\mathcalK" ?𝒦)
("\\mathcalL" ?ℒ)
("\\mathcalM" ?ℳ)
("\\mathcalR" ?ℛ)
("\\mathcalQ" ?𝒬)
("\\mathcalS" ?𝒮)
("\\mathfrakP" ?𝔓)))))
(add-hook 'input-method-activate-hook
#'db/add-symbols-to-TeX-input-method)))
;; * Org Mode
(use-package org
:mode (("\\.org\\'" . org-mode))
:commands (org-agenda
org-capture
org-store-link
db/export-diary
org-clock-save
db/org-agenda-to-appt
hydra-org-clock/body)
:config (progn
(bind-key [remap org-return] 'org-return-indent org-mode-map)
(use-package db-org
:load-path "site-lisp")
;; avoid important buffers to end up in `org-agenda-new-buffers’ by
;; opening them manually
(mapc #'find-file-noselect org-agenda-files)
(org-clock-persistence-insinuate)
(require 'hydra)
(defhydra hydra-org-clock (:color blue)
"
Current Task: %`org-clock-current-task; "
("w" (lambda ()
(interactive)
(clock-in-task-by-id org-working-task-id)))
("h" (lambda ()
(interactive)
(clock-in-task-by-id org-home-task-id)))
("b" (lambda ()
(interactive)
(clock-in-task-by-id org-break-task-id)))
("i" (lambda ()
(interactive)
(org-clock-in '(4))))
("a" counsel-org-goto-all)
("o" org-clock-out)
("l" db/org-clock-in-last-task)
("p" db/play-playlist)
("d" (lambda ()
(interactive)
(when (org-clock-is-active)
(save-window-excursion
(org-clock-goto)
(let ((org-inhibit-logging 'note))
(org-todo 'done)
(org-save-all-org-buffers)))))))))
(use-package org-ref
:config (progn
(require 'org-ref-pdf)
(require 'org-ref-url-utils)
(setq org-ref-default-bibliography '("~/Documents/uni/research/references.bib")
org-ref-pdf-directory "~/Documents/library/.bibtex-pdfs/"
org-ref-bibliography-notes "~/Documents/uni/research/references.org")))
;; * Some essential packages
(use-package crux
:commands (crux-eval-and-replace
crux-smart-open-line-above
crux-kill-whole-line
crux-cleanup-buffer-or-region))
(use-package db-utils
:load-path "site-lisp/"
:commands (endless/fill-or-unfill
db/delete-trailing-whitespace-maybe
db/go-dark
db/go-light
db/show-current-org-task
db/run-or-hide-shell
db/run-or-hide-eshell
db/run-or-hide-ansi-term
db/helm-shortcuts))
(use-package db-emacsclient
:load-path "site-lisp/")
(use-package hydra
:commands (hydra-toggle/body
hydra-zoom/body
hydra-rectangle/body
hydra-ispell/body
defhydra)
5 years ago
:config (progn
(defhydra hydra-toggle (:color blue)
"toggle"
("c" column-number-mode "column")
("d" toggle-debug-on-error "debug-on-error")
("e" toggle-debug-on-error "debug-on-error")
("f" auto-fill-mode "auto-fill")
("l" toggle-truncate-lines "truncate lines")
("q" toggle-debug-on-quit "debug-on-quit")
("r" read-only-mode "read-only"))
;; zooming with single keystrokes (from oremacs)
(defhydra hydra-zoom (:color red)
"zoom"
("g" text-scale-increase "increase")
("l" text-scale-decrease "decrease"))
;; rectangle mode
(defhydra hydra-rectangle (:body-pre (rectangle-mark-mode 1)
:color pink
:post (deactivate-mark))
"
^_k_^ _d_elete _s_tring
_h_ _l_ _o_k _y_ank
^_j_^ _n_ew-copy _r_eset
^^^^ _e_xchange _u_ndo
^^^^ ^ ^ _p_aste
"
("h" backward-char nil)
("l" forward-char nil)
("k" previous-line nil)
("j" next-line nil)
("e" ora-ex-point-mark nil)
("n" copy-rectangle-as-kill nil)
("d" delete-rectangle nil)
("r" (if (region-active-p)
(deactivate-mark)
(rectangle-mark-mode 1))
nil)
("y" yank-rectangle nil)
("u" undo nil)
("s" string-rectangle nil)
("p" kill-rectangle nil)
("o" nil nil))
(defhydra hydra-ispell (:color blue)
"ispell"
("g" (lambda ()
(interactive)
(setq ispell-dictionary "de_DE")
(ispell-change-dictionary "de_DE"))
"german")
("e" (lambda ()
(interactive)
(setq ispell-dictionary "en_US")
(ispell-change-dictionary "en_US"))
"english"))))
(use-package magit
:ensure magit
:commands (magit-status)
:config (progn
(setq magit-diff-refine-hunk t
magit-commit-show-diff nil
magit-popup-use-prefix-argument 'default)
(add-to-list 'magit-no-confirm 'stage-all-changes)
(setq magit-repository-directories
(mapcar
(lambda (dir)
(substring dir 0 -1))
(cl-remove-if-not
(lambda (project)
(unless (file-remote-p project)
(file-exists-p (concat project "/.git"))))
(projectile-relevant-known-projects))))))
(use-package projectile
:ensure projectile
:commands (projectile-relevant-known-projects projectile-mode)
:config (progn
(setq projectile-switch-project-action 'projectile-dired
projectile-completion-system 'ivy))
:diminish projectile-mode)
(use-package exec-path-from-shell
:ensure exec-path-from-shell
:commands (exec-path-from-shell-copy-envs))
5 years ago
;; * Mail
(use-package bbdb
:ensure bbdb
:commands (bbdb-search-name bbab-initialize bbdb-mua-auto-update-init bbdb-save)
:config (progn
(setq bbdb-completion-display-record nil
bbdb-complete-mail-allow-cycling t
bbdb-mua-auto-update-p 'query
bbdb-default-country "Germany"
bbdb-user-mail-address-re (regexp-opt
(list db/personal-mail-address
db/work-mail-address))
bbdb-file (expand-file-name "private/bbdb" emacs-d))
5 years ago
(add-hook 'message-setup-hook 'bbdb-mail-aliases)
(add-hook 'mail-setup-hook 'bbdb-mail-aliases)))
(use-package gnus
:defines (gnus-init-file)
:commands (gnus)
:init (setq gnus-group-update-tool-bar nil)
:config (progn
(bbdb-initialize 'gnus 'message)
(bbdb-mua-auto-update-init 'message)
(setq gnus-init-file (expand-file-name "gnus" emacs-d)
gnus-home-directory (expand-file-name "~/Mail/news/")
gnus-directory (expand-file-name "~/Mail/news/")
gnus-kill-files-directory gnus-directory
gnus-startup-file (expand-file-name "~/Mail/gnus-newsrc")
gnus-cache-directory (expand-file-name
"cache/" gnus-directory))))
5 years ago
;; * Crypto
(use-package nsm
:config (progn (setq network-security-level 'medium
nsm-save-host-names t
nsm-settings-file (expand-file-name
"private/network-security.data"
emacs-d))))
5 years ago
(use-package gnutls
:config (progn
(setq gnutls-log-level 0
gnutls-min-prime-bits 1024
gnutls-verify-error t)
;; add own trustfiles
(dolist (cert-file
(directory-files "~/.local/etc/certs" t "\.crt$"))
(add-to-list 'gnutls-trustfiles cert-file))))
(use-package epg
:config (progn
(setq epg-program "/usr/bin/gpg2"
epg-debug t)))
;; * Appearance
(use-package solarized-theme
:init (setq solarized-use-less-bold t
solarized-emphasize-indicators t
solarized-use-variable-pitch nil))
(use-package smart-mode-line
:init (setq sml/use-projectile-p t))
;; * Dired
(use-package dired
:config (progn
(setq dired-dwim-target t)
(put 'dired-find-alternate-file 'disabled nil)
(setq dired-listing-switches "-alLh")
(setq dired-hide-details-hide-information-lines nil)
(setq dired-recursive-copies 'top)
(setq dired-recursive-deletes 'top)
(require 'dired-x)
5 years ago
;; Gnus support in dired
(require 'gnus-dired)
5 years ago
(add-hook 'dired-mode-hook #'turn-on-gnus-dired-mode)
;; omitting files
(add-hook 'dired-mode-hook #'dired-omit-mode)
(setq dired-omit-files
(concat dired-omit-files "\\|^\\...+$"))
5 years ago
(setq dired-guess-shell-alist-user
'(("\\.pdf\\'" "evince")
("\\.ps\\'" "evince")
("\\.\\(?:djvu\\|eps\\)\\'" "evince")
("\\.\\(?:jpg\\|jpeg\\|png\\|gif\\|xpm\\)\\'" "geeqie")
("\\.\\(?:xcf\\)\\'" "gimp")
("\\.\\(?:mp4\\|mkv\\|avi\\|flv\\|ogv\\)\\(?:\\.part\\)?\\'"
"vlc")
("\\.\\(?:mp3\\|flac\\|ogg\\)\\'" "mplayer")
("\\.html?\\'" "firefox")
("\\.docx?\\'" "loffice")))
(unbind-key "C-M-o" dired-mode-map)
(require 'dired+)
5 years ago
(custom-set-variables ; needs to be set with custom
'(diredp-hide-details-initially-flag nil))
5 years ago
;; disable exaggerated fontification of dired+
(require 'font-lock)
(add-to-list 'font-lock-maximum-decoration '(wdired-mode . 1))
(add-to-list 'font-lock-maximum-decoration '(dired-mode . 1))
;; https://oremacs.com/2017/03/18/dired-ediff/
(defun ora-ediff-files ()
(interactive)
(lexical-let ((files (dired-get-marked-files))
(wnd (current-window-configuration)))
(if (<= (length files) 2)
(lexical-let ((file1 (car files))
(file2 (if (cdr files)
(cadr files)
(read-file-name
"file: "
(dired-dwim-target-directory)))))
(if (file-newer-than-file-p file1 file2)
(ediff-files file2 file1)
(ediff-files file1 file2))
(add-hook 'ediff-after-quit-hook-internal
(lambda ()
(setq ediff-after-quit-hook-internal nil)
(set-window-configuration wnd))))
(error "no more than 2 files should be marked"))))
(require 'dired-quick-sort)
(dired-quick-sort-setup)
(bind-key [remap beginning-of-buffer]
#'dired-back-to-top dired-mode-map)
(bind-key [remap end-of-buffer]
#'dired-jump-to-bottom dired-mode-map)
(bind-key "z" 'dired-get-size dired-mode-map)
(unbind-key "s" dired-mode-map)
(unbind-key "<f1>" dired-mode-map)
5 years ago
(bind-key "e" #'ora-ediff-files dired-mode-map)))
5 years ago
(use-package find-dired
:commands (find-dired)
:config (setq find-ls-option '("-print0 | xargs -0 ls -ld" . "-ld")))
;; * Completion
(use-package hippie-exp
:commands (hippie-expand))
(use-package helm
:commands (helm-command-prefix
helm-show-kill-ring)
:ensure helm
:diminish helm-mode
:defines (helm-command-prefix-key
helm-command-prefix
helm-command-map
helm-completing-read-handlers-alist)
:init (require 'helm-config)
:config (progn
(setq helm-input-idle-delay 0.0
helm-M-x-fuzzy-match t
helm-M-x-requires-pattern nil
helm-buffers-fuzzy-matching t
helm-recentf-fuzzy-match t
helm-mode-fuzzy-match t
helm-autoresize-min-height 20
helm-ff-auto-update-initial-value t
helm-ff-file-name-history-use-recentf t
helm-ff-search-library-in-sexp t
helm-ff-skip-boring-files nil
helm-split-window-in-side-p t
helm-move-to-line-cycle-in-source nil
helm-scroll-amount nil
helm-locate-command nil
helm-candidate-number-limit 100
helm-follow-mode-persistent t
helm-buffer-details-flag t
helm-buffer-skip-remote-checking t)
(unbind-key helm-command-prefix-key)
(bind-key "<tab>" 'helm-execute-persistent-action helm-map)
(bind-key "C-i" 'helm-execute-persistent-action helm-map)
(bind-key "C-z" 'helm-select-action helm-map)
(require 'db-utils)
(setq helm-mini-default-sources '(helm-source-buffers-list
helm-source-recentf
db/helm-frequently-used-features
db/helm-frequently-visited-locations
helm-source-buffer-not-found
helm-source-bookmarks
5 years ago
helm-source-bookmark-set))))
5 years ago
(use-package ivy
:commands (ivy-mode
5 years ago
ivy-resume
ivy-recentf)
5 years ago
:diminish ivy-mode
:config (progn
(setq ivy-use-virtual-buffers t
enable-recursive-minibuffers t)
(setq ivy-initial-inputs-alist '((counsel-describe-function . "^")
(counsel-describe-variable . "^")
(man . "^")
(woman . "^")))))
5 years ago
(use-package counsel
:commands (counsel-org-goto-all
counsel-ag
counsel-M-x
counsel-find-file
counsel-info-lookup-symbol
counsel-unicode-char
counsel-describe-variable
counsel-describe-function))
(use-package swiper
:commands (swiper))
(use-package recentf
:commands (recentf-mode recentf-save-list)
5 years ago
:init (setq recentf-max-saved-items 1000))
5 years ago
(use-package company
:commands (company-mode global-company-mode))
;; * Navigation
(use-package ace-window
:ensure t
:commands (ace-window ace-window-display-mode)
:demand t
:config (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)
aw-background nil
aw-leading-char-style 'char
aw-scope 'frame))
(use-package avy
:commands (avy-goto-char-timer
avy-goto-word-or-subword-1
avy-goto-line))
(use-package dumb-jump
:commands (dumb-jump-go-other-window
dumb-jump-go
dumb-jump-back
dumb-jump-quick-look
dumb-jump-go-prefer-external
dumb-jump-go-prefer-external-other-window)
:config (setq dumb-jump-selector 'helm))
;; * EMMS
(use-package emms
:ensure t
:commands (emms
emms-stream-init
db/play-playlist
emms-cache-save
emms-play-directory-tree
emms-control/body)
:defines (emms-playlist-mode-map)
:config (progn
(require 'emms-setup)
(emms-all)
(emms-default-players)
(setq emms-source-file-default-directory "~/Documents/media/audio/")
(defadvice emms-tag-editor-submit (after delete-window activate)
(delete-window))
(bind-key "S s" #'emms-shuffle emms-playlist-mode-map)
(add-hook 'emms-player-started-hook 'emms-show)
(setq emms-show-format "NP: %s")
(emms-mode-line -1)
(emms-playing-time-enable-display)
(setq emms-player-list
'(emms-player-mplayer emms-player-mplayer-playlist))
(defun db/play-playlist ()
(interactive)
(save-window-excursion
(let ((music-buffer-name "*EMMS Playlist* -- Misc"))
(unless (get-buffer music-buffer-name)
(emms-playlist-new music-buffer-name))
(with-current-buffer (get-buffer music-buffer-name)
(emms-stop)
(emms-playlist-set-playlist-buffer)
(emms-playlist-current-clear)
(emms-playlist-current-insert-source
'emms-insert-playlist
"~/Documents/home/misc/playlist-daniel.pls")
(beginning-of-buffer)
(emms-shuffle)
;; (emms-playlist-sort-by-play-count)
(emms-playlist-select-first)
(emms-start)))))
;; adapt track description
(defun db/emms-track-description (track)
(require 'seq)
(let* ((artist (propertize (emms-track-get track 'info-artist "")
'face 'emms-browser-artist-face))
(composer (propertize (emms-track-get track 'info-composer "")
'face 'emms-browser-composer-face))
(performer (propertize (emms-track-get track 'info-performer "")
'face 'emms-browser-performer-face))
(title (propertize (emms-track-get track 'info-title "")
'face 'emms-browser-track-face))
(note (emms-track-get track 'info-note "")))
(let ((main-description (if (not (seq-empty-p title))
(cond
((and (not (seq-empty-p composer))
(not (seq-empty-p performer)))
(if (string= composer performer)
(format "“%s” by %s"
title composer)
(format "“%s” by %s, performed by %s"
title
composer
performer)))
((not (seq-empty-p artist))
(format "“%s” by %s" title artist))
(t title))
(emms-track-simple-description track)))
(note (if (seq-empty-p note)
""
(concat " [" note "]"))))
(concat main-description note))))
(setq emms-track-description-function
'db/emms-track-description)
;; don't set face in playlist to emms-playlist-track-face
(defun db/emms-playlist-mode-insert-track (track &optional no-newline)
"Insert the description of TRACK at point.
When NO-NEWLINE is non-nil, do not insert a newline after the track."
(emms-playlist-ensure-playlist-buffer)
(emms-with-inhibit-read-only-t
(insert (emms-propertize (emms-track-force-description track)
'emms-track track
;'face 'emms-playlist-track-face
))
(when (emms-playlist-selected-track-at-p)
(emms-playlist-mode-overlay-selected))
(unless no-newline
(insert "\n"))))
(add-hook 'emms-playlist-mode-hook
(lambda ()
(setq emms-playlist-insert-track-function
#'db/emms-playlist-mode-insert-track)))
;; streams
(require 'emms-stream-info)
(setq emms-stream-default-action "play")
(defun db/emms-track-status ()
(if emms-player-playing-p
(format "%s" (emms-track-description
(emms-playlist-current-selected-track)))
"«nothing»"))
;; easy control
(defhydra emms-control (:color red :hint none)
"
Playing: %s(db/emms-track-status)
_n_: ?n? _p_: ?p?
_RET_: ?RET? _M_: ?M?
_-_: lower volume _+_: ?+?
"
("n" emms-next "next")
("p" emms-previous "previous")
("RET" emms-pause "play/pause")
("s" emms-show "show title")
("-" emms-volume-lower "lower volume")
("+" emms-volume-raise "raise volume")
("M" emms "show playlist"))
t))
(use-package helm-emms
:commands (helm-emms)
:config (progn
(require 'helm-adaptive)
(setq helm-emms-default-sources
'(helm-source-emms-streams
helm-source-emms-dired
helm-source-emms-files))))
5 years ago
;; * Shells and such