Reorganize basic emacs config

Move everything in a use-package block for clarity and organization
This commit is contained in:
Dimitri Lozeve 2024-01-22 14:15:03 +01:00
parent bc41d2b3d8
commit 1a797360fe

143
init.el
View file

@ -4,73 +4,96 @@
;;; Code: ;;; Code:
;;; Straight.el setup
(setq straight-repository-branch "develop"
straight-use-package-by-default t)
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 6))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
;;; Appearance and general behavior
(use-package emacs
:straight nil
:config
;; Always load newest byte code ;; Always load newest byte code
(setq load-prefer-newer t) (setq load-prefer-newer t)
;; Display configuration
(setq inhibit-startup-screen t) (setq inhibit-startup-screen t)
(tool-bar-mode -1) (tool-bar-mode -1)
(scroll-bar-mode -1) (scroll-bar-mode -1)
(menu-bar-mode -1) (menu-bar-mode -1)
(setq visible-bell 1) (setq visible-bell 1)
(line-number-mode 1)
(column-number-mode 1)
(size-indication-mode 1)
(blink-cursor-mode 0) (blink-cursor-mode 0)
(show-paren-mode 1)
(setq auto-window-vscroll nil) (global-hl-line-mode -1)
(setq view-read-only t) (global-hi-lock-mode 1)
;; More useful frame title, that show either a file or a buffer name
(setq ns-right-alternate-modifier nil ;; (if the buffer isn't visiting a file)
ns-command-modifier 'meta)
(setq frame-resize-pixelwise t)
;; Display time in mode-line
(setq display-time-24hr-format t)
(display-time-mode 1)
;; Dired human readable sizes
(setq dired-listing-switches "-Alh")
;; Enable disabled commands
(put 'narrow-to-region 'disabled nil)
;; more useful frame title, that show either a file or a
;; buffer name (if the buffer isn't visiting a file)
(setq frame-title-format (setq frame-title-format
'((:eval (if (buffer-file-name) '((:eval (if (buffer-file-name)
(abbreviate-file-name (buffer-file-name)) (abbreviate-file-name (buffer-file-name))
"%b")))) "%b"))))
;; Newline at end of file ;; Font configuration
(setq require-final-newline t) (let ((my-font "Iosevka Term")
(my-height 130))
(set-face-attribute 'default nil :family my-font :height my-height)
(set-face-attribute 'fixed-pitch nil :family my-font :height my-height))
(set-face-attribute 'variable-pitch nil :family "Libertinus Serif" :height 160)
;; TAB cycle if there are only few candidates ;; Mode line configuration
(setq completion-cycle-threshold 3) (line-number-mode 1)
(column-number-mode 1)
(size-indication-mode 1)
(setq display-time-24hr-format t)
(display-time-mode 1)
;; Behavior configuration
(prefer-coding-system 'utf-8) (prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8) (set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8) (set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8) (set-keyboard-coding-system 'utf-8)
(setq auto-window-vscroll nil)
(setq frame-resize-pixelwise t)
(setq view-read-only t)
;; Newline at end of file
(setq require-final-newline t)
;; TAB cycle if there are only few candidates
(setq completion-cycle-threshold 3)
;; System locale to use for formatting time values. Make sure that ;; System locale to use for formatting time values. Make sure that
;; the weekdays in the time stamps of your Org mode files and in the ;; the weekdays in the time stamps of your Org mode files and in the
;; agenda appear in English. ;; agenda appear in English.
(setq system-time-locale "C") (setq system-time-locale "C")
;; Enable disabled commands
(put 'narrow-to-region 'disabled nil)
;; MacOS specific configuration
(setq ns-right-alternate-modifier nil
ns-command-modifier 'meta)
;; Dired human readable sizes
(setq dired-listing-switches "-Alh")
;; C mode configuration
(setq-default c-basic-offset 2) (setq-default c-basic-offset 2)
(setq c-default-style "linux") (setq c-default-style "linux")
(setq-default c-doc-comment-style (setq-default c-doc-comment-style
'((c-mode . doxygen) '((c-mode . doxygen)
(c++-mode . doxygen))) (c++-mode . doxygen)))
(let ((my-font "Iosevka Term")
(my-height 130))
(set-face-attribute 'default nil :family my-font :height my-height)
(set-face-attribute 'fixed-pitch nil :family my-font :height my-height))
(set-face-attribute 'variable-pitch nil :family "Libertinus Serif" :height 160)
;; Better renaming rules for buffers with the same name ;; Better renaming rules for buffers with the same name
(setq uniquify-buffer-name-style 'forward) (setq uniquify-buffer-name-style 'forward)
(setq uniquify-separator "/") (setq uniquify-separator "/")
@ -89,44 +112,17 @@
(let ((fill-column (point-max))) (let ((fill-column (point-max)))
(fill-region (region-beginning) (region-end) nil))) (fill-region (region-beginning) (region-end) nil)))
(defun random-todo () :bind (("M-o" . other-window)
(interactive) ([remap buffer-menu] . ibuffer)
(let ((points nil)) ([remap count-words-region] . count-words)
(goto-char (point-min)) ([remap just-one-space] . cycle-spacing)
(while (search-forward-regexp "\*\sTODO" nil t) ([remap zap-to-char] . zap-up-to-char)
(setq points (cons (1+ (match-end 0)) points)))
(goto-char (seq-random-elt points))))
;; Straight.el setup
(setq straight-repository-branch "develop"
straight-use-package-by-default t)
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 6))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
;; Better than default: act on the region if active ;; Better than default: act on the region if active
(bind-key [remap upcase-word] #'upcase-dwim) ([remap upcase-word] . upcase-dwim)
(bind-key [remap downcase-word] #'downcase-dwim) ([remap downcase-word] . downcase-dwim)
(bind-key [remap capitalize-word] #'capitalize-dwim) ([remap capitalize-word] . capitalize-dwim)))
(bind-key [remap count-words-region] #'count-words)
(bind-key [remap just-one-space] #'cycle-spacing)
(bind-key [remap zap-to-char] #'zap-up-to-char)
(bind-key [remap buffer-menu] #'ibuffer)
(bind-key "M-o" #'other-window)
;;; Appearance
;; Theme configuration
(use-package emacs (use-package emacs
:straight nil :straight nil
:init :init
@ -137,9 +133,6 @@
:config :config
;; (setq modus-themes-common-palette-overrides modus-themes-preset-overrides-faint) ;; (setq modus-themes-common-palette-overrides modus-themes-preset-overrides-faint)
(load-theme 'modus-vivendi) (load-theme 'modus-vivendi)
(show-paren-mode 1)
(global-hl-line-mode -1) ; Highlight the current line
(global-hi-lock-mode 1)
:bind ("<f12>" . modus-themes-toggle)) :bind ("<f12>" . modus-themes-toggle))
(use-package diminish (use-package diminish