From 2b46acf486483ecd3e047d5ff8e6f9d2d5cc88d3 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Thu, 2 Dec 2021 09:41:01 +0100 Subject: Various changes, I don't care. --- init.org | 272 ++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 129 insertions(+), 143 deletions(-) diff --git a/init.org b/init.org index 0492b1d..5d8e4c4 100644 --- a/init.org +++ b/init.org @@ -21,6 +21,7 @@ With multiple files I spend too much time trying to find the best place for any We take all code blocks in this file and assemble an =init.el= from it if the source file =init.org= is younger. At startup time we check if the =init.el= has to be regenerated. To get started you need to have an =init.el= with at least these contents. #+BEGIN_SRC elisp +(setq lexical-binding t) (let ((orgfile (expand-file-name (concat user-emacs-directory "init.org"))) (target (expand-file-name (concat user-emacs-directory "init.el")))) (when (not (file-newer-than-file-p target orgfile)) @@ -38,99 +39,90 @@ We take all code blocks in this file and assemble an =init.el= from it if the so Emacs is an operating system and I use it as such (see [[http://elephly.net/posts/2016-02-14-ilovefs-emacs.html][this blog post]]). I rely on quite a few extensions that have been made available on various ELPA repositories. Recently, I have moved to installing and managing Emacs packages like any other software package on my system with the functional package manager [[https://gnu.org/s/guix][GNU Guix]]. I find this more reliable, although at first it is slightly less convenient as I can no longer just use =package.el= but first need to package the Elisp code for Guix. -To install all packages via GNU Guix I can either use a manifest file or use the following invocation: - -#+BEGIN_SRC shell :noweb-ref nil - guix install \ - emacs \ - emacs-ag \ - emacs-all-the-icons \ - emacs-all-the-icons-dired \ - emacs-auctex \ - emacs-company \ - emacs-debbugs \ - emacs-ess \ - emacs-expand-region \ - emacs-fill-column-indicator \ - geiser \ - emacs-god-mode \ - emacs-guix \ - emacs-lispy \ - emacs-markdown-mode \ - emacs-mmm-mode \ - emacs-multiple-cursors \ - emacs-olivetti \ - emacs-org \ - emacs-org-bullets \ - emacs-org-trello \ - emacs-page-break-lines \ - emacs-paren-face \ - emacs-pdf-tools \ - emacs-perspective \ - emacs-projectile \ - emacs-rich-minority \ - emacs-shell-switcher \ - emacs-skewer-mode \ - emacs-smart-mode-line \ - emacs-solarized-theme \ - emacs-tagedit \ - emacs-typo \ - emacs-undo-tree \ - emacs-web-mode \ - emacs-wget \ - emacs-znc \ - emacs-paredit \ - magit \ - sicp \ - mu -#+END_SRC - -If there are packages that are not yet packaged for Guix, I can define them in this list: - -#+BEGIN_SRC elisp -(defvar my/packages '()) -#+END_SRC - -I want these packages to be installed automatically. First I need to define in what repositories Emacs should look for the packages. I’m using packages from both the “melpa” and “marmalade” repositories. - -#+BEGIN_SRC elisp -(require 'package) -(add-to-list 'package-archives - '("melpa" . "http://melpa.milkbox.net/packages/")) -(package-initialize) -#+END_SRC - -If this is a fresh Emacs installation melpa needs to be initialised first: - -#+BEGIN_SRC elisp -(unless (file-exists-p "~/.emacs.d/elpa/archives/melpa") - (package-refresh-contents)) -#+END_SRC - -Now we are ready to install packages if they aren’t yet installed. - -#+BEGIN_SRC elisp -(defun packages-install (packages) - (mapc (lambda (package) - (when (not (package-installed-p package)) - (package-install package))) - packages) - (delete-other-windows)) - -(defun init--install-packages () - (packages-install my/packages)) -#+END_SRC - -Install packages as soon as this configuration is evaluated. If there’s an error (e.g. because a package by this name cannot be found) ask Emacs to refresh the list of packages and retry. If there’s an error again we just ignore it. It could be that it’s because there’s no Internet connection. - -#+BEGIN_SRC elisp -(condition-case e - (init--install-packages) - (error - (ignore-errors - (package-refresh-contents) - (init--install-packages)))) -#+END_SRC +To install all packages via GNU Guix I use a manifest file: + +#+BEGIN_SRC scheme :noweb-ref nil :tangle ~/.emacs.d/manifest.scm :eval no :results output silent +;; This is my Guix manifest +(specifications->manifest + (list + "emacs" + "emacs-ace-jump-mode" + "emacs-ag" + "emacs-all-the-icons" + "emacs-all-the-icons-dired" + "emacs-benchmark-init" + "emacs-company" + "emacs-debbugs" + "emacs-desktop-environment" + "emacs-dired-sidebar" + "emacs-erc-hl-nicks" + "emacs-ess" + "emacs-expand-region" + "emacs-fill-column-indicator" + "emacs-geiser" + "emacs-guix" + "emacs-ivy" + "emacs-ivy-posframe" + "emacs-magit" + "emacs-markdown-mode" + "emacs-mmm-mode" + "emacs-multiple-cursors" + "emacs-nov-el" + "emacs-olivetti" + "emacs-org" + "emacs-org-bullets" + "emacs-org-re-reveal" + "emacs-org-reveal" + "emacs-page-break-lines" + "emacs-paredit" + "emacs-paren-face" + "emacs-pdf-tools" + "emacs-perspective" + "emacs-pinentry" + "emacs-projectile" + "emacs-scpaste" + "emacs-shell-switcher" + "emacs-simple-mpc" + "emacs-skewer-mode" + "emacs-solaire-mode" + "emacs-tablist" + "emacs-tagedit" + "emacs-terraform-mode" + "emacs-typo" + "emacs-undo-tree" + "emacs-web-mode" + "emacs-wget" + "emacs-which-key" + "emacs-yasnippet" + "emacs-znc" + + "sicp" + "mu" + + ;; themes + "emacs-almost-mono-themes" + "emacs-solarized-theme" + "emacs-doom-modeline" + "emacs-quasi-monochrome" + "emacs-poet-theme" + "emacs-tao-theme" + "emacs-doom-themes")) +#+END_SRC + +And then I use Guix to instantiate this manifest file as a profile in =~/.emacs.d/.guix-profile= + +#+begin_src sh :noweb-ref nil :results output silent :tangle no :eval yes +guix package -p ~/.emacs.d/.guix-profile -m ~/.emacs.d/manifest.scm +#+end_src + +#+RESULTS: + +Make Emacs load packages from the profile: + +#+begin_src elisp +(setq package-directory-list + '("/home/rekado/.emacs.d/.guix-profile/share/emacs/site-lisp")) +#+end_src * Better defaults :PROPERTIES: @@ -154,46 +146,52 @@ Here are a few more simple tweaks: ;; No splash screen please ... (setq inhibit-startup-message t) +;; Use UTF-8 by default +(prefer-coding-system 'utf-8-unix) + +;; When point is on a file name and find-file is used, populate the prompt with the name of the file at point. +(ffap-bindings) + ;; display tool tips in echo area only (tooltip-mode -1) - +(tool-bar-mode 0) +(menu-bar-mode 0) ;; by default Emacs will only resize the frame line by line (setq frame-resize-pixelwise t) ;; don’t force me to input “yes” or “no” (defalias 'yes-or-no-p 'y-or-n-p) +;; Use ibuffer instead of list-buffer +(global-set-key (kbd "C-x C-b") 'ibuffer) + ;; disable mouse scrolling (mouse-wheel-mode -1) + +;(set-frame-parameter nil 'undecorated t) #+END_SRC -Tell Emacs to look for my custom code in the =lisp= directory. This will not be needed in the future once everything is found in this Org document. +I don’t use Helm because it’s too “busy” but I do want a more intelligent way to select buffers and find files. #+BEGIN_SRC elisp -(add-to-list 'load-path (concat user-emacs-directory "lisp")) +(require 'ivy) +(ivy-mode 1) +(require 'ivy-posframe) +(setq ivy-posframe-display-functions-alist '((t . ivy-posframe-display-at-frame-top-center))) #+END_SRC -Also tell Emacs that I want to have a separate file for all other customisations that are handled through =M-x customize=. +Enter a directory when RET is hit. #+BEGIN_SRC elisp -;; Keep emacs Custom-settings in separate file -(setq custom-file (expand-file-name "custom.el" user-emacs-directory)) -(load custom-file) +(define-key ivy-minibuffer-map (kbd "") 'ivy-alt-done) #+END_SRC -Emacs doesn’t deal well with very long lines. I often produce very long lines when hacking Scheme using Geiser, which regularly kills my session. The following snippet shortens long lines in =comint=-derived modes such as Geiser. This code was provided by wasamasa as [[http://emacs.stackexchange.com/a/5559/2005][an answer to my question on the Emacs StackExchange]]. +Also tell Emacs that I want to have a separate file for all other customisations that are handled through =M-x customize=. #+BEGIN_SRC elisp -(defun my/comint-shorten-long-lines (text) - ;; Use \x22 here instead of straight double quotes because that would - ;; break the regular expression for prettifying Org src blocks. - (let* ((regexp "^\\(.\\{380\\}\\).*?\\(\x22?\\)$") - (shortened-text (replace-regexp-in-string regexp "\\1\\2" text))) - (if (string= shortened-text text) - text - (propertize shortened-text 'font-lock-face 'shadow 'help-echo text)))) - -(add-hook 'comint-preoutput-filter-functions 'my/comint-shorten-long-lines) +;; Keep emacs Custom-settings in separate file +(setq custom-file (expand-file-name "custom.el" user-emacs-directory)) +(load custom-file) #+END_SRC * Theme @@ -201,12 +199,22 @@ Emacs doesn’t deal well with very long lines. I often produce very long lines :header-args: :noweb-ref theme :END: -Currently, I’m a fan of themes with muted colours. The =tao-yang-theme= is a light theme with very few colours. +** Use only one theme at a time + +The default behavior of Emacs is that you can compose multiple themes; however, in practice that’s never done and will likely just mess things up. With this little advice, we tell Emacs that once a theme is loaded, all prior themes should be disabled. #+BEGIN_SRC elisp -(setq frame-background-mode 'light) -(require 'solarized) -(load-theme 'solarized-light t) +(defadvice load-theme (before theme-dont-propagate activate) + (progn (mapc #'disable-theme custom-enabled-themes) + (run-hooks 'after-load-theme-hook))) +#+END_SRC + +The Doom Emacs themes look pretty nice. I also like to highlight source buffers to distinguish them from side windows, so I enable =solaire-mode= first. + +#+BEGIN_SRC elisp +;(setq frame-background-mode 'dark) +(solaire-global-mode +1) +(load-theme 'doom-molokai) #+END_SRC Dired mode becomes much prettier with =all-the-icons=. @@ -248,7 +256,7 @@ I’m often building Guix packages in the shell. =guix-build-log-minor-mode= gi I’m monitoring the Guix build farm =berlin.guixsd.org=, which is hosted at the MDC. #+BEGIN_SRC elisp -(setq guix-hydra-url "https://berlin.guixsd.org") +(setq guix-hydra-url "https://ci.guix.gnu.org") #+END_SRC For bug and patch tracking the Guix project uses debbugs. Here are some better defaults for using =debbugs-gnu= with Guix: @@ -334,10 +342,9 @@ This is my org mode configuration. Much of it is in one big blob and I haven’ (setq org-directory "~/Documents/org") (setq org-agenda-files (mapcar (lambda (x) (concat org-directory x)) (list "/master.org" - "/work.org" "/email.org" - "/study.org" - "/home.org"))) + "/home.org" + "/birthdays.org"))) (setq org-default-notes-file (concat org-directory "/notes.org")) (setq org-agenda-custom-commands @@ -588,6 +595,7 @@ TRAMP is a really convenient way to edit files on remote systems from within the ;; respect the PATH variable on the remote machine (add-to-list 'tramp-remote-path 'tramp-own-remote-path) +(add-to-list 'tramp-remote-path "~/.guix-profile/bin") (setq tramp-verbose 3) #+END_SRC @@ -691,6 +699,7 @@ TODO: here’s the rest of my shell configuration: ;; Show current path instead of just "*shell*<2>" (setq uniquify-buffer-name-style 'forward) +(setq uniquify-min-dir-content 1024) (require 'uniquify) #+END_SRC @@ -852,32 +861,9 @@ Not EMMS but MPC: :header-args: :noweb-ref modeline :END: -Before setting up any modeline themes we load the IRC client ERC and -tell it where to place the indicator for channel activity. #+BEGIN_SRC elisp -(require 'erc) -(setq erc-track-position-in-mode-line 'before-modes) -#+END_SRC - -I don’t like a cluttered modeline, so I like to hide mode lighters with =rich-minority=. - -#+BEGIN_SRC elisp -;; clean up mode line -(require 'rich-minority) -(setq rm-whitelist '(" God" " Paredit")) - -;; show time in modeline but not load average -(setq display-time-format "%H:%M") -(setq display-time-default-load-average nil) -(display-time-mode 1) - -;; show column position of point in status bar -(column-number-mode 1) - -;; smart mode line -(setq sml/theme 'respectful) -(sml/setup) +(doom-modeline-mode) #+END_SRC -- cgit v1.2.3