From 0f9db243ad9f851bdf39f80ca684d0274988c174 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Mon, 26 Aug 2024 16:02:44 +0200 Subject: [PATCH 01/69] 'Fresh' start - Use config_new.org as main config file Trimmed down version of old config. Insipred by 'mastering emacs' book to use more the built-in functionality of emacs. I found that It's more than good enough for my usecases. - adapt early-init for quicker startup Stolen from doom emacs - Don't use/load project.org Use .dir-locals.el you peasant --- config.org | 118 +++++++++---------- config_new.org | 299 +++++++++++++++++++++++++++++++++++++++++++++++++ early-init.el | 8 ++ init.el | 21 +++- 4 files changed, 385 insertions(+), 61 deletions(-) create mode 100644 config_new.org diff --git a/config.org b/config.org index bb73156..ff3b9cb 100644 --- a/config.org +++ b/config.org @@ -117,11 +117,13 @@ This configuration requires the installation of : ** Garbage collection -Increase GC threshold to minimize time wasting: +Increase GC threshold to minimize time wasting on modern machines: #+BEGIN_SRC emacs-lisp (setq gc-cons-threshold 20000000) ;; 20 MB #+END_SRC +Recommendation stolen from https://github.com/lewang/flx?tab=readme-ov-file#gc-optimization . + * Base packages to install first ** Elpaca @@ -130,76 +132,43 @@ Replacement for built-in package manager package.el : https://github.com/progfolio/elpaca #+BEGIN_SRC emacs-lisp - (defvar elpaca-installer-version 0.4) - + (defvar elpaca-installer-version 0.7) (defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory)) - (defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory)) - (defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory)) - (defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git" - - :ref nil - - :files (:defaults (:exclude "extensions")) - - :build (:not elpaca--activate-package))) - + :ref nil :depth 1 + :files (:defaults "elpaca-test.el" (:exclude "extensions")) + :build (:not elpaca--activate-package))) (let* ((repo (expand-file-name "elpaca/" elpaca-repos-directory)) - - (build (expand-file-name "elpaca/" elpaca-builds-directory)) - - (order (cdr elpaca-order)) - - (default-directory repo)) - + (build (expand-file-name "elpaca/" elpaca-builds-directory)) + (order (cdr elpaca-order)) + (default-directory repo)) (add-to-list 'load-path (if (file-exists-p build) build repo)) - (unless (file-exists-p repo) - (make-directory repo t) - (when (< emacs-major-version 28) (require 'subr-x)) - (condition-case-unless-debug err - - (if-let ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*")) - - ((zerop (call-process "git" nil buffer t "clone" - - (plist-get order :repo) repo))) - - ((zerop (call-process "git" nil buffer t "checkout" - - (or (plist-get order :ref) "--")))) - - (emacs (concat invocation-directory invocation-name)) - - ((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch" - - "--eval" "(byte-recompile-directory \".\" 0 'force)"))) - - ((require 'elpaca)) - - ((elpaca-generate-autoloads "elpaca" repo))) - - (kill-buffer buffer) - - (error "%s" (with-current-buffer buffer (buffer-string)))) - - ((error) (warn "%s" err) (delete-directory repo 'recursive)))) - + (if-let ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*")) + ((zerop (apply #'call-process `("git" nil ,buffer t "clone" + ,@(when-let ((depth (plist-get order :depth))) + (list (format "--depth=%d" depth) "--no-single-branch")) + ,(plist-get order :repo) ,repo)))) + ((zerop (call-process "git" nil buffer t "checkout" + (or (plist-get order :ref) "--")))) + (emacs (concat invocation-directory invocation-name)) + ((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch" + "--eval" "(byte-recompile-directory \".\" 0 'force)"))) + ((require 'elpaca)) + ((elpaca-generate-autoloads "elpaca" repo))) + (progn (message "%s" (buffer-string)) (kill-buffer buffer)) + (error "%s" (with-current-buffer buffer (buffer-string)))) + ((error) (warn "%s" err) (delete-directory repo 'recursive)))) (unless (require 'elpaca-autoloads nil t) - (require 'elpaca) - (elpaca-generate-autoloads "elpaca" repo) - (load "./elpaca-autoloads"))) - (add-hook 'after-init-hook #'elpaca-process-queues) - (elpaca `(,@elpaca-order)) #+END_SRC @@ -453,6 +422,14 @@ We could use an alias (alias sudo eshell/sudo $*), but to keep things inside thi (setq password-cache-expiry 3600) ; for one hour (time in secs) #+END_SRC +** Vterm + +#+BEGIN_SRC emacs-lisp +(use-package vterm + :ensure t + ) +#+END_SRC + * Dired @@ -754,7 +731,7 @@ will the entire line including the following newline will be deleted. #+BEGIN_SRC emacs-lisp (setq kill-ring-max 5000) ; increase kill-ring capacity -(setq kill-whole-line t) +;; (setq kill-whole-line t) #+END_SRC ** Newline at end-of-file @@ -1115,6 +1092,13 @@ TODO: need to document this * Magit + +#+BEGIN_SRC emacs-lisp +(use-package transient + :ensure t + ) +#+END_SRC + #+BEGIN_SRC emacs-lisp (use-package magit :ensure t @@ -1171,6 +1155,26 @@ https://github.com/joaotavora/yasnippet *** Eglot +Eldoc complaints: + +#+BEGIN_SRC emacs-lisp +(use-package eldoc + :preface + (unload-feature 'eldoc t) + (setq custom-delayed-init-variables '()) + (defvar global-eldoc-mode nil) + :config + (global-eldoc-mode)) + + +(use-package jsonrpc + :preface + (unload-feature 'jsonrpc t) + ) + +#+END_SRC + + #+BEGIN_SRC emacs-lisp (use-package eglot :hook (prog-mode . eglot-ensure) diff --git a/config_new.org b/config_new.org new file mode 100644 index 0000000..c5dd757 --- /dev/null +++ b/config_new.org @@ -0,0 +1,299 @@ +#+STARTUP: overview +#+TITLE: My Emacs +#+CREATOR: Laurens Miers +#+LANGUAGE: en +[[./img/dash_logo.png]] + +* Elpaca + +#+begin_src emacs-lisp +(defvar elpaca-installer-version 0.7) +(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory)) +(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory)) +(defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory)) +(defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git" + :ref nil :depth 1 + :files (:defaults "elpaca-test.el" (:exclude "extensions")) + :build (:not elpaca--activate-package))) +(let* ((repo (expand-file-name "elpaca/" elpaca-repos-directory)) + (build (expand-file-name "elpaca/" elpaca-builds-directory)) + (order (cdr elpaca-order)) + (default-directory repo)) + (add-to-list 'load-path (if (file-exists-p build) build repo)) + (unless (file-exists-p repo) + (make-directory repo t) + (when (< emacs-major-version 28) (require 'subr-x)) + (condition-case-unless-debug err + (if-let ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*")) + ((zerop (apply #'call-process `("git" nil ,buffer t "clone" + ,@(when-let ((depth (plist-get order :depth))) + (list (format "--depth=%d" depth) "--no-single-branch")) + ,(plist-get order :repo) ,repo)))) + ((zerop (call-process "git" nil buffer t "checkout" + (or (plist-get order :ref) "--")))) + (emacs (concat invocation-directory invocation-name)) + ((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch" + "--eval" "(byte-recompile-directory \".\" 0 'force)"))) + ((require 'elpaca)) + ((elpaca-generate-autoloads "elpaca" repo))) + (progn (message "%s" (buffer-string)) (kill-buffer buffer)) + (error "%s" (with-current-buffer buffer (buffer-string)))) + ((error) (warn "%s" err) (delete-directory repo 'recursive)))) + (unless (require 'elpaca-autoloads nil t) + (require 'elpaca) + (elpaca-generate-autoloads "elpaca" repo) + (load "./elpaca-autoloads"))) +(add-hook 'after-init-hook #'elpaca-process-queues) +(elpaca `(,@elpaca-order)) +#+end_src + +#+begin_src emacs-lisp + ;; Install use-package support + (elpaca elpaca-use-package + ;; Enable use-package :ensure support for Elpaca. + (elpaca-use-package-mode) + ) +#+end_src + +* General config + +** Yes-or-no + +Because I'm lazy, important yes-or-no questions can be answered with y-or-n: +#+begin_src emacs-lisp +(defalias 'yes-or-no-p 'y-or-n-p) +#+end_src + +** FIDO + +Use Fake-ido as minibuffer completion system, more info here: +https://www.gnu.org/software/emacs/manual/html_node/emacs/Icomplete.html + +#+begin_src emacs-lisp +(fido-vertical-mode 1) +#+end_src + +** Switch windows + +#+begin_src emacs-lisp +(global-set-key (kbd "M-o") 'other-window) +#+end_src + +** Maximize at startup + +More info : https://www.emacswiki.org/emacs/FullScreen + +#+begin_src emacs-lisp +(push '(fullscreen . maximized) default-frame-alist) +#+end_src + +** ibuffer + +Use list-buffers bigger brother. +#+begin_src emacs-lisp +(global-set-key [remap list-buffers] 'ibuffer) +#+end_src + +** Mark + +#+begin_src emacs-lisp +(global-set-key (kbd "M-SPC") 'mark-word) +#+end_src + +** Isearch + +Display number of matches: +#+begin_src emacs-lisp +(setq-default isearch-lazy-count t) +#+end_src + +Reference that might be interesting for later: +https://endlessparentheses.com/leave-the-cursor-at-start-of-match-after-isearch.html + +** Sudo file + +#+begin_src emacs-lisp +(defun sudo () + "Use TRAMP to `sudo' the current buffer." + (interactive) + (when buffer-file-name + (find-alternate-file + (concat "/sudo:root@localhost:" + buffer-file-name) + ) + ) +) +#+end_src + +* Whole-line-or-region + +Source: +https://github.com/purcell/whole-line-or-region + +Operate on the current line if no region is active. + +#+begin_src emacs-lisp +(use-package whole-line-or-region + :ensure t + :config + (whole-line-or-region-global-mode 1) +) +#+end_src + +* imenu + +** Flatten + +#+begin_src emacs-lisp +(use-package flimenu + :ensure t + :config + (flimenu-global-mode 1) +) + +(global-set-key (kbd "M-i") 'imenu) +#+end_src + +* Terminal + +** Toggle between char- and line-mode + +Courtesy goes to https://joelmccracken.github.io/entries/switching-between-term-mode-and-line-mode-in-emacs-term/ + +#+BEGIN_SRC emacs-lisp +(require 'term) + +(defun jnm/term-toggle-mode () + "Toggles term between line mode and char mode" + (interactive) + (if (term-in-line-mode) + (term-char-mode) + (term-line-mode))) + +(define-key term-mode-map (kbd "C-c C-j") 'jnm/term-toggle-mode) +(define-key term-mode-map (kbd "C-c C-k") 'jnm/term-toggle-mode) + +(define-key term-raw-map (kbd "C-c C-j") 'jnm/term-toggle-mode) +(define-key term-raw-map (kbd "C-c C-k") 'jnm/term-toggle-mode) +#+END_SRC + +For the keybindings, we have to defien them in both raw and line mode. From the help page of term mode: + If you define custom keybindings, make sure to assign them to the + correct keymap (or to both): use ‘term-raw-map’ in raw mode and + ‘term-mode-map’ in line mode. + +* Theme + +#+BEGIN_SRC emacs-lisp +(use-package monokai-theme + :ensure t + :init + (load-theme 'monokai t) +) +#+END_SRC + +* Dashboard + +#+begin_src emacs-lisp +(use-package dashboard + :ensure t + :config + (add-hook 'elpaca-after-init-hook #'dashboard-insert-startupify-lists) + (add-hook 'elpaca-after-init-hook #'dashboard-initialize) + (dashboard-setup-startup-hook)) +#+end_src + +* Hydra + +Install and wait for hydra to be available since we are using it in this init.el : +#+begin_src emacs-lisp +(use-package hydra + :ensure (:wait t) + ) +#+end_src + +** Text zoom + +#+begin_src emacs-lisp +(defhydra hydra-zoom (global-map "") + "zoom" + ("g" text-scale-increase "in") + ("l" text-scale-decrease "out") +) +#+end_src + +* Programming + +** Eglot + +#+BEGIN_SRC emacs-lisp +(use-package eglot + :ensure t + :defer t + ;; This doesn't work for some reason, workaround below + ;;:hook (prog-mode . eglot-ensure) + ;; :config + ;; (add-hook 'prog-mode-hook 'eglot-ensure) +) +#+END_SRC + +Workaround to enable eglot in all programming modes: +#+BEGIN_SRC emacs-lisp +(add-hook 'prog-mode-hook 'eglot-ensure) +#+END_SRC + +** Yasnippet + +#+BEGIN_SRC emacs-lisp +(use-package yasnippet + :ensure t + :config + (yas-reload-all) + (add-hook 'prog-mode-hook 'yas-minor-mode) +) +#+END_SRC + +** Magit + +#+BEGIN_SRC emacs-lisp +(use-package magit + :ensure t +) +#+END_SRC + +* Multiple cursors + +#+BEGIN_SRC emacs-lisp +(use-package multiple-cursors + :ensure t +) +#+END_SRC + +* Comment-dwim-2 + +Replacement for built-in =comment-dwim=, more comment features. + +https://github.com/remyferre/comment-dwim-2 + +#+BEGIN_SRC emacs-lisp +(use-package comment-dwim-2 + :ensure t + :config + (global-set-key (kbd "M-;") 'comment-dwim-2) +) +#+END_SRC + +* Projectile + +#+BEGIN_SRC emacs-lisp +(use-package projectile + :ensure t + :hook (prog-mode . projectile-mode) +;; :config +;; (setq projectile-globally-ignored-directories (cons ".ccls-cache" projectile-globally-ignored-directories)) +;; (setq projectile-indexing-method 'alien) +;; (setq projectile-enable-caching t) +;; (projectile-mode) +) + +#+END_SRC diff --git a/early-init.el b/early-init.el index 512068a..0fe1b95 100644 --- a/early-init.el +++ b/early-init.el @@ -1 +1,9 @@ (setq package-enable-at-startup nil) + + +;; Local Variables: +;; no-byte-compile: t +;; no-native-compile: t +;; no-update-autoloads: t +;; End: + diff --git a/init.el b/init.el index 444b5ab..b25e39d 100644 --- a/init.el +++ b/init.el @@ -5,13 +5,26 @@ ;;; ... (let ((gc-cons-threshold most-positive-fixnum)) ;; This is the actual config file. It is omitted if it doesn't exist so emacs won't refuse to launch. - (defvar config-file (expand-file-name "config.org" user-emacs-directory)) - (defvar project-file (expand-file-name "project.org" user-emacs-directory)) + (defvar config-file (expand-file-name "config_new.org" user-emacs-directory)) + ;;(defvar project-file (expand-file-name "project.org" user-emacs-directory)) (when (file-readable-p config-file) (org-babel-load-file (expand-file-name config-file))) ;; If it exists, load some project-specific configurations. - (when (file-readable-p project-file) - (org-babel-load-file (expand-file-name project-file))) + ;;(when (file-readable-p project-file) + ;; (org-babel-load-file (expand-file-name project-file))) ) +(custom-set-variables + ;; custom-set-variables was added by Custom. + ;; 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. + '(package-selected-packages + '(flycheck-clang-tidy org-tree-slide ox-reveal writeroom-mode visual-fill-column org-present clang-format+ dash))) +(custom-set-faces + ;; custom-set-faces was added by Custom. + ;; 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. + ) From 0db6d1753e8fc43e2b3b7c7c49f328a733f4f539 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Sun, 8 Sep 2024 11:58:49 +0200 Subject: [PATCH 02/69] ADD multipe-cursor keybindings --- config_new.org | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config_new.org b/config_new.org index c5dd757..d073aef 100644 --- a/config_new.org +++ b/config_new.org @@ -266,6 +266,12 @@ Workaround to enable eglot in all programming modes: #+BEGIN_SRC emacs-lisp (use-package multiple-cursors :ensure t + :bind + ("C-x r a" . mc/edit-beginnings-of-lines) + ("C-x r e" . mc/edit-ends-of-lines) + ("C->" . mc/mark-next-like-this) + ("C-<" . mc/mark-previous-like-this) + ("C-c C->" . mc/mark-all-like-this) ) #+END_SRC From ef04adcfd92e173ec3a28cbe5bb441312dfbea94 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Sun, 8 Sep 2024 18:02:47 +0200 Subject: [PATCH 03/69] ADD hippie-expand Remap dabbrev to hippie-expand --- config_new.org | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config_new.org b/config_new.org index d073aef..04a3253 100644 --- a/config_new.org +++ b/config_new.org @@ -125,6 +125,12 @@ https://endlessparentheses.com/leave-the-cursor-at-start-of-match-after-isearch. ) #+end_src +** Abbrev + +#+begin_src emacs-lisp +(global-set-key [remap dabbrev-expand] 'hippie-expand) +#+end_src + * Whole-line-or-region Source: From 3bf48f5927c3d64d7f3c340461f8bf3b006b972a Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Sun, 8 Sep 2024 18:03:02 +0200 Subject: [PATCH 04/69] ADD zap-up-to-char keybinding --- config_new.org | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config_new.org b/config_new.org index 04a3253..2ef4bb6 100644 --- a/config_new.org +++ b/config_new.org @@ -131,6 +131,12 @@ https://endlessparentheses.com/leave-the-cursor-at-start-of-match-after-isearch. (global-set-key [remap dabbrev-expand] 'hippie-expand) #+end_src +** Zap + +#+begin_src emacs-lisp +(global-set-key (kbd "M-S-z") 'zap-up-to-char) +#+end_src + * Whole-line-or-region Source: From d184007b9b3c9b2f8c44f21622022f9c86370b4e Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Sun, 8 Sep 2024 18:03:19 +0200 Subject: [PATCH 05/69] ADD spell checking in prog-mode --- config_new.org | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/config_new.org b/config_new.org index 2ef4bb6..ff8ee7a 100644 --- a/config_new.org +++ b/config_new.org @@ -137,6 +137,14 @@ https://endlessparentheses.com/leave-the-cursor-at-start-of-match-after-isearch. (global-set-key (kbd "M-S-z") 'zap-up-to-char) #+end_src +** Spell checking + +Look into customizing the 'ispell' group. + +#+begin_src emacs-lisp +(add-hook 'prog-mode-hook 'flyspell-prog-mode) +#+end_src + * Whole-line-or-region Source: From db266f3ecec8b746c3decd4319b13b732f35dd19 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Sun, 8 Sep 2024 18:03:32 +0200 Subject: [PATCH 06/69] ADD 'transient' dependant package for magit --- config_new.org | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/config_new.org b/config_new.org index ff8ee7a..d567839 100644 --- a/config_new.org +++ b/config_new.org @@ -275,6 +275,18 @@ Workaround to enable eglot in all programming modes: ** Magit +*** Transient + +Magit depends on this and it seems it's not installed as a dependency, so install it explicitly. + +#+BEGIN_SRC emacs-lisp +(use-package transient + :ensure t + ) +#+END_SRC + +*** Core + #+BEGIN_SRC emacs-lisp (use-package magit :ensure t From bd3f73747779c16d9efa643f47113ca3e675340d Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Sun, 8 Sep 2024 18:19:53 +0200 Subject: [PATCH 07/69] ADD enhanced dired --- config_new.org | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config_new.org b/config_new.org index d567839..2876e5c 100644 --- a/config_new.org +++ b/config_new.org @@ -145,6 +145,12 @@ Look into customizing the 'ispell' group. (add-hook 'prog-mode-hook 'flyspell-prog-mode) #+end_src +* Dired + +#+begin_src emacs-lisp +(require 'dired-x) +#+end_src + * Whole-line-or-region Source: From 00d40a2d5ac4f40adcf904b5903263e8dc7f9900 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Sun, 8 Sep 2024 18:22:53 +0200 Subject: [PATCH 08/69] PROJECTILE: Initial configuration Not sure yet about this but working for now. Override default project keymap --- config_new.org | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/config_new.org b/config_new.org index 2876e5c..6d4403d 100644 --- a/config_new.org +++ b/config_new.org @@ -332,12 +332,11 @@ https://github.com/remyferre/comment-dwim-2 #+BEGIN_SRC emacs-lisp (use-package projectile :ensure t - :hook (prog-mode . projectile-mode) -;; :config -;; (setq projectile-globally-ignored-directories (cons ".ccls-cache" projectile-globally-ignored-directories)) -;; (setq projectile-indexing-method 'alien) -;; (setq projectile-enable-caching t) -;; (projectile-mode) + :config + (setq projectile-indexing-method 'alien) + (setq projectile-enable-caching t) + (define-key projectile-mode-map (kbd "C-x p") 'projectile-command-map) + (projectile-mode +1) ) #+END_SRC From a6c81d05bac145c6fa8b8efabf9d03f93c32890d Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Sun, 8 Sep 2024 18:45:34 +0200 Subject: [PATCH 09/69] ADD smartparens --- config_new.org | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/config_new.org b/config_new.org index 6d4403d..1bfa1c6 100644 --- a/config_new.org +++ b/config_new.org @@ -299,6 +299,22 @@ Magit depends on this and it seems it's not installed as a dependency, so instal ) #+END_SRC +** Smartparens +Smart minor-mode to deal with pairs. + +https://github.com/Fuco1/smartparens + +#+BEGIN_SRC emacs-lisp +(use-package smartparens + :ensure t + :bind + ("C-M-w" . sp-copy-sexp) + :hook (prog-mode text-mode markdown-mode) + :config + (require 'smartparens-config) +) +#+END_SRC + * Multiple cursors #+BEGIN_SRC emacs-lisp From b8ef2937f35169ad15be4a1f9090759ff6c5a8b4 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Thu, 12 Sep 2024 12:34:16 +0200 Subject: [PATCH 10/69] ADD save history and recentf --- config_new.org | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/config_new.org b/config_new.org index 1bfa1c6..6a890d2 100644 --- a/config_new.org +++ b/config_new.org @@ -57,6 +57,25 @@ * General config +** Save history and recent files + +#+begin_src emacs-lisp +;; The built-in `savehist-mode' saves minibuffer histories. Vertico +;; can then use that information to put recently selected options at +;; the top. +;; +;; Further reading: https://protesilaos.com/emacs/dotemacs#h:25765797-27a5-431e-8aa4-cc890a6a913a +(savehist-mode 1) + +;; The built-in `recentf-mode' keeps track of recently visited files. +;; You can then access those through the `consult-buffer' interface or +;; with `recentf-open'/`recentf-open-files'. +;; +;; I do not use this facility, because the files I care about are +;; either in projects or are bookmarked. +(recentf-mode 1) +#+end_src + ** Yes-or-no Because I'm lazy, important yes-or-no questions can be answered with y-or-n: From 9541cfbf440ecd26561adb6161e730170788b8fe Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Thu, 12 Sep 2024 12:34:31 +0200 Subject: [PATCH 11/69] Delete trailing whitespaces before-saving Enable globally because I don't know of a scenario where we would ever want this. --- config_new.org | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/config_new.org b/config_new.org index 6a890d2..4866110 100644 --- a/config_new.org +++ b/config_new.org @@ -57,6 +57,12 @@ * General config +** Delete trailing whitespaces + +#+BEGIN_SRC emacs-lisp +(add-hook 'before-save-hook 'delete-trailing-whitespace) +#+END_SRC + ** Save history and recent files #+begin_src emacs-lisp @@ -103,7 +109,7 @@ https://www.gnu.org/software/emacs/manual/html_node/emacs/Icomplete.html More info : https://www.emacswiki.org/emacs/FullScreen #+begin_src emacs-lisp -(push '(fullscreen . maximized) default-frame-alist) +(push '(fullscreen . maximized) default-frame-alist) #+end_src ** ibuffer @@ -284,7 +290,7 @@ Install and wait for hydra to be available since we are using it in this init.el Workaround to enable eglot in all programming modes: #+BEGIN_SRC emacs-lisp -(add-hook 'prog-mode-hook 'eglot-ensure) +(add-hook 'prog-mode-hook 'eglot-ensure) #+END_SRC ** Yasnippet @@ -373,5 +379,3 @@ https://github.com/remyferre/comment-dwim-2 (define-key projectile-mode-map (kbd "C-x p") 'projectile-command-map) (projectile-mode +1) ) - -#+END_SRC From 7329b044f3861f515bdaa2399c9253658dc859d9 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Thu, 12 Sep 2024 12:35:11 +0200 Subject: [PATCH 12/69] ADD save-symbol-at-point function This was originally supplied by smartparens but I don't need the whole package for this function. Other functionality which I used from smartparens is available with electric-pair-mode . --- config_new.org | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/config_new.org b/config_new.org index 4866110..688035d 100644 --- a/config_new.org +++ b/config_new.org @@ -379,3 +379,17 @@ https://github.com/remyferre/comment-dwim-2 (define-key projectile-mode-map (kbd "C-x p") 'projectile-command-map) (projectile-mode +1) ) + +* Custom + +** Save symbol at point + +#+BEGIN_SRC emacs-lisp +(defun myrmi/save-symbol-at-point () + "Make symbol at point the latest kill in the kill ring." + (interactive) + (let ((symbol (thing-at-point 'symbol))) + (when symbol (kill-new symbol)))) + +(global-set-key (kbd "C-M-w") 'myrmi/save-symbol-at-point) +#+END_SRC From 801188ed90116da9c696fdaf81e26cd137437be1 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Thu, 12 Sep 2024 12:36:50 +0200 Subject: [PATCH 13/69] ADD electric-pair mode in prog-mode This was originally supplied by smartparens but I'm only using a subset of this package. The main functionality which I used from smartparens is available with electric-pair-mode . --- config_new.org | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config_new.org b/config_new.org index 688035d..de2f4e0 100644 --- a/config_new.org +++ b/config_new.org @@ -275,6 +275,11 @@ Install and wait for hydra to be available since we are using it in this init.el * Programming +** Electric pair +#+BEGIN_SRC emacs-lisp +(add-hook 'prog-mode-hook 'electric-pair-mode) +#+END_SRC + ** Eglot #+BEGIN_SRC emacs-lisp From 22a827592d6cb8eda46f7972be1541d9f657cf6c Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Thu, 12 Sep 2024 12:38:09 +0200 Subject: [PATCH 14/69] REMOVE imenu use consult-imenu in future --- config_new.org | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/config_new.org b/config_new.org index de2f4e0..4e3591d 100644 --- a/config_new.org +++ b/config_new.org @@ -191,20 +191,6 @@ Operate on the current line if no region is active. ) #+end_src -* imenu - -** Flatten - -#+begin_src emacs-lisp -(use-package flimenu - :ensure t - :config - (flimenu-global-mode 1) -) - -(global-set-key (kbd "M-i") 'imenu) -#+end_src - * Terminal ** Toggle between char- and line-mode From df5d0349070cfebfc3f151f8112cd875e5c3ce97 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Thu, 12 Sep 2024 12:38:50 +0200 Subject: [PATCH 15/69] PROJECTILE: install project.el hooks Some packages use the project.el functions/bindings (like consult, ...) for their functionality. Install the projectile bindings so that they start using the projectile framework. --- config_new.org | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config_new.org b/config_new.org index 4e3591d..f53f9a0 100644 --- a/config_new.org +++ b/config_new.org @@ -369,7 +369,10 @@ https://github.com/remyferre/comment-dwim-2 (setq projectile-enable-caching t) (define-key projectile-mode-map (kbd "C-x p") 'projectile-command-map) (projectile-mode +1) + (require 'project) + (add-hook 'project-find-functions #'project-projectile) ) +#+END_SRC * Custom From 35102de7f578cca937af0afeb8342a149bcd2d48 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Thu, 12 Sep 2024 12:45:00 +0200 Subject: [PATCH 16/69] REMOVE fido, ADD Vertico Switch from fido to vertico --- config_new.org | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/config_new.org b/config_new.org index f53f9a0..893ccfd 100644 --- a/config_new.org +++ b/config_new.org @@ -55,6 +55,23 @@ ) #+end_src +* Vertico-stack + +** Vertico + +#+BEGIN_SRC emacs-lisp +;; Enable vertico +(use-package vertico + :ensure t + ;; :custom + ;; (vertico-scroll-margin 0) ;; Different scroll margin + ;; (vertico-count 20) ;; Show more candidates + ;; (vertico-resize t) ;; Grow and shrink the Vertico minibuffer + ;; (vertico-cycle t) ;; Enable cycling for `vertico-next/previous' + :init + (vertico-mode)) +#+END_SRC + * General config ** Delete trailing whitespaces @@ -89,15 +106,6 @@ Because I'm lazy, important yes-or-no questions can be answered with y-or-n: (defalias 'yes-or-no-p 'y-or-n-p) #+end_src -** FIDO - -Use Fake-ido as minibuffer completion system, more info here: -https://www.gnu.org/software/emacs/manual/html_node/emacs/Icomplete.html - -#+begin_src emacs-lisp -(fido-vertical-mode 1) -#+end_src - ** Switch windows #+begin_src emacs-lisp From 393bace7cff1e1b535dc0ab35fccc4883cc6fa53 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Thu, 12 Sep 2024 12:45:25 +0200 Subject: [PATCH 17/69] ADD consult example config --- config_new.org | 111 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/config_new.org b/config_new.org index 893ccfd..bb451bd 100644 --- a/config_new.org +++ b/config_new.org @@ -72,6 +72,117 @@ (vertico-mode)) #+END_SRC +** Consult + +#+BEGIN_SRC emacs-lisp +(use-package consult + :ensure t + ;; Replace bindings. Lazily loaded by `use-package'. + :bind (;; C-c bindings in `mode-specific-map' + ;; ("C-c M-x" . consult-mode-command) + ;; ("C-c h" . consult-history) + ;; ("C-c k" . consult-kmacro) + ;; ("C-c m" . consult-man) + ;; ("C-c i" . consult-info) + ([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) + ;; ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck + ("M-g g" . consult-goto-line) ;; orig. goto-line + ("M-g M-g" . consult-goto-line) ;; orig. goto-line + ;; ("M-g o" . consult-outline) ;; Alternative: consult-org-heading + ;; ("M-g m" . consult-mark) + ;; ("M-g k" . consult-global-mark) + ("M-i" . consult-imenu) + ("M-I" . consult-imenu-multi) + ;; M-s bindings in `search-map' + ;; ("M-s d" . consult-find) ;; Alternative: consult-fd + ;; ("M-s c" . consult-locate) + ;; ("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) + ;; Isearch integration + ("M-s e" . consult-isearch-history) + :map isearch-mode-map + ("M-e" . consult-isearch-history) ;; orig. isearch-edit-string + ("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string + ("M-s l" . consult-line) ;; needed by consult-line to detect isearch + ("M-s L" . consult-line-multi) ;; needed by consult-line to detect isearch + ;; Minibuffer history + :map minibuffer-local-map + ("M-s" . consult-history) ;; orig. next-matching-history-element + ("M-r" . consult-history) ;; orig. previous-matching-history-element + ) + + ;; Enable automatic preview at point in the *Completions* buffer. This is + ;; relevant when you use the default completion UI. + :hook (completion-list-mode . consult-preview-at-point-mode) + + ;; The :init configuration is always executed (Not lazy) + :init + + ;; Optionally configure the register formatting. This improves the register + ;; preview for `consult-register', `consult-register-load', + ;; `consult-register-store' and the Emacs built-ins. + ;; (setq register-preview-delay 0.5 + ;; register-preview-function #'consult-register-format) + + ;; Optionally tweak the register preview window. + ;; This adds thin lines, sorting and hides the mode line of the window. + ;; (advice-add #'register-preview :override #'consult-register-window) + + ;; Use Consult to select xref locations with preview + (setq xref-show-xrefs-function #'consult-xref + xref-show-definitions-function #'consult-xref) + + ;; Configure other variables and modes in the :config section, + ;; after lazily loading the package. + ;; :config + + ;; Optionally configure preview. The default value + ;; is 'any, such that any key triggers the preview. + ;; (setq consult-preview-key 'any) + ;; (setq consult-preview-key "M-.") + ;; (setq consult-preview-key '("S-" "S-")) + ;; For some commands and buffer sources it is useful to configure the + ;; :preview-key on a per-command basis using the `consult-customize' macro. + ;; (consult-customize + ;; consult-theme :preview-key '(:debounce 0.2 any) + ;; consult-ripgrep consult-git-grep consult-grep + ;; consult-bookmark consult-recent-file consult-xref + ;; consult--source-bookmark consult--source-file-register + ;; consult--source-recent-file consult--source-project-recent-file + ;; :preview-key "M-." + ;; :preview-key '(:debounce 0.4 any)) + + ;; Optionally configure the narrowing key. + ;; Both < and C-+ work reasonably well. + ;; (setq consult-narrow-key "<") ;; "C-+" + + ;; Optionally make narrowing help available in the minibuffer. + ;; You may want to use `embark-prefix-help-command' or which-key instead. + ;; (keymap-set consult-narrow-map (concat consult-narrow-key " ?") #'consult-narrow-help) +) +#+END_SRC + * General config ** Delete trailing whitespaces From 17515a83778ba08e25ca158ad5753f4be29698e7 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Thu, 12 Sep 2024 12:45:39 +0200 Subject: [PATCH 18/69] ADD Corfu For nice popup in eglot. --- config_new.org | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/config_new.org b/config_new.org index bb451bd..9d3ade8 100644 --- a/config_new.org +++ b/config_new.org @@ -183,6 +183,35 @@ ) #+END_SRC +** Corfu + +#+BEGIN_SRC emacs-lisp + (use-package corfu + :ensure t + ;; Optional customizations + ;; :custom + ;; (corfu-cycle t) ;; Enable cycling for `corfu-next/previous' + ;; (corfu-auto t) ;; Enable auto completion + ;; (corfu-separator ?\s) ;; Orderless field separator + ;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary + ;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match + ;; (corfu-preview-current nil) ;; Disable current candidate preview + ;; (corfu-preselect 'prompt) ;; Preselect the prompt + ;; (corfu-on-exact-match nil) ;; Configure handling of exact matches + ;; (corfu-scroll-margin 5) ;; Use scroll margin + + ;; Enable Corfu only for certain modes. See also `global-corfu-modes'. + ;; :hook ((prog-mode . corfu-mode) + ;; (shell-mode . corfu-mode) + ;; (eshell-mode . corfu-mode)) + + ;; Recommended: Enable Corfu globally. This is recommended since Dabbrev can + ;; be used globally (M-/). See also the customization variable + ;; `global-corfu-modes' to exclude certain modes. + :init + (global-corfu-mode)) +#+end_src + * General config ** Delete trailing whitespaces From 6e1ed0ebb6af66e0553d2f43f8567a6a713ad36c Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Thu, 12 Sep 2024 12:45:57 +0200 Subject: [PATCH 19/69] ADD Orderless --- config_new.org | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/config_new.org b/config_new.org index 9d3ade8..51e576b 100644 --- a/config_new.org +++ b/config_new.org @@ -212,6 +212,31 @@ (global-corfu-mode)) #+end_src +** Orderless + +#+begin_src emacs-lisp + (use-package orderless + :ensure t + :demand t + :custom + (completion-styles '(orderless basic)) + ;; (gnus-completion-styles '(orderless substring basic)) + ;; (completion-category-overrides '((file (styles basic partial-completion)))) + + ;; Below not necessary if using vertico + ;; (completion-category-overrides '( + ;; (command (styles orderless basic partial-completion)) + ;; (file (styles orderless basic partial-completion)) + ;;;; (buffer (styles orderless basic)) + ;; (variable (styles orderless basic)) + ;; (symbol (styles orderless basic)) + ;; (consult-location (styles orderless)) + ;; (consult-multi (styles orderless)) + ;; ) + ;; ) + ) +#+end_src + * General config ** Delete trailing whitespaces From 49e26e5568c3b88fdbd73250acfc5271064b2dfb Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Thu, 12 Sep 2024 12:46:07 +0200 Subject: [PATCH 20/69] ADD Marginalia Some eye candy in the minibuffer --- config_new.org | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/config_new.org b/config_new.org index 51e576b..e4e294b 100644 --- a/config_new.org +++ b/config_new.org @@ -237,6 +237,27 @@ ) #+end_src +** Marginalia + +#+begin_src emacs-lisp +;; Enable rich annotations using the Marginalia package +(use-package marginalia + :ensure t + ;; Bind `marginalia-cycle' locally in the minibuffer. To make the binding + ;; available in the *Completions* buffer, add it to the + ;; `completion-list-mode-map'. + :bind (:map minibuffer-local-map + ("M-A" . marginalia-cycle)) + + ;; The :init section is always executed. + :init + + ;; Marginalia must be activated in the :init section of use-package such that + ;; the mode gets enabled right away. Note that this forces loading the + ;; package. + (marginalia-mode)) +#+end_src + * General config ** Delete trailing whitespaces From 1549038f73f74b2c4c756a89a76b6742364c193f Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Thu, 12 Sep 2024 12:58:13 +0200 Subject: [PATCH 21/69] ADD backup configuration Store backups in /backups --- config_new.org | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/config_new.org b/config_new.org index e4e294b..43ae68b 100644 --- a/config_new.org +++ b/config_new.org @@ -285,6 +285,27 @@ (recentf-mode 1) #+end_src +** Backups + +#+BEGIN_SRC emacs-lisp +(defvar myrmi-backup-directory (concat user-emacs-directory "backups")) +(if (not (file-exists-p myrmi-backup-directory)) + (make-directory myrmi-backup-directory t) + ) +(setq backup-directory-alist `(("." . ,myrmi-backup-directory))) +(setq make-backup-files t + backup-by-copying t + version-control t + delete-old-versions t + delete-by-moving-to-trash t + kept-old-versions 6 + kept-new-versions 9 + auto-save-default t + auto-save-timeout 20 + auto-save-interval 200 + ) +#+END_SRC + ** Yes-or-no Because I'm lazy, important yes-or-no questions can be answered with y-or-n: From 43c75a29e21c33f6d73a14375025c43368682297 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Thu, 12 Sep 2024 13:03:17 +0200 Subject: [PATCH 22/69] REMOVE custom-set-variables Find a way to move this elegantly to a file which can be ignored by git --- init.el | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/init.el b/init.el index b25e39d..4a3164f 100644 --- a/init.el +++ b/init.el @@ -15,16 +15,3 @@ ;;(when (file-readable-p project-file) ;; (org-babel-load-file (expand-file-name project-file))) ) -(custom-set-variables - ;; custom-set-variables was added by Custom. - ;; 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. - '(package-selected-packages - '(flycheck-clang-tidy org-tree-slide ox-reveal writeroom-mode visual-fill-column org-present clang-format+ dash))) -(custom-set-faces - ;; custom-set-faces was added by Custom. - ;; 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. - ) From 53dd2a90840d4a723280f9ee460cb59a31a39f7d Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Thu, 12 Sep 2024 21:37:06 +0200 Subject: [PATCH 23/69] ADD custom ceedling commands Convience function to run the ceedling command --- config_new.org | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/config_new.org b/config_new.org index 43ae68b..8b6a9d7 100644 --- a/config_new.org +++ b/config_new.org @@ -602,3 +602,23 @@ https://github.com/remyferre/comment-dwim-2 (global-set-key (kbd "C-M-w") 'myrmi/save-symbol-at-point) #+END_SRC + +** Ceedling + +#+BEGIN_SRC emacs-lisp +(defvar ceedling-project-file-name "project.yml") +(defvar ceedling-cmd "ceedling") +(defvar ceedling-project-root ".") + +(defun myrmi/run-ceedling-tests (&optional file-name) + (interactive) + (let* ( + (file-path (or file-name buffer-file-name)) + (root-path (or (locate-dominating-file file-path ceedling-project-file-name) ceedling-project-root)) + ) + (compile + (concat "cd " root-path " && " ceedling-cmd) + ) + ) + ) +#+END_SRC From 12b33b1f498bcea3e1edcad76e5bde84ed90ca00 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Thu, 12 Sep 2024 21:37:32 +0200 Subject: [PATCH 24/69] PROJECTILE: use hybrid method Gives more flexibility with .projectile file IMO to add/remove folders from projectile-find-file . --- config_new.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config_new.org b/config_new.org index 8b6a9d7..07ef738 100644 --- a/config_new.org +++ b/config_new.org @@ -580,7 +580,7 @@ https://github.com/remyferre/comment-dwim-2 (use-package projectile :ensure t :config - (setq projectile-indexing-method 'alien) + (setq projectile-indexing-method 'hybrid) (setq projectile-enable-caching t) (define-key projectile-mode-map (kbd "C-x p") 'projectile-command-map) (projectile-mode +1) From 832bc40d8141f23bc8d0a607795690d2410f5377 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Sat, 14 Sep 2024 08:37:47 +0200 Subject: [PATCH 25/69] Set path/exec-path to shell path For .dir-locals.el to find the custom programs --- config_new.org | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/config_new.org b/config_new.org index 07ef738..e0d116c 100644 --- a/config_new.org +++ b/config_new.org @@ -622,3 +622,16 @@ https://github.com/remyferre/comment-dwim-2 ) ) #+END_SRC + +** Set path to shell path + +#+BEGIN_SRC emacs-lisp +(defun set-exec-path-from-shell-PATH () + (let ((path-from-shell + (replace-regexp-in-string "[[:space:]\n]*$" "" + (shell-command-to-string "$SHELL -l -c 'echo $PATH'")))) + (setenv "PATH" path-from-shell) + (setq exec-path (split-string path-from-shell path-separator)))) + +(set-exec-path-from-shell-PATH) +#+END_SRC From 1475b4acb8e0e163a2edee2d4b1f6dc256fe41a4 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Sun, 15 Sep 2024 17:46:29 +0200 Subject: [PATCH 26/69] CUSTOM: Add functions to reload .dir-locals.el --- config_new.org | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/config_new.org b/config_new.org index e0d116c..f6f9247 100644 --- a/config_new.org +++ b/config_new.org @@ -635,3 +635,23 @@ https://github.com/remyferre/comment-dwim-2 (set-exec-path-from-shell-PATH) #+END_SRC + +** Reload dir-locals.el + +#+BEGIN_SRC emacs-lisp +(defun myrmi/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 myrmi/reload-dir-locals-for-all-buffers-in-this-directory () + "For every buffer with the same `default-directory` as the + current buffer, reload dir-locals." + (interactive) + (let ((dir default-directory)) + (dolist (buffer (buffer-list)) + (with-current-buffer buffer + (when (equal default-directory dir) + (myrmi/reload-dir-locals-for-current-buffer)))))) +#+END_SRC From f44190a45d0ca5a25241182a0fe670efda7424fa Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Sun, 15 Sep 2024 17:47:30 +0200 Subject: [PATCH 27/69] ELISP: add demos to describe-function It saves me some extra googling. --- config_new.org | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/config_new.org b/config_new.org index f6f9247..4747938 100644 --- a/config_new.org +++ b/config_new.org @@ -589,6 +589,18 @@ https://github.com/remyferre/comment-dwim-2 ) #+END_SRC +* Elisp + +** Add demos to describe-function + +#+BEGIN_SRC emacs-lisp +(use-package elisp-demos + :ensure t + :config + (advice-add 'describe-function-1 :after #'elisp-demos-advice-describe-function-1) + ) +#+END_SRC + * Custom ** Save symbol at point From 9d84faf97a55f81ca4f58d6cb2c40f9f07d9aff4 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Sun, 15 Sep 2024 19:40:21 +0200 Subject: [PATCH 28/69] ADD custom visit/reload config functions --- config_new.org | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/config_new.org b/config_new.org index 4747938..b5d6d45 100644 --- a/config_new.org +++ b/config_new.org @@ -667,3 +667,20 @@ https://github.com/remyferre/comment-dwim-2 (when (equal default-directory dir) (myrmi/reload-dir-locals-for-current-buffer)))))) #+END_SRC + +** Visit/reload config + +These snippets assume my-config-file variable is set outside this configuration. +This should normally be done by the init.el to load this configuration. + +#+BEGIN_SRC emacs-lisp +(defun myrmi/visit-config () + "Reloads ~/.emacs.d/config.org at runtime" + (interactive) + (find-file my-config-file)) + +(defun myrmi/reload-config () + "Reloads ~/.emacs.d/config.org at runtime" + (interactive) + (org-babel-load-file my-config-file)) +#+END_SRC From f121ec0330da1929c07ccea7939309ba013a624b Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 17 Sep 2024 20:55:04 +0200 Subject: [PATCH 29/69] REMOVE smartparens Replaced with electric-pair mode, good enough for my usecase. Don't need all the fancy stuff smartparens provides --- config_new.org | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/config_new.org b/config_new.org index b5d6d45..4196378 100644 --- a/config_new.org +++ b/config_new.org @@ -530,22 +530,6 @@ Magit depends on this and it seems it's not installed as a dependency, so instal ) #+END_SRC -** Smartparens -Smart minor-mode to deal with pairs. - -https://github.com/Fuco1/smartparens - -#+BEGIN_SRC emacs-lisp -(use-package smartparens - :ensure t - :bind - ("C-M-w" . sp-copy-sexp) - :hook (prog-mode text-mode markdown-mode) - :config - (require 'smartparens-config) -) -#+END_SRC - * Multiple cursors #+BEGIN_SRC emacs-lisp From 2c29e771325c2c89730d1f717ab92092325d7451 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Thu, 19 Sep 2024 22:44:13 +0200 Subject: [PATCH 30/69] ADD dumb-jump mode Add it immediatelly to the list of xref backends. --- config_new.org | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/config_new.org b/config_new.org index 4196378..a6901a2 100644 --- a/config_new.org +++ b/config_new.org @@ -530,6 +530,16 @@ Magit depends on this and it seems it's not installed as a dependency, so instal ) #+END_SRC +** Dumb-jump + +#+BEGIN_SRC emacs-lisp + (use-package dumb-jump + :ensure t + :init + (add-hook 'xref-backend-functions #'dumb-jump-xref-activate) + ) +#+END_SRC + * Multiple cursors #+BEGIN_SRC emacs-lisp From 0482e48c7fec99cc0793915ecdf38679fa543731 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Thu, 19 Sep 2024 22:44:41 +0200 Subject: [PATCH 31/69] Ensure eglot does not take full control of Xref Eglot by default will take full control of xref and make the xref-backend-functions (eglot-xref-backend t) . To have dumb-jump as backup if eglot would fail, instruct eglot to stay out of Xref and add/remove eglot xref backend manually. --- config_new.org | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/config_new.org b/config_new.org index a6901a2..91dda14 100644 --- a/config_new.org +++ b/config_new.org @@ -484,19 +484,17 @@ Install and wait for hydra to be available since we are using it in this init.el ** Eglot #+BEGIN_SRC emacs-lisp -(use-package eglot - :ensure t - :defer t - ;; This doesn't work for some reason, workaround below - ;;:hook (prog-mode . eglot-ensure) - ;; :config - ;; (add-hook 'prog-mode-hook 'eglot-ensure) -) -#+END_SRC + (use-package eglot + :ensure t + ) -Workaround to enable eglot in all programming modes: -#+BEGIN_SRC emacs-lisp -(add-hook 'prog-mode-hook 'eglot-ensure) + (setq eglot-stay-out-of '(xref)) + (add-hook 'prog-mode-hook 'eglot-ensure) + (add-hook 'eglot-managed-mode-hook (lambda () + (if (eglot-managed-p) + (add-hook 'xref-backend-functions 'eglot-xref-backend) + (remove-hook 'xref-backend-functions 'eglot-xref-backend) + ))) #+END_SRC ** Yasnippet From ee7073ea67b013019c785cdc8a57a04166003360 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Thu, 19 Sep 2024 22:46:14 +0200 Subject: [PATCH 32/69] ADD Yasnippet hook to prog- and org-mode --- config_new.org | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config_new.org b/config_new.org index 91dda14..4c0966d 100644 --- a/config_new.org +++ b/config_new.org @@ -497,14 +497,17 @@ Install and wait for hydra to be available since we are using it in this init.el ))) #+END_SRC + ** Yasnippet #+BEGIN_SRC emacs-lisp (use-package yasnippet :ensure t + :hook + (prog-mode . yas-minor-mode) + (org-mode . yas-minor-mode) :config (yas-reload-all) - (add-hook 'prog-mode-hook 'yas-minor-mode) ) #+END_SRC From 8732e361600e8ff50d7000511a98d1c9940999d8 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Thu, 19 Sep 2024 22:47:48 +0200 Subject: [PATCH 33/69] PROJECTILE: Don't set indexing method This can be forced through .dir.locals.el if necessary. Leave it at default value (alien). --- config_new.org | 1 - 1 file changed, 1 deletion(-) diff --git a/config_new.org b/config_new.org index 4c0966d..52951b8 100644 --- a/config_new.org +++ b/config_new.org @@ -575,7 +575,6 @@ https://github.com/remyferre/comment-dwim-2 (use-package projectile :ensure t :config - (setq projectile-indexing-method 'hybrid) (setq projectile-enable-caching t) (define-key projectile-mode-map (kbd "C-x p") 'projectile-command-map) (projectile-mode +1) From 8b3f426ae147d7b10f29485c8a9e1db9833cc354 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Fri, 20 Sep 2024 10:08:45 +0200 Subject: [PATCH 34/69] ADD markdown-mode --- config_new.org | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/config_new.org b/config_new.org index 52951b8..a105850 100644 --- a/config_new.org +++ b/config_new.org @@ -497,6 +497,13 @@ Install and wait for hydra to be available since we are using it in this init.el ))) #+END_SRC +** Markdown-mode + +#+BEGIN_SRC emacs-lisp +(use-package markdown-mode + :ensure t +) +#+END_SRC ** Yasnippet From c748fb94c4122ce5ddec48e395e8dcf5d0c24de9 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Fri, 20 Sep 2024 10:09:13 +0200 Subject: [PATCH 35/69] ADD treesitter-mode for C --- config_new.org | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/config_new.org b/config_new.org index a105850..a68be07 100644 --- a/config_new.org +++ b/config_new.org @@ -548,6 +548,14 @@ Magit depends on this and it seems it's not installed as a dependency, so instal ) #+END_SRC +** C-programming + +*** Tree-sitter + +#+BEGIN_SRC emacs-lisp +(add-to-list 'major-mode-remap-alist '(c-mode . c-ts-mode)) +#+END_SRC + * Multiple cursors #+BEGIN_SRC emacs-lisp From 69010af86e84d20710cea13e5b70365248c19314 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Fri, 20 Sep 2024 18:35:15 +0200 Subject: [PATCH 36/69] INIT: Fix config file name for myrmi/{visit,reload}-config --- init.el | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/init.el b/init.el index 4a3164f..bd22fe2 100644 --- a/init.el +++ b/init.el @@ -5,11 +5,10 @@ ;;; ... (let ((gc-cons-threshold most-positive-fixnum)) ;; This is the actual config file. It is omitted if it doesn't exist so emacs won't refuse to launch. - (defvar config-file (expand-file-name "config_new.org" user-emacs-directory)) - ;;(defvar project-file (expand-file-name "project.org" user-emacs-directory)) + (defvar my-config-file (expand-file-name "config_new.org" user-emacs-directory)) - (when (file-readable-p config-file) - (org-babel-load-file (expand-file-name config-file))) + (when (file-readable-p my-config-file) + (org-babel-load-file (expand-file-name my-config-file))) ;; If it exists, load some project-specific configurations. ;;(when (file-readable-p project-file) From cdcd5779395fd75e7f5158ce73715767567b75c0 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Fri, 20 Sep 2024 18:35:37 +0200 Subject: [PATCH 37/69] INIT: Move customization to its own file that we can ignore --- .gitignore | 1 + init.el | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7ea8f90 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +custom.el diff --git a/init.el b/init.el index bd22fe2..2676b28 100644 --- a/init.el +++ b/init.el @@ -4,13 +4,12 @@ ;;; https://jonnay.github.io/emagicians-starter-kit/Emagician-Base.html ;;; ... (let ((gc-cons-threshold most-positive-fixnum)) + (setq custom-file (expand-file-name "custom.el" user-emacs-directory)) ;; This is the actual config file. It is omitted if it doesn't exist so emacs won't refuse to launch. (defvar my-config-file (expand-file-name "config_new.org" user-emacs-directory)) (when (file-readable-p my-config-file) (org-babel-load-file (expand-file-name my-config-file))) - ;; If it exists, load some project-specific configurations. - ;;(when (file-readable-p project-file) - ;; (org-babel-load-file (expand-file-name project-file))) + (load custom-file) ) From f1eed76f1ba039cd7128f3376f59de4ee5806972 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Fri, 20 Sep 2024 18:36:22 +0200 Subject: [PATCH 38/69] SNIPPET: Add c-define snippet --- snippets/c-mode/define | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 snippets/c-mode/define diff --git a/snippets/c-mode/define b/snippets/c-mode/define new file mode 100644 index 0000000..eb89c4a --- /dev/null +++ b/snippets/c-mode/define @@ -0,0 +1,6 @@ +# -*- mode: snippet -*- +# name: Make a define +# key: def +# -- + +#define ${1:mydefine$(upcase yas-text)} $2 From 1449ae0e5f1fc955babea40850f9ac67ecb30686 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Fri, 20 Sep 2024 18:37:12 +0200 Subject: [PATCH 39/69] SNIPPET: Add org source-code-block snippet --- snippets/org-mode/emacs-lisp-source-block | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 snippets/org-mode/emacs-lisp-source-block diff --git a/snippets/org-mode/emacs-lisp-source-block b/snippets/org-mode/emacs-lisp-source-block new file mode 100644 index 0000000..c0d946b --- /dev/null +++ b/snippets/org-mode/emacs-lisp-source-block @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: Lisp source code block +# key: se> +# -- + +#+BEGIN_SRC emacs-lisp +#+END_SRC From 752734c381e7fbf0a7d4a0f1a549e6ce994b6d2f Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Fri, 20 Sep 2024 18:37:22 +0200 Subject: [PATCH 40/69] SNIPPET: Add git-commit message template --- snippets/text-mode/git-commit-message-before-after | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 snippets/text-mode/git-commit-message-before-after diff --git a/snippets/text-mode/git-commit-message-before-after b/snippets/text-mode/git-commit-message-before-after new file mode 100644 index 0000000..983e180 --- /dev/null +++ b/snippets/text-mode/git-commit-message-before-after @@ -0,0 +1,10 @@ +# -*- mode: snippet -*- +# name: Git commit message template +# key: bac +# -- + +Before this commit, +${1} + +After this commit, +${2} From 31da5498b610e723a71900b38ef829bd2c91211d Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Sun, 22 Sep 2024 11:16:05 +0200 Subject: [PATCH 41/69] SNIPPETS: Fix org mode lisp source block snippet + add general source block --- snippets/org-mode/emacs-lisp-source-block | 2 +- snippets/org-mode/source_block_emacs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 snippets/org-mode/source_block_emacs diff --git a/snippets/org-mode/emacs-lisp-source-block b/snippets/org-mode/emacs-lisp-source-block index c0d946b..5909c42 100644 --- a/snippets/org-mode/emacs-lisp-source-block +++ b/snippets/org-mode/emacs-lisp-source-block @@ -1,6 +1,6 @@ # -*- mode: snippet -*- # name: Lisp source code block -# key: se> +# key: s> # -- #+BEGIN_SRC emacs-lisp diff --git a/snippets/org-mode/source_block_emacs b/snippets/org-mode/source_block_emacs new file mode 100644 index 0000000..98bfd6f --- /dev/null +++ b/snippets/org-mode/source_block_emacs @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: Start emacs source block +# key: se> +# -- + +#+BEGIN_SRC emacs-lisp +#+END_SRC From 091b5fbda2a9953e69b4153229eceffc68056c22 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Sun, 22 Sep 2024 11:17:30 +0200 Subject: [PATCH 42/69] GENERAL: Enable delete-selection-mode --- config_new.org | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config_new.org b/config_new.org index a68be07..b48f483 100644 --- a/config_new.org +++ b/config_new.org @@ -385,6 +385,12 @@ Look into customizing the 'ispell' group. (add-hook 'prog-mode-hook 'flyspell-prog-mode) #+end_src +** Delete selection mode + +#+BEGIN_SRC emacs-lisp +(delete-selection-mode t) +#+END_SRC + * Dired #+begin_src emacs-lisp From 6f306b4ea51ad6c701a2696f9c0e1e3c03cb7ee8 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Sun, 22 Sep 2024 11:26:12 +0200 Subject: [PATCH 43/69] Add "Enable disabled commands" section Enable narrow functions cause they're really handy. --- config_new.org | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/config_new.org b/config_new.org index b48f483..b329034 100644 --- a/config_new.org +++ b/config_new.org @@ -391,6 +391,16 @@ Look into customizing the 'ispell' group. (delete-selection-mode t) #+END_SRC +** Enable disabled commands + +Some commands are disabled to protect the user. +Narrow-region/page is a really handy feature, enable it: + +#+BEGIN_SRC emacs-lisp +(put 'narrow-to-page 'disabled nil) +(put 'narrow-to-region 'disabled nil) +#+END_SRC + * Dired #+begin_src emacs-lisp From 012e96051096f337035ff8cdbd194ac6b81c968f Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Sun, 22 Sep 2024 11:44:09 +0200 Subject: [PATCH 44/69] COMPILATION: goto end of buffer on completion --- config_new.org | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/config_new.org b/config_new.org index b329034..2f066d7 100644 --- a/config_new.org +++ b/config_new.org @@ -572,6 +572,21 @@ Magit depends on this and it seems it's not installed as a dependency, so instal (add-to-list 'major-mode-remap-alist '(c-mode . c-ts-mode)) #+END_SRC +** Compilation + +*** Goto end of buffer on completion + +Compilation output is almost always bigger than a normal buffer. +Move to the end if the compilation finishes. + +#+BEGIN_SRC emacs-lisp +(defun goto-end-compilation-buffer (comp-buffer msg) + (goto-char (point-max)) + ) + +(add-hook 'compilation-finish-functions #'goto-end-compilation-buffer) +#+END_SRC + * Multiple cursors #+BEGIN_SRC emacs-lisp From 6e52096e2d7cb214dec17b32a23b656b1f9bb57b Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Sun, 22 Sep 2024 11:48:43 +0200 Subject: [PATCH 45/69] Only load custom file if it exists --- init.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/init.el b/init.el index 2676b28..2ee5b47 100644 --- a/init.el +++ b/init.el @@ -11,5 +11,6 @@ (when (file-readable-p my-config-file) (org-babel-load-file (expand-file-name my-config-file))) - (load custom-file) + (when (file-readable-p custom-file) + (load custom-file)) ) From 1b6619a978d0e6034cfea5ad2ba5e87472c82f28 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Sun, 22 Sep 2024 17:18:32 +0200 Subject: [PATCH 46/69] USE_PACKAGE: always set ':ensure t' by default --- config_new.org | 123 +++++++++++++++++++++++-------------------------- 1 file changed, 57 insertions(+), 66 deletions(-) diff --git a/config_new.org b/config_new.org index 2f066d7..5245488 100644 --- a/config_new.org +++ b/config_new.org @@ -62,7 +62,6 @@ #+BEGIN_SRC emacs-lisp ;; Enable vertico (use-package vertico - :ensure t ;; :custom ;; (vertico-scroll-margin 0) ;; Different scroll margin ;; (vertico-count 20) ;; Show more candidates @@ -76,7 +75,6 @@ #+BEGIN_SRC emacs-lisp (use-package consult - :ensure t ;; Replace bindings. Lazily loaded by `use-package'. :bind (;; C-c bindings in `mode-specific-map' ;; ("C-c M-x" . consult-mode-command) @@ -186,55 +184,53 @@ ** Corfu #+BEGIN_SRC emacs-lisp - (use-package corfu - :ensure t - ;; Optional customizations - ;; :custom - ;; (corfu-cycle t) ;; Enable cycling for `corfu-next/previous' - ;; (corfu-auto t) ;; Enable auto completion - ;; (corfu-separator ?\s) ;; Orderless field separator - ;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary - ;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match - ;; (corfu-preview-current nil) ;; Disable current candidate preview - ;; (corfu-preselect 'prompt) ;; Preselect the prompt - ;; (corfu-on-exact-match nil) ;; Configure handling of exact matches - ;; (corfu-scroll-margin 5) ;; Use scroll margin +(use-package corfu + ;; Optional customizations + ;; :custom + ;; (corfu-cycle t) ;; Enable cycling for `corfu-next/previous' + ;; (corfu-auto t) ;; Enable auto completion + ;; (corfu-separator ?\s) ;; Orderless field separator + ;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary + ;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match + ;; (corfu-preview-current nil) ;; Disable current candidate preview + ;; (corfu-preselect 'prompt) ;; Preselect the prompt + ;; (corfu-on-exact-match nil) ;; Configure handling of exact matches + ;; (corfu-scroll-margin 5) ;; Use scroll margin - ;; Enable Corfu only for certain modes. See also `global-corfu-modes'. - ;; :hook ((prog-mode . corfu-mode) - ;; (shell-mode . corfu-mode) - ;; (eshell-mode . corfu-mode)) + ;; Enable Corfu only for certain modes. See also `global-corfu-modes'. + ;; :hook ((prog-mode . corfu-mode) + ;; (shell-mode . corfu-mode) + ;; (eshell-mode . corfu-mode)) - ;; Recommended: Enable Corfu globally. This is recommended since Dabbrev can - ;; be used globally (M-/). See also the customization variable - ;; `global-corfu-modes' to exclude certain modes. - :init - (global-corfu-mode)) + ;; Recommended: Enable Corfu globally. This is recommended since Dabbrev can + ;; be used globally (M-/). See also the customization variable + ;; `global-corfu-modes' to exclude certain modes. + :init + (global-corfu-mode)) #+end_src ** Orderless #+begin_src emacs-lisp - (use-package orderless - :ensure t - :demand t - :custom - (completion-styles '(orderless basic)) - ;; (gnus-completion-styles '(orderless substring basic)) - ;; (completion-category-overrides '((file (styles basic partial-completion)))) +(use-package orderless + :demand t + :custom + (completion-styles '(orderless basic)) + ;; (gnus-completion-styles '(orderless substring basic)) + ;; (completion-category-overrides '((file (styles basic partial-completion)))) - ;; Below not necessary if using vertico - ;; (completion-category-overrides '( - ;; (command (styles orderless basic partial-completion)) - ;; (file (styles orderless basic partial-completion)) - ;;;; (buffer (styles orderless basic)) - ;; (variable (styles orderless basic)) - ;; (symbol (styles orderless basic)) - ;; (consult-location (styles orderless)) - ;; (consult-multi (styles orderless)) - ;; ) - ;; ) - ) +;; Below not necessary if using vertico +;; (completion-category-overrides '( +;; (command (styles orderless basic partial-completion)) +;; (file (styles orderless basic partial-completion)) +;;;; (buffer (styles orderless basic)) +;; (variable (styles orderless basic)) +;; (symbol (styles orderless basic)) +;; (consult-location (styles orderless)) +;; (consult-multi (styles orderless)) +;; ) +;; ) +) #+end_src ** Marginalia @@ -242,7 +238,6 @@ #+begin_src emacs-lisp ;; Enable rich annotations using the Marginalia package (use-package marginalia - :ensure t ;; Bind `marginalia-cycle' locally in the minibuffer. To make the binding ;; available in the *Completions* buffer, add it to the ;; `completion-list-mode-map'. @@ -251,7 +246,6 @@ ;; The :init section is always executed. :init - ;; Marginalia must be activated in the :init section of use-package such that ;; the mode gets enabled right away. Note that this forces loading the ;; package. @@ -401,6 +395,15 @@ Narrow-region/page is a really handy feature, enable it: (put 'narrow-to-region 'disabled nil) #+END_SRC +** Use-package + +*** Always ensure + +#+BEGIN_SRC emacs-lisp +(require 'use-package-ensure) +(setq use-package-always-ensure t) +#+END_SRC + * Dired #+begin_src emacs-lisp @@ -416,7 +419,7 @@ Operate on the current line if no region is active. #+begin_src emacs-lisp (use-package whole-line-or-region - :ensure t + :config (whole-line-or-region-global-mode 1) ) @@ -454,7 +457,7 @@ For the keybindings, we have to defien them in both raw and line mode. From the #+BEGIN_SRC emacs-lisp (use-package monokai-theme - :ensure t + :init (load-theme 'monokai t) ) @@ -464,7 +467,6 @@ For the keybindings, we have to defien them in both raw and line mode. From the #+begin_src emacs-lisp (use-package dashboard - :ensure t :config (add-hook 'elpaca-after-init-hook #'dashboard-insert-startupify-lists) (add-hook 'elpaca-after-init-hook #'dashboard-initialize) @@ -500,9 +502,7 @@ Install and wait for hydra to be available since we are using it in this init.el ** Eglot #+BEGIN_SRC emacs-lisp - (use-package eglot - :ensure t - ) + (use-package eglot) (setq eglot-stay-out-of '(xref)) (add-hook 'prog-mode-hook 'eglot-ensure) @@ -516,16 +516,14 @@ Install and wait for hydra to be available since we are using it in this init.el ** Markdown-mode #+BEGIN_SRC emacs-lisp -(use-package markdown-mode - :ensure t -) +(use-package markdown-mode) + #+END_SRC ** Yasnippet #+BEGIN_SRC emacs-lisp (use-package yasnippet - :ensure t :hook (prog-mode . yas-minor-mode) (org-mode . yas-minor-mode) @@ -541,24 +539,20 @@ Install and wait for hydra to be available since we are using it in this init.el Magit depends on this and it seems it's not installed as a dependency, so install it explicitly. #+BEGIN_SRC emacs-lisp -(use-package transient - :ensure t - ) +(use-package transient) #+END_SRC *** Core #+BEGIN_SRC emacs-lisp -(use-package magit - :ensure t -) +(use-package magit) + #+END_SRC ** Dumb-jump #+BEGIN_SRC emacs-lisp (use-package dumb-jump - :ensure t :init (add-hook 'xref-backend-functions #'dumb-jump-xref-activate) ) @@ -591,7 +585,6 @@ Move to the end if the compilation finishes. #+BEGIN_SRC emacs-lisp (use-package multiple-cursors - :ensure t :bind ("C-x r a" . mc/edit-beginnings-of-lines) ("C-x r e" . mc/edit-ends-of-lines) @@ -609,7 +602,6 @@ https://github.com/remyferre/comment-dwim-2 #+BEGIN_SRC emacs-lisp (use-package comment-dwim-2 - :ensure t :config (global-set-key (kbd "M-;") 'comment-dwim-2) ) @@ -619,7 +611,6 @@ https://github.com/remyferre/comment-dwim-2 #+BEGIN_SRC emacs-lisp (use-package projectile - :ensure t :config (setq projectile-enable-caching t) (define-key projectile-mode-map (kbd "C-x p") 'projectile-command-map) @@ -635,7 +626,7 @@ https://github.com/remyferre/comment-dwim-2 #+BEGIN_SRC emacs-lisp (use-package elisp-demos - :ensure t + :config (advice-add 'describe-function-1 :after #'elisp-demos-advice-describe-function-1) ) From 074c5fe0b1696680e28b5d6ea41236324b1889bd Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Sun, 22 Sep 2024 17:19:06 +0200 Subject: [PATCH 47/69] ADD Org mode settings from old config - Enable Super/sub-scripts - Preserve indentation - Org bullets --- config_new.org | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/config_new.org b/config_new.org index 5245488..0774e54 100644 --- a/config_new.org +++ b/config_new.org @@ -620,13 +620,41 @@ https://github.com/remyferre/comment-dwim-2 ) #+END_SRC +* Org + +** General config +*** Super/Sub-scripts + +Use ={}= for subscripting: + +https://orgmode.org/manual/Subscripts-and-superscripts.html + +#+BEGIN_SRC emacs-lisp +(setq org-use-sub-superscripts '{}) +#+END_SRC + +*** Indentation + +Preserve indentation in SRC blocks + +#+BEGIN_SRC emacs-lisp +(setq org-src-preserve-indentation t) +#+END_SRC + +** Org bullets + +#+BEGIN_SRC emacs-lisp +(use-package org-bullets + :config + (add-hook 'org-mode-hook (lambda () (org-bullets-mode)))) +#+END_SRC + * Elisp ** Add demos to describe-function #+BEGIN_SRC emacs-lisp (use-package elisp-demos - :config (advice-add 'describe-function-1 :after #'elisp-demos-advice-describe-function-1) ) From e02a1990aac09ddfd67e184a961fbf2e8fb1d373 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Sun, 22 Sep 2024 17:19:24 +0200 Subject: [PATCH 48/69] ADD Zygospore from old config It's too usefull not to have --- config_new.org | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/config_new.org b/config_new.org index 0774e54..5b85570 100644 --- a/config_new.org +++ b/config_new.org @@ -492,6 +492,20 @@ Install and wait for hydra to be available since we are using it in this init.el ) #+end_src +* Zygospore + +Revert =C-x 1= by pressing =C-x 1= again: +[[https://github.com/louiskottmann/zygospore.el]] + +FYI: At one point, used this together with sr-speedbar. They did not play well together... + +#+BEGIN_SRC emacs-lisp +(use-package zygospore + :config + (global-set-key (kbd "C-x 1") 'zygospore-toggle-delete-other-windows) +) +#+END_SRC + * Programming ** Electric pair From 122f1f51865675ef3d200af377258298a5a147b9 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Sun, 22 Sep 2024 17:19:48 +0200 Subject: [PATCH 49/69] ADD Iedit from old config It's too usefull not to have --- config_new.org | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/config_new.org b/config_new.org index 5b85570..78c1d6b 100644 --- a/config_new.org +++ b/config_new.org @@ -506,6 +506,17 @@ FYI: At one point, used this together with sr-speedbar. They did not play well t ) #+END_SRC +* Iedit + +Highlight occurences of symbol and replace them simultanously. +Shortkey: =C-;= + +https://github.com/victorhge/iedit + +#+BEGIN_SRC emacs-lisp +(use-package iedit) +#+END_SRC + * Programming ** Electric pair From d757ce44a819506691a9f97d08fe28f963dd4e9c Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Sun, 22 Sep 2024 17:51:57 +0200 Subject: [PATCH 50/69] GENERAL: Move general config first before vertico stack This fixes the init error on vertico stack symbols not being known due to ':ensure' being removed since it should be enabled by default but this was only done later in the 'general config' section. --- config_new.org | 305 +++++++++++++++++++++++++------------------------ 1 file changed, 153 insertions(+), 152 deletions(-) diff --git a/config_new.org b/config_new.org index 78c1d6b..e4d24d6 100644 --- a/config_new.org +++ b/config_new.org @@ -55,6 +55,159 @@ ) #+end_src +* General config + +** Delete trailing whitespaces + +#+BEGIN_SRC emacs-lisp +(add-hook 'before-save-hook 'delete-trailing-whitespace) +#+END_SRC + +** Save history and recent files + +#+begin_src emacs-lisp +;; The built-in `savehist-mode' saves minibuffer histories. Vertico +;; can then use that information to put recently selected options at +;; the top. +;; +;; Further reading: https://protesilaos.com/emacs/dotemacs#h:25765797-27a5-431e-8aa4-cc890a6a913a +(savehist-mode 1) + +;; The built-in `recentf-mode' keeps track of recently visited files. +;; You can then access those through the `consult-buffer' interface or +;; with `recentf-open'/`recentf-open-files'. +;; +;; I do not use this facility, because the files I care about are +;; either in projects or are bookmarked. +(recentf-mode 1) +#+end_src + +** Backups + +#+BEGIN_SRC emacs-lisp +(defvar myrmi-backup-directory (concat user-emacs-directory "backups")) +(if (not (file-exists-p myrmi-backup-directory)) + (make-directory myrmi-backup-directory t) + ) +(setq backup-directory-alist `(("." . ,myrmi-backup-directory))) +(setq make-backup-files t + backup-by-copying t + version-control t + delete-old-versions t + delete-by-moving-to-trash t + kept-old-versions 6 + kept-new-versions 9 + auto-save-default t + auto-save-timeout 20 + auto-save-interval 200 + ) +#+END_SRC + +** Yes-or-no + +Because I'm lazy, important yes-or-no questions can be answered with y-or-n: +#+begin_src emacs-lisp +(defalias 'yes-or-no-p 'y-or-n-p) +#+end_src + +** Switch windows + +#+begin_src emacs-lisp +(global-set-key (kbd "M-o") 'other-window) +#+end_src + +** Maximize at startup + +More info : https://www.emacswiki.org/emacs/FullScreen + +#+begin_src emacs-lisp +(push '(fullscreen . maximized) default-frame-alist) +#+end_src + +** ibuffer + +Use list-buffers bigger brother. +#+begin_src emacs-lisp +(global-set-key [remap list-buffers] 'ibuffer) +#+end_src + +** Mark + +#+begin_src emacs-lisp +(global-set-key (kbd "M-SPC") 'mark-word) +#+end_src + +** Isearch + +Display number of matches: +#+begin_src emacs-lisp +(setq-default isearch-lazy-count t) +#+end_src + +Reference that might be interesting for later: +https://endlessparentheses.com/leave-the-cursor-at-start-of-match-after-isearch.html + +** Sudo file + +#+begin_src emacs-lisp +(defun sudo () + "Use TRAMP to `sudo' the current buffer." + (interactive) + (when buffer-file-name + (find-alternate-file + (concat "/sudo:root@localhost:" + buffer-file-name) + ) + ) +) +#+end_src + +** Abbrev + +#+begin_src emacs-lisp +(global-set-key [remap dabbrev-expand] 'hippie-expand) +#+end_src + +** Zap + +#+begin_src emacs-lisp +(global-set-key (kbd "M-S-z") 'zap-up-to-char) +#+end_src + +** Spell checking + +Look into customizing the 'ispell' group. + +#+begin_src emacs-lisp +(add-hook 'prog-mode-hook 'flyspell-prog-mode) +#+end_src + +** Delete selection mode + +#+BEGIN_SRC emacs-lisp +(delete-selection-mode t) +#+END_SRC + +** Enable disabled commands + +Some commands are disabled to protect the user. +Narrow-region/page is a really handy feature, enable it: + +#+BEGIN_SRC emacs-lisp +(put 'narrow-to-page 'disabled nil) +(put 'narrow-to-region 'disabled nil) +#+END_SRC + +** Use-package + +*** Always ensure + +#+BEGIN_SRC emacs-lisp +(require 'use-package-ensure) +(setq use-package-always-ensure t) +#+END_SRC + +** Adaptive cursor width * Vertico-stack ** Vertico @@ -252,158 +405,6 @@ (marginalia-mode)) #+end_src -* General config - -** Delete trailing whitespaces - -#+BEGIN_SRC emacs-lisp -(add-hook 'before-save-hook 'delete-trailing-whitespace) -#+END_SRC - -** Save history and recent files - -#+begin_src emacs-lisp -;; The built-in `savehist-mode' saves minibuffer histories. Vertico -;; can then use that information to put recently selected options at -;; the top. -;; -;; Further reading: https://protesilaos.com/emacs/dotemacs#h:25765797-27a5-431e-8aa4-cc890a6a913a -(savehist-mode 1) - -;; The built-in `recentf-mode' keeps track of recently visited files. -;; You can then access those through the `consult-buffer' interface or -;; with `recentf-open'/`recentf-open-files'. -;; -;; I do not use this facility, because the files I care about are -;; either in projects or are bookmarked. -(recentf-mode 1) -#+end_src - -** Backups - -#+BEGIN_SRC emacs-lisp -(defvar myrmi-backup-directory (concat user-emacs-directory "backups")) -(if (not (file-exists-p myrmi-backup-directory)) - (make-directory myrmi-backup-directory t) - ) -(setq backup-directory-alist `(("." . ,myrmi-backup-directory))) -(setq make-backup-files t - backup-by-copying t - version-control t - delete-old-versions t - delete-by-moving-to-trash t - kept-old-versions 6 - kept-new-versions 9 - auto-save-default t - auto-save-timeout 20 - auto-save-interval 200 - ) -#+END_SRC - -** Yes-or-no - -Because I'm lazy, important yes-or-no questions can be answered with y-or-n: -#+begin_src emacs-lisp -(defalias 'yes-or-no-p 'y-or-n-p) -#+end_src - -** Switch windows - -#+begin_src emacs-lisp -(global-set-key (kbd "M-o") 'other-window) -#+end_src - -** Maximize at startup - -More info : https://www.emacswiki.org/emacs/FullScreen - -#+begin_src emacs-lisp -(push '(fullscreen . maximized) default-frame-alist) -#+end_src - -** ibuffer - -Use list-buffers bigger brother. -#+begin_src emacs-lisp -(global-set-key [remap list-buffers] 'ibuffer) -#+end_src - -** Mark - -#+begin_src emacs-lisp -(global-set-key (kbd "M-SPC") 'mark-word) -#+end_src - -** Isearch - -Display number of matches: -#+begin_src emacs-lisp -(setq-default isearch-lazy-count t) -#+end_src - -Reference that might be interesting for later: -https://endlessparentheses.com/leave-the-cursor-at-start-of-match-after-isearch.html - -** Sudo file - -#+begin_src emacs-lisp -(defun sudo () - "Use TRAMP to `sudo' the current buffer." - (interactive) - (when buffer-file-name - (find-alternate-file - (concat "/sudo:root@localhost:" - buffer-file-name) - ) - ) -) -#+end_src - -** Abbrev - -#+begin_src emacs-lisp -(global-set-key [remap dabbrev-expand] 'hippie-expand) -#+end_src - -** Zap - -#+begin_src emacs-lisp -(global-set-key (kbd "M-S-z") 'zap-up-to-char) -#+end_src - -** Spell checking - -Look into customizing the 'ispell' group. - -#+begin_src emacs-lisp -(add-hook 'prog-mode-hook 'flyspell-prog-mode) -#+end_src - -** Delete selection mode - -#+BEGIN_SRC emacs-lisp -(delete-selection-mode t) -#+END_SRC - -** Enable disabled commands - -Some commands are disabled to protect the user. -Narrow-region/page is a really handy feature, enable it: - -#+BEGIN_SRC emacs-lisp -(put 'narrow-to-page 'disabled nil) -(put 'narrow-to-region 'disabled nil) -#+END_SRC - -** Use-package - -*** Always ensure - -#+BEGIN_SRC emacs-lisp -(require 'use-package-ensure) -(setq use-package-always-ensure t) -#+END_SRC - * Dired #+begin_src emacs-lisp From f6c14e7caaf7e111c19a662ba0772f910994e28a Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Sun, 22 Sep 2024 17:52:43 +0200 Subject: [PATCH 51/69] GENERAL: Add adaptive cursor width --- config_new.org | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/config_new.org b/config_new.org index e4d24d6..a070af1 100644 --- a/config_new.org +++ b/config_new.org @@ -208,6 +208,13 @@ Narrow-region/page is a really handy feature, enable it: #+END_SRC ** Adaptive cursor width + +Make cursor the width of the character it is under f.e. full width of a tab. + +#+BEGIN_SRC emacs-lisp +(setq x-stretch-cursor t) +#+END_SRC + * Vertico-stack ** Vertico From 2be3a79aed9d452c3ceaa877b7a5e702fa42ebdb Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Mon, 23 Sep 2024 16:22:11 +0200 Subject: [PATCH 52/69] CORFU: Enable automatic completion in buffer Also cycle if we reach begin/end of list of candidates. --- config_new.org | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config_new.org b/config_new.org index a070af1..3b57a67 100644 --- a/config_new.org +++ b/config_new.org @@ -346,9 +346,9 @@ Make cursor the width of the character it is under f.e. full width of a tab. #+BEGIN_SRC emacs-lisp (use-package corfu ;; Optional customizations - ;; :custom - ;; (corfu-cycle t) ;; Enable cycling for `corfu-next/previous' - ;; (corfu-auto t) ;; Enable auto completion + :custom + (corfu-cycle t) ;; Enable cycling for `corfu-next/previous' + (corfu-auto t) ;; Enable auto completion ;; (corfu-separator ?\s) ;; Orderless field separator ;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary ;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match From 539570657720a3115efe678023572723cb54c733 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Mon, 23 Sep 2024 16:26:43 +0200 Subject: [PATCH 53/69] ORG_MODE: Fix snippets to place cursor inside source block --- snippets/org-mode/emacs-lisp-source-block | 1 + snippets/org-mode/source_block_emacs | 1 + 2 files changed, 2 insertions(+) diff --git a/snippets/org-mode/emacs-lisp-source-block b/snippets/org-mode/emacs-lisp-source-block index 5909c42..2f90c13 100644 --- a/snippets/org-mode/emacs-lisp-source-block +++ b/snippets/org-mode/emacs-lisp-source-block @@ -4,4 +4,5 @@ # -- #+BEGIN_SRC emacs-lisp +${1} #+END_SRC diff --git a/snippets/org-mode/source_block_emacs b/snippets/org-mode/source_block_emacs index 98bfd6f..73ed1eb 100644 --- a/snippets/org-mode/source_block_emacs +++ b/snippets/org-mode/source_block_emacs @@ -4,4 +4,5 @@ # -- #+BEGIN_SRC emacs-lisp +${1} #+END_SRC From 584a0b1b7cb31ef105320224dd223fddf2bffa81 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Mon, 23 Sep 2024 16:27:02 +0200 Subject: [PATCH 54/69] MAGIT: Add example command to update submodules --- config_new.org | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/config_new.org b/config_new.org index 3b57a67..e40e8b3 100644 --- a/config_new.org +++ b/config_new.org @@ -572,16 +572,36 @@ https://github.com/victorhge/iedit Magit depends on this and it seems it's not installed as a dependency, so install it explicitly. #+BEGIN_SRC emacs-lisp -(use-package transient) +(use-package transient + :ensure (:wait t) +) #+END_SRC *** Core #+BEGIN_SRC emacs-lisp -(use-package magit) +(use-package magit +:ensure (:wait t) +) #+END_SRC +**** Extra commands + +***** Update all submodules + +#+BEGIN_SRC emacs-lisp +(transient-define-suffix magit-submodule-update-all () + "Update all submodules" + :description "Update All git submodule update --init --recursive" + (interactive) + (magit-with-toplevel + (magit-run-git-async "submodule" "update" "--force"))) + +(transient-append-suffix 'magit-submodule "f" + '("U" magit-submodule-update-all)) +#+END_SRC + ** Dumb-jump #+BEGIN_SRC emacs-lisp From 5ef08b39b658e61cc8bf3ec63190beb9af6aeeec Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Mon, 23 Sep 2024 16:31:10 +0200 Subject: [PATCH 55/69] ADD volatile highlights --- config_new.org | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/config_new.org b/config_new.org index e40e8b3..74af99d 100644 --- a/config_new.org +++ b/config_new.org @@ -647,6 +647,19 @@ Move to the end if the compilation finishes. ) #+END_SRC +* Volatile highlights + +Show/highlight changes when doing undo/yanks/kills/... + +https://github.com/k-talo/volatile-highlights.el + +#+BEGIN_SRC emacs-lisp +(use-package volatile-highlights + :config + (volatile-highlights-mode t) +) +#+END_SRC + * Comment-dwim-2 Replacement for built-in =comment-dwim=, more comment features. From 78afc078ff26793a208fd2221226a5586cda6937 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Mon, 23 Sep 2024 16:35:04 +0200 Subject: [PATCH 56/69] GENERAL: Enable column numbers --- config_new.org | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config_new.org b/config_new.org index 74af99d..4f8f1e8 100644 --- a/config_new.org +++ b/config_new.org @@ -57,6 +57,12 @@ * General config +** Enable column numbers + +#+BEGIN_SRC emacs-lisp +(setq column-number-mode 1) +#+END_SRC + ** Delete trailing whitespaces #+BEGIN_SRC emacs-lisp From d5f79bf639b40b574eba68ef8a3182e7d13da9b6 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 24 Sep 2024 11:31:08 +0200 Subject: [PATCH 57/69] ADD angry faces face to major prog modes --- config_new.org | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/config_new.org b/config_new.org index 4f8f1e8..debb4fc 100644 --- a/config_new.org +++ b/config_new.org @@ -533,6 +533,28 @@ https://github.com/victorhge/iedit * Programming +** Angry faces + +#+BEGIN_SRC emacs-lisp +(defface highlight-angry-faces + '( + (default :background "Yellow" :foreground "Red") + ) + "Angry faces highlighting." + :group 'basic-faces +) + +(mapc (lambda (mode) + (font-lock-add-keywords + mode + '( + ("\\<\\(FIXME\\)" 1 'highlight-angry-faces t) + ("\\<\\(TODO\\)" 1 'highlight-angry-faces t) + ))) + '(text-mode emacs-lisp-mode rust-mode zig-mode c-ts-mode c-mode prog-mode) +) +#+END_SRC + ** Electric pair #+BEGIN_SRC emacs-lisp (add-hook 'prog-mode-hook 'electric-pair-mode) From 954196d061579ea8f3f1bcb47c502fa2a7cb8987 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 24 Sep 2024 11:31:25 +0200 Subject: [PATCH 58/69] ADD rust-mode --- config_new.org | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/config_new.org b/config_new.org index debb4fc..bbc9811 100644 --- a/config_new.org +++ b/config_new.org @@ -662,6 +662,14 @@ Move to the end if the compilation finishes. (add-hook 'compilation-finish-functions #'goto-end-compilation-buffer) #+END_SRC +** Rust + +#+BEGIN_SRC emacs-lisp +(use-package rust-mode + :init + (setq rust-mode-treesitter-derive t)) +#+END_SRC + * Multiple cursors #+BEGIN_SRC emacs-lisp From f2cfe8035ca1accfd5af44edcfd6ee4f320817d5 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 24 Sep 2024 11:31:32 +0200 Subject: [PATCH 59/69] ADD zig mode --- config_new.org | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config_new.org b/config_new.org index bbc9811..9ff9041 100644 --- a/config_new.org +++ b/config_new.org @@ -670,6 +670,12 @@ Move to the end if the compilation finishes. (setq rust-mode-treesitter-derive t)) #+END_SRC +** Zig + +#+BEGIN_SRC emacs-lisp +(use-package zig-mode) +#+END_SRC + * Multiple cursors #+BEGIN_SRC emacs-lisp From edee35724e51d847cda9e9c92a7033701517851d Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 24 Sep 2024 11:31:37 +0200 Subject: [PATCH 60/69] ADD python mode --- config_new.org | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config_new.org b/config_new.org index 9ff9041..330635d 100644 --- a/config_new.org +++ b/config_new.org @@ -676,6 +676,12 @@ Move to the end if the compilation finishes. (use-package zig-mode) #+END_SRC +** Python + +#+BEGIN_SRC emacs-lisp +(use-package python-mode) +#+END_SRC + * Multiple cursors #+BEGIN_SRC emacs-lisp From c31bd5ab5b097ca77e18e7c0a94fe87f23fe7238 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 24 Sep 2024 11:32:27 +0200 Subject: [PATCH 61/69] ADD visible bell --- config_new.org | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/config_new.org b/config_new.org index 330635d..c7ee028 100644 --- a/config_new.org +++ b/config_new.org @@ -57,6 +57,14 @@ * General config +** Bell + +The audible bell is annoying AF. + +#+BEGIN_SRC emacs-lisp +(setq visible-bell 1) +#+END_SRC + ** Enable column numbers #+BEGIN_SRC emacs-lisp From d3f6a04e9bee99bdb1428dd2dc13ee5184e2856b Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 24 Sep 2024 11:37:07 +0200 Subject: [PATCH 62/69] ADD resize-mode --- config_new.org | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/config_new.org b/config_new.org index c7ee028..5633e96 100644 --- a/config_new.org +++ b/config_new.org @@ -229,6 +229,62 @@ Make cursor the width of the character it is under f.e. full width of a tab. (setq x-stretch-cursor t) #+END_SRC +* Resize-mode + +Minor-mode to easily resize frames (works with EXWM (firefox, ...)). +Courtesy goes to kuanyui (https://gist.github.com/kuanyui/65a408d393871048771c): + +#+BEGIN_SRC emacs-lisp +;;; resize-frame.el --- A minor mode to resize frames easily. -*- lexical-binding: t; -*- + +;; Copyright (C) 2014 kuanyui + +;; Author: kuanyui +;; Keywords: frames, tools, convenience +;; License: WTFPL 1.0 + +;;; Commentary: + +;; Press "ESC `" and use arrow-keys or i/j/k/l to adjust frames. press any key to done. + +;;; Code: + +(defvar resize-frame-map + (let ((map (make-keymap))) + (define-key map (kbd "") 'enlarge-window) + (define-key map (kbd "") 'shrink-window) + (define-key map (kbd "") 'enlarge-window-horizontally) + (define-key map (kbd "") 'shrink-window-horizontally) + (set-char-table-range (nth 1 map) t 'resize-frame-done) + (define-key map (kbd "C-p") 'enlarge-window) + (define-key map (kbd "C-n") 'shrink-window) + (define-key map (kbd "C-f") 'enlarge-window-horizontally) + (define-key map (kbd "C-b") 'shrink-window-horizontally) + map)) + +(define-minor-mode resize-frame + "A simple minor mode to resize-frame. +C-c C-c to apply." + ;; The initial value. + :init-value nil + ;; The indicator for the mode line. + :lighter " ResizeFrame" + ;; The minor mode bindings. + :keymap resize-frame-map + :global t + (if (<= (length (window-list)) 1) + (progn (setq resize-frame nil) + (message "Only root frame exists, abort.")) + (message "Use arrow-keys or i/j/k/l to adjust frames."))) + +(defun resize-frame-done () + (interactive) + (setq resize-frame nil) + (message "Done.")) + +(global-set-key (kbd "C-x C-r") 'resize-frame) +#+END_SRC + * Vertico-stack ** Vertico From 55e765911ef76e71cc69b9ec34496d74305da70b Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 24 Sep 2024 20:24:29 +0200 Subject: [PATCH 63/69] Rename Vertico-stack to Completion section --- config_new.org | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/config_new.org b/config_new.org index 5633e96..59c02ef 100644 --- a/config_new.org +++ b/config_new.org @@ -285,9 +285,8 @@ C-c C-c to apply." (global-set-key (kbd "C-x C-r") 'resize-frame) #+END_SRC -* Vertico-stack - -** Vertico +* Completion +** Minibuffer #+BEGIN_SRC emacs-lisp ;; Enable vertico From 4233409d50e835860e3741fbc0ecd452d3e27423 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 24 Sep 2024 20:27:16 +0200 Subject: [PATCH 64/69] Enable dired-x whenever dired mode is invoked --- config_new.org | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/config_new.org b/config_new.org index 59c02ef..83529a9 100644 --- a/config_new.org +++ b/config_new.org @@ -483,8 +483,20 @@ C-c C-c to apply." * Dired +** Dired-x + #+begin_src emacs-lisp -(require 'dired-x) +(with-eval-after-load 'dired + (require 'dired-x) + ;; Set dired-x global variables here. For example: + ;; (setq dired-x-hands-off-my-keys nil) + )) + +(add-hook 'dired-mode-hook + (lambda () + ;; Set dired-x buffer-local variables here. For example: + ;; (dired-omit-mode 1) + )) #+end_src * Whole-line-or-region From caf08093ddffa08e6c5885e4b2bd378443298cc4 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 24 Sep 2024 20:44:32 +0200 Subject: [PATCH 65/69] ADD eshell plan9/smart-mode settings --- config_new.org | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/config_new.org b/config_new.org index 83529a9..90bcdd7 100644 --- a/config_new.org +++ b/config_new.org @@ -515,6 +515,21 @@ Operate on the current line if no region is active. #+end_src * Terminal +** Eshell +*** Smart mode + +Plan 9 smart terminal features, for more info: +https://www.masteringemacs.org/article/complete-guide-mastering-eshell + +#+BEGIN_SRC emacs-lisp +(require 'eshell) +(require 'em-smart) +(setq eshell-where-to-jump 'begin) +(setq eshell-review-quick-commands nil) +(setq eshell-smart-space-goes-to-end t) + +(add-hook 'eshell-mode-hook 'eshell-smart-initialize) +#+END_SRC ** Toggle between char- and line-mode From cb018ca96b1dea4d2f300521084d14359e404e20 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 24 Sep 2024 20:47:22 +0200 Subject: [PATCH 66/69] Move config.org to config_old.org This to keep the old settings, you never know. Yeah, I know, it's in git and I can always go back, but it's easier to compare if the file is still in the repo... --- config.org => config_old.org | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename config.org => config_old.org (100%) diff --git a/config.org b/config_old.org similarity index 100% rename from config.org rename to config_old.org From ddc622f270b05a3e6fde0419e162c142d3fa68b5 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 24 Sep 2024 20:49:14 +0200 Subject: [PATCH 67/69] Move config_new.org to config.org Use it as the main config now. --- config_new.org => config.org | 0 init.el | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename config_new.org => config.org (100%) diff --git a/config_new.org b/config.org similarity index 100% rename from config_new.org rename to config.org diff --git a/init.el b/init.el index 2ee5b47..e442e9c 100644 --- a/init.el +++ b/init.el @@ -6,7 +6,7 @@ (let ((gc-cons-threshold most-positive-fixnum)) (setq custom-file (expand-file-name "custom.el" user-emacs-directory)) ;; This is the actual config file. It is omitted if it doesn't exist so emacs won't refuse to launch. - (defvar my-config-file (expand-file-name "config_new.org" user-emacs-directory)) + (defvar my-config-file (expand-file-name "config.org" user-emacs-directory)) (when (file-readable-p my-config-file) (org-babel-load-file (expand-file-name my-config-file))) From 29f8a2b08bb56c8030e0b521d6faf4631396a173 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 24 Sep 2024 20:52:36 +0200 Subject: [PATCH 68/69] Update gitignore --- .gitignore | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.gitignore b/.gitignore index 7ea8f90..ea48958 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,21 @@ custom.el +backups +eshell +elpaca + +# projectile +projectile* + +# savehist file +history + +# recentf file +recentf + +session* + +# .org converted files +config*.el + +# Tramp connection file +tramp From 7c39432564d45137eae605851285ae2823807fb3 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 24 Sep 2024 21:00:23 +0200 Subject: [PATCH 69/69] Move sudo to myrmi/sudo-current-buffer It's a new function, use the custom prefix to make that clear. --- config.org | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/config.org b/config.org index 90bcdd7..d2fe38c 100644 --- a/config.org +++ b/config.org @@ -161,21 +161,6 @@ Display number of matches: Reference that might be interesting for later: https://endlessparentheses.com/leave-the-cursor-at-start-of-match-after-isearch.html -** Sudo file - -#+begin_src emacs-lisp -(defun sudo () - "Use TRAMP to `sudo' the current buffer." - (interactive) - (when buffer-file-name - (find-alternate-file - (concat "/sudo:root@localhost:" - buffer-file-name) - ) - ) -) -#+end_src - ** Abbrev #+begin_src emacs-lisp @@ -866,6 +851,22 @@ Preserve indentation in SRC blocks * Custom +** Sudo current buffer + +#+BEGIN_SRC emacs-lisp +(defun myrmi/sudo-current-buffer () + "Use TRAMP to `sudo' the current buffer." + (interactive) + (when buffer-file-name + (find-alternate-file + (concat "/sudo:root@localhost:" + buffer-file-name) + ) + ) +) +#+END_SRC + + ** Save symbol at point #+BEGIN_SRC emacs-lisp