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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999
  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. ;; * Mail
  1255. (use-package db-mail
  1256. :commands (db/smtpmail-send-it
  1257. db/public-key
  1258. db/encryption-possible-p
  1259. db/message-recipients
  1260. db/signencrypt-message-when-possible
  1261. db/gnus-save-newsrc-with-whitespace-1
  1262. db/gnus-summary-open-Link
  1263. db/gnus-html-mime-part-to-org
  1264. db/gnus-demon-scan-news-on-level-2))
  1265. (use-package bbdb
  1266. :commands (bbdb-search-name
  1267. bbdb-initialize
  1268. bbdb-mua-auto-update-init
  1269. bbdb-save)
  1270. :init (setq bbdb-completion-display-record nil
  1271. bbdb-complete-mail-allow-cycling t
  1272. bbdb-mua-auto-update-p 'query
  1273. bbdb-default-country "Germany")
  1274. :config (progn
  1275. (add-hook 'message-setup-hook 'bbdb-mail-aliases)
  1276. (add-hook 'mail-setup-hook 'bbdb-mail-aliases)
  1277. (run-with-timer 0 3600 #'bbdb-save)))
  1278. ;; General Gnus configuration
  1279. (setq gnus-init-file (expand-file-name "gnus.el" emacs-d)
  1280. gnus-home-directory (expand-file-name "~/Mail/news/")
  1281. gnus-directory (expand-file-name "~/Mail/news/")
  1282. gnus-kill-files-directory gnus-directory
  1283. gnus-startup-file (expand-file-name "~/Mail/gnus-newsrc")
  1284. gnus-cache-directory (expand-file-name "cache/" gnus-directory)
  1285. gnus-verbose 10
  1286. message-directory (expand-file-name "mail/" gnus-directory)
  1287. nnmail-message-id-cache-file (expand-file-name ".nnmail-cache" gnus-directory)
  1288. nnml-directory message-directory
  1289. mail-sources '((file))
  1290. mail-source-delete-incoming t
  1291. nntp-nov-is-evil t
  1292. nntp-connection-timeout nil
  1293. gnus-asynchronous t
  1294. gnus-save-killed-list nil
  1295. gnus-save-newsrc-file nil
  1296. gnus-read-newsrc-file nil
  1297. gnus-check-new-newsgroups nil
  1298. gnus-use-cache 'passive
  1299. gnus-read-active-file 'some
  1300. gnus-build-sparse-threads 'some
  1301. gnus-subscribe-newsgroup-method 'gnus-subscribe-killed
  1302. gnus-group-list-inactive-groups t
  1303. gnus-suppress-duplicates nil
  1304. gnus-large-newsgroup 200
  1305. nnmail-expiry-wait 7
  1306. nnmail-cache-accepted-message-ids t
  1307. gnus-summary-next-group-on-exit nil
  1308. gnus-use-full-window nil
  1309. gnus-always-force-window-configuration t
  1310. gnus-fetch-old-headers nil
  1311. gnus-select-method '(nnnil "")
  1312. gnus-refer-article-method 'current
  1313. gnus-visible-headers (regexp-opt '("From:"
  1314. "Newsgroups:"
  1315. "Subject:"
  1316. "Date:"
  1317. "Followup-To:"
  1318. "Reply-To:"
  1319. "Organization:"
  1320. "Summary:"
  1321. "Keywords:"
  1322. "Mail-Copies-To:"
  1323. "To:"
  1324. "Cc:"
  1325. "BCC:"
  1326. "X-Newsreader:"
  1327. "X-Mailer:"
  1328. "X-Sent:"
  1329. "Posted-To:"
  1330. "Mail-Copies-To:"
  1331. "Apparently-To:"
  1332. "Gnus-Warning:"
  1333. "Resent-From:"
  1334. "gpg-key-ID:"
  1335. "fingerprint:"
  1336. "X-Jabber-ID:"
  1337. "User-Agent:"))
  1338. message-citation-line-function
  1339. (lambda ()
  1340. (when message-reply-headers
  1341. (insert "ghItlhpu' "
  1342. (mail-header-from message-reply-headers)
  1343. ":")
  1344. (newline))))
  1345. ;; Gnus Appearence
  1346. (setq gnus-group-line-format "%S%p%P%5y(%2i):%B%(%s:%G%)\n"
  1347. gnus-auto-select-first nil
  1348. gnus-auto-select-next nil
  1349. gnus-summary-line-format "%U%O%R%6k %(%&user-date; %-13,13f %B%s%)\n"
  1350. gnus-thread-sort-functions '(gnus-thread-sort-by-most-recent-date)
  1351. gnus-subthread-sort-functions '(gnus-thread-sort-by-date)
  1352. gnus-thread-hide-subtree t
  1353. gnus-user-date-format-alist '((t . "%Y-%m-%d %H:%M"))
  1354. gnus-sum-thread-tree-indent " "
  1355. gnus-sum-thread-tree-root "● "
  1356. gnus-sum-thread-tree-false-root "◎ "
  1357. gnus-sum-thread-tree-single-indent "◯ "
  1358. gnus-sum-thread-tree-single-leaf "╰► "
  1359. gnus-sum-thread-tree-leaf-with-other "├► "
  1360. gnus-sum-thread-tree-vertical "│"
  1361. gnus-summary-thread-gathering-function 'gnus-gather-threads-by-references
  1362. ;; New mark symbols (seen here:
  1363. ;; `https://github.com/cofi/dotfiles/blob/master/gnus.el')
  1364. gnus-ancient-mark ?✓
  1365. ;; gnus-cached-mark ?☍
  1366. gnus-canceled-mark ?↗
  1367. gnus-del-mark ?✗
  1368. ;; gnus-dormant-mark ?⚐
  1369. gnus-expirable-mark ?♻
  1370. gnus-forwarded-mark ?↪
  1371. ;; gnus-killed-mark ?☠
  1372. ;; gnus-process-mark ?⚙
  1373. gnus-read-mark ?✓
  1374. gnus-recent-mark ?✩
  1375. gnus-replied-mark ?↺
  1376. gnus-unread-mark ?✉
  1377. ;; gnus-unseen-mark ?★
  1378. ;; gnus-ticked-mark ?⚑
  1379. gnus-treat-hide-boring-headers 'head
  1380. gnus-treat-strip-multiple-blank-lines nil
  1381. gnus-treat-display-smileys t
  1382. gnus-treat-emphasize 'head
  1383. gnus-treat-unsplit-urls t)
  1384. (use-package gnus-art
  1385. :init (setq gnus-ignored-mime-types '("text/x-vcard")
  1386. gnus-inhibit-mime-unbuttonizing nil
  1387. gnus-buttonized-mime-types '("multipart/signed" "multipart/encrypted")
  1388. gnus-inhibit-images t
  1389. gnus-blocked-images ".*"))
  1390. ;; Adaptive Scoring
  1391. (setq gnus-use-scoring t
  1392. gnus-use-adaptive-scoring '(word line)
  1393. gnus-summary-mark-below nil
  1394. gnus-adaptive-word-length-limit 5
  1395. gnus-adaptive-word-no-group-words t
  1396. gnus-default-adaptive-score-alist
  1397. '((gnus-unread-mark)
  1398. (gnus-ticked-mark (from 4))
  1399. (gnus-dormant-mark (from 5))
  1400. (gnus-del-mark (from -4) (subject -1))
  1401. (gnus-read-mark (from 4) (subject 2))
  1402. (gnus-expirable-mark (from -1) (subject -1))
  1403. (gnus-killed-mark (from -1) (subject -3))
  1404. (gnus-kill-file-mark)
  1405. (gnus-ancient-mark)
  1406. (gnus-low-score-mark)
  1407. (gnus-catchup-mark (from -1) (subject -1)))
  1408. gnus-summary-mark-below nil)
  1409. ;; Gnus Registry
  1410. (use-package gnus-registry
  1411. :commands (gnus-registry-split-fancy-with-parent
  1412. gnus-registry-initialize)
  1413. :init (setq gnus-registry-split-strategy 'majority
  1414. gnus-registry-ignored-groups '(("^nntp" t)
  1415. ("^nnfolder" t)
  1416. ("^nnir" t)
  1417. ("^nnmaildir" t)
  1418. ("INBOX$" t))
  1419. gnus-registry-max-entries 40000
  1420. gnus-registry-track-extra '(sender subject recipient)
  1421. gnus-registry-cache-file (expand-file-name "gnus.registry.eioioi"
  1422. emacs-d)))
  1423. ;; MIME decoding
  1424. (use-package mm-decode
  1425. :init (setq mm-text-html-renderer 'shr
  1426. mm-discouraged-alternatives '("text/richtext")
  1427. mm-decrypt-option 'known
  1428. mm-verify-option 'known)
  1429. :config (progn
  1430. (setq mm-automatic-display (-difference mm-automatic-display
  1431. '("text/enriched"
  1432. "text/richtext")))
  1433. ;; Automatically show PGP data inline
  1434. (add-to-list 'mm-inlined-types "application/pgp$")
  1435. (add-to-list 'mm-inline-media-tests
  1436. '("application/pgp$" mm-inline-text identity))
  1437. (add-to-list 'mm-automatic-display "application/pgp$")
  1438. ;; When copying MIME buffers, we are looking for the start of the
  1439. ;; header by searching ^\n; however, if we received mail from
  1440. ;; Outlook, there's an ^\r\n seperating header and body, which is
  1441. ;; not found by `mm-copy-to-buffer', leaving the target buffer empty
  1442. ;; and the mail as well. Redefining `mm-copy-to-buffer' to also
  1443. ;; search for ^\r\n might help.
  1444. (defun mm-copy-to-buffer ()
  1445. "Copy the contents of the current buffer to a fresh buffer."
  1446. (let ((obuf (current-buffer))
  1447. (mb enable-multibyte-characters)
  1448. beg)
  1449. (goto-char (point-min))
  1450. ;; The following regex has been extended by \r? .
  1451. (search-forward-regexp "^\r?\n" nil 'move) ;; There might be no body.
  1452. (setq beg (point))
  1453. (with-current-buffer
  1454. (generate-new-buffer " *mm*")
  1455. ;; Preserve the data's unibyteness (for url-insert-file-contents).
  1456. (set-buffer-multibyte mb)
  1457. (insert-buffer-substring obuf beg)
  1458. (current-buffer))))))
  1459. (setq message-forward-as-mime nil)
  1460. ;; MIME creation; signing, and encryption
  1461. (use-package mml
  1462. :config (progn
  1463. ;; Move to end of message buffer before attaching a file
  1464. ;; http://mbork.pl/2015-11-28_Fixing_mml-attach-file_using_advice
  1465. (defun db/mml-attach-file--go-to-eob (orig-fun &rest args)
  1466. "Go to the end of buffer before attaching files."
  1467. (save-excursion
  1468. (save-restriction
  1469. (widen)
  1470. (goto-char (point-max))
  1471. (apply orig-fun args))))
  1472. (advice-add 'mml-attach-file
  1473. :around #'db/mml-attach-file--go-to-eob)))
  1474. (use-package mm-encode
  1475. :init (setq mm-encrypt-option nil
  1476. mm-sign-option nil))
  1477. (setq mml-secure-openpgp-encrypt-to-self t
  1478. mml-secure-smime-encrypt-to-self t
  1479. mml2015-display-key-image nil
  1480. gnus-message-replysign t
  1481. gnus-message-replyencrypt t
  1482. gnus-message-replysignencrypted t
  1483. mml-secure-cache-passphrase nil
  1484. mml-secure-openpgp-sign-with-sender t
  1485. mml-secure-smime-sign-with-sender t)
  1486. (use-package mml-smime
  1487. :init (setq mml-smime-use 'epg)
  1488. :config (progn
  1489. ;; Outlook seems to expect \r\n in PKCS#7 encrypted containers, but
  1490. ;; Gnus is only sending \n; so let's artificially replace \n by \r\n
  1491. ;; before, well, signing? Seems to work at least in the case where
  1492. ;; we are sending S/MIME encrypted and signed messages.
  1493. (advice-add 'mml-smime-epg-sign
  1494. :after #'db/convert-lf-to-crlf-in-buffer) ))
  1495. ;; Archiving
  1496. ;; We store messages in the current group, so there is
  1497. ;; no need to use Gnus’ archiving method
  1498. (setq gnus-message-archive-method nil
  1499. gnus-update-message-archive-method t
  1500. gnus-message-archive-group nil
  1501. gnus-gcc-mark-as-read t)
  1502. ;; Searching
  1503. (setq nnir-method-default-engines '((nnimap . imap)
  1504. (nnmaildir . notmuch)
  1505. (nntp . gmane)))
  1506. ;; Agents
  1507. (setq gnus-agent-mark-unread-after-downloaded nil
  1508. gnus-agent-synchronize-flags t
  1509. gnus-agent-go-online t)
  1510. ;; Package configuration
  1511. (use-package gnus
  1512. :commands (gnus)
  1513. :config (progn
  1514. (require 'db-mail)
  1515. (with-demoted-errors "Setting up BBDB failed: %s"
  1516. (bbdb-initialize 'gnus 'message)
  1517. (bbdb-mua-auto-update-init 'message))
  1518. ;; Ensure that whenever we compose new mail, it will use the correct
  1519. ;; posting style. This is ensured by setting ARG of
  1520. ;; `gnus-group-mail’ to 1 to let it query the user for a group.
  1521. (defadvice gnus-group-mail (before inhibit-no-argument activate)
  1522. (unless (ad-get-arg 0)
  1523. (ad-set-arg 0 1)))
  1524. (remove-hook 'gnus-mark-article-hook
  1525. 'gnus-summary-mark-read-and-unread-as-read)
  1526. (add-hook 'gnus-mark-article-hook 'gnus-summary-mark-unread-as-read)
  1527. ;; Quit Gnus gracefully when exiting Emacs
  1528. (add-hook 'kill-emacs-hook #'(lambda ()
  1529. (interactive)
  1530. (when (get-buffer "*Group*")
  1531. (gnus-group-exit))))
  1532. ;; Don’t quit summary buffer when pressing `q’
  1533. (bind-key "q" #'gnus-summary-expand-window gnus-article-mode-map)
  1534. ;; Show topics in group buffer
  1535. (add-hook 'gnus-group-mode-hook 'gnus-topic-mode)
  1536. ;; We need to do some magic as otherwise the agent does not delete
  1537. ;; articles from its .overview when we move them around. Thus we
  1538. ;; mark articles as expireable when they have been moved to another
  1539. ;; group.
  1540. (defadvice gnus-summary-move-article (around
  1541. no-cancel-mark
  1542. (&optional n to-newsgroup
  1543. select-method action)
  1544. activate)
  1545. (let ((articles (gnus-summary-work-articles n))
  1546. (return ad-do-it))
  1547. (when (or (null action)
  1548. (eq action 'move))
  1549. (dolist (article articles)
  1550. (gnus-summary-mark-article article gnus-expirable-mark)))
  1551. return))
  1552. ;; Increase score of group after reading it
  1553. (add-hook 'gnus-summary-exit-hook
  1554. 'gnus-summary-bubble-group)
  1555. ;; Use Gnus’ registry; doing this too early conflicts with `gnus'
  1556. ;; calling `gnus-shutdown', which in turn calls
  1557. ;; `gnus-registry-clear', leaving us with an empty registry upon
  1558. ;; startup. So let's call this initialization right after startup,
  1559. ;; that should be fine.
  1560. (add-hook 'gnus-started-hook
  1561. #'gnus-registry-initialize)
  1562. ;; Automatic encryption if all necessary keys are present
  1563. (add-hook 'gnus-message-setup-hook
  1564. #'db/signencrypt-message-when-possible)
  1565. ;; Do some pretty printing before saving the newsrc file
  1566. (add-hook 'gnus-save-quick-newsrc-hook
  1567. #'db/gnus-save-newsrc-with-whitespace-1)
  1568. ;; Automatically scan for new news
  1569. (gnus-demon-add-handler 'db/gnus-demon-scan-news-on-level-2 5 5)
  1570. (add-hook 'gnus-started-hook #'gnus-demon-init)
  1571. ;; Visit group under point and immediately close it; this updates
  1572. ;; gnus’ registry as a side-effect
  1573. (bind-key "v u"
  1574. '(lambda ()
  1575. (interactive)
  1576. (save-mark-and-excursion
  1577. (when (gnus-topic-select-group)
  1578. (gnus-summary-exit))))
  1579. gnus-group-mode-map)
  1580. ;; Toggle visibility of News group
  1581. (bind-key "v c"
  1582. (lambda ()
  1583. (interactive)
  1584. (save-mark-and-excursion
  1585. (gnus-topic-jump-to-topic "News")
  1586. (gnus-topic-read-group)))
  1587. gnus-group-mode-map)
  1588. (bind-key "C-<return>" #'db/gnus-summary-open-Link gnus-summary-mode-map)
  1589. (bind-key "C-<return>" #'db/gnus-summary-open-Link gnus-article-mode-map)))
  1590. ;; Sending mail
  1591. (setq message-send-mail-function #'db/smtpmail-send-it
  1592. send-mail-function #'db/smtpmail-send-it
  1593. mail-user-agent 'gnus-user-agent)
  1594. (use-package smtpmail
  1595. :init (setq smtpmail-stream-type 'starttls
  1596. smtpmail-smtp-service 587
  1597. smtpmail-debug-info t))
  1598. ;; * Crypto
  1599. (use-package nsm
  1600. :init (setq network-security-level 'high
  1601. nsm-save-host-names t
  1602. nsm-settings-file (expand-file-name
  1603. "~/.emacs.d/private/network-security.data"))
  1604. :config (advice-add 'nsm-write-settings
  1605. :before #'db/sort-nsm-permanent-settings))
  1606. (use-package gnutls
  1607. :init (setq gnutls-log-level 0 ; too noisy otherwise
  1608. gnutls-min-prime-bits 1024
  1609. gnutls-verify-error t))
  1610. (use-package epg
  1611. :init (setq epg-debug t
  1612. epg-gpg-program "gpg"))
  1613. ;; * Appearance
  1614. (setq-default cursor-type 'bar
  1615. cursor-in-non-selected-windows nil
  1616. font-lock-maximum-decoration '((t . t)))
  1617. (setq mode-line-format '((ace-window-display-mode
  1618. (:eval
  1619. (window-parameter
  1620. (selected-window)
  1621. 'ace-window-path)))
  1622. "%e"
  1623. mode-line-front-space
  1624. mode-line-position
  1625. mode-line-mule-info
  1626. mode-line-client
  1627. mode-line-modified
  1628. mode-line-remote
  1629. mode-line-buffer-identification
  1630. mode-line-modes
  1631. (vc-mode vc-mode)
  1632. mode-line-misc-info
  1633. mode-line-end-spaces))
  1634. (use-package solarized-theme
  1635. :ensure t
  1636. :init (setq solarized-use-less-bold t
  1637. solarized-emphasize-indicators t
  1638. solarized-use-variable-pitch nil))
  1639. (use-package smart-mode-line
  1640. :ensure t
  1641. :init (setq sml/mode-width 'full
  1642. sml/name-width 30)
  1643. :commands (sml/setup))
  1644. (use-package minions
  1645. :ensure t
  1646. :commands (minions-mode)
  1647. :init (setq minions-mode-line-lighter "…"))
  1648. (use-package moody
  1649. :ensure t
  1650. :commands (moody-replace-mode-line-buffer-identification
  1651. moody-replace-vc-mode))
  1652. ;; * Dired
  1653. (use-package dired
  1654. :bind (:map dired-mode-map
  1655. ("e" . ora-ediff-files)
  1656. ("z" . dired-get-size)
  1657. ([remap beginning-of-buffer] . dired-back-to-top)
  1658. ([remap end-of-buffer] . dired-jump-to-bottom)
  1659. ("<f1>" . nil)
  1660. ("<tab>" . dired-subtree-toggle)
  1661. ("<C-tab>" . dired-subtree-cycle))
  1662. :init (progn
  1663. (setq dired-dwim-target t
  1664. dired-listing-switches (if on-windows "-aGFhlv" "-aGFhlv --group-directories-first --time-style=long-iso")
  1665. dired-hide-details-hide-information-lines t
  1666. dired-hide-details-hide-symlink-targets t
  1667. dired-recursive-copies 'top
  1668. dired-recursive-deletes 'top
  1669. dired-create-destination-dirs 'ask
  1670. dired-vc-rename-file t
  1671. ;; Don’t use obsolete diredx local variables
  1672. dired-enable-local-variables nil
  1673. dired-local-variables-file nil
  1674. dired-omit-files "^\\.?#\\|^\\.$\\|^\\.\\.$\\|^\\..*$"
  1675. diredp-hide-details-initially-flag t
  1676. wdired-create-parent-directories t
  1677. wdired-allow-to-change-permissions t
  1678. dired-isearch-filenames 'dwim
  1679. dired-auto-revert-buffer t)
  1680. (setq dired-guess-shell-alist-user
  1681. '(("\\.pdf\\'" "evince")
  1682. ("\\.ps\\'" "evince")
  1683. ("\\.\\(?:djvu\\|eps\\)\\'" "evince")
  1684. ("\\.\\(?:jpg\\|jpeg\\|png\\|gif\\|xpm\\)\\'" "eog")
  1685. ("\\.\\(?:xcf\\)\\'" "gimp")
  1686. ("\\.\\(?:mp4\\|mkv\\|avi\\|flv\\|ogv\\|webm\\)\\(?:\\.part\\)?\\'"
  1687. "vlc")
  1688. ("\\.\\(?:mp3\\|flac\\|ogg\\)\\'" "mplayer")
  1689. ("\\.docx?\\'" "loffice")))
  1690. (when on-windows
  1691. (setq directory-free-space-program nil)))
  1692. :config (progn
  1693. (put 'dired-find-alternate-file 'disabled nil)
  1694. (require 'dired-x)
  1695. (with-demoted-errors "Non-Fatal Errors (dired-open): %s"
  1696. (require 'dired-open))
  1697. (if (eq system-type 'windows-nt)
  1698. (with-demoted-errors "Non-Fatal Error (w32-browser): %s"
  1699. (require 'w32-browser)
  1700. (bind-key "M-RET" #'dired-w32-browser dired-mode-map)
  1701. (bind-key "<C-return>" #'dired-w32explore dired-mode-map))
  1702. (bind-key "M-RET" #'dired-open-xdg dired-mode-map))
  1703. (with-demoted-errors "Non-Fatal Errors (dired-recent): %s"
  1704. (dired-recent-mode +1))
  1705. ;; Gnus support in dired
  1706. (add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)
  1707. ;; Highlight current line more prominently
  1708. (add-hook 'dired-mode-hook 'hl-line-mode)
  1709. ;; omitting files
  1710. (add-hook 'dired-mode-hook 'dired-omit-mode)
  1711. (add-hook 'dired-mode-hook 'dired-hide-details-mode)
  1712. (dolist (extension '(".out" ".synctex.gz" ".thm"))
  1713. (add-to-list 'dired-latex-unclean-extensions extension))
  1714. (defun ora-ediff-files ()
  1715. "Compare marked files in dired with ediff."
  1716. ;; from: https://oremacs.com/2017/03/18/dired-ediff/
  1717. (interactive)
  1718. (lexical-let ((files (dired-get-marked-files))
  1719. (wnd (current-window-configuration)))
  1720. (if (<= (length files) 2)
  1721. (lexical-let ((file1 (car files))
  1722. (file2 (if (cdr files)
  1723. (cadr files)
  1724. (read-file-name
  1725. "file: "
  1726. (dired-dwim-target-directory)))))
  1727. (if (file-newer-than-file-p file1 file2)
  1728. (ediff-files file2 file1)
  1729. (ediff-files file1 file2))
  1730. (add-hook 'ediff-after-quit-hook-internal
  1731. (lambda ()
  1732. (setq ediff-after-quit-hook-internal nil)
  1733. (set-window-configuration wnd))))
  1734. (error "No more than 2 files should be marked"))))
  1735. (defun dired-back-to-top ()
  1736. "Jump to first non-trivial line in dired."
  1737. (interactive)
  1738. (goto-char (point-min))
  1739. (dired-next-line 1))
  1740. (defun dired-jump-to-bottom ()
  1741. "Jump to last non-trivial line in dired."
  1742. (interactive)
  1743. (goto-char (point-max))
  1744. (dired-next-line -1))
  1745. (defun dired-get-size () ; from emacswiki, via oremacs
  1746. "Print size of all files marked in the current dired buffer."
  1747. (interactive)
  1748. (let ((files (dired-get-marked-files)))
  1749. (with-temp-buffer
  1750. (apply 'call-process "/usr/bin/du" nil t nil "-sch" files)
  1751. (message
  1752. "size of all marked files: %s"
  1753. (progn
  1754. (re-search-backward "\\(^[0-9.,]+[a-za-z]+\\).*total$")
  1755. (match-string 1))))))))
  1756. (use-package dired-x
  1757. :commands (dired-jump dired-jump-other-window)
  1758. :init (setq dired-clean-confirm-killing-deleted-buffers t
  1759. dired-x-hands-off-my-keys t
  1760. dired-bind-man nil
  1761. dired-bind-info nil
  1762. dired-clean-up-buffers-too t))
  1763. (use-package dired-subtree
  1764. :commands (dired-subtree-toggle))
  1765. (use-package find-dired
  1766. :commands (find-dired)
  1767. :init (setq find-ls-option '("-print0 | xargs -0 ls -ld" . "-ld")))
  1768. (use-package dired-open
  1769. :ensure t
  1770. :init (progn
  1771. (unless (eq system-type 'gnu/linux)
  1772. (setq dired-open-use-nohup nil))
  1773. (setq dired-open-extensions-elisp '(("html" . eww-open-file))))
  1774. :config (progn
  1775. (add-to-list 'dired-open-functions
  1776. #'dired-open-guess-shell-alist)
  1777. (add-to-list 'dired-open-functions
  1778. #'dired-open-call-function-by-extension)))
  1779. (use-package dired-recent
  1780. :ensure t
  1781. :init (setq dired-recent-max-directories nil)
  1782. :commands (dired-recent-mode
  1783. dired-recent-open))
  1784. (use-package gnus-dired
  1785. :commands (turn-on-gnus-dired-mode))
  1786. (use-package trashed
  1787. ;; A simple dired-like interface to the system trash bin
  1788. ;; Configuration taken from https://protesilaos.com/dotemacs
  1789. :init (setq trashed-action-confirmer 'y-or-n-p
  1790. trashed-use-header-line t
  1791. trashed-sort-key '("Date deleted" . t)
  1792. trashed-date-format "%Y-%m-%d %H:%M:%S"))
  1793. ;; * Completion
  1794. (use-package hippie-exp
  1795. :commands (hippie-expand))
  1796. (use-package helm
  1797. :ensure t
  1798. :diminish helm-mode
  1799. :init (setq helm-command-prefix-key "C-c h"
  1800. helm-input-idle-delay 0.0
  1801. helm-buffers-fuzzy-matching t
  1802. helm-mode-fuzzy-match t
  1803. helm-autoresize-min-height 20
  1804. helm-ff-auto-update-initial-value t
  1805. helm-ff-file-name-history-use-recentf t
  1806. helm-ff-search-library-in-sexp t
  1807. helm-ff-skip-boring-files nil
  1808. helm-split-window-inside-p t
  1809. helm-move-to-line-cycle-in-source nil
  1810. helm-scroll-amount nil
  1811. helm-locate-command nil
  1812. helm-candidate-number-limit 100
  1813. helm-follow-mode-persistent t
  1814. helm-buffer-details-flag t
  1815. helm-buffer-skip-remote-checking t
  1816. helm-mode-no-completion-in-region-in-modes '(eshell-mode))
  1817. :config (progn
  1818. (require 'helm-config)
  1819. (require 'helm-mode)
  1820. (require 'helm-buffers)
  1821. (require 'helm-ring)
  1822. (if (require 'helm-global-bindings nil :no-error)
  1823. (progn
  1824. (bind-key "#" #'helm-emms helm-command-map)
  1825. (bind-key "P" #'helm-pages helm-command-map))
  1826. (warn (concat
  1827. "Cannot load `helm-global-bindings', please check your helm installation for completeness. "
  1828. "(Have you installed it from melpa?)")))
  1829. (bind-key "<tab>" #'helm-execute-persistent-action helm-map)
  1830. (bind-key "C-i" #'helm-execute-persistent-action helm-map)
  1831. (bind-key "C-z" #'helm-select-action helm-map)))
  1832. (use-package helm-ring
  1833. :commands (helm-show-kill-ring))
  1834. (use-package ivy
  1835. :ensure t
  1836. :commands (ivy-mode
  1837. ivy-resume)
  1838. :diminish ivy-mode
  1839. :init (setq ivy-use-virtual-buffers t
  1840. ivy-magic-tilde nil
  1841. ivy-count-format "(%d/%d) "
  1842. ivy-initial-inputs-alist '((counsel-describe-function . "^")
  1843. (counsel-describe-variable . "^")
  1844. (man . "^")
  1845. (woman . "^"))
  1846. ivy-use-selectable-prompt t
  1847. ivy-do-completion-in-region t
  1848. ivy-re-builders-alist '((t . ivy--regex-ignore-order)))
  1849. :config (progn
  1850. ;; Since we are using `ivy--regex-ignore-order' for completion
  1851. ;; anyway, providing the an individual restriction in the ivy buffer
  1852. ;; is not necessary anymore. Since I often mistype S-SPC for SPC,
  1853. ;; loosing the current candidate and annoying myself, removing this
  1854. ;; shortcut is both helpful and not removing necessary
  1855. ;; functionality.
  1856. (define-key ivy-minibuffer-map (kbd "S-SPC") nil)))
  1857. (use-package ivy-hydra)
  1858. (use-package counsel
  1859. :ensure t
  1860. :commands (counsel-org-goto-all
  1861. counsel-ag
  1862. counsel-M-x
  1863. counsel-find-file
  1864. counsel-info-lookup-symbol
  1865. counsel-unicode-char
  1866. counsel-descbinds
  1867. counsel-describe-variable
  1868. counsel-describe-function
  1869. counsel-recentf
  1870. counsel-shell-history))
  1871. (use-package swiper
  1872. :ensure t
  1873. :commands (swiper
  1874. swiper-from-isearch))
  1875. (use-package recentf
  1876. :commands (recentf-mode recentf-save-list)
  1877. :init (setq recentf-max-saved-items 1000)
  1878. :config (run-with-timer 0 3600 #'recentf-save-list))
  1879. (use-package company
  1880. :commands (company-mode global-company-mode)
  1881. :init (setq company-show-numbers t))
  1882. ;; * Navigation
  1883. (defun db/helm-shortcuts (arg)
  1884. "Open helm completion on common locations.
  1885. With given ARG, display files in `db/important-document-path’."
  1886. (interactive "p")
  1887. (require 'helm-bookmark)
  1888. (require 'helm-for-files) ; for helm-source-recentf
  1889. (helm :sources (list
  1890. (helm-make-source "Frequently Used" 'helm-source-sync
  1891. :candidates (mapcar #'(lambda (entry)
  1892. (cons (car entry)
  1893. (caddr entry)))
  1894. db/frequently-used-features)
  1895. :action '(("Open" . call-interactively))
  1896. :filtered-candidate-transformer #'helm-adaptive-sort)
  1897. ;; taken from `helm-buffers-list'
  1898. (helm-make-source "Buffers" 'helm-source-buffers)
  1899. helm-source-recentf
  1900. ;; if prefix arg is given, extract files from
  1901. ;; `db/important-documents-path’ and list them as well
  1902. (when (and (= arg 4)
  1903. (file-directory-p db/important-documents-path))
  1904. (let ((search-path (expand-file-name db/important-documents-path)))
  1905. (helm-make-source "Important files" 'helm-source-sync
  1906. :candidates (mapcar #'(lambda (file)
  1907. ;; display only relative path,
  1908. ;; but keep absolute path for
  1909. ;; actions
  1910. (cons (string-remove-prefix search-path file)
  1911. file))
  1912. (directory-files-recursively search-path ""))
  1913. :action '(("Open externally" . db/system-open)
  1914. ("Find file" . find-file)))))
  1915. helm-source-bookmarks
  1916. helm-source-buffer-not-found
  1917. helm-source-bookmark-set)))
  1918. (use-package ace-window
  1919. :ensure t
  1920. :commands (ace-window ace-window-display-mode)
  1921. :init (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)
  1922. aw-background t
  1923. aw-leading-char-style 'char
  1924. aw-scope 'frame))
  1925. (use-package avy
  1926. :ensure t
  1927. :commands (avy-goto-char-timer
  1928. avy-goto-word-or-subword-1
  1929. avy-goto-line))
  1930. (use-package bm
  1931. ;; Taken from https://protesilaos.com/dotemacs/ and slightly adapted
  1932. :ensure t
  1933. :commands (bm-toggle bm-next bm-previous bm-toggle-buffer-persistence)
  1934. :init (setq bm-restore-repository-on-load t
  1935. bm-annotate-on-create nil
  1936. bm-buffer-persistence t
  1937. bm-cycle-all-buffers t
  1938. bm-goto-position nil
  1939. bm-highlight-style 'bm-highlight-line-and-fringe
  1940. bm-marker 'bm-marker-right
  1941. bm-in-lifo-order nil
  1942. bm-recenter t
  1943. bm-repository-file "~/.emacs.d/bm-bookmarks"
  1944. bm-repository-size 100
  1945. bm-show-annotations t
  1946. bm-wrap-immediately t
  1947. bm-wrap-search t))
  1948. (use-package dumb-jump
  1949. :commands (dumb-jump-xref-activate)
  1950. :init (progn
  1951. (setq dumb-jump-selector 'helm)
  1952. (add-hook 'xref-backend-functions #'dumb-jump-xref-activate)))
  1953. (use-package helm-pages
  1954. :ensure t
  1955. :commands (helm-pages))
  1956. (use-package imenu
  1957. :init (setq imenu-use-markers t
  1958. imenu-auto-rescan t
  1959. imenu-auto-rescan-maxout 600000
  1960. imenu-max-item-length 100
  1961. imenu-use-popup-menu nil
  1962. imenu-eager-completion-buffer t))
  1963. (use-package eyebrowse
  1964. :ensure t
  1965. :commands (eyebrowse-mode)
  1966. :init (setq eyebrowse-keymap-prefix (kbd "C-c w")))
  1967. (use-package goto-last-change
  1968. :commands goto-last-change)
  1969. ;; * Media
  1970. (use-package emms
  1971. :pin "melpa-stable"
  1972. :commands (emms
  1973. emms-pause
  1974. emms-stop
  1975. emms-next
  1976. emms-previous)
  1977. :bind (:map emms-playlist-mode-map
  1978. ("S s" . emms-shuffle))
  1979. :init (setq emms-source-file-default-directory "~/Documents/media/audio/"
  1980. emms-player-list '(emms-player-mplayer emms-player-mplayer-playlist)
  1981. emms-show-format "NP: %s"
  1982. emms-stream-default-action "play"
  1983. emms-track-description-function 'db/emms-track-description
  1984. emms-playlist-default-major-mode 'emms-playlist-mode
  1985. emms-cache-file (expand-file-name "private/emms/cache" emacs-d)
  1986. emms-history-file (expand-file-name "private/emms/history" emacs-d)
  1987. emms-score-file (expand-file-name "private/emms/scores" emacs-d)
  1988. emms-stream-bookmarks-file (expand-file-name "private/emms/streams" emacs-d))
  1989. :config (progn
  1990. ;; Initialization copied and adapted from `emms-setup’
  1991. (require 'emms-source-file)
  1992. (require 'emms-source-playlist)
  1993. (require 'emms-player-simple)
  1994. (require 'emms-player-mplayer)
  1995. (require 'emms-playlist-mode)
  1996. (require 'emms-info)
  1997. (require 'emms-info-mp3info)
  1998. (require 'emms-info-ogginfo)
  1999. (require 'emms-info-opusinfo)
  2000. (require 'emms-cache)
  2001. (require 'emms-mode-line)
  2002. (require 'emms-mark)
  2003. (require 'emms-tag-editor)
  2004. (require 'emms-show-all)
  2005. (require 'emms-streams)
  2006. (require 'emms-playing-time)
  2007. (require 'emms-player-mpd)
  2008. (require 'emms-playlist-sort)
  2009. (require 'emms-browser)
  2010. (require 'emms-mode-line-icon)
  2011. (require 'emms-cue)
  2012. (require 'emms-bookmarks)
  2013. (require 'emms-last-played)
  2014. (require 'emms-metaplaylist-mode)
  2015. (require 'emms-stream-info)
  2016. (require 'emms-score)
  2017. (require 'emms-history)
  2018. (require 'emms-i18n)
  2019. (require 'emms-volume)
  2020. (require 'emms-playlist-limit)
  2021. (add-to-list 'emms-track-initialize-functions
  2022. 'emms-info-initialize-track)
  2023. (if (require 'emms-info-mediainfo nil 'no-error)
  2024. (setq emms-info-functions '(emms-info-mediainfo))
  2025. (when (executable-find emms-info-mp3info-program-name)
  2026. (add-to-list 'emms-info-functions 'emms-info-mp3info))
  2027. (when (executable-find emms-info-ogginfo-program-name)
  2028. (add-to-list 'emms-info-functions 'emms-info-ogginfo))
  2029. (when (executable-find emms-info-opusinfo-program-name)
  2030. (add-to-list 'emms-info-functions 'emms-info-opusinfo))
  2031. (add-to-list 'emms-info-functions 'emms-info-cueinfo))
  2032. (when (fboundp 'emms-cache) ; work around compiler warning
  2033. (emms-cache 1))
  2034. (emms-mode-line -1)
  2035. (emms-playing-time 1)
  2036. (emms-score 1)
  2037. (add-hook 'emms-player-started-hook 'emms-last-played-update-current)
  2038. (add-hook 'emms-player-started-hook 'emms-show)
  2039. (advice-add 'emms-tag-editor-submit
  2040. :after (lambda (&rest r)
  2041. (ignore r)
  2042. (delete-window)))
  2043. (unless (eq system-type 'windows-nt)
  2044. (setq emms-source-file-directory-tree-function
  2045. #'db/emms-source-file-directory-tree-find))
  2046. ;; `emms-playlist-mode’ sets `emms-playlist-insert-track-function’,
  2047. ;; no matter what previous values or customization may say otherwise
  2048. ;; … so we need to employ a hook to change its value
  2049. (add-hook 'emms-playlist-mode-hook
  2050. (lambda ()
  2051. (setq emms-playlist-insert-track-function
  2052. #'db/emms-playlist-mode-insert-track)))
  2053. (run-with-timer 0 3600 #'emms-cache-save)))
  2054. ;; Make sure emms is up and running when we call functions such as
  2055. ;; `emms-play-dired’ etc.
  2056. (use-package emms-source-file
  2057. :config (require 'emms))
  2058. (use-package db-emms
  2059. :commands (db/emms-source-file-directory-tree-find
  2060. db/emms-track-description
  2061. db/emms-playlist-mode-insert-track))
  2062. (use-package helm-emms
  2063. :commands (helm-emms)
  2064. :init (setq helm-emms-use-track-description-function t
  2065. helm-emms-default-sources '(helm-source-emms-streams
  2066. helm-source-emms-dired
  2067. helm-source-emms-files))
  2068. :config (progn
  2069. (require 'emms)
  2070. (require 'helm-adaptive)))
  2071. (use-package db-music
  2072. :init (setq db/auto-playlist-file-function
  2073. #'(lambda ()
  2074. (db/playlist-files-from-git-annex-find
  2075. "--metadata db-playlist=include")))
  2076. :commands (db/play-auto-playlist
  2077. db/playlist-files-from-git-annex-find
  2078. db/play-auto-playlist-from-git-annex-find
  2079. music-control/body
  2080. db/play-radio-stations
  2081. db/update-playlist-files))
  2082. ;; * Shells and such
  2083. (use-package comint
  2084. :init (setq comint-scroll-to-bottom-on-input t
  2085. comint-scroll-to-bottom-on-output nil
  2086. comint-scroll-show-maximum-output t
  2087. comint-completion-addsuffix t
  2088. comint-buffer-maximum-size 100000
  2089. comint-input-ring-size 5000)
  2090. :config (progn
  2091. ;; Never let bash know that we are inside Emacs;
  2092. ;; cf. https://coredumped.dev/2020/01/04/native-shell-completion-in-emacs/
  2093. (advice-add 'comint-term-environment
  2094. :filter-return #'(lambda (env) (cons "INSIDE_EMACS" env)))))
  2095. (use-package term
  2096. :commands (term-send-string)
  2097. :init (setq explicit-shell-file-name "/bin/bash")
  2098. :config (progn
  2099. (add-hook 'term-exec-hook ; oremacs.com
  2100. (lambda ()
  2101. (let* ((buff (current-buffer))
  2102. (proc (get-buffer-process buff)))
  2103. (set-process-sentinel
  2104. proc
  2105. `(lambda (process event)
  2106. (if (string= event "finished\n")
  2107. (kill-buffer ,buff)))))))
  2108. ;; does not work; C-c is shadowed by some minor modes like semantic,
  2109. ;; projectile, and winner
  2110. (bind-key "C-c" #'term-send-raw term-raw-map)
  2111. ;; unbind some keys to allow the global keymap to handle them
  2112. (unbind-key "M-:" term-raw-map)
  2113. (unbind-key "C-h" term-raw-map)
  2114. (unbind-key "M-x" term-raw-map)
  2115. (unbind-key "M-o" term-raw-map)
  2116. ;; we need to set keys starting with C-x after `ansi-term' has been
  2117. ;; called, as it resets the escape character to C-x.
  2118. (defadvice ansi-term (after ansi-term-set-keys activate)
  2119. (unbind-key "C-x C-j" term-raw-map)
  2120. (unbind-key "C-x g" term-raw-map))
  2121. (add-hook 'term-mode-hook (lambda () (yas-minor-mode -1)))))
  2122. (use-package ansi-color
  2123. :commands (ansi-color-for-comint-mode-on
  2124. ansi-color-apply-on-region)
  2125. :config (progn
  2126. (add-hook 'compilation-filter-hook 'endless/colorize-compilation)))
  2127. (use-package shell
  2128. :commands (shell)
  2129. :bind (:map shell-mode-map
  2130. ("C-r" . counsel-shell-history))
  2131. :config (progn
  2132. (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
  2133. (add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m)
  2134. (add-hook 'shell-mode-hook 'with-editor-export-editor)
  2135. ;; We may want to use readline support in bash, don't inhibit this
  2136. ;; with explicit command line arguments;
  2137. ;; cf. https://coredumped.dev/2020/01/04/native-shell-completion-in-emacs/
  2138. (setq explicit-bash-args
  2139. (delete "--noediting" explicit-bash-args))))
  2140. (use-package db-eshell
  2141. :commands (db/run-or-hide-eshell
  2142. eshell-clear-buffer
  2143. eshell/default-prompt-function
  2144. eshell/gst
  2145. eshell-insert-history
  2146. pcomplete/git))
  2147. (use-package eshell
  2148. :commands (eshell)
  2149. :init (setq eshell-cmpl-cycle-completions nil
  2150. eshell-scroll-to-bottom-on-input t
  2151. eshell-prefer-lisp-functions nil
  2152. eshell-error-if-no-glob t
  2153. eshell-hist-ignoredups t
  2154. eshell-save-history-on-exit t
  2155. eshell-history-size 5000
  2156. eshell-destroy-buffer-when-process-dies t
  2157. eshell-prompt-function #'eshell/default-prompt-function
  2158. eshell-prompt-regexp "└─[$#] "
  2159. eshell-highlight-prompt nil
  2160. eshell-cd-on-directory t
  2161. eshell-expand-input-functions '(eshell-expand-history-references))
  2162. :config (progn (require 'em-prompt)
  2163. (require 'em-term)
  2164. (require 'em-cmpl)
  2165. (setenv "PAGER" "cat")
  2166. (add-to-list 'eshell-command-completions-alist
  2167. '("gunzip" "gz\\'"))
  2168. (add-to-list 'eshell-command-completions-alist
  2169. '("tar" "\\(\\.tar|\\.tgz\\|\\.tar\\.gz\\)\\'"))
  2170. (add-hook 'eshell-mode-hook
  2171. 'with-editor-export-editor)
  2172. (add-hook 'eshell-mode-hook
  2173. (lambda ()
  2174. (bind-key "C-a" #'eshell-bol eshell-mode-map)
  2175. (bind-key "M-r" #'eshell-insert-history eshell-mode-map)
  2176. (bind-key "M-P" #'eshell-previous-prompt eshell-mode-map)
  2177. (bind-key "M-N" #'eshell-next-prompt eshell-mode-map)))
  2178. ;; Ignoring case when completing file names seems to have a
  2179. ;; bug: when a ~ is encountered, it is implicitly expaned by
  2180. ;; `pcomplete-insert-entry’, overwriting the prompt as a side
  2181. ;; effect. Keeping the case as it is does not seem to have
  2182. ;; this issue. This problem occurs by default only on Windows
  2183. ;; systems (in all flavors), because this is the only time
  2184. ;; `pcomplete-ignore-case’ is non-nil by default.
  2185. (when on-windows
  2186. (add-to-list 'eshell-mode-hook
  2187. (lambda ()
  2188. (setq pcomplete-ignore-case nil))))
  2189. ;; Sometimes, when completing path names and immediately
  2190. ;; hitting RET, `completion-in-region-mode' still seems to be
  2191. ;; active; this often happens when calling cd. Then,
  2192. ;; `post-command-hook' still contains
  2193. ;; `completion-in-region--postch', which calls some `pcomplete'
  2194. ;; function to determine whether completion mode should exit.
  2195. ;; However, after RET (i.e., `eshell-send-input'), we only have
  2196. ;; an empty prompt, and `pcomplete' just computes all possible
  2197. ;; functions for completion (doesn't show it, though). This
  2198. ;; introduces a noticeable amount of delay, which is annoying.
  2199. ;; Expliticly disabling `completion-in-region-mode' before
  2200. ;; sending input seems to alleviate the problem.
  2201. (advice-add 'eshell-send-input
  2202. :before #'(lambda (&rest _)
  2203. "Disable completion-in-region-mode before sending input."
  2204. (when completion-in-region-mode
  2205. (completion-in-region-mode -1))))
  2206. (require 'db-eshell)))
  2207. (use-package with-editor
  2208. :commands (with-editor-export-editor))
  2209. ;; * Lisp
  2210. ;; General Stuff first
  2211. (use-package lisp-mode
  2212. :init (setq lisp-indent-function #'lisp-indent-function))
  2213. (use-package lispy
  2214. :ensure t
  2215. :commands (lispy-mode)
  2216. :diminish lispy-mode)
  2217. (use-package eldoc
  2218. :commands (global-eldoc-mode
  2219. turn-on-eldoc-mode)
  2220. :diminish eldoc-mode)
  2221. ;; Lisp Dialects
  2222. (use-package elisp-mode
  2223. :config (progn
  2224. (add-hook 'emacs-lisp-mode-hook 'turn-on-lispy-when-available)
  2225. (add-hook 'emacs-lisp-mode-hook 'turn-on-flycheck-when-file)))
  2226. (use-package geiser
  2227. :commands (geiser-mode))
  2228. (use-package cider
  2229. :commands (cider-jack-in)
  2230. :init (setq nrepl-hide-special-buffers t
  2231. cider-auto-select-error-buffer t
  2232. cider-stacktrace-default-filters '(tooling dup)
  2233. cider-stacktrace-fill-column 80
  2234. cider-save-file-on-load nil
  2235. cider-repl-result-prefix ";; => "
  2236. cider-repl-use-clojure-font-lock t
  2237. cider-repl-wrap-history t
  2238. cider-repl-history-size 1000
  2239. ;;cider-lein-parameters "trampoline repl :headless"
  2240. cider-lein-parameters "repl :headless"
  2241. cider-repl-history-file (expand-file-name ".cider-history" emacs-d)
  2242. cider-repl-display-help-banner nil)
  2243. :config (progn
  2244. (add-hook 'cider-repl-mode-hook 'subword-mode)
  2245. (add-hook 'cider-repl-mode-hook 'turn-on-lispy-when-available)
  2246. (add-hook 'cider-repl-mode-hook 'cider-repl-toggle-pretty-printing)
  2247. (add-hook 'cider-repl-mode-hook 'company-mode)))
  2248. (use-package clojure-mode
  2249. :config (progn
  2250. (define-clojure-indent
  2251. (forall 'defun)
  2252. (exists 'defun)
  2253. (dopar 'defun))
  2254. (add-hook 'clojure-mode-hook 'turn-on-lispy-when-available)
  2255. (add-hook 'clojure-mode-hook 'clj-refactor-mode)
  2256. (add-hook 'clojure-mode-hook 'company-mode)))
  2257. (use-package clj-refactor
  2258. :commands (clj-refactor-mode)
  2259. :config (progn
  2260. (cljr-add-keybindings-with-prefix "C-c C-m")
  2261. (setq cljr-eagerly-build-asts-on-startup nil
  2262. cljr-warn-on-eval nil)))
  2263. (use-package slime
  2264. :commands (slime slime-mode slime-connect)
  2265. :init (progn
  2266. (setq inferior-lisp-program "sbcl --noinform --no-linedit"
  2267. slime-compile-file-options '(:fasl-directory "/tmp/slime-fasls/")
  2268. slime-net-coding-system 'utf-8-unix
  2269. slime-completion-at-point-functions 'slime-fuzzy-complete-symbol
  2270. slime-lisp-implementations '((sbcl ("sbcl") :coding-system utf-8-unix)
  2271. (cmucl ("cmucl") :coding-system utf-8-unix)
  2272. (ccl ("ccl") :coding-system utf-8-unix))
  2273. slime-repl-history-remove-duplicates t
  2274. slime-repl-history-trim-whitespaces t)
  2275. (add-hook 'lisp-mode-hook '(lambda () (slime-mode +1)) t))
  2276. :config (progn
  2277. (make-directory "/tmp/slime-fasls/" t)
  2278. (slime-setup '(slime-repl slime-fancy slime-autodoc))
  2279. (add-hook 'slime-mode-hook 'slime-redirect-inferior-output)))
  2280. (use-package hy-mode
  2281. :commands (hy-mode)
  2282. :config (progn
  2283. (add-hook 'hy-mode-hook 'turn-on-lispy-when-available)
  2284. (add-hook 'hy-mode-hook 'inferior-lisp)))
  2285. ;; * TeX
  2286. (use-package reftex
  2287. :commands (turn-on-reftex)
  2288. :init (setq reftex-plug-into-AUCTeX t)
  2289. :config (with-eval-after-load 'helm-mode
  2290. (add-to-list 'helm-completing-read-handlers-alist
  2291. '(reftex-citation . nil))))
  2292. (use-package tex
  2293. :init (setq TeX-auto-save t
  2294. TeX-save-query nil
  2295. TeX-parse-self t
  2296. TeX-master t
  2297. TeX-electric-sub-and-superscript t
  2298. TeX-electric-math '("$" . "$")
  2299. TeX-electric-escape nil
  2300. LaTeX-electric-left-right-brace t
  2301. LaTeX-fill-break-at-separators nil
  2302. TeX-fold-math-spec-list '(("≤" ("le"))
  2303. ("≥" ("ge"))
  2304. ("∉" ("notin")))
  2305. TeX-source-correlate-start-server nil
  2306. LaTeX-eqnarray-label "eqn:"
  2307. LaTeX-equation-label "eqn:"
  2308. LaTeX-figure-label "fig:"
  2309. LaTeX-table-label "tab:"
  2310. TeX-newline-function 'reindent-then-newline-and-indent
  2311. LaTeX-section-hook '(LaTeX-section-heading
  2312. LaTeX-section-title
  2313. LaTeX-section-section
  2314. LaTeX-section-label))
  2315. :config (progn
  2316. (require 'latex)
  2317. (require 'tex-buf)
  2318. (require 'reftex)
  2319. (TeX-engine-set 'default)
  2320. (put 'TeX-narrow-to-group 'disabled nil)
  2321. (put 'LaTeX-narrow-to-environment 'disabled nil)
  2322. (add-hook 'LaTeX-mode-hook #'turn-on-flyspell)
  2323. (add-hook 'LaTeX-mode-hook #'turn-on-visual-line-mode)
  2324. (add-hook 'LaTeX-mode-hook #'LaTeX-math-mode)
  2325. (add-hook 'LaTeX-mode-hook #'outline-minor-mode)
  2326. (add-hook 'LaTeX-mode-hook #'page-break-lines-mode)
  2327. (add-hook 'LaTeX-mode-hook #'turn-on-reftex)
  2328. (add-hook 'latex-mode-hook #'turn-on-reftex)
  2329. (add-hook 'LaTeX-mode-hook '(lambda ()
  2330. (TeX-PDF-mode 1)
  2331. (TeX-source-correlate-mode 1)
  2332. (TeX-fold-mode 1)))
  2333. (add-to-list 'TeX-view-program-selection
  2334. '(output-pdf "Evince"))
  2335. ;; use pdf-tools when loaded
  2336. (with-eval-after-load 'pdf-tools
  2337. (add-to-list 'TeX-view-program-selection '(output-pdf "PDF Tools"))
  2338. (add-to-list 'TeX-after-compilation-finished-functions
  2339. #'TeX-revert-document-buffer))
  2340. ;; style used for my personal definitions; not clear whether this
  2341. ;; works as intended
  2342. (TeX-add-style-hook
  2343. "mydefs"
  2344. (lambda ()
  2345. (TeX-run-style-hooks "etex"
  2346. "etoolbox"
  2347. "ifthen"
  2348. "amsmath"
  2349. "amssymb"
  2350. "latexsym"
  2351. "mathabx"
  2352. "stmaryrd"
  2353. "verbatim"
  2354. "graphicx"
  2355. "enumerate"
  2356. "array"
  2357. "booktabs"
  2358. "ulem"
  2359. "nicefrac"
  2360. "listings"
  2361. "microtype"
  2362. "tabularx"
  2363. "tikz"
  2364. "csquotes"
  2365. "ntheorem"
  2366. "xspace")
  2367. (LaTeX-add-environments
  2368. '("Exercise" LaTeX-env-label)
  2369. '("Theorem" LaTeX-env-label)
  2370. '("Proposition" LaTeX-env-label)
  2371. '("Lemma" LaTeX-env-label)
  2372. '("Corollary" LaTeX-env-label)
  2373. '("Remark" LaTeX-env-label)
  2374. '("Example" LaTeX-env-label)
  2375. '("Definition" LaTeX-env-label)
  2376. '("Proof" LaTeX-env-label))
  2377. ;; https://tex.stackexchange.com/questions/217799/auctex-11-88-bug-on-latex-env-label-cannot-automatically-insert-label
  2378. (setf (cadr reftex-insert-label-flags)
  2379. (concat (cadr reftex-insert-label-flags) "TLPDRCE"))
  2380. (dolist (label-spec
  2381. '(("Theorem" ?T "thm:" "~\\ref{%s}" t ("Theorem" "Thm.") nil)
  2382. ("Lemma" ?L "lem:" "~\\ref{%s}" t ("Lemma" "Lem.") nil)
  2383. ("Proposition" ?P "prop:" "~\\ref{%s}" t ("Proposition" "Prop.") nil)
  2384. ("Satz" ?T "thm:" "~\\ref{%s}" t ("Satz") nil)
  2385. ("Definition" ?D "def:" "~\\ref{%s}" t ("Definition" "Def.") nil)
  2386. ("Remark" ?R "rem:" "~\\ref{%s}" t ("Remark" "Rem.") nil)
  2387. ("Corollary" ?C "cor:" "~\\ref{%s}" t ("Corollary" "Cor.") nil)
  2388. ("Example" ?E "expl:" "~\\ref{%s}" t ("Example") nil)))
  2389. (add-to-list 'reftex-label-alist label-spec)
  2390. (add-to-list 'LaTeX-label-alist (cons (nth 0 label-spec)
  2391. (nth 2 label-spec))))))
  2392. ;; Add completion for cleverref’s reference macros; not clear
  2393. ;; whether this works as intended
  2394. (TeX-add-style-hook
  2395. "cleveref"
  2396. (lambda ()
  2397. (add-to-list 'reftex-ref-style-alist
  2398. '("Cleveref" "cleveref"
  2399. (("\\cref" ?c) ("\\Cref" ?C)
  2400. ("\\cpageref" ?d) ("\\Cpageref" ?D))))
  2401. (reftex-ref-style-activate "Cleveref")
  2402. (TeX-add-symbols
  2403. '("cref" TeX-arg-ref)
  2404. '("Cref" TeX-arg-ref)
  2405. '("cpageref" TeX-arg-ref)
  2406. '("Cpageref" TeX-arg-ref))))
  2407. ;; Language definitions
  2408. (add-hook 'TeX-language-de-hook
  2409. (lambda () (ispell-change-dictionary "de_DE")))
  2410. (add-hook 'TeX-language-en-hook
  2411. (lambda () (ispell-change-dictionary "en_US")))
  2412. (add-hook 'TeX-mode-hook
  2413. (lambda () (setq ispell-parser 'tex)))))
  2414. (use-package helm-bibtex
  2415. :commands (helm-bibtex))
  2416. ;; * Various Mode Configurations
  2417. ;; These are packages that are not essential, but still nice to have. They
  2418. ;; provide optional functionality and may redefine builtin commands.
  2419. (use-package cperl-mode
  2420. :ensure t
  2421. :commands (cperl-mode)
  2422. :init (progn
  2423. ;; replace perl-mode with cperl-mode
  2424. (mapc
  2425. (lambda (pair)
  2426. (if (eq (cdr pair) 'perl-mode)
  2427. (setcdr pair 'cperl-mode)))
  2428. (append auto-mode-alist interpreter-mode-alist))
  2429. (setq cperl-hairy nil
  2430. cperl-invalid-face 'default
  2431. cperl-electric-keywords nil
  2432. cperl-lazy-help-time 2
  2433. cperl-highlight-variables-indiscriminately t))
  2434. :config (progn
  2435. (add-hook 'cperl-mode-hook 'flycheck-mode)
  2436. (add-hook 'cperl-mode-hook 'prettify-symbols-mode)
  2437. ;; enable display of help messages after a short period of time, as
  2438. ;; controlled by the value of `cperl-lazy-help-time'
  2439. (add-hook 'cperl-mode-hook 'cperl-lazy-install)))
  2440. (use-package db-projects
  2441. :commands (projects-add-project
  2442. projects-archive-project
  2443. projects-lint-projects))
  2444. (use-package define-word
  2445. :ensure t
  2446. :commands (define-word-at-point define-word))
  2447. (use-package dictcc
  2448. :ensure t
  2449. :commands (dictcc)
  2450. :config (require 'gnutls))
  2451. (use-package edit-list
  2452. :ensure t
  2453. :commands edit-list)
  2454. (use-package expand-region
  2455. :ensure t
  2456. :commands (er/expand-region))
  2457. (use-package eproject
  2458. ;; This configuration is only present to inhibit eproject overriding
  2459. ;; keybindings in `message-mode'
  2460. :config (progn
  2461. (message "Loaded eproject … done")
  2462. (with-eval-after-load 'message
  2463. (add-hook 'message-setup-hook
  2464. (lambda ()
  2465. (eproject-mode -1))))))
  2466. (use-package eww
  2467. :init (setq eww-bookmarks-directory
  2468. (expand-file-name "private/" emacs-d)))
  2469. (use-package haskell-mode
  2470. :config (progn
  2471. (add-hook 'haskell-mode-hook 'haskell-doc-mode)
  2472. (add-hook 'haskell-mode-hook 'turn-on-haskell-indent)
  2473. (add-hook 'haskell-mode-hook
  2474. (lambda ()
  2475. (company-mode +1)
  2476. (set (make-local-variable 'company-backends)
  2477. (append '((company-capf company-dabbrev-code))
  2478. company-backends))))
  2479. (add-hook 'haskell-mode-hook 'flycheck-mode)
  2480. (with-demoted-errors "Non-Fatal Error: %s"
  2481. (require 'haskell-indentation)
  2482. (add-hook 'haskell-mode-hook
  2483. 'haskell-indentation-mode))
  2484. (add-hook 'haskell-mode-hook
  2485. 'interactive-haskell-mode)))
  2486. (use-package markdown-mode
  2487. :ensure t
  2488. :commands (markdown-mode)
  2489. :init (progn
  2490. (setq markdown-use-pandoc-style-yaml-metadata t
  2491. markdown-command "pandoc --standalone")
  2492. (fset 'markdown-output-standalone-p #'(lambda () t))))
  2493. (use-package pdf-occur
  2494. :commands (pdf-occur-global-minor-mode))
  2495. (use-package pdf-tools
  2496. :commands (pdf-tools-install))
  2497. (use-package python
  2498. :config (progn
  2499. (add-hook 'python-mode-hook #'highlight-indentation-mode)
  2500. (add-hook 'python-mode-hook #'company-mode)
  2501. (add-hook 'python-mode-hook #'eglot-ensure)))
  2502. (use-package shr
  2503. :init (setq shr-use-fonts nil
  2504. shr-use-colors nil
  2505. shr-max-image-proportion 0.7
  2506. shr-image-animate nil
  2507. shr-width (current-fill-column)))
  2508. ;; Interactive interface to sdcv, the StarDict concole version. To use sdcv,
  2509. ;; put the dictionary data under ~/.stardict/dic.
  2510. (use-package sdcv
  2511. :commands (sdcv-search-pointer
  2512. sdcv-search-input))
  2513. (use-package sh-script
  2514. :init (setq sh-basic-offset 2))
  2515. (use-package timeline-tools
  2516. :load-path "site-lisp"
  2517. :commands (timeline-tools-format-timeline
  2518. timeline-tools-format-timeline-of-day
  2519. timeline-tools-copy-clocklines
  2520. timeline-tools-clockline-no-org-agenda-conflicts))
  2521. (use-package typing
  2522. :commands (typing-of-emacs)
  2523. :init (setq toe-highscore-file nil))
  2524. (use-package vlf
  2525. :ensure t
  2526. :commands (vlf))
  2527. (use-package which-key
  2528. :ensure t
  2529. :commands (which-key-mode)
  2530. :diminish which-key-mode
  2531. :init (setq which-key-side-window-max-width 0.33
  2532. which-key-side-window-max-height 0.25)
  2533. :config (which-key-setup-side-window-bottom))
  2534. ;; * Load customizations
  2535. (when (file-exists-p custom-file)
  2536. (load-file custom-file))
  2537. ;;; init.el ends here