changelog shortlog graph tags branches files raw help

Mercurial > core / changeset: init graph.el

changeset 623: a304c9713a51
parent 622: c0062541039f
child 624: 97dd03beda03
author: Richard Westhaver <ellis@rwest.io>
date: Sun, 25 Aug 2024 00:14:17 -0400
files: emacs/default.el emacs/init.el emacs/keys.el emacs/lib/c2.el emacs/lib/graph.el emacs/lib/scrum.el emacs/lib/ulang.el lisp/bin/skel.lisp lisp/ffi/rocksdb/rocksdb.asd lisp/ffi/rocksdb/tests.lisp lisp/lib/cli/clap/cli.lisp lisp/lib/cli/clap/pkg.lisp
description: init graph.el
     1.1--- a/emacs/default.el	Fri Aug 23 19:40:56 2024 -0400
     1.2+++ b/emacs/default.el	Sun Aug 25 00:14:17 2024 -0400
     1.3@@ -69,7 +69,7 @@
     1.4 (defvar user-stash-directory (expand-file-name ".stash" user-home-directory))
     1.5 (defvar user-store-directory (expand-file-name ".store" user-home-directory))
     1.6 (defvar user-mail-directory (expand-file-name "mail" user-home-directory))
     1.7-
     1.8+(defvar user-org-stash-directory (expand-file-name "org" user-stash-directory))
     1.9 (defvar default-theme 'leuven-dark)
    1.10 (defvar company-source-directory (join-paths user-home-directory "comp"))
    1.11 (defvar company-org-directory (join-paths company-source-directory "org"))
    1.12@@ -80,9 +80,10 @@
    1.13 (defvar company-cdn-url "https://cdn.compiler.company")
    1.14 
    1.15 ;;; Theme
    1.16-(defun load-default-theme () (interactive) (load-theme default-theme))
    1.17-
    1.18-;; (add-hook 'after-init-hook #'load-default-theme)
    1.19+(defun load-default-theme (&optional theme)
    1.20+  (interactive)
    1.21+  (when theme (setq default-theme theme))
    1.22+  (load-theme default-theme))
    1.23 
    1.24 ;;; Packages
    1.25 (with-eval-after-load 'package
    1.26@@ -94,7 +95,7 @@
    1.27    use-package-always-ensure t
    1.28    use-package-expand-minimally t)
    1.29   (add-packages
    1.30-   ;; eglot-x ;; LSP extensions
    1.31+   eglot-x ;; LSP extensions
    1.32    org-web-tools ;; web parsing
    1.33    citeproc ;; citations
    1.34    htmlize ;; html export
    1.35@@ -138,7 +139,10 @@
    1.36 
    1.37 (use-package corfu
    1.38   :ensure t
    1.39-  :config (global-corfu-mode)
    1.40+  :config
    1.41+  (global-corfu-mode)
    1.42+  (corfu-popupinfo-mode)
    1.43+  (corfu-echo-mode)
    1.44   (dolist (c (list (cons "SPC" " ")
    1.45                  (cons "." ".")
    1.46                  (cons "," ",")
    1.47@@ -151,7 +155,31 @@
    1.48                                          (corfu-insert)
    1.49                                          (insert ,(cdr c)))))
    1.50   (add-to-list 'completion-at-point-functions #'cape-dabbrev t)
    1.51-  (add-to-list 'completion-at-point-functions #'cape-abbrev t))
    1.52+  (add-to-list 'completion-at-point-functions #'cape-abbrev t)
    1.53+  (add-to-list 'completion-at-point-functions #'cape-file)
    1.54+  (defun corfu-move-to-minibuffer ()
    1.55+    (interactive)
    1.56+    (pcase completion-in-region--data
    1.57+      (`(,beg ,end ,table ,pred ,extras)
    1.58+       (let ((completion-extra-properties extras)
    1.59+             completion-cycle-threshold completion-cycling)
    1.60+         (consult-completion-in-region beg end table pred)))))
    1.61+  (keymap-set corfu-map "M-m" #'corfu-move-to-minibuffer)
    1.62+  (add-to-list 'corfu-continue-commands #'corfu-move-to-minibuffer)
    1.63+  (unless (package-installed-p 'corfu-terminal)
    1.64+    (package-vc-install '(corfu-terminal :url "https://codeberg.org/akib/emacs-corfu-terminal.git")))
    1.65+  (unless (display-graphic-p)
    1.66+    (corfu-terminal-mode 1)))
    1.67+
    1.68+(use-package kind-icon
    1.69+  :ensure t
    1.70+  :after corfu
    1.71+  ;:custom
    1.72+  ; (kind-icon-blend-background t)
    1.73+  ; (kind-icon-default-face 'corfu-default) ; only needed with blend-background
    1.74+  :config
    1.75+  (add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter))
    1.76+
    1.77 
    1.78 (use-package vertico
    1.79   :ensure t
    1.80@@ -159,6 +187,13 @@
    1.81   (keymap-set vertico-map "M-q" #'vertico-quick-insert)
    1.82   (keymap-set vertico-map "C-q" #'vertico-quick-exit))
    1.83 
    1.84+(use-package marginalia :ensure t
    1.85+  :config (marginalia-mode))
    1.86+(use-package embark
    1.87+  :ensure t)
    1.88+(use-package embark-consult :ensure t)
    1.89+(use-package consult :ensure t)
    1.90+
    1.91 ;;; Desktop
    1.92 (setopt desktop-dirname (expand-file-name "sessions" user-emacs-directory))
    1.93 
     2.1--- a/emacs/init.el	Fri Aug 23 19:40:56 2024 -0400
     2.2+++ b/emacs/init.el	Sun Aug 25 00:14:17 2024 -0400
     2.3@@ -17,4 +17,4 @@
     2.4 (add-hook 'after-init-hook (if (and (boundp 'user-custom-file) (file-exists-p user-custom-file))
     2.5 	                       (load-file user-custom-file)))
     2.6 
     2.7-
     2.8+(add-hook 'after-init-hook 'load-default-theme)
     3.1--- a/emacs/keys.el	Fri Aug 23 19:40:56 2024 -0400
     3.2+++ b/emacs/keys.el	Sun Aug 25 00:14:17 2024 -0400
     3.3@@ -101,9 +101,9 @@
     3.4   "u" #'compile
     3.5   "a" #'org-agenda
     3.6   "A" #'org-agenda-show-week-all
     3.7-  "<return>" #'eshell
     3.8-  "C-<return>" #'eshell-new
     3.9-  "s-<return>" #'term
    3.10+  "RET" #'eshell
    3.11+  "C-RET" #'eshell-new
    3.12+  "s-RET" #'term
    3.13   "!" #'async-shell-command
    3.14   "i" #'imenu
    3.15   "SPC" toggle-map
    3.16@@ -114,7 +114,7 @@
    3.17   "(" parens-map
    3.18   "M-l" #'duplicate-dwim
    3.19   "d i" #'image-dired
    3.20-  "<tab>" #'outline-cycle
    3.21+  "TAB" #'outline-cycle
    3.22   "<backtab>" #'outline-cycle-buffer
    3.23   "z" #'scratch-buffer
    3.24   "C-z" #'scratch-new
     4.1--- a/emacs/lib/c2.el	Fri Aug 23 19:40:56 2024 -0400
     4.2+++ b/emacs/lib/c2.el	Sun Aug 25 00:14:17 2024 -0400
     4.3@@ -26,7 +26,7 @@
     4.4 (defgroup c2 nil
     4.5   "elisp server")
     4.6 
     4.7-(defcustom c2-dir "~/c2" "c2 directory."
     4.8+(defcustom c2-directory (join-paths user-stash-directory "c2") "c2 directory."
     4.9   :group 'c2)
    4.10 
    4.11 (defcustom c2-after-make-frame-hook nil
     5.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2+++ b/emacs/lib/graph.el	Sun Aug 25 00:14:17 2024 -0400
     5.3@@ -0,0 +1,105 @@
     5.4+;;; graph.el --- Graph-oriented Extensions -*- lexical-binding: t; -*-
     5.5+
     5.6+;; Copyright (C) 2024  The Compiler Company
     5.7+;; Version: "0.2.0"
     5.8+;; Author: Richard Westhaver <richard.westhaver@gmail.com>
     5.9+;; Keywords: docs, maint, outlines, extensions
    5.10+
    5.11+;; This program is free software; you can redistribute it and/or modify
    5.12+;; it under the terms of the GNU General Public License as published by
    5.13+;; the Free Software Foundation, either version 3 of the License, or
    5.14+;; (at your option) any later version.
    5.15+
    5.16+;; This program is distributed in the hope that it will be useful,
    5.17+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.18+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    5.19+;; GNU General Public License for more details.
    5.20+
    5.21+;; You should have received a copy of the GNU General Public License
    5.22+;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
    5.23+
    5.24+;;; Commentary:
    5.25+
    5.26+;;
    5.27+
    5.28+;;; Code:
    5.29+(require 'org)
    5.30+(require 'org-agenda)
    5.31+(require 'default)
    5.32+(require 'ulang)
    5.33+
    5.34+(defgroup graph nil
    5.35+  "CC Graph")
    5.36+
    5.37+(defcustom org-graph-db-directory (join-paths user-org-stash-directory "graph")
    5.38+  "graph database storage directory."
    5.39+  :type 'directory
    5.40+  :group 'graph)
    5.41+
    5.42+(defcustom org-graph-locations (list (join-paths company-org-directory "notes"))
    5.43+  "List of directories to check for nodes."
    5.44+  :type '(list directory)
    5.45+  :group 'graph)
    5.46+
    5.47+(defcustom org-graph-include-agenda-files nil
    5.48+  "When non-nil, include `org-agenda-files' in the graph."
    5.49+  :type 'boolean
    5.50+  :group 'graph)
    5.51+
    5.52+(defcustom org-graph-include-archive nil
    5.53+  "When non-nil, include `org-arhive-location' in the graph."
    5.54+  :type 'boolean
    5.55+  :group 'graph)
    5.56+
    5.57+(defcustom org-graph-include-org-directory nil
    5.58+  "When non-nil, include `org-directory' files in the graph."
    5.59+  :type 'boolean
    5.60+  :group 'graph)
    5.61+
    5.62+(defcustom org-graph-compaction-hook nil
    5.63+  "Hook run when a graph is compacted to `org-graph-db'."
    5.64+  :type 'hook
    5.65+  :group 'graph)
    5.66+
    5.67+(defcustom org-graph-capture-hook nil
    5.68+  "Hook run when a node is added to the graph."
    5.69+  :type 'hook
    5.70+  :group 'graph)
    5.71+
    5.72+(defvar-local org-graph nil
    5.73+  "The currently active graph of org nodes.")
    5.74+
    5.75+(defcustom org-graph-db-init-script (join-paths company-source-directory "infra/scripts/org-db-init.lisp")
    5.76+  "Path to a lisp script responsible for initializing the `org-graph-db-directory'.")
    5.77+
    5.78+(cl-defstruct org-graph-db-handle
    5.79+  (type :rocksdb)
    5.80+  (name "org-graph-db")
    5.81+  get
    5.82+  put
    5.83+  delete
    5.84+  merge
    5.85+  compact
    5.86+  shutdown)
    5.87+
    5.88+(defcustom org-graph-db (make-org-graph-db-handle)
    5.89+  "A handle to the database backend which stores nodes and edges."
    5.90+  :type 'org-graph-db-handle
    5.91+  :group 'graph)
    5.92+
    5.93+(defun org-graph-from-id-locations ()
    5.94+  "Populate the `org-graph' from `org-id-locations', filtering out any
    5.95+entries not under a member of `org-graph-locations'."
    5.96+  (setq-local org-graph (copy-hash-table (org-id-locations-load)))
    5.97+  (maphash
    5.98+   (lambda (k v)
    5.99+     (mapc
   5.100+      (lambda (x)
   5.101+        (unless (string-prefix-p x (file-truename v))
   5.102+          (remhash k org-graph)))
   5.103+      org-graph-locations))
   5.104+   org-graph))
   5.105+
   5.106+(provide 'graph)
   5.107+;; graph.el ends here
   5.108+
     6.1--- a/emacs/lib/scrum.el	Fri Aug 23 19:40:56 2024 -0400
     6.2+++ b/emacs/lib/scrum.el	Sun Aug 25 00:14:17 2024 -0400
     6.3@@ -53,6 +53,10 @@
     6.4 ;;; Code:
     6.5 (require 'ulang)
     6.6 (require 'uml-mode)
     6.7+
     6.8+(defgroup scrum nil
     6.9+  "CC Scrum Framework.")
    6.10+
    6.11 (defvar scrum-properties '("SPRINT" "RELEASE" "TASKID"))
    6.12 
    6.13 (provide 'scrum)
     7.1--- a/emacs/lib/ulang.el	Fri Aug 23 19:40:56 2024 -0400
     7.2+++ b/emacs/lib/ulang.el	Sun Aug 25 00:14:17 2024 -0400
     7.3@@ -21,18 +21,20 @@
     7.4 ;;; Commentary:
     7.5 
     7.6 ;; 
     7.7-;; (setq org-export-global-macros nil)
     7.8+
     7.9 
    7.10 ;;; Code:
    7.11 (require 'org)
    7.12 (require 'ox)
    7.13-(require 'inbox)
    7.14-(require 'publish)
    7.15-(defvar ulang-links-history nil)
    7.16-(defvar ulang-files-history nil)
    7.17+
    7.18+(defgroup ulang nil
    7.19+  "CC Universal Language.")
    7.20+
    7.21+(defvar ulang-link-history nil)
    7.22+(defvar ulang-file-history nil)
    7.23 
    7.24 ;;;###autoload
    7.25-(defun ulang-dblock-insert-links (regexp)
    7.26+(defun dblock-insert-links (regexp)
    7.27   "Create dblock to insert links matching REGEXP."
    7.28   (interactive (list (read-regexp "Insert links matching: " nil ulang-links-history)))
    7.29   (org-create-dblock (list :name "links"
    7.30@@ -40,9 +42,10 @@
    7.31                            :id-only nil))
    7.32   (org-update-dblock))
    7.33 
    7.34-(org-dynamic-block-define "links" 'ulang-dblock-insert-links)
    7.35+(org-dynamic-block-define "links" 'dblock-insert-links)
    7.36 
    7.37 (org-export-translate-to-lang (list '("Table of Contents" "Index")) "ulang")
    7.38+;; (setq org-export-global-macros nil)
    7.39 
    7.40 ;; todo keywords
    7.41 (setq org-stuck-projects '("+PROJECT/-DONE" ("NEXT") nil ""))
    7.42@@ -121,14 +124,20 @@
    7.43   (interactive)
    7.44   (org-map-entries (lambda () (org-custom-id-get (point) 'create))))
    7.45 
    7.46-(defun org-id-add-to-headlines-in-agenda-files ()
    7.47+(defun org-id-add-to-headlines-in-files (&optional files)
    7.48   (interactive)
    7.49   (with-temp-buffer
    7.50-    (dolist (f org-agenda-files)
    7.51+    (dolist (f (or files org-agenda-files))
    7.52       (find-file f)
    7.53       (org-id-add-to-headlines-in-file)
    7.54       (save-buffer))))
    7.55 
    7.56+(defun org-id-add-to-headlines-in-directory (&optional dir)
    7.57+  (interactive)
    7.58+  (let ((dir (or dir org-directory)))
    7.59+    (org-id-add-to-headlines-in-files
    7.60+     (directory-files-recursively dir "[.]org$"))))
    7.61+
    7.62 (message "Initialized ULANG.")
    7.63 
    7.64 (provide 'ulang)
     8.1--- a/lisp/bin/skel.lisp	Fri Aug 23 19:40:56 2024 -0400
     8.2+++ b/lisp/bin/skel.lisp	Sun Aug 25 00:14:17 2024 -0400
     8.3@@ -14,7 +14,7 @@
     8.4 (in-package :bin/skel)
     8.5 (in-readtable :shell)
     8.6 
     8.7-(defopt skc-help (print-help *cli*) *arg*)
     8.8+(defopt skc-help (print-help *cli*))
     8.9 (defopt skc-version (print-version *cli*))
    8.10 (defopt skc-level *log-level*
    8.11         (setq *log-level* (if *arg* (if (stringp *arg*)
    8.12@@ -23,8 +23,10 @@
    8.13                               :info)))
    8.14 
    8.15 ;; TODO 2023-10-13: almost there
    8.16-;; (defopt skc-config
    8.17-;;   (init-user-skelrc (when *arg* (parse-file-opt *arg*))))
    8.18+(defopt skc-config
    8.19+  (load-user-skelrc (or
    8.20+                     *arg*
    8.21+                     *user-skelrc*)))
    8.22 
    8.23 (defcmd skc-edit
    8.24   (let ((file (or (when *args* (pop *args*)) (sk-path *skel-project*))))
    8.25@@ -185,23 +187,25 @@
    8.26 (defcmd skc-make
    8.27   (let ((sk (find-skelfile #P"." :load t)))
    8.28     (sb-ext:enable-debugger)
    8.29-    (print *args*)
    8.30+    (log:debug! "cli args" *args*)
    8.31     ;; (setq *no-exit* t)
    8.32     (if *args*
    8.33         (loop for a in *args*
    8.34               do (debug!
    8.35-                  (when-let ((rule (sk-find-rule a sk)))
    8.36-                    (sk-make sk rule))))
    8.37+                  (if-let ((rule (sk-find-rule a sk)))
    8.38+                    (sk-make sk rule)
    8.39+                    ;;  TODO 2024-08-23: restart condition here
    8.40+                    (skel-simple-error "rule not found: ~A" a))))
    8.41         (debug! (sk-make sk (aref (sk-rules sk) 0))))))
    8.42 
    8.43 (defcmd skc-run
    8.44   (if *args*
    8.45       (mapc (lambda (script)
    8.46-              (debug!
    8.47-               (sk-run
    8.48-                (sk-find-script
    8.49-                 (pathname-name script)
    8.50-                 (find-skelfile #P"." :load t))))) *args*)
    8.51+              (when-let ((script (sk-find-script
    8.52+                                  (pathname-name script)
    8.53+                                  (find-skelfile #P"." :load t))))
    8.54+                (debug! (sk-run script))))
    8.55+            *args*)
    8.56       (required-argument 'name)))
    8.57 
    8.58 (defcmd skc-vc
     9.1--- a/lisp/ffi/rocksdb/rocksdb.asd	Fri Aug 23 19:40:56 2024 -0400
     9.2+++ b/lisp/ffi/rocksdb/rocksdb.asd	Sun Aug 25 00:14:17 2024 -0400
     9.3@@ -18,9 +18,9 @@
     9.4                (:file "db")
     9.5                (:file "metadata")
     9.6                (:file "merge")
     9.7-               (:file "slicetransform")
     9.8                (:file "compaction")
     9.9                (:file "comparator")
    9.10+               (:file "slicetransform")
    9.11                (:file "writebatch")
    9.12                (:file "logger")
    9.13                (:file "stats")
    10.1--- a/lisp/ffi/rocksdb/tests.lisp	Fri Aug 23 19:40:56 2024 -0400
    10.2+++ b/lisp/ffi/rocksdb/tests.lisp	Sun Aug 25 00:14:17 2024 -0400
    10.3@@ -226,8 +226,7 @@
    10.4       ;; ingest sst file
    10.5       (rocksdb-ingest-external-file db (cast flist (* c-string)) 1 iopts errptr)
    10.6       (is (null-alien errptr))
    10.7-      (let ((vres (make-array vlen :element-type 'octet :fill-pointer 0)))
    10.8-        (is (string= (octets-to-string val) (cast (rocksdb-get db ropts k klen (make-alien size-t vlen) errptr) c-string))))
    10.9+      (is (string= (octets-to-string val) (cast (rocksdb-get db ropts k klen (make-alien size-t vlen) errptr) c-string)))
   10.10       
   10.11       ;; rocksdb-sstfilewriter-file-size
   10.12       (rocksdb-sstfilewriter-destroy writer)
   10.13@@ -249,7 +248,6 @@
   10.14          (klen (length key))
   10.15          (vlen (length val))
   10.16          (wopts (rocksdb-writeoptions-create))
   10.17-         (ropts (rocksdb-readoptions-create))
   10.18          (ctx (rocksdb::rocksdb-perfcontext-create))
   10.19          (hist (rocksdb-statistics-histogram-data-create)))
   10.20     (with-alien ((k (* (unsigned 8)) (make-alien (unsigned 8) klen))
   10.21@@ -509,12 +507,14 @@
   10.22          (rocksdb-writebatch-wi-create 0 0)
   10.23          '(alien (* rocksdb-writebatch-wi))))))
   10.24 
   10.25-(deftest slicetransform (:skip t)
   10.26+(deftest slicetransform ()
   10.27   "Test slicetransform functionality."
   10.28   (with-alien ((state (* t))
   10.29                (destructor (* rocksdb-destructor-function) (alien-sap (alien-callable-function 'rocksdb-destructor)))
   10.30-               (transform (* t) (* rocksdb-transform-function))
   10.31+               (transform (* rocksdb-transform-function))
   10.32                (in-domain (* rocksdb-in-domain-function))
   10.33                (in-range (* rocksdb-in-range-function))
   10.34                (name (* rocksdb-name-function) (alien-sap (alien-callable-function 'rocksdb-name))))
   10.35-    (rocksdb-slicetransform-create state destructor transform in-domain in-range name)))
   10.36+    (is (typep
   10.37+         (rocksdb-slicetransform-create state destructor transform in-domain in-range name)
   10.38+         '(alien (* rocksdb-slicetransform))))))
    11.1--- a/lisp/lib/cli/clap/cli.lisp	Fri Aug 23 19:40:56 2024 -0400
    11.2+++ b/lisp/lib/cli/clap/cli.lisp	Sun Aug 25 00:14:17 2024 -0400
    11.3@@ -107,7 +107,7 @@
    11.4   (let ((o (active-opts cli))
    11.5         (a (cli-cmd-args cli))
    11.6         (c (active-cmds cli)))
    11.7-    (log:debug! (cli-cd cli) o a c)))
    11.8+    (log:debug! :pwd (cli-cd cli) :active-opts o :cmd-args a :active-cmds c)))
    11.9 
   11.10 (defmacro with-cli (slots cli &body body)
   11.11   "Like with-slots with some extra bindings.
    12.1--- a/lisp/lib/cli/clap/pkg.lisp	Fri Aug 23 19:40:56 2024 -0400
    12.2+++ b/lisp/lib/cli/clap/pkg.lisp	Sun Aug 25 00:14:17 2024 -0400
    12.3@@ -56,4 +56,5 @@
    12.4 (pkg:defpkg :cli/clap
    12.5   (:nicknames :clap)
    12.6   (:use-reexport :cli/clap/obj :cli/clap/vars :cli/clap/proto
    12.7-   :cli/clap/simple :cli/clap/util :cli/clap/macs :cli/clap/ast))
    12.8+   :cli/clap/simple :cli/clap/util :cli/clap/macs :cli/clap/ast
    12.9+   :cli/clap/vars))