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

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