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

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