changelog shortlog graph tags branches changeset file revisions annotate raw help

Mercurial > org > meta / babel.org

revision 9: 995df3d48af0
parent 8: 06698c6708de
child 10: 65bf0057ca35
     1.1--- a/babel.org	Wed Sep 04 16:59:32 2024 -0400
     1.2+++ b/babel.org	Sat Sep 07 22:38:02 2024 -0400
     1.3@@ -2,7 +2,7 @@
     1.4 #+author: Richard Westhaver
     1.5 #+description: Core Library of Babel
     1.6 #+setupfile: ../clean.theme
     1.7-#+property: header-args :exports both :eval no
     1.8+#+property: header-args :exports both :eval no-export
     1.9 Welcome to the CC [[https://www.gnu.org/software/emacs/manual/html_node/org/Library-of-Babel.html][Library of Babel]]. This file contains a collection of
    1.10 code blocks which may be used by authors throughout our public
    1.11 documentation.
    1.12@@ -113,24 +113,30 @@
    1.13 systemctl list-units --state=running | grep -v systemd | awk '{print $1}' | grep service
    1.14 #+end_src
    1.15 
    1.16-* wc-dir-lines                                                           :fs:
    1.17+* wc-lines                                                               :fs:
    1.18 :PROPERTIES:
    1.19 :ID:       70008815-9634-48ca-b672-b8dcf2a44074
    1.20 :END:
    1.21-#+name: wc-dir-lines
    1.22-#+begin_src shell :var dir="."
    1.23-cd $dir && cat * | wc -l
    1.24+#+name: wc-lines
    1.25+#+begin_src shell :dir "."
    1.26+cat * | wc -l
    1.27 #+end_src
    1.28 
    1.29-* wc-dir-words                                                           :fs:
    1.30+#+RESULTS: wc-lines
    1.31+: 1574
    1.32+
    1.33+* wc-words                                                               :fs:
    1.34 :PROPERTIES:
    1.35 :ID:       be755790-f367-4654-87e5-cd2927bfef45
    1.36 :END:
    1.37-#+name: wc-dir-words
    1.38-#+begin_src shell :var dir="."
    1.39-cd $dir && cat * | wc -w
    1.40+#+name: wc-words
    1.41+#+begin_src shell :dir "."
    1.42+cat * | wc -w
    1.43 #+end_src
    1.44 
    1.45+#+RESULTS: wc-words
    1.46+: 5944
    1.47+
    1.48 * buffer-name                                                          :util:
    1.49 :PROPERTIES:
    1.50 :ID:       7e9f492e-224a-4cf5-b36d-828ccedc630a
    1.51@@ -139,38 +145,45 @@
    1.52 #+begin_src emacs-lisp
    1.53 (buffer-name)
    1.54 #+end_src
    1.55-* tokei-dir-lines                                                        :fs:
    1.56+
    1.57+* lines                                                                  :fs:
    1.58 :PROPERTIES:
    1.59 :ID:       670e9855-f8d2-43eb-86af-3ef7292f90b9
    1.60 :END:
    1.61-#+name: tokei-dir-lines
    1.62-#+begin_src shell :var src="" :results output replace
    1.63-  cd ~/comp/$src
    1.64+#+name: lines
    1.65+#+begin_src shell :dir "." :results table replace
    1.66   input=`tokei -C -o json`
    1.67   echo $input | jq -r '.["Total"] | .code, .comments, .blanks'
    1.68 #+end_src
    1.69 
    1.70-* tokei-dir-langs                                                        :fs:
    1.71+#+RESULTS: lines
    1.72+| 1584 |
    1.73+|    1 |
    1.74+|  127 |
    1.75+
    1.76+* langs                                                                  :fs:
    1.77 :PROPERTIES:
    1.78 :ID:       ff9682f0-bb64-427f-a87d-e0c655f9fdc9
    1.79 :END:
    1.80-#+name: tokei-dir-langs
    1.81-#+begin_src shell :var src="org" :results output replace
    1.82-  cd ~/comp/$src
    1.83+#+name: langs
    1.84+#+begin_src shell :dir "." :results output table replace
    1.85   input=`tokei -C -o json`
    1.86   echo $input | jq -r '.["Total"].children | keys[]'
    1.87 #+end_src
    1.88 
    1.89+#+RESULTS: langs
    1.90+: Org
    1.91+
    1.92 * sum-str-nums                                                         :util:
    1.93 :PROPERTIES:
    1.94 :ID:       d3c4ac69-337f-430b-a4db-760504f099ea
    1.95 :END:
    1.96 #+name: sum-str-nums
    1.97-#+begin_src emacs-lisp :var s=tokei-dir-lines()
    1.98+#+begin_src emacs-lisp :var str=lines()
    1.99   (let ((tot 0))
   1.100     (cl-loop
   1.101      with tot = 0
   1.102-     for i in (split-string s) do
   1.103+     for i in (split-string str) do
   1.104      (setf tot (+ tot (string-to-number i)))
   1.105      finally return tot))
   1.106 #+end_src
   1.107@@ -236,21 +249,193 @@
   1.108 
   1.109 #+end_src
   1.110 
   1.111-* make-files-tbl                                                     :org:fs:
   1.112+* trim                                                                 :util:
   1.113+#+name: trim
   1.114+#+begin_src bash :var str=""
   1.115+  # remove leading whitespace characters
   1.116+  str="${str#"${str%%[![:space:]]*}"}"
   1.117+  # remove trailing whitespace characters
   1.118+  str="${str%"${str##*[![:space:]]}"}"
   1.119+  printf '%s' "$str"
   1.120+#+end_src
   1.121+
   1.122+#+RESULTS: trim
   1.123+: a b c
   1.124+
   1.125+* skel-show
   1.126+#+name: skel-show
   1.127+#+begin_src shell :dir "~/comp/core" :var key=":id" :results replace
   1.128+  echo $(skel show $key)
   1.129+#+end_src
   1.130+
   1.131+#+RESULTS: skel-show
   1.132+: 15bc-b763-ec92-1cf5
   1.133+
   1.134+#+RESULTS:
   1.135+: (core lisp rust emacs c)
   1.136+* project-root                                                      :project:
   1.137+#+name: project-root
   1.138+#+begin_src emacs-lisp :var project=(project-current)
   1.139+  (project-root project)
   1.140+#+end_src
   1.141+
   1.142+#+RESULTS: project-root
   1.143+: ~/comp/org/meta/
   1.144+
   1.145+* project-name                                                      :project:
   1.146+#+name: project
   1.147+#+begin_src emacs-lisp :var project="."
   1.148+  (project-name (project-current nil project))
   1.149+#+end_src
   1.150+
   1.151+#+RESULTS: project
   1.152+: meta
   1.153+
   1.154+* project-vc                                                        :project:
   1.155+#+name: project-vc
   1.156+#+begin_src emacs-lisp :var project=(project-current)
   1.157+  (cadr project)
   1.158+#+end_src
   1.159+
   1.160+#+RESULTS: project-vc
   1.161+: Hg
   1.162+
   1.163+* project-list                                                      :project:
   1.164+#+name: project-list
   1.165+#+begin_src emacs-lisp
   1.166+  project--list
   1.167+#+end_src
   1.168+
   1.169+#+RESULTS: project-list
   1.170+| ~/comp/core/                    |
   1.171+| ~/comp/org/meta/                |
   1.172+| ~/.emacs.d/elpa/corfu-terminal/ |
   1.173+| ~/comp/core                     |
   1.174+| ~/comp/scratch/zig-pg/          |
   1.175+| ~/comp/scratch/wam/             |
   1.176+| ~/comp/scratch/vdeplug4/        |
   1.177+| ~/comp/scratch/tmux/            |
   1.178+| ~/comp/scratch/scryer-prolog/   |
   1.179+| ~/comp/scratch/screamer/        |
   1.180+| ~/comp/scratch/rerun/           |
   1.181+| ~/comp/scratch/r8k/             |
   1.182+| ~/comp/scratch/qemu/            |
   1.183+| ~/comp/scratch/octatrack/       |
   1.184+| ~/comp/scratch/nu_plugin_quic/  |
   1.185+| ~/comp/scratch/mpk/             |
   1.186+| ~/comp/scratch/lemmy/           |
   1.187+| ~/comp/scratch/io-uring/        |
   1.188+| ~/comp/scratch/infodb/          |
   1.189+| ~/comp/scratch/hy/              |
   1.190+| ~/comp/scratch/hg/              |
   1.191+| ~/comp/scratch/hackrf/          |
   1.192+| ~/comp/scratch/gengat/          |
   1.193+| ~/comp/scratch/fin/             |
   1.194+| ~/comp/scratch/egui/            |
   1.195+| ~/comp/scratch/egui-video/      |
   1.196+| ~/comp/scratch/dev/             |
   1.197+| ~/comp/scratch/davfs2/          |
   1.198+| ~/comp/scratch/crust-0/         |
   1.199+| ~/comp/scratch/cepl.examples/   |
   1.200+| ~/comp/scratch/cc-install/      |
   1.201+| ~/comp/scratch/blok/            |
   1.202+| ~/comp/scratch/archiso/         |
   1.203+| ~/comp/scratch/arch-boxes/      |
   1.204+| ~/comp/scratch/                 |
   1.205+| ~/comp/pod/                     |
   1.206+| ~/comp/org/notes/               |
   1.207+| ~/comp/org/docs/                |
   1.208+| ~/comp/org/blog/                |
   1.209+| ~/comp/org/archive/             |
   1.210+| ~/comp/org/                     |
   1.211+| ~/comp/infra/.stash/src/emacs/  |
   1.212+| ~/comp/infra/                   |
   1.213+| ~/comp/home/                    |
   1.214+| ~/comp/etc/                     |
   1.215+| ~/comp/demo/                    |
   1.216+| ~/comp/box/                     |
   1.217+| ~/.emacs.d/elpa/org-glossary/   |
   1.218+| ~/comp/org/plan/                |
   1.219+| ~/.emacs.d/elpa/eglot-x/        |
   1.220+
   1.221+* project-details                                                   :project:
   1.222+#+name: project-details
   1.223+#+begin_src emacs-lisp :var project="."
   1.224+  (let* ((project (project-current nil project))
   1.225+         (name (project-name project))
   1.226+         (root (project-root project))
   1.227+         (vc-type (downcase (symbol-name (cadr project))))
   1.228+         (age (org-sbe hg-log-age ''(dir root)))
   1.229+         (rev (org-sbe hg-rev ''(dir root)))
   1.230+         (num (org-sbe hg-id-num ''(dir root)))
   1.231+         (tags (org-sbe skel-show (key "':tags'") ''(dir root)))
   1.232+         (id (org-sbe skel-show (key "':id'") ''(dir root)))
   1.233+         (version (org-sbe skel-show (key "':version'") ''(dir root)))
   1.234+         (description (org-sbe skel-show (key "':description'") ''(dir root)))
   1.235+         (vc (format ":%s [[https://vc.compiler.company/%s][vc.compiler.company/%s]] :rev %s"
   1.236+                     vc-type name name
   1.237+                     (format "[[https://vc.compiler.company/%s/rev/%s][%s:%s]]" name rev rev num)))
   1.238+         (langs (mapcar (lambda (x) (downcase (format "%s" x))) (flatten (read (org-sbe langs ''(dir root))))))
   1.239+         (line-counts (flatten (read (org-sbe lines ''(dir root)))))
   1.240+         (line-sum (cl-reduce '+ line-counts))
   1.241+         (lines (format "%s :λ %s :# %s :_ %s" line-sum (pop line-counts) (pop line-counts) (pop line-counts))))
   1.242+    `(hline
   1.243+      (name ,name)
   1.244+      (version ,version)
   1.245+      (description ,description)
   1.246+      (skel-id ,id)
   1.247+      (root ,root)
   1.248+      (vc ,vc)
   1.249+      (tags ,tags)
   1.250+      (updated ,age)
   1.251+      (langs ,langs)
   1.252+      (lines ,lines)
   1.253+      hline))
   1.254+#+end_src
   1.255+
   1.256+#+RESULTS: project-details
   1.257+|-------------+---------------------------------------------------|
   1.258+| name        | meta                                              |
   1.259+| version     | 0.1.0                                             |
   1.260+| description | The Compiler Company Core                         |
   1.261+| skel-id     | 15bc-b763-ec92-1cf5                               |
   1.262+| root        | ~/comp/org/meta/                                  |
   1.263+| vc          | :hg [[https://vc.compiler.company/meta][vc.compiler.company/meta]] :rev [[https://vc.compiler.company/meta/rev/06698c6708de][06698c6708de:8+]] |
   1.264+| tags        | (core lisp rust emacs c)                          |
   1.265+| updated     | 3 days ago                                        |
   1.266+| langs       | (org)                                             |
   1.267+| lines       | 1768 :λ 1632 :# 3 :_ 133                          |
   1.268+|-------------+---------------------------------------------------|
   1.269+
   1.270+* files                                                                  :fs:
   1.271 :PROPERTIES:
   1.272 :ID:       e2ff9dcf-8340-48b8-a1a6-e0036cbcc495
   1.273 :END:
   1.274-#+name: ls-files
   1.275-#+begin_src sh :results silent :var dir=(expand-file-name "~/comp") name="org"
   1.276-  ls -lh $dir/$name --time-style=long-iso \
   1.277+#+name: format-files
   1.278+#+begin_src python :var tab="" :results table :colnames yes :hlines yes :exports results :eval no-export
   1.279+return tab
   1.280+#+end_src
   1.281+
   1.282+#+name: files
   1.283+#+begin_src sh :results replace table :dir "." :colnames yes :hlines yes :post format-files-tbl(*this*)
   1.284+  ls -lh $PWD --time-style=long-iso \
   1.285     |awk '{if (NR!=1) print $8, $5, $6"-"$7}' \
   1.286     |awk 'BEGIN{print "file size updated"}{print $0}'
   1.287 #+end_src
   1.288 
   1.289-#+name: make-files-tbl
   1.290-#+begin_src python :var tab=ls-files() :results table :colnames yes :hlines yes :exports results :eval no-export
   1.291-return tab
   1.292-#+end_src
   1.293+#+RESULTS: files
   1.294+| file          | size |          updated |
   1.295+|---------------+------+------------------|
   1.296+| babel.org     | 24K  | 2024-09-07-19:45 |
   1.297+| business.org  | 803  | 2024-08-19-21:19 |
   1.298+| glossary.org  | 1.2K | 2024-09-06-15:35 |
   1.299+| mindset.org   | 119  | 2024-08-15-21:20 |
   1.300+| pitch.org     | 1.6K | 2024-08-11-17:16 |
   1.301+| readme.org    | 1.1K | 2024-08-27-21:13 |
   1.302+| style.org     | 3.2K | 2024-08-21-16:18 |
   1.303+| tech.org      | 3.6K | 2024-08-21-18:16 |
   1.304+| ulang.org     | 12K  | 2024-09-06-16:12 |
   1.305+| workflows.org | 7.5K | 2024-09-03-16:59 |
   1.306 
   1.307 * env-table                                                              :os:
   1.308 :PROPERTIES:
   1.309@@ -297,11 +482,11 @@
   1.310 		 (format "Org v%s" (org-version))))
   1.311 #+end_src
   1.312 
   1.313-* vc-log                                                                 :vc:
   1.314+* vc-buffer-log                                                          :vc:
   1.315 :PROPERTIES:
   1.316 :ID:       b2d9f6f0-2ac7-4e45-abbe-b32cc2d0f7aa
   1.317 :END:
   1.318-#+name: vc-log
   1.319+#+name: vc-buffer-log
   1.320 #+header: :var limit=-1
   1.321 #+header: :var buf=(buffer-name (current-buffer))
   1.322 #+begin_src emacs-lisp
   1.323@@ -331,35 +516,86 @@
   1.324 :ID:       8119cf43-f2e7-4829-939c-fc4e8531ae6c
   1.325 :END:
   1.326 #+name: hg-rev
   1.327-#+begin_src sh :var src="org"
   1.328-cd ~/comp/$src && hg log -l 1 --template '{node|short}'
   1.329+#+begin_src sh :dir "."
   1.330+hg log -l 1 --template '{node|short}'
   1.331 #+end_src
   1.332 
   1.333 #+RESULTS: hg-rev
   1.334-: 2b6f731f3684
   1.335-
   1.336+: 06698c6708de
   1.337 * hg-id-num                                                              :vc:
   1.338 :PROPERTIES:
   1.339 :ID:       9602faee-5522-445b-a568-be603e20a978
   1.340 :END:
   1.341 #+name: hg-id-num
   1.342-#+begin_src shell :var src="org"
   1.343-cd ~/comp/$src && hg id -n
   1.344+#+begin_src shell :dir "."
   1.345+hg id -n
   1.346 #+end_src
   1.347 
   1.348 #+RESULTS: hg-id-num
   1.349-: 36+
   1.350+: 8+
   1.351 
   1.352 * hg-log-age                                                             :vc:
   1.353 :PROPERTIES:
   1.354 :ID:       8492f4fb-51a6-4221-8705-a15eb5a50ed4
   1.355 :END:
   1.356 #+name: hg-log-age
   1.357-#+begin_src shell :var src="."
   1.358-  cd ~/comp/$src && hg log -l1 --template "{date|age}"
   1.359+#+begin_src shell :dir "."
   1.360+  hg log -l1 --template "{date|age}"
   1.361 #+end_src
   1.362 
   1.363 #+RESULTS: hg-log-age
   1.364+: 3 days ago
   1.365+
   1.366+* hg-churn                                                               :vc:
   1.367+#+name: hg-churn
   1.368+#+begin_src shell :dir "~/comp/core" :results output
   1.369+  hg churn -f "%Y-%m" -s
   1.370+#+end_src
   1.371+
   1.372+#+RESULTS: hg-churn
   1.373+#+begin_example
   1.374+2023-10  36394 ************************************
   1.375+2023-11  12777 ************
   1.376+2023-12  61624 *************************************************************
   1.377+2024-01   4923 ****
   1.378+2024-02   5701 *****
   1.379+2024-03  27292 ***************************
   1.380+2024-04  23322 ***********************
   1.381+2024-05  24141 ***********************
   1.382+2024-06  17608 *****************
   1.383+2024-07   9757 *********
   1.384+2024-08  16177 ****************
   1.385+2024-09   2430 **
   1.386+#+end_example
   1.387+
   1.388+* hg-status
   1.389+#+name: hg-status
   1.390+#+begin_src shell :dir "."
   1.391+hg status
   1.392+#+end_src
   1.393+
   1.394+#+RESULTS: hg-status
   1.395+| M | babel.org    |
   1.396+| M | glossary.org |
   1.397+| M | ulang.org    |
   1.398+
   1.399+* homer
   1.400+#+begin_src shell
   1.401+homer
   1.402+#+end_src
   1.403+
   1.404+#+RESULTS:
   1.405+| :PUSH | /home/ellis/.stash/scripts/wg-gen-keys.sh                   |
   1.406+| :PUSH | /home/ellis/.stash/scripts/upgrade.sh                       |
   1.407+| :PUSH | /home/ellis/.stash/scripts/sc.sh                            |
   1.408+| :PUSH | /home/ellis/.stash/scripts/rec.sh                           |
   1.409+| :PUSH | /home/ellis/.stash/scripts/port-scan.sh                     |
   1.410+| :PUSH | /home/ellis/.stash/scripts/podman-machine-default-update.sh |
   1.411+| :PUSH | /home/ellis/.stash/scripts/pacman-pkgsearch.sh              |
   1.412+| :PUSH | /home/ellis/.stash/scripts/nfs-export.sh                    |
   1.413+| :PUSH | /home/ellis/.stash/scripts/new-mail.sh                      |
   1.414+| :PUSH | /home/ellis/.stash/scripts/genfstab.sh                      |
   1.415+| :PUSH | /home/ellis/.stash/scripts/gen-libera-cert.sh               |
   1.416 
   1.417 * sh-ob-tangle                                                          :org:
   1.418 :PROPERTIES: