nav.el 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. (defun wi-set-current-frame-80-40 ()
  2. "Set current frame to 80 pixels width and 40 pixels height."
  3. (interactive)
  4. (set-frame-size (selected-frame) 80 40))
  5. (defun wi-set-current-frame-80-24 ()
  6. "Set current frame to 80 pixels width and 24 pixels height."
  7. (interactive)
  8. (set-frame-size (selected-frame) 80 24))
  9. ;; Origin https://emacsredux.com/blog/2020/07/18/automatically-kill-running-processes-on-exit/
  10. (setq confirm-kill-processes nil)
  11. ;; Open buffer in vertical split by default
  12. (setq split-height-threshold nil)
  13. (setq split-width-threshold 140)
  14. ;; Origin <https://github.com/Wilfred/.emacs.d/blob/gh-pages/init.org>.
  15. (setq scroll-preserve-screen-position 'always) ; Preserve scroll pos.
  16. (setq dumb-jump-max-find-time 4)
  17. ;; Origin <https://github.com/Wilfred/.emacs.d/blob/gh-pages/init.org>.
  18. (setq enable-recursive-minibuffers t) ; Enable recursive minibuffer.
  19. ;; (with-eval-after-load 'tramp
  20. ;; (recentf-mode 1))
  21. (setq recentf-max-menu-items 30)
  22. (setq recentf-max-saved-items nil)
  23. (setq recentf-auto-cleanup 'never)
  24. ;; See <https://www.emacswiki.org/emacs/DoWhatIMean>
  25. (setq dired-dwim-target t)
  26. (add-hook 'diff-mode-hook (lambda () (setq-local truncate-lines t)))
  27. (setq dumb-jump-selector 'ivy)
  28. (setq dumb-jump-force-searcher 'ag)
  29. (autoload 'crux-transpose-windows "crux" nil t)
  30. (autoload 'crux-open-with "crux" nil t)
  31. (autoload 'stupid-indent-mode "stupid-indent-mode" nil t)
  32. ;; (global-undo-tree-mode)
  33. ;; (setq undo-tree-auto-save-history t)
  34. ;; (setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo")))
  35. ;; Default from Emacs 26
  36. ;; See <http://git.savannah.gnu.org/cgit/emacs.git/commit/etc/NEWS?id=72ee93d68daea00e2ee69417afd4e31b3145a9fa>
  37. (setq print-quoted t)
  38. ;; Enable functions
  39. (put 'narrow-to-page 'disabled nil)
  40. (put 'narrow-to-region 'disabled nil)
  41. (put 'set-goal-column 'disabled nil)
  42. (setq-default fill-column 78)
  43. (defun wi-switch-to-scratch-elisp ()
  44. "Switch to *scratch* buffer."
  45. (interactive)
  46. (switch-to-buffer "*scratch*"))
  47. (setq mouse-yank-at-point t) ; Ignore mouse position on paste
  48. (setq mouse-autoselect-window t) ; Sloppy mouse
  49. ; Unprettify symbol after the cursor
  50. (setq prettify-symbols-unprettify-at-point 'right-edge)
  51. (setq whitespace-style
  52. '(face tabs
  53. spaces
  54. trailing
  55. ;; lines
  56. space-before-tab
  57. newline
  58. indentation
  59. empty
  60. space-after-tab
  61. space-mark
  62. tab-mark
  63. ;; newline-mark
  64. ))
  65. (when (boundp #'hl-todo-mode)
  66. (add-hook 'prog-mode-hook 'hl-todo-mode))
  67. ;; (add-hook 'prog-mode-hook 'which-function-mode)
  68. (when (functionp #'symbol-overlay-mode)
  69. (add-hook 'prog-mode-hook 'symbol-overlay-mode))
  70. (when (functionp #'hideshowvis-minor-mode)
  71. (add-hook 'prog-mode-hook 'hideshowvis-minor-mode)
  72. (add-hook 'conf-javaprop-mode-hook 'hideshowvis-minor-mode))
  73. (setq wi-groups-direcotories-git t)
  74. (setq wi-groups-direcotories
  75. '("~/src/gitlab01.bqtstuff.com"
  76. "~/src/gitlab.intr"
  77. "~/src/anongit.gentoo.org"
  78. "~/src/ansible-cmdb-majordomo"
  79. "~/src/ansible-ping"
  80. "~/src/bento"
  81. "~/src/bitbucket.org"
  82. "~/src/cc"
  83. "~/src/cerb-js"
  84. "~/src/cgit.duckdns.org"
  85. "~/src/code.orgmode.org"
  86. "~/src/discord"
  87. "~/src/docker-nextcloud"
  88. "~/src/docker-stack-deploy-pipeline"
  89. "~/src/docker-tftp"
  90. "~/src/dwl"
  91. "~/src/elk"
  92. "~/src/elpa"
  93. "~/src/emacs-anywhere-mode"
  94. "~/src/emacs-guix-misc"
  95. "~/src/emacs-hydra-timestamp"
  96. "~/src/emacs-redshift"
  97. "~/src/emacs-wi-tabu-youtube"
  98. "~/src/emacs-wi-utils"
  99. "~/src/erza"
  100. "~/src/example-nodejs-app"
  101. "~/src/files-maintenance"
  102. "~/src/gesturefy"
  103. "~/src/git.archlinux.org"
  104. "~/src/git.dn42.dev"
  105. "~/src/github.com"
  106. "~/src/git.ispconfig.org"
  107. "~/src/git.kernel.org"
  108. "~/src/gitlab"
  109. "~/src/gitlab.com"
  110. "~/src/gitlab.intr"
  111. "~/src/gitlab.wugi.info"
  112. "~/src/git.net-core.org"
  113. "~/src/gitolite-admin"
  114. "~/src/git.php.net"
  115. "~/src/git.savannah.gnu.org"
  116. "~/src/git.savannah.nongnu.org"
  117. "~/src/git.slackbuilds.org"
  118. "~/src/git.sr.ht"
  119. "~/src/git.zabbix.com"
  120. "~/src/grafana"
  121. "~/src/guile-dovecot"
  122. "~/src/guile-feed"
  123. "~/src/guile-haunt"
  124. "~/src/guile-hello-rogue"
  125. "~/src/guile-remote"
  126. "~/src/guix-browse"
  127. "~/src/guix-eve-online"
  128. "~/src/guix-gtk"
  129. "~/src/guix-latest-eval"
  130. "~/src/guix-media"
  131. "~/src/guix-media-nonfree"
  132. "~/src/guix-wigust-workflow"
  133. "~/src/hello-agda"
  134. "~/src/hello-alerta"
  135. "~/src/hello-assembly"
  136. "~/src/hello-bash"
  137. "~/src/hello-c"
  138. "~/src/hello-cepl"
  139. "~/src/hello-chicken"
  140. "~/src/hello-clojure"
  141. "~/src/hello-coq"
  142. "~/src/hello-coredump"
  143. "~/src/hello-cpp"
  144. "~/src/hello-cuirass"
  145. "~/src/hello-gnu-accembly"
  146. "~/src/hello-go"
  147. "~/src/hello-godot"
  148. "~/src/hello-guile"
  149. "~/src/hello-gwl"
  150. "~/src/hello-haskell"
  151. "~/src/hello-karate"
  152. "~/src/hello-lisp"
  153. "~/src/hello-middleman"
  154. "~/src/hello-nightmarejs"
  155. "~/src/hello-nix"
  156. "~/src/hello-ocaml"
  157. "~/src/hello-php"
  158. "~/src/hello-polymer-app"
  159. "~/src/hello-rust"
  160. "~/src/hello-scheme"
  161. "~/src/hello-sdl"
  162. "~/src/hello-spring"
  163. "~/src/hello-zabbix"
  164. "~/src/home"
  165. "~/src/kube"
  166. "~/src/ledger"
  167. "~/src/lua"
  168. "~/src/majordomo-backup"
  169. "~/src/majordomo-help"
  170. "~/src/majordomo-maintenance"
  171. "~/src/majordomo-src"
  172. "~/src/majordomo-src-fool"
  173. "~/src/majordomo-tickets"
  174. "~/src/malware-scanner"
  175. "~/src/math"
  176. "~/src/monitoror"
  177. "~/src/mpv-scripts"
  178. "~/src/nixos-mailserver-flake"
  179. "~/src/nixpkgs-wigust"
  180. "~/src/noise"
  181. "~/src/opensearch"
  182. "~/src/paws"
  183. "~/src/pelzflorian.de"
  184. "~/src/python-nmap2json"
  185. "~/src/remote"
  186. "~/src/ssh-exporter"
  187. "~/src/ssl"
  188. "~/src/sup2eng"
  189. "~/src/tab-slideshow"
  190. "~/src/temp"
  191. "~/src/terraform-gitlab"
  192. "~/src/terraform-notabug"
  193. "~/src/tick"
  194. "~/src/tmp"
  195. "~/src/tome4-notes"
  196. "~/src/upwork-telethon"
  197. "~/src/wigust.github.io"
  198. "~/src/wigust-resume"
  199. "~/src/wireguard"
  200. "~/src/zabbix"
  201. "~/src/zabbix-aws"
  202. "~/src/zabbix-guix"))
  203. (setq wi-projects-directories '("~/src" "~/archive/src"))
  204. (defun wi-find-file-readlink ()
  205. (interactive)
  206. (let ((file-name (buffer-file-name)))
  207. (kill-buffer (current-buffer))
  208. (find-file
  209. (string-trim
  210. (shell-command-to-string
  211. (format "readlink -f %s" file-name))))))
  212. (add-hook 'find-file-hook
  213. '(lambda ()
  214. (when (string-match (rx (and any ".guix-profile")) (buffer-file-name))
  215. (wi-find-file-readlink))))
  216. (setq auto-insert-directory
  217. (expand-file-name "~/.emacs.d/insert"))
  218. (defalias 'center-mode 'olivetti-mode)
  219. ;; Show recursion depth.
  220. (progn
  221. (minibuffer-depth-indicate-mode)
  222. (when (boundp #'global-git-gutter-mode)
  223. (global-git-gutter-mode))
  224. (when (< emacs-major-version 29)
  225. (when (macrop #'bind-key)
  226. (bind-key "<C-mouse-4>" #'text-scale-increase)
  227. (bind-key "<C-mouse-5>" #'text-scale-decrease))
  228. (when (boundp #'default-text-scale-mode)
  229. (default-text-scale-mode)))
  230. (when (boundp #'projectile-mode)
  231. (projectile-global-mode))
  232. ;; Don't use ido
  233. (setq projectile-completion-system 'ivy)
  234. (when (boundp #'projectile-project-root-files)
  235. (add-to-list 'projectile-project-root-files "environment-variables"))
  236. (setq projectile-switch-project-action 'projectile-dired)
  237. (when (boundp #'projectile-mode-map)
  238. (define-key projectile-mode-map (kbd "C-c g p") 'projectile-command-map)
  239. (define-key projectile-mode-map (kbd "C-c g p h") 'helm-projectile))
  240. (when (boundp #'beginend-global-mode)
  241. (beginend-global-mode))
  242. (save-place-mode) ; Remember position in files
  243. ;; Toggle prettify symbols mode on
  244. (global-prettify-symbols-mode)
  245. ;; Undo and redo operations on windows and buffers
  246. (winner-mode 1)
  247. ;; (windmove-default-keybindings) ;XXX: Breaks vterm-mode-map
  248. ;; Display key bindings help window (after some delay)
  249. (when (boundp #'which-key-mode)
  250. (which-key-mode))
  251. ;; Toggle show-paren-mode on
  252. (show-paren-mode))
  253. ;; Emacs redraw issue in X.org on VMWare and VirtualBox | fujii.github.io
  254. ;; <https://fujii.github.io/2016/09/06/emacs-redisplay-issue-on-vmware/>
  255. (when (eq window-system 'x)
  256. (add-hook 'window-scroll-functions
  257. (lambda (&rest x)
  258. (run-with-idle-timer 0.5 nil 'redraw-display))))