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 119KB

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