commit 94a827fdeb9968abf8223e77ab2ae465dd206663
parent 704e8daded0c6c04c95c04d8e674dec3b9f47829
Author: Vincent Demeester <vincent@sbr.pm>
Date: Mon, 8 Jul 2024 16:54:01 +0200
tools/emacs: attempting to clean some stuff
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Diffstat:
10 files changed, 183 insertions(+), 315 deletions(-)
diff --git a/tools/emacs/config/00-clean.el b/tools/emacs/config/00-clean.el
@@ -3,6 +3,11 @@
;;; no-littering and recentf configurations
;;; Note: this file is autogenerated from an org-mode file.
;;; Code:
+
+(setopt make-backup-files nil)
+(setopt backup-inhibited nil) ; Not sure if needed, given `make-backup-files'
+(setopt create-lockfiles nil)
+
(use-package recentf
:config
(setq recentf-max-saved-items 200
@@ -40,6 +45,8 @@
(advice-add 'dired-rename-file :after #'rjs/recentf-rename-notify))
+
+;; 2024-07-08: Do I have to setup this, or should I do like prot, disable *all* backup, lockfile, …
(use-package no-littering ; Keep .emacs.d clean
:config
(require 'recentf)
diff --git a/tools/emacs/config/config-appearance.el b/tools/emacs/config/config-appearance.el
@@ -3,30 +3,25 @@
;;; Appearance configuration
;;; Code:
-(use-package emacs
- :config
- (set-face-attribute 'fill-column-indicator nil
- :foreground "#717C7C" ; katana-gray
- )
- (global-display-fill-column-indicator-mode 1))
-
-(use-package emacs
- :config
- (setq-default use-file-dialog nil
- use-dialog-box nil
- echo-keystrokes 0.1
- line-number-display-limit-width 10000
- indicate-buffer-boundaries 'left
- indicate-empty-lines +1)
- (line-number-mode 1)
- (column-number-mode 1)
- (global-unset-key (kbd "C-z"))
- (global-unset-key (kbd "C-x C-z"))
- (global-unset-key (kbd "C-h h"))
- ;; let's enable it for all programming major modes
- (add-hook 'prog-mode-hook #'hl-line-mode)
- ;; and for all modes derived from text-mode
- (add-hook 'text-mode-hook #'hl-line-mode))
+(set-face-attribute 'fill-column-indicator nil
+ :foreground "#717C7C" ; katana-gray
+ )
+(global-display-fill-column-indicator-mode 1)
+
+(setopt echo-keystrokes 0.1
+ line-number-display-limit-width 10000
+ indicate-buffer-boundaries 'left
+ indicate-empty-lines +1)
+
+(line-number-mode 1)
+(column-number-mode 1)
+(global-unset-key (kbd "C-z"))
+(global-unset-key (kbd "C-x C-z"))
+(global-unset-key (kbd "C-h h"))
+;; let's enable it for all programming major modes
+(add-hook 'prog-mode-hook #'hl-line-mode)
+;; and for all modes derived from text-mode
+(add-hook 'text-mode-hook #'hl-line-mode)
(use-package frame
:unless noninteractive
diff --git a/tools/emacs/config/config-buffers.el b/tools/emacs/config/config-buffers.el
@@ -3,7 +3,6 @@
;;; Buffer related configurations
;;; Code:
-
(use-package savehist
:unless noninteractive
:init
diff --git a/tools/emacs/config/config-completion.el b/tools/emacs/config/config-completion.el
@@ -250,21 +250,22 @@ Useful for prompts such as `eval-expression' and `shell-command'."
:bind (("M-+" . tempel-complete) ;; Alternative tempel-expand
("M-*" . tempel-insert))
:init
- (defun tempel-setup-capf ()
- ;; Add the Tempel Capf to `completion-at-point-functions'.
- ;; `tempel-expand' only triggers on exact matches. Alternatively use
- ;; `tempel-complete' if you want to see all matches, but then you
- ;; should also configure `tempel-trigger-prefix', such that Tempel
- ;; does not trigger too often when you don't expect it. NOTE: We add
- ;; `tempel-expand' *before* the main programming mode Capf, such
- ;; that it will be tried first.
- (setq-local completion-at-point-functions
- (cons #'tempel-expand
- completion-at-point-functions)))
+ ;; (defun tempel-setup-capf ()
+ ;; ;; Add the Tempel Capf to `completion-at-point-functions'.
+ ;; ;; `tempel-expand' only triggers on exact matches. Alternatively use
+ ;; ;; `tempel-complete' if you want to see all matches, but then you
+ ;; ;; should also configure `tempel-trigger-prefix', such that Tempel
+ ;; ;; does not trigger too often when you don't expect it. NOTE: We add
+ ;; ;; `tempel-expand' *before* the main programming mode Capf, such
+ ;; ;; that it will be tried first.
+ ;; (setq-local completion-at-point-functions
+ ;; (cons #'tempel-expand
+ ;; completion-at-point-functions)))
(setq tempel-path (expand-file-name "templates" user-emacs-directory))
- (add-hook 'conf-mode-hook 'tempel-setup-capf)
- (add-hook 'prog-mode-hook 'tempel-setup-capf)
- (add-hook 'text-mode-hook 'tempel-setup-capf))
+ ;; (add-hook 'conf-mode-hook 'tempel-setup-capf)
+ ;; (add-hook 'prog-mode-hook 'tempel-setup-capf)
+ ;; (add-hook 'text-mode-hook 'tempel-setup-capf)
+ )
(use-package tempel-collection
:after tempel)
diff --git a/tools/emacs/config/config-dired.el b/tools/emacs/config/config-dired.el
@@ -199,12 +199,12 @@ This relies on the external 'fd' executable."
:bind (:map dired-mode-map
("r" . dired-rsync)))
-(use-package diredfl
- :unless noninteractive
- :commands (diredfl-mode)
- :config
- (setq diredfl-ignore-compressed-flag nil)
- :hook (dired-mode . diredfl-mode))
+;; (use-package diredfl
+;; :unless noninteractive
+;; :commands (diredfl-mode)
+;; :config
+;; (setq diredfl-ignore-compressed-flag nil)
+;; :hook (dired-mode . diredfl-mode))
(use-package trashed
:unless noninteractive
@@ -215,165 +215,23 @@ This relies on the external 'fd' executable."
(setq trashed-sort-key '("Date deleted" . t))
(setq trashed-date-format "%Y-%m-%d %H:%M:%S"))
-(use-package dired-sidebar
- :unless noninteractive
- :commands (dired-sidebar-toggle-sidebar)
- :bind ("C-c C-n" . dired-sidebar-toggle-sidebar)
- :init
- (add-hook 'dired-sidebar-mode-hook
- (lambda ()
- (unless (file-remote-p default-directory)
- (auto-revert-mode))))
- :config
- (push 'toggle-window-split dired-sidebar-toggle-hidden-commands)
- (push 'rotate-windows dired-sidebar-toggle-hidden-commands)
-
- ;; (setq dired-sidebar-subtree-line-prefix "__")
- ;;(setq dired-sidebar-use-custom-font t)
- (setq dired-sidebar-theme 'arrow)
- (setq dired-sidebar-use-term-integration t))
-
-(require 'transient)
-(require 'easymenu)
-
-(defcustom cc-dired-listing-switches '("--human-readable"
- "--group-directories-first"
- "--time-style=long-iso")
- "List of GNU ls arguments used by the function `cc/--dired-sort-by'.
-
-This variable requires GNU ls from coreutils installed.\n
-See the man page `ls(1)' for details."
- :type '(repeat string)
- :group 'dired)
-
-(transient-define-prefix cc/dired-sort-by ()
- "Transient menu to sort Dired buffer by different criteria.
-
-This function requires GNU ls from coreutils installed."
- :value '("--human-readable"
- "--group-directories-first"
- "--time-style=long-iso")
- ; TODO: support cc-dired-listing-switches
- [["Arguments"
- ("-a" "all" "--all")
- ("g" "group directories first" "--group-directories-first")
- ("-r" "reverse" "--reverse")
- ("-h" "human readable" "--human-readable")
- ("t" "time style" "--time-style="
- :choices ("full-iso" "long-iso" "iso" "locale"))]
-
- ["Sort By"
- ("n"
- "Name"
- (lambda () (interactive)
- (cc/--dired-sort-by :name
- (transient-args transient-current-command)))
- :transient nil)
- ("k"
- "Kind"
- (lambda () (interactive)
- (cc/--dired-sort-by :kind
- (transient-args transient-current-command)))
- :transient nil)
- ("l"
- "Date Last Opened"
- (lambda () (interactive)
- (cc/--dired-sort-by :date-last-opened
- (transient-args transient-current-command)))
- :transient nil)
- ("a"
- "Date Added"
- (lambda () (interactive)
- (cc/--dired-sort-by :date-added
- (transient-args transient-current-command)))
- :transient nil)
- ("m"
- "Date Modified"
- (lambda () (interactive)
- (cc/--dired-sort-by :date-modified
- (transient-args transient-current-command)))
- :transient nil)
- ("M"
- "Date Metadata Changed"
- (lambda () (interactive)
- (cc/--dired-sort-by :date-metadata-changed
- (transient-args transient-current-command)))
- :transient nil)
- ("v"
- "Version"
- (lambda () (interactive)
- (cc/--dired-sort-by :version
- (transient-args transient-current-command)))
- :transient nil)
- ("s"
- "Size"
- (lambda () (interactive)
- (cc/--dired-sort-by :size
- (transient-args transient-current-command)))
- :transient nil)]])
-
-(defun cc/--dired-sort-by (criteria &optional prefix-args)
- "Sort current Dired buffer according to CRITERIA and PREFIX-ARGS.
-
-This function will invoke `dired-sort-other' with arguments built from
-CRITERIA and PREFIX-ARGS.
-
-CRITERIA is a keyword of which the following are supported:
- :name :date-added :version
- :kind :date-metadata-changed :size
- :date-last-opened :date-modified
-
-PREFIX-ARGS is a list of GNU ls arguments. If nil, then it will use the value
-of `cc-dired-listing-switches'. Otherwise this is typically populated by the
-Transient menu `cc/dired-sort-by'.
-
-This function requires GNU ls from coreutils installed.
-
-See the man page `ls(1)' for details."
- (let ((arg-list (list "-l")))
- (if prefix-args
- (nconc arg-list prefix-args)
- (nconc arg-list cc-dired-listing-switches))
- (cond
- ((eq criteria :name)
- (message "Sorted by name"))
-
- ((eq criteria :kind)
- (message "Sorted by kind")
- (push "--sort=extension" arg-list))
-
- ((eq criteria :date-last-opened)
- (message "Sorted by date last opened")
- (push "--sort=time" arg-list)
- (push "--time=access" arg-list))
-
- ((eq criteria :date-added)
- (message "Sorted by date added")
- (push "--sort=time" arg-list)
- (push "--time=creation" arg-list))
-
- ((eq criteria :date-modified)
- (message "Sorted by date modified")
- (push "--sort=time" arg-list)
- (push "--time=modification" arg-list))
-
- ((eq criteria :date-metadata-changed)
- (message "Sorted by date metadata changed")
- (push "--sort=time" arg-list)
- (push "--time=status" arg-list))
-
- ((eq criteria :version)
- (message "Sorted by version")
- (push "--sort=version" arg-list))
-
- ((eq criteria :size)
- (message "Sorted by size")
- (push "-S" arg-list))
-
- (t
- (message "Default sorted by name")))
-
- (dired-sort-other (mapconcat 'identity arg-list " "))))
+;; (use-package dired-sidebar
+;; :unless noninteractive
+;; :commands (dired-sidebar-toggle-sidebar)
+;; :bind ("C-c C-n" . dired-sidebar-toggle-sidebar)
+;; :init
+;; (add-hook 'dired-sidebar-mode-hook
+;; (lambda ()
+;; (unless (file-remote-p default-directory)
+;; (auto-revert-mode))))
+;; :config
+;; (push 'toggle-window-split dired-sidebar-toggle-hidden-commands)
+;; (push 'rotate-windows dired-sidebar-toggle-hidden-commands)
+;;
+;; ;; (setq dired-sidebar-subtree-line-prefix "__")
+;; ;;(setq dired-sidebar-use-custom-font t)
+;; (setq dired-sidebar-theme 'arrow)
+;; (setq dired-sidebar-use-term-integration t))
(use-package casual-dired
:bind (:map dired-mode-map ("C-o" . 'casual-dired-tmenu)))
diff --git a/tools/emacs/config/config-editing.el b/tools/emacs/config/config-editing.el
@@ -122,15 +122,15 @@ Else toggle the comment status of the line at point."
("M-o" . delete-blank-lines)
("<C-f6>" . tear-off-window)))
-(use-package pdf-tools
- :unless noninteractive
- :mode ("\\.pdf\\'" . pdf-view-mode)
- :config
- (setq-default pdf-view-display-size 'fit-page)
- (setq pdf-annot-activate-created-annotations t)
- (setq pdf-view-midnight-colors '("#ffffff" . "#000000"))
- (pdf-tools-install :no-query)
- (require 'pdf-occur))
+;; (use-package pdf-tools
+;; :unless noninteractive
+;; :mode ("\\.pdf\\'" . pdf-view-mode)
+;; :config
+;; (setq-default pdf-view-display-size 'fit-page)
+;; (setq pdf-annot-activate-created-annotations t)
+;; (setq pdf-view-midnight-colors '("#ffffff" . "#000000"))
+;; (pdf-tools-install :no-query)
+;; (require 'pdf-occur))
(use-package scratch
:unless noninteractive
@@ -162,11 +162,11 @@ If region is active, add its contents to the new buffer."
:diminish
:hook (prog-mode-hook . subword-mode))
-(use-package selection-highlight-mode
- :preface
- (unless (package-installed-p 'selection-highlight-mode)
- (package-vc-install "https://github.com/balloneij/selection-highlight-mode"))
- :config (selection-highlight-mode))
+;; (use-package selection-highlight-mode
+;; :preface
+;; (unless (package-installed-p 'selection-highlight-mode)
+;; (package-vc-install "https://github.com/balloneij/selection-highlight-mode"))
+;; :config (selection-highlight-mode))
(use-package surround
:bind-keymap ("M-'" . surround-keymap))
diff --git a/tools/emacs/config/config-files.el b/tools/emacs/config/config-files.el
@@ -3,12 +3,12 @@
;;; Files related configurations
;;; Code:
-(use-package autoinsert
- :init
- (setq-default auto-insert-query nil
- auto-insert-alist nil)
- :config
- (auto-insert-mode 1))
+;; (use-package autoinsert
+;; :init
+;; (setq-default auto-insert-query nil
+;; auto-insert-alist nil)
+;; :config
+;; (auto-insert-mode 1))
(use-package files
:commands (revert-buffer)
diff --git a/tools/emacs/config/config-web.el b/tools/emacs/config/config-web.el
@@ -3,72 +3,72 @@
;;; Web related configuration, notably the built-in web browser.
;;; Code:
-(use-package shr
- :config
- (setq shr-use-fonts nil)
- (setq shr-use-colors nil)
- (setq shr-bullet "• ")
- (setq shr-folding-mode t)
-
- (setq shr-max-image-proportion 0.7)
- (setq shr-image-animate nil)
- (setq shr-width (current-fill-column)))
-
-(use-package shr-tag-pre-highlight
- :after shr
- :config
- (add-to-list 'shr-external-rendering-functions
- '(pre . shr-tag-pre-highlight))
- (when (version< emacs-version "26")
- (with-eval-after-load 'eww
- (advice-add 'eww-display-html :around
- 'eww-display-html--override-shr-external-rendering-functions))))
-
-(use-package eww
- :commands (eww
- eww-browse-url
- eww-search-words
- eww-open-in-new-buffer
- eww-open-file
- vde/eww-visit-history)
- :config
- (setq eww-restore-desktop nil)
- (setq eww-desktop-remove-duplicates t)
- (setq eww-header-line-format "%u")
- (setq eww-search-prefix "https://duckduckgo.com/html/?q=")
- (setq url-privacy-level '(email agent cookies lastloc))
- (setq eww-download-directory "~/desktop/downloads/")
- (setq eww-suggest-uris
- '(eww-links-at-point
- thing-at-point-url-at-point))
- (setq eww-bookmarks-directory "~/.emacs.d/eww-bookmarks/")
- (setq eww-history-limit 150)
- (setq eww-use-external-browser-for-content-type
- "\\`\\(video/\\|audio/\\|application/pdf\\)")
- (setq eww-browse-url-new-window-is-tab nil)
- (setq eww-form-checkbox-selected-symbol "[X]")
- (setq eww-form-checkbox-symbol "[ ]")
-
- ;; eww-view-source
-
- (defvar vde/eww-mode-global-map
- (let ((map (make-sparse-keymap)))
- (define-key map "s" 'eww-search-words)
- (define-key map "o" 'eww-open-in-new-buffer)
- (define-key map "f" 'eww-open-file)
- map)
- "Key map to scope `eww' bindings for global usage.
-The idea is to bind this to a prefix sequence, so that its
-defined keys follow the pattern of <PREFIX> <KEY>.")
- :bind-keymap ("C-x w" . vde/eww-mode-global-map)
- :bind (:map eww-mode-map
- ("n" . next-line)
- ("p" . previous-line)
- ("f" . forward-char)
- ("b" . backward-char)
- ("B" . eww-back-url)
- ("N" . eww-next-url)
- ("P" . eww-previous-url)))
+;; (use-package shr
+;; :config
+;; (setq shr-use-fonts nil)
+;; (setq shr-use-colors nil)
+;; (setq shr-bullet "• ")
+;; (setq shr-folding-mode t)
+;;
+;; (setq shr-max-image-proportion 0.7)
+;; (setq shr-image-animate nil)
+;; (setq shr-width (current-fill-column)))
+;;
+;; (use-package shr-tag-pre-highlight
+;; :after shr
+;; :config
+;; (add-to-list 'shr-external-rendering-functions
+;; '(pre . shr-tag-pre-highlight))
+;; (when (version< emacs-version "26")
+;; (with-eval-after-load 'eww
+;; (advice-add 'eww-display-html :around
+;; 'eww-display-html--override-shr-external-rendering-functions))))
+;;
+;; (use-package eww
+;; :commands (eww
+;; eww-browse-url
+;; eww-search-words
+;; eww-open-in-new-buffer
+;; eww-open-file
+;; vde/eww-visit-history)
+;; :config
+;; (setq eww-restore-desktop nil)
+;; (setq eww-desktop-remove-duplicates t)
+;; (setq eww-header-line-format "%u")
+;; (setq eww-search-prefix "https://duckduckgo.com/html/?q=")
+;; (setq url-privacy-level '(email agent cookies lastloc))
+;; (setq eww-download-directory "~/desktop/downloads/")
+;; (setq eww-suggest-uris
+;; '(eww-links-at-point
+;; thing-at-point-url-at-point))
+;; (setq eww-bookmarks-directory "~/.emacs.d/eww-bookmarks/")
+;; (setq eww-history-limit 150)
+;; (setq eww-use-external-browser-for-content-type
+;; "\\`\\(video/\\|audio/\\|application/pdf\\)")
+;; (setq eww-browse-url-new-window-is-tab nil)
+;; (setq eww-form-checkbox-selected-symbol "[X]")
+;; (setq eww-form-checkbox-symbol "[ ]")
+;;
+;; ;; eww-view-source
+;;
+;; (defvar vde/eww-mode-global-map
+;; (let ((map (make-sparse-keymap)))
+;; (define-key map "s" 'eww-search-words)
+;; (define-key map "o" 'eww-open-in-new-buffer)
+;; (define-key map "f" 'eww-open-file)
+;; map)
+;; "Key map to scope `eww' bindings for global usage.
+;; The idea is to bind this to a prefix sequence, so that its
+;; defined keys follow the pattern of <PREFIX> <KEY>.")
+;; :bind-keymap ("C-x w" . vde/eww-mode-global-map)
+;; :bind (:map eww-mode-map
+;; ("n" . next-line)
+;; ("p" . previous-line)
+;; ("f" . forward-char)
+;; ("b" . backward-char)
+;; ("B" . eww-back-url)
+;; ("N" . eww-next-url)
+;; ("P" . eww-previous-url)))
(use-package browse-url
:after eww
diff --git a/tools/emacs/early-init.el b/tools/emacs/early-init.el
@@ -37,7 +37,8 @@
;; Do not initialize installed packages
(setopt package-enable-at-startup nil
- package-archives nil)
+ package-archives nil
+ package-quickstart nil)
(setopt use-package-ensure-function 'ignore)
;; Do not resize the frame at this early stage
@@ -79,6 +80,11 @@
(advice-add #'x-apply-session-resources :override #'ignore)
(setopt inhibit-x-resources t)
+;;
+(when (getenv-internal "DEBUG")
+ (setq init-file-debug t
+ debug-on-error t))
+
;; - Resetting garbage collection and file-name-handler values.
(add-hook 'after-init-hook
`(lambda ()
diff --git a/tools/emacs/init.el b/tools/emacs/init.el
@@ -238,36 +238,38 @@
(setq native-comp-async-report-warnings-errors 'silent) ; Emacs 28 with native compilation
(setq native-compile-prune-cache t)) ; Emacs 29
+;; Refactor this completely. Reduce to the minimum.
(require '00-base)
(require '00-clean) ;; Maybe refactor no-littering
-(require 'config-appearance)
-(require 'config-buffers)
-(require 'config-compile)
-(require 'config-completion)
-(require 'config-dired)
+(unless noninteractive
+ (require 'config-appearance)
+ (require 'config-buffers)
+ (require 'config-compile)
+ (require 'config-completion)
+ (require 'config-dired)
+ (require 'config-mouse)
+ (require 'config-navigating)
+ (require 'config-org)
+ (require 'config-programming)
+ (require 'config-projects)
+ (require 'config-search)
+ (require 'config-shells)
+ (require 'config-vcs)
+ (require 'config-web)
+ (require 'config-windows)
+ (require 'programming-config)
+ (require 'programming-containers)
+ (require 'programming-cue)
+ (require 'programming-eglot)
+ (require 'programming-go)
+ (require 'programming-js)
+ (require 'programming-nix)
+ (require 'programming-treesitter)
+ (require 'programming-web))
(require 'config-editing)
(require 'config-files)
(require 'config-keybindings)
(require 'config-misc)
-(require 'config-mouse)
-(require 'config-navigating)
-(require 'config-org)
-(require 'config-programming)
-(require 'config-projects)
-(require 'config-search)
-(require 'config-shells)
-(require 'config-vcs)
-(require 'config-web)
-(require 'config-windows)
-(require 'programming-config)
-(require 'programming-containers)
-(require 'programming-cue)
-(require 'programming-eglot)
-(require 'programming-go)
-(require 'programming-js)
-(require 'programming-nix)
-(require 'programming-treesitter)
-(require 'programming-web)
(if (file-exists-p (downcase (concat user-emacs-directory "/hosts/" (vde/short-hostname) ".el")))
(load-file (downcase (concat user-emacs-directory "/hosts/" (vde/short-hostname) ".el"))))