commit 1f07d495eeeaed9f12ff1fda98a9592873f44a68
parent cae5d7be873fe80e34cff5284a9491c2bcb63160
Author: dwrz <dwrz@dwrz.net>
Date: Mon, 11 Dec 2023 01:58:21 +0000
Update Emacs init
Diffstat:
M | emacs/init.el | | | 107 | +++++++++++++++++++++++++++++++++++++++++-------------------------------------- |
1 file changed, 56 insertions(+), 51 deletions(-)
diff --git a/emacs/init.el b/emacs/init.el
@@ -1,8 +1,3 @@
-;;; init.el --- Summary
-;;; Commentary:
-;;; Emacs configuration.
-;;; Code:
-
;; Global C source code variables.
(setq auto-save-interval 24
delete-by-moving-to-trash t
@@ -53,6 +48,21 @@
(when filename (kill-new filename)
(message "Copied buffer name '%s' to the clipboard." filename)))))
+(defun dwrz-transpose-line-up ()
+ "Move the current line up."
+ (interactive)
+ (transpose-lines 1)
+ (forward-line -2)
+ (indent-according-to-mode))
+
+(defun dwrz-transpose-line-down ()
+ "Move the current line down."
+ (interactive)
+ (forward-line 1)
+ (transpose-lines 1)
+ (forward-line -1)
+ (indent-according-to-mode))
+
(defun dwrz-org-capture-at-point ()
"Insert an org capture template at point."
(interactive)
@@ -127,37 +137,19 @@
:functions calendar-set-date-style)
(use-package cape
- ;; Alternative prefix keys: C-c p, M-p, M-+, ...
- ;; :bind (("C-c p p" . completion-at-point) ;; capf
- ;; ("C-c p t" . complete-tag) ;; etags
- ;; ("C-c p d" . cape-dabbrev) ;; or dabbrev-completion
- ;; ("C-c p h" . cape-history)
- ;; ("C-c p f" . cape-file)
- ;; ("C-c p k" . cape-keyword)
- ;; ("C-c p s" . cape-elisp-symbol)
- ;; ("C-c p e" . cape-elisp-block)
- ;; ("C-c p a" . cape-abbrev)
- ;; ("C-c p l" . cape-line)
- ;; ("C-c p w" . cape-dict)
- ;; ("C-c p :" . cape-emoji)
- ;; ("C-c p \\" . cape-tex)
- ;; ("C-c p _" . cape-tex)
- ;; ("C-c p ^" . cape-tex)
- ;; ("C-c p &" . cape-sgml)
- ;; ("C-c p r" . cape-rfc1345))
:init
+ (add-to-list 'completion-at-point-functions #'cape-abbrev)
(add-to-list 'completion-at-point-functions #'cape-dabbrev)
(add-to-list 'completion-at-point-functions #'cape-file)
+ (add-to-list 'completion-at-point-functions #'cape-emoji)
+ (add-to-list 'completion-at-point-functions #'cape-dict)
+ (add-to-list 'completion-at-point-functions #'cape-keyword)
+ (add-to-list 'completion-at-point-functions #'cape-history)
+ (add-to-list 'completion-at-point-functions #'cape-sgml)
+ (add-to-list 'completion-at-point-functions #'cape-rfc1345)
(add-to-list 'completion-at-point-functions #'cape-elisp-block)
- ;;(add-to-list 'completion-at-point-functions #'cape-history)
- ;;(add-to-list 'completion-at-point-functions #'cape-keyword)
- ;;(add-to-list 'completion-at-point-functions #'cape-tex)
- ;;(add-to-list 'completion-at-point-functions #'cape-sgml)
- ;;(add-to-list 'completion-at-point-functions #'cape-rfc1345)
- ;;(add-to-list 'completion-at-point-functions #'cape-abbrev)
- ;;(add-to-list 'completion-at-point-functions #'cape-dict)
- ;;(add-to-list 'completion-at-point-functions #'cape-elisp-symbol)
- ;;(add-to-list 'completion-at-point-functions #'cape-line)
+ (add-to-list 'completion-at-point-functions #'cape-elisp-symbol)
+ (add-to-list 'completion-at-point-functions #'cape-line)
:ensure t)
(use-package cc-vars :config (setq-default c-basic-offset 8) :ensure nil)
@@ -169,8 +161,14 @@
(use-package conf-mode :ensure nil)
(use-package consult
- :bind (("C-s" . consult-line)
- ("C-r" . consult-ripgrep))
+ :bind (("C-r" . consult-ripgrep)
+ ("C-s" . consult-line)
+ ("C-x 4 b" . consult-buffer-other-window)
+ ("C-x 5 b" . consult-buffer-other-frame)
+ ("C-x b" . consult-buffer)
+ ("C-x p b" . consult-project-buffer)
+ ("C-x r b" . consult-bookmark))
+
;; :bind (;; C-c bindings in `mode-specific-map'
;; ("C-c M-x" . consult-mode-command)
;; ("C-c h" . consult-history)
@@ -180,17 +178,10 @@
;; ([remap Info-search] . consult-info)
;; ;; C-x bindings in `ctl-x-map'
;; ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command
- ;; ("C-x b" . consult-buffer) ;; orig. switch-to-buffer
- ;; ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window
- ;; ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame
- ;; ("C-x t b" . consult-buffer-other-tab) ;; orig. switch-to-buffer-other-tab
- ;; ("C-x r b" . consult-bookmark) ;; orig. bookmark-jump
- ;; ("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer
;; ;; Custom M-# bindings for fast register access
;; ("M-#" . consult-register-load)
;; ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated)
;; ("C-M-#" . consult-register)
- ;; ;; Other custom bindings
;; ("M-y" . consult-yank-pop) ;; orig. yank-pop
;; ;; M-g bindings in `goto-map'
;; ("M-g e" . consult-compile-error)
@@ -207,7 +198,6 @@
;; ("M-s g" . consult-grep)
;; ("M-s G" . consult-git-grep)
;; ("M-s r" . consult-ripgrep)
- ;; ("M-s l" . consult-line)
;; ("M-s L" . consult-line-multi)
;; ("M-s k" . consult-keep-lines)
;; ("M-s u" . consult-focus-lines)
@@ -572,7 +562,7 @@
"~/projects/home/home.org"
"~/projects/rz/rz.org"
"~/projects/src/src.org")
- work-agenda-files '("~/projects/eti/museum-exchange.org"))
+ eti-agenda-files '("~/projects/eti/eti.org"))
(defun dwrz-switch-org-ctx (ctx)
"Switch org agenda context."
@@ -584,7 +574,7 @@
chimerical-agenda-files))
((string= ctx "dwrz") (setq org-agenda-files
dwrz-agenda-files))
- ((string= ctx "work") (setq org-agenda-files work-agenda-files))))
+ ((string= ctx "eti") (setq org-agenda-files eti-agenda-files))))
;; Set the default context.
(dwrz-switch-org-ctx "dwrz")
@@ -601,7 +591,7 @@
org-agenda-use-time-grid nil
org-agenda-window-setup 'current-window
org-archive-location "~/org/archive.org::")
- :defines chimerical-agenda-files dwrz-agenda-files work-agenda-files
+ :defines chimerical-agenda-files dwrz-agenda-files eti-agenda-files
:functions dwrz-switch-org-ctx
:ensure nil)
@@ -697,9 +687,7 @@
:config (set-register ?c '(file . "~/.config/"))
(set-register ?d '(file . "~/org/diary.org"))
(set-register ?e '(file . "~/projects/eti/"))
- (set-register ?f '(file . "~/projects/finances/finances.org"))
(set-register ?g '(file . "~/org/gtd.org"))
- (set-register ?h '(file . "~/projects/home/home.org"))
(set-register ?i '(file . "~/.config/emacs/init.el"))
(set-register ?j '(file . "~/journal/2023/2023.org"))
(set-register ?o '(file . "~/org/")))
@@ -795,6 +783,21 @@
;; Hydras
;; TODO: add, clean up.
+(defhydra hydra-cape (:color blue)
+ ("q" nil "quit" :column "quit")
+ ("&" cape-sgml "sgml" :column "cape")
+ (":" cape-emoji "emoji" :column "cape")
+ ("a" cape-abbrev "abbrev" :column "cape")
+ ("d" cape-dabbrev "dabbrev" :column "cape")
+ ("e" cape-elisp-block "elisp-block" :column "cape")
+ ("f" cape-file "file" :column "cape")
+ ("h" cape-history "history" :column "cape")
+ ("k" cape-keyword "keyword" :column "cape")
+ ("l" cape-line "line" :column "cape")
+ ("e" cape-elisp-symbol "elisp-symbol" :column "cape")
+ ("r" cape-rfc1345 "RFC 1345" :column "cape")
+ ("w" cape-dict "dict" :column "cape"))
+
(defhydra hydra-highlight (:color blue)
("q" nil "quit" :column "highlight")
("s" highlight-symbol-at-point "symbol" :color blue :column "do")
@@ -804,11 +807,11 @@
("u" unhighlight-regexp "unhighlight" :color blue :column "undo"))
(defhydra hydra-org (:color blue)
- ("q" nil "quit" :column "highlight")
+ ("q" nil "quit" :column "quit")
("a" (dwrz-switch-org-ctx "all") "all" :column "ctx")
("c" (dwrz-switch-org-ctx "chimerical") "chimerical" :column "ctx")
("d" (dwrz-switch-org-ctx "dwrz") "dwrz" :column "ctx")
- ("c" (dwrz-switch-org-ctx "work") "work" :column "ctx"))
+ ("e" (dwrz-switch-org-ctx "eti") "eti" :column "ctx"))
(defhydra hydra-point (:color blue)
("q" nil "quit" :column "point")
@@ -842,6 +845,7 @@
(defhydra hydra-meta-hydra (:color blue)
("q" nil "quit" :column "meta")
+ ("c" hydra-cape/body "cape" :column "hydras")
("h" hydra-highlight/body "highlight" :column "hydras")
("o" hydra-org/body "org" :column "hydras")
("p" hydra-point/body "point" :column "hydras")
@@ -849,6 +853,7 @@
("w" hydra-windows/body "windows" :column "hydras"))
;; KEYBINDINGS
+(global-set-key (kbd "C-c #") 'display-line-numbers-mode)
(global-set-key (kbd "C-c b") 'ibuffer)
(global-set-key (kbd "C-c c") 'dwrz-org-capture-at-point)
(global-set-key (kbd "C-c d") nil)
@@ -872,8 +877,8 @@
(global-set-key (kbd "C-c x") 'hydra-org/body)
(global-set-key (kbd "C-c y") nil)
(global-set-key (kbd "C-c z") nil)
-(global-set-key (kbd "C-c #") 'display-line-numbers-mode)
(global-set-key (kbd "C-x 9") 'dwrz-split-window-two-thirds)
(global-set-key (kbd "C-x C-b") 'ibuffer)
(global-set-key (kbd "C-x t") 'dwrz-shell-in-current-directory)
-;;; init.el ends here
+(global-set-key [(meta down)] 'dwrz-transpose-line-down)
+(global-set-key [(meta up)] 'dwrz-transpose-line-up)