changeset 678: |
2b7d5a8d63ac |
parent 677: |
585f14458a65 |
child 679: |
12287fab15d0 |
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Wed, 25 Sep 2024 21:39:39 -0400 |
files: |
emacs/default.el emacs/lib/graph.el lisp/lib/rdb/obj.lisp lisp/lib/rdb/tests.lisp lisp/std/alien.lisp |
description: |
alien octets fix, workin with org-graph-db |
1.1--- a/emacs/default.el Tue Sep 24 22:19:05 2024 -0400
1.2+++ b/emacs/default.el Wed Sep 25 21:39:39 2024 -0400
1.3@@ -99,7 +99,7 @@
1.4 use-package-always-ensure t
1.5 use-package-expand-minimally t)
1.6 (add-packages
1.7- eglot-x ;; LSP extensions
1.8+ ;; eglot-x ;; LSP extensions
1.9 org-web-tools ;; web parsing
1.10 citeproc ;; citations
1.11 htmlize ;; html export
1.12@@ -338,15 +338,15 @@
1.13 scsh-program "scsh")
1.14
1.15 ;;; Eglot
1.16-(with-eval-after-load 'eglot
1.17- (unless (package-installed-p 'eglot-x)
1.18- (package-vc-install '(eglot-x :url "https://vc.compiler.company/packy/eglot-x")))
1.19- (require 'eglot-x)
1.20- (with-eval-after-load 'eglot-x
1.21- (add-to-list 'eglot-server-programs
1.22- '((rust-ts-mode rust-mode) .
1.23- ("rust-analyzer" :initializationOptions (:check (:command "clippy")))))
1.24- (eglot-x-setup)))
1.25+;; (with-eval-after-load 'eglot
1.26+;; (unless (package-installed-p 'eglot-x)
1.27+;; (package-vc-install '(eglot-x :url "https://vc.compiler.company/packy/eglot-x")))
1.28+;; (require 'eglot-x)
1.29+;; (with-eval-after-load 'eglot-x
1.30+;; (add-to-list 'eglot-server-programs
1.31+;; '((rust-ts-mode rust-mode) .
1.32+;; ("rust-analyzer" :initializationOptions (:check (:command "clippy")))))
1.33+;; (eglot-x-setup)))
1.34
1.35 ;;; Rust
1.36 (add-hook 'rust-mode-hook 'eglot-ensure)
2.1--- a/emacs/lib/graph.el Tue Sep 24 22:19:05 2024 -0400
2.2+++ b/emacs/lib/graph.el Wed Sep 25 21:39:39 2024 -0400
2.3@@ -211,8 +211,8 @@
2.4 (when update
2.5 (mapc (lambda (e)
2.6 (puthash
2.7- (org-graph-edge-in e)
2.8- e
2.9+ (org-graph-edge-in e)
2.10+ e
2.11 (org-graph-edges (if (eql t update) org-graph update))))
2.12 edges))
2.13 edges))
2.14@@ -301,7 +301,7 @@
2.15 "The interface to use for finding target links. If you provide a custom
2.16 function it will be called with the `point` at the location the link
2.17 should be inserted. The only other requirement is that it should call
2.18-the function `org-graph-edge--insert-link' with a marker to the target
2.19+the function `org-graph-edge-insert-link-marker' with a marker to the target
2.20 link. AKA the place you want the edge.
2.21
2.22 `org-graph-edge-get-location' internally uses `org-refile-get-location'.")
2.23@@ -333,9 +333,7 @@
2.24
2.25 (defun org-graph-edge-get-location ()
2.26 "Default for function `org-graph-edge-search-function' that reuses the `org-refile' machinery."
2.27- (let ((target (org-refile-get-location "Node")))
2.28- (org-graph-edge--insert-link (set-marker (make-marker) (car (cdddr target))
2.29- (get-file-buffer (car (cdr target)))))))
2.30+ (org-refile-get-location "Node"))
2.31
2.32 (cl-defmacro with-org-graph-edge-drawer ((start &optional create) &rest body)
2.33 "START is a symbol which is bound to the start of the edge drawer."
2.34@@ -343,9 +341,10 @@
2.35 `(save-excursion
2.36 (org-with-wide-buffer
2.37 (let ((org-log-into-drawer (org-graph-edge-drawer)))
2.38- (org-graph-edge--org-narrow-to-here)
2.39+ (org-graph-narrow-to-node)
2.40 (let ((,start (org-log-beginning ,create)))
2.41- (when (re-search-forward (rx bol ?: "END" ?: eol) nil t)
2.42+ (when (or (re-search-forward (rx bol ?: "END" ?: eol) nil t)
2.43+ (re-search-backward (rx bol ?: "END" ?: eol) nil t))
2.44 (goto-char ,start)
2.45 ,@body))))))
2.46
2.47@@ -403,7 +402,7 @@
2.48 ((stringp p) p)
2.49 (t org-graph-edge-drawer))))
2.50
2.51-(defun org-graph-edge--org-narrow-to-here ()
2.52+(defun org-graph-narrow-to-node ()
2.53 "Narrow to current heading, excluding subheadings."
2.54 (org-narrow-to-subtree)
2.55 (save-excursion
2.56@@ -411,9 +410,9 @@
2.57 (narrow-to-region (point-min) (point))))
2.58
2.59 ;; delete related functions
2.60-(defun org-graph-find-edges (id)
2.61+(defun org-graph-find-links (id)
2.62 "Return link elements for ID."
2.63- (org-graph-edge--org-narrow-to-here)
2.64+ (org-graph-narrow-to-node)
2.65 (let ((links
2.66 (org-element-map (org-element-parse-buffer) 'link
2.67 (lambda (link)
2.68@@ -447,7 +446,7 @@
2.69 (insert (format "%s %s " (org-graph-edge-prefix)
2.70 (org-graph-edge-arrow arrow)))
2.71 (org-insert-link nil link desc)
2.72- (insert (org-graph-edge-link-postfix))
2.73+ (insert (org-graph-edge-link-postfix))
2.74 (newline))
2.75
2.76 (defun org-graph-edge-insert-related (link desc)
2.77@@ -457,18 +456,20 @@
2.78 (org-indent-region beg (point))))
2.79
2.80 (defun org-graph-edge-insert-backlink (link desc)
2.81- "Insert edge to LINK with DESC.
2.82-Where the edge is placed is determined by the variable `org-graph-edge-drawer'."
2.83+ "Insert a backlink edge."
2.84 (with-org-graph-edge-drawer (beg t)
2.85 (let ((description (org-graph-edge-default-description-formatter link desc)))
2.86 (org-graph-edge--insert link description 'backlink)
2.87 (org-indent-region beg (point)))))
2.88
2.89 (defun org-graph-edge-insert-link (link desc)
2.90- "insert a forward link edge."
2.91+ "insert a forward link edge. When BACKLINK is non-nil also create a
2.92+backlink at the node specified in LINK."
2.93+ (interactive)
2.94 (with-org-graph-edge-drawer (beg t)
2.95- (org-graph-edge--insert link desc 'link)
2.96- (org-indent-region beg (point))))
2.97+ (let ((description (org-graph-edge-default-description-formatter link desc)))
2.98+ (org-graph-edge--insert link desc 'link)
2.99+ (org-indent-region beg (point)))))
2.100
2.101 (defun org-graph-edge-links-action (marker hooks)
2.102 "Go to MARKER, run HOOKS and store a link."
2.103@@ -488,35 +489,38 @@
2.104 (description (org-graph-edge-default-description-formatter link-ref pre-desc)))
2.105 (cons link-ref description)))
2.106
2.107-(defun org-graph-edge--insert-link (target &optional no-forward)
2.108+(defun org-graph-edge-insert-link-marker (target &optional no-forward no-backward)
2.109 "Insert link to marker TARGET and create an edge.
2.110 Only create edges in files in `org-mode' or a derived mode, otherwise just
2.111 act like a normal link.
2.112
2.113-If NO-FORWARD is non-nil skip creating the forward link. Currently
2.114-only used when converting a link."
2.115+If NO-FORWARD is non-nil skip creating the forward link. If NO-BACKWARD
2.116+is non-nil skip creating the backlink."
2.117 (let* ((source (point-marker))
2.118 (source-link (org-graph-edge-links-action source 'org-graph-edge-pre-link-hook))
2.119 (target-link (org-graph-edge-links-action target 'org-graph-edge-pre-backlink-hook))
2.120 (source-formatted-link (org-graph-edge-link-builder source-link))
2.121 (target-formatted-link (org-graph-edge-link-builder target-link)))
2.122- (with-current-buffer (marker-buffer target)
2.123- (save-excursion
2.124- (save-restriction
2.125- (widen) ;; buffer could be narrowed
2.126- (goto-char (marker-position target))
2.127- (when (derived-mode-p 'org-mode)
2.128- (org-graph-edge-insert-backlink (car source-formatted-link) (cdr source-formatted-link))))))
2.129+ (unless no-backward
2.130+ (with-current-buffer (marker-buffer target)
2.131+ (save-excursion
2.132+ (save-restriction
2.133+ (widen) ;; buffer could be narrowed
2.134+ (goto-char (marker-position target))
2.135+ (when (derived-mode-p 'org-mode)
2.136+ (org-graph-edge-insert-backlink (car source-formatted-link) (cdr source-formatted-link)))))))
2.137 (unless no-forward
2.138 (with-current-buffer (marker-buffer source)
2.139 (save-excursion
2.140 (goto-char (marker-position source))
2.141+ (print target-formatted-link)
2.142 (org-graph-edge-insert-link (car target-formatted-link) (cdr target-formatted-link)))))))
2.143
2.144 ;;;###autoload
2.145-(defun org-graph-edge-convert-link (arg)
2.146+(defun org-graph-edge-convert-link (&optional arg)
2.147 "Convert a normal `org-mode' link at `point' to a graph link, ARG prefix.
2.148-When called interactively with a `C-u' prefix argument do not modify existing link."
2.149+When called interactively with a `C-u' prefix argument do not modify
2.150+existing link."
2.151 (interactive "P")
2.152 (let ((from-m (point-marker))
2.153 (target (save-window-excursion
2.154@@ -524,7 +528,7 @@
2.155 (save-excursion
2.156 (org-open-at-point)
2.157 (point-marker))))))
2.158- (org-graph-edge--insert-link target arg)
2.159+ (org-graph-edge-insert-link-marker target arg)
2.160 (goto-char (marker-position from-m)))
2.161 (when (not arg)
2.162 (let ((begin (org-element-property :begin (org-element-context)))
2.163@@ -533,9 +537,9 @@
2.164
2.165 ;;;###autoload
2.166 (defun org-graph-edge-delete ()
2.167- "Delete the link at point, and the corresponding reverse link.
2.168-If no reverse link exists, just delete link at point.
2.169-This works from either side, and deletes both sides of a link."
2.170+ "Delete the link at point, and the corresponding backlink.
2.171+If no backlink exists, just delete link at point. This works from
2.172+either side, and deletes both sides of a link."
2.173 (interactive)
2.174 (save-window-excursion
2.175 (with-current-buffer (current-buffer)
2.176@@ -552,19 +556,31 @@
2.177
2.178 ;;;###autoload
2.179 (defun org-graph-edge-insert ()
2.180- "Insert an edge from `org-stored-links')"
2.181+ "Insert an edge from `org-stored-links'."
2.182 (interactive)
2.183 (if org-stored-links
2.184 (progn
2.185 (org-link-open (pop org-stored-links))
2.186- (org-graph-edge--insert-link (set-marker (make-marker) (point))))
2.187+ (org-graph-edge-insert-link-marker (set-marker (make-marker) (point))))
2.188 (org-graph-edge-link)))
2.189
2.190 ;;;###autoload
2.191-(defun org-graph-edge-link ()
2.192- "Insert a link edge and add a backlink edge to the target heading."
2.193+(defun org-graph-edge-link (&optional no-backlink)
2.194+ "Insert a link edge and add a backlink edge to the target heading. With
2.195+'C-u' don't create a backlink to the target."
2.196 (interactive)
2.197- (org-graph-edge-search-function))
2.198+ (let ((target (org-graph-edge-search-function)))
2.199+ (org-graph-edge-insert-link-marker (set-marker (make-marker) (car (cdddr target))
2.200+ (get-file-buffer (car (cdr target))))
2.201+ nil no-backlink)))
2.202+
2.203+(defun org-graph-edge-backlink ()
2.204+ "Insert a backlink edge to the target heading from the current one."
2.205+ (interactive)
2.206+ (let ((target (org-graph-edge-search-function)))
2.207+ (org-graph-edge-insert-link-marker (set-marker (make-marker) (car (cdddr target))
2.208+ (get-file-buffer (car (cdr target))))
2.209+ t)))
2.210
2.211 (defun org-dblock-write:links ()
2.212 "Generate a 'links' block for the designated node.")
3.1--- a/lisp/lib/rdb/obj.lisp Tue Sep 24 22:19:05 2024 -0400
3.2+++ b/lisp/lib/rdb/obj.lisp Wed Sep 25 21:39:39 2024 -0400
3.3@@ -471,6 +471,11 @@
3.4 (make-rdb-stats (get-stats-raw (rdb-opts-sap (rdb-opts self)) htype)))
3.5
3.6 (defmethod create-iter ((self rdb) &optional cf (opts (rocksdb-readoptions-create)))
3.7+ (when cf
3.8+ (setf cf (etypecase cf
3.9+ (rdb-cf (rdb-cf-sap cf))
3.10+ (string (rdb-cf-sap (find-cf cf self)))
3.11+ (alien cf))))
3.12 (unless-null-db () self
3.13 (make-instance 'rdb-iter :sap (if cf
3.14 (create-cf-iter-raw db cf opts)
4.1--- a/lisp/lib/rdb/tests.lisp Tue Sep 24 22:19:05 2024 -0400
4.2+++ b/lisp/lib/rdb/tests.lisp Wed Sep 25 21:39:39 2024 -0400
4.3@@ -119,7 +119,6 @@
4.4 (get-prop tmp "rocksdb.levelstats")
4.5 (print-stats tmp))))
4.6
4.7-
4.8 (deftest metadata ()
4.9 "Test metadata types: CF -> LEVEL -> SST-FILE."
4.10 (with-temp-db (tmp () :open t :destroy t)
5.1--- a/lisp/std/alien.lisp Tue Sep 24 22:19:05 2024 -0400
5.2+++ b/lisp/std/alien.lisp Wed Sep 25 21:39:39 2024 -0400
5.3@@ -101,7 +101,7 @@
5.4
5.5 (defun clone-octets-to-alien (lispa alien)
5.6 (declare (optimize (speed 3))
5.7- (simple-vector lispa))
5.8+ ((vector (unsigned-byte 8)) lispa))
5.9 ;; (setf aliena (cast aliena (array (unsigned 8))))
5.10 (loop for i from 0 below (length lispa)
5.11 do (setf (deref alien i)
5.12@@ -118,7 +118,7 @@
5.13
5.14 (defun clone-octets-from-alien (aliena lispa &optional len)
5.15 (declare (optimize (speed 3))
5.16- (simple-vector lispa))
5.17+ (vector lispa))
5.18 (unless len (setf len (length lispa)))
5.19 (loop for i from 0 below len
5.20 do (setf (aref lispa i)