commit 6fc3dd7e69c150ee0b103bea1093eb3d1c975ed8
parent df78a0646f795409fcf1e856e686e66a31356154
Author: Alex Balgavy <alex@balgavy.eu>
Date: Mon, 22 Nov 2021 19:02:25 +0100
emacs: bunch of small config changes
Diffstat:
M | emacs/config.org | | | 160 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------- |
M | emacs/custom.el | | | 42 | ++++++++++++++++++++++++++++++++++++++++-- |
2 files changed, 160 insertions(+), 42 deletions(-)
diff --git a/emacs/config.org b/emacs/config.org
@@ -36,8 +36,18 @@ Define the themes I want:
;; (setq light-theme 'doom-acario-light)
;; I used to use doom-acario-light before writing my own theme
(setq light-theme 'jokull)
- (defun dark-theme () "Switch to dark theme" (interactive) (load-theme dark-theme))
- (defun light-theme () "Switch to light theme" (interactive) (load-theme light-theme))
+
+ (defun dark-theme ()
+ "Switch to dark theme"
+ (interactive)
+ (load-theme dark-theme t)
+ (add-hook 'pdf-view-mode-hook #'pdf-view-midnight-minor-mode))
+
+ (defun light-theme ()
+ "Switch to light theme"
+ (interactive)
+ (load-theme light-theme t)
+ (remove-hook 'pdf-view-mode-hook #'pdf-view-midnight-minor-mode))
#+end_src
Change theme depending on the current system theme.
@@ -48,8 +58,8 @@ If calling a function that's in a variable, you have to use 'funcall'.
#+begin_src emacs-lisp
(let ((dark-mode-p (lambda () (file-exists-p "~/.config/dark-theme"))))
(if (funcall dark-mode-p)
- (load-theme dark-theme t)
- (load-theme light-theme t)))
+ (dark-theme)
+ (light-theme)))
#+end_src
* Garbage collection
@@ -108,6 +118,7 @@ Switched to this from Helm, it's more lightweight.
(use-package counsel :demand
:bind
(("C-s" . swiper-isearch)
+ ("C-r" . swiper-isearch-backward)
("M-x" . counsel-M-x)
("C-x C-f" . counsel-find-file)
("M-y" . counsel-yank-pop)
@@ -159,13 +170,6 @@ Switched to this from Helm, it's more lightweight.
(ivy-quit-and-run (counsel-file-jump nil "~/.dotfiles/")))))
#+end_src
-
-Ag (silver searcher) support:
-
-#+begin_src emacs-lisp
- (use-package helm-ag)
-#+end_src
-
** org
In org mode, I want to use bullets instead of stars.
Also, I add a few expansions
@@ -275,19 +279,19 @@ anki-editor doesn't provide a keymap so I have to set one up here:
#+begin_src emacs-lisp
(use-package anki-editor
- :init
+ :config
(defvar anki-editor-mode-map (make-sparse-keymap))
(add-to-list 'minor-mode-map-alist (cons 'anki-editor-mode
anki-editor-mode-map))
- :config
(setq anki-editor-use-math-jax t)
- :bind (:map anki-editor-mode-map
- ("C-c t" . org-property-next-allowed-value)
- ("C-c i" . anki-editor-insert-note)
- ("C-c p" . anki-editor-push-notes)
- ("C-c c" . anki-editor-cloze-dwim)))
+ :hook
+ (anki-editor-mode . (lambda ()
+ (define-key (kbd "C-c t") #'org-property-next-allowed-value)
+ (define-key (kbd "C-c i") #'anki-editor-insert-note)
+ (define-key (kbd "C-c p") #'anki-editor-push-notes)
+ (define-key (kbd "C-c c") #'anki-editor-cloze-dwim))))
#+end_src
** rainbow-mode
@@ -298,6 +302,28 @@ anki-editor doesn't provide a keymap so I have to set one up here:
:hook (emacs-lisp-mode . rainbow-mode))
#+end_src
+** pdf-tools
+A better replacement for DocView:
+
+#+begin_src emacs-lisp
+ (use-package pdf-tools
+ :hook
+ (pdf-view-mode . (lambda () (display-line-numbers-mode 0)))
+ (pdf-view-mode . (lambda () (define-key pdf-isearch-minor-mode-map (kbd "C-s") #'isearch-forward))))
+ (pdf-tools-install)
+#+end_src
+
+** virtualenvwrapper
+Like virtualenvwrapper.sh, but for Emacs.
+
+#+begin_src emacs-lisp
+ (use-package virtualenvwrapper
+ :config
+ (venv-initialize-interactive-shells)
+ (venv-initialize-eshell)
+ (setq venv-location "~/.config/virtualenvs"))
+#+end_src
+
* Interface
** Messages
Hide some messages I don't need.
@@ -315,12 +341,14 @@ Highlight the current line:
(global-hl-line-mode)
(show-paren-mode 1)
#+end_src
+
*** Cursor
The default box cursor isn't really accurate, because the cursor is actually between letters, not on a letter.
So, I want a bar instead of a box:
#+begin_src emacs-lisp
- (setq-default cursor-type '(bar . 4))
+ (setq-default cursor-type '(bar . 4)
+ cursor-in-non-selected-windows 'hollow)
#+end_src
(I use ~setq-default~ here because cursor-type is automatically buffer-local when it's set)
@@ -350,7 +378,7 @@ I want to show the time and date in the modeline:
#+begin_src emacs-lisp
(setq display-time-day-and-date t ; also the date
display-time-default-load-average nil ; don't show load average
- display-time-format "%I:%M%p %e %b") ; "HR:MIN(AM/PM) day-of-month Month"
+ display-time-format "%I:%M%p %e %b (%a)") ; "HR:MIN(AM/PM) day-of-month Month (Day)"
(display-time-mode 1) ; enable time mode
#+end_src
@@ -360,7 +388,23 @@ I want to show the current function:
(which-function-mode 1)
#+end_src
-Maybe at some point I'll customize the modeline too.
+And to set the modeline format:
+
+#+begin_src emacs-lisp
+ (setq-default mode-line-format '("%e" 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)
+ " " mode-line-modes mode-line-misc-info mode-line-end-spaces))
+#+end_src
+
+I want to hide certain modes from the modeline, they're always on:
+
+#+begin_src emacs-lisp
+ (use-package diminish
+ :config
+ (let ((modes-to-hide '(ivy-mode counsel-mode which-key-mode)))
+ (mapc (lambda (mode-name) (diminish mode-name)) modes-to-hide)))
+#+end_src
+
** Buffer displaying
So, this is a bit hard to grok. But basically the alist contains a
@@ -446,7 +490,6 @@ The second one actually loads them.
#+end_src
* Editor
-
** Overwrite selection on typing
Normally, when I select something and start typing, Emacs clears the selection.
I want to replace the selection.
@@ -588,8 +631,8 @@ Set default submodes:
#+begin_src emacs-lisp
(setq semantic-default-submodes '(global-semantic-idle-scheduler-mode ; reparse buffer when idle
global-semanticdb-minor-mode ; maintain database
- global-semantic-idle-summary-mode ; show information (e.g. types) about tag at point
- global-semantic-stickyfunc-mode)) ; show current func in header line
+ global-semantic-idle-summary-mode)) ; show information (e.g. types) about tag at point
+ ;; global-semantic-stickyfunc-mode)) ; show current func in header line
#+end_src
Add some keybindings:
@@ -629,7 +672,8 @@ Bind C-M-S-F to the old functionality of M-f (stop at end of word)
(global-set-key (kbd "C-x r R") 'replace-rectangle)
#+end_src
-** Org mode - yank URL
+* Org mode
+** Yank URL
#+begin_src emacs-lisp
(defun org-yank-link-url ()
(interactive)
@@ -638,6 +682,37 @@ Bind C-M-S-F to the old functionality of M-f (stop at end of word)
(define-key org-mode-map (kbd "C-c M-y") 'org-yank-link-url)
#+end_src
+** Catch invisible edits
+Sometimes when text is folded away, I might accidentally edit text inside of it.
+This option prevents that.
+I wanted to do 'smart', but that has a 'fixme' so it might change in the future...
+Instead, show what's being edited, but don't perform the edit.
+
+#+begin_src emacs-lisp
+ (setq org-catch-invisible-edits 'show-and-error)
+#+end_src
+
+** Notification
+macOS doesn't have dbus. So I use terminal-notifier for functions like org-notify:
+
+#+begin_src emacs-lisp
+ (if (and (eq system-type 'darwin)
+ (executable-find "terminal-notifier"))
+ (setq org-show-notification-handler
+ (lambda (str) (start-process "terminal-notifier" nil (executable-find "terminal-notifier")
+ "-title" "Timer done"
+ "-message" str
+ "-group" "org.gnu.Emacs"
+ "-sender" "org.gnu.Emacs"))))
+#+end_src
+* Python
+In Python, I want to enable flycheck and semantic mode:
+
+#+begin_src emacs-lisp
+ (add-hook 'python-mode-hook 'flycheck-mode)
+ (add-hook 'python-mode-hook 'semantic-mode)
+#+end_src
+
* Misc settings
** Enable all commands
By default, Emacs disables some commands.
@@ -646,6 +721,7 @@ I want to have these enabled so I don't get a prompt whenever I try to use a dis
#+begin_src emacs-lisp
(setq disabled-command-function nil)
#+end_src
+
** More extensive apropos
#+begin_src emacs-lisp
(setq apropos-do-all t)
@@ -664,20 +740,6 @@ I want to bind view-mode to a key for easy access:
(global-set-key (kbd "C-c v") 'view-mode)
#+end_src
-** Org notification
-macOS doesn't have dbus. So I use terminal-notifier for functions like org-notify:
-
-#+begin_src emacs-lisp
- (if (and (eq system-type 'darwin)
- (executable-find "terminal-notifier"))
- (setq org-show-notification-handler
- (lambda (str) (start-process "terminal-notifier" nil (executable-find "terminal-notifier")
- "-title" "Timer done"
- "-message" str
- "-group" "org.gnu.Emacs"
- "-sender" "org.gnu.Emacs"))))
-#+end_src
-
** Kill this buffer
I like to be able to kill a buffer instantly:
@@ -748,7 +810,7 @@ Run notmuch-hook script on hello refresh, to move messages to folders according
Set the windows I want to show:
#+begin_src emacs-lisp
- (setq mpc-browser-tags '(Artist Album Genre))
+ (setq mpc-browser-tags '(Artist Album Genre Playlist))
#+end_src
Define some keybindings:
@@ -783,6 +845,24 @@ Just a wrapper function to my radio script:
(define-key dired-mode-map (kbd "M-k") #'dired-kill-subdir)
#+end_src
+Set up listing display:
+
+#+begin_src emacs-lisp
+ (setq-default dired-listing-switches "-alhv")
+#+end_src
+
+By default, hide details (show again by pressing oparen):
+
+#+begin_src emacs-lisp
+ (add-hook 'dired-mode-hook 'dired-hide-details-mode)
+#+end_src
+
+If I have another dired window open, use that as target:
+
+#+begin_src emacs-lisp
+ (setq dired-dwim-target t)
+#+end_src
+
* References
Here's a list of good articles I encountered about configging emacs:
- [[https://karthinks.com/software/batteries-included-with-emacs/][Batteries included with Emacs]]
diff --git a/emacs/custom.el b/emacs/custom.el
@@ -3,12 +3,50 @@
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
+ '(ansi-color-names-vector
+ ["#282c34" "#ff6c6b" "#98be65" "#ECBE7B" "#51afef" "#c678dd" "#46D9FF" "#bbc2cf"])
'(custom-safe-themes
- '("fc38df02f7c48603f9c392c73f1810011a04b2e1fce8f085d7e15f2b35138863" "45e9823d714d1f28f6d53f79e1981b403ae905acbd027e6fcd5f3414a78a2341" "f91395598d4cb3e2ae6a2db8527ceb83fed79dbaf007f435de3e91e5bda485fb" "6c386d159853b0ee6695b45e64f598ed45bd67c47f671f69100817d7db64724d" "8f5a7a9a3c510ef9cbb88e600c0b4c53cdcdb502cfe3eb50040b7e13c6f4e78e" "4bca89c1004e24981c840d3a32755bf859a6910c65b829d9441814000cf6c3d0" "f2927d7d87e8207fa9a0a003c0f222d45c948845de162c885bf6ad2a255babfd" "e3c64e88fec56f86b49dcdc5a831e96782baf14b09397d4057156b17062a8848" "f4876796ef5ee9c82b125a096a590c9891cec31320569fc6ff602ff99ed73dca" default))
+ '("835868dcd17131ba8b9619d14c67c127aa18b90a82438c8613586331129dda63" "fc38df02f7c48603f9c392c73f1810011a04b2e1fce8f085d7e15f2b35138863" "45e9823d714d1f28f6d53f79e1981b403ae905acbd027e6fcd5f3414a78a2341" "f91395598d4cb3e2ae6a2db8527ceb83fed79dbaf007f435de3e91e5bda485fb" "6c386d159853b0ee6695b45e64f598ed45bd67c47f671f69100817d7db64724d" "8f5a7a9a3c510ef9cbb88e600c0b4c53cdcdb502cfe3eb50040b7e13c6f4e78e" "4bca89c1004e24981c840d3a32755bf859a6910c65b829d9441814000cf6c3d0" "f2927d7d87e8207fa9a0a003c0f222d45c948845de162c885bf6ad2a255babfd" "e3c64e88fec56f86b49dcdc5a831e96782baf14b09397d4057156b17062a8848" "f4876796ef5ee9c82b125a096a590c9891cec31320569fc6ff602ff99ed73dca" default))
'(default-input-method "czech-qwerty")
+ '(exwm-floating-border-color "#191b20")
+ '(fci-rule-color "#5B6268")
+ '(highlight-tail-colors
+ ((("#333a38" "#99bb66" "green")
+ . 0)
+ (("#2b3d48" "#46D9FF" "brightcyan")
+ . 20)))
+ '(jdee-db-active-breakpoint-face-colors (cons "#1B2229" "#51afef"))
+ '(jdee-db-requested-breakpoint-face-colors (cons "#1B2229" "#98be65"))
+ '(jdee-db-spec-breakpoint-face-colors (cons "#1B2229" "#3f444a"))
+ '(objed-cursor-color "#ff6c6b")
'(package-hidden-regexps '("^I"))
'(package-selected-packages
- '(counsel rainbow-mode edit-indirect helm-ag expand-region elpher sr-speedbar 2048-game vterm notmuch magit lean-mode markdown-mode anki-connect anki-editor doom-themes all-the-icons use-package-ensure which-key use-package org-bullets helm exec-path-from-shell)))
+ '(virtualenvwrapper elpy pdf-tools diminish company-lean counsel rainbow-mode edit-indirect expand-region elpher sr-speedbar 2048-game vterm notmuch magit lean-mode markdown-mode anki-connect anki-editor doom-themes all-the-icons use-package-ensure which-key use-package org-bullets exec-path-from-shell))
+ '(pdf-view-midnight-colors (cons "#bbc2cf" "#282c34"))
+ '(rustic-ansi-faces
+ ["#282c34" "#ff6c6b" "#98be65" "#ECBE7B" "#51afef" "#c678dd" "#46D9FF" "#bbc2cf"])
+ '(vc-annotate-background "#282c34")
+ '(vc-annotate-color-map
+ (list
+ (cons 20 "#98be65")
+ (cons 40 "#b4be6c")
+ (cons 60 "#d0be73")
+ (cons 80 "#ECBE7B")
+ (cons 100 "#e6ab6a")
+ (cons 120 "#e09859")
+ (cons 140 "#da8548")
+ (cons 160 "#d38079")
+ (cons 180 "#cc7cab")
+ (cons 200 "#c678dd")
+ (cons 220 "#d974b7")
+ (cons 240 "#ec7091")
+ (cons 260 "#ff6c6b")
+ (cons 280 "#cf6162")
+ (cons 300 "#9f585a")
+ (cons 320 "#6f4e52")
+ (cons 340 "#5B6268")
+ (cons 360 "#5B6268")))
+ '(vc-annotate-very-old-color nil))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.