summaryrefslogtreecommitdiff
path: root/mms-configuration.org
diff options
context:
space:
mode:
authormms <michal@sapka.me>2024-01-19 15:22:13 +0100
committermms <michal@sapka.me>2024-01-19 15:22:13 +0100
commit9ab57ee255a03b86ed7303aa94959e3b104e1719 (patch)
tree926293dc6d9460f1eab12231573b71abc8d5ac4e /mms-configuration.org
feat: extract into dedicated repo
Diffstat (limited to 'mms-configuration.org')
-rw-r--r--mms-configuration.org193
1 files changed, 193 insertions, 0 deletions
diff --git a/mms-configuration.org b/mms-configuration.org
new file mode 100644
index 0000000..63b9e1c
--- /dev/null
+++ b/mms-configuration.org
@@ -0,0 +1,193 @@
+#+TITLE: mms Emacs Config - General settings
+#+AUTHOR: MichaƂ Sapka (https://michal.sapka.me)
+#+STARTUP: showall indent logdone
+
+#+HUGO_BASE_DIR: ~/ghq/vcs.sapka.me/michal-sapka-me/
+#+HUGO_WEIGHT: 10
+#+HUGO_SECTION: emacs/config
+#+HUGO_CATEGORIES: emacs emacs-config
+#+HUGO_MENU :menu "emacs-config" :name "Genral settings"
+#+HUGO_CUSTOM_FRONT_MATTER: :abstract "My emacs config - general config"
+#+HUGO_CUSTOM_FRONT_MATTER: :menu-abstract "Just some basic stuff"
+#+EXPORT_FILE_NAME: configuration
+
+This file sets generic things around my Emacs config.
+All other files rely on this.
+
+* Lexical binding
+
+#+BEGIN_SRC emacs-lisp
+ ;;; -*- lexical-binding: t -*-
+#+END_SRC
+
+* Basic configuration
+
+I want to use UTF-8 everywhere
+
+#+BEGIN_SRC emacs-lisp
+ (prefer-coding-system 'utf-8)
+ (set-default-coding-systems 'utf-8)
+ (set-language-environment "UTF-8")
+ (setq require-final-newline t)
+#+END_SRC
+
+Emacs has this terrible habbit of wanting to write "yes" or "no" to confirm different things.
+This changes it to simple "y" and "n"
+
+#+begin_src emacs-lisp
+ (setopt use-short-answers t)
+#+end_src
+
+I will save a lot files in my temporary filder.
+
+#+begin_src emacs-lisp
+ (defvar mms-tmp-dir (concat (user-login-name) "/tmp"))
+ (make-directory mms-tmp-dir t)
+#+end_src
+
+I don't want to pollute each and every one of my folders, so I'm keeping all backup files in one place.
+On each of my systems I have a =~/tmp= folder just for custom temporary file.
+
+#+begin_src emacs-lisp
+ (setq backup-directory-alist `((".*" . ,mms-tmp-dir)))
+ (setq auto-save-file-name-transforms `((".*" ,mms-tmp-dir t)))
+#+end_src
+
+Tramp can get /even slower/ with file locks, so I disable those
+Or at least this is what I've been told.
+
+#+begin_src emacs-lisp
+ (setq remote-file-name-inhibit-locks t)
+#+end_src
+
+Tabs, what are they good for?
+Absolutelly nothing!
+Let's use spaces everywhere
+
+#+begin_src emacs-lisp
+ (setq-default indent-tabs-mode nil)
+#+end_src
+* Package management
+
+Recently, I have migrated to Elpaca.
+A lot of emacsers tend to use Straight, but Elpaca seems more modern with asynchronous loading of packages.
+This, of course, is a can of worms.
+
+#+BEGIN_SRC emacs-lisp
+ (defvar elpaca-installer-version 0.6)
+ (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)))
+ (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 (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))))
+ (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
+ (elpaca elpaca-use-package
+ ;; Enable :elpaca use-package keyword.
+ (elpaca-use-package-mode)
+ ;; Assume :elpaca t unless otherwise specified.
+ (setq elpaca-use-package-by-default t))
+#+end_src
+
+We need to wait here for elpaca to actually load.
+We will see this pattern again.
+
+#+begin_src emacs-lisp
+ (elpaca-wait)
+#+end_src
+
+* Auto-complete in minibuffer
+
+Having autocomplete in emacs is one of most important things.
+I've used =ido= before, but now I'm trying =vertico=.
+I don't want a big plugin here, like helm.
+
+I left the optional params here from the tutorial in case I want to get /fancy/.
+
+#+begin_src emacs-lisp
+ (use-package vertico
+ :init
+ (vertico-mode)
+
+ ;; Different scroll margin
+ ;; (setq vertico-scroll-margin 0)
+
+ ;; Show more candidates
+ ;; (setq vertico-count 20)
+
+ ;; Grow and shrink the Vertico minibuffer
+ ;; (setq vertico-resize t)
+ )
+#+end_src
+
+Marginalia adds extra information to the list
+
+#+begin_src emacs-lisp
+(use-package marginalia
+ :init
+ (marginalia-mode))
+#+end_src
+
+* Variables
+
+I use two machines on different OSes (personal on FreeBSD and work on MacOS).
+On a few occasions, I will use device to use correct behavior.
+
+#+begin_src emacs-lisp
+ (setq mms-is-voyager (string= (system-name) "voyager"))
+ (setq mms-is-mac (string= (system-name) "RN90Y7RDHT"))
+#+end_src
+
+* Line numbering
+
+Most of the time, I want my line numbers.
+I use Evil after all.
+
+But sometimes they are not needed.
+
+#+begin_src emacs-lisp
+ (defun mms-hide-line-numbers()
+ (interactive)
+ (display-line-numbers-mode 0))
+#+end_src
+
+* Allow for diminished mode
+
+Emacs is based od modes which may pollute the modeline.
+Dimish will hide them from the modeline, even if they are enabled.
+
+#+begin_src emacs-lisp
+ (use-package diminish
+ :elpaca t)
+#+end_src