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.

init.el 116KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014
  1. ;;; Init.el --- Daniel's Emacs Configuration -*- lexical-binding: t -*-
  2. ;;; Commentary:
  3. ;; This is the main entry point for Emacs to load this configuration. The
  4. ;; structure is roughly as follows:
  5. ;; * first comes some preliminary setup, mostly setting up `package’;
  6. ;; * the main activation of the configuration is done in the function
  7. ;; `db/run-init’, which is installed in `after-init-hook’; it is thus run
  8. ;; after init.el has been read
  9. ;; * then comes setting up all the packages that can be used by this
  10. ;; configuration; most of these packages are not loaded however, and only
  11. ;; configuration hooks are installed (using `use-package’); this way a user
  12. ;; can choose in `db/run-init’ which configuration to activate without
  13. ;; changing much of the rest of the file.
  14. ;; * this file also introduces a new customization group `personal-settings’
  15. ;; containing variables (mostly file paths) that must be set to enable some
  16. ;; of the provided functionality.
  17. ;;; Code:
  18. ;; * Preliminaries (constants and path settings)
  19. (defconst emacs-d (file-name-directory
  20. (file-chase-links load-file-name))
  21. "The giant turtle on which the world rests.")
  22. (defconst on-windows (memq system-type '(windows-nt cygwin))
  23. "Non-nil if and only if this instance of Emacs runs on Windows.")
  24. (setq custom-file (expand-file-name "private/custom.el" emacs-d)
  25. custom-theme-directory (expand-file-name "themes/" emacs-d))
  26. (add-to-list 'load-path (expand-file-name "site-lisp" emacs-d))
  27. ;; Ensure that ~/.emacs.d/private exists, because we want to store data there
  28. (let ((private-data-dir (expand-file-name "private/" emacs-d)))
  29. (unless (file-directory-p private-data-dir)
  30. (make-directory private-data-dir)))
  31. ;; * Packages
  32. (setq package-archives
  33. '(("melpa" . "https://melpa.org/packages/")
  34. ("gnu" . "https://elpa.gnu.org/packages/")
  35. ("melpa-stable" . "https://stable.melpa.org/packages/")
  36. ("org" . "https://orgmode.org/elpa/")))
  37. (when (< emacs-major-version 27)
  38. ;; Before Emacs 27.1, we had to do package initialization ourselves. In Emacs
  39. ;; 27.1 and later, it's done directly after loading early-init.el. See
  40. ;; https://www.gnu.org/software/emacs/news/NEWS.27.1
  41. (load-file (expand-file-name "early-init.el" emacs-d))
  42. (package-initialize))
  43. (eval-when-compile
  44. (setq use-package-enable-imenu-support t
  45. use-package-always-defer t
  46. use-package-verbose t
  47. use-package-minimum-reported-time 0.01)
  48. (dolist (package '(bind-key use-package))
  49. (unless (package-installed-p package)
  50. (package-install package))
  51. (require package)))
  52. (add-to-list 'package-pinned-packages '(use-package . "melpa-stable"))
  53. (add-to-list 'package-pinned-packages '(bind-key . "melpa-stable"))
  54. (put 'use-package 'lisp-indent-function 1)
  55. ;; * Mode activation
  56. (defun db/run-init ()
  57. "Run main initialization after everything is set up."
  58. (message "Running main initialization ...")
  59. ;; Activate modes (builtin)
  60. (show-paren-mode 1)
  61. (transient-mark-mode 1)
  62. (global-font-lock-mode 1)
  63. (column-number-mode 1)
  64. ;; (display-time)
  65. (delete-selection-mode 1)
  66. (dolist (mode '(tool-bar-mode
  67. scroll-bar-mode
  68. menu-bar-mode
  69. blink-cursor-mode
  70. tooltip-mode))
  71. (when (fboundp mode)
  72. (funcall mode 0)))
  73. (when (<= 24 emacs-major-version)
  74. (electric-indent-mode -1))
  75. (appt-activate +1)
  76. (savehist-mode 1)
  77. (size-indication-mode 1)
  78. (display-battery-mode -1)
  79. (electric-pair-mode +1)
  80. (recentf-mode t)
  81. (winner-mode 1)
  82. (global-auto-revert-mode -1)
  83. (which-function-mode +1)
  84. (global-eldoc-mode +1)
  85. ;; Activate modes (packages)
  86. (dolist (mode '(global-undo-tree-mode
  87. ace-window-display-mode
  88. key-chord-mode
  89. ivy-mode
  90. minions-mode
  91. which-key-mode
  92. eyebrowse-mode
  93. projectile-mode
  94. yas-global-mode
  95. semantic-mode))
  96. (with-demoted-errors "Cannot activate mode: %s"
  97. (funcall mode +1)))
  98. (unless on-windows
  99. (with-demoted-errors "Cannot load `pdf-tools’: %s"
  100. (pdf-tools-install)))
  101. (with-demoted-errors "Cannot activate moody: %s"
  102. (moody-replace-mode-line-buffer-identification)
  103. (moody-replace-vc-mode))
  104. (with-demoted-errors "Cannot activate `vlf': %s"
  105. (require 'vlf-setup))
  106. ;; Explicitly require helm, because autoloading is difficult with helm's
  107. ;; separate `helm-command-prefix-key' mechanism.
  108. (require 'helm)
  109. (when (package-installed-p 'org-roam)
  110. (if (executable-find "sqlite3")
  111. (org-roam-mode +1)
  112. (warn "Cannot activate org-roam: sqlite3 not found.")))
  113. ;; Global Hooks
  114. (add-hook 'minibuffer-setup-hook 'conditionally-enable-lispy)
  115. (add-hook 'minibuffer-setup-hook 'cursor-intangible-mode)
  116. (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
  117. (add-hook 'prog-mode-hook 'page-break-lines-mode)
  118. (add-hook 'prog-mode-hook 'subword-mode)
  119. (add-hook 'lisp-mode-hook 'turn-on-lispy-when-available)
  120. (when (<= 24 emacs-major-version)
  121. (add-hook 'prog-mode-hook 'electric-indent-local-mode))
  122. (add-hook 'text-mode-hook 'turn-on-auto-fill)
  123. (add-hook 'text-mode-hook 'abbrev-mode)
  124. ;; Auto-Modes
  125. (dolist (mode-spec '(("\\.clj\\'" . clojure-mode)
  126. ("\\.cl\\'" . lisp-mode)
  127. ("\\.lisp\\'" . lisp-mode)
  128. ("\\.plx\\’" . cperl-mode)
  129. ("\\.hs\\'" . haskell-mode)
  130. ("\\.lhs\\'" . haskell-mode)
  131. ("\\.md\\'" . markdown-mode)
  132. ("\\.html\\'" . nxml-mode)
  133. ("\\.xml\\'" . nxml-mode)))
  134. (add-to-list 'auto-mode-alist mode-spec))
  135. ;; Top-Level Keybindings
  136. (bind-key "<XF86Back>" #'winner-undo)
  137. (bind-key "<XF86Forward>" #'winner-redo)
  138. (bind-key "<f10>" #'magit-status)
  139. (bind-key "<f1>" #'db/run-or-hide-eshell)
  140. (bind-key "<f2>" #'hydra-feature-shortcuts/body)
  141. (bind-key "<f5>" (if (executable-find "ag") #'counsel-ag #'rgrep))
  142. (bind-key "<f6>" #'hydra-zoom/body)
  143. (bind-key "<f7>" #'dictcc)
  144. (bind-key "<f8>" #'bm-toggle)
  145. (bind-key "<f9>" #'hydra-org-linking/body)
  146. (bind-key "<C-f8>" #'bm-next)
  147. (bind-key "<C-S-f8>" #'bm-previous)
  148. (bind-key "C-," #'mc/skip-to-previous-like-this)
  149. (bind-key "C-." #'mc/skip-to-next-like-this)
  150. (bind-key "C-;" #'iedit-mode)
  151. (bind-key "C-<" #'mc/mark-previous-like-this)
  152. (bind-key "C->" #'mc/mark-next-like-this)
  153. (bind-key "C-@" #'er/expand-region)
  154. (bind-key "C-M-\\" #'crux-cleanup-buffer-or-region)
  155. (bind-key "C-S-c C-S-c" #'mc/edit-lines)
  156. (bind-key "C-Z" #'undo-tree-redo)
  157. (bind-key "C-c C-<" #'mc/mark-all-like-this)
  158. (bind-key "C-c C-r" #'ivy-resume)
  159. (bind-key "C-c D" #'define-word)
  160. (bind-key "C-c J" #'avy-goto-word-or-subword-1)
  161. (bind-key "C-c P" #'ivy-pages)
  162. (bind-key "C-c a" #'org-agenda)
  163. (bind-key "C-c c" #'org-capture)
  164. (bind-key "C-c d" #'define-word-at-point)
  165. (bind-key "C-c e" #'crux-eval-and-replace)
  166. (bind-key "C-c i" #'ispell-change-dictionary)
  167. (bind-key "C-c j" #'avy-goto-char-timer)
  168. (bind-key "C-c l" #'org-store-link)
  169. (bind-key "C-c m" #'music-control/body)
  170. (bind-key "C-c n I" #'org-roam-insert-immediate)
  171. (bind-key "C-c n i" #'org-roam-insert)
  172. (bind-key "C-c o" #'hydra-org-clock/body)
  173. (bind-key "C-c s" #'synonyms)
  174. (bind-key "C-c t" #'hydra-toggle/body)
  175. (bind-key "C-h C-f" #'find-function)
  176. (bind-key "C-h C-k" #'find-function-on-key)
  177. (bind-key "C-h C-v" #'find-variable)
  178. (bind-key "C-x 4 C-j" #'dired-jump-other-window)
  179. (bind-key "C-x C-b" #'ibuffer)
  180. (bind-key "C-x C-d" #'dired)
  181. (bind-key "C-x C-j" #'dired-jump)
  182. (bind-key "C-x C-r" #'revert-buffer)
  183. (bind-key "C-x SPC" #'hydra-rectangle/body)
  184. (bind-key "C-x g" #'db/helm-shortcuts)
  185. (bind-key "C-x r E" #'db/bookmark-add-external)
  186. (bind-key "C-x r M" #'db/bookmark-add-url)
  187. (bind-key "C-x r v" #'list-registers)
  188. (bind-key "C-z" #'goto-last-change)
  189. (bind-key "M-/" #'hippie-expand)
  190. (bind-key "M-:" #'pp-eval-expression)
  191. (bind-key "M-=" #'count-words)
  192. (bind-key "M-SPC" #'cycle-spacing)
  193. (bind-key "M-Z" #'zap-to-char)
  194. (bind-key "M-i" #'swiper-from-isearch isearch-mode-map)
  195. (bind-key "M-j" #'(lambda () (interactive) (join-line -1)))
  196. (bind-key "M-z" #'zap-up-to-char)
  197. (bind-key [remap fill-paragraph] #'endless/fill-or-unfill)
  198. (bind-key [remap keyboard-quit] #'keyboard-quit-context+)
  199. (unbind-key "<insert>" global-map)
  200. (unbind-key "<kp-insert>" global-map)
  201. (unbind-key "C-x C-c" global-map)
  202. (unbind-key "M-o" global-map)
  203. ;; Overwrite certain keybindings only if packages are avilable
  204. (when (package-installed-p 'counsel)
  205. (bind-key "M-x" #'counsel-M-x) ; gets nicer sorting with smex installed
  206. (bind-key "C-c r" #'counsel-recentf)
  207. (bind-key "C-x C-f" #'counsel-find-file)
  208. (bind-key "C-h f" #'counsel-describe-function)
  209. (bind-key "C-h v" #'counsel-describe-variable)
  210. (bind-key "C-h b" #'counsel-descbinds)
  211. (bind-key "C-S-s" #'counsel-grep-or-swiper))
  212. (when (package-installed-p 'helm)
  213. (bind-key "M-y" #'helm-show-kill-ring))
  214. (when (package-installed-p 'crux)
  215. (bind-key [remap kill-whole-line] #'crux-kill-whole-line)
  216. (bind-key [remap open-line] #'crux-smart-open-line-above))
  217. (when (package-installed-p 'ace-window)
  218. (bind-key "C-x o" #'ace-window))
  219. (when (package-installed-p 'avy)
  220. (bind-key "M-g M-g" #'avy-goto-line)
  221. (bind-key "M-g g" #'avy-goto-line))
  222. ;; Environment Variables
  223. (unless on-windows
  224. (with-demoted-errors "Cannot import environment variables: %s"
  225. (exec-path-from-shell-copy-envs '("SSH_AUTH_SOCK"
  226. "SSH_AGENT_PID"
  227. "PATH"
  228. "TEXMFHOME"
  229. "PERL5LIB"
  230. "PERL_LOCAL_LIB_ROOT"
  231. "PERL_MB_OPT"
  232. "PERL_MM_OPT"))))
  233. ;; Start Server when not running already
  234. ;; The following condition should actually always be false, since we have
  235. ;; neither loaded the server package yet nor have explicitly started the
  236. ;; server process. Also the --daemon command line switches will start the
  237. ;; server only later, after initialization (and they do so unconditionally,
  238. ;; thus restarting the server we have started here). However, for robustness,
  239. ;; we keep the condition nevertheless, since when a server process is already
  240. ;; present, we really don't have to do anything. Furthermore, calling
  241. ;; `db/run-init' again in a running Emacs will not restart the server (but
  242. ;; then, why whould one want to do this?).
  243. (if (and (boundp 'server-process) server-process)
  244. (message "Server already running, not restarting.")
  245. (require 'server)
  246. (let ((server-file (expand-file-name server-name
  247. (if server-use-tcp server-auth-dir server-socket-dir))))
  248. (if (file-exists-p server-file)
  249. (warn "Server file already exists, but no server process is running. Check %s and restart server manually."
  250. server-file)
  251. (server-start)
  252. (cl-ecase (server-running-p)
  253. ((t) t) ; server is running
  254. (nil (warn "Server not running, check logs and restart manually."))
  255. (t (warn "`server-running-p' returned neither nil nor t. Check and restart server manually if required."))))))
  256. ;; Load custom code
  257. (dolist (file db/after-init-load-files)
  258. (message "Loading %s" file)
  259. (with-demoted-errors "Error loading file: %s"
  260. (load-file file)))
  261. ;; Finish
  262. (message "Running main initialization ... done")
  263. t)
  264. (add-hook 'after-init-hook #'db/run-init)
  265. ;; * Personal customization
  266. (use-package db-customize
  267. :demand t
  268. :defines (db/jabber-id
  269. db/important-documents-path
  270. db/path-to-onenote
  271. db/path-to-outlook
  272. db/cert-file-directory
  273. org-working-task-id
  274. org-break-task-id
  275. org-home-task-id
  276. db/org-clock-current-task-file
  277. db/org-default-org-file
  278. db/org-default-work-file
  279. db/org-default-home-file
  280. db/org-default-notes-file
  281. db/org-default-refile-file
  282. db/after-init-load-files))
  283. ;; * General configuration
  284. (use-package cl-lib
  285. :demand t)
  286. (use-package subr-x
  287. :demand t)
  288. (set-default-coding-systems 'utf-8)
  289. (prefer-coding-system 'utf-8)
  290. (set-terminal-coding-system 'utf-8)
  291. (set-keyboard-coding-system 'utf-8)
  292. (setq buffer-file-coding-system 'utf-8)
  293. (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))
  294. (setq inhibit-startup-message t
  295. inhibit-default-init t
  296. frame-inhibit-implied-resize t
  297. initial-scratch-message nil
  298. initial-major-mode 'fundamental-mode
  299. ring-bell-function #'ignore
  300. garbage-collection-messages nil
  301. load-prefer-newer nil ; t breaks `org-reload'
  302. auth-sources '("~/.authinfo.gpg")
  303. auth-source-save-behavior nil)
  304. (fset 'yes-or-no-p 'y-or-n-p)
  305. (setq-default fill-column 80)
  306. (setq-default indent-tabs-mode nil)
  307. (setq frame-title-format "emacs")
  308. (setq select-enable-clipboard t
  309. select-enable-primary t
  310. save-interprogram-paste-before-kill t
  311. mouse-yank-at-point t
  312. require-final-newline nil
  313. sentence-end-double-space t
  314. recenter-positions '(top middle bottom)
  315. scroll-conservatively 10
  316. message-log-max t
  317. inhibit-eol-conversion nil
  318. tab-always-indent 'complete
  319. enable-recursive-minibuffers t
  320. set-mark-command-repeat-pop t
  321. large-file-warning-threshold 10000000
  322. echo-keystrokes 0.1
  323. delete-by-moving-to-trash t
  324. delete-trailing-lines nil
  325. x-underline-at-descent-line t
  326. search-whitespace-regexp "[ \t\r\n]+"
  327. visual-line-fringe-indicators '(left-curly-arrow right-curly-arrow)
  328. history-delete-duplicates t
  329. track-eol t)
  330. (when (memq system-type '(gnu gnu/linux gnu/kfreebsd))
  331. (setq x-wait-for-event-timeout nil))
  332. (when on-windows
  333. ;; treat memory for display time ... but hey, this is Windows, memory doesn’t
  334. ;; matter!
  335. (setq inhibit-compacting-font-caches t))
  336. ;; don't let the cursor go into minibuffer prompt
  337. (setq minibuffer-prompt-properties '(read-only t
  338. face minibuffer-prompt
  339. cursor-intangible t))
  340. ;; Make M-v undo C-v
  341. (setq scroll-preserve-screen-position 'always)
  342. ;; Backups and Autosave
  343. (defvar backup-dir (expand-file-name "ebackup/" emacs-d))
  344. (defvar autosave-dir (expand-file-name "eautosave/" emacs-d))
  345. (setq make-backup-files t
  346. backup-directory-alist (list (cons ".*" backup-dir))
  347. auto-save-list-file-prefix autosave-dir
  348. auto-save-file-name-transforms `((".*" ,autosave-dir t))
  349. version-control t
  350. kept-old-versions 2
  351. kept-new-versions 4
  352. delete-old-versions t
  353. vc-make-backup-files t)
  354. (setq undo-limit 80000000)
  355. (setq-default async-shell-command-buffer 'new-buffer)
  356. (add-to-list 'display-buffer-alist
  357. '("^\\*Async Shell Command*" . (display-buffer-no-window)))
  358. (put 'set-goal-column 'disabled nil)
  359. (put 'upcase-region 'disabled nil)
  360. (put 'downcase-region 'disabled nil)
  361. (put 'narrow-to-region 'disabled nil)
  362. (setq-default savehist-file (expand-file-name "savehist" emacs-d))
  363. (setq default-input-method "TeX")
  364. ;; * Fixes
  365. (with-eval-after-load 'enriched
  366. (defun enriched-decode-display-prop (start end &optional params)
  367. (ignore params)
  368. (list start end)))
  369. ;; Disable gconf settings, as it might interfere with ours. Cf.
  370. ;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25228 and
  371. ;; https://emacs.stackexchange.com/questions/32641/something-changes-the-default-face-in-my-emacs.
  372. (define-key special-event-map [config-changed-event] 'ignore)
  373. ;; * Builtin Packages
  374. (use-package misc
  375. :commands (zap-up-to-char zap-to-char))
  376. (use-package grep
  377. :commands (rgrep zrgrep)
  378. :bind (:map grep-mode-map
  379. ("C-x C-q" . wgrep-change-to-wgrep-mode)
  380. ("C-c C-c" . wgrep-finish-edit)))
  381. (use-package winner
  382. :commands (winner-mode winner-undo winner-redo))
  383. (use-package abbrev
  384. :init (setq save-abbrevs 'silently
  385. abbrev-file-name (expand-file-name "private/abbrev_defs"))
  386. :diminish abbrev-mode)
  387. (use-package appt
  388. :commands (appt-activate)
  389. :init (setq appt-display-mode-line nil))
  390. (use-package ispell
  391. :commands (ispell-change-directory))
  392. (use-package mailcap
  393. :config (progn
  394. ;; Remove doc-view so pdf will open with default viewer
  395. (setcdr
  396. (assoc "application" mailcap-mime-data)
  397. (remove '("pdf"
  398. (viewer . doc-view-mode)
  399. (type . "application/pdf")
  400. (test eq window-system 'x))
  401. (cdr (assoc "application" mailcap-mime-data))))))
  402. (use-package quail
  403. :config (add-hook 'input-method-activate-hook
  404. #'db/add-symbols-to-TeX-input-method))
  405. (use-package isearch
  406. :init (setq isearch-allow-scroll t))
  407. (use-package server
  408. :commands (server-running-p server-start)
  409. :init (setq server-log t))
  410. (use-package bookmark
  411. :init (setq bookmark-default-file (expand-file-name "private/bookmarks"
  412. emacs-d)))
  413. (use-package warnings
  414. :config (cl-pushnew '(undo discard-info) warning-suppress-types
  415. :test #'equal))
  416. (use-package calender
  417. :init (setq calendar-date-style 'iso
  418. calendar-week-start-day 1 ; Monday
  419. calendar-bahai-all-holidays-flag nil
  420. calendar-chinese-all-holidays-flag nil
  421. calendar-christian-all-holidays-flag t
  422. calendar-islamic-all-holidays-flag nil
  423. calendar-hebrew-all-holidays-flag nil
  424. holiday-general-holidays '((holiday-fixed 1 1 "New Year's Day")
  425. (holiday-fixed 2 14 "Valentine's Day")
  426. (holiday-fixed 4 1 "April Fools' Day")
  427. (holiday-fixed 5 1 "Labour Day")
  428. (holiday-fixed 10 3 "German Unity Day")
  429. (holiday-fixed 10 31 "Reformation Day")
  430. (holiday-float 11 3 -1 "Day of Repentance and Prayer" 22)
  431. (holiday-float 11 4 4 "Thanksgiving"))
  432. holiday-other-holidays '((holiday-fixed 2 13 "Jahrestag Zerstörung Dresden 1945")
  433. (holiday-fixed 5 25 "Towel Day")
  434. (holiday-fixed 6 4 "Tiananmen Massacre 1989")
  435. (holiday-fixed 6 5 "Snowden-Veröffentlichungen 2013")
  436. (holiday-fixed 6 6 "D-Day 1944")
  437. (holiday-fixed 6 8 "Yoneda Appreciation Day")
  438. (holiday-fixed 6 10 "Jahrestag Zerstörung von Oradour-sur-Glane 1944")
  439. (holiday-fixed 6 10 "Jahrestag Massaker von Distomo 1944")
  440. (holiday-fixed 6 16 "Bloomsday")
  441. (holiday-fixed 7 20 "Jahrestag Attentat auf Hitler 1944")
  442. (holiday-fixed 7 21 "Jahrestag der 1. Mondlandung 1969")
  443. (holiday-fixed 7 21 "Jahrestag Massaker von Vassieux-en-Vercors 1944")
  444. (holiday-fixed 7 28 "Start WWI 1914")
  445. (holiday-fixed 11 11 "End WWI 1918"))
  446. diary-show-holidays-flag t
  447. calendar-view-holidays-initially-flag nil))
  448. (use-package re-builder
  449. :commands (re-builder)
  450. :init (setq reb-re-syntax 'string))
  451. (use-package browser-url
  452. :init (setq browse-url-browser-function 'browse-url-generic
  453. browse-url-generic-program "firefox"))
  454. (use-package tramp
  455. :init (setq tramp-default-method (if on-windows "plink" "sshx")))
  456. (use-package calc
  457. ;; https://florian.adamsky.it/2016/03/31/emacs-calc-for-programmers-and-cs.html
  458. :defines (math-additional-units
  459. math-units-table)
  460. :init (setq math-additional-units
  461. '((bit nil "Bit")
  462. (byte "8 * bit" "Byte")
  463. (bps "bit / s" "Bit per second"))
  464. math-units-table nil))
  465. (use-package tab-bar
  466. :init (setq tab-bar-show nil)
  467. :config (progn
  468. (tab-bar-history-mode +1)))
  469. ;; * Essential external packages
  470. (use-package dash)
  471. (use-package hydra
  472. :pin "melpa-stable")
  473. ;; `lv' is a dependency of `hydra'
  474. (add-to-list 'package-pinned-packages '(lv . "melpa-stable"))
  475. (use-package db-utils
  476. :commands (endless/fill-or-unfill
  477. db/delete-trailing-whitespace-maybe
  478. db/run-or-hide-shell
  479. db/gnus
  480. db/org-agenda
  481. db/scratch
  482. db/find-user-init-file
  483. db/run-or-hide-ansi-term
  484. db/hex-to-ascii
  485. db/text-to-hex
  486. conditionally-enable-lispy
  487. turn-on-lispy-when-available
  488. turn-on-flycheck-when-file
  489. db/sort-nsm-permanent-settings
  490. endless/colorize-compilation
  491. db/turn-off-local-electric-pair-mode
  492. db/add-symbols-to-TeX-input-method
  493. db/two-monitors-xrandr
  494. db/one-monitor-xrandr
  495. db/pretty-print-xml
  496. db/bookmark-add-external
  497. db/bookmark-add-url
  498. db/lookup-smime-key
  499. db/dired-from-shell-command
  500. db/system-open
  501. db/switch-to-dark-theme
  502. db/switch-to-light-theme
  503. keyboard-quit-context+
  504. db/convert-lf-to-crlf-in-buffer
  505. db/convert-crlf-to-lf-in-buffer
  506. db/sync-magit-repos-from-projectile))
  507. (use-package db-hydras
  508. :commands (hydra-toggle/body
  509. hydra-zoom/body
  510. hydra-rectangle/body
  511. db/define-feature-shortcuts-hydra
  512. hydra-feature-shortcuts/body))
  513. (use-package exec-path-from-shell
  514. :pin "melpa-stable"
  515. :commands (exec-path-from-shell-copy-envs))
  516. (use-package crux
  517. :ensure t
  518. :commands (crux-eval-and-replace
  519. crux-smart-open-line-above
  520. crux-kill-whole-line
  521. crux-cleanup-buffer-or-region
  522. crux-delete-buffer-and-file))
  523. ;; * Text editing
  524. (use-package electric
  525. :commands (electric-quote-mode))
  526. (use-package elec-pair
  527. :commands (electric-pair-mode)
  528. :config (progn
  529. (add-to-list 'electric-pair-pairs '(?“ . ?”))
  530. (add-to-list 'electric-pair-text-pairs '(?“ . ?”))
  531. (add-to-list 'electric-pair-pairs '(?„ . ?“))
  532. (add-to-list 'electric-pair-text-pairs '(?„ . ?“))))
  533. (use-package flyspell
  534. :commands (flyspell-mode turn-on-flyspell)
  535. :config (progn
  536. (unbind-key "C-M-i" flyspell-mode-map)
  537. (unbind-key "C-c $" flyspell-mode-map)))
  538. (use-package key-chord
  539. :ensure t
  540. :commands (key-chord-mode)
  541. :config (progn
  542. (key-chord-define-global "``" "“")
  543. (key-chord-define-global "''" "”")
  544. (key-chord-define-global ",," "„")))
  545. (use-package multiple-cursors
  546. :pin "melpa-stable"
  547. :ensure t
  548. :commands (mc/edit-lines
  549. mc/mark-next-like-this
  550. mc/mark-previous-like-this
  551. mc/mark-all-like-this))
  552. (use-package synonyms
  553. :commands (synonyms))
  554. (use-package undo-tree
  555. :ensure t
  556. :commands (global-undo-tree-mode
  557. undo
  558. undo-tree-redo)
  559. :init (setq undo-tree-visualizer-timestamps t
  560. undo-tree-visualizer-diff t)
  561. :diminish undo-tree-mode)
  562. (use-package wgrep
  563. :ensure t
  564. :commands (wgrep-finish-edit
  565. wgrep-change-to-wgrep-mode))
  566. (use-package yasnippet
  567. :commands (yas-minor-mode-on
  568. yas-minor-mode
  569. yas-global-mode
  570. yas-reload-all)
  571. :diminish yas-minor-mode
  572. :config (yas-reload-all))
  573. ;; * Org
  574. (use-package db-org
  575. :commands (db/check-special-org-files-in-agenda
  576. db/verify-refile-target
  577. org-reset-checkbox-state-maybe
  578. db/find-parent-task
  579. db/ensure-running-clock
  580. db/save-current-org-task-to-file
  581. db/org-update-frame-title-with-current-clock
  582. db/org-clock-out
  583. db/org-clock-in-break-task
  584. db/org-clock-in-home-task
  585. db/org-clock-in-work-task
  586. db/show-current-org-task
  587. endless/org-ispell
  588. db/org-agenda-list-deadlines
  589. db/org-agenda-skip-tag
  590. hydra-org-agenda-view/body
  591. db/org-agenda-insert-efforts
  592. org-babel-execute:hy
  593. db/org-timestamp-difference
  594. db/org-capture-code-snippet
  595. hydra-org-clock/body
  596. db/make-org-capture-frame
  597. db/org-onenote-open
  598. db/org-outlook-open
  599. db/org-rfc-open
  600. db/org-cleanup-continuous-clocks
  601. db/find-csv-in-org
  602. db/org-mark-current-default-task
  603. db/export-diary
  604. db/org-copy-template-for-periodic-task
  605. db/org-find-links-to-current-item
  606. db/org-add-link-to-other-item
  607. db/org-add-link-to-current-clock
  608. hydra-org-linking/body))
  609. (use-package org
  610. :pin "gnu"
  611. :bind (:map org-mode-map
  612. ([remap org-return] . org-return-indent))
  613. :init (progn
  614. (setq org-deadline-warning-days 14
  615. org-read-date-popup-calendar t
  616. org-insert-heading-respect-content t
  617. org-adapt-indentation nil
  618. org-edit-timestamp-down-means-later t
  619. org-archive-location "%s_archive.gpg::"
  620. org-image-actual-width nil
  621. org-imenu-depth 10
  622. org-footnote-section nil
  623. org-log-into-drawer "LOGBOOK"
  624. org-log-reschedule 'note
  625. org-log-redeadline 'note
  626. org-log-note-clock-out nil
  627. org-log-done 'note
  628. org-clone-delete-id t
  629. org-catch-invisible-edits 'error
  630. org-M-RET-may-split-line '((default . nil))
  631. org-highlight-latex-and-related '(latex)
  632. org-use-sub-superscripts '{}
  633. org-src-fontify-natively t
  634. org-src-preserve-indentation t
  635. org-src-tab-acts-natively nil
  636. org-ellipsis "⤵"
  637. org-fontify-done-headline nil
  638. org-cycle-separator-lines 0
  639. org-duration-format '(("y") ("w") ("d") (special . h:mm))
  640. org-treat-S-cursor-todo-selection-as-state-change nil
  641. org-global-properties
  642. '(("Effort_ALL" . "0:00 0:05 0:10 0:15 0:30 0:45 1:00 2:00 3:00 4:00 6:00 8:00"))
  643. org-columns-default-format
  644. "%80ITEM(Task) %10Effort(Effort) %10CLOCKSUM")
  645. ;; Keywords and Tags
  646. (setq org-todo-keywords
  647. '((sequence "TODO(t)" "CONT(n!)" "|" "DONE(d@)")
  648. (sequence "GOTO(g)" "ATTN(a)" "|" "DONE(d@)")
  649. (sequence "READ(r)" "CONT(n!)" "|" "DONE(d@)")
  650. (sequence "DELG(e@/!)" "WAIT(w@/!)" "HOLD(h@/!)"
  651. "|" "CANC(c@/!)" "PHONE" "MEETING"))
  652. org-todo-state-tags-triggers
  653. '(("WAIT" ("HOLD") ("WAIT" . t))
  654. ("DELG" ("HOLD") ("WAIT" . t))
  655. ("HOLD" ("HOLD" . t) ("WAIT"))
  656. (done ("HOLD") ("WAIT"))
  657. ("TODO" ("HOLD") ("WAIT") ("DATE") ("READ"))
  658. ("READ" ("READ" . t) ("DATE") ("HOLD") ("WAIT"))
  659. ("GOTO" ("DATE" . t) ("READ") ("HOLD") ("WAIT"))
  660. ("CONT" ("DATE") ("HOLD") ("WAIT"))
  661. ("ATTN" ("DATE" . t) ("READ") ("HOLD") ("WAIT"))
  662. ("" ("HOLD") ("WAIT") ("DATE") ("READ")))
  663. org-tag-alist
  664. '((:startgroup . nil)
  665. ("WORK" . ?w)
  666. ("HOME" . ?h)
  667. ("FUN" . ?f)
  668. ("UNTAGGED" . ?u)
  669. (:endgroup . nil)
  670. ("NOTE" . ?n)
  671. ("PERIODIC" . ?p)
  672. ("REGULAR" . ?r)
  673. ("NOP" . ?o)
  674. ("TOPIC" . ?t))
  675. org-fast-tag-selection-single-key 'expert)
  676. ;; Faces
  677. (setq org-todo-keyword-faces
  678. '(("TODO" :foreground "red" :weight normal)
  679. ("GOTO" :foreground "red" :weight normal)
  680. ("READ" :foreground "red" :weight normal)
  681. ("CONT" :foreground "DeepSkyBlue" :weight normal)
  682. ("ATTN" :foreground "DeepSkyBlue" :weight normal)
  683. ("DONE" :foreground "forest green" :weight normal)
  684. ("DELG" :foreground "dark orange" :weight normal)
  685. ("WAIT" :foreground "orange" :weight normal)
  686. ("HOLD" :foreground "magenta" :weight normal)
  687. ("CANC" :foreground "lime green" :weight normal)
  688. ("MEETING" :foreground "forest green" :weight normal)
  689. ("PHONE" :foreground "forest green" :weight normal)
  690. ("REPEAT" :foreground "indian red" :weight normal))
  691. org-priority-faces
  692. '((?A . (:foreground "Red" :weight bold))
  693. (?B . (:foreground "firebrick"))
  694. (?C . (:foreground "tomato"))))
  695. ;; Refiling
  696. (setq org-refile-targets '((org-agenda-files . (:maxlevel . 9))
  697. (nil . (:maxlevel . 9))
  698. (db/org-default-notes-file . (:maxlevel . 9)))
  699. org-refile-use-outline-path 'file
  700. org-refile-use-cache t
  701. org-refile-allow-creating-parent-nodes 'confirm
  702. org-indirect-buffer-display 'current-window
  703. org-outline-path-complete-in-steps nil
  704. org-refile-target-verify-function 'db/verify-refile-target)
  705. ;; Bable
  706. (setq org-babel-load-languages '((shell . t)
  707. (emacs-lisp . t))))
  708. :config (progn
  709. ;; Allow company completion in Org Mode buffers
  710. (add-hook 'org-mode-hook 'company-mode)
  711. ;; Reset checkboxes if the RESET_CHECK_BOXES property is set
  712. (add-hook 'org-after-todo-state-change-hook 'org-reset-checkbox-state-maybe)
  713. ;; Statically color links sponding to whether the file exists, but
  714. ;; this turns out to be slow on Windows; we can use `org-lint' for
  715. ;; this when necessary)
  716. (org-link-set-parameters "file" :face 'org-link)
  717. ;; File Apps
  718. (add-to-list 'org-file-apps '(directory . emacs))
  719. (add-to-list 'org-file-apps '("\\.docx?\\'" . default))
  720. (add-to-list 'org-file-apps '("\\.pptx?\\'" . default))
  721. (add-to-list 'org-file-apps '("\\.xlsx?\\'" . default))
  722. (when (eq system-type 'cygwin)
  723. (add-to-list 'org-file-apps '(t . "cygstart %s") t))
  724. ;; Custom link types for Windows
  725. (when (eq system-type 'windows-nt)
  726. (org-link-set-parameters "onenote" :follow #'db/org-onenote-open)
  727. (org-link-set-parameters "outlook" :follow #'db/org-outlook-open))
  728. ;; Skip some org mode regions to be skipped by ispell
  729. (add-hook 'org-mode-hook #'endless/org-ispell)
  730. ;; Link type for RFCs
  731. (org-link-set-parameters "rfc" :follow #'db/org-rfc-open)
  732. ;; Some timers
  733. (unless (memq #'org-clock-save
  734. (mapcar #'timer--function timer-list))
  735. (run-with-timer 0 3600 #'org-clock-save))
  736. (unless (memq #'db/export-diary
  737. (mapcar #'timer--function timer-idle-list))
  738. (run-with-idle-timer 200 t #'db/export-diary))
  739. ;; Hack: The default implementation is too slow, because it is
  740. ;; parsing all properties of an entry by default. Let’s simplify
  741. ;; this to only parse what we are looking for. This makes tag
  742. ;; search *much* faster!
  743. (with-eval-after-load 'org
  744. (defun org-cached-entry-get (pom property)
  745. (if (or (eq t org-use-property-inheritance)
  746. (and (stringp org-use-property-inheritance)
  747. (let ((case-fold-search t))
  748. (string-match-p org-use-property-inheritance property)))
  749. (and (listp org-use-property-inheritance)
  750. (member-ignore-case property org-use-property-inheritance)))
  751. ;; Caching is not possible, check it directly.
  752. (org-entry-get pom property 'inherit)
  753. ;; This is different in the original implementation
  754. (org-entry-get pom property))))))
  755. ;; Drag-and-Drop images into org-mode buffer
  756. (use-package org-download
  757. :commands (org-download-yank
  758. org-download-screenshot
  759. org-download-clipboard)
  760. :init (setq org-download-method 'attach))
  761. (use-package ol
  762. :init (setq org-link-keep-stored-after-insertion t)
  763. :commands (org-store-link))
  764. (use-package org-id
  765. :init (setq org-id-link-to-org-use-id t))
  766. (use-package org-clock
  767. :commands (org-clock-save)
  768. :init (progn
  769. (setq org-clock-history-length 23
  770. org-clock-in-resume t
  771. org-clock-into-drawer t
  772. org-clock-idle-time nil
  773. org-clock-out-remove-zero-time-clocks t
  774. org-clock-out-when-done '("DONE" "CANC" "WAIT" "HOLD")
  775. org-clock-auto-clock-resolution 'when-no-clock-is-running
  776. org-clock-mode-line-total 'auto
  777. org-clock-report-include-clocking-task t
  778. org-clock-in-switch-to-state (lambda (_)
  779. (when (not
  780. (and (boundp 'org-capture-mode)
  781. org-capture-mode))
  782. (cond
  783. ((member (org-get-todo-state)
  784. (list "TODO" "READ"))
  785. "CONT")
  786. ((member (org-get-todo-state)
  787. (list "GOTO"))
  788. "ATTN"))))
  789. org-clock-persist t
  790. org-clock-persist-query-resume nil
  791. org-time-stamp-rounding-minutes '(1 1))
  792. ;; On Windows, we don't have dbus to show notifications; default to
  793. ;; `message' instead
  794. (when on-windows
  795. (setq org-show-notification-handler #'message)))
  796. :config (progn
  797. (org-clock-persistence-insinuate)
  798. (add-hook 'org-clock-in-hook #'db/org-mark-current-default-task)
  799. (add-hook 'org-clock-in-hook #'db/org-update-frame-title-with-current-clock)
  800. ;; Clock in default task if no other task is given
  801. (add-hook 'org-clock-out-hook #'db/ensure-running-clock 'append)
  802. ;; Communicate the currently clocked in task to the outside world
  803. (add-hook 'org-clock-in-hook #'db/save-current-org-task-to-file)))
  804. ;; Agenda
  805. (use-package org-agenda
  806. :commands (org-agenda)
  807. :bind (:map org-agenda-mode-map
  808. ("i" . org-agenda-clock-in)
  809. ("v" . hydra-org-agenda-view/body))
  810. :init (setq org-agenda-include-diary t
  811. org-agenda-span 1
  812. org-agenda-insert-diary-strategy 'top-level
  813. org-catch-invisible-edits 'show
  814. org-agenda-sorting-strategy '((agenda time-up habit-up priority-down)
  815. (todo category-keep)
  816. (tags category-keep)
  817. (search category-keep))
  818. org-agenda-window-setup 'current-window
  819. org-agenda-restore-windows-after-quit t
  820. org-agenda-compact-blocks nil
  821. org-agenda-todo-ignore-with-date nil
  822. org-agenda-todo-ignore-deadlines nil
  823. org-agenda-todo-ignore-scheduled nil
  824. org-agenda-todo-ignore-timestamp nil
  825. org-agenda-skip-deadline-if-done t
  826. org-agenda-skip-scheduled-if-done t
  827. org-agenda-skip-timestamp-if-done t
  828. org-agenda-skip-scheduled-if-deadline-is-shown 'not-today
  829. org-agenda-tags-todo-honor-ignore-options t
  830. org-agenda-start-with-log-mode nil
  831. org-agenda-log-mode-items '(closed clock)
  832. org-agenda-remove-tags t
  833. org-agenda-sticky nil
  834. org-agenda-inhibit-startup nil
  835. org-agenda-tags-todo-honor-ignore-options t
  836. org-agenda-dim-blocked-tasks nil
  837. org-enforce-todo-checkbox-dependencies t
  838. org-enforce-todo-dependencies t
  839. org-agenda-use-time-grid t
  840. org-agenda-persistent-filter t
  841. org-agenda-search-headline-for-time nil
  842. org-agenda-search-view-always-boolean t
  843. ;; Show daily efforts directly in the agenda
  844. org-agenda-finalize-hook '(db/org-agenda-insert-efforts)
  845. org-agenda-clock-consistency-checks
  846. '(:max-duration 9999999
  847. :min-duration 0
  848. :max-gap 0
  849. :gap-ok-around nil
  850. :default-face ((:background "DarkRed") (:foreground "white"))
  851. :overlap-face nil :gap-face nil :no-end-time-face nil
  852. :long-face nil :short-face nil)
  853. org-agenda-clockreport-parameter-plist
  854. '(:link t :maxlevel 4 :compact t :narrow 60 :fileskip0 t)
  855. org-stuck-projects
  856. '("+TODO=\"\"-DATE-REGULAR-HOLD-NOTE-TAGS={NOP\\|TOPIC}"
  857. ("CONT" "TODO" "READ" "WAIT" "GOTO" "DELG" "ATTN")
  858. ()
  859. "")
  860. org-agenda-prefix-format
  861. '((agenda . "%11s%?-12t%-4e ")
  862. (todo . "%-8c ")
  863. (tags . "%-8c ")
  864. (search . "%-8c "))
  865. org-agenda-custom-commands
  866. `(("A" "Main Agenda"
  867. ((agenda
  868. ""
  869. ((org-agenda-entry-types '(:timestamp :sexp :scheduled))
  870. (org-deadline-warning-days 0)))
  871. (db/org-agenda-list-deadlines
  872. ""
  873. ((org-agenda-overriding-header "Deadlines")
  874. (org-agenda-sorting-strategy '(deadline-up priority-down))
  875. (org-deadline-warning-days 30)))
  876. (tags "REFILE"
  877. ((org-agenda-files (list db/org-default-refile-file))
  878. (org-agenda-overriding-header "Things to refile (make it empty!)")))))
  879. ("O" "Open, non-periodic TODOs"
  880. ((tags-todo "-PERIODIC-SOMEWHEN-REGULAR-HOLD"
  881. ((org-agenda-overriding-header "List of open, non-periodic TODO items")
  882. (org-use-tag-inheritance t)
  883. (org-agenda-sorting-strategy '(deadline-down priority-down))
  884. (org-agenda-prefix-format '((tags . "%-12c %-4e ")))))))
  885. ("U" "Unsupervised (Waiting, Unscheduled, Stuck, Hold)"
  886. ((tags-todo "WAIT"
  887. ((org-agenda-overriding-header "Tasks requiring response/input")))
  888. (tags-todo "-HOLD-READ-SOMEWHEN/-DONE"
  889. ((org-agenda-overriding-header "Things not being scheduled or deadlined")
  890. (org-tags-match-list-sublevels t)
  891. (org-agenda-todo-ignore-with-date t)
  892. (org-agenda-sorting-strategy
  893. '(priority-down time-up category-keep))))
  894. (stuck ""
  895. ((org-agenda-overriding-header "Stuck Tasks")))
  896. (tags-todo "HOLD"
  897. ((org-agenda-overriding-header "Tasks on Hold")))))
  898. ("S" "Somewhen (Do if nothing else to do, i.e., personal backlog)"
  899. ((tags-todo "SOMEWHEN/-CANC-DONE|READ/-CANC-DONE"
  900. ((org-agenda-overriding-header "Things to do or read somewhen")
  901. (org-agenda-todo-ignore-with-date t)
  902. (org-tags-match-list-sublevels nil)))))
  903. ("P" "Current Projects"
  904. tags "TODO=\"\"-TAGS={NOP\\|TOPIC}-PERIODIC-NOTE-DATE"
  905. ((org-agenda-overriding-header "Open Projects (no TODO keyword, no PERIODIC, no NOTE, no DATE)")))
  906. ("W" "Weekly Review"
  907. ((agenda ""
  908. ((org-agenda-span 7)
  909. (org-agenda-archives-mode t)
  910. (org-agenda-dim-blocked-tasks nil)
  911. (org-agenda-skip-deadline-prewarning-if-scheduled t)))))))
  912. :config (progn
  913. ;; avoid important buffers to end up in `org-agenda-new-buffers’ by
  914. ;; opening them manually
  915. (mapc #'find-file-noselect org-agenda-files)
  916. (add-hook 'org-agenda-mode-hook #'hl-line-mode 'append)
  917. (advice-add 'org-agenda
  918. :before #'db/check-special-org-files-in-agenda)))
  919. ;; Capturing
  920. (use-package org-capture
  921. :commands (org-capture)
  922. :init (setq org-capture-use-agenda-date nil
  923. org-capture-templates
  924. `(("t" "Simple Task"
  925. entry
  926. (file db/org-default-refile-file)
  927. ,(concat "* TODO [#B] %^{What}\n"
  928. "SCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n"
  929. ":PROPERTIES:\n:CREATED: %U\n:END:\n"
  930. "%a\n"
  931. "%?"))
  932. ("T" "Complex Tasks")
  933. ("TC" "Record new complex task with first item"
  934. entry
  935. (file db/org-default-refile-file)
  936. ,(concat "* %^{Task Description}\n"
  937. ":PROPERTIES:\n:CREATED: %U\n:END:\n"
  938. "\n** TODO [#B] %^{First Thing to Do}\n"
  939. "SCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n"
  940. ":PROPERTIES:\n:CREATED: %U\n:END:\n"
  941. "\n%?"))
  942. ("TT" "Record new ticket with first item"
  943. entry
  944. (file db/org-default-refile-file)
  945. ,(concat "* Ticket #%^{Ticket Number}: %^{Ticket Description}\n"
  946. ":PROPERTIES:\n:CREATED: %U\n:END:\n"
  947. "\nReference: %^{Reference}\n"
  948. "\n** TODO [#B] %^{First Task}\n"
  949. "SCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n"
  950. ":PROPERTIES:\n:CREATED: %U\n:END:\n"
  951. "\n%?"))
  952. ("n" "Note"
  953. entry
  954. (file db/org-default-refile-file)
  955. "* %^{About} :NOTE:\n:PROPERTIES:\n:CREATED: %U\n:END:\n\n%?")
  956. ("d" "Date"
  957. entry
  958. (file db/org-default-refile-file)
  959. "* GOTO [#B] %^{What} :DATE:\n%^{When}t\n%a%?")
  960. ("i" "Interruptions"
  961. entry
  962. (file db/org-default-refile-file)
  963. "* DONE [#B] %^{What}\nCLOSED: %U\n\n%?"
  964. :clock-in t :clock-resume t)
  965. ("r" "respond"
  966. entry
  967. (file db/org-default-refile-file)
  968. ,(concat "* TODO [#B] E-Mail: %:subject (%:from) :EMAIL:\n"
  969. "SCHEDULED: %^{Reply when?}t\n"
  970. ":PROPERTIES:\n:CREATED: %U\n:END:\n"
  971. "\n%a")
  972. :immediate-finish t)
  973. ("R" "read"
  974. entry
  975. (file db/org-default-refile-file)
  976. ,(concat "* READ [#B] %:subject :READ:\n"
  977. ;; "DEADLINE: <%(org-read-date nil nil \"+1m\")>\n"
  978. ":PROPERTIES:\n:CREATED: %U\n:END:\n"
  979. "\n%a"))
  980. ("U" "Read current content of clipboard"
  981. entry
  982. (file db/org-default-refile-file)
  983. ,(concat "* READ [#B] %^{Description} :READ:\n"
  984. ":PROPERTIES:\n:CREATED: %U\n:END:\n"
  985. "\n%(current-kill 0)"))
  986. ("w" "Weekly Summary"
  987. entry
  988. (file+olp+datetree db/org-default-pensieve-file "Reviews")
  989. "* Weekly Review\n\n%?")
  990. ("s" "Code Snippet"
  991. entry
  992. (file db/org-default-refile-file)
  993. "* %?\n%(db/org-capture-code-snippet \"%F\")")
  994. ;; http://www.howardism.org/Technical/Emacs/capturing-content.html
  995. ("c" "Note for currently clocked in task"
  996. item
  997. (clock)
  998. "%i%?"
  999. :empty-lines 1)
  1000. ("K" "Kill-ring to currently clocked in task"
  1001. plain
  1002. (clock)
  1003. "%c"
  1004. :immediate-finish t :empty-lines 1)))
  1005. :config (progn
  1006. ;; disable usage of helm for `org-capture'
  1007. (with-eval-after-load 'helm-mode
  1008. (defvar helm-completing-read-handlers-alist) ; for the byte compiler
  1009. (add-to-list 'helm-completing-read-handlers-alist
  1010. '(org-capture . nil)))))
  1011. ;; Babel
  1012. (use-package ob-core
  1013. :init (setq org-export-use-babel nil)
  1014. :config (setf (alist-get :results org-babel-default-header-args)
  1015. "output code replace"))
  1016. (use-package ob-sql
  1017. :config (progn
  1018. (defun db/ob-sql-oracle-ask-for-password (orig-fun
  1019. host port user password database)
  1020. "Ask for PASSWORD if not given, and call ORIG-FUN with arguments afterwards."
  1021. (cond
  1022. ((not (or (and user database host port)
  1023. (and user database)))
  1024. (user-error "Insufficient login credentials given, aborting"))
  1025. (password
  1026. (funcall orig-fun host port user password database))
  1027. (t
  1028. (funcall orig-fun
  1029. host port user
  1030. (password-read (format "Password for %s@%s: " user database))
  1031. database))))
  1032. (advice-add #'org-babel-sql-dbstring-oracle
  1033. :around #'db/ob-sql-oracle-ask-for-password)))
  1034. ;; Exporting
  1035. (use-package ox-icalendar
  1036. :commands (org-icalendar-combine-agenda-files)
  1037. :init (setq org-icalendar-include-body nil
  1038. org-icalendar-store-UID t
  1039. org-icalendar-use-deadline nil
  1040. org-icalendar-use-scheduled nil
  1041. org-icalendar-include-todo nil
  1042. org-icalendar-exclude-tags '("NO_EXPORT")))
  1043. (use-package ox
  1044. :init (setq org-export-with-broken-links 'mark
  1045. org-export-with-sub-superscripts '{}
  1046. org-export-with-author nil
  1047. org-export-with-date nil
  1048. org-export-with-toc nil
  1049. org-export-with-archived-trees nil
  1050. org-export-with-tags t
  1051. org-export-with-priority nil
  1052. org-export-with-creator nil
  1053. org-export-with-entities t
  1054. org-export-with-special-strings t
  1055. org-export-with-todo-keywords nil
  1056. org-export-exclude-tags '("NO_EXPORT"))
  1057. :config (with-demoted-errors "Cannot load package: %s"
  1058. (require 'ox-md)
  1059. (require 'ox-pandoc)))
  1060. (use-package ox-latex
  1061. :init (setq org-latex-default-class "scrartcl"
  1062. org-latex-listings t
  1063. org-latex-compiler "lualatex")
  1064. :config (progn
  1065. (add-to-list 'org-latex-classes
  1066. `("scrartcl"
  1067. ,(concat "\\documentclass[parskip=half,colorlinks]{scrartcl}\n"
  1068. "[DEFAULT-PACKAGES]"
  1069. "[PACKAGES]"
  1070. "
  1071. \\lstset{
  1072. basewidth=0.5em,
  1073. keywordstyle=\\textcolor{blue!80!white},
  1074. basicstyle=\\ttfamily,
  1075. commentstyle={\\itshape},
  1076. frame=tb,
  1077. showspaces=false,
  1078. showtabs=false,
  1079. showstringspaces=false,
  1080. }
  1081. "
  1082. "[EXTRA]\n")
  1083. ("\\section{%s}" . "\\section*{%s}")
  1084. ("\\subsection{%s}" . "\\subsection*{%s}")
  1085. ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
  1086. ("\\paragraph{%s}" . "\\paragraph*{%s}")
  1087. ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
  1088. (add-to-list 'org-latex-classes
  1089. `("beamer"
  1090. ,(concat "\\documentclass[presentation]{beamer}\n"
  1091. "[DEFAULT-PACKAGES]"
  1092. "[PACKAGES]"
  1093. "
  1094. \\lstset{
  1095. basewidth=0.5em,
  1096. keywordstyle=\\textcolor{blue!80!white},
  1097. basicstyle=\\ttfamily,
  1098. commentstyle={\\itshape},
  1099. frame=tb,
  1100. showspaces=false,
  1101. showtabs=false,
  1102. showstringspaces=false,
  1103. }
  1104. "
  1105. "[EXTRA]\n")
  1106. ("\\section{%s}" . "\\section*{%s}")
  1107. ("\\subsection{%s}" . "\\subsection*{%s}")
  1108. ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
  1109. (add-to-list 'org-latex-packages-alist
  1110. '("" "listings"))
  1111. (add-to-list 'org-latex-packages-alist
  1112. '("" "xcolor"))))
  1113. (use-package ox-html
  1114. :init (setq org-html-postamble nil))
  1115. (use-package ox-pandoc
  1116. :init (setq org-pandoc-options-for-docx '((standalone . t))))
  1117. (use-package org-tree-slide
  1118. :commands (org-tree-slide-mode)
  1119. ;; Configuration from https://protesilaos.com/dotemacs/
  1120. :init (setq org-tree-slide-breadcrumbs " → "
  1121. org-tree-slide-header t
  1122. org-tree-slide-slide-in-effect nil
  1123. org-tree-slide-heading-emphasis nil
  1124. org-tree-slide-cursor-init t
  1125. org-tree-slide-modeline-display nil
  1126. org-tree-slide-skip-done nil
  1127. org-tree-slide-skip-comments t
  1128. org-tree-slide-fold-subtrees-skipped t
  1129. org-tree-slide-skip-outline-level 8
  1130. org-tree-slide-never-touch-face t
  1131. org-tree-slide-activate-message (propertize "Presentation mode ON" 'face 'success)
  1132. org-tree-slide-deactivate-message (propertize "Presentation mode OFF" 'face 'error))
  1133. :bind (:map org-tree-slide-mode-map
  1134. ("<C-down>" . org-tree-slide-display-header-toggle)
  1135. ("<C-right>" . org-tree-slide-move-next-tree)
  1136. ("<C-left>" . org-tree-slide-move-previous-tree)))
  1137. (use-package org-roam
  1138. :commands (org-roam-find-file)
  1139. :custom ((org-roam-directory "~/Documents/zettelkasten/")
  1140. (org-roam-db-location "~/Documents/zettelkasten/org-roam.db")
  1141. (org-roam-completion-everywhere t))
  1142. :bind (:map org-roam-mode-map
  1143. (("C-c n l" . org-roam)
  1144. ("C-c n f" . org-roam-find-file)
  1145. ("C-c n g" . org-roam-graph)))
  1146. :config (progn
  1147. ;; There seems to be a problem when capturing notes with the capture
  1148. ;; template. More precisely, `org-roam-current-title' does not get
  1149. ;; set correctly (is it my setup or a general bug?) This causes
  1150. ;; `org-roam--update-file-name-on-title-change' to get a nil
  1151. ;; argument, on which it barfs. Let's intercept this case and don't
  1152. ;; do anything. This effectively disables the auto-rename
  1153. ;; functionality when using org-capture to add notes.
  1154. (defun db/org-roam--no-titlechange-if-title-is-nil (orig-fun &rest args)
  1155. (unless (cl-some #'null args)
  1156. (apply orig-fun args)))
  1157. (advice-add 'org-roam--update-file-name-on-title-change
  1158. :around #'db/org-roam--no-titlechange-if-title-is-nil)
  1159. ;; `org-roam--id-link-face' apparently changes the matching data,
  1160. ;; resulting in `org-finalize-agenda' to fail while applying text
  1161. ;; properties to ID links; let's warp `save-match-data' around calls
  1162. ;; to it.
  1163. (defun db/save-match-data (orig-fun &rest args)
  1164. (save-match-data
  1165. (apply orig-fun args)))
  1166. (advice-add 'org-roam--id-link-face
  1167. :around #'db/save-match-data)))
  1168. (use-package org-ref
  1169. :config (progn
  1170. (require 'org-ref-pdf)
  1171. (require 'org-ref-url-utils)))
  1172. ;; * General Programming
  1173. (use-package ediff
  1174. :init (setq ediff-diff-options "-w"
  1175. ediff-window-setup-function 'ediff-setup-windows-plain
  1176. ediff-split-window-function 'split-window-horizontally
  1177. ediff-show-clashes-only t)
  1178. :config (progn
  1179. (add-hook 'ediff-keymap-setup-hook
  1180. '(lambda ()
  1181. (bind-key "j" #'ediff-next-difference ediff-mode-map)
  1182. (bind-key "k" #'ediff-previous-difference ediff-mode-map)))
  1183. (add-hook 'ediff-after-quit-hook-internal 'winner-undo)))
  1184. (use-package git-commit
  1185. :commands (global-git-commit-mode)
  1186. :init (setq git-commit-style-convention-checks '(non-empty-second-line
  1187. overlong-summary-line)
  1188. git-commit-known-pseudo-headers '("Signed-off-by"
  1189. "Acked-by"
  1190. "Modified-by"
  1191. "Cc"
  1192. "Suggested-by"
  1193. "Reported-by"
  1194. "Tested-by"
  1195. "Reviewed-by")))
  1196. (use-package magit
  1197. :commands (magit-status)
  1198. :init (setq magit-diff-refine-hunk nil
  1199. magit-commit-show-diff nil)
  1200. :config (progn
  1201. (when (fboundp 'global-magit-file-mode)
  1202. (global-magit-file-mode -1))
  1203. (global-git-commit-mode +1)
  1204. (db/sync-magit-repos-from-projectile)))
  1205. (use-package magit-repos
  1206. :commands (magit-list-repositories))
  1207. (use-package projectile
  1208. :ensure t
  1209. :commands (projectile-mode)
  1210. :defines (projectile-known-projects)
  1211. :bind (:map projectile-mode-map ("C-c p" . projectile-command-map))
  1212. :init (setq projectile-switch-project-action 'projectile-dired
  1213. projectile-completion-system 'helm
  1214. projectile-ignored-project-function #'file-remote-p
  1215. projectile-create-missing-test-files t
  1216. projectile-known-projects-file (expand-file-name "private/projectile-bookmarks.eld"
  1217. emacs-d))
  1218. :diminish projectile-mode)
  1219. (use-package counsel-projectile
  1220. :commands counsel-projectile)
  1221. (use-package highlight-indentation
  1222. :commands highlight-indentation-mode)
  1223. (use-package iedit
  1224. :ensure t
  1225. :commands (iedit-mode))
  1226. (use-package page-break-lines
  1227. :pin "melpa-stable"
  1228. :commands (page-break-lines-mode)
  1229. :diminish page-break-lines-mode)
  1230. (use-package semantic
  1231. :commands (semantic-mode)
  1232. :init (setq semantic-default-submodes
  1233. '(global-semantic-idle-scheduler-mode
  1234. global-semanticdb-minor-mode))
  1235. :config (progn
  1236. (require 'semantic/ia)
  1237. (require 'semantic/bovine/el)
  1238. ;; recognize `use-package' as include statement; the function seems
  1239. ;; to have to be a byte-compiled function, for otherwise it just
  1240. ;; won’t work … ?
  1241. (eval `(semantic-elisp-setup-form-parser
  1242. ,(lambda (form start end)
  1243. (ignore start end)
  1244. (semantic-tag-new-include (symbol-name (nth 1 form))
  1245. nil))
  1246. use-package))))
  1247. (use-package flycheck
  1248. :ensure t
  1249. :commands (global-flycheck-mode flycheck-mode)
  1250. :init (setq flycheck-emacs-lisp-load-path 'inherit))
  1251. (use-package eglot
  1252. :ensure t
  1253. :commands (eglot-ensure)
  1254. ;; Highlighting takes a lot of time and does not add much value, so let's just
  1255. ;; disable it
  1256. :init (setq eglot-ignored-server-capabilites '(:documentHighlightProvider)))
  1257. ;; * Mail
  1258. (use-package db-mail
  1259. :commands (db/smtpmail-send-it
  1260. db/public-key
  1261. db/encryption-possible-p
  1262. db/message-recipients
  1263. db/signencrypt-message-when-possible
  1264. db/gnus-save-newsrc-with-whitespace-1
  1265. db/gnus-summary-open-Link
  1266. db/gnus-html-mime-part-to-org
  1267. db/gnus-demon-scan-news-on-level-2))
  1268. (use-package bbdb
  1269. :commands (bbdb-search-name
  1270. bbdb-initialize
  1271. bbdb-mua-auto-update-init
  1272. bbdb-save)
  1273. :init (setq bbdb-completion-display-record nil
  1274. bbdb-complete-mail-allow-cycling t
  1275. bbdb-mua-auto-update-p 'query
  1276. bbdb-default-country "Germany")
  1277. :config (progn
  1278. (add-hook 'message-setup-hook 'bbdb-mail-aliases)
  1279. (add-hook 'mail-setup-hook 'bbdb-mail-aliases)
  1280. (run-with-timer 0 3600 #'bbdb-save)))
  1281. ;; General Gnus configuration
  1282. (setq gnus-init-file (expand-file-name "gnus.el" emacs-d)
  1283. gnus-home-directory (expand-file-name "~/Mail/news/")
  1284. gnus-directory (expand-file-name "~/Mail/news/")
  1285. gnus-kill-files-directory gnus-directory
  1286. gnus-startup-file (expand-file-name "~/Mail/gnus-newsrc")
  1287. gnus-cache-directory (expand-file-name "cache/" gnus-directory)
  1288. gnus-verbose 10
  1289. message-directory (expand-file-name "mail/" gnus-directory)
  1290. nnmail-message-id-cache-file (expand-file-name ".nnmail-cache" gnus-directory)
  1291. nnml-directory message-directory
  1292. mail-sources '((file))
  1293. mail-source-delete-incoming t
  1294. nntp-nov-is-evil t
  1295. nntp-connection-timeout nil
  1296. gnus-asynchronous t
  1297. gnus-save-killed-list nil
  1298. gnus-save-newsrc-file nil
  1299. gnus-read-newsrc-file nil
  1300. gnus-check-new-newsgroups nil
  1301. gnus-use-cache 'passive
  1302. gnus-read-active-file 'some
  1303. gnus-build-sparse-threads 'some
  1304. gnus-subscribe-newsgroup-method 'gnus-subscribe-killed
  1305. gnus-group-list-inactive-groups t
  1306. gnus-suppress-duplicates nil
  1307. gnus-large-newsgroup 200
  1308. nnmail-expiry-wait 7
  1309. nnmail-cache-accepted-message-ids t
  1310. gnus-summary-next-group-on-exit nil
  1311. gnus-use-full-window nil
  1312. gnus-always-force-window-configuration t
  1313. gnus-fetch-old-headers nil
  1314. gnus-select-method '(nnnil "")
  1315. gnus-refer-article-method 'current
  1316. gnus-visible-headers (regexp-opt '("From:"
  1317. "Newsgroups:"
  1318. "Subject:"
  1319. "Date:"
  1320. "Followup-To:"
  1321. "Reply-To:"
  1322. "Organization:"
  1323. "Summary:"
  1324. "Keywords:"
  1325. "Mail-Copies-To:"
  1326. "To:"
  1327. "Cc:"
  1328. "BCC:"
  1329. "X-Newsreader:"
  1330. "X-Mailer:"
  1331. "X-Sent:"
  1332. "Posted-To:"
  1333. "Mail-Copies-To:"
  1334. "Apparently-To:"
  1335. "Gnus-Warning:"
  1336. "Resent-From:"
  1337. "gpg-key-ID:"
  1338. "fingerprint:"
  1339. "X-Jabber-ID:"
  1340. "User-Agent:"))
  1341. message-citation-line-function
  1342. (lambda ()
  1343. (when message-reply-headers
  1344. (insert "ghItlhpu' "
  1345. (mail-header-from message-reply-headers)
  1346. ":")
  1347. (newline))))
  1348. ;; Gnus Appearence
  1349. (setq gnus-group-line-format "%S%p%P%5y(%2i):%B%(%s:%G%)\n"
  1350. gnus-auto-select-first nil
  1351. gnus-auto-select-next nil
  1352. gnus-summary-line-format "%U%O%R%6k %(%&user-date; %-13,13f %B%s%)\n"
  1353. gnus-thread-sort-functions '(gnus-thread-sort-by-most-recent-date)
  1354. gnus-subthread-sort-functions '(gnus-thread-sort-by-date)
  1355. gnus-thread-hide-subtree t
  1356. gnus-user-date-format-alist '((t . "%Y-%m-%d %H:%M"))
  1357. gnus-sum-thread-tree-indent " "
  1358. gnus-sum-thread-tree-root "● "
  1359. gnus-sum-thread-tree-false-root "◎ "
  1360. gnus-sum-thread-tree-single-indent "◯ "
  1361. gnus-sum-thread-tree-single-leaf "╰► "
  1362. gnus-sum-thread-tree-leaf-with-other "├► "
  1363. gnus-sum-thread-tree-vertical "│"
  1364. gnus-summary-thread-gathering-function 'gnus-gather-threads-by-references
  1365. ;; New mark symbols (seen here:
  1366. ;; `https://github.com/cofi/dotfiles/blob/master/gnus.el')
  1367. gnus-ancient-mark ?✓
  1368. ;; gnus-cached-mark ?☍
  1369. gnus-canceled-mark ?↗
  1370. gnus-del-mark ?✗
  1371. ;; gnus-dormant-mark ?⚐
  1372. gnus-expirable-mark ?♻
  1373. gnus-forwarded-mark ?↪
  1374. ;; gnus-killed-mark ?☠
  1375. ;; gnus-process-mark ?⚙
  1376. gnus-read-mark ?✓
  1377. gnus-recent-mark ?✩
  1378. gnus-replied-mark ?↺
  1379. gnus-unread-mark ?✉
  1380. ;; gnus-unseen-mark ?★
  1381. ;; gnus-ticked-mark ?⚑
  1382. gnus-treat-hide-boring-headers 'head
  1383. gnus-treat-strip-multiple-blank-lines nil
  1384. gnus-treat-display-smileys t
  1385. gnus-treat-emphasize 'head
  1386. gnus-treat-unsplit-urls t)
  1387. (use-package gnus-art
  1388. :init (setq gnus-ignored-mime-types '("text/x-vcard")
  1389. gnus-inhibit-mime-unbuttonizing nil
  1390. gnus-buttonized-mime-types '("multipart/signed" "multipart/encrypted")
  1391. gnus-inhibit-images t
  1392. gnus-blocked-images ".*"))
  1393. ;; Adaptive Scoring
  1394. (setq gnus-use-scoring t
  1395. gnus-use-adaptive-scoring '(word line)
  1396. gnus-summary-mark-below nil
  1397. gnus-adaptive-word-length-limit 5
  1398. gnus-adaptive-word-no-group-words t
  1399. gnus-default-adaptive-score-alist
  1400. '((gnus-unread-mark)
  1401. (gnus-ticked-mark (from 4))
  1402. (gnus-dormant-mark (from 5))
  1403. (gnus-del-mark (from -4) (subject -1))
  1404. (gnus-read-mark (from 4) (subject 2))
  1405. (gnus-expirable-mark (from -1) (subject -1))
  1406. (gnus-killed-mark (from -1) (subject -3))
  1407. (gnus-kill-file-mark)
  1408. (gnus-ancient-mark)
  1409. (gnus-low-score-mark)
  1410. (gnus-catchup-mark (from -1) (subject -1)))
  1411. gnus-summary-mark-below nil)
  1412. ;; Gnus Registry
  1413. (use-package gnus-registry
  1414. :commands (gnus-registry-split-fancy-with-parent
  1415. gnus-registry-initialize)
  1416. :init (setq gnus-registry-split-strategy 'majority
  1417. gnus-registry-ignored-groups '(("^nntp" t)
  1418. ("^nnfolder" t)
  1419. ("^nnir" t)
  1420. ("^nnmaildir" t)
  1421. ("INBOX$" t))
  1422. gnus-registry-max-entries 40000
  1423. gnus-registry-track-extra '(sender subject recipient)
  1424. gnus-registry-cache-file (expand-file-name "gnus.registry.eioioi"
  1425. emacs-d)))
  1426. ;; MIME decoding
  1427. (use-package mm-decode
  1428. :init (setq mm-text-html-renderer 'shr
  1429. mm-discouraged-alternatives '("text/richtext")
  1430. mm-decrypt-option 'known
  1431. mm-verify-option 'known)
  1432. :config (progn
  1433. (setq mm-automatic-display (-difference mm-automatic-display
  1434. '("text/enriched"
  1435. "text/richtext")))
  1436. ;; Automatically show PGP data inline
  1437. (add-to-list 'mm-inlined-types "application/pgp$")
  1438. (add-to-list 'mm-inline-media-tests
  1439. '("application/pgp$" mm-inline-text identity))
  1440. (add-to-list 'mm-automatic-display "application/pgp$")
  1441. ;; When copying MIME buffers, we are looking for the start of the
  1442. ;; header by searching ^\n; however, if we received mail from
  1443. ;; Outlook, there's an ^\r\n seperating header and body, which is
  1444. ;; not found by `mm-copy-to-buffer', leaving the target buffer empty
  1445. ;; and the mail as well. Redefining `mm-copy-to-buffer' to also
  1446. ;; search for ^\r\n might help.
  1447. (defun mm-copy-to-buffer ()
  1448. "Copy the contents of the current buffer to a fresh buffer."
  1449. (let ((obuf (current-buffer))
  1450. (mb enable-multibyte-characters)
  1451. beg)
  1452. (goto-char (point-min))
  1453. ;; The following regex has been extended by \r? .
  1454. (search-forward-regexp "^\r?\n" nil 'move) ;; There might be no body.
  1455. (setq beg (point))
  1456. (with-current-buffer
  1457. (generate-new-buffer " *mm*")
  1458. ;; Preserve the data's unibyteness (for url-insert-file-contents).
  1459. (set-buffer-multibyte mb)
  1460. (insert-buffer-substring obuf beg)
  1461. (current-buffer))))))
  1462. (setq message-forward-as-mime nil)
  1463. ;; MIME creation; signing, and encryption
  1464. (use-package mml
  1465. :config (progn
  1466. ;; Move to end of message buffer before attaching a file
  1467. ;; http://mbork.pl/2015-11-28_Fixing_mml-attach-file_using_advice
  1468. (defun db/mml-attach-file--go-to-eob (orig-fun &rest args)
  1469. "Go to the end of buffer before attaching files."
  1470. (save-excursion
  1471. (save-restriction
  1472. (widen)
  1473. (goto-char (point-max))
  1474. (apply orig-fun args))))
  1475. (advice-add 'mml-attach-file
  1476. :around #'db/mml-attach-file--go-to-eob)))
  1477. (use-package mm-encode
  1478. :init (setq mm-encrypt-option nil
  1479. mm-sign-option nil))
  1480. (setq mml-secure-openpgp-encrypt-to-self t
  1481. mml-secure-smime-encrypt-to-self t
  1482. mml2015-display-key-image nil
  1483. gnus-message-replysign t
  1484. gnus-message-replyencrypt t
  1485. gnus-message-replysignencrypted t
  1486. mml-secure-cache-passphrase nil
  1487. mml-secure-openpgp-sign-with-sender t
  1488. mml-secure-smime-sign-with-sender t)
  1489. (use-package mml-smime
  1490. :init (setq mml-smime-use 'epg)
  1491. :config (progn
  1492. ;; Outlook seems to expect \r\n in PKCS#7 encrypted containers, but
  1493. ;; Gnus is only sending \n; so let's artificially replace \n by \r\n
  1494. ;; after, well, signing? But only if we are encrypting with S/MIME,
  1495. ;; as otherwise the search for \n\n in `message-encode-message-body'
  1496. ;; will break. However, I think this is not the right way to do it
  1497. ;; … isn't there some way to specify the encoding of the the
  1498. ;; relevant MML buffers to be some nasty cp1252 or something?
  1499. ;; A previous version of this worked, but the following has not been
  1500. ;; tested with Outlook proper.
  1501. (defun db/smime-add-crlf-when-pkcs7 (cont)
  1502. "If CONT signifies encryption with smime, replace all \n with \r\n."
  1503. (when (and (eq (car cont) 'part)
  1504. (string= "smime" (or (cdr (assq 'encrypt cont)) "")))
  1505. (db/convert-lf-to-crlf-in-buffer)))
  1506. (advice-add 'mml-smime-epg-sign
  1507. :after #'db/smime-add-crlf-when-pkcs7)))
  1508. ;; Archiving
  1509. ;; We store messages in the current group, so there is
  1510. ;; no need to use Gnus’ archiving method
  1511. (setq gnus-message-archive-method nil
  1512. gnus-update-message-archive-method t
  1513. gnus-message-archive-group nil
  1514. gnus-gcc-mark-as-read t)
  1515. ;; Searching
  1516. (setq nnir-method-default-engines '((nnimap . imap)
  1517. (nnmaildir . notmuch)
  1518. (nntp . gmane)))
  1519. ;; Agents
  1520. (setq gnus-agent-mark-unread-after-downloaded nil
  1521. gnus-agent-synchronize-flags t
  1522. gnus-agent-go-online t)
  1523. ;; Package configuration
  1524. (use-package gnus
  1525. :commands (gnus)
  1526. :config (progn
  1527. (require 'db-mail)
  1528. (with-demoted-errors "Setting up BBDB failed: %s"
  1529. (bbdb-initialize 'gnus 'message)
  1530. (bbdb-mua-auto-update-init 'message))
  1531. ;; Ensure that whenever we compose new mail, it will use the correct
  1532. ;; posting style. This is ensured by setting ARG of
  1533. ;; `gnus-group-mail’ to 1 to let it query the user for a group.
  1534. (defadvice gnus-group-mail (before inhibit-no-argument activate)
  1535. (unless (ad-get-arg 0)
  1536. (ad-set-arg 0 1)))
  1537. (remove-hook 'gnus-mark-article-hook
  1538. 'gnus-summary-mark-read-and-unread-as-read)
  1539. (add-hook 'gnus-mark-article-hook 'gnus-summary-mark-unread-as-read)
  1540. ;; Quit Gnus gracefully when exiting Emacs
  1541. (add-hook 'kill-emacs-hook #'(lambda ()
  1542. (interactive)
  1543. (when (get-buffer "*Group*")
  1544. (gnus-group-exit))))
  1545. ;; Don’t quit summary buffer when pressing `q’
  1546. (bind-key "q" #'gnus-summary-expand-window gnus-article-mode-map)
  1547. ;; Show topics in group buffer
  1548. (add-hook 'gnus-group-mode-hook 'gnus-topic-mode)
  1549. ;; We need to do some magic as otherwise the agent does not delete
  1550. ;; articles from its .overview when we move them around. Thus we
  1551. ;; mark articles as expireable when they have been moved to another
  1552. ;; group.
  1553. (defadvice gnus-summary-move-article (around
  1554. no-cancel-mark
  1555. (&optional n to-newsgroup
  1556. select-method action)
  1557. activate)
  1558. (let ((articles (gnus-summary-work-articles n))
  1559. (return ad-do-it))
  1560. (when (or (null action)
  1561. (eq action 'move))
  1562. (dolist (article articles)
  1563. (gnus-summary-mark-article article gnus-expirable-mark)))
  1564. return))
  1565. ;; Increase score of group after reading it
  1566. (add-hook 'gnus-summary-exit-hook
  1567. 'gnus-summary-bubble-group)
  1568. ;; Use Gnus’ registry; doing this too early conflicts with `gnus'
  1569. ;; calling `gnus-shutdown', which in turn calls
  1570. ;; `gnus-registry-clear', leaving us with an empty registry upon
  1571. ;; startup. So let's call this initialization right after startup,
  1572. ;; that should be fine.
  1573. (add-hook 'gnus-started-hook
  1574. #'gnus-registry-initialize)
  1575. ;; Automatic encryption if all necessary keys are present
  1576. (add-hook 'gnus-message-setup-hook
  1577. #'db/signencrypt-message-when-possible)
  1578. ;; Do some pretty printing before saving the newsrc file
  1579. (add-hook 'gnus-save-quick-newsrc-hook
  1580. #'db/gnus-save-newsrc-with-whitespace-1)
  1581. ;; Automatically scan for new news
  1582. (gnus-demon-add-handler 'db/gnus-demon-scan-news-on-level-2 5 5)
  1583. (add-hook 'gnus-started-hook #'gnus-demon-init)
  1584. ;; Visit group under point and immediately close it; this updates
  1585. ;; gnus’ registry as a side-effect
  1586. (bind-key "v u"
  1587. '(lambda ()
  1588. (interactive)
  1589. (save-mark-and-excursion
  1590. (when (gnus-topic-select-group)
  1591. (gnus-summary-exit))))
  1592. gnus-group-mode-map)
  1593. ;; Toggle visibility of News group
  1594. (bind-key "v c"
  1595. (lambda ()
  1596. (interactive)
  1597. (save-mark-and-excursion
  1598. (gnus-topic-jump-to-topic "News")
  1599. (gnus-topic-read-group)))
  1600. gnus-group-mode-map)
  1601. (bind-key "C-<return>" #'db/gnus-summary-open-Link gnus-summary-mode-map)
  1602. (bind-key "C-<return>" #'db/gnus-summary-open-Link gnus-article-mode-map)))
  1603. ;; Sending mail
  1604. (setq message-send-mail-function #'db/smtpmail-send-it
  1605. send-mail-function #'db/smtpmail-send-it
  1606. mail-user-agent 'gnus-user-agent)
  1607. (use-package smtpmail
  1608. :init (setq smtpmail-stream-type 'starttls
  1609. smtpmail-smtp-service 587
  1610. smtpmail-debug-info t))
  1611. ;; * Crypto
  1612. (use-package nsm
  1613. :init (setq network-security-level 'high
  1614. nsm-save-host-names t
  1615. nsm-settings-file (expand-file-name
  1616. "~/.emacs.d/private/network-security.data"))
  1617. :config (advice-add 'nsm-write-settings
  1618. :before #'db/sort-nsm-permanent-settings))
  1619. (use-package gnutls
  1620. :init (setq gnutls-log-level 0 ; too noisy otherwise
  1621. gnutls-min-prime-bits 1024
  1622. gnutls-verify-error t))
  1623. (use-package epg
  1624. :init (setq epg-debug t
  1625. epg-gpg-program "gpg"))
  1626. ;; * Appearance
  1627. (setq-default cursor-type 'bar
  1628. cursor-in-non-selected-windows nil
  1629. font-lock-maximum-decoration '((t . t)))
  1630. (setq mode-line-format '((ace-window-display-mode
  1631. (:eval
  1632. (window-parameter
  1633. (selected-window)
  1634. 'ace-window-path)))
  1635. "%e"
  1636. mode-line-front-space
  1637. mode-line-position
  1638. mode-line-mule-info
  1639. mode-line-client
  1640. mode-line-modified
  1641. mode-line-remote
  1642. mode-line-buffer-identification
  1643. mode-line-modes
  1644. (vc-mode vc-mode)
  1645. mode-line-misc-info
  1646. mode-line-end-spaces))
  1647. (use-package solarized-theme
  1648. :ensure t
  1649. :init (setq solarized-use-less-bold t
  1650. solarized-emphasize-indicators t
  1651. solarized-use-variable-pitch nil))
  1652. (use-package smart-mode-line
  1653. :ensure t
  1654. :init (setq sml/mode-width 'full
  1655. sml/name-width 30)
  1656. :commands (sml/setup))
  1657. (use-package minions
  1658. :ensure t
  1659. :commands (minions-mode)
  1660. :init (setq minions-mode-line-lighter "…"))
  1661. (use-package moody
  1662. :ensure t
  1663. :commands (moody-replace-mode-line-buffer-identification
  1664. moody-replace-vc-mode))
  1665. ;; * Dired
  1666. (use-package dired
  1667. :bind (:map dired-mode-map
  1668. ("e" . ora-ediff-files)
  1669. ("z" . dired-get-size)
  1670. ([remap beginning-of-buffer] . dired-back-to-top)
  1671. ([remap end-of-buffer] . dired-jump-to-bottom)
  1672. ("<f1>" . nil)
  1673. ("<tab>" . dired-subtree-toggle)
  1674. ("<C-tab>" . dired-subtree-cycle))
  1675. :init (progn
  1676. (setq dired-dwim-target t
  1677. dired-listing-switches (if on-windows "-aGFhlv" "-aGFhlv --group-directories-first --time-style=long-iso")
  1678. dired-hide-details-hide-information-lines t
  1679. dired-hide-details-hide-symlink-targets t
  1680. dired-recursive-copies 'top
  1681. dired-recursive-deletes 'top
  1682. dired-create-destination-dirs 'ask
  1683. dired-vc-rename-file t
  1684. ;; Don’t use obsolete diredx local variables
  1685. dired-enable-local-variables nil
  1686. dired-local-variables-file nil
  1687. dired-omit-files "^\\.?#\\|^\\.$\\|^\\.\\.$\\|^\\..*$"
  1688. diredp-hide-details-initially-flag t
  1689. wdired-create-parent-directories t
  1690. wdired-allow-to-change-permissions t
  1691. dired-isearch-filenames 'dwim
  1692. dired-auto-revert-buffer t)
  1693. (setq dired-guess-shell-alist-user
  1694. '(("\\.pdf\\'" "evince")
  1695. ("\\.ps\\'" "evince")
  1696. ("\\.\\(?:djvu\\|eps\\)\\'" "evince")
  1697. ("\\.\\(?:jpg\\|jpeg\\|png\\|gif\\|xpm\\)\\'" "eog")
  1698. ("\\.\\(?:xcf\\)\\'" "gimp")
  1699. ("\\.\\(?:mp4\\|mkv\\|avi\\|flv\\|ogv\\|webm\\)\\(?:\\.part\\)?\\'"
  1700. "vlc")
  1701. ("\\.\\(?:mp3\\|flac\\|ogg\\)\\'" "mplayer")
  1702. ("\\.docx?\\'" "loffice")))
  1703. (when on-windows
  1704. (setq directory-free-space-program nil)))
  1705. :config (progn
  1706. (put 'dired-find-alternate-file 'disabled nil)
  1707. (require 'dired-x)
  1708. (with-demoted-errors "Non-Fatal Errors (dired-open): %s"
  1709. (require 'dired-open))
  1710. (if (eq system-type 'windows-nt)
  1711. (with-demoted-errors "Non-Fatal Error (w32-browser): %s"
  1712. (require 'w32-browser)
  1713. (bind-key "M-RET" #'dired-w32-browser dired-mode-map)
  1714. (bind-key "<C-return>" #'dired-w32explore dired-mode-map))
  1715. (bind-key "M-RET" #'dired-open-xdg dired-mode-map))
  1716. (with-demoted-errors "Non-Fatal Errors (dired-recent): %s"
  1717. (dired-recent-mode +1))
  1718. ;; Gnus support in dired
  1719. (add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)
  1720. ;; Highlight current line more prominently
  1721. (add-hook 'dired-mode-hook 'hl-line-mode)
  1722. ;; omitting files
  1723. (add-hook 'dired-mode-hook 'dired-omit-mode)
  1724. (add-hook 'dired-mode-hook 'dired-hide-details-mode)
  1725. (dolist (extension '(".out" ".synctex.gz" ".thm"))
  1726. (add-to-list 'dired-latex-unclean-extensions extension))
  1727. (defun ora-ediff-files ()
  1728. "Compare marked files in dired with ediff."
  1729. ;; from: https://oremacs.com/2017/03/18/dired-ediff/
  1730. (interactive)
  1731. (lexical-let ((files (dired-get-marked-files))
  1732. (wnd (current-window-configuration)))
  1733. (if (<= (length files) 2)
  1734. (lexical-let ((file1 (car files))
  1735. (file2 (if (cdr files)
  1736. (cadr files)
  1737. (read-file-name
  1738. "file: "
  1739. (dired-dwim-target-directory)))))
  1740. (if (file-newer-than-file-p file1 file2)
  1741. (ediff-files file2 file1)
  1742. (ediff-files file1 file2))
  1743. (add-hook 'ediff-after-quit-hook-internal
  1744. (lambda ()
  1745. (setq ediff-after-quit-hook-internal nil)
  1746. (set-window-configuration wnd))))
  1747. (error "No more than 2 files should be marked"))))
  1748. (defun dired-back-to-top ()
  1749. "Jump to first non-trivial line in dired."
  1750. (interactive)
  1751. (goto-char (point-min))
  1752. (dired-next-line 1))
  1753. (defun dired-jump-to-bottom ()
  1754. "Jump to last non-trivial line in dired."
  1755. (interactive)
  1756. (goto-char (point-max))
  1757. (dired-next-line -1))
  1758. (defun dired-get-size () ; from emacswiki, via oremacs
  1759. "Print size of all files marked in the current dired buffer."
  1760. (interactive)
  1761. (let ((files (dired-get-marked-files)))
  1762. (with-temp-buffer
  1763. (apply 'call-process "/usr/bin/du" nil t nil "-sch" files)
  1764. (message
  1765. "size of all marked files: %s"
  1766. (progn
  1767. (re-search-backward "\\(^[0-9.,]+[a-za-z]+\\).*total$")
  1768. (match-string 1))))))))
  1769. (use-package dired-x
  1770. :commands (dired-jump dired-jump-other-window)
  1771. :init (setq dired-clean-confirm-killing-deleted-buffers t
  1772. dired-x-hands-off-my-keys t
  1773. dired-bind-man nil
  1774. dired-bind-info nil
  1775. dired-clean-up-buffers-too t))
  1776. (use-package dired-subtree
  1777. :commands (dired-subtree-toggle))
  1778. (use-package find-dired
  1779. :commands (find-dired)
  1780. :init (setq find-ls-option '("-print0 | xargs -0 ls -ld" . "-ld")))
  1781. (use-package dired-open
  1782. :ensure t
  1783. :init (progn
  1784. (unless (eq system-type 'gnu/linux)
  1785. (setq dired-open-use-nohup nil))
  1786. (setq dired-open-extensions-elisp '(("html" . eww-open-file))))
  1787. :config (progn
  1788. (add-to-list 'dired-open-functions
  1789. #'dired-open-guess-shell-alist)
  1790. (add-to-list 'dired-open-functions
  1791. #'dired-open-call-function-by-extension)))
  1792. (use-package dired-recent
  1793. :ensure t
  1794. :init (setq dired-recent-max-directories nil)
  1795. :commands (dired-recent-mode
  1796. dired-recent-open))
  1797. (use-package gnus-dired
  1798. :commands (turn-on-gnus-dired-mode))
  1799. (use-package trashed
  1800. ;; A simple dired-like interface to the system trash bin
  1801. ;; Configuration taken from https://protesilaos.com/dotemacs
  1802. :init (setq trashed-action-confirmer 'y-or-n-p
  1803. trashed-use-header-line t
  1804. trashed-sort-key '("Date deleted" . t)
  1805. trashed-date-format "%Y-%m-%d %H:%M:%S"))
  1806. ;; * Completion
  1807. (use-package hippie-exp
  1808. :commands (hippie-expand))
  1809. (use-package helm
  1810. :ensure t
  1811. :diminish helm-mode
  1812. :init (setq helm-command-prefix-key "C-c h"
  1813. helm-input-idle-delay 0.0
  1814. helm-buffers-fuzzy-matching t
  1815. helm-mode-fuzzy-match t
  1816. helm-autoresize-min-height 20
  1817. helm-ff-auto-update-initial-value t
  1818. helm-ff-file-name-history-use-recentf t
  1819. helm-ff-search-library-in-sexp t
  1820. helm-ff-skip-boring-files nil
  1821. helm-split-window-inside-p t
  1822. helm-move-to-line-cycle-in-source nil
  1823. helm-scroll-amount nil
  1824. helm-locate-command nil
  1825. helm-candidate-number-limit 100
  1826. helm-follow-mode-persistent t
  1827. helm-buffer-details-flag t
  1828. helm-buffer-skip-remote-checking t
  1829. helm-mode-no-completion-in-region-in-modes '(eshell-mode))
  1830. :config (progn
  1831. (require 'helm-config)
  1832. (require 'helm-mode)
  1833. (require 'helm-buffers)
  1834. (require 'helm-ring)
  1835. (if (require 'helm-global-bindings nil :no-error)
  1836. (progn
  1837. (bind-key "#" #'helm-emms helm-command-map)
  1838. (bind-key "P" #'helm-pages helm-command-map))
  1839. (warn (concat
  1840. "Cannot load `helm-global-bindings', please check your helm installation for completeness. "
  1841. "(Have you installed it from melpa?)")))
  1842. (bind-key "<tab>" #'helm-execute-persistent-action helm-map)
  1843. (bind-key "C-i" #'helm-execute-persistent-action helm-map)
  1844. (bind-key "C-z" #'helm-select-action helm-map)))
  1845. (use-package helm-ring
  1846. :commands (helm-show-kill-ring))
  1847. (use-package ivy
  1848. :ensure t
  1849. :commands (ivy-mode
  1850. ivy-resume)
  1851. :diminish ivy-mode
  1852. :init (setq ivy-use-virtual-buffers t
  1853. ivy-magic-tilde nil
  1854. ivy-count-format "(%d/%d) "
  1855. ivy-initial-inputs-alist '((counsel-describe-function . "^")
  1856. (counsel-describe-variable . "^")
  1857. (man . "^")
  1858. (woman . "^"))
  1859. ivy-use-selectable-prompt t
  1860. ivy-do-completion-in-region t
  1861. ivy-re-builders-alist '((t . ivy--regex-ignore-order)))
  1862. :config (progn
  1863. ;; Since we are using `ivy--regex-ignore-order' for completion
  1864. ;; anyway, providing the an individual restriction in the ivy buffer
  1865. ;; is not necessary anymore. Since I often mistype S-SPC for SPC,
  1866. ;; loosing the current candidate and annoying myself, removing this
  1867. ;; shortcut is both helpful and not removing necessary
  1868. ;; functionality.
  1869. (define-key ivy-minibuffer-map (kbd "S-SPC") nil)))
  1870. (use-package ivy-hydra)
  1871. (use-package counsel
  1872. :ensure t
  1873. :commands (counsel-org-goto-all
  1874. counsel-ag
  1875. counsel-M-x
  1876. counsel-find-file
  1877. counsel-info-lookup-symbol
  1878. counsel-unicode-char
  1879. counsel-descbinds
  1880. counsel-describe-variable
  1881. counsel-describe-function
  1882. counsel-recentf
  1883. counsel-shell-history))
  1884. (use-package swiper
  1885. :ensure t
  1886. :commands (swiper
  1887. swiper-from-isearch))
  1888. (use-package recentf
  1889. :commands (recentf-mode recentf-save-list)
  1890. :init (setq recentf-max-saved-items 1000)
  1891. :config (run-with-timer 0 3600 #'recentf-save-list))
  1892. (use-package company
  1893. :commands (company-mode global-company-mode)
  1894. :init (setq company-show-numbers t))
  1895. ;; * Navigation
  1896. (defun db/helm-shortcuts (arg)
  1897. "Open helm completion on common locations.
  1898. With given ARG, display files in `db/important-document-path’."
  1899. (interactive "p")
  1900. (require 'helm-bookmark)
  1901. (require 'helm-for-files) ; for helm-source-recentf
  1902. (helm :sources (list
  1903. (helm-make-source "Frequently Used" 'helm-source-sync
  1904. :candidates (mapcar #'(lambda (entry)
  1905. (cons (car entry)
  1906. (caddr entry)))
  1907. db/frequently-used-features)
  1908. :action '(("Open" . call-interactively))
  1909. :filtered-candidate-transformer #'helm-adaptive-sort)
  1910. ;; taken from `helm-buffers-list'
  1911. (helm-make-source "Buffers" 'helm-source-buffers)
  1912. helm-source-recentf
  1913. ;; if prefix arg is given, extract files from
  1914. ;; `db/important-documents-path’ and list them as well
  1915. (when (and (= arg 4)
  1916. (file-directory-p db/important-documents-path))
  1917. (let ((search-path (expand-file-name db/important-documents-path)))
  1918. (helm-make-source "Important files" 'helm-source-sync
  1919. :candidates (mapcar #'(lambda (file)
  1920. ;; display only relative path,
  1921. ;; but keep absolute path for
  1922. ;; actions
  1923. (cons (string-remove-prefix search-path file)
  1924. file))
  1925. (directory-files-recursively search-path ""))
  1926. :action '(("Open externally" . db/system-open)
  1927. ("Find file" . find-file)))))
  1928. helm-source-bookmarks
  1929. helm-source-buffer-not-found
  1930. helm-source-bookmark-set)))
  1931. (use-package ace-window
  1932. :ensure t
  1933. :commands (ace-window ace-window-display-mode)
  1934. :init (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)
  1935. aw-background t
  1936. aw-leading-char-style 'char
  1937. aw-scope 'frame))
  1938. (use-package avy
  1939. :ensure t
  1940. :commands (avy-goto-char-timer
  1941. avy-goto-word-or-subword-1
  1942. avy-goto-line))
  1943. (use-package bm
  1944. ;; Taken from https://protesilaos.com/dotemacs/ and slightly adapted
  1945. :ensure t
  1946. :commands (bm-toggle bm-next bm-previous bm-toggle-buffer-persistence)
  1947. :init (setq bm-restore-repository-on-load t
  1948. bm-annotate-on-create nil
  1949. bm-buffer-persistence t
  1950. bm-cycle-all-buffers t
  1951. bm-goto-position nil
  1952. bm-highlight-style 'bm-highlight-line-and-fringe
  1953. bm-marker 'bm-marker-right
  1954. bm-in-lifo-order nil
  1955. bm-recenter t
  1956. bm-repository-file "~/.emacs.d/bm-bookmarks"
  1957. bm-repository-size 100
  1958. bm-show-annotations t
  1959. bm-wrap-immediately t
  1960. bm-wrap-search t))
  1961. (use-package dumb-jump
  1962. :commands (dumb-jump-xref-activate)
  1963. :init (progn
  1964. (setq dumb-jump-selector 'helm)
  1965. (add-hook 'xref-backend-functions #'dumb-jump-xref-activate)))
  1966. (use-package helm-pages
  1967. :ensure t
  1968. :commands (helm-pages))
  1969. (use-package imenu
  1970. :init (setq imenu-use-markers t
  1971. imenu-auto-rescan t
  1972. imenu-auto-rescan-maxout 600000
  1973. imenu-max-item-length 100
  1974. imenu-use-popup-menu nil
  1975. imenu-eager-completion-buffer t))
  1976. (use-package eyebrowse
  1977. :ensure t
  1978. :commands (eyebrowse-mode)
  1979. :init (setq eyebrowse-keymap-prefix (kbd "C-c w")))
  1980. (use-package goto-last-change
  1981. :commands goto-last-change)
  1982. ;; * Media
  1983. (use-package emms
  1984. :pin "melpa-stable"
  1985. :commands (emms
  1986. emms-pause
  1987. emms-stop
  1988. emms-next
  1989. emms-previous)
  1990. :bind (:map emms-playlist-mode-map
  1991. ("S s" . emms-shuffle))
  1992. :init (setq emms-source-file-default-directory "~/Documents/media/audio/"
  1993. emms-player-list '(emms-player-mplayer emms-player-mplayer-playlist)
  1994. emms-show-format "NP: %s"
  1995. emms-stream-default-action "play"
  1996. emms-track-description-function 'db/emms-track-description
  1997. emms-playlist-default-major-mode 'emms-playlist-mode
  1998. emms-cache-file (expand-file-name "private/emms/cache" emacs-d)
  1999. emms-history-file (expand-file-name "private/emms/history" emacs-d)
  2000. emms-score-file (expand-file-name "private/emms/scores" emacs-d)
  2001. emms-stream-bookmarks-file (expand-file-name "private/emms/streams" emacs-d))
  2002. :config (progn
  2003. ;; Initialization copied and adapted from `emms-setup’
  2004. (require 'emms-source-file)
  2005. (require 'emms-source-playlist)
  2006. (require 'emms-player-simple)
  2007. (require 'emms-player-mplayer)
  2008. (require 'emms-playlist-mode)
  2009. (require 'emms-info)
  2010. (require 'emms-info-mp3info)
  2011. (require 'emms-info-ogginfo)
  2012. (require 'emms-info-opusinfo)
  2013. (require 'emms-cache)
  2014. (require 'emms-mode-line)
  2015. (require 'emms-mark)
  2016. (require 'emms-tag-editor)
  2017. (require 'emms-show-all)
  2018. (require 'emms-streams)
  2019. (require 'emms-playing-time)
  2020. (require 'emms-player-mpd)
  2021. (require 'emms-playlist-sort)
  2022. (require 'emms-browser)
  2023. (require 'emms-mode-line-icon)
  2024. (require 'emms-cue)
  2025. (require 'emms-bookmarks)
  2026. (require 'emms-last-played)
  2027. (require 'emms-metaplaylist-mode)
  2028. (require 'emms-stream-info)
  2029. (require 'emms-score)
  2030. (require 'emms-history)
  2031. (require 'emms-i18n)
  2032. (require 'emms-volume)
  2033. (require 'emms-playlist-limit)
  2034. (add-to-list 'emms-track-initialize-functions
  2035. 'emms-info-initialize-track)
  2036. (if (require 'emms-info-mediainfo nil 'no-error)
  2037. (setq emms-info-functions '(emms-info-mediainfo))
  2038. (when (executable-find emms-info-mp3info-program-name)
  2039. (add-to-list 'emms-info-functions 'emms-info-mp3info))
  2040. (when (executable-find emms-info-ogginfo-program-name)
  2041. (add-to-list 'emms-info-functions 'emms-info-ogginfo))
  2042. (when (executable-find emms-info-opusinfo-program-name)
  2043. (add-to-list 'emms-info-functions 'emms-info-opusinfo))
  2044. (add-to-list 'emms-info-functions 'emms-info-cueinfo))
  2045. (when (fboundp 'emms-cache) ; work around compiler warning
  2046. (emms-cache 1))
  2047. (emms-mode-line -1)
  2048. (emms-playing-time 1)
  2049. (emms-score 1)
  2050. (add-hook 'emms-player-started-hook 'emms-last-played-update-current)
  2051. (add-hook 'emms-player-started-hook 'emms-show)
  2052. (advice-add 'emms-tag-editor-submit
  2053. :after (lambda (&rest r)
  2054. (ignore r)
  2055. (delete-window)))
  2056. (unless (eq system-type 'windows-nt)
  2057. (setq emms-source-file-directory-tree-function
  2058. #'db/emms-source-file-directory-tree-find))
  2059. ;; `emms-playlist-mode’ sets `emms-playlist-insert-track-function’,
  2060. ;; no matter what previous values or customization may say otherwise
  2061. ;; … so we need to employ a hook to change its value
  2062. (add-hook 'emms-playlist-mode-hook
  2063. (lambda ()
  2064. (setq emms-playlist-insert-track-function
  2065. #'db/emms-playlist-mode-insert-track)))
  2066. (run-with-timer 0 3600 #'emms-cache-save)))
  2067. ;; Make sure emms is up and running when we call functions such as
  2068. ;; `emms-play-dired’ etc.
  2069. (use-package emms-source-file
  2070. :config (require 'emms))
  2071. (use-package db-emms
  2072. :commands (db/emms-source-file-directory-tree-find
  2073. db/emms-track-description
  2074. db/emms-playlist-mode-insert-track))
  2075. (use-package helm-emms
  2076. :commands (helm-emms)
  2077. :init (setq helm-emms-use-track-description-function t
  2078. helm-emms-default-sources '(helm-source-emms-streams
  2079. helm-source-emms-dired
  2080. helm-source-emms-files))
  2081. :config (progn
  2082. (require 'emms)
  2083. (require 'helm-adaptive)))
  2084. (use-package db-music
  2085. :init (setq db/auto-playlist-file-function
  2086. #'(lambda ()
  2087. (db/playlist-files-from-git-annex-find
  2088. "--metadata db-playlist=include")))
  2089. :commands (db/play-auto-playlist
  2090. db/playlist-files-from-git-annex-find
  2091. db/play-auto-playlist-from-git-annex-find
  2092. music-control/body
  2093. db/play-radio-stations
  2094. db/update-playlist-files))
  2095. ;; * Shells and such
  2096. (use-package comint
  2097. :init (setq comint-scroll-to-bottom-on-input t
  2098. comint-scroll-to-bottom-on-output nil
  2099. comint-scroll-show-maximum-output t
  2100. comint-completion-addsuffix t
  2101. comint-buffer-maximum-size 100000
  2102. comint-input-ring-size 5000)
  2103. :config (progn
  2104. ;; Never let bash know that we are inside Emacs;
  2105. ;; cf. https://coredumped.dev/2020/01/04/native-shell-completion-in-emacs/
  2106. (advice-add 'comint-term-environment
  2107. :filter-return #'(lambda (env) (cons "INSIDE_EMACS" env)))))
  2108. (use-package term
  2109. :commands (term-send-string)
  2110. :init (setq explicit-shell-file-name "/bin/bash")
  2111. :config (progn
  2112. (add-hook 'term-exec-hook ; oremacs.com
  2113. (lambda ()
  2114. (let* ((buff (current-buffer))
  2115. (proc (get-buffer-process buff)))
  2116. (set-process-sentinel
  2117. proc
  2118. `(lambda (process event)
  2119. (if (string= event "finished\n")
  2120. (kill-buffer ,buff)))))))
  2121. ;; does not work; C-c is shadowed by some minor modes like semantic,
  2122. ;; projectile, and winner
  2123. (bind-key "C-c" #'term-send-raw term-raw-map)
  2124. ;; unbind some keys to allow the global keymap to handle them
  2125. (unbind-key "M-:" term-raw-map)
  2126. (unbind-key "C-h" term-raw-map)
  2127. (unbind-key "M-x" term-raw-map)
  2128. (unbind-key "M-o" term-raw-map)
  2129. ;; we need to set keys starting with C-x after `ansi-term' has been
  2130. ;; called, as it resets the escape character to C-x.
  2131. (defadvice ansi-term (after ansi-term-set-keys activate)
  2132. (unbind-key "C-x C-j" term-raw-map)
  2133. (unbind-key "C-x g" term-raw-map))
  2134. (add-hook 'term-mode-hook (lambda () (yas-minor-mode -1)))))
  2135. (use-package ansi-color
  2136. :commands (ansi-color-for-comint-mode-on
  2137. ansi-color-apply-on-region)
  2138. :config (progn
  2139. (add-hook 'compilation-filter-hook 'endless/colorize-compilation)))
  2140. (use-package shell
  2141. :commands (shell)
  2142. :bind (:map shell-mode-map
  2143. ("C-r" . counsel-shell-history))
  2144. :config (progn
  2145. (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
  2146. (add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m)
  2147. (add-hook 'shell-mode-hook 'with-editor-export-editor)
  2148. ;; We may want to use readline support in bash, don't inhibit this
  2149. ;; with explicit command line arguments;
  2150. ;; cf. https://coredumped.dev/2020/01/04/native-shell-completion-in-emacs/
  2151. (setq explicit-bash-args
  2152. (delete "--noediting" explicit-bash-args))))
  2153. (use-package db-eshell
  2154. :commands (db/run-or-hide-eshell
  2155. eshell-clear-buffer
  2156. eshell/default-prompt-function
  2157. eshell/gst
  2158. eshell-insert-history
  2159. pcomplete/git))
  2160. (use-package eshell
  2161. :commands (eshell)
  2162. :init (setq eshell-cmpl-cycle-completions nil
  2163. eshell-scroll-to-bottom-on-input t
  2164. eshell-prefer-lisp-functions nil
  2165. eshell-error-if-no-glob t
  2166. eshell-hist-ignoredups t
  2167. eshell-save-history-on-exit t
  2168. eshell-history-size 5000
  2169. eshell-destroy-buffer-when-process-dies t
  2170. eshell-prompt-function #'eshell/default-prompt-function
  2171. eshell-prompt-regexp "└─[$#] "
  2172. eshell-highlight-prompt nil
  2173. eshell-cd-on-directory t
  2174. eshell-expand-input-functions '(eshell-expand-history-references))
  2175. :config (progn (require 'em-prompt)
  2176. (require 'em-term)
  2177. (require 'em-cmpl)
  2178. (setenv "PAGER" "cat")
  2179. (add-to-list 'eshell-command-completions-alist
  2180. '("gunzip" "gz\\'"))
  2181. (add-to-list 'eshell-command-completions-alist
  2182. '("tar" "\\(\\.tar|\\.tgz\\|\\.tar\\.gz\\)\\'"))
  2183. (add-hook 'eshell-mode-hook
  2184. 'with-editor-export-editor)
  2185. (add-hook 'eshell-mode-hook
  2186. (lambda ()
  2187. (bind-key "C-a" #'eshell-bol eshell-mode-map)
  2188. (bind-key "M-r" #'eshell-insert-history eshell-mode-map)
  2189. (bind-key "M-P" #'eshell-previous-prompt eshell-mode-map)
  2190. (bind-key "M-N" #'eshell-next-prompt eshell-mode-map)))
  2191. ;; Ignoring case when completing file names seems to have a
  2192. ;; bug: when a ~ is encountered, it is implicitly expaned by
  2193. ;; `pcomplete-insert-entry’, overwriting the prompt as a side
  2194. ;; effect. Keeping the case as it is does not seem to have
  2195. ;; this issue. This problem occurs by default only on Windows
  2196. ;; systems (in all flavors), because this is the only time
  2197. ;; `pcomplete-ignore-case’ is non-nil by default.
  2198. (when on-windows
  2199. (add-to-list 'eshell-mode-hook
  2200. (lambda ()
  2201. (setq pcomplete-ignore-case nil))))
  2202. ;; Sometimes, when completing path names and immediately
  2203. ;; hitting RET, `completion-in-region-mode' still seems to be
  2204. ;; active; this often happens when calling cd. Then,
  2205. ;; `post-command-hook' still contains
  2206. ;; `completion-in-region--postch', which calls some `pcomplete'
  2207. ;; function to determine whether completion mode should exit.
  2208. ;; However, after RET (i.e., `eshell-send-input'), we only have
  2209. ;; an empty prompt, and `pcomplete' just computes all possible
  2210. ;; functions for completion (doesn't show it, though). This
  2211. ;; introduces a noticeable amount of delay, which is annoying.
  2212. ;; Expliticly disabling `completion-in-region-mode' before
  2213. ;; sending input seems to alleviate the problem.
  2214. (advice-add 'eshell-send-input
  2215. :before #'(lambda (&rest _)
  2216. "Disable completion-in-region-mode before sending input."
  2217. (when completion-in-region-mode
  2218. (completion-in-region-mode -1))))
  2219. (require 'db-eshell)))
  2220. (use-package with-editor
  2221. :commands (with-editor-export-editor))
  2222. ;; * Lisp
  2223. ;; General Stuff first
  2224. (use-package lisp-mode
  2225. :init (setq lisp-indent-function #'lisp-indent-function))
  2226. (use-package lispy
  2227. :ensure t
  2228. :commands (lispy-mode)
  2229. :diminish lispy-mode)
  2230. (use-package eldoc
  2231. :commands (global-eldoc-mode
  2232. turn-on-eldoc-mode)
  2233. :diminish eldoc-mode)
  2234. ;; Lisp Dialects
  2235. (use-package elisp-mode
  2236. :config (progn
  2237. (add-hook 'emacs-lisp-mode-hook 'turn-on-lispy-when-available)
  2238. (add-hook 'emacs-lisp-mode-hook 'turn-on-flycheck-when-file)))
  2239. (use-package geiser
  2240. :commands (geiser-mode))
  2241. (use-package cider
  2242. :commands (cider-jack-in)
  2243. :init (setq nrepl-hide-special-buffers t
  2244. cider-auto-select-error-buffer t
  2245. cider-stacktrace-default-filters '(tooling dup)
  2246. cider-stacktrace-fill-column 80
  2247. cider-save-file-on-load nil
  2248. cider-repl-result-prefix ";; => "
  2249. cider-repl-use-clojure-font-lock t
  2250. cider-repl-wrap-history t
  2251. cider-repl-history-size 1000
  2252. ;;cider-lein-parameters "trampoline repl :headless"
  2253. cider-lein-parameters "repl :headless"
  2254. cider-repl-history-file (expand-file-name ".cider-history" emacs-d)
  2255. cider-repl-display-help-banner nil)
  2256. :config (progn
  2257. (add-hook 'cider-repl-mode-hook 'subword-mode)
  2258. (add-hook 'cider-repl-mode-hook 'turn-on-lispy-when-available)
  2259. (add-hook 'cider-repl-mode-hook 'cider-repl-toggle-pretty-printing)
  2260. (add-hook 'cider-repl-mode-hook 'company-mode)))
  2261. (use-package clojure-mode
  2262. :config (progn
  2263. (define-clojure-indent
  2264. (forall 'defun)
  2265. (exists 'defun)
  2266. (dopar 'defun))
  2267. (add-hook 'clojure-mode-hook 'turn-on-lispy-when-available)
  2268. (add-hook 'clojure-mode-hook 'clj-refactor-mode)
  2269. (add-hook 'clojure-mode-hook 'company-mode)))
  2270. (use-package clj-refactor
  2271. :commands (clj-refactor-mode)
  2272. :config (progn
  2273. (cljr-add-keybindings-with-prefix "C-c C-m")
  2274. (setq cljr-eagerly-build-asts-on-startup nil
  2275. cljr-warn-on-eval nil)))
  2276. (use-package slime
  2277. :commands (slime slime-mode slime-connect)
  2278. :init (progn
  2279. (setq inferior-lisp-program "sbcl --noinform --no-linedit"
  2280. slime-compile-file-options '(:fasl-directory "/tmp/slime-fasls/")
  2281. slime-net-coding-system 'utf-8-unix
  2282. slime-completion-at-point-functions 'slime-fuzzy-complete-symbol
  2283. slime-lisp-implementations '((sbcl ("sbcl") :coding-system utf-8-unix)
  2284. (cmucl ("cmucl") :coding-system utf-8-unix)
  2285. (ccl ("ccl") :coding-system utf-8-unix))
  2286. slime-repl-history-remove-duplicates t
  2287. slime-repl-history-trim-whitespaces t)
  2288. (add-hook 'lisp-mode-hook '(lambda () (slime-mode +1)) t))
  2289. :config (progn
  2290. (make-directory "/tmp/slime-fasls/" t)
  2291. (slime-setup '(slime-repl slime-fancy slime-autodoc))
  2292. (add-hook 'slime-mode-hook 'slime-redirect-inferior-output)))
  2293. (use-package hy-mode
  2294. :commands (hy-mode)
  2295. :config (progn
  2296. (add-hook 'hy-mode-hook 'turn-on-lispy-when-available)
  2297. (add-hook 'hy-mode-hook 'inferior-lisp)))
  2298. ;; * TeX
  2299. (use-package reftex
  2300. :commands (turn-on-reftex)
  2301. :init (setq reftex-plug-into-AUCTeX t)
  2302. :config (with-eval-after-load 'helm-mode
  2303. (add-to-list 'helm-completing-read-handlers-alist
  2304. '(reftex-citation . nil))))
  2305. (use-package tex
  2306. :init (setq TeX-auto-save t
  2307. TeX-save-query nil
  2308. TeX-parse-self t
  2309. TeX-master t
  2310. TeX-electric-sub-and-superscript t
  2311. TeX-electric-math '("$" . "$")
  2312. TeX-electric-escape nil
  2313. LaTeX-electric-left-right-brace t
  2314. LaTeX-fill-break-at-separators nil
  2315. TeX-fold-math-spec-list '(("≤" ("le"))
  2316. ("≥" ("ge"))
  2317. ("∉" ("notin")))
  2318. TeX-source-correlate-start-server nil
  2319. LaTeX-eqnarray-label "eqn:"
  2320. LaTeX-equation-label "eqn:"
  2321. LaTeX-figure-label "fig:"
  2322. LaTeX-table-label "tab:"
  2323. TeX-newline-function 'reindent-then-newline-and-indent
  2324. LaTeX-section-hook '(LaTeX-section-heading
  2325. LaTeX-section-title
  2326. LaTeX-section-section
  2327. LaTeX-section-label))
  2328. :config (progn
  2329. (require 'latex)
  2330. (require 'tex-buf)
  2331. (require 'reftex)
  2332. (TeX-engine-set 'default)
  2333. (put 'TeX-narrow-to-group 'disabled nil)
  2334. (put 'LaTeX-narrow-to-environment 'disabled nil)
  2335. (add-hook 'LaTeX-mode-hook #'turn-on-flyspell)
  2336. (add-hook 'LaTeX-mode-hook #'turn-on-visual-line-mode)
  2337. (add-hook 'LaTeX-mode-hook #'LaTeX-math-mode)
  2338. (add-hook 'LaTeX-mode-hook #'outline-minor-mode)
  2339. (add-hook 'LaTeX-mode-hook #'page-break-lines-mode)
  2340. (add-hook 'LaTeX-mode-hook #'turn-on-reftex)
  2341. (add-hook 'latex-mode-hook #'turn-on-reftex)
  2342. (add-hook 'LaTeX-mode-hook '(lambda ()
  2343. (TeX-PDF-mode 1)
  2344. (TeX-source-correlate-mode 1)
  2345. (TeX-fold-mode 1)))
  2346. (add-to-list 'TeX-view-program-selection
  2347. '(output-pdf "Evince"))
  2348. ;; use pdf-tools when loaded
  2349. (with-eval-after-load 'pdf-tools
  2350. (add-to-list 'TeX-view-program-selection '(output-pdf "PDF Tools"))
  2351. (add-to-list 'TeX-after-compilation-finished-functions
  2352. #'TeX-revert-document-buffer))
  2353. ;; style used for my personal definitions; not clear whether this
  2354. ;; works as intended
  2355. (TeX-add-style-hook
  2356. "mydefs"
  2357. (lambda ()
  2358. (TeX-run-style-hooks "etex"
  2359. "etoolbox"
  2360. "ifthen"
  2361. "amsmath"
  2362. "amssymb"
  2363. "latexsym"
  2364. "mathabx"
  2365. "stmaryrd"
  2366. "verbatim"
  2367. "graphicx"
  2368. "enumerate"
  2369. "array"
  2370. "booktabs"
  2371. "ulem"
  2372. "nicefrac"
  2373. "listings"
  2374. "microtype"
  2375. "tabularx"
  2376. "tikz"
  2377. "csquotes"
  2378. "ntheorem"
  2379. "xspace")
  2380. (LaTeX-add-environments
  2381. '("Exercise" LaTeX-env-label)
  2382. '("Theorem" LaTeX-env-label)
  2383. '("Proposition" LaTeX-env-label)
  2384. '("Lemma" LaTeX-env-label)
  2385. '("Corollary" LaTeX-env-label)
  2386. '("Remark" LaTeX-env-label)
  2387. '("Example" LaTeX-env-label)
  2388. '("Definition" LaTeX-env-label)
  2389. '("Proof" LaTeX-env-label))
  2390. ;; https://tex.stackexchange.com/questions/217799/auctex-11-88-bug-on-latex-env-label-cannot-automatically-insert-label
  2391. (setf (cadr reftex-insert-label-flags)
  2392. (concat (cadr reftex-insert-label-flags) "TLPDRCE"))
  2393. (dolist (label-spec
  2394. '(("Theorem" ?T "thm:" "~\\ref{%s}" t ("Theorem" "Thm.") nil)
  2395. ("Lemma" ?L "lem:" "~\\ref{%s}" t ("Lemma" "Lem.") nil)
  2396. ("Proposition" ?P "prop:" "~\\ref{%s}" t ("Proposition" "Prop.") nil)
  2397. ("Satz" ?T "thm:" "~\\ref{%s}" t ("Satz") nil)
  2398. ("Definition" ?D "def:" "~\\ref{%s}" t ("Definition" "Def.") nil)
  2399. ("Remark" ?R "rem:" "~\\ref{%s}" t ("Remark" "Rem.") nil)
  2400. ("Corollary" ?C "cor:" "~\\ref{%s}" t ("Corollary" "Cor.") nil)
  2401. ("Example" ?E "expl:" "~\\ref{%s}" t ("Example") nil)))
  2402. (add-to-list 'reftex-label-alist label-spec)
  2403. (add-to-list 'LaTeX-label-alist (cons (nth 0 label-spec)
  2404. (nth 2 label-spec))))))
  2405. ;; Add completion for cleverref’s reference macros; not clear
  2406. ;; whether this works as intended
  2407. (TeX-add-style-hook
  2408. "cleveref"
  2409. (lambda ()
  2410. (add-to-list 'reftex-ref-style-alist
  2411. '("Cleveref" "cleveref"
  2412. (("\\cref" ?c) ("\\Cref" ?C)
  2413. ("\\cpageref" ?d) ("\\Cpageref" ?D))))
  2414. (reftex-ref-style-activate "Cleveref")
  2415. (TeX-add-symbols
  2416. '("cref" TeX-arg-ref)
  2417. '("Cref" TeX-arg-ref)
  2418. '("cpageref" TeX-arg-ref)
  2419. '("Cpageref" TeX-arg-ref))))
  2420. ;; Language definitions
  2421. (add-hook 'TeX-language-de-hook
  2422. (lambda () (ispell-change-dictionary "de_DE")))
  2423. (add-hook 'TeX-language-en-hook
  2424. (lambda () (ispell-change-dictionary "en_US")))
  2425. (add-hook 'TeX-mode-hook
  2426. (lambda () (setq ispell-parser 'tex)))))
  2427. (use-package helm-bibtex
  2428. :commands (helm-bibtex))
  2429. ;; * Various Mode Configurations
  2430. ;; These are packages that are not essential, but still nice to have. They
  2431. ;; provide optional functionality and may redefine builtin commands.
  2432. (use-package cperl-mode
  2433. :ensure t
  2434. :commands (cperl-mode)
  2435. :init (progn
  2436. ;; replace perl-mode with cperl-mode
  2437. (mapc
  2438. (lambda (pair)
  2439. (if (eq (cdr pair) 'perl-mode)
  2440. (setcdr pair 'cperl-mode)))
  2441. (append auto-mode-alist interpreter-mode-alist))
  2442. (setq cperl-hairy nil
  2443. cperl-invalid-face 'default
  2444. cperl-electric-keywords nil
  2445. cperl-lazy-help-time 2
  2446. cperl-highlight-variables-indiscriminately t))
  2447. :config (progn
  2448. (add-hook 'cperl-mode-hook 'flycheck-mode)
  2449. (add-hook 'cperl-mode-hook 'prettify-symbols-mode)
  2450. ;; enable display of help messages after a short period of time, as
  2451. ;; controlled by the value of `cperl-lazy-help-time'
  2452. (add-hook 'cperl-mode-hook 'cperl-lazy-install)))
  2453. (use-package db-projects
  2454. :commands (projects-add-project
  2455. projects-archive-project
  2456. projects-lint-projects))
  2457. (use-package define-word
  2458. :ensure t
  2459. :commands (define-word-at-point define-word))
  2460. (use-package dictcc
  2461. :ensure t
  2462. :commands (dictcc)
  2463. :config (require 'gnutls))
  2464. (use-package edit-list
  2465. :ensure t
  2466. :commands edit-list)
  2467. (use-package expand-region
  2468. :ensure t
  2469. :commands (er/expand-region))
  2470. (use-package eproject
  2471. ;; This configuration is only present to inhibit eproject overriding
  2472. ;; keybindings in `message-mode'
  2473. :config (progn
  2474. (message "Loaded eproject … done")
  2475. (with-eval-after-load 'message
  2476. (add-hook 'message-setup-hook
  2477. (lambda ()
  2478. (eproject-mode -1))))))
  2479. (use-package eww
  2480. :init (setq eww-bookmarks-directory
  2481. (expand-file-name "private/" emacs-d)))
  2482. (use-package haskell-mode
  2483. :config (progn
  2484. (add-hook 'haskell-mode-hook 'haskell-doc-mode)
  2485. (add-hook 'haskell-mode-hook 'turn-on-haskell-indent)
  2486. (add-hook 'haskell-mode-hook
  2487. (lambda ()
  2488. (company-mode +1)
  2489. (set (make-local-variable 'company-backends)
  2490. (append '((company-capf company-dabbrev-code))
  2491. company-backends))))
  2492. (add-hook 'haskell-mode-hook 'flycheck-mode)
  2493. (with-demoted-errors "Non-Fatal Error: %s"
  2494. (require 'haskell-indentation)
  2495. (add-hook 'haskell-mode-hook
  2496. 'haskell-indentation-mode))
  2497. (add-hook 'haskell-mode-hook
  2498. 'interactive-haskell-mode)))
  2499. (use-package markdown-mode
  2500. :ensure t
  2501. :commands (markdown-mode)
  2502. :init (progn
  2503. (setq markdown-use-pandoc-style-yaml-metadata t
  2504. markdown-command "pandoc --standalone")
  2505. (fset 'markdown-output-standalone-p #'(lambda () t))))
  2506. (use-package pdf-occur
  2507. :commands (pdf-occur-global-minor-mode))
  2508. (use-package pdf-tools
  2509. :commands (pdf-tools-install))
  2510. (use-package python
  2511. :config (progn
  2512. (add-hook 'python-mode-hook #'highlight-indentation-mode)
  2513. (add-hook 'python-mode-hook #'company-mode)
  2514. (add-hook 'python-mode-hook #'eglot-ensure)))
  2515. (use-package shr
  2516. :init (setq shr-use-fonts nil
  2517. shr-use-colors nil
  2518. shr-max-image-proportion 0.7
  2519. shr-image-animate nil
  2520. shr-width (current-fill-column)))
  2521. ;; Interactive interface to sdcv, the StarDict concole version. To use sdcv,
  2522. ;; put the dictionary data under ~/.stardict/dic.
  2523. (use-package sdcv
  2524. :commands (sdcv-search-pointer
  2525. sdcv-search-input))
  2526. (use-package sh-script
  2527. :init (setq sh-basic-offset 2))
  2528. (use-package timeline-tools
  2529. :load-path "site-lisp"
  2530. :commands (timeline-tools-format-timeline
  2531. timeline-tools-format-timeline-of-day
  2532. timeline-tools-copy-clocklines
  2533. timeline-tools-clockline-no-org-agenda-conflicts))
  2534. (use-package typing
  2535. :commands (typing-of-emacs)
  2536. :init (setq toe-highscore-file nil))
  2537. (use-package vlf
  2538. :ensure t
  2539. :commands (vlf))
  2540. (use-package which-key
  2541. :ensure t
  2542. :commands (which-key-mode)
  2543. :diminish which-key-mode
  2544. :init (setq which-key-side-window-max-width 0.33
  2545. which-key-side-window-max-height 0.25)
  2546. :config (which-key-setup-side-window-bottom))
  2547. ;; * Load customizations
  2548. (when (file-exists-p custom-file)
  2549. (load-file custom-file))
  2550. ;;; init.el ends here