diff options
Diffstat (limited to '.emacs.d/rul-emacs.org')
-rw-r--r-- | .emacs.d/rul-emacs.org | 140 |
1 files changed, 122 insertions, 18 deletions
diff --git a/.emacs.d/rul-emacs.org b/.emacs.d/rul-emacs.org index f2a3a45..1ba5aae 100644 --- a/.emacs.d/rul-emacs.org +++ b/.emacs.d/rul-emacs.org @@ -40,10 +40,23 @@ Customization of graphical aspects of Emacs, such as size, panels, etc. (scroll-bar-mode -1) ;; Avoid initial flash of light. -;; Inspired on prot-emacs-avoid-initial-flash-of-light. -(setq mode-line-format nil) -(set-face-attribute 'default nil :background "#000000" :foreground "#ffffff") -(set-face-attribute 'mode-line nil :background "#000000" :foreground "#ffffff" :box 'unspecified) +(defun prot-emacs-re-enable-frame-theme (_frame) + "Re-enable active theme, if any, upon FRAME creation. +Add this to `after-make-frame-functions' so that new frames do +not retain the generic background set by the function +`prot-emacs-avoid-initial-flash-of-light'." + (when-let* ((theme (car custom-enabled-themes))) + (enable-theme theme))) + +(defun prot-emacs-avoid-initial-flash-of-light () + "Avoid flash of light when starting Emacs, if needed. +New frames are instructed to call `prot-emacs-re-enable-frame-theme'." + (setq mode-line-format nil) + (set-face-attribute 'default nil :background "#000000" :foreground "#ffffff") + (set-face-attribute 'mode-line nil :background "#000000" :foreground "#ffffff" :box 'unspecified) + (add-hook 'after-make-frame-functions #'prot-emacs-re-enable-frame-theme)) + +(prot-emacs-avoid-initial-flash-of-light) #+end_src ** Frame configuration @@ -59,11 +72,9 @@ environment. ;; Do not resize when font size changes (setq frame-resize-pixelwise t) -;; By default, start maximized +;; By default, start maximized, undecorated (add-to-list 'default-frame-alist '(fullscreen . maximized)) - -;; No need for titlebar -(modify-frame-parameters nil '((undecorated . t))) +(add-to-list 'default-frame-alist '(undecorated . t)) ;; Name frames to ease switching between them (add-hook 'after-init-hook (lambda () (set-frame-name "main"))) @@ -101,9 +112,10 @@ I use package from both stable and bleeding-edge Melpa. Emacs tends to clutter the filesystem with backup files. A backup file is normally the filename with a =~= suffix. I rather have my filesystem clean, and centralize all backups in a single directory. #+begin_src emacs-lisp :tangle "init.el" -(if (file-directory-p "~/.backup") - (setq backup-directory-alist '(("." . "~/.backup"))) - (message "Directory does not exist: ~/.backup")) +(let ((backup-dir "~/.backup")) + (unless (file-directory-p backup-dir) + (make-directory backup-dir t)) + (setq backup-directory-alist `(("." . ,backup-dir)))) (setq backup-by-copying t ; Don't delink hardlinks @@ -156,6 +168,13 @@ General configurations related to text editing across all modes. (setq auto-save-no-message t) ; Do not print a message when auto-saving (pixel-scroll-precision-mode 1) ; Precision scrolling + + +;; Source: https://protesilaos.com/codelog/2024-12-11-emacs-diff-save-some-buffers/ +(add-to-list 'save-some-buffers-action-alist + (list "d" + (lambda (buffer) (diff-buffer-with-file (buffer-file-name buffer))) + "show diff between the buffer and its file")) #+end_src ** Emacs server I used to run Emacs as a systemd daemon, but it was not too deterministic as sometimes it would break. @@ -184,6 +203,7 @@ Now, I simply start it from Emacs itself. This approach works well for me. (require 'rul-themes) (require 'rul-bindings) (require 'rul-completion) +(require 'rul-dashboard) (require 'rul-fm) (require 'rul-fonts) (require 'rul-io) @@ -503,6 +523,31 @@ context-specific actions in the minibuffer, or common buffers. (provide 'rul-completion) #+end_src +** The =dashboard= module +#+begin_src emacs-lisp :tangle "rul-lisp/packages/rul-dashboard.el" +(use-package page-break-lines :ensure t) + +(use-package dashboard + :ensure t + + :config + (dashboard-setup-startup-hook) + + :custom + (dashboard-center-content t) + (dashboard-startup-banner 3) + (dashboard-items '((recents . 5) + (bookmarks . 5) + (projects . 5) + (agenda . 5) + )) + (dashboard-icon-type 'nerd-icons) + (dashboard-set-heading-icons t) + (dashboard-set-file-icons t) +) + +(provide 'rul-dashboard) +#+end_src ** The =fm= module The =fm= module contains code pertaining to file management. In particular, it's the module that configures =dired= and adds a few extra @@ -559,6 +604,11 @@ installs =fontaine=, a software that allows defining font presets. :default-weight semilight :default-height 230 :bold-weight extrabold) + (writing + :default-height 140 + :default-family "Lato" + :variable-pitch-family "Regular" + ) (t :default-family "Iosevka" :default-weight regular @@ -624,7 +674,9 @@ Emacs can act as Mail User Agent. My preferred package for this is notmuch-hello-auto-refresh t notmuch-hello-recent-searches-max 20 notmuch-hello-thousands-separator "" - notmuch-show-all-tags-list t) + notmuch-show-all-tags-list t + notmuch-show-text/html-blocked-images nil + ) ;; Keymaps (defun rul/capture-mail() @@ -889,7 +941,21 @@ My org mode configuration is quite big, so I split it across multiple files. (setq org-edit-src-content-indentation 0) (use-package org-modern :ensure t) -(use-package org-pomodoro :ensure t) +(use-package org-pomodoro + :ensure t + :config + (defun rul/disable-notifications () + "Disable GNOME notifications." + (shell-command "gsettings set org.gnome.desktop.notifications show-banners false")) + + (defun rul/enable-notifications () + "Enable GNOME notifications." + (shell-command "gsettings set org.gnome.desktop.notifications show-banners true")) + + ;; Add hooks for Pomodoro start and finish + (add-hook 'org-pomodoro-started-hook #'rul/disable-notifications) + (add-hook 'org-pomodoro-finished-hook #'rul/enable-notifications) + (add-hook 'org-pomodoro-killed-hook #'rul/enable-notifications)) ;; (add-hook 'org-mode-hook 'turn-off-auto-fill) ;; (add-hook 'auto-save-hook 'org-save-all-org-buffers) @@ -913,6 +979,10 @@ My org mode configuration is quite big, so I split it across multiple files. (global-set-key (kbd "C-c c") #'org-capture) (global-set-key (kbd "C-c s") #'org-schedule) +(global-set-key (kbd "<f9>") 'bh/punch-in) +(global-set-key (kbd "<f10>") 'bh/punch-out) +(global-set-key (kbd "<f12>") 'org-agenda) + ;; ORG STATES ;; (setq org-todo-keywords (quote ((sequence "TODO(t)" "MAYBE(m)" "NEXT(n)" "|" "DONE(d)") @@ -933,6 +1003,7 @@ My org mode configuration is quite big, so I split it across multiple files. (setq org-log-done (quote time)) (setq org-log-redeadline (quote time)) (setq org-log-reschedule (quote time)) +(setq org-log-into-drawer t) ;; CAPTURE ;; (setq org-capture-templates @@ -957,13 +1028,12 @@ My org mode configuration is quite big, so I split it across multiple files. ("L" "Web Link" entry (file+headline org-refile-path "Read later") - "* %?[[%:link][%:description]] \"\")\n %:initial\n \nCaptured On: %U" + "* %?[[%:link][%:description]]\n %:initial\n \nCaptured On: %U" ) ("l" "Web Link with Selection" entry (file+headline org-refile-path "Read later") - "* [[%:link][%:description]] \n %:initial\n \nCaptured On: %U") - + "* [[%:link][%:description]]\n %:initial\n \nCaptured On: %U") ))) ;; REFILE ;; @@ -1401,7 +1471,7 @@ as the default task." (when bh/keep-clock-running (bh/clock-in-default-task))))))) -(defvar bh/organization-task-id "eb155a82-92b2-4f25-a3c6-0304591af2f9") +(defvar bh/organization-task-id "redefine") ;; org-id-get-create ;; https://stackoverflow.com/a/10091330 (defun zin/org-agenda-skip-tag (tag &optional others) @@ -1434,6 +1504,34 @@ If OTHERS is true, skip all entries that do not correspond to TAG." (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append) +;;; Focusing on current work + +(global-set-key (kbd "<f5>") 'bh/org-todo) +(defun bh/org-todo (arg) + (interactive "p") + (if (equal arg 4) + (save-restriction + (bh/narrow-to-org-subtree) + (org-show-todo-tree nil)) + (bh/narrow-to-org-subtree) + (org-show-todo-tree nil))) + +(global-set-key (kbd "<S-f5>") 'bh/widen) +(defun bh/widen () + (interactive) + (if (equal major-mode 'org-agenda-mode) + (progn + (org-agenda-remove-restriction-lock) + (when org-agenda-sticky + (org-agenda-redo))) + (widen))) + +(defun bh/narrow-to-org-subtree () + (widen) + (org-narrow-to-subtree) + (save-restriction + (org-agenda-set-restriction-lock))) + ;; AGENDA VIEW ;; ;; Do not dim blocked tasks @@ -1500,7 +1598,13 @@ on a single file. ;; Python (use-package blacken :ensure t :defer t) -(add-hook 'python-mode-hook 'py-autopep8-enable-on-save) +(with-eval-after-load 'lsp-mode + (lsp-register-client + (make-lsp-client + :new-connection (lsp-stdio-connection '("ruff" "server")) + :activation-fn (lsp-activate-on "python") + :server-id 'ruff-lsp))) +(add-hook 'python-mode-hook #'lsp) ;; Terraform (use-package terraform-mode :ensure t :defer t) |