From 9b7417f6c69360273e82b41130992c44fe373101 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sun, 30 Jan 2022 23:12:22 -0800 Subject: Update GNUmakefile - Add the ‘dunst’, ‘zsh’, ‘mcron’, and ‘mbsync’ modules. - Tell Make that any ‘*.el’ files ar “precious”, meaning that when a ‘.elc’ file was generated from a ‘.el’ file that was itself generated from a ‘.org’ file, the ‘.el’ file isn't just an intermediate file and should not be deleted. - Change the ‘install’ and ‘clean’ to use the ‘*-stow’ and ‘*-clean’ rules set up for each module. - Add configuration for ‘outline-minor-mode’ and change the headings to adhere to that configuration. - Stop using the ‘build/’ directory, tangle all the files to the same directory as the source files, and use stow, not cp, to install them. The only exception is the XDG files, which now have their specific ‘xdg-stow’ rule. This is necessary because programs using these files will overwrite a symbolic link they find and replace it with a new file, overwriting my settings. - Add some files that were missing, and rename some files to follow the existing convention to make them easy to tangle. --- GNUmakefile | 109 +++++++++++++--------------- emacs/.config/emacs/init.org | 53 ++++++++++++++ emacs/.config/shepherd/init.d/emacs.org | 16 ---- emacs/.config/shepherd/init.d/emacs.scm.org | 16 ++++ mbsync/.config/cron/mbsync.guile.org | 5 ++ mcron/.config/shepherd/init.d/mcron.scm.org | 17 +++++ shepherd/.config/shepherd/init.org | 13 ---- shepherd/.config/shepherd/init.scm.org | 13 ++++ 8 files changed, 153 insertions(+), 89 deletions(-) create mode 100644 emacs/.config/emacs/init.org delete mode 100644 emacs/.config/shepherd/init.d/emacs.org create mode 100644 emacs/.config/shepherd/init.d/emacs.scm.org create mode 100644 mbsync/.config/cron/mbsync.guile.org create mode 100644 mcron/.config/shepherd/init.d/mcron.scm.org delete mode 100644 shepherd/.config/shepherd/init.org create mode 100644 shepherd/.config/shepherd/init.scm.org diff --git a/GNUmakefile b/GNUmakefile index d63de98..5d25714 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,9 +1,11 @@ -MODULES=xmodmap emacs xdg shepherd +MODULES=xmodmap emacs xdg shepherd dunst zsh mcron mbsync STOW = stow EMACS = emacs SCHEME_IMPLEMENTATION = guile +.PRECIOUS: %.el + define tangle = @echo -e "\e[35mOBT\e[0m" $< @$(EMACS) -quick -batch \ @@ -18,14 +20,8 @@ endef all: $(MODULES) -install: - cp --recursive --verbose build/. ~/ - -clean: - rm -r build - -zsh: - $(MAKE) -C $@ +install: $(addsuffix -stow,$(MODULES)) +clean: $(addsuffix -clean,$(MODULES)) before-%-install: # Dummy recipe @true @@ -39,7 +35,7 @@ before-%-install: # Dummy recipe %-uninstall: $(STOW) -D $(subst -uninstall,,$@) -# Picom +## Picom picom: picom/.config/picom.conf @@ -49,31 +45,22 @@ picom/.config/picom.conf: picom/.config/picom.org picom-clean: rm -f picom/.config/picom.conf -######### -# Emacs # -######### +## Emacs -emacs: build/.config/shepherd/init.d/ build/.config/shepherd/init.d/emacs.scm \ - emacs/.config/emacs/init.elc - -build/.config/shepherd/init.d/emacs.scm: emacs/.config/shepherd/init.d/emacs.org - $(call tangle) +emacs: emacs/.config/shepherd/init.d/emacs.scm emacs/.config/emacs/init.elc -########### -# Xmodmap # -########### +emacs-clean: + rm -f emacs/.config/shepherd/init.d/emacs.scm emacs/.config/emacs/init.el \ + emacs/.config/emacs/init.elc -xmodmap: build/ build/.Xmodmap +## Xmodmap -build/.Xmodmap: xmodmap/Xmodmap.org - $(call tangle,fundamental) +xmodmap: xmodmap/.Xmodmap xmodmap-clean: - rm -f build/.Xmodmap + rm -f xmodmap/.Xmodmap -######### -# Cower # -######### +## Cower cower: cower/.config/cower/config @@ -83,9 +70,7 @@ cower/.config/cower/config: cower/.config/cower/config.org cower-clean: rm -f cower/.config/cower/config -############# -# Mowedline # -############# +## Mowedline mowedline: mowedline/.config/mowedline/init.scm @@ -96,59 +81,63 @@ mowedline/.config/mowedline/init.scm: mowedline/.config/mowedline/init.org mowedline-clean: rm -f mowedline/.config/mowedline/init.scm -######### -# Dunst # -######### +## Dunst dunst: dunst/.config/dunst/dunstrc -dunst/.config/dunst/dunstrc: dunst/.config/dunst/dunstrc.org - $(call tangle,conf-unix) - -dunst-clean: - rm -f dunst/.config/dunst/dunstrc - -# X11 +## X11 x11-install: lib-install x11/dot-x11-0-1-any.pkg.tar.xz x11/dot-x11-0-1-any.pkg.tar.xz: x11/PKGBUILD cd x11 && makepkg -sicf -####### -# XDG # -####### +## XDG -xdg: build/.config/ build/.config/mimeapps.list build/.config/user-dirs.dirs \ - build/.config/user-dirs.locale +xdg: xdg/.config/mimeapps.list xdg/.config/user-dirs.dirs \ + xdg/.config/user-dirs.locale -build/.config/mimeapps.list: xdg/.config/mimeapps.list.org - $(call tangle) +# These files shouldn't be stowed because the applications managing/using them +# immediately replace the symbolic links with new files and the settings in them +# are lost. +xdg-stow: + cp xdg/.config/mimeapps.list xdg/.config/user-dirs.dirs xdg/.config/user-dirs.locale $(HOME)/.config/ -build/.config/user-dirs.dirs: xdg/.config/user-dirs.dirs.org - $(call tangle) +## Shepherd -build/.config/user-dirs.locale: xdg/.config/user-dirs.locale.org - $(call tangle) +shepherd: shepherd/.config/shepherd/init.scm -# Shepherd +## Mcron -shepherd: build/.config/shepherd/ build/.config/shepherd/init.scm +mcron: mcron/.config/shepherd/init.d/mcron.scm -build/.config/shepherd/init.scm: shepherd/.config/shepherd/init.org - $(call tangle) +## Mbsync + +mbsync: mbsync/.config/cron/mbsync.guile + +## ZSH -# Helper +zsh: zsh/.profile zsh/.zshrc zsh/.zsh/functions/unzip.zwc \ + zsh/.zsh/functions/x-yank.zwc zsh/.zsh/functions/x-copy-region-as-kill.zwc + +## Helper %.el: %.org $(call tangle,emacs-lisp) %.elc: %.el @echo -e "\e[36mELC\e[0m" $< - $(EMACS) -batch -f batch-byte-compile $< + $(EMACS) -batch -f package-initialize -f batch-byte-compile $< %: %.org $(call tangle) -%/: - mkdir -p $@ +.%: %.org + $(call tangle) + +%.zwc: % + zsh -c "zcompile $@ $^" + +# Local Variables: +# outline-regexp: "##+" +# End: diff --git a/emacs/.config/emacs/init.org b/emacs/.config/emacs/init.org new file mode 100644 index 0000000..ff7186d --- /dev/null +++ b/emacs/.config/emacs/init.org @@ -0,0 +1,53 @@ +#+TITLE: Emacs Configuration + +First, lexical binding must be enabled. This is better for performance, but also makes variable binding behave more as expected, and allows the creation of closures. + +#+begin_src emacs-lisp :padline no + ;; -*- lexical-binding: t; -*- +#+end_src + +#+begin_src emacs-lisp + (require 'oni-core) + (require 'oni-gui) +#+end_src + +Store all auto-save files in =$XDG_DATA_HOME/emacs/auto-save-list= to prevent them from clogging up =$XDG_CONFIG_HOME/emacs/=. The XDG specification says that if =XDG_DATA_HOME= hasn't been specified a default of =~/.local/share= should be used. + +#+begin_src emacs-lisp + (add-to-list + 'auto-save-file-name-transforms + `(,(rx (zero-or-more any)) + ,(concat (or (getenv "XDG_DATA_HOME") + (expand-file-name "~/.local/share")) + "/emacs/auto-save-list") + t) + t) +#+end_src + +Use =hunspell= instead of the default =aspell=. Hunspell is used by LibreOffice and other programs too. So far (at least through Emacs) it doesn't recognize the =’= as an apostrophe and I have to use ='= in org-mode if I want spell checking to accept word contractions in English. + +#+begin_src emacs-lisp + (eval-when-compile (require 'ispell)) + (with-eval-after-load 'ispell + (setq ispell-program-name "hunspell" + ispell-really-hunspell t)) +#+end_src + +Electric quote uses pretty quoting characters =’=, =‘=, =”=, and =“= instead of ='= and ="=, but when I'm in the middle of a word I don't want to use =’= (right single quotation mark), but ='= (apostrophe), which provides better results with spellchecking. So here is a function that checks whether the character before the previous is a word character. + +#+begin_src emacs-lisp + (defun oni-in-word-p () + "Check whether the character just typed was part of a word." + (save-excursion + (backward-char) + (looking-back (rx word) (1- (point))))) +#+end_src + +Now that I can check whether or not I'm typing a word, I can tell =electric-quote-mode= not to use =’= in that case. + +#+begin_src emacs-lisp + (with-eval-after-load 'electric + (add-hook 'electric-quote-inhibit-functions #'oni-in-word-p)) +#+end_src + +So now that that's settled, I should be writing ='= in words like “shouldn't'' and =’= otherwise. And spellchecking should work just fine. diff --git a/emacs/.config/shepherd/init.d/emacs.org b/emacs/.config/shepherd/init.d/emacs.org deleted file mode 100644 index 11bef69..0000000 --- a/emacs/.config/shepherd/init.d/emacs.org +++ /dev/null @@ -1,16 +0,0 @@ -Define a service for shepherd that starts up Emacs. - -#+begin_src scheme -(define emacs - (make - #:provides '(emacs) - #:docstring "Run `emacs --daemon'" - #:start (make-forkexec-constructor - '("emacs" "--fg-daemon") - #:log-file (string-append (getenv "HOME") "/.logs/emacs.log")) - #:stop (make-kill-destructor))) - -(register-services emacs) - -(start emacs) -#+end_src diff --git a/emacs/.config/shepherd/init.d/emacs.scm.org b/emacs/.config/shepherd/init.d/emacs.scm.org new file mode 100644 index 0000000..11bef69 --- /dev/null +++ b/emacs/.config/shepherd/init.d/emacs.scm.org @@ -0,0 +1,16 @@ +Define a service for shepherd that starts up Emacs. + +#+begin_src scheme +(define emacs + (make + #:provides '(emacs) + #:docstring "Run `emacs --daemon'" + #:start (make-forkexec-constructor + '("emacs" "--fg-daemon") + #:log-file (string-append (getenv "HOME") "/.logs/emacs.log")) + #:stop (make-kill-destructor))) + +(register-services emacs) + +(start emacs) +#+end_src diff --git a/mbsync/.config/cron/mbsync.guile.org b/mbsync/.config/cron/mbsync.guile.org new file mode 100644 index 0000000..1ca7508 --- /dev/null +++ b/mbsync/.config/cron/mbsync.guile.org @@ -0,0 +1,5 @@ +Run mbsync every single minute to synchronize my email messages. + +#+begin_src scheme + (job '(next-minute) "mbsync --all --quiet --verbose") +#+end_src diff --git a/mcron/.config/shepherd/init.d/mcron.scm.org b/mcron/.config/shepherd/init.d/mcron.scm.org new file mode 100644 index 0000000..2598a25 --- /dev/null +++ b/mcron/.config/shepherd/init.d/mcron.scm.org @@ -0,0 +1,17 @@ +Mcron is a guile-based cron service. Define a service for it and start it up! + +#+begin_src scheme + (define mcron + (make + #:provides '(mcron) + #:docstring "Run `mcron'" + #:start (make-forkexec-constructor + '("mcron") + #:log-file (string-append (getenv "HOME") "/.logs/mcron.log")) + #:stop (make-kill-destructor) + #:respawn? #t)) + + (register-services mcron) + + (start mcron) +#+end_src diff --git a/shepherd/.config/shepherd/init.org b/shepherd/.config/shepherd/init.org deleted file mode 100644 index 05c9d6e..0000000 --- a/shepherd/.config/shepherd/init.org +++ /dev/null @@ -1,13 +0,0 @@ -[[info:shepherd][The Shepherd manual]] suggests that you use a single =init.scm=, but as is pointed out by this article about [[https://guix.gnu.org/en/blog/2020/gnu-shepherd-user-services/][GNU Shepherd user services]] it might be better to have the services in separate files so you can restart them individually if you make any changes to them. So I just put a loading script into =init.scm= that goes through the =init.d= directory and loads each service defined in there. - -#+begin_src scheme -(use-modules (shepherd service) - ((ice-9 ftw) #:select (scandir))) - -(for-each - (λ (file) (load (string-append "init.d/" file))) - (scandir (string-append (dirname (current-filename)) "/init.d") - (λ (file) (string-suffix? ".scm" file)))) - -(action 'shepherd 'daemonize) -#+end_src diff --git a/shepherd/.config/shepherd/init.scm.org b/shepherd/.config/shepherd/init.scm.org new file mode 100644 index 0000000..05c9d6e --- /dev/null +++ b/shepherd/.config/shepherd/init.scm.org @@ -0,0 +1,13 @@ +[[info:shepherd][The Shepherd manual]] suggests that you use a single =init.scm=, but as is pointed out by this article about [[https://guix.gnu.org/en/blog/2020/gnu-shepherd-user-services/][GNU Shepherd user services]] it might be better to have the services in separate files so you can restart them individually if you make any changes to them. So I just put a loading script into =init.scm= that goes through the =init.d= directory and loads each service defined in there. + +#+begin_src scheme +(use-modules (shepherd service) + ((ice-9 ftw) #:select (scandir))) + +(for-each + (λ (file) (load (string-append "init.d/" file))) + (scandir (string-append (dirname (current-filename)) "/init.d") + (λ (file) (string-suffix? ".scm" file)))) + +(action 'shepherd 'daemonize) +#+end_src -- cgit v1.2.3-54-g00ecf