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

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