diff options
author | shoshin <shoshin@cicadas.surf> | 2022-05-21 13:19:47 -0500 |
---|---|---|
committer | shoshin <shoshin@cicadas.surf> | 2022-05-21 13:19:47 -0500 |
commit | bb67745117cd1cf3b1ec0944fc367f47167cd071 (patch) | |
tree | 0a55e8175c8779af864f8f81e87d1ae9a148729f |
Add: first pass of literate config
-rw-r--r-- | moo.org | 98 | ||||
-rw-r--r-- | shoshin-config.el | 55 | ||||
-rw-r--r-- | shoshin-config.org | 343 |
3 files changed, 496 insertions, 0 deletions
@@ -0,0 +1,98 @@ +#+PROPERTY: header-args:emacs-lisp :lexical t + +Setting the property for the whole buffer to have lexical binding in emacs-lisp +source blocks. Lexical binding will hold when evaluating any source block where +no other ~:lexical~ header arg is present. + +* Moo +:PROPERTIES: +:header-args:emacs-lisp+: :noweb-ref moo +:END: + +noweb-ref will make all blocks under this heading expand with =<<moo>>= + +#+begin_src emacs-lisp + (+ x 3) +#+end_src + +* Goo +:PROPERTIES: +:header-args:emacs-lisp+: :noweb yes +:header-args:emacs-lisp+: :var foo="bar" +:END: + +turn noweb on so we interpret the =<<moo>>= syntax as code to expand +setting a var ~foo~ to the string "bar" to be used later. + +** Poop + +properties go down into the subtrees + +#+begin_src emacs-lisp + (let ((x 1)) + <<moo>>) +#+end_src + +#+RESULTS: +: 4 + +*** Floppy +:PROPERTIES: +:header-args:emacs-lisp+: :noweb no +:END: + +apparently continuing with the "+" pattern takes the no over the yes above +this will fail to expand moo. + +#+begin_src emacs-lisp + (let ((x 1)) + <<moo>>) +#+end_src + +#+RESULTS: +: let: Symbol’s value as variable is void: <<moo>> + +** Gah + +Define a function with a free variable x. + +#+begin_src emacs-lisp :results none + (defun getx () + x) +#+end_src + +Because ~x~ is lexically bound in this block, ~getx~ will error +since ~x~ is not a dynamic variable and isn't bound with indefinite scope. + +#+begin_src emacs-lisp + (let ((x 1)) ; ‘x’ is lexically bound. + (getx)) +#+end_src + +#+RESULTS: +: Symbol’s value as variable is void: x + +we can flip lexical binding off for the evaluation of this block and +the free variable ~x~ is bound when ~getx~ is evaluated. + +#+begin_src emacs-lisp :lexical no + (let ((x 2)) ; ‘x’ is dynamically bound + (getx)) +#+end_src + +#+RESULTS: +: 2 + +** Bah +:PROPERTIES: +:header-args:emacs-lisp+: :var foo="baz" +:END: + +overriding the variable in this subtree + +#+begin_src emacs-lisp + foo +#+end_src + +#+RESULTS: +: baz diff --git a/shoshin-config.el b/shoshin-config.el new file mode 100644 index 0000000..982f66f --- /dev/null +++ b/shoshin-config.el @@ -0,0 +1,55 @@ +;;; shoshimacs.el --- Beginner's Mind Config -*- lexical-binding:t -*- + +;;; Package Management +(add-to-list 'load-path (expand-file-name "xah-fly-keys/" user-emacs-directory)) +(require 'xah-fly-keys) +(xah-fly-keys-set-layout "qwerty") +(xah-fly-keys t) + +;;; Completion +(package-install 'consult) + +(package-install 'corfu) + +(package-install 'marginalia) + +(package-install 'embark) + +(package-install 'vertico) + +;;; Editing +(electric-pair-mode) + +(package-install 'markdown-mode) + +;;; Programming +(package-install 'json-mode) + +(package-install 'devdocs) + +;;; Projects + + +;;; External Services +(package-install 'plz) + +(package-install 'srht) +(setq srht-username "shoshin") + +;;; User Interface +(scroll-bar-mode nil) +(fringe-mode '(8 . 0)) +(tab-bar-mode t) +(display-battery-mode t) + +(package-install 'darkroom) + +(set-frame-font "Victor Mono" t t t) + +(global-hl-line-mode t) + +(setq my-chosen-themes + '(cyberpunk-theme dracula-theme)) +(mapc #'package-install my-chosen-themes) + +(package-install 'windresize) diff --git a/shoshin-config.org b/shoshin-config.org new file mode 100644 index 0000000..5aaa2fc --- /dev/null +++ b/shoshin-config.org @@ -0,0 +1,343 @@ +#+STARTUP: overview +#+PROPERTY: header-args:emacs-lisp :lexical t + +* ANUSTART + +To welcome in Emacs 28 I intend to re-aquaint myself with the application +and its ecosystem. I've been perusing the packages available through the +default ELPA and non-gnu ELPA repos and trying to put together the various +things that I've grown accustomed to. + +However, with a beginner's mind, I've been trying to avoid going down the +same old idiosyncratic paths. Courting a bit of discomfort in order to learn +what newcomers might experience coming to Emacs in this current version. + +** Overview + +This document is a journal, manual, and a program at once. I'm no expert at +writing a document like this. If you happen to be reading it, the journal +nature may be confusing. Over time, the journal will be incorporated into the +bits that are a manual, solidified knowledge gained through the experience. + +The program bits will be tangled into [[file:shoshin-config.el]]. As a program, it +requires a certain structure from top to bottom. Here, the snippets may be +scattered around. I'll attempt to have a system to keep them organized, but +this is all an experiment. + +The following code block is the "table of contents" that determines what +is tangled into the resulting elisp file: + +#+begin_src emacs-lisp :tangle yes :noweb yes + ;;; shoshimacs.el --- Beginner's Mind Config -*- lexical-binding:t -*- + + ;;; Package Management + <<package-management>> + + ;;; Completion + <<completion>> + + ;;; Editing + <<editing>> + + ;;; Programming + <<programming>> + + ;;; Projects + <<projects>> + + ;;; External Services + <<external-services>> + + ;;; User Interface + <<user-interface>> +#+end_src + +* Package Management +:PROPERTIES: +:header-args:emacs-lisp+: :noweb-ref package-management :noweb-sep "\n\n" :results silent +:END: + +i've been using ~straight.el~ in my "main" config, primarily because i liked +having the package repos cloned onto my machine for easy contribution +possibilities. additionally, at the time it was a nice easy way to install +a package without the custom package installation snippets borrowed from +the web ages ago. + +however, these days ~package.el~ offers the [[help:package-install][package-install]] command (since +Emacs 25 apparently) which "does the right thing" if used in one's init +file. so for the time being, packages will have their installation and +configuration happen in place in this literate config file. + +** Packages not in repos (flykeys) + +muscle memory has bound me to xah-fly-keys, and so i've decided to just +manually install it by cloning the repo and adding it to the load + +#+begin_src shell :var dir=(expand-file-name "xah-fly-keys" user-emacs-directory) :tangle no + git clone https://github.com/xahlee/xah-fly-keys $dir +#+end_src + +#+begin_src emacs-lisp + (add-to-list 'load-path (expand-file-name "xah-fly-keys/" user-emacs-directory)) + (require 'xah-fly-keys) + (xah-fly-keys-set-layout "qwerty") + (xah-fly-keys t) +#+end_src + +Set this up first, so other keymap changes will add onto flykeys (hopefully). + +* Completion +:PROPERTIES: +:header-args:emacs-lisp: :noweb-ref completion :noweb-sep "\n\n" :results silent +:END: + +Completion is a huge part of my experience using Emacs. I have been on +an evolving journey of from the basic type of terminal tab completion +to spaceship level UI implemented as almost a sub-application in Emacs. + +This configuration is aiming at using a new crop of completion enhancements +that tie into Emacs's native completion API. This is a more modular approach +that allows a sort of composition of extensions to completion behavior and +its appearance in the user interface. + +** [[info:consult#Top][consult]] - Consulting [[info:elisp#Minibuffer Completion][completing-read]] + +consult offers enhanced completion similar to ivy and helm, but with the +built in completing read functionality of the minibuffer. + +#+begin_src emacs-lisp + (package-install 'consult) +#+end_src + +main entry point would be ~consult-buffer~. however, there are many consult +commands that can enhance any completing read function. ~consult-themes~ for +example. + +i had a bit of a mess with it at first, because i'd implemented my own +solution to a quirk of theme loading. enabling themes is additive, +and can cause unexpected results. so i added [[info:elisp#Advising Functions][advice]] +to ~load-theme~ to automatically disable the old one before enabling +the new. it seems like consult does this as well as switching themes +/as you narrow your selection/. + +*** consult keybindings + +** corfu + +#+begin_src emacs-lisp + (package-install 'corfu) +#+end_src + +** marginalia + +#+begin_src emacs-lisp + (package-install 'marginalia) +#+end_src + +** embark + +#+begin_src emacs-lisp + (package-install 'embark) +#+end_src + +** vertico + +#+begin_src emacs-lisp + (package-install 'vertico) +#+end_src + +* Editing +:PROPERTIES: +:header-args:emacs-lisp: :noweb-ref editing :noweb-sep "\n\n" :results silent +:END: +** [[info:emacs#Matching][electric pair mode]] +I've been using smartparens -> (bookmark-jump "smartparens package") in my +main config. electric pair mode does some of what smartparens does out of +the box. what i'm missing is the generalized ~sp-hybrid-slurp~ or +whatever it was called. but using the built in is good for now. further +config might get what i want with vanilla built ins. + +#+begin_src emacs-lisp + (electric-pair-mode) +#+end_src + +** markdown mode +#+begin_src emacs-lisp + (package-install 'markdown-mode) +#+end_src + +* Programming +:PROPERTIES: +:header-args:emacs-lisp: :noweb-ref programming :noweb-sep "\n\n" :results silent +:END: +** Languages +*** Javascript + +#+begin_src emacs-lisp + (package-install 'json-mode) +#+end_src + +** Dev Docs +#+begin_src emacs-lisp + (package-install 'devdocs) +#+end_src +* Projects +:PROPERTIES: +:header-args:emacs-lisp: :noweb-ref projects :noweb-sep "\n\n" :results silent +:END: + +** project.el +* External Services +:PROPERTIES: +:header-args:emacs-lisp: :noweb-ref external-services :noweb-sep "\n\n" :results silent +:END: + +Packages that enable communication via HTTP or connect with external APIs or other +resources outside of Emacs and/or the local machine. + +** plz - http library + +this is an http library that intends to solve some of the "pain points" of url.el. +i ran into some of them trying to download and install the Victor Mono font used +by my configuration. the downside of ~plz~ is that it is dependent on ~curl~, rather +than being pure elisp. however, this is a non-issue for me, especially since my +use case had devolved into using ~make-process~ to call ~wget~ and then implement +a "callback" with a process sentinel. kinda neat, but maybe too much. + +#+begin_src emacs-lisp + (package-install 'plz) +#+end_src + +the sourcehut package in this config also depends on ~plz~ + +** sourcehut +there's a new package in GNU ELPA for some basic interaction with the sr.ht http api. +i'm interested to try it out since i still pay for the account, plus the forge is +free software and could be self-hosted if it comes to it. + +it also depends on ~plz~ which is another new package providing a nicer API for +HTTP requests I was going + +#+begin_src emacs-lisp + (package-install 'srht) + (setq srht-username "shoshin") +#+end_src + +an API token is stored in my ~.authinfo~ file. + +* UI +:PROPERTIES: +:header-args:emacs-lisp: :noweb-ref user-interface :noweb-sep "\n\n" :results silent +:END: +** basic Emacs UI tweaks + +#+begin_src emacs-lisp + (scroll-bar-mode nil) + (fringe-mode '(8 . 0)) + (tab-bar-mode t) + (display-battery-mode t) +#+end_src + +** [[file:elpa/darkroom-0.3/darkroom.el::;;; Commentary:][darkroom]] - distraction free writing + +the notes suggest using ~darkroom-tentative-mode~ which auto switches +depending on the window layout currently in use. + +#+begin_src emacs-lisp + (package-install 'darkroom) +#+end_src + +*** comp warnings +#+begin_example +Warning (comp): darkroom.el:337:13: Warning: Use keywords rather than deprecated positional arguments to `define-minor-mode' Disable showing Disable logging +Warning (comp): darkroom.el:338:9: Warning: reference to free variable ‘darkroom-tentative-mode’ Disable showing Disable logging +Warning (comp): darkroom.el:361:13: Warning: Use keywords rather than deprecated positional arguments to `define-minor-mode' Disable showing Disable logging +Warning (comp): darkroom.el:365:10: Warning: function ‘darkroom-tentative-mode’ defined multiple times in this file Disable showing Disable logging +#+end_example + +** Fonts +For code, I've grown fond of Victor Mono. + +#+begin_src emacs-lisp + (set-frame-font "Victor Mono" t t t) +#+end_src + +*** COMMENT Attempt to install the font via Emacs, url.el and ~make-process~ + +in the end, this "works" but isn't very useful. the font cache needs to be updated +before Emacs runs for the font to register anyway. This will instead be implemented +as a shell script that can be run as a pre-req before initializing emacs. + +however, i did learn a bit about [[info:elisp#Sentinels][Sentinels]] they are kinda neat. + +#+begin_src emacs-lisp + ;; this actually doesn't work right, because the process unzipping starts + ;; before the file is completely written i think. + (url-retrieve "https://rubjo.github.io/victor-mono/VictorMonoAll.zip" + #'victor-mono-download-callback) + + (make-process :name "getting victor mono" + :buffer "*Download Victor Mono*" + :command '("wget" "--output-document=/home/shoshin/.fonts/VictorMonoAll.zip" + "https://rubjo.github.io/victor-mono/VictorMonoAll.zip") + :sentinel #'victor-mono-download-callback) + + (defun victor-mono-download-callback (process event) + (if (string-equal "finished\n" event) + (let ((default-directory "~/.fonts/VictorMono")) + (unless (file-directory-p default-directory) + (make-directory default-directory)) + (make-process :name "unzipping victor mono" + :buffer "*Unzip Victor Mono*" + :command `("unzip" ,(expand-file-name "~/.fonts/VictorMonoAll.zip")) + :sentinel #'victor-mono-sentinel)))) + + (defun victor-mono-sentinel (process event) + (print event) + (if (string-equal "finished\n" event) + (progn (message "works!") + (make-process :name "run fc-cache" :command '("fc-cache"))))) +#+end_src + +** Highlights +*** [[help:global-hl-line-mode][global-hl-mode]] +i enjoy having the current line highighted as a visual cue. + +#+begin_src emacs-lisp + (global-hl-line-mode t) +#+end_src + +can be toggled with <leader> l 2 + +*** COMMENT lin-global-mode +Make `hl-line-mode' more suitable for selection UIs + +add other hooks to ~lin-mode-hooks~ + +#+begin_src emacs-lisp + (setq my-lin-mode-hooks + '()) +#+end_src + +#+begin_src emacs-lisp + (package-install 'lin) + (require 'lin) + (setq lin-face 'lin-blue) + (mapc (lambda (e) (cl-pushnew e lin-mode-hooks)) my-lin-mode-hooks) + (lin-global-mode) +#+end_src +** Themes + +#+begin_src emacs-lisp + (setq my-chosen-themes + '(cyberpunk-theme dracula-theme)) + (mapc #'package-install my-chosen-themes) +#+end_src + +** windresize + +#+begin_src emacs-lisp + (package-install 'windresize) +#+end_src + + |