Commit ef12080de9dd
Changed files (14)
config/00-vde-mode.el
@@ -1,59 +0,0 @@
-;;; -*- lexical-binding: t; -*-
-(defvar vde-special-keymap-prefix (kbd "C-x m")
- "`vde-mode' keymap prefix.
-Overrides the default binding for `compose-mail'.")
-
-(defvar vde-mode-special-map (make-sparse-keymap)
- "Special keymap for `vde-mode' whose bindings begin with
-`vde-special-keymap-prefix'.")
-(fset 'vde-mode-special-map vde-mode-special-map)
-
-(defvar vde-mode-map (let ((map (make-sparse-keymap)))
- (define-key map vde-special-keymap-prefix 'vde-mode-special-map)
- map)
- "Keymap for `vde-mode'.")
-
-;;;###autoload
-(define-minor-mode vde-mode
- "A minor mode so that my key settings override annoying major modes."
- ;; If init-value is not set to t, this mode does not get enabled in
- ;; `fundamental-mode' buffers even after doing \"(global-vde-mode 1)\".
- ;; More info: http://emacs.stackexchange.com/q/16693/115
- :init-value t
- :lighter " μ"
- :keymap vde-mode-map)
-
-;;;###autoload
-(define-globalized-minor-mode global-vde-mode vde-mode vde-mode)
-
-;; https://github.com/jwiegley/use-package/blob/master/bind-key.el
-;; The keymaps in `emulation-mode-map-alists' take precedence over
-;; `minor-mode-map-alist'
-(add-to-list 'emulation-mode-map-alists `((vde-mode . ,vde-mode-map)))
-
-;; Turn off the minor mode in the minibuffer
-(defun turn-off-vde-mode ()
- "Turn off vde-mode."
- (vde-mode -1))
-(add-hook 'minibuffer-setup-hook #'turn-off-vde-mode)
-
-(defmacro bind-to-vde-map (key fn)
- "Bind a function to the `vde-mode-special-map'.
-USAGE: (bind-to-vde-map \"f\" #'full-screen-center)."
- `(define-key vde-mode-special-map (kbd ,key) ,fn))
-
-;; http://emacs.stackexchange.com/a/12906/115
-(defun unbind-from-vde-map (key)
- "Unbind a function from the `vde-mode-map'
-USAGE: (unbind-from-vde-map \"C-x m f\")
-"
- (interactive "Unset key from vde-mode-map: ")
- (define-key vde-mode-map (kbd (key-description key)) nil)
- (message "%s" (format "Unbound %s key from the %s."
- (propertize (key-description key)
- 'face 'font-lock-function-name-face)
- (propertize "vde-mode-map"
- 'face 'font-lock-function-name-face))))
-
-(provide 'setup-vde-mode)
-;; Minor mode tutorial: http://nullprogram.com/blog/2013/02/06/
config/01-server.el
@@ -1,2 +1,8 @@
+;;; 01-server.el --- -*- lexical-binding: t -*-
+
+;; UseServer
(use-package server
:config (or (server-running-p) (server-mode)))
+;; -UseServer
+
+;;; 01-server.el ends here
config/setup-completion.el
@@ -14,22 +14,18 @@
(ivy-use-selectable-prompt t)
(ivy-fixed-height-minibuffer nil)
(ivy-extra-directories nil) ; Default value: ("../" "./")
- :bind (:map vde-mode-map
- ("C-x b" . vde/switch-buffer)
- ("C-x B" . ivy-switch-buffer)
- ("M-u" . ivy-resume) ;Override the default binding for `upcase-word'
- ("C-c C-w p" . ivy-push-view) ;Push window configuration to `ivy-views'
- ("C-c C-w P" . ivy-pop-view) ;Remove window configuration from `ivy-views'
- ("C-c C-w s" . ivy-switch-view) ; Switch window configuration to `ivy-views'
- :map ivy-occur-mode-map
- ("f" . forward-char)
- ("b" . backward-char)
- ("n" . ivy-occur-next-line)
- ("p" . ivy-occur-previous-line)
- ("<C-return>" . ivy-occur-press))
- :init
- (progn
- (bind-to-vde-map "v" #'counsel-set-variable))
+ :bind (("C-x b" . vde/switch-buffer)
+ ("C-x B" . ivy-switch-buffer)
+ ("M-u" . ivy-resume) ;Override the default binding for `upcase-word'
+ ("C-c C-w p" . ivy-push-view) ;Push window configuration to `ivy-views'
+ ("C-c C-w P" . ivy-pop-view) ;Remove window configuration from `ivy-views'
+ ("C-c C-w s" . ivy-switch-view) ; Switch window configuration to `ivy-views'
+ :map ivy-occur-mode-map
+ ("f" . forward-char)
+ ("b" . backward-char)
+ ("n" . ivy-occur-next-line)
+ ("p" . ivy-occur-previous-line)
+ ("<C-return>" . ivy-occur-press))
:hook
(ivy-occur-mode . hl-line-mode)
:config
@@ -72,91 +68,29 @@ Otherwise, use `counsel-projectile-switch-project'."
"\\(?:\\`[#.]\\)"
;; file names ending with # or ~
"\\|\\(?:[#~]\\'\\)"))
- :bind (:map vde-mode-map
- ("M-i" . counsel-semantic-or-imenu)
- ;;("M-i" . counsel-grep-or-swiper)
- ("C-x C-r" . counsel-recentf)
- ("C-M-y" . counsel-yank-pop)
- ("C-h F" . counsel-faces) ;Overrides `Info-goto-emacs-command-node'
- ("C-h S" . counsel-info-lookup-symbol)
- ("C-c u" . counsel-unicode-char)
- ("C-c C" . counsel-colors-emacs) ;Alternative to `list-colors-display'
- ([remap execute-extended-command] . counsel-M-x)
- ([remap bookmark-jump] . counsel-bookmark) ;Jump to book or set it if it doesn't exist, C-x r b
- ([remap bookmark-set] . counsel-bookmark) ;C-x r m
- ([remap find-file] . counsel-find-file)
- ([remap describe-bindings] . counsel-descbinds)
- ([remap finder-by-keyword] . counsel-package) ;C-h p
- ([remap describe-variable] . counsel-describe-variable)
- ([remap describe-function] . counsel-describe-function)
- ("M-s r" . counsel-rg)
- ("M-s g" . counsel-git-grep)
- ("M-s z" . prot/counsel-fzf-rg-files)
- :map ivy-minibuffer-map
- ("C-r" . counsel-minibuffer-history)
- ("C-SPC" . ivy-restrict-to-matches))
- :init
- (progn
- (bind-to-vde-map "s" #'counsel-rg))
+ :bind (("M-i" . counsel-semantic-or-imenu)
+ ("C-x C-r" . counsel-recentf)
+ ("C-M-y" . counsel-yank-pop)
+ ("C-h F" . counsel-faces) ;Overrides `Info-goto-emacs-command-node'
+ ("C-h S" . counsel-info-lookup-symbol)
+ ("C-c u" . counsel-unicode-char)
+ ("C-c C" . counsel-colors-emacs) ;Alternative to `list-colors-display'
+ ([remap execute-extended-command] . counsel-M-x)
+ ([remap bookmark-jump] . counsel-bookmark) ;Jump to book or set it if it doesn't exist, C-x r b
+ ([remap bookmark-set] . counsel-bookmark) ;C-x r m
+ ([remap find-file] . counsel-find-file)
+ ([remap describe-bindings] . counsel-descbinds)
+ ([remap finder-by-keyword] . counsel-package) ;C-h p
+ ([remap describe-variable] . counsel-describe-variable)
+ ([remap describe-function] . counsel-describe-function)
+ ("M-s r" . counsel-rg)
+ ("M-s g" . counsel-git-grep)
+ ("M-s z" . prot/counsel-fzf-rg-files)
+ :map ivy-minibuffer-map
+ ("C-r" . counsel-minibuffer-history)
+ ("C-SPC" . ivy-restrict-to-matches))
:config
(progn
- (defun prot/counsel-fzf-rg-files (&optional input dir)
- "Run `fzf' in tandem with `ripgrep' to find files in the
-present directory. If invoked from inside a version-controlled
-repository, then the corresponding root is used instead."
- (interactive)
- (let* ((process-environment
- (cons (concat "FZF_DEFAULT_COMMAND=rg -Sn --color never --files --no-follow --hidden")
- process-environment))
- (vc (vc-root-dir)))
- (if dir
- (counsel-fzf input dir)
- (if (eq vc nil)
- (counsel-fzf input default-directory)
- (counsel-fzf input vc)))))
-
- (defun prot/counsel-fzf-dir (arg)
- "Specify root directory for `counsel-fzf'."
- (prot/counsel-fzf-rg-files ivy-text
- (read-directory-name
- (concat (car (split-string counsel-fzf-cmd))
- " in directory: "))))
-
- (defun prot/counsel-rg-dir (arg)
- "Specify root directory for `counsel-rg'."
- (let ((current-prefix-arg '(4)))
- (counsel-rg ivy-text nil "")))
-
- ;; TODO generalise for all relevant file/buffer counsel-*?
- (defun prot/counsel-fzf-ace-window (arg)
- "Use `ace-window' on `prot/counsel-fzf-rg-files' candidate."
- (ace-window t)
- (let ((default-directory (if (eq (vc-root-dir) nil)
- counsel--fzf-dir
- (vc-root-dir))))
- (if (> (length (aw-window-list)) 1)
- (progn
- (find-file arg))
- (find-file-other-window arg))
- (balance-windows)))
-
- ;; Pass functions as appropriate Ivy actions (accessed via M-o)
- (ivy-add-actions
- 'counsel-fzf
- '(("r" prot/counsel-fzf-dir "change root directory")
- ("g" prot/counsel-rg-dir "use ripgrep in root directory")
- ("a" prot/counsel-fzf-ace-window "ace-window switch")))
-
- (ivy-add-actions
- 'counsel-rg
- '(("r" prot/counsel-rg-dir "change root directory")
- ("z" prot/counsel-fzf-dir "find file with fzf in root directory")))
-
- (ivy-add-actions
- 'counsel-find-file
- '(("g" prot/counsel-rg-dir "use ripgrep in root directory")
- ("z" prot/counsel-fzf-dir "find file with fzf in root directory")))
-
(ivy-set-actions
'counsel-find-file
`(("x"
config/setup-multiple-cursors.el
@@ -1,6 +1,4 @@
(use-package multiple-cursor
- :bind (:map vde-mode-map
- ("C-S-c C-S-c" . mc/edit-lines))
:bind (:map region-bindings-mode-map
("a" . mc/mark-all-like-this)
("p" . mc/mark-previous-like-this)
config/setup-org.el
@@ -86,7 +86,10 @@
(setq fill-column 90)
(auto-revert-mode)
(auto-fill-mode)
- (org-indent-mode)))
+ (org-indent-mode)
+ (add-hook 'after-save-hook #'save-and-update-includes nil 'make-it-local)))
+
+;; (add-hook 'before-save-hook #'save-and-update-includes)
(use-package org-id
:after (org)
@@ -304,13 +307,9 @@
(use-package ox-hugo
:after ox
:commands (org-hugo-slug)
- :bind (:map vde-mode-map
- ("C-c G" . org-hugo-export-wim-to-md))
:config
(use-package ox-hugo-auto-export))
-;;; -*- lexical-binding: t; -*-
-
(use-package org
:defer t
:ensure org-plus-contrib
config/setup-shells.el
@@ -9,20 +9,7 @@
("<tab>" . completion-at-point)))
:config
(unbind-key "C-c C-l" shell-mode-map)
- (bind-key "C-c C-l" #'counsel-shell-history shell-mode-map)
-
- (defun vde/comint-delchar-or-eof-or-kill-buffer (arg)
- "Restore window configuration if process is dead, otherwise delete ARG."
- (interactive "p")
- (if (null (get-buffer-process (current-buffer)))
- (vde/pop-window-configuration)
- (comint-delchar-or-maybe-eof arg)))
-
- (add-hook 'shell-mode-hook
- (lambda ()
- (bind-key "C-d" #'vde/comint-delchar-or-eof-or-kill-buffer
- shell-mode-map)))
- )
+ (bind-key "C-c C-l" #'counsel-shell-history shell-mode-map))
(use-package eshell ; Emacs command shell
:bind* ("C-x m t" . eshell-here)
config/setup-web.el
@@ -1,35 +1,35 @@
-;;; -*- lexical-binding: t; -*-
-(use-package web-mode
- :mode
- ("\\.html\\'" . web-mode)
- ("\\.phtml\\'" . web-mode)
- ("\\.[agj]sp\\'" . web-mode)
- ("\\.as[cp]x\\'" . web-mode)
- ("\\.erb\\'" . web-mode)
- ("\\.mustache\\'" . web-mode)
- ("\\.djhtml\\'" . web-mode)
- ("\\.jsp\\'" . web-mode)
- ("\\.eex\\'" . web-mode)
- ("\\.tsx\\'" . web-mode)
- :config
- (setq web-mode-attr-indent-offset 2)
- (setq web-mode-code-indent-offset 2)
- (setq web-mode-css-indent-offset 2)
- (setq web-mode-indent-style 2)
- (setq web-mode-markup-indent-offset 2)
- (setq web-mode-sql-indent-offset 2)
- (eval-after-load 'smartparens
- (lambda ()
- (setq web-mode-enable-auto-pairing nil)
- (sp-with-modes '(web-mode)
- (sp-local-pair "%" "%"
- :unless '(sp-in-string-p)
- :post-handlers '(((lambda (&rest _ignored)
- (just-one-space)
- (save-excursion (insert " ")))
- "SPC" "=" "#")))
- (sp-local-tag "%" "<% " " %>")
- (sp-local-tag "=" "<%= " " %>")
- (sp-local-tag "#" "<%# " " %>")))))
-
-(provide 'setup-web)
+(if *sys/full*
+ (progn
+ (use-package web-mode
+ :mode
+ ("\\.html\\'" . web-mode)
+ ("\\.phtml\\'" . web-mode)
+ ("\\.[agj]sp\\'" . web-mode)
+ ("\\.as[cp]x\\'" . web-mode)
+ ("\\.erb\\'" . web-mode)
+ ("\\.mustache\\'" . web-mode)
+ ("\\.djhtml\\'" . web-mode)
+ ("\\.jsp\\'" . web-mode)
+ ("\\.eex\\'" . web-mode)
+ ("\\.tsx\\'" . web-mode)
+ :config
+ (setq web-mode-attr-indent-offset 2)
+ (setq web-mode-code-indent-offset 2)
+ (setq web-mode-css-indent-offset 2)
+ (setq web-mode-indent-style 2)
+ (setq web-mode-markup-indent-offset 2)
+ (setq web-mode-sql-indent-offset 2)
+ (eval-after-load 'smartparens
+ (lambda ()
+ (setq web-mode-enable-auto-pairing nil)
+ (sp-with-modes '(web-mode)
+ (sp-local-pair "%" "%"
+ :unless '(sp-in-string-p)
+ :post-handlers '(((lambda (&rest _ignored)
+ (just-one-space)
+ (save-excursion (insert " ")))
+ "SPC" "=" "#")))
+ (sp-local-tag "%" "<% " " %>")
+ (sp-local-tag "=" "<%= " " %>")
+ (sp-local-tag "#" "<%# " " %>")))))
+ ))
config/setup-windows.el
@@ -31,22 +31,6 @@
;; The function does not expect arguments
(t (funcall func))))
-(defun vde/restore-window-configuration (config)
- "Kill current buffer and restore the window configuration in CONFIG."
- (interactive)
- (kill-this-buffer)
- (set-window-configuration config))
-
-(defun vde/pop-window-configuration ()
- "Restore the previous window configuration and clear current window."
- (interactive)
- (let ((config (pop vde/saved-window-configuration)))
- (if config
- (vde/restore-window-configuration config)
- (if (> (length (window-list)) 1)
- (delete-window)
- (bury-buffer)))))
-
(use-package eyebrowse ; Easy workspaces creation and switching
:init (eyebrowse-mode t)
:config
lisp/init-func.el
@@ -0,0 +1,53 @@
+;;; init-func.el --- -*- lexical-binding: t -*-
+;;
+;; OrgIncludeAuto
+;; https://endlessparentheses.com/updating-org-mode-include-statements-on-the-fly.html
+(defun save-and-update-includes ()
+ "Update the line numbers of #+INCLUDE:s in current buffer.
+Only looks at INCLUDEs that have either :range-begin or :range-end.
+This function does nothing if not in `org-mode', so you can safely
+add it to `before-save-hook'."
+ (interactive)
+ (when (derived-mode-p 'org-mode)
+ (save-excursion
+ (goto-char (point-min))
+ (while (search-forward-regexp
+ "^\\s-*#\\+INCLUDE: *\"\\([^\"]+\\)\".*:range-\\(begin\\|end\\)"
+ nil 'noerror)
+ (let* ((file (expand-file-name (match-string-no-properties 1)))
+ lines begin end)
+ (forward-line 0)
+ (when (looking-at "^.*:range-begin *\"\\([^\"]+\\)\"")
+ (setq begin (match-string-no-properties 1)))
+ (when (looking-at "^.*:range-end *\"\\([^\"]+\\)\"")
+ (setq end (match-string-no-properties 1)))
+ (setq lines (decide-line-range file begin end))
+ (when lines
+ (if (looking-at ".*:lines *\"\\([-0-9]+\\)\"")
+ (replace-match lines :fixedcase :literal nil 1)
+ (goto-char (line-end-position))
+ (insert " :lines \"" lines "\""))))))))
+
+(add-hook 'before-save-hook #'save-and-update-includes)
+
+(defun decide-line-range (file begin end)
+ "Visit FILE and decide which lines to include.
+BEGIN and END are regexps which define the line range to use."
+ (let (l r)
+ (save-match-data
+ (with-temp-buffer
+ (insert-file-contents file)
+ (goto-char (point-min))
+ (if (null begin)
+ (setq l "")
+ (search-forward-regexp begin)
+ (setq l (line-number-at-pos (match-beginning 0))))
+ (if (null end)
+ (setq r "")
+ (search-forward-regexp end)
+ (setq r (1+ (line-number-at-pos (match-end 0)))))
+ (format "%s-%s" (+ l 1) (- r 1)))))) ;; Exclude wrapper
+;; -OrgIncludeAuto
+
+(provide 'init-func)
+;;; init-func.el ends here
_setup.org
@@ -1,14 +1,7 @@
-#+AUTHOR: Vincent Demeester
-#+EMAIL: vincent@sbr.pm
-#+EXPORT_EXCLUDE_TAGS: noexport
+
#+STARTUP: showall
#+OPTIONS: ':t *:t -:t ::t <:t H:3 \n:nil ^:t arch:headline author:t c:nil
#+OPTIONS: creator:comment d:(not LOGBOOK) date:t e:t email:nil f:t inline:nil
#+OPTIONS: num:t p:nil pri:t stat:t tags:t tasks:t tex:t timestamp:t toc:nil
#+OPTIONS: todo:t |:t
-#+CREATOR: Emacs 27.0.90 (Org mode 9.3)
-#+LANGUAGE: en
-
-#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="./notes.css"/>
-#+OPTIONS: html-style:nil
early-init.el
@@ -1,21 +1,34 @@
+;;; early-init.el --- -*- lexical-binding: t -*-
+;; PkgStartup
(setq package-enable-at-startup nil)
+;; -PkgStartup
+;; FrameResize
(setq frame-inhibit-implied-resize t)
+;; -FrameResize
+;; DisableUI
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(horizontal-scroll-bar-mode -1)
+;; -DisableUI
+;; GarbageCollection
(setq gc-cons-threshold 402653184
gc-cons-percentage 0.6)
+;; -GarbageCollection
+;; FileNameHandler
(defvar file-name-handler-alist-original file-name-handler-alist)
(setq file-name-handler-alist nil)
+;; -FileNameHandler
+;; AfterInitHook
(add-hook 'after-init-hook
`(lambda ()
(setq gc-cons-threshold 67108864 ; 64mb
gc-cons-percentage 0.1
file-name-handler-alist file-name-handler-alist-original)
(garbage-collect)) t)
+;; -AfterInitHook
emacs.org
@@ -1,5 +1,11 @@
-#+SETUPFILE: ./_setup.org
#+TITLE: Vincent Demeester's .emacs.d
+#+AUTHOR: Vincent Demeester
+#+EMAIL: vincent@sbr.pm
+#+EXPORT_EXCLUDE_TAGS: noexport
+#+CREATOR: Emacs 27.0.90 (Org mode 9.3)
+#+LANGUAGE: en
+#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="./notes.css"/>
+#+OPTIONS: html-style:nil
#+TOC: headlines 3
@@ -185,109 +191,62 @@
calling `package-initialize'. Emacs 27 changed the default behavior: It now calls
`package-initialize' before loading the init file.
- #+begin_src emacs-lisp :tangle early-init.el
- (setq package-enable-at-startup nil)
- #+end_src
+ #+INCLUDE: "./early-init.el" src emacs-lisp :range-begin "PkgStartup" :range-end "-PkgStartup" :lines "3-4"
- Let's inhibit resizing the frame at early stage.
- #+begin_src emacs-lisp :tangle early-init.el
- (setq frame-inhibit-implied-resize t)
- #+end_src
+ #+INCLUDE: "./early-init.el" src emacs-lisp :range-begin "FrameResize" :range-end "-FrameResize" :lines "7-8"
- I never use the /menu-bar/, or the /tool-bar/ or even the /scroll-bar/, so we can safely
disable those very very early.
- #+begin_src emacs-lisp :tangle early-init.el
- (menu-bar-mode -1)
- (tool-bar-mode -1)
- (scroll-bar-mode -1)
- (horizontal-scroll-bar-mode -1)
- #+end_src
+ #+INCLUDE: "./early-init.el" src emacs-lisp :range-begin "DisableUI" :range-end "-DisableUI" :lines "11-15"
- Finally we can try to avoid garbage collection at startup. The garbage collector can
easily double startup time, so we suppress it at startup by turning up ~gc-cons-threshold~
(and perhaps ~gc-cons-percentage~) temporarily.
- #+begin_src emacs-lisp :tangle early-init.el
- (setq gc-cons-threshold 402653184
- gc-cons-percentage 0.6)
- #+end_src
+ #+INCLUDE: "./early-init.el" src emacs-lisp :range-begin "GarbageCollection" :range-end "-GarbageCollection" :lines "18-20"
- Another small optimization concerns on =file-name-handler-alist= : on every .el and .elc
file loaded during start up, it has to runs those regexps against the filename ; setting
it to ~nil~ and after initialization finished put the value back make the initialization
process quicker.
- #+begin_src emacs-lisp :tangle early-init.el
- (defvar file-name-handler-alist-original file-name-handler-alist)
- (setq file-name-handler-alist nil)
- #+end_src
+ #+INCLUDE: "./early-init.el" src emacs-lisp :range-begin "FileNameHandler" :range-end "-FileNameHandler" :lines "23-25"
However, it is important to reset it eventually. Not doing so will cause garbage
collection freezes during long-term interactive use. Conversely, a ~gc-cons-threshold~
that is too small will cause stuttering.
- #+begin_src emacs-lisp :tangle early-init.el
- (add-hook 'after-init-hook
- `(lambda ()
- (setq gc-cons-threshold 67108864 ; 64mb
- gc-cons-percentage 0.1
- file-name-handler-alist file-name-handler-alist-original)
- (garbage-collect)) t)
- #+end_src
+ #+INCLUDE: "./early-init.el" src emacs-lisp :range-begin "AfterInitHook" :range-end "-AfterInitHook" :lines "28-34"
One thing though, I am currently not necessarily running Emacs 27, so I am going to need
to have the same configuration in ~init.el~ for a little bit of time.
/Note: the lowest emacs version I wanna support is 26 (as of today, might evolve)/
-#+begin_src emacs-lisp :tangle init.el
-;;; -*- lexical-binding: t; -*-
-(let ((minver 26))
- (unless (>= emacs-major-version minver)
- (error "Your Emacs is too old -- this configuration requires v%s or higher" minver)))
-
-(defconst emacs-start-time (current-time))
-
-;; load early-init.el before Emacs 27.0
-(unless (>= emacs-major-version 27)
- (message "Early init: Emacs Version < 27.0")
- (load (expand-file-name "early-init.el" user-emacs-directory)))
-#+end_src
+#+INCLUDE: "./init.el" src emacs-lisp :range-begin "CheckVer" :range-end "-CheckVer" :lines "3-13"
We also want our configuration to be working the same on any computer, this means we want
to define every option by ourselves, not relying on default files (~default.el~) that
would be set by our distribution. This is where =inhibit-default-init= comes into play,
setting it to non-nil inhibit loading the ~default~ library.
-#+begin_src emacs-lisp :tangle init.el
-(setq inhibit-default-init t) ; Disable the site default settings
-#+end_src
-
We also want to inhibit some initial default start messages and screen. The default screen
will be as bare as possible.
-#+begin_src emacs-lisp :tangle init.el
-(setq inhibit-startup-message t
- inhibit-startup-screen t)
-#+end_src
+#+INCLUDE: "./init.el" src emacs-lisp :range-begin "Inhibit" :range-end "-Inhibit" :lines "16-20"
Let's also use =y= or =n= instead of =yes= and =no= when exiting Emacs.
-#+begin_src emacs-lisp :tangle init.el
-(setq confirm-kill-emacs #'y-or-n-p)
-#+end_src
-
+#+INCLUDE: "./init.el" src emacs-lisp :range-begin "Confirm" :range-end "-Confirm" :lines "23-24"
One last piece to the puzzle is the default mode. Setting it to fundamental-mode means we
won't load any /heavy/ mode at startup (like =org-mode=). We also want this scratch buffer
to be empty, so let's set it as well
-#+begin_src emacs-lisp :tangle init.el
-(setq initial-major-mode 'fundamental-mode
- initial-scratch-message nil)
-#+end_src
+#+INCLUDE: "./init.el" src emacs-lisp :range-begin "DefaultMode" :range-end "-DefaultMode" :lines "27-29"
*** Unicode all the way
:PROPERTIES:
@@ -297,13 +256,7 @@
By default, all my systems are configured and support =utf-8=, so let's just make it a
default in Emacs ; and handle special case on demand.
-#+begin_src emacs-lisp :tangle init.el
-(prefer-coding-system 'utf-8)
-(set-default-coding-systems 'utf-8)
-(set-language-environment 'utf-8)
-(set-selection-coding-system 'utf-8)
-(set-terminal-coding-system 'utf-8)
-#+end_src
+#+INCLUDE: "./init.el" src emacs-lisp :range-begin "Unicode" :range-end "-Unicode" :lines "32-37"
*** Package management with =use-package=
:PROPERTIES:
@@ -329,58 +282,7 @@
We need to setup the emacs package system and install =use-package= if not present
already.
-#+begin_src emacs-lisp :tangle init.el
-;;; package setup
-(require 'package)
-
-(setq package-archives
- '(("melpa" . "http://melpa.org/packages/")
- ("org" . "https://orgmode.org/elpa/")
- ("gnu" . "https://elpa.gnu.org/packages/")))
-
-(setq package-archive-priorities
- '(("melpa" . 3)
- ("org" . 2)
- ("gnu" . 1)))
-
-(require 'tls)
-
-;; From https://github.com/hlissner/doom-emacs/blob/5dacbb7cb1c6ac246a9ccd15e6c4290def67757c/core/core-packages.el#L102
-(setq gnutls-verify-error (not (getenv "INSECURE")) ; you shouldn't use this
- tls-checktrust gnutls-verify-error
- tls-program (list "gnutls-cli --x509cafile %t -p %p %h"
- ;; compatibility fallbacks
- "gnutls-cli -p %p %h"
- "openssl s_client -connect %h:%p -no_ssl2 -no_ssl3 -ign_eof"))
-
-;; Initialise the packages, avoiding a re-initialisation.
-(unless (bound-and-true-p package--initialized)
- (setq package-enable-at-startup nil)
- (package-initialize))
-
-(setq load-prefer-newer t) ; Always load newer compiled files
-(setq ad-redefinition-action 'accept) ; Silence advice redefinition warnings
-
-;; Init `delight'
-(unless (package-installed-p 'delight)
- (package-refresh-contents)
- (package-install 'delight))
-
-;; Configure `use-package' prior to loading it.
-(eval-and-compile
- (setq use-package-always-ensure nil)
- (setq use-package-always-defer nil)
- (setq use-package-always-demand nil)
- (setq use-package-expand-minimally nil)
- (setq use-package-enable-imenu-support t))
-
-(unless (package-installed-p 'use-package)
- (package-refresh-contents)
- (package-install 'use-package))
-
-(eval-when-compile
- (require 'use-package))
-#+end_src
+#+INCLUDE: "./init.el" src emacs-lisp :range-begin "UsePackageSetup" :range-end "-UsePackageSetup" :lines "40-89"
*** =custom.el=
:PROPERTIES:
@@ -391,23 +293,7 @@
your liking, Emacs will append a piece of elisp to your init file. I prefer to have that
stored in a separate file.
-#+begin_src emacs-lisp :tangle init.el
-(defconst vde/custom-file (locate-user-emacs-file "custom.el")
- "File used to store settings from Customization UI.")
-
-(use-package cus-edit
- :config
- (setq
- custom-file vde/custom-file
- custom-buffer-done-kill nil ; Kill when existing
- custom-buffer-verbose-help nil ; Remove redundant help text
- custom-unlispify-tag-names nil ; Show me the real variable name
- custom-unlispify-menu-entries nil)
- (unless (file-exists-p custom-file)
- (write-region "" nil custom-file))
-
- (load vde/custom-file 'no-error 'no-message))
-#+end_src
+#+INCLUDE: "./init.el" src emacs-lisp :range-begin "CustomFile" :range-end "-CustomFile" :lines "92-107"
*** Remove built-in =org-mode=
:PROPERTIES:
@@ -418,26 +304,14 @@
configuration) instead of the built-in one. To do that safely, let's remove the built-in
version out of the load path.
-#+begin_src emacs-lisp :tangle init.el
-(require 'cl-seq)
-(setq load-path
- (cl-remove-if
- (lambda (x)
- (string-match-p "org$" x))
- load-path))
-#+end_src
+#+INCLUDE: "./init.el" src emacs-lisp :range-begin "NoBuiltinOrg" :range-end "-NoBuiltinOrg" :lines "110-116"
*** Pinentry
:PROPERTIES:
:CUSTOM_ID: h:1f016a1a-f4ef-4ef0-be01-1fd68ca0d951
:END:
-#+begin_src emacs-lisp :tangle init.el
-(use-package pinentry
- :config
- (setenv "INSIDE_EMACS" (format "%s,comint" emacs-version))
- (pinentry-start))
-#+end_src
+#+INCLUDE: "./init.el" src emacs-lisp :range-begin "Pinentry" :range-end "-PinEntry" :lines "119-123"
*** Loading configuration files
:PROPERTIES:
@@ -454,90 +328,29 @@
Let's define some functions that would do the job.
-#+begin_src emacs-lisp :tangle init.el
-(defun vde/el-load-dir (dir)
- "Load el files from the given folder"
- (let ((files (directory-files dir nil "\.el$")))
- (while files
- (load-file (concat dir (pop files))))))
-
-(defun vde/short-hostname ()
- "Return hostname in short (aka wakasu.local -> wakasu)"
- (string-match "[0-9A-Za-z-]+" system-name)
- (substring system-name (match-beginning 0) (match-end 0)))
-#+end_src
+#+INCLUDE: "./init.el" src emacs-lisp :range-begin "LoadCfgFunc" :range-end "-LoadCfgFunc" :lines "126-136"
Let's define some constants early, based on the system, and the environment, to be able to
use those later on to skip some package or change some configuration accordingly.
-#+begin_src emacs-lisp :tangle init.el
-(defconst *sys/gui*
- (display-graphic-p)
- "Are we running on a GUI Emacs ?")
-(defconst *sys/linux*
- (eq system-type 'gnu/linux)
- "Are we running on a GNU/Linux system?")
-(defconst *sys/mac*
- (eq system-type 'darwin)
- "Are we running on a Mac system?")
-(defconst *sys/root*
- (string-equal "root" (getenv "USER"))
- "Are you a ROOT user?")
-(defconst *nix*
- (executable-find "nix")
- "Do we have nix? (aka are we running in NixOS or a system using nixpkgs)")
-(defconst *rg*
- (executable-find "rg")
- "Do we have ripgrep?")
-(defconst *gcc*
- (executable-find "gcc")
- "Do we have gcc?")
-(defconst *git*
- (executable-find "git")
- "Do we have git?")
-
-(defvar *sys/full*
- (member (vde/short-hostname) '("wakasu")) ; "naruhodo" <- put naruhodo back in
- "Is it a full system ?")
-(defvar *sys/light*
- (not *sys/full*)
- "Is it a light system ?")
-#+end_src
+#+INCLUDE: "./init.el" src emacs-lisp :range-begin "CfgConstant" :range-end "-CfgConstant" :lines "139-170"
Now, in order to load ~lisp~ and ~config~ files, it's just a matter of calling this
function with the right argument.
-#+begin_src emacs-lisp :tangle init.el
-(add-to-list 'load-path (concat user-emacs-directory "lisp/"))
-(vde/el-load-dir (concat user-emacs-directory "/config/"))
-#+end_src
+#+INCLUDE: "./init.el" src emacs-lisp :range-begin "CfgLoad" :range-end "-CfgLoad" :lines "173-176"
Finally, I want to be able to load files for a specific machine, in case I need it (not
entirely sure why yet but…)
-#+begin_src emacs-lisp :tangle init.el
-(if (file-exists-p (downcase (concat user-emacs-directory "/hosts/" (vde/short-hostname) ".el")))
- (load-file (downcase (concat user-emacs-directory "/hosts/" (vde/short-hostname) ".el"))))
-#+end_src
+#+INCLUDE: "./init.el" src emacs-lisp :range-begin "CfgHostLoad" :range-end "-CfgHostLoad" :lines "179-181"
*** Counting the time of loading
:PROPERTIES:
:CUSTOM_ID: h:2b645e95-6776-4f5b-a318-e5a915943881
:END:
-#+begin_src emacs-lisp :tangle init.el
-(let ((elapsed (float-time (time-subtract (current-time)
- emacs-start-time))))
- (message "Loading %s...done (%.3fs)" load-file-name elapsed))
-
-(add-hook 'after-init-hook
- `(lambda ()
- (let ((elapsed
- (float-time
- (time-subtract (current-time) emacs-start-time))))
- (message "Loading %s...done (%.3fs) [after-init]"
- ,load-file-name elapsed))) t)
-#+end_src
+#+INCLUDE: "./init.el" src emacs-lisp :range-begin "LastInit" :range-end "-LastInit" :lines "184-195"
** ~PATH~'s customization
:PROPERTIES:
@@ -674,17 +487,13 @@
** Server mode
:PROPERTIES:
-:header-args: :tangle config/01-server.el
:CUSTOM_ID: h:51ffd089-63c6-4ba6-8cc5-4c888521ef3a
:END:
My current setup involves a =emacs --daemon= systemd service. We want to start the server
if it's not already running, so that =emacsclient= can connect to it.
-#+begin_src emacs-lisp
-(use-package server
- :config (or (server-running-p) (server-mode)))
-#+end_src
+#+INCLUDE: "./config/01-server.el" src emacs-lisp :range-begin "UseServer" :range-end "-UseServer" :lines "4-6"
* TODO Selection candidates and search methods
:PROPERTIES:
@@ -1366,8 +1175,6 @@
(use-package ox-hugo
:after ox
:commands (org-hugo-slug)
- :bind (:map vde-mode-map
- ("C-c G" . org-hugo-export-wim-to-md))
:config
(use-package ox-hugo-auto-export))
#+end_src
@@ -1877,6 +1684,8 @@
[[att:2020-03-03-21-57-41.png]]
+#+INCLUDE: lisp/shortbrain-light-theme.el src emacs-lisp
+
See [[https://github.com/vdemeester/emacs-config/blob/master/lisp/shortbrain-light-theme.el][=lisp/shortbrain-light-theme.el=]].
**** Dark theme
@@ -1888,6 +1697,8 @@
[[att:2020-03-03-21-59-22.png]]
+#+INCLUDE: lisp/shortbrain-theme.el src emacs-lisp
+
See [[https://github.com/vdemeester/emacs-config/blob/master/lisp/shortbrain-theme.el][=lisp/shortbrain-theme.el=]].
* TODO Programming
@@ -1895,2719 +1706,6 @@
:CUSTOM_ID: h:635a27c4-5ff9-46e4-8d42-283d316cf4d6
:END:
-* Legacy
-:PROPERTIES:
-:CUSTOM_ID: h:9e392a26-fe69-4156-910f-fb1911fd8924
-:END:
-
-This holds legacy code from the previous configuration (without org-mode). This will
-slowly but surely move into an org-mode header and or disappear.
-
-** Configurations
-:PROPERTIES:
-:CUSTOM_ID: h:2227a24c-90e4-4544-bbf0-c123122e3b39
-:END:
-
-These are the initial configuration files to be imported in this file slowly but surely.
-
-*** ~setup-buffers.el~
-:PROPERTIES:
-:CUSTOM_ID: h:98200f45-7379-42e7-be0d-7db52cd950c8
-:END:
-
-#+begin_src emacs-lisp :tangle config/setup-buffers.el
-;;; -*- lexical-binding: t; -*-
-;; Don't let the cursor go into minibuffer prompt
-(let ((default (eval (car (get 'minibuffer-prompt-properties 'standard-value))))
- (dont-touch-prompt-prop '(cursor-intangible t)))
- (setq minibuffer-prompt-properties
- (append default dont-touch-prompt-prop))
- (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode))
-
-;; Allow to read from minibuffer while in minibuffer.
-(setq enable-recursive-minibuffers t)
-
-;; Show the minibuffer depth (when larger than 1)
-(minibuffer-depth-indicate-mode 1)
-
-(use-package savehist ; Save minibuffer history
- :init (savehist-mode t)
- :custom
- (history-length 1000)
- (savehist-save-minibuffer-history t)
- (savehist-autosave-interval 180)
- :config
- (savehist-mode 1))
-
-(use-package emacs
- :init
- ;; Configure `display-buffer' behaviour for some special buffers
- (setq display-buffer-alist
- '(;; bottom side window
- ("\\*e?shell.*"
- (display-buffer-in-side-window)
- (window-height . 0.25)
- (side . bottom)
- (slot . -1))
- ("\\*v?term.*"
- (display-buffer-in-side-window)
- (window-height . 0.25)
- (side . bottom)
- (slot . -1))
- ("\\*\\(Backtrace\\|Warnings\\|Compile-Log\\|[Hh]elp\\|Messages\\)\\*"
- (display-buffer-in-side-window)
- (window-height . 0.25)
- (side . bottom)
- (slot . 0))
- ("\\*\\(helpful\\).*"
- (display-buffer-in-side-window)
- (window-height . 0.25)
- (side . bottom)
- (slot . 0))
- ("\\*\\(compilation\\|go test\\).*"
- (display-buffer-in-side-window)
- (window-height . 0.25)
- (side . bottom)
- (slot . 0))
- ("\\*\\(ielm\\).*"
- (display-buffer-in-side-window)
- (window-height . 0.25)
- (side . bottom)
- (slot . 1))
- ;; right side window
- ("\\*wclock*"
- (display-buffer-in-side-window)
- (window-width . 0.20)
- (side . right)
- (slot . -1))
- ("\\*undo-tree*"
- (display-buffer-in-side-window)
- (window-width . 0.20)
- (side . right)
- (slot . -1))
- ("\\*\\(Flycheck\\|Package-Lint\\).*"
- (display-buffer-in-side-window)
- (window-width . 0.20)
- (side . right)
- (slot . 0)
- (window-parameters . ((no-other-window . t)
- (mode-line-format . (" "
- mode-line-buffer-identification)))))
- ("\\*Faces\\*"
- (display-buffer-in-side-window)
- (window-width . 0.20)
- (side . right)
- (slot . 1)
- (window-parameters . ((no-other-window . t)
- (mode-line-format . (" "
- mode-line-buffer-identification)))))
- ("\\*Custom.*"
- (display-buffer-in-side-window)
- (window-width . 0.20)
- (side . right)
- (slot . 2))))
- (setq window-sides-vertical nil)
- (setq window-combination-resize t) ; Size new windows proportionally
- :bind (("C-x +" . balance-windows-area)
- ("<f7>" . window-toggle-side-windows)))
-
-(use-package uniquify ; Unique buffer names
- :custom
- (uniquify-buffer-name-style 'post-forward)
- (uniquify-separator ":")
- (uniquify-ignore-buffers-re "^\\*")
- (uniquify-after-kill-buffer-p t))
-
-(use-package ibuf-ext ; Extensions for Ibuffer
- :config
- ;; Do not show empty groups
- (setq ibuffer-show-empty-filter-groups nil))
-
-(use-package ibuffer ; Buffer management
- :custom
- (ibuffer-expert t)
- (ibuffer-filter-group-name-face 'font-lock-doc-face)
- (ibuffer-default-sorting-mode 'filename/process)
- (ibuffer-use-header-line t)
- :bind (("C-x C-b" . ibuffer)
- ([remap list-buffers] . ibuffer))
- :config
- ;; Use human readable Size column instead of original one
- (define-ibuffer-column size-h
- (:name "Size" :inline t)
- (cond
- ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0)))
- ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0)))
- (t (format "%8d" (buffer-size)))))
-
- (setq ibuffer-formats
- '((mark modified read-only " "
- (name 18 18 :left :elide)
- " "
- (size-h 9 -1 :right)
- " "
- (mode 16 16 :left :elide)
- " "
- filename-and-process)
- (mark modified read-only " "
- (name 18 18 :left :elide)
- " "
- (size 9 -1 :right)
- " "
- (mode 16 16 :left :elide)
- " "
- (vc-status 16 16 :left)
- " "
- filename-and-process))))
-
-(use-package ibuffer-vc ; Group buffers by VC project and status
- :defer 2
- :init (add-hook 'ibuffer-hook
- (lambda ()
- (ibuffer-vc-set-filter-groups-by-vc-root)
- (unless (eq ibuffer-sorting-mode 'filename/process)
- (ibuffer-do-sort-by-filename/process)))))
-
-(provide 'setup-buffers)
-#+end_src
-
-*** ~setup-compile.el~
-:PROPERTIES:
-:CUSTOM_ID: h:c5d92923-4c37-44d6-9adf-a5911e950f7e
-:END:
-
-#+begin_src emacs-lisp :tangle config/setup-compile.el
-;;; -*- lexical-binding: t; -*-
-(use-package compile
- :defer 2
- :config
- (progn
- ;; http://stackoverflow.com/a/13408008/1219634
- (setq
- compilation-scroll-output t
- ;; I'm not scared of saving everything.
- compilation-ask-about-save nil
- ;; Automatically scroll and jump to the first error
- compilation-scroll-output 'next-error
- ;; compilation-scroll-output 'first-error
- ;; compilation-auto-jump-to-first-error t
- ;; Skip over warnings and info messages in compilation
- compilation-skip-threshold 2
- ;; Don't freeze when process reads from stdin
- compilation-disable-input t
- ;; Show three lines of context around the current message
- compilation-context-lines 3)
- (require 'ansi-color)
- (defun vde/colorize-compilation-buffer ()
- (unless (or (derived-mode-p 'grep-mode) ;Don't mess up colors in Grep/Ag results buffers
- (derived-mode-p 'ag-mode))
- (ansi-color-apply-on-region compilation-filter-start (point))))
- (add-hook 'compilation-filter-hook #'vde/colorize-compilation-buffer)
-
- (defun vde/mark-compilation-window-as-dedicated ()
- "Setup the *compilation* window with custom settings."
- (when (string-prefix-p "*compilation: " (buffer-name))
- (save-selected-window
- (save-excursion
- (let* ((w (get-buffer-window (buffer-name))))
- (when w
- (select-window w)
- (switch-to-buffer (buffer-name))
- (set-window-dedicated-p w t)))))))
- (add-hook 'compilation-mode-hook 'vde/mark-compilation-window-as-dedicated)))
-
-(use-package flycheck
- :if (not (eq system-type 'windows-nt))
- :defer 4
- :commands (flycheck-mode
- flycheck-next-error
- flycheck-previous-error)
- :init
- (dolist (where '((emacs-lisp-mode-hook . emacs-lisp-mode-map)
- (haskell-mode-hook . haskell-mode-map)
- (js2-mode-hook . js2-mode-map)
- (go-mode-hook . go-mode-map)
- (c-mode-common-hook . c-mode-base-map)))
- (add-hook (car where)
- `(lambda ()
- (bind-key "M-n" #'flycheck-next-error ,(cdr where))
- (bind-key "M-p" #'flycheck-previous-error ,(cdr where)))
- t))
- :config
- (add-hook 'prog-mode-hook 'flycheck-mode)
- (defalias 'show-error-at-point-soon
- 'flycheck-show-error-at-point)
- (setq flycheck-idle-change-delay 1.2))
-
-(provide 'setup-compile)
-#+end_src
-
-*** ~setup-completion.el~
-:PROPERTIES:
-:CUSTOM_ID: h:5d87a504-6cba-4cc4-a694-ce46756d2fe6
-:END:
-
-#+begin_src emacs-lisp :tangle config/setup-completion.el
-;;; -*- lexical-binding: t; -*-
-(use-package ivy
- :delight
- :custom
- (ivy-count-format "%d/%d ")
- (ivy-height-alist '((t lambda (_caller) (/ (window-height) 4))))
- (ivy-use-virtual-buffers t)
- (ivy-virtual-abbreviate 'full) ;Show the full virtual file paths
- (ivy-wrap nil)
- (ivy-re-builders-alist
- '((counsel-M-x . ivy--regex-fuzzy)
- (t . ivy--regex-plus)))
- (ivy-display-style 'fancy)
- (ivy-use-selectable-prompt t)
- (ivy-fixed-height-minibuffer nil)
- (ivy-extra-directories nil) ; Default value: ("../" "./")
- :bind (:map vde-mode-map
- ("C-x b" . vde/switch-buffer)
- ("C-x B" . ivy-switch-buffer)
- ("M-u" . ivy-resume) ;Override the default binding for `upcase-word'
- ("C-c C-w p" . ivy-push-view) ;Push window configuration to `ivy-views'
- ("C-c C-w P" . ivy-pop-view) ;Remove window configuration from `ivy-views'
- ("C-c C-w s" . ivy-switch-view) ; Switch window configuration to `ivy-views'
- :map ivy-occur-mode-map
- ("f" . forward-char)
- ("b" . backward-char)
- ("n" . ivy-occur-next-line)
- ("p" . ivy-occur-previous-line)
- ("<C-return>" . ivy-occur-press))
- :init
- (progn
- (bind-to-vde-map "v" #'counsel-set-variable))
- :hook
- (ivy-occur-mode . hl-line-mode)
- :config
- (ivy-set-occur 'ivy-switch-buffer 'ivy-switch-buffer-occur)
- (ivy-set-occur 'swiper 'swiper-occur)
- (ivy-set-occur 'swiper-isearch 'swiper-occur)
- (ivy-mode 1)
- (progn
- (defun vde/switch-buffer (arg)
- "Custom switch to buffer.
-With universal argument ARG or when not in project, rely on
-`ivy-switch-buffer'.
-Otherwise, use `counsel-projectile-switch-project'."
- (interactive "P")
- (if (or arg
- (not (projectile-project-p)))
- (ivy-switch-buffer)
- (counsel-projectile-switch-to-buffer)))
- ;; Disable ido
- (with-eval-after-load 'ido
- (ido-mode -1)
- ;; Enable ivy
- (ivy-mode 1))
- ))
-
-(use-package counsel
- :after ivy
- :custom
- (counsel-yank-pop-preselect-last t)
- (counsel-yank-pop-separator "\n—————————\n")
- (counsel-describe-function-function 'helpful-function)
- (counsel-describe-variable-function 'helpful-variable)
- (counsel-find-file-at-point t)
- (counsel-find-file-ignore-regexp
- ;; Note that `ivy-extra-directories' should also not contain the "../" and
- ;; "./" elements if you don't want to see those in the `counsel-find-file'
- ;; completion list.
- (concat
- ;; file names beginning with # or .
- "\\(?:\\`[#.]\\)"
- ;; file names ending with # or ~
- "\\|\\(?:[#~]\\'\\)"))
- :bind (:map vde-mode-map
- ("M-i" . counsel-semantic-or-imenu)
- ;;("M-i" . counsel-grep-or-swiper)
- ("C-x C-r" . counsel-recentf)
- ("C-M-y" . counsel-yank-pop)
- ("C-h F" . counsel-faces) ;Overrides `Info-goto-emacs-command-node'
- ("C-h S" . counsel-info-lookup-symbol)
- ("C-c u" . counsel-unicode-char)
- ("C-c C" . counsel-colors-emacs) ;Alternative to `list-colors-display'
- ([remap execute-extended-command] . counsel-M-x)
- ([remap bookmark-jump] . counsel-bookmark) ;Jump to book or set it if it doesn't exist, C-x r b
- ([remap bookmark-set] . counsel-bookmark) ;C-x r m
- ([remap find-file] . counsel-find-file)
- ([remap describe-bindings] . counsel-descbinds)
- ([remap finder-by-keyword] . counsel-package) ;C-h p
- ([remap describe-variable] . counsel-describe-variable)
- ([remap describe-function] . counsel-describe-function)
- ("M-s r" . counsel-rg)
- ("M-s g" . counsel-git-grep)
- ("M-s z" . prot/counsel-fzf-rg-files)
- :map ivy-minibuffer-map
- ("C-r" . counsel-minibuffer-history)
- ("C-SPC" . ivy-restrict-to-matches))
- :init
- (progn
- (bind-to-vde-map "s" #'counsel-rg))
- :config
- (progn
- (defun prot/counsel-fzf-rg-files (&optional input dir)
- "Run `fzf' in tandem with `ripgrep' to find files in the
-present directory. If invoked from inside a version-controlled
-repository, then the corresponding root is used instead."
- (interactive)
- (let* ((process-environment
- (cons (concat "FZF_DEFAULT_COMMAND=rg -Sn --color never --files --no-follow --hidden")
- process-environment))
- (vc (vc-root-dir)))
- (if dir
- (counsel-fzf input dir)
- (if (eq vc nil)
- (counsel-fzf input default-directory)
- (counsel-fzf input vc)))))
-
- (defun prot/counsel-fzf-dir (arg)
- "Specify root directory for `counsel-fzf'."
- (prot/counsel-fzf-rg-files ivy-text
- (read-directory-name
- (concat (car (split-string counsel-fzf-cmd))
- " in directory: "))))
-
- (defun prot/counsel-rg-dir (arg)
- "Specify root directory for `counsel-rg'."
- (let ((current-prefix-arg '(4)))
- (counsel-rg ivy-text nil "")))
-
- ;; TODO generalise for all relevant file/buffer counsel-*?
- (defun prot/counsel-fzf-ace-window (arg)
- "Use `ace-window' on `prot/counsel-fzf-rg-files' candidate."
- (ace-window t)
- (let ((default-directory (if (eq (vc-root-dir) nil)
- counsel--fzf-dir
- (vc-root-dir))))
- (if (> (length (aw-window-list)) 1)
- (progn
- (find-file arg))
- (find-file-other-window arg))
- (balance-windows)))
-
- ;; Pass functions as appropriate Ivy actions (accessed via M-o)
- (ivy-add-actions
- 'counsel-fzf
- '(("r" prot/counsel-fzf-dir "change root directory")
- ("g" prot/counsel-rg-dir "use ripgrep in root directory")
- ("a" prot/counsel-fzf-ace-window "ace-window switch")))
-
- (ivy-add-actions
- 'counsel-rg
- '(("r" prot/counsel-rg-dir "change root directory")
- ("z" prot/counsel-fzf-dir "find file with fzf in root directory")))
-
- (ivy-add-actions
- 'counsel-find-file
- '(("g" prot/counsel-rg-dir "use ripgrep in root directory")
- ("z" prot/counsel-fzf-dir "find file with fzf in root directory")))
-
- (ivy-set-actions
- 'counsel-find-file
- `(("x"
- (lambda (x) (delete-file (expand-file-name x ivy--directory)))
- ,(propertize "delete" 'face 'font-lock-warning-face))))
-
- (push '(counsel-rg . "--glob '**' -- ") ivy-initial-inputs-alist)
- ;; counsel-rg
- ;; Redefine `counsel-rg-base-command' with my required options, especially
- ;; the `--follow' option to allow search through symbolic links (part of
- ;; `modi/rg-arguments').
- (setq counsel-rg-base-command
- (concat (mapconcat #'shell-quote-argument
- (append '("rg")
- vde/rg-arguments
- '("--no-heading" ;No file names above matching content
- ))
- " ")
- " %s" ;This MUST be %s, not %S
- ;https://github.com/abo-abo/swiper/issues/427
- ))))
-
-
-(use-package company
- :commands global-company-mode
- :init
- (add-hook 'after-init-hook #'global-company-mode)
- (setq
- company-idle-delay 0.2
- company-selection-wrap-around t
- company-minimum-prefix-length 2
- company-require-match nil
- company-dabbrev-ignore-case nil
- company-dabbrev-downcase nil
- company-show-numbers t
- company-tooltip-align-annotations t)
- :config
- (bind-keys :map company-active-map
- ("C-d" . company-show-doc-buffer)
- ("C-l" . company-show-location)
- ("C-n" . company-select-next)
- ("C-p" . company-select-previous)
- ("C-t" . company-select-next)
- ("C-s" . company-select-previous)
- ("TAB" . company-complete))
- (setq company-backends
- '(company-css
- company-clang
- company-capf
- company-semantic
- company-xcode
- company-cmake
- company-files
- company-gtags
- company-etags
- company-keywords)))
-
-;;; Default rg arguments
-;; https://github.com/BurntSushi/ripgrep
-(defconst vde/rg-arguments
- `("--no-ignore-vcs" ;Ignore files/dirs ONLY from `.ignore'
- "--line-number" ;Line numbers
- "--smart-case"
- "--max-columns" "150" ;Emacs doesn't handle long line lengths very well
- "--ignore-file" ,(expand-file-name ".ignore" (getenv "HOME")))
- "Default rg arguments used in the functions in `counsel' and `projectile' packages.")
-
-
-(if *sys/full*
- (progn
- (use-package ivy-rich
- :after ivy
- :custom
- (ivy-virtual-abbreviate 'full
- ivy-rich-switch-buffer-align-virtual-buffer t
- ivy-rich-path-style 'abbrev)
- :config (ivy-rich-mode 1))
-
- (use-package prescient
- :custom
- (prescient-history-length 50)
- ;; (prescient-save-file "~/.emacs.d/prescient-items")
- (prescient-filter-method '(fuzzy initialism regexp))
- :config
- (prescient-persist-mode 1))
-
-
- (use-package ivy-prescient
- :after (prescient ivy)
- :custom
- (ivy-prescient-sort-commands
- '(:not swiper ivy-switch-buffer counsel-switch-buffer))
- (ivy-prescient-retain-classic-highlighting t)
- (ivy-prescient-enable-filtering t)
- (ivy-prescient-enable-sorting t)
- :config
- (defun prot/ivy-prescient-filters (str)
- "Specify an exception for `prescient-filter-method'.
-
-This new rule can be used to tailor the results of individual
-Ivy-powered commands, using `ivy-prescient-re-builder'."
- (let ((prescient-filter-method '(literal regexp)))
- (ivy-prescient-re-builder str)))
-
- (setq ivy-re-builders-alist
- '((counsel-rg . prot/ivy-prescient-filters)
- (counsel-grep . prot/ivy-prescient-filters)
- (counsel-yank-pop . prot/ivy-prescient-filters)
- (swiper . prot/ivy-prescient-filters)
- (swiper-isearch . prot/ivy-prescient-filters)
- (swiper-all . prot/ivy-prescient-filters)
- (t . ivy-prescient-re-builder)))
- (ivy-prescient-mode 1))
-
- (use-package company-prescient
- :ensure company
- :after (company prescient)
- :config
- (company-prescient-mode 1))
-
- (use-package company-emoji
- :ensure company
- :config
- (add-to-list 'company-backends 'company-emoji))
-
- (use-package lsp-mode
- :commands (lsp lsp-deferred)
- :custom
- (lsp-enable-file-watchers nil)
- (lsp-gopls-staticcheck t)
- (lsp-gopls-complete-unimported t)
- (lsp-eldoc-render-all nil)
- (lsp-enable-snippet nil)
- (lsp-enable-links nil)
- (lsp-enable-folding nil)
- (lsp-enable-completion-at-point nil) ;; company-lsp takes care of it ?
- (lsp-diagnostic-package :none)
- (lsp-restart 'auto-restart)
- (lsp-ui-sideline-enable nil)
- (lsp-ui-sideline-show-hover nil)
- (lsp-ui-sideline-delay 2.0)
- (lsp-ui-doc-enable nil)
- (lsp-ui-doc-max-width 30)
- (lsp-ui-doc-max-height 15)
- (lsp-document-highlight-delay 2.0)
- (lsp-auto-guess-root t)
- (lsp-ui-flycheck-enable nil)
- ;; @see https://github.com/emacs-lsp/lsp-mode/pull/1498
- ;; and read code related to auto configure
- ;; require clients could be slow and that's only thing auto configure
- ;; could do for me. Manual loading of client is faster.
- (lsp-auto-configure nil)
- (lsp-prefer-flymake nil) ; Use flycheck instead of flymake
- :config
- ;; don't ping LSP lanaguage server too frequently
- (defvar lsp-on-touch-time 0)
- (defadvice lsp-on-change (around lsp-on-change-hack activate)
- ;; don't run `lsp-on-change' too frequently
- (when (> (- (float-time (current-time))
- lsp-on-touch-time) 30) ;; 30 seconds
- (setq lsp-on-touch-time (float-time (current-time)))
- ad-do-it))
- :hook ((go-mode . lsp-deferred)
- (python-mode . lsp-deferred)))
-
- ;; lsp-ui: This contains all the higher level UI modules of lsp-mode, like flycheck support and code lenses.
- ;; https://github.com/emacs-lsp/lsp-ui
- (use-package lsp-ui
- :after lsp-mode
- ;;:hook ((lsp-mode . lsp-ui-mode)
- ;; (lsp-ui-mode . lsp-ui-peek-mode))
- :config
- (define-key lsp-ui-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions)
- (define-key lsp-ui-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references))
-
- ;;Set up before-save hooks to format buffer and add/delete imports.
- ;;Make sure you don't have other gofmt/goimports hooks enabled.
- (defun lsp-go-install-save-hooks ()
- (add-hook 'before-save-hook #'lsp-format-buffer t t)
- (add-hook 'before-save-hook #'lsp-organize-imports t t))
- (add-hook 'go-mode-hook #'lsp-go-install-save-hooks)
-
- (with-eval-after-load "company"
- (use-package company-lsp
- :after lsp-mode
- :config
- (push 'company-lsp company-backends)))
-
- (with-eval-after-load "projectile"
- (defun my-set-projectile-root ()
- (when lsp--cur-workspace
- (setq projectile-project-root (lsp--workspace-root lsp--cur-workspace))))
- (add-hook 'lsp-before-open-hook #'my-set-projectile-root))
-
- (use-package dap-mode
- :after lsp-mode
- :bind (:map dap-mode-map
- ([f9] . dap-debug)
- ;; ([f9] . dap-continue)
- ;; ([S-f9] . dap-disconnect)
- ;; ([f10] . dap-next)
- ;; ([f11] . dap-step-in)
- ;; ([S-f11] . dap-step-out)
- ([C-f9] . dap-hide/show-ui))
- :hook (dap-stopped-hook . (lambda (arg) (call-interactively #'dap-hydra)))
- :config
- ;; FIXME: Create nice solution instead of a hack
- (defvar dap-hide/show-ui-hidden? t)
- (defun dap-hide/show-ui ()
- "Hide/show dap ui. FIXME"
- (interactive)
- (if dap-hide/show-ui-hidden?
- (progn
- (setq dap-hide/show-ui-hidden? nil)
- (dap-ui-locals)
- (dap-ui-repl))
- (dolist (buf '("*dap-ui-inspect*" "*dap-ui-locals*" "*dap-ui-repl*" "*dap-ui-sessions*"))
- (when (get-buffer buf)
- (kill-buffer buf)))
- (setq dap-hide/show-ui-hidden? t)))
-
- (dap-mode)
- (dap-ui-mode)
- (dap-tooltip-mode))
-
- ))
-
-(provide 'setup-completion)
-#+end_src
-
-*** ~setup-dired.el~
-:PROPERTIES:
-:CUSTOM_ID: h:739e0f3e-18f0-47c8-b510-ad5a4b09abdc
-:END:
-
-#+begin_src emacs-lisp :tangle config/setup-dired.el
-;;; -*- lexical-binding: t; -*-
-(use-package dired
- :defer t
- :custom
- (dired-auto-revert-buffer t)
- (dired-recursive-copies 'always)
- (dired-recursive-deletes 'always)
- (dired-isearch-filenames 'dwim)
- (delete-by-moving-to-trash t)
- (dired-listing-switches "-lFaGh1v --group-directories-first")
- (dired-ls-F-marks-symlinks t)
- (dired-dwim-target t)
- :bind (("<C-return>" . vde/open-in-external-app)
- ("C-c f g" . vde/dired-get-size)
- ("C-c f f" . find-name-dired)
- (:map dired-mode-map
- ("M-p" . vde/dired-up)
- ("^" . vde/dired-up)
- ("<backspace>" . vde/dired-up)
- ("M-n" . vde/dired-down)
- ("RET" . find-file-reuse-dir-buffer)
- ("!" . vde/sudired)
- ("<prior>" . beginend-dired-mode-goto-beginning)
- ("<next>" . beginend-dired-mode-goto-end)))
- :config
- (when (string= system-type "darwin")
- (setq dired-use-ls-dired t
- insert-directory-program "/usr/local/bin/gls"))
-
- ;; Enable dired-find-alternate-file
- (put 'dired-find-alternate-file 'disabled nil)
-
- ;; Handle long file names
- (add-hook 'dired-mode-hook #'toggle-truncate-lines)
-
- (defun vde/dired-up ()
- "Go to previous directory."
- (interactive)
- (find-alternate-file ".."))
-
- (defun vde/dired-down ()
- "Enter directory."
- (interactive)
- (dired-find-alternate-file))
-
- (defun vde/open-in-external-app ()
- "Open the file(s) at point with an external application."
- (interactive)
- (let* ((file-list
- (dired-get-marked-files)))
- (mapc
- (lambda (file-path)
- (let ((process-connection-type nil))
- (start-process "" nil "xdg-open" file-path))) file-list)))
-
- (defun find-file-reuse-dir-buffer ()
- "Like `dired-find-file', but reuse Dired buffers."
- (interactive)
- (set-buffer-modified-p nil)
- (let ((file (dired-get-file-for-visit)))
- (if (file-directory-p file)
- (find-alternate-file file)
- (find-file file))))
-
- (defun vde/sudired ()
- "Open directory with sudo in Dired."
- (interactive)
- (require 'tramp)
- (let ((dir (expand-file-name default-directory)))
- (if (string-match "^/sudo:" dir)
- (user-error "Already in sudo")
- (dired (concat "/sudo::" dir)))))
-
- (defun vde/dired-get-size ()
- "Quick and easy way to get file size in Dired."
- (interactive)
- (let ((files (dired-get-marked-files)))
- (with-temp-buffer
- (apply 'call-process "du" nil t nil "-sch" files)
- (message
- "Size of all marked files: %s"
- (progn
- (re-search-backward "\\(^[0-9.,]+[A-Za-z]+\\).*total$")
- (match-string 1)))))))
-
-(use-package find-dired
- :after dired
- :custom
- (find-ls-option ;; applies to `find-name-dired'
- '("-ls" . "-AFhlv --group-directories-first"))
- (find-name-arg "-iname"))
-
-(use-package dired-x ; Enable some nice Dired features
- :bind ("C-x C-j" . dired-jump)
- :custom
- (dired-omit-verbose nil)
- (dired-clean-confirm-killing-deleted-buffers nil)
- :hook
- (dired-mode . dired-omit-mode)
- :config
- (setq dired-omit-files (concat dired-omit-files "\\|^\\.+$\\|^\\..+$")))
-
-(use-package dired-aux ; Other Dired customizations
- :after dired
- :config
- (setq
- ;; Ask for creation of missing directories when copying/moving
- dired-create-destination-dirs 'ask
- ;; Search only file names when point is on a file name
- dired-isearch-filenames'dwim))
-
-(use-package dired-collapse
- :defer 1
- :commands (dired-collapse-mode)
- :init
- (add-hook 'dired-mode-hook #'dired-collapse-mode))
-
-(use-package dired-quick-sort
- :defer 1
- :after dired
- :config
- (dired-quick-sort-setup))
-
-(use-package async)
-
-(use-package dired-async
- :after (dired async)
- :config
- (dired-async-mode 1))
-
-(use-package dired-narrow
- :after dired
- :custom
- (dired-narrow-exit-when-one-left t)
- (dired-narrow-enable-blinking t)
- (dired-narrow-blink-time 0.3)
- :bind (:map dired-mode-map
- ("M-s n" . dired-narrow)))
-
-(use-package wdired
- :after dired
- :commands (wdired-mode
- wdired-change-to-wdired-mode)
- :custom
- (wdired-allow-to-change-permissions t)
- (wdired-create-parent-directories t))
-
-(use-package dired-rsync
- :ensure t
- :bind (:map dired-mode-map
- ("r" . dired-rsync)))
-
-(provide 'setup-dired)
-#+end_src
-
-*** ~setup-docker.el~
-:PROPERTIES:
-:CUSTOM_ID: h:47e8ae18-cb65-4b18-99eb-36cee80786e8
-:END:
-
-#+begin_src emacs-lisp :tangle config/setup-docker.el
-;;; -*- lexical-binding: t; -*-
-(use-package dockerfile-mode ; Edit docker's Dockerfiles
- :unless *sys/full*
- :mode ("Dockerfile\\'" . dockerfile-mode))
-
-;; I have a bunch of different 'profiles' for kubernetes by different cluster so
-;; i don't mess between things
-;; This allow me to set the KUBECONFIG variable between those easily
-;; TODO: add the current profile in modeline
-(defun my-switch-kubeconfig-env (&optional kubeconfig)
- "Set KUBECONFIG environment variable for the current session"
- (interactive
- (list
- (completing-read
- "Kubeconfig: "
- (mapcar
- (lambda (x)
- (replace-regexp-in-string
- "^config\." ""
- (file-name-nondirectory(directory-file-name x))))
- (directory-files-recursively
- (expand-file-name "~/.kube") "^config\.")) nil t )))
- (setq kubeconfig (expand-file-name (format "~/.kube/config.%s" kubeconfig)))
- (if (file-exists-p kubeconfig)
- (setenv "KUBECONFIG" kubeconfig)
- (error "Cannot find kubeconfig: %s" kubeconfig)))
-
-(provide 'setup-docker)
-#+end_src
-
-*** ~setup-editing.el~
-:PROPERTIES:
-:CUSTOM_ID: h:60b9cba7-507c-4f07-be1a-e8e71c3ae7a4
-:END:
-
-#+begin_src emacs-lisp :tangle config/setup-editing.el
-;;; -*- lexical-binding: t; -*-
-(setq enable-remote-dir-locals t)
-(use-package aggressive-indent ; Automatically indent code
- :bind ("C-c e i" . aggressive-indent-mode)
- :hook ((lisp-mode . aggressive-indent-mode)
- (emacs-lisp-mode . aggressive-indent-mode)
- (clojure-mode . aggressive-indent-mode))
- :config
- ;; Free C-c C-q, used in Org and in CIDER
- (unbind-key "C-c C-q" aggressive-indent-mode-map))
-
-(use-package undo-tree ; Show buffer changes as a tree
- :defer 1
- :init (global-undo-tree-mode)
- :config (setq undo-tree-visualizer-timestamps t
- undo-tree-enable-undo-in-region t))
-
-(use-package whitespace
- :defer 1
- :hook ((prog-mode . whitespace-mode))
- :config
- (setq whitespace-style '(face tabs spaces trailing space-before-tab newline indentation empty space-after-tab space-mark tab-mark newline-mark)))
-
-(use-package smartparens
- :defer 1
- :init
- (progn
- (use-package smartparens-config)
- (show-smartparens-global-mode 1))
- :config
- (progn
- (require 'smartparens-config)
- (add-hook 'prog-mode-hook 'turn-on-smartparens-strict-mode)
- (add-hook 'markdown-mode-hook 'turn-on-smartparens-strict-mode)
-
- (sp-local-pair 'minibuffer-inactive-mode "'" nil :actions nil)
- (sp-local-pair 'web-mode "{%" "%}")
- (sp-with-modes 'emacs-lisp-mode
- ;; disable ', it's the quote character!
- (sp-local-pair "'" nil :actions nil)
- ;; also only use the pseudo-quote inside strings where it
- ;; serves as hyperlink.
- (sp-local-pair "`" "'" :when '(sp-in-string-p sp-in-comment-p)))))
-
-(use-package expand-region
- :bind (("C-=" . er/expand-region)
- ("C--". er/contract-region)))
-
-(use-package iedit
- :defines hydra-iedit/body
- :bind* (:map global-map
- ("C-*" . iedit-mode)
- :map iedit-mode-keymap
- ("M-n" . iedit-next-occurence)
- ("M-p" . iedit-prev-occurence))
- :config
- (defhydra hydra-iedit (:color pink :columns 1)
- "IEDIT"
- ("C-*" iedit-mode "toggle")
- ("C-p" iedit-prev-occurrence "prev")
- ("C-n" iedit-next-occurrence "next")
- ("C-g" iedit-quit "toggle" :color blue)))
-
-(use-package visual-regexp
- :bind (("C-c r" . vr/replace)
- ("C-c %" . vr/query-replace)
- ("C-c m" . vr/mc-mark)))
-
-(use-package yasnippet
- :after (company prog-mode)
- :defer 5
- :bind (("C-c y d" . yas-load-directory)
- ("C-c y i" . yas-insert-snippet)
- ("C-c y f" . yas-visit-snippet-file)
- ("C-c y n" . yas-new-snippet)
- ("C-c y t" . yas-tryout-snippet)
- ("C-c y l" . yas-describe-tables)
- ("C-c y g" . yas-global-mode)
- ("C-c y m" . yas-minor-mode)
- ("C-c y a" . yas-reload-all)
- ("C-c y x" . yas-expand))
- :bind (:map yas-keymap
- ("C-i" . yas-next-field-or-maybe-expand))
- :mode ("/\\.emacs\\.d/etc/yasnippet/snippets/" . snippet-mode)
- :hook (go-mode . yas-minor-mode)
- :config
- (yas-load-directory (concat user-emacs-directory "etc/yasnippet/snippets"))
- (yas-global-mode 1)
- :init
- (add-hook 'term-mode-hook (lambda () (yas-minor-mode -1))))
-
-(use-package hs-minor-mode
- :hook ((prog-mode . hs-minor-mode)))
-
-(use-package easy-kill
- :config
- (global-set-key [remap kill-ring-save] 'easy-kill)
- (global-set-key [remap mark-sexp] 'easy-mark))
-
-(use-package define-word)
-
-(setq display-line-numbers-type 'relative)
-(add-hook 'prog-mode-hook
- 'display-line-numbers-mode)
-(add-hook 'prog-mode-hook 'toggle-truncate-lines)
-
-(use-package newcomment
- :custom
- (comment-empty-lines t)
- (comment-fill-column nil)
- (comment-multi-line t)
- (comment-style 'multi-line)
- :config
- (defun prot/comment-dwim (&optional arg)
- "Alternative to `comment-dwim': offers a simple wrapper
-around `comment-line' and `comment-dwim'.
-
-If the region is active, then toggle the comment status of the
-region or, if the major mode defines as much, of all the lines
-implied by the region boundaries.
-
-Else toggle the comment status of the line at point."
- (interactive "*P")
- (if (use-region-p)
- (comment-dwim arg)
- (save-excursion
- (comment-line arg))))
-
- :bind (("C-;" . prot/comment-dwim)
- ("C-:" . comment-kill)
- ("M-;" . comment-indent)
- ("C-x C-;" . comment-box)))
-
-(use-package flyspell
- :init
- (setq flyspell-issue-message-flag nil)
- (setq flyspell-issue-welcome-flag nil)
- (setq ispell-program-name "hunspell")
- (setq ispell-local-dictionary "en_GB")
- (setq ispell-local-dictionary-alist
- '(("en_GB"
- "[[:alpha:]]"
- "[^[:alpha:]]"
- "[']"
- nil
- ("-d" "en_GB,fr_FR")
- nil
- utf-8)))
- :config
- (define-key flyspell-mode-map (kbd "C-;") nil)
- :hook
- (text-mode . turn-on-flyspell)
- (prog-mode . turn-off-flyspell))
-
-(use-package flyspell-correct-ivy
- :after flyspell
- :bind (:map flyspell-mode-map
- ([remap flyspell-correct-word-before-point] . flyspell-correct-previous-word-generic)))
-
-(use-package electric
- :custom
- (electric-pair-inhibit-predicate 'electric-pair-default-inhibit)
- (electric-pair-pairs '((8216 . 8217)
- (8220 . 8221)
- (171 . 187)))
- (electric-pair-skip-self 'electric-pair-default-skip-self)
- (electric-quote-context-sensitive t)
- (electric-quote-paragraph t)
- (electric-quote-string nil)
- :config
- (electric-indent-mode 1)
- (electric-pair-mode 1)
- (electric-quote-mode -1))
-
-(use-package emacs
- :init
- (setq-default tab-always-indent 'complete)
- (setq-default tab-width 4)
- (setq-default indent-tabs-mode nil))
-
-(use-package emacs
- :hook (before-save . delete-trailing-whitespace))
-
-(use-package delsel
- :config
- (delete-selection-mode 1))
-
-(use-package emacs
- :custom
- (repeat-on-final-keystroke t)
- (set-mark-command-repeat-pop t)
- :bind ("M-z" . zap-up-to-char))
-
-(use-package emacs
- :config
- (defun prot/new-line-below ()
- "Create a new line below the current one. Move the point to
-the absolute beginning. Also see `prot/new-line-above'."
- (interactive)
- (end-of-line)
- (newline))
-
- (defun prot/new-line-above ()
- "Create a new line above the current one. Move the point to
-the absolute beginning. Also see `prot/new-line-below'."
- (interactive)
- (beginning-of-line)
- (newline)
- (forward-line -1))
-
- (defun prot/yank-replace-line-or-region ()
- "Replace the line at point with the contents of the last
-stretch of killed text. If the region is active, operate over it
-instead. This command can then be followed by the standard
-`yank-pop' (default is bound to M-y)."
- (interactive)
- (if (use-region-p)
- (progn
- (delete-region (region-beginning) (region-end))
- (yank))
- (progn
- (delete-region (point-at-bol) (point-at-eol))
- (yank))))
-
- :bind (("C-S-SPC" . contrib/mark-whole-word)
- ("<C-return>" . prot/new-line-below)
- ("<C-S-return>" . prot/new-line-above)
- ("M-SPC" . cycle-spacing)
- ("M-o" . delete-blank-lines)
- ("<f6>" . tear-off-window)
- ("C-S-y" . prot/yank-replace-line-or-region)))
-
-(use-package crux
- :commands (crux-transpose-windows
- crux-duplicate-current-line-or-region
- crux-rename-file-and-buffer
- crux-open-with)
- :bind (("C-c w S" . crux-transpose-windows)
- ("C-c d" . crux-duplicate-current-line-or-region)
- ("<C-f2>" . crux-rename-file-and-buffer)
- :map dired-mode-map
- ("<M-return>" . crux-open-with)))
-
-(use-package goto-last-change
- :commands goto-last-change
- :bind ("C-z" . goto-last-change))
-
-(use-package pdf-tools
- :pin manual
- :mode ("\\.pdf\\'" . pdf-view-mode)
- :config
- (setq-default pdf-view-display-size 'fit-page)
- (setq pdf-annot-activate-created-annotations t)
- (setq pdf-view-midnight-colors '("#ffffff" . "#000000"))
- (pdf-tools-install :no-query)
- (require 'pdf-occur))
-
-(provide 'setup-editing)
-#+end_src
-
-*** ~setup-files.el~
-:PROPERTIES:
-:CUSTOM_ID: h:2e1f18fb-5555-4c91-a134-e509eccdf67a
-:END:
-
-#+begin_src emacs-lisp :tangle config/setup-files.el
-;;; -*- lexical-binding: t; -*-
-(use-package files ; Core commands for files
- :bind (("<f5>" . revert-buffer)))
-
-(use-package ripgrep
- :defer 2)
-
-(setq view-read-only t) ; View read-only
-
-(use-package direnv
- :custom
- (direnv-always-show-summary t)
- (direnv-show-paths-in-summary nil)
- :config
- (direnv-mode))
-
-(use-package hardhat ; Protect user-writable files
- :init (global-hardhat-mode))
-
-(use-package image-file ; Visit images as images
- :init (auto-image-file-mode))
-
-(use-package markdown-mode ; Edit markdown files
- :mode ("\\.md\\'" . markdown-mode)
- :config
- (setq markdown-fontify-code-blocks-natively t)
-
- ;; Don't change font in code blocks
- (set-face-attribute 'markdown-code-face nil
- :inherit nil)
-
- ;; Process Markdown with Pandoc, using a custom stylesheet for nice output
- (let ((stylesheet (expand-file-name
- (locate-user-emacs-file "etc/pandoc.css"))))
- (setq markdown-command
- (mapconcat #'shell-quote-argument
- `("pandoc" "--toc" "--section-divs"
- "--css" ,(concat "file://" stylesheet)
- "--standalone" "-f" "markdown" "-t" "html5")
- " ")))
- (add-hook 'markdown-mode-hook #'auto-fill-mode))
-
-(use-package highlight-indentation
- :config
- (set-face-background 'highlight-indentation-face "#e3e3d3")
- (set-face-background 'highlight-indentation-current-column-face "#c3b3b3"))
-
-(use-package yaml-mode
- :mode "\\.ya?ml\\'"
- :hook ((yaml-mode . highlight-indentation-mode)
- (yaml-mode . highlight-indentation-current-column-mode)))
-
-(use-package toml-mode
- :mode "\\.to?ml\\'")
-
-;;;###autoload
-(defun vde/delete-this-file ()
- "Delete the current file, and kill the buffer."
- (interactive)
- (or (buffer-file-name) (error "No file is currently being edited"))
- (when (yes-or-no-p (format "Really delete '%s'?"
- (file-name-nondirectory buffer-file-name)))
- (delete-file (buffer-file-name))
- (kill-this-buffer)))
-
-;;;###autoload
-(defun vde/rename-this-file-and-buffer (new-name)
- "Renames both current buffer and file it's visiting to NEW-NAME."
- (interactive "sNew name: ")
- (let ((name (buffer-name))
- (filename (buffer-file-name)))
- (unless filename
- (error "Buffer '%s' is not visiting a file!" name))
- (if (get-buffer new-name)
- (message "A buffer named '%s' already exists!" new-name)
- (progn
- (when (file-exists-p filename)
- (rename-file filename new-name 1))
- (rename-buffer new-name)
- (set-visited-file-name new-name)))))
-
-(bind-key "C-c f D" #'vde/delete-this-file)
-(bind-key "C-c f R" #'vde/rename-this-file-and-buffer)
-
-;; Additional bindings for built-ins
-(bind-key "C-c f v d" #'add-dir-local-variable)
-(bind-key "C-c f v l" #'add-file-local-variable)
-(bind-key "C-c f v p" #'add-file-local-variable-prop-line)
-
-(defun vde/reload-dir-locals-for-current-buffer ()
- "Reload dir locals for the current buffer."
- (interactive)
- (let ((enable-local-variables :all))
- (hack-dir-local-variables-non-file-buffer)))
-
-(defun vde/reload-dir-locals-for-all-buffers-in-this-directory ()
- "Reload dir-locals for all buffers in current buffer's `default-directory'."
- (interactive)
- (let ((dir default-directory))
- (dolist (buffer (buffer-list))
- (with-current-buffer buffer
- (when (equal default-directory dir))
- (vde/reload-dir-locals-for-current-buffer)))))
-
-(bind-key "C-c f v r" #'vde/reload-dir-locals-for-current-buffer)
-(bind-key "C-c f v r" #'vde/reload-dir-locals-for-all-buffers-in-this-directory)
-
-(provide 'setup-files)
-#+end_src
-
-*** ~setup-go.el~
-:PROPERTIES:
-:CUSTOM_ID: h:28696bf2-7a37-493f-b760-bb4d89a5d051
-:END:
-
-#+begin_src emacs-lisp :tangle config/setup-go.el
-;;; -*- lexical-binding: t; -*-
-(use-package go-mode
- :mode "\\.go$"
- :interpreter "go"
- :config
- (use-package company-go
- :config
- (setq company-go-show-annotation t)
- (push 'company-go company-backends))
- ;(setq gofmt-command "goimports")
- (if (not (executable-find "goimports"))
- (warn "go-mode: couldn't find goimports; no code formatting/fixed imports on save")
- (add-hook 'before-save-hook 'gofmt-before-save))
- (if (not (string-match "go" compile-command)) ; set compile command default
- (set (make-local-variable 'compile-command)
- "go build -v && go test -v && go vet")))
-
-(use-package flycheck-golangci-lint
- :hook (go-mode . flycheck-golangci-lint-setup)
- :config (setq flycheck-golangci-lint-tests t))
-
-(use-package dap-go
- :after dap-mode)
-
-(use-package gotest
- :after go-mode)
-
-(use-package gotest-ui
- :after (go-mode gotest)
- :bind (:map go-mode-map
- ("C-c t t" . gotest-ui-current-test)
- ("C-c t f" . gotest-ui-current-file)
- ("C-c t p" . gotest-ui-current-project)))
-
-(provide 'setup-go)
-#+end_src
-
-*** ~setup-hydras.el~
-:PROPERTIES:
-:CUSTOM_ID: h:c763026a-a3f2-4ed5-a6e6-1b49fa2a6b1c
-:END:
-
-#+begin_src emacs-lisp :tangle config/setup-hydras.el
-;;; -*- lexical-binding: t; -*-
-(defhydra hydra-goto-line (goto-map "")
- "goto-line"
- ("g" goto-line "go")
- ("m" set-mark-command "mark" :bind nil)
- ("q" nil "quit"))
-
-(defhydra hydra-yank-pop ()
- "yank"
- ("C-y" yank nil)
- ("M-y" yank-pop nil)
- ("y" (yank-pop 1) "next")
- ("Y" (yank-pop -1) "prev")) ; or browse-kill-ring
-
-(defhydra hydra-zoom (global-map "<f2>")
- "zoom"
- ("g" text-scale-increase "in")
- ("l" text-scale-decrease "out")
- ("r" (text-scale-set 0) "reset")
- ("0" (text-scale-set 0) :bind nil :exit t)
- ("1" (text-scale-set 0) nil :bind nil :exit t))
-
-;; Better shrink/enlarge windows
-(defhydra hydra-resize (global-map "<f2>")
- "resize windows"
- ("<up>" enlarge-window "enlarge")
- ("<down>" shrink-window "shrink")
- ("<left>" shrink-window-horizontally "shrink horizontaly")
- ("<right>" enlarge-window-horizontally "enlarge horizontaly"))
-
-(defvar hide-mode-line-mode nil)
-(defvar whitespace-mode nil)
-(defvar subword-mode nil)
-(defhydra hydra-toggle (:color pink :hint nil)
- "
-_a_ abbrev-mode: %`abbrev-mode
-_b_ subword-mode: %`subword-mode
-_d_ debug-on-error: %`debug-on-error
-_h_ hide-mode-line-mode %`hide-mode-line-mode
-_f_ auto-fill-mode: %`auto-fill-function
-_r_ readonly-mode: %`buffer-read-only
-_t_ truncate-lines %`truncate-lines
-_v_ visual-line-mode: %`visual-line-mode
-_w_ whitespace-mode: %`whitespace-mode
-_s_ smartparens-strict: %`smartparens-strict-mode
-_V_ visible-mode: %`visible-mode
-"
- ("a" abbrev-mode nil)
- ("b" subword-mode nil)
- ("d" toggle-debug-on-error nil)
- ("f" auto-fill-mode nil)
- ("h" hide-mode-line-mode nil)
- ("r" dired-toggle-read-only nil)
- ("t" toggle-truncate-lines nil)
- ("v" visual-line-mode nil)
- ("V" visible-mode nil)
- ("w" whitespace-mode nil)
- ("s" smartparens-strict-mode nil)
- ("q" nil "quit"))
-
-(global-set-key (kbd "C-c C-v") 'hydra-toggle/body)
-
-(defhydra hydra-marked-items (dired-mode-map "")
- "
-Number of marked items: %(length (dired-get-marked-files))
-"
- ("m" dired-mark "mark"))
-
-(bind-key "M-y" #'hydra-yank-pop/yank-pop)
-(bind-key "C-y" #'hydra-yank-pop/yank)
-
-(provide 'setup-hydras)
-#+end_src
-
-*** ~setup-keybindings.el~
-:PROPERTIES:
-:CUSTOM_ID: h:35f0e304-7076-4b73-b148-a206db3f0bcb
-:END:
-
-#+begin_src emacs-lisp :tangle config/setup-keybindings.el
-(use-package which-key
- :init (which-key-mode)
- :custom
- (which-key-idle-delay 2)
- (which-key-idle-secondary-delay 0.05)
- (which-key-show-early-on-C-h t)
- (which-key-sort-order 'which-key-prefix-then-key-order)
- (which-key-popup-type 'side-window)
- (which-key-show-prefix 'echo)
- (which-key-max-display-columns 6)
- (which-key-separator " → ")
- :config
- (add-to-list 'which-key-replacement-alist '(("TAB" . nil) . ("↹" . nil)))
- (add-to-list 'which-key-replacement-alist '(("RET" . nil) . ("⏎" . nil)))
- (add-to-list 'which-key-replacement-alist '(("DEL" . nil) . ("⇤" . nil)))
- (add-to-list 'which-key-replacement-alist '(("SPC" . nil) . ("␣" . nil))))
-
-(use-package region-bindings-mode
- :config
- ;; Do not activate `region-bindings-mode' in Special modes like `dired' and
- ;; `ibuffer'. Single-key bindings like 'm' are useful in those modes even
- ;; when a region is selected.
- (setq region-bindings-mode-disabled-modes '(dired-mode ibuffer-mode))
-
- (region-bindings-mode-enable)
-
- (defun vde/disable-rbm-deactivate-mark ()
- "Disable `region-bindings-mode' and deactivate mark."
- (interactive)
- (region-bindings-mode -1)
- (deactivate-mark)
- (message "Mark deactivated"))
-
- (bind-keys
- :map region-bindings-mode-map
- ("<C-SPC>" . vde/disable-rbm-deactivate-mark)))
-
-;; Disable C-x C-n to avoid the disabled command buffer
-(unbind-key "C-x C-n" global-map)
-
-(provide 'setup-keybindings)
-#+end_src
-
-*** ~setup-multiple-cursor.el~
-:PROPERTIES:
-:CUSTOM_ID: h:2b97e563-abdc-4f0d-95e2-b212c696196c
-:END:
-
-#+begin_src emacs-lisp :tangle config/setup-multiple-cursors.el
-(use-package multiple-cursor
- :bind (:map vde-mode-map
- ("C-S-c C-S-c" . mc/edit-lines))
- :bind (:map region-bindings-mode-map
- ("a" . mc/mark-all-like-this)
- ("p" . mc/mark-previous-like-this)
- ("n" . mc/mark-next-like-this)
- ("P" . mc/unmark-previous-like-this)
- ("N" . mc/unmark-next-like-this)
- ("[" . mc/cycle-backward)
- ("]" . mc/cycle-forward)
- ("m" . mc/mark-more-like-this-extended)
- ("h" . mc-hide-unmatched-lines-mode)
- ("\\" . mc/vertical-align-with-space)
- ("#" . mc/insert-numbers) ; use num prefix to set the starting number
- ("^" . mc/edit-beginnings-of-lines)
- ("$" . mc/edit-ends-of-lines)))
-
-(provide 'setup-multiple-cursors)
-#+end_src
-
-*** ~setup-navigating.el~
-:PROPERTIES:
-:CUSTOM_ID: h:e082e210-60b9-446e-a85f-c97ed94854a8
-:END:
-
-#+begin_src emacs-lisp :tangle config/setup-navigating.el
-(use-package avy ; Jump to characters in buffers
- :bind (("C-c j" . avy-goto-word-1)
- ("C-c n b" . avy-pop-mark)
- ("C-c n j" . avy-goto-char-2)
- ("C-c n t" . avy-goto-char-timer)
- ("C-c n w" . avy-goto-word-1)))
-
-(use-package helpful
- :unless noninteractive
- :bind (("C-c h F" . helpful-function)
- ("C-c h C" . helpful-command)
- ("C-c h M" . helpful-macro)
- ("C-c h L" . helpful-callable)
- ("C-c h S" . helpful-at-point)
- ("C-c h V" . helpful-variable)))
-(use-package winner
- :unless noninteractive
- :defer 5
- :config
- (winner-mode 1))
-
-(use-package hideshow
- :defer 5
- :bind (("C-c @ a" . hs-show-all)
- ("C-c @ c" . hs-toggle-hiding)
- ("C-c @ t" . hs-hide-all)
- ("C-c @ d" . hs-hide-block)
- ("C-c @ l" . hs-hide-level)))
-
-(use-package mwim
- :bind (:map prog-mode-map
- ("C-a" . mwim-beginning-of-code-or-line)
- ("C-e" . mwim-end-of-code-or-line)))
-
-(provide 'setup-navigating)
-#+end_src
-
-*** ~setup-nix.el~
-:PROPERTIES:
-:CUSTOM_ID: h:5429052a-d792-429a-9176-c9a3e3e7e130
-:END:
-
-#+begin_src emacs-lisp :tangle config/setup-nix.el
-;;; -*- lexical-binding: t; -*-
-(use-package nix-mode
- :mode ("\\.nix\\'" "\\.nix.in\\'"))
-
-(use-package nix-drv-mode
- :ensure nix-mode
- :mode "\\.drv\\'")
-
-(use-package nix-shell
- :ensure nix-mode
- :commands (nix-shell-unpack nix-shell-configure nix-shell-build))
-
-(provide 'setup-nix)
-#+end_src
-
-*** ~setup-notmuch.el~
-:PROPERTIES:
-:CUSTOM_ID: h:a6256db2-c230-4261-bf4a-0f8a0f09e810
-:END:
-
-#+begin_src emacs-lisp :tangle config/setup-notmuch.el
-(if *sys/full*
- (progn
- (setenv "NOTMUCH_CONFIG" (expand-file-name ".config/notmuch/notmuchrc" (getenv "HOME")))
- (use-package notmuch
- :defer t
- :bind ("<f6>" . notmuch)
- :config
- (setq notmuch-search-oldest-first nil
- mail-user-agent 'message-user-agent
- notmuch-tree-show-out t)
- (setq notmuch-saved-searches
- '((:key "i" :name "inbox" :query "tag:Inbox")
- (:key "r" :name "redhat inbox folder" :query "folder:redhat/Inbox")
- (:key "p" :name "perso inbox folder" :query "folder:perso/Inbox")
- (:key "u" :name "unread" :query "tag:unread")
- (:key "F" :name "flagged" :query "tag:flagged")
- (:key "S" :name "sent" :query "tag:Sent Mail"))))))
-#+end_src
-
-*** ~setup-org.el~
-:PROPERTIES:
-:CUSTOM_ID: h:46adc0c2-75cb-4bc7-8aab-c4338a06a96d
-:END:
-
-#+begin_src emacs-lisp :tangle config/setup-org.el
-;;; -*- lexical-binding: t; -*-
-
-(use-package org
- :defer t
- :ensure org-plus-contrib
- :config
- (use-package find-lisp)
-
- (defun vde/is-project-p ()
- "Any task with a todo keyword subtask"
- (save-restriction
- (widen)
- (let ((has-subtask)
- (subtree-end (save-excursion (org-end-of-subtree t)))
- (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
- (save-excursion
- (forward-line 1)
- (while (and (not has-subtask)
- (< (point) subtree-end)
- (re-search-forward "^\*+ " subtree-end t))
- (when (member (org-get-todo-state) org-todo-keywords-1)
- (setq has-subtask t))))
- (and is-a-task has-subtask))))
-
- (defun vde/is-project-subtree-p ()
- "Any task with a todo keyword that is in a project subtree.
-Callers of this function already widen the buffer view."
- (let ((task (save-excursion (org-back-to-heading 'invisible-ok)
- (point))))
- (save-excursion
- (vde/find-project-task)
- (if (equal (point) task)
- nil
- t))))
-
- (defun vde/find-project-task ()
- "Move point to the parent (project) task if any"
- (save-restriction
- (widen)
- (let ((parent-task (save-excursion (org-back-to-heading 'invisible-ok) (point))))
- (while (org-up-heading-safe)
- (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
- (setq parent-task (point))))
- (goto-char parent-task)
- parent-task)))
-
- (defun vde/is-task-p ()
- "Any task with a todo keyword and no subtask"
- (save-restriction
- (widen)
- (let ((has-subtask)
- (subtree-end (save-excursion (org-end-of-subtree t)))
- (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
- (save-excursion
- (forward-line 1)
- (while (and (not has-subtask)
- (< (point) subtree-end)
- (re-search-forward "^\*+ " subtree-end t))
- (when (member (org-get-todo-state) org-todo-keywords-1)
- (setq has-subtask t))))
- (and is-a-task (not has-subtask)))))
-
- (defun vde/is-subproject-p ()
- "Any task which is a subtask of another project"
- (let ((is-subproject)
- (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
- (save-excursion
- (while (and (not is-subproject) (org-up-heading-safe))
- (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
- (setq is-subproject t))))
- (and is-a-task is-subproject)))
-
- (org-clock-persistence-insinuate)
- ;; Show lot of clocking history so it's easy to pick items off the C-F11 list
- (setq org-clock-history-length 23)
- ;; Change tasks to STARTED when clocking in
- (setq org-clock-in-switch-to-state 'vde/clock-in-to-started)
- ;; Clock out when moving task to a done state
- (setq org-clock-out-when-done t)
- ;; Save the running clock and all clock history when exiting Emacs, load it on startup
- (setq org-clock-persist t)
-
- (defun vde/clock-in-to-started (kw)
- "Switch a task from TODO to STARTED when clocking in.
-Skips capture tasks, projects, and subprojects.
-Switch projects and subprojects from STARTED back to TODO"
- (when (not (and (boundp 'org-capture-mode) org-capture-mode))
- (cond
- ((and (member (org-get-todo-state) (list "TODO"))
- (vde/is-task-p))
- "STARTED")
- ((and (member (org-get-todo-state) (list "STARTED"))
- (vde/is-project-p))
- "TODO"))))
-
- (defvar org-capture-templates (list))
- (setq org-protocol-default-template-key "l")
-
- ;; images
- (setq org-image-actual-width nil
- org-startup-with-inline-images nil)
-
- ;; Tasks (-> inbox)
-
- ;; Journal
-
- (setq org-ditaa-jar-path "/home/vincent/.nix-profile/lib/ditaa.jar") ;; FIXME(vdemeester) remove /home/vincent
- ;; org-babel
- (org-babel-do-load-languages
- 'org-babel-load-languages
- '((css . t)
- (dot . t)
- (ditaa . t)
- (emacs-lisp . t)
- (go . t)
- (gnuplot . t)
- (http . t)
- (js . t)
- ;;(ledger . t)
- (latex . t)
- (python . t)
- (shell . t)
- ))
-
- (setq org-list-demote-modify-bullet
- '(("+" . "-") ("-" . "+")))
-
- (add-to-list 'ispell-skip-region-alist '(":\\(PROPERTIES\\|LOGBOOK\\):" ":END:"))
- (add-to-list 'ispell-skip-region-alist '("#\\+BEGIN_SRC" "#\\+END_SRC"))
- (add-to-list 'ispell-skip-region-alist '("#\\+BEGIN_EXAMPLE" "#\\+END_EXAMPLE"))
-
- ;; org-links
- ;; from http://endlessparentheses.com/use-org-mode-links-for-absolutely-anything.html
- (org-link-set-parameters "tag"
- :follow #'endless/follow-tag-link)
- (defun endless/follow-tag-link (tag)
- "Display a list of TODO headlines with tag TAG.
-With prefix argument, also display headlines without a TODO keyword."
- (org-tags-view (null current-prefix-arg) tag))
-
- (org-link-set-parameters "grep"
- :follow #'vde/follow-grep-link
- :face '(:foreground "DarkRed" :underline t))
- (defun vde/follow-grep-link (regexp)
- "Run `rgrep' with REGEXP and FOLDER as argument,
-like this : [[grep:REGEXP:FOLDER]]."
- (setq expressions (split-string regexp ":"))
- (setq exp (nth 0 expressions))
- (grep-compute-defaults)
- (if (= (length expressions) 1)
- (progn
- (rgrep exp "*" (expand-file-name "./")))
- (progn
- (setq folder (nth 1 expressions))
- (rgrep exp "*" (expand-file-name folder))))
- )
-
- (org-link-set-parameters "rg"
- :follow #'vde/follow-rg-link
- :face '(:foreground "DarkGreen" :underline t))
- (defun vde/follow-rg-link (regexp)
- "Run `ripgrep-regexp` with REXEP and FOLDER as argument,
-like this : [[pt:REGEXP:FOLDER]]"
- (setq expressions (split-string regexp ":"))
- (setq exp (nth 0 expressions))
- (if (= (length expressions) 1)
- (progn
- (ripgrep-regexp exp (expand-file-name "./")))
- (progn
- (setq folder (nth 1 expressions))
- (ripgrep-regexp exp (file-name-as-directory (expand-file-name folder)))))
- )
-
- (org-link-set-parameters
- "org"
- :complete (lambda () (+org-link-read-file "org" org-directory))
- :follow (lambda (link) (find-file (expand-file-name link org-directory)))
- :face (lambda (link)
- (if (file-exists-p (expand-file-name link org-directory))
- 'org-link
- 'error)))
- (defun +org-link-read-file (key dir)
- (let ((file (read-file-name (format "%s: " (capitalize key)) dir)))
- (format "%s:%s"
- key
- (file-relative-name file dir))))
- )
-
-(use-package smartparens-org
- :after org-mode)
-
-(use-package org-capture-pop-frame)
-
-(use-package darkroom
- :custom
- (darkroom-text-scale-increase 2))
-(use-package org-tree-slide
- :after (org darkroom)
- :custom
- (org-tree-slide-breadcrumbs nil)
- (org-tree-slide-header nil)
- (org-tree-slide-slide-in-effect nil)
- (org-tree-slide-heading-emphasis nil)
- (org-tree-slide-cursor-init t)
- (org-tree-slide-modeline-display nil)
- (org-tree-slide-skip-done nil)
- (org-tree-slide-skip-comments t)
- (org-tree-slide-fold-subtrees-skipped t)
- (org-tree-slide-skip-outline-level 8)
- (org-tree-slide-never-touch-face t)
- :config
- (defun prot/org-presentation ()
- "Specifies conditions that should apply locally upon
-activation of `org-tree-slide-mode'."
- (if (eq darkroom-tentative-mode nil)
- (progn
- (darkroom-tentative-mode 1)
- (org-indent-mode 1)
- (set-frame-font "Hack-14" t t)
- (setq cursor-type '(bar . 1)))
- (darkroom-tentative-mode -1)
- (org-indent-mode -1)
- (setq cursor-type 'box)))
- :bind (("<f8>" . org-tree-slide-mode)
- :map org-tree-slide-mode-map
- ("<C-right>" . org-tree-slide-move-next-tree)
- ("<C-left>" . org-tree-slide-move-previous-tree))
- :hook (org-tree-slide-mode . prot/org-presentation))
-
-(use-package orgit
- :after magit)
-
-(provide 'setup-org)
-#+end_src
-
-*** ~setup-projectile.el~
-:PROPERTIES:
-:CUSTOM_ID: h:fcfa4636-70a0-4088-a021-7f6b2dc16208
-:END:
-
-#+begin_src emacs-lisp :tangle config/setup-projectile.el
-;;; -*- lexical-binding: t; -*-
-(use-package projectile ; Project management
- :init (projectile-mode)
- :bind-keymap ("C-c p" . projectile-command-map)
- :config
- ;; Remove dead projects when Emacs is idle
- (run-with-idle-timer 10 nil #'projectile-cleanup-known-projects)
- (setq
- ;; Custom compilation buffer name function
- compilation-buffer-name-function (lambda (mode) (concat "*" (downcase mode) ": " (projectile-project-name) "*"))
- projectile-completion-system 'ivy
- projectile-find-dir-includes-top-level t
- projectile-switch-project-action #'projectile-commander
- projectile-create-missing-test-files t
- projectile-mode-line '(:eval (format " Proj[%s]" (projectile-project-name))))
- (def-projectile-commander-method ?s
- "Open a *shell* buffer for the project"
- (projectile-run-eshell))
- (def-projectile-commander-method ?c
- "Run `compile' in the project"
- (projectile-compile-project nil)))
-
-(use-package counsel-projectile ; Ivy integration for Projectile
- :bind (:map projectile-command-map
- ("p" . counsel-projectile-switch-project)
- ("r" . counsel-projectile-rg))
- :init (counsel-projectile-mode))
-
-(provide 'setup-projectile)
-#+end_src
-
-*** ~setup-search.el~
-:PROPERTIES:
-:CUSTOM_ID: h:25d09ed7-8a16-421d-94c7-2b1dfb96ace4
-:END:
-
-#+begin_src emacs-lisp :tangle config/setup-search.el
-;;; -*- lexical-binding: t; -*-
-;; Ignore directories during grep
-(with-eval-after-load 'grep
- '(progn
- (add-to-list 'grep-find-ignored-directories "auto")
- (add-to-list 'grep-find-ignored-directories "elpa")))
-
-;; Truncate lines during grep
-(add-hook 'grep-mode-hook #'toggle-truncate-lines)
-(use-package isearch
- :custom
- (search-whitespace-regexp ".*?")
- (isearch-lax-whitespace t)
- (isearch-regexp-lax-whitespace nil)
- :config
- (defun prot/isearch-mark-and-exit ()
- "Marks the current search string. Can be used as a building
-block for a more complex chain, such as to kill a region, or
-place multiple cursors."
- (interactive)
- (push-mark isearch-other-end t 'activate)
- (setq deactivate-mark nil)
- (isearch-done))
-
- (defun stribb/isearch-region (&optional not-regexp no-recursive-edit)
- "If a region is active, make this the isearch default search
-pattern."
- (interactive "P\np")
- (when (use-region-p)
- (let ((search (buffer-substring-no-properties
- (region-beginning)
- (region-end))))
- (message "stribb/ir: %s %d %d" search (region-beginning) (region-end))
- (setq deactivate-mark t)
- (isearch-yank-string search))))
- (advice-add 'isearch-forward-regexp :after 'stribb/isearch-region)
- (advice-add 'isearch-forward :after 'stribb/isearch-region)
- (advice-add 'isearch-backward-regexp :after 'stribb/isearch-region)
- (advice-add 'isearch-backward :after 'stribb/isearch-region)
-
- (defun contrib/isearchp-remove-failed-part-or-last-char ()
- "Remove failed part of search string, or last char if successful.
-Do nothing if search string is empty to start with."
- (interactive)
- (if (equal isearch-string "")
- (isearch-update)
- (if isearch-success
- (isearch-delete-char)
- (while (isearch-fail-pos) (isearch-pop-state)))
- (isearch-update)))
-
- (defun contrib/isearch-done-opposite-end (&optional nopush edit)
- "End current search in the opposite side of the match.
-Particularly useful when the match does not fall within the
-confines of word boundaries (e.g. multiple words)."
- (interactive)
- (funcall #'isearch-done nopush edit)
- (when isearch-other-end (goto-char isearch-other-end)))
- :bind (("M-s M-o" . multi-occur)
- :map isearch-mode-map
- ("C-SPC" . prot/isearch-mark-and-exit)
- ("DEL" . contrib/isearchp-remove-failed-part-or-last-char)
- ("<C-return>" . contrib/isearch-done-opposite-end)))
-
-(use-package anzu
- :ensure t
- :delight
- :custom
- (anzu-search-threshold 100)
- (anzu-replace-threshold nil)
- (anzu-deactivate-region nil)
- (anzu-replace-to-string-separator "")
- :config
- (global-anzu-mode 1)
- :bind (([remap isearch-query-replace] . anzu-isearch-query-replace)
- ([remap isearch-query-replace-regexp] . anzu-isearch-query-replace-regexp))
- ([remap query-replace] . anzu-query-replace)
- ([remap query-replace-regexp] . anzu-query-replace-regexp)
- ("M-s %" . anzu-query-replace-at-cursor))
-
-(use-package swiper
- :after ivy
- :custom
- (swiper-action-recenter t)
- (swiper-goto-start-of-match t)
- (swiper-include-line-number-in-search t)
- :bind (("C-S-s" . swiper)
- ("M-s s" . swiper-multi)
- ("M-s w" . swiper-thing-at-point)
- :map swiper-map
- ("M-y" . yank)
- ("C-." . swiper-avy)))
-
-(use-package wgrep ; Editable grep buffer
- :defer 2
- :custom
- (wgrep-auto-save-buffer t)
- (wgrep-change-readonly-file t))
-
-(use-package visual-regexp ; Regexp replace with in-buffer display
- :bind (("C-c s r" . vr/query-replace)
- ("C-c s R" . vr/replace)))
-
-(provide 'setup-search)
-#+end_src
-
-*** ~setup-shells.el~
-:PROPERTIES:
-:CUSTOM_ID: h:fd536392-1477-450c-965a-80bbbd1e4d81
-:END:
-
-#+begin_src emacs-lisp :tangle config/setup-shells.el
-;;; -*- lexical-binding: t; -*-
-(use-package shell ; Specialized comint.el for running the shell
- :custom
- ;(ansi-color-for-comint-mode 'filter)
- (explicit-shell-file-name "zsh")
- (shell-file-name "zsh")
- :bind (("<f1>" . shell)
- (:map shell-mode-map
- ("<tab>" . completion-at-point)))
- :config
- (unbind-key "C-c C-l" shell-mode-map)
- (bind-key "C-c C-l" #'counsel-shell-history shell-mode-map)
-
- (defun vde/comint-delchar-or-eof-or-kill-buffer (arg)
- "Restore window configuration if process is dead, otherwise delete ARG."
- (interactive "p")
- (if (null (get-buffer-process (current-buffer)))
- (vde/pop-window-configuration)
- (comint-delchar-or-maybe-eof arg)))
-
- (add-hook 'shell-mode-hook
- (lambda ()
- (bind-key "C-d" #'vde/comint-delchar-or-eof-or-kill-buffer
- shell-mode-map)))
- )
-
-(use-package eshell ; Emacs command shell
- :bind* ("C-x m t" . eshell-here)
- :config
- (defun eshell-here ()
- "Open EShell in the directory associated with the current buffer's file.
-The EShell is renamed to match that directory to make multiple windows easier."
- (interactive)
- (let* ((parent (if (buffer-file-name)
- (file-name-directory (buffer-file-name))
- default-directory))
- (name (car (last (split-string parent "/" t)))))
- (eshell "new")
- (rename-buffer (concat "*eshell: " name "*"))))
-
- ;; Handy aliases
- (defalias 'ff 'find-file)
-
- (defun eshell/d ()
- "Open a dired instance of the current working directory."
- (dired "."))
-
- (defun eshell/gs (&rest args)
- (magit-status (pop args) nil)
- (eshell/echo)) ; The echo command suppresses output
-
- (defun eshell/extract (file)
- "One universal command to extract FILE (for bz2, gz, rar, etc.)"
- (eshell-command-result (format "%s %s" (cond ((string-match-p ".*\.tar.bz2" file)
- "tar xzf")
- ((string-match-p ".*\.tar.gz" file)
- "tar xzf")
- ((string-match-p ".*\.bz2" file)
- "bunzip2")
- ((string-match-p ".*\.rar" file)
- "unrar x")
- ((string-match-p ".*\.gz" file)
- "gunzip")
- ((string-match-p ".*\.tar" file)
- "tar xf")
- ((string-match-p ".*\.tbz2" file)
- "tar xjf")
- ((string-match-p ".*\.tgz" file)
- "tar xzf")
- ((string-match-p ".*\.zip" file)
- "unzip")
- ((string-match-p ".*\.jar" file)
- "unzip")
- ((string-match-p ".*\.Z" file)
- "uncompress")
- (t
- (error "Don't know how to extract %s" file)))
- file)))
-
- (add-hook
- 'eshell-mode-hook
- (lambda ()
- (let ((ls (if (executable-find "exa") "exa" "ls")))
- (eshell/alias "ls" (concat ls " --color=always $*"))
- (eshell/alias "ll" (concat ls " --color=always -l $*"))
- (eshell/alias "l" (concat ls " --color=always -lah $*")))
- (eshell-smart-initialize)
- (eshell-dirs-initialize)
- (bind-keys :map eshell-mode-map
- ("C-c C-l" . counsel-esh-history)
- ([remap eshell-pcomplete] . completion-at-point))))
-
- ;; Use system su/sudo
- (with-eval-after-load "em-unix"
- '(progn
- (unintern 'eshell/su nil)
- (unintern 'eshell/sudo nil)))
-
- (add-hook 'eshell-mode-hook #'with-editor-export-editor))
-
-(use-package em-prompt ; EShell command prompts
- :defer 2
- :config
- (defun vde/eshell-quit-or-delete-char (arg)
- "Use C-d to either delete forward char or exit EShell."
- (interactive "p")
- (if (and (eolp) (looking-back eshell-prompt-regexp nil nil))
- (progn
- (eshell-life-is-too-much))
- (delete-char arg)))
-
- (add-hook 'eshell-mode-hook
- (lambda ()
- (bind-key "C-d"
- #'vde/eshell-quit-or-delete-char eshell-mode-map))))
-
-(use-package esh-mode ; EShell UI customizations
- :ensure eshell
- :config (setq eshell-scroll-to-bottom-on-input 'all))
-
-(use-package em-smart
- :ensure eshell)
-(use-package em-dirs
- :ensure eshell)
-
-(use-package em-cmpl ; EShell TAB completion
- :ensure eshell
- :config
- (add-hook 'eshell-mode-hook #'eshell-cmpl-initialize)
-
- (add-to-list 'eshell-command-completions-alist
- '("gunzip" "gz\\'"))
- (add-to-list 'eshell-command-completions-alist
- '("tar" "\\(\\.tar|\\.tgz\\|\\.tar\\.gz\\)\\'")))
-
-(use-package em-hist ; EShell History management
- :ensure eshell
- :config (setq eshell-hist-ignoredups t))
-
-(use-package em-term ; Handle visual commands in EShell
- :ensure eshell
- :config
- (add-to-list 'eshell-visual-commands "ssh")
- (add-to-list 'eshell-visual-commands "htop")
- (add-to-list 'eshell-visual-commands "top")
- (add-to-list 'eshell-visual-commands "tail")
- (add-to-list 'eshell-visual-commands "npm")
- (add-to-list 'eshell-visual-commands "ncdu"))
-
-(use-package em-banner
- :ensure eshell
- :config
- (setq eshell-banner-message "
- Welcome to the Emacs
-
- _/ _/ _/
- _/_/ _/_/_/ _/_/_/ _/_/ _/ _/
- _/_/_/_/ _/_/ _/ _/ _/_/_/_/ _/ _/
- _/ _/_/ _/ _/ _/ _/ _/
- _/_/_/ _/_/_/ _/ _/ _/_/_/ _/ _/
-
-"))
-
-(use-package fish-completion ; Add Fish completion to EShell
- :defer 2
- :when (executable-find "fish")
- :config (add-hook 'eshell-mode-hook #'fish-completion-mode))
-
-(use-package eshell-prompt-extras
- :defer 1
- :custom
- (eshell-highlight-prompt nil)
- (eshell-prompt-function 'vde-theme-lambda)
- :config
- (defun vde-kubernetes-current-context ()
- "Return the current context"
- (if (not (string-empty-p (getenv "KUBECONFIG")))
- (epe-trim-newline (shell-command-to-string (concat
- "env KUBECONFIG="
- (getenv "KUBECONFIG")
- " kubectl config current-context")))
- (epe-trim-newline (shell-command-to-string "kubectl config current-context"))))
- (defun vde-kubernetes-p ()
- "If you have kubectl install and a config set,
-using either KUBECONFIG or ~/.kube/config"
- (and (eshell-search-path "kubectl")
- (not (string-empty-p (vde-kubernetes-current-context)))
- (not (string-match-p "error: current-context is not set" (vde-kubernetes-current-context)))))
- ;; From epe-theme-lambda
- (defun vde-theme-lambda ()
- "A eshell-prompt lambda theme."
- (setq eshell-prompt-regexp "^[^#\nλ]*[#λ] ")
- (concat
- (when (epe-remote-p)
- (epe-colorize-with-face
- (concat (epe-remote-user) "@" (epe-remote-host) " ")
- 'epe-remote-face))
- (when (and epe-show-python-info (bound-and-true-p venv-current-name))
- (epe-colorize-with-face (concat "(" venv-current-name ") ") 'epe-venv-face))
- (let ((f (cond ((eq epe-path-style 'fish) 'epe-fish-path)
- ((eq epe-path-style 'single) 'epe-abbrev-dir-name)
- ((eq epe-path-style 'full) 'abbreviate-file-name))))
- (epe-colorize-with-face (funcall f (eshell/pwd)) 'epe-dir-face))
- (when (epe-git-p)
- (concat
- (epe-colorize-with-face ":" 'epe-dir-face)
- (epe-colorize-with-face
- (concat (epe-git-branch)
- (epe-git-dirty)
- (epe-git-untracked)
- (let ((unpushed (epe-git-unpushed-number)))
- (unless (= unpushed 0)
- (concat ":" (number-to-string unpushed)))))
- 'epe-git-face)))
- (when (vde-kubernetes-p)
- (concat (epe-colorize-with-face " (" 'epe-dir-face)
- (epe-colorize-with-face (vde-kubernetes-current-context) 'epe-dir-face)
- (epe-colorize-with-face ")" 'epe-dir-face)))
- (epe-colorize-with-face " λ" 'epe-symbol-face)
- (epe-colorize-with-face (if (= (user-uid) 0) "#" "") 'epe-sudo-symbol-face)
- " ")))
-
-(use-package esh-autosuggest
- :defer 1
- :hook (eshell-mode . esh-autosuggest-mode))
-
-(use-package xterm-color
- :init
- (setq comint-output-filter-functions
- (remove 'ansi-color-process-output comint-output-filter-functions))
- (add-hook 'shell-mode-hook
- (lambda ()
- ;; Disable font-locking in this buffer to improve performance
- (font-lock-mode -1)
- ;; Prevent font-locking from being re-enabled in this buffer
- (make-local-variable 'font-lock-function)
- (setq font-lock-function (lambda (_) nil))
- (add-hook 'comint-preoutput-filter-functions 'xterm-color-filter nil t)))
- (add-hook 'eshell-before-prompt-hook
- (lambda ()
- (setenv "TERM" "xterm-256color")
- (setq xterm-color-preserve-properties t)))
- (add-to-list 'eshell-preoutput-filter-functions 'xterm-color-filter)
- (setq eshell-output-filter-functions (remove 'eshell-handle-ansi-color eshell-output-filter-functions))
- (setq compilation-environment '("TERM=xterm-256color"))
- (add-hook 'compilation-start-hook
- (lambda (proc)
- ;; We need to differentiate between compilation-mode buffers
- ;; and running as part of comint (which at this point we assume
- ;; has been configured separately for xterm-color)
- (when (eq (process-filter proc) 'compilation-filter)
- ;; This is a process associated with a compilation-mode buffer.
- ;; We may call `xterm-color-filter' before its own filter function.
- (set-process-filter
- proc
- (lambda (proc string)
- (funcall 'compilation-filter proc
- (xterm-color-filter string))))))))
-
-;; for fish in ansi-term
-(add-hook 'term-mode-hook 'toggle-truncate-lines)
-
-(provide 'setup-shells)
-#+end_src
-
-*** ~setup-style.el~
-:PROPERTIES:
-:CUSTOM_ID: h:8ad2ded5-f9e0-4973-9c6e-99efd37aaad4
-:END:
-
-#+begin_src emacs-lisp :tangle config/setup-style.el
-;;; -*- lexical-binding: t; -*-
-;;; ¯\_(ツ)_/¯
-;;; - Iosevka (https://github.com/be5invis/Iosevka)
-;;; - Fira Sans (https://github.com/mozilla/Fira/)
-(defconst font-height 130)
-;; Middle/Near East: שלום, السّلام عليكم
-(when (member "Noto Sans Arabic" (font-family-list))
- (set-fontset-font t 'arabic "Noto Sans Arabic"))
-(when (member "Noto Sans Hebrew" (font-family-list))
- (set-fontset-font t 'arabic "Noto Sans Hebrew"))
-
-;; Africa: ሠላም
-(when (member "Noto Sans Ethiopic" (font-family-list))
- (set-fontset-font t 'ethiopic "Noto Sans Ethiopic"))
-
-(set-face-attribute 'default nil
- :family "Ubuntu Mono"
- :height font-height)
-(set-face-attribute 'variable-pitch nil
- :family "Ubuntu Sans"
- :height font-height
- :weight 'regular)
-
-;;; Utilities and key bindings
-(defun mu-reset-fonts ()
- "Reset fonts to my preferences."
- (interactive)
- (set-face-attribute 'default nil
- :family "Ubuntu Mono"
- :height font-height)
- (set-face-attribute 'variable-pitch nil
- :family "Ubuntu Sans"
- :height font-height
- :weight 'regular))
-
-(bind-key "C-c f r" #'mu-reset-fonts)
-
-;;; Interface
-(use-package frame ; Frames
- :bind ("C-c w f" . toggle-frame-fullscreen)
- :init
- ;; Kill `suspend-frame'
- (unbind-key "C-x C-z")
- :config (add-to-list 'initial-frame-alist '(fullscreen . maximized)))
-
-(use-package emacs
- :custom
- (use-file-dialog nil)
- (use-dialog-box nil)
- (echo-keystrokes 0.1) ; Faster echo keystrokes
- (line-number-display-limit-width 10000) ;; Avoid showing ?? in the mode line when we have long lines.
- (display-time-world-list '(("Europe/London" "London")
- ("Europe/Paris" "Paris")
- ("America/New_York" "Boston")
- ("America/Los_Angeles" "San-Francisco")
- ("Asia/Calcutta" "Bangalore")
- ("Australia/Brisbane" "Brisbane")))
- :config
- (line-number-mode 1)
- (column-number-mode 1)
- (global-hl-line-mode 1)
- (global-unset-key (kbd "C-z"))
- (global-unset-key (kbd "C-x C-z"))
- (global-unset-key (kbd "C-h h")))
-
-;;; Theme
-(setq custom-safe-themes t) ; Treat themes as safe
-
-(use-package shortbrain-light-theme
- :config
- (load-theme 'shortbrain-light))
-
-(use-package solaire-mode
- :config
- (setq solaire-mode-remap-modeline nil)
- (add-hook 'after-change-major-mode-hook #'turn-on-solaire-mode)
- (add-hook 'after-revert-hook #'turn-on-solaire-mode)
- (add-hook 'minibuffer-setup-hook #'solaire-mode-in-minibuffer)
- (add-hook 'ediff-prepare-buffer-hook #'solaire-mode)
- (advice-add #'persp-load-state-from-file :after #'solaire-mode-restore-persp-mode-buffers))
-
-;; Show buffer position percentage starting from top
-(setq mode-line-percent-position '(-3 "%o"))
-(defvar mu-eyebrowse-mode-line
- '(:propertize
- (:eval
- (when (bound-and-true-p eyebrowse-mode)
- (let* ((num (eyebrowse--get 'current-slot))
- (tag (when num
- (nth 2 (assoc num (eyebrowse--get 'window-configs)))))
- (str (concat
- " "
- (if (and tag (< 0 (length tag)))
- tag
- (when num (int-to-string num)))
- " ")))
- str)))
- face (:background "#81a2be" :foreground "#373b41"))
- "Mode line format for Eyebrowse.")
-
-(put 'mu-eyebrowse-mode-line 'risky-local-variable t)
-
-(setq-default mode-line-format
- '("%e"
- mu-eyebrowse-mode-line
- mode-line-front-space
- mode-line-mule-info
- mode-line-client
- mode-line-modified
- mode-line-remote
- mode-line-frame-identification
- mode-line-buffer-identification " " mode-line-position
- (vc-mode vc-mode)
- (multiple-cursors-mode mc/mode-line)
- " " mode-line-modes
- mode-line-end-spaces))
-
-(defmacro rename-modeline (package-name mode new-name)
- "Rename PACKAGE-NAME with MODE into NEW-NAME in the mode line."
- `(eval-after-load ,package-name
- '(defadvice ,mode (after rename-modeline activate)
- (setq mode-name ,new-name))))
-
-(defun generic-term-init ()
- (visual-line-mode -1)
- (setq-local global-hl-line-mode nil)
- (setq-local scroll-margin 0))
-
-(add-hook 'term-mode-hook #'generic-term-init)
-(add-hook 'shell-mode-hook #'generic-term-init)
-(add-hook 'eshell-mode-hook #'generic-term-init)
-
-(use-package moody
- :config
- (setq x-underline-at-descent-line t)
- (moody-replace-mode-line-buffer-identification)
- (moody-replace-vc-mode))
-
-(use-package minions ; A minor-mode menu for the mode line
- :init (minions-mode)
- :config
- (setq
- minions-mode-line-lighter "λ="
- minions-direct '(flycheck-mode)))
-
-(setq-default indicate-buffer-boundaries 'left)
-(setq-default indicate-empty-lines +1)
-
-(use-package highlight
- :ensure t
- :pin melpa)
-
-(use-package highlight-numbers
- :hook (prog-mode . highlight-numbers-mode))
-
-(use-package symbol-overlay
- :defer 4
- :bind
- ("M-s h ." . symbol-overlay-put)
- ("M-s h n" . symbol-overlay-jump-next)
- ("M-s h p" . symbol-overlay-jump-prev)
- :hook (prog-mode . symbol-overlay-mode)
- :config
- (setq symbol-overlay-idle-time 0.2))
-
-(use-package rainbow-delimiters
- :hook (prog-mode . rainbow-delimiters-mode))
-
-(use-package rainbow-mode
- :commands rainbow-mode
- :hook (prog-mode . rainbow-mode))
-
-(use-package visual-fill-column
- :commands visual-fill-column-mode)
-
-(use-package hide-mode-line-mode
- :commands hide-mode-line-mode)
-
-(defun set-light-theme ()
- "Set the light theme with some customization if needed."
- (interactive)
- (use-package shortbrain-light-theme
- :config
- (load-theme 'shortbrain-light t)))
-
-(defun set-dark-theme ()
- "Set the dark theme with some customization if needed."
- (interactive)
- (use-package shortbrain-theme
- :config
- (load-theme 'shortbrain t)))
-
-(defun theme-switcher ()
- (interactive)
- (let ((current-hour (string-to-number (format-time-string "%H"))))
- (if (and (> current-hour 6) (< current-hour 20))
- (set-light-theme)
- (set-dark-theme))))
-
-;; Run at every 3600 seconds, after 0s delay
-;; (run-with-timer 0 3600 'theme-switcher)
-
-(provide 'setup-style)
-#+end_src
-
-*** ~setup-vcs.el~
-:PROPERTIES:
-:CUSTOM_ID: h:225b08ad-d82e-46a1-9695-9d0d9ed2c17f
-:END:
-
-#+begin_src emacs-lisp :tangle config/setup-vcs.el
-;;; -*- lexical-binding: t; -*-
-(use-package vc-hooks ; Simple version control
- :bind (("S-<f5>" . vc-revert)
- ("C-c v r" . vc-refresh-state))
- :config
- ;; Always follow symlinks to files in VCS repos
- (setq vc-follow-symlinks t))
-
-(use-package magit ; The best Git client out there
- :bind (("C-c v c" . magit-clone)
- ("C-c v C" . magit-checkout)
- ("C-c v d" . magit-dispatch-popup)
- ("C-c v g" . magit-blame)
- ("C-c v l" . magit-log-buffer-file)
- ("C-c v p" . magit-pull)
- ("C-c v v" . magit-status))
- :config
- (setq
- magit-save-repository-buffers 'dontask
- magit-refs-show-commit-count 'all
- magit-branch-prefer-remote-upstream '("master")
- magit-display-buffer-function #'magit-display-buffer-traditional
- magit-completing-read-function 'ivy-completing-read
- )
-
- (magit-define-popup-option 'magit-rebase-popup
- ?S "Sign using gpg" "--gpg-sign=" #'magit-read-gpg-secret-key)
- (magit-define-popup-switch 'magit-log-popup
- ?m "Omit merge commits" "--no-merges")
-
- ;; Hide "Recent Commits"
- (magit-add-section-hook 'magit-status-sections-hook
- 'magit-insert-unpushed-to-upstream
- 'magit-insert-unpushed-to-upstream-or-recent
- 'replace)
-
- (use-package magit-files
- :config
- (global-magit-file-mode))
-
- ;; Show refined hunks during diffs
- (set-default 'magit-diff-refine-hunk t)
-
- (add-hook 'projectile-switch-project-hook
- #'mu-magit-set-repo-dirs-from-projectile)
-
- ;; Refresh `magit-status' after saving a buffer
- (add-hook 'after-save-hook #'magit-after-save-refresh-status)
-
- ;; Free C-c C-w for Eyebrowse
- (unbind-key "C-c C-w" git-commit-mode-map) )
-(put 'magit-diff-edit-hunk-commit 'disabled nil)
-(use-package magit-repos
- :after magit
- :commands magit-list-repositories
- :config
- (setq magit-repository-directories
- '(("~/src" . 3))))
-
-(use-package git-commit ; Git commit message mode
- :defer 2
- :init (global-git-commit-mode)
- :config
- (setq git-commit-summary-max-length 50)
- (setq git-commit-known-pseudo-headers
- '("Signed-off-by"
- "Acked-by"
- "Modified-by"
- "Cc"
- "Suggested-by"
- "Reported-by"
- "Tested-by"
- "Reviewed-by"))
- (setq git-commit-style-convention-checks
- '(non-empty-second-line
- overlong-summary-line))
- (remove-hook 'git-commit-finish-query-functions
- #'git-commit-check-style-conventions))
-
-(use-package gitconfig-mode ; Git configuration mode
- :defer 2)
-
-(use-package gitignore-mode ; .gitignore mode
- :defer 2)
-
-(use-package gitattributes-mode ; Git attributes mode
- :defer 2)
-
-(use-package dired-git-info
- :bind (:map dired-mode-map
- (")" . dired-git-info-mode))
- :defer 2)
-
-(use-package ediff
- :config
- (setq ediff-window-setup-function 'ediff-setup-windows-plain)
- (setq ediff-split-window-function 'split-window-horizontally)
- (setq ediff-diff-options "-w")
- (add-hook 'ediff-after-quit-hook-internal 'winner-undo))
-
-(defun git-blame-line ()
- "Runs `git blame` on the current line and
- adds the commit id to the kill ring"
- (interactive)
- (let* ((line-number (save-excursion
- (goto-char (point-at-bol))
- (+ 1 (count-lines 1 (point)))))
- (line-arg (format "%d,%d" line-number line-number))
- (commit-buf (generate-new-buffer "*git-blame-line-commit*")))
- (call-process "git" nil commit-buf nil
- "blame" (buffer-file-name) "-L" line-arg)
- (let* ((commit-id (with-current-buffer commit-buf
- (buffer-substring 1 9)))
- (log-buf (generate-new-buffer "*git-blame-line-log*")))
- (kill-new commit-id)
- (call-process "git" nil log-buf nil
- "log" "-1" "--pretty=%h %an %s" commit-id)
- (with-current-buffer log-buf
- (message "Line %d: %s" line-number (buffer-string)))
- (kill-buffer log-buf))
- (kill-buffer commit-buf)))
-
-(provide 'setup-vcs)
-#+end_src
-
-*** ~setup-vde-mode.el~
-:PROPERTIES:
-:CUSTOM_ID: h:19bf468b-1fcd-469f-9c25-dee2e200f7e7
-:END:
-
-#+begin_src emacs-lisp :tangle config/00-vde-mode.el
-;;; -*- lexical-binding: t; -*-
-(defvar vde-special-keymap-prefix (kbd "C-x m")
- "`vde-mode' keymap prefix.
-Overrides the default binding for `compose-mail'.")
-
-(defvar vde-mode-special-map (make-sparse-keymap)
- "Special keymap for `vde-mode' whose bindings begin with
-`vde-special-keymap-prefix'.")
-(fset 'vde-mode-special-map vde-mode-special-map)
-
-(defvar vde-mode-map (let ((map (make-sparse-keymap)))
- (define-key map vde-special-keymap-prefix 'vde-mode-special-map)
- map)
- "Keymap for `vde-mode'.")
-
-;;;###autoload
-(define-minor-mode vde-mode
- "A minor mode so that my key settings override annoying major modes."
- ;; If init-value is not set to t, this mode does not get enabled in
- ;; `fundamental-mode' buffers even after doing \"(global-vde-mode 1)\".
- ;; More info: http://emacs.stackexchange.com/q/16693/115
- :init-value t
- :lighter " μ"
- :keymap vde-mode-map)
-
-;;;###autoload
-(define-globalized-minor-mode global-vde-mode vde-mode vde-mode)
-
-;; https://github.com/jwiegley/use-package/blob/master/bind-key.el
-;; The keymaps in `emulation-mode-map-alists' take precedence over
-;; `minor-mode-map-alist'
-(add-to-list 'emulation-mode-map-alists `((vde-mode . ,vde-mode-map)))
-
-;; Turn off the minor mode in the minibuffer
-(defun turn-off-vde-mode ()
- "Turn off vde-mode."
- (vde-mode -1))
-(add-hook 'minibuffer-setup-hook #'turn-off-vde-mode)
-
-(defmacro bind-to-vde-map (key fn)
- "Bind a function to the `vde-mode-special-map'.
-USAGE: (bind-to-vde-map \"f\" #'full-screen-center)."
- `(define-key vde-mode-special-map (kbd ,key) ,fn))
-
-;; http://emacs.stackexchange.com/a/12906/115
-(defun unbind-from-vde-map (key)
- "Unbind a function from the `vde-mode-map'
-USAGE: (unbind-from-vde-map \"C-x m f\")
-"
- (interactive "Unset key from vde-mode-map: ")
- (define-key vde-mode-map (kbd (key-description key)) nil)
- (message "%s" (format "Unbound %s key from the %s."
- (propertize (key-description key)
- 'face 'font-lock-function-name-face)
- (propertize "vde-mode-map"
- 'face 'font-lock-function-name-face))))
-
-(provide 'setup-vde-mode)
-;; Minor mode tutorial: http://nullprogram.com/blog/2013/02/06/
-#+end_src
-
-*** ~setup-web.el~
-:PROPERTIES:
-:CUSTOM_ID: h:cb940809-e0af-4e9f-9c09-71c95b6cb472
-:END:
-
-#+begin_src emacs-lisp :tangle config/setup-web.el
-;;; -*- lexical-binding: t; -*-
-(use-package web-mode
- :mode
- ("\\.html\\'" . web-mode)
- ("\\.phtml\\'" . web-mode)
- ("\\.[agj]sp\\'" . web-mode)
- ("\\.as[cp]x\\'" . web-mode)
- ("\\.erb\\'" . web-mode)
- ("\\.mustache\\'" . web-mode)
- ("\\.djhtml\\'" . web-mode)
- ("\\.jsp\\'" . web-mode)
- ("\\.eex\\'" . web-mode)
- ("\\.tsx\\'" . web-mode)
- :config
- (setq web-mode-attr-indent-offset 2)
- (setq web-mode-code-indent-offset 2)
- (setq web-mode-css-indent-offset 2)
- (setq web-mode-indent-style 2)
- (setq web-mode-markup-indent-offset 2)
- (setq web-mode-sql-indent-offset 2)
- (eval-after-load 'smartparens
- (lambda ()
- (setq web-mode-enable-auto-pairing nil)
- (sp-with-modes '(web-mode)
- (sp-local-pair "%" "%"
- :unless '(sp-in-string-p)
- :post-handlers '(((lambda (&rest _ignored)
- (just-one-space)
- (save-excursion (insert " ")))
- "SPC" "=" "#")))
- (sp-local-tag "%" "<% " " %>")
- (sp-local-tag "=" "<%= " " %>")
- (sp-local-tag "#" "<%# " " %>")))))
-
-(provide 'setup-web)
-#+end_src
-
-*** ~setup-windows.el~
-:PROPERTIES:
-:CUSTOM_ID: h:c53d2549-1bd0-430e-a7b1-cd981d994b7a
-:END:
-
-#+begin_src emacs-lisp :tangle config/setup-windows.el
-;;; -*- lexical-binding: t; -*-
-
-;;;###autoload
-(defun vde/window-split-toggle ()
- "Toggle between horizontal and vertical split with two windows."
- (interactive)
- (if (> (length (window-list)) 2)
- (error "Can't toggle with more than 2 windows!")
- (let ((func (if (window-full-height-p)
- #'split-window-vertically
- #'split-window-horizontally)))
- (delete-other-windows)
- (funcall func)
- (save-selected-window
- (other-window 1)
- (switch-to-buffer (other-buffer))))))
-
-(bind-key "C-c w t" #'vde/window-split-toggle)
-
-(defvar vde/saved-window-configuration nil)
-
-(defun vde/save-wins-then-call (func &optional args)
- "Save current window configuration, then call FUNC optionally with ARGS."
- (interactive)
- (push (current-window-configuration) vde/saved-window-configuration)
- (cond
- ;; We have arguments for the function
- ((bound-and-true-p args) (funcall func args))
- ;; The function expects exactly one argument, and we want it to be nil
- ((equal args "nil") (funcall func nil))
- ;; The function does not expect arguments
- (t (funcall func))))
-
-(defun vde/restore-window-configuration (config)
- "Kill current buffer and restore the window configuration in CONFIG."
- (interactive)
- (kill-this-buffer)
- (set-window-configuration config))
-
-(defun vde/pop-window-configuration ()
- "Restore the previous window configuration and clear current window."
- (interactive)
- (let ((config (pop vde/saved-window-configuration)))
- (if config
- (vde/restore-window-configuration config)
- (if (> (length (window-list)) 1)
- (delete-window)
- (bury-buffer)))))
-
-(use-package eyebrowse ; Easy workspaces creation and switching
- :init (eyebrowse-mode t)
- :config
- (setq
- eyebrowse-mode-line-separator " "
- eyebrowse-mode-line-style 'always
- eyebrowse-new-workspace t
- eyebrowse-wrap-around t))
-
-(use-package ace-window ; Better movements between windows
- :custom
- (aw-keys '(?a ?u ?i ?e ?, ?c ?t ?r ?m))
- (aw-scope 'frame)
- (aw-dispatch-always t)
- (aw-dispatch-alist
- '((?s aw-swap-window "Swap Windows")
- (?2 aw-split-window-vert "Split Window Vertically")
- (?3 aw-split-window-horz "Split Window Horizontally")
- (?? aw-show-dispatch-help)))
- (aw-minibuffer-flag t)
- (aw-ignore-current nil)
- (aw-display-mode-overlay t)
- (aw-background t)
- :bind (("C-x o" . ace-window)
- ("C-c w w" . ace-window)
- ("C-c w s" . ace-swap-window)))
-
-(use-package windmove
- :bind (("M-<left>" . windmove-left)
- ("M-<down>" . windmove-down)
- ("M-<up>" . windmove-up)
- ("M-<right>" . windmove-right)))
-
-(provide 'setup-windows)
-#+end_src
-
* External libraries
:PROPERTIES:
:CUSTOM_ID: h:96ce2856-182e-42c8-a8b3-418c38124dcc
@@ -4618,7 +1716,7 @@
:CUSTOM_ID: h:bd8804a0-df0e-4aca-b748-429ea9402cd6
:END:
-#+INCLUDE: "lisp/use-package-list.el" src emacs-lisp
+#+INCLUDE: lisp/use-package-list.el src emacs-lisp
** ~gotest-ui.el~
:PROPERTIES:
@@ -4627,7 +1725,7 @@
From [[https://github.com/antifuchs/gotest-ui-mode/][antifuchs/gotest-ui-mode]].
-#+INCLUDE: "lisp/gotest-ui.el" src emacs-lisp
+#+INCLUDE: lisp/gotest-ui.el src emacs-lisp
** Org mode links
:PROPERTIES:
@@ -4638,18 +1736,10 @@
- ~ol-github.el~: link to GitHub repositories, issues and pull-requests.
- #+INCLUDE: "lisp/ol-github.el" src emacs-lisp
+ #+INCLUDE: lisp/ol-github.el src emacs-lisp
- ~ol-gitlab.el~: link to GitLab repositories, issues and merge-requests.
- #+INCLUDE: "lisp/ol-gitlab.el" src emacs-lisp
+ #+INCLUDE: lisp/ol-gitlab.el src emacs-lisp
More to comes…
-
-* Local Variables
-:PROPERTIES:
-:CUSTOM_ID: h:58879ff0-e44a-4fca-b148-5a3db7c41b8e
-:END:
-# Local Variables:
-# eval: (add-hook 'after-save-hook (lambda ()(org-babel-tangle)) nil t)
-# End:
index.org
@@ -1,5 +1,11 @@
-#+SETUPFILE: ./_setup.org
#+TITLE: vdemeester's .emacs.d
+#+AUTHOR: Vincent Demeester
+#+EMAIL: vincent@sbr.pm
+#+EXPORT_EXCLUDE_TAGS: noexport
+#+CREATOR: Emacs 27.0.90 (Org mode 9.3)
+#+LANGUAGE: en
+#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="./notes.css"/>
+#+OPTIONS: html-style:nil
#+BEGIN_QUOTE
My emacs setup is tested to work only with emacs 26.1 and newer versions. If you are on
init.el
@@ -1,4 +1,5 @@
-;;; -*- lexical-binding: t; -*-
+;;; init.el --- -*- lexical-binding: t -*-
+;; +CheckVer
(let ((minver 26))
(unless (>= emacs-major-version minver)
(error "Your Emacs is too old -- this configuration requires v%s or higher" minver)))
@@ -9,24 +10,33 @@
(unless (>= emacs-major-version 27)
(message "Early init: Emacs Version < 27.0")
(load (expand-file-name "early-init.el" user-emacs-directory)))
+;; -CheckVer
+;; Inhibit
(setq inhibit-default-init t) ; Disable the site default settings
(setq inhibit-startup-message t
inhibit-startup-screen t)
+;; -Inhibit
+;; Confirm
(setq confirm-kill-emacs #'y-or-n-p)
+;; -Confirm
+;; DefaultMode
(setq initial-major-mode 'fundamental-mode
initial-scratch-message nil)
+;; -DefaultMode
+;; Unicode
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-language-environment 'utf-8)
(set-selection-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
+;; -Unicode
-;;; package setup
+;;; UsePackageSetup
(require 'package)
(setq package-archives
@@ -76,7 +86,9 @@
(eval-when-compile
(require 'use-package))
+;; -UsePackageSetup
+;; CustomFile
(defconst vde/custom-file (locate-user-emacs-file "custom.el")
"File used to store settings from Customization UI.")
@@ -92,19 +104,25 @@
(write-region "" nil custom-file))
(load vde/custom-file 'no-error 'no-message))
+;; -CustomFile
+;; NoBuiltinOrg
(require 'cl-seq)
(setq load-path
(cl-remove-if
(lambda (x)
(string-match-p "org$" x))
load-path))
+;; -NoBuiltinOrg
+;; PinEntry
(use-package pinentry
:config
(setenv "INSIDE_EMACS" (format "%s,comint" emacs-version))
(pinentry-start))
+;; -PinEntry
+;; LoadCfgFunc
(defun vde/el-load-dir (dir)
"Load el files from the given folder"
(let ((files (directory-files dir nil "\.el$")))
@@ -115,7 +133,9 @@
"Return hostname in short (aka wakasu.local -> wakasu)"
(string-match "[0-9A-Za-z-]+" system-name)
(substring system-name (match-beginning 0) (match-end 0)))
+;; -LoadCfgFunc
+;; CfgConstant
(defconst *sys/gui*
(display-graphic-p)
"Are we running on a GUI Emacs ?")
@@ -147,13 +167,20 @@
(defvar *sys/light*
(not *sys/full*)
"Is it a light system ?")
+;; -CfgConstant
+;; CfgLoad
(add-to-list 'load-path (concat user-emacs-directory "lisp/"))
+(require 'init-func)
(vde/el-load-dir (concat user-emacs-directory "/config/"))
+;; -CfgLoad
+;; CfgHostLoad
(if (file-exists-p (downcase (concat user-emacs-directory "/hosts/" (vde/short-hostname) ".el")))
(load-file (downcase (concat user-emacs-directory "/hosts/" (vde/short-hostname) ".el"))))
+;; -CfgHostLoad
+;; LastInit
(let ((elapsed (float-time (time-subtract (current-time)
emacs-start-time))))
(message "Loading %s...done (%.3fs)" load-file-name elapsed))
@@ -165,3 +192,4 @@
(time-subtract (current-time) emacs-start-time))))
(message "Loading %s...done (%.3fs) [after-init]"
,load-file-name elapsed))) t)
+;; -LastInit