changelog shortlog graph tags branches changeset files file revisions raw help

Mercurial > core / annotate emacs/lib/graph.el

changeset 698: 96958d3eb5b0
parent: 2b7d5a8d63ac
author: Richard Westhaver <ellis@rwest.io>
date: Fri, 04 Oct 2024 22:04:59 -0400
permissions: -rw-r--r--
description: fixes
623
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
1
 ;;; graph.el --- Graph-oriented Extensions -*- lexical-binding: t; -*-
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
2
 
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
3
 ;; Copyright (C) 2024  The Compiler Company
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
4
 ;; Version: "0.2.0"
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
5
 ;; Author: Richard Westhaver <richard.westhaver@gmail.com>
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
6
 ;; Keywords: docs, maint, outlines, extensions
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
7
 
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
8
 ;; This program is free software; you can redistribute it and/or modify
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
9
 ;; it under the terms of the GNU General Public License as published by
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
10
 ;; the Free Software Foundation, either version 3 of the License, or
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
11
 ;; (at your option) any later version.
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
12
 
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
13
 ;; This program is distributed in the hope that it will be useful,
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
14
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
15
 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
16
 ;; GNU General Public License for more details.
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
17
 
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
18
 ;; You should have received a copy of the GNU General Public License
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
19
 ;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
20
 
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
21
 ;;; Commentary:
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
22
 
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
23
 ;;
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
24
 
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
25
 ;;; Code:
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
26
 (require 'org)
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
27
 (require 'org-agenda)
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
28
 (require 'default)
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
29
 (require 'ulang)
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
30
 
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
31
 (defgroup graph nil
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
32
   "CC Graph")
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
33
 
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
34
 (defcustom org-graph-db-directory (join-paths user-org-stash-directory "graph")
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
35
   "graph database storage directory."
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
36
   :type 'directory
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
37
   :group 'graph)
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
38
 
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
39
 (defcustom org-graph-locations (list (join-paths company-org-directory "notes/"))
623
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
40
   "List of directories to check for nodes."
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
41
   :type '(list directory)
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
42
   :group 'graph)
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
43
 
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
44
 (defcustom org-graph-include-agenda-files nil
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
45
   "When non-nil, include `org-agenda-files' in the graph."
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
46
   :type 'boolean
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
47
   :group 'graph)
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
48
 
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
49
 (defcustom org-graph-include-archive nil
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
50
   "When non-nil, include `org-arhive-location' in the graph."
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
51
   :type 'boolean
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
52
   :group 'graph)
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
53
 
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
54
 (defcustom org-graph-include-org-directory nil
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
55
   "When non-nil, include `org-directory' files in the graph."
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
56
   :type 'boolean
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
57
   :group 'graph)
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
58
 
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
59
 (defcustom org-graph-compaction-hook nil
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
60
   "Hook run when a graph is compacted to `org-graph-db'."
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
61
   :type 'hook
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
62
   :group 'graph)
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
63
 
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
64
 (defcustom org-graph-capture-hook nil
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
65
   "Hook run when a node is added to the graph."
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
66
   :type 'hook
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
67
   :group 'graph)
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
68
 
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
69
 (defcustom org-graph-db-init-script (join-paths company-source-directory "infra/scripts/org-db-init.lisp")
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
70
   "Path to a lisp script responsible for initializing the `org-graph-db-directory'.")
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
71
 
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
72
 (cl-defstruct org-graph-db-handle
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
73
   (type :rocksdb)
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
74
   (name "org-graph-db")
656
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
75
   init
623
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
76
   get
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
77
   put
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
78
   delete
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
79
   merge
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
80
   compact
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
81
   shutdown)
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
82
 
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
83
 (defcustom org-graph-db (make-org-graph-db-handle)
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
84
   "A handle to the database backend which stores nodes and edges."
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
85
   :type 'org-graph-db-handle
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
86
   :group 'graph)
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
87
 
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
88
 (defun org-graph-from-id-locations (&optional edges local)
623
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
89
   "Populate the `org-graph' from `org-id-locations', filtering out any
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
90
 entries not under a member of `org-graph-locations'. When EDGES is
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
91
 non-nil visit each node and collect all edges found."
666
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
92
   (interactive "P")
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
93
   (save-excursion
666
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
94
     (let* ((node-ids (copy-hash-table (org-id-locations-load))) ;; don't overwrite `org-id-locations'
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
95
            (graph (make-org-graph :nodes node-ids)))
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
96
       (maphash
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
97
        (lambda (k v)
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
98
          (if-let ((ok (cl-loop for l in org-graph-locations
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
99
                                when (string-prefix-p l (file-truename v))
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
100
                                return t)))
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
101
              (let ((pos (cdr (org-id-find-id-in-file k v))))
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
102
                (message "%s %s" k v)
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
103
                (org-with-file-buffer v
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
104
                  (goto-char pos)
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
105
                  (org-graph-node-at-point graph)
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
106
                  (when edges (org-graph-edges-at-point graph))))
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
107
            (remhash k (org-graph-nodes graph))))
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
108
        (org-graph-nodes graph))
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
109
       (if local
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
110
           (setq-local org-graph graph)
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
111
         (setq org-graph graph)))))
623
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
112
 
656
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
113
 (defun org-graph-files ()
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
114
   (org-list-files org-graph-locations org-agenda-extensions))
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
115
 
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
116
 (cl-defstruct org-graph
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
117
   ;; TODO 2024-09-17: use integers instead of string
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
118
   (nodes (make-hash-table :test 'equal))
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
119
   (edges (make-hash-table :test 'equal)))
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
120
 
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
121
 (defvar org-graph (make-org-graph)
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
122
   "The Emacs-native org-graph. Should be assigned to an `org-graph' instance.")
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
123
 
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
124
 (cl-defstruct org-graph-node id name file point)
666
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
125
 (cl-defstruct org-graph-edge (type 'link) in properties timestamp point out)
656
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
126
 
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
127
 (defun org-graph--file-hash (file)
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
128
   "Compute the hash of FILE."
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
129
   (with-temp-buffer
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
130
     (set-buffer-multibyte nil)
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
131
     (insert-file-contents-literally file)
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
132
     (secure-hash 'md5 (current-buffer))))
638
6c0e4a44c082 dblocks
Richard Westhaver <ellis@rwest.io>
parents: 623
diff changeset
133
 
656
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
134
 (defun org-graph-node-at-point (&optional update)
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
135
   "Return the `org-graph-node' at point. When UPDATE is non-nil insert or
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
136
 update the node into the org-graph object specified or when 't' use the
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
137
 currently active org-graph."
656
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
138
   (let* ((file (buffer-file-name))
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
139
          (node (make-org-graph-node :point (point) :file file)))
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
140
     (if (derived-mode-p 'org-mode)
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
141
         (progn
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
142
           (if (org-before-first-heading-p)
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
143
               (setf (org-graph-node-name node) (org-get-title)
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
144
                     ;; use the filename, create a hash as id
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
145
                     (org-graph-node-id node) (org-graph--file-hash file))
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
146
             (setf (org-graph-node-id node) (org-id-get)
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
147
                   (org-graph-node-name node) (elt (org-heading-components) 4))))
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
148
       (setf (org-graph-node-id node) (org-graph--file-hash file)
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
149
             (org-graph-node-name node) (file-name-nondirectory file)))
656
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
150
     (when update
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
151
       (puthash (org-graph-node-id node) node (org-graph-nodes (if (eql t update) org-graph update))))
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
152
     node))
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
153
 
666
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
154
 ;; TODO 2024-09-22: properties
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
155
 (defun org-graph-collect-edge ()
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
156
   "Collect the edge at point which should be a line created with `org-graph-edge--insert'."
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
157
   (org-with-point-at (beginning-of-line)
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
158
     (when (org-at-timestamp-p 'lax)
666
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
159
       (let ((ep (point))
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
160
             (ts (match-string-no-properties 0))
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
161
             (end (match-end 0)))
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
162
         (goto-char (1+ end))
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
163
         ;; next 2 chars are the arrow
666
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
164
         (let ((arrow (org-graph-edge-arrow* (buffer-substring-no-properties (point) (+ 2 (point))))))
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
165
           (goto-char (+ (point) 4))
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
166
           (make-org-graph-edge :in (org-id-get)
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
167
                                :type arrow
666
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
168
                                :point ep
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
169
                                :timestamp (org-parse-time-string ts t) 
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
170
                                :out (string-trim (org--link-at-point) "id:")))))))
638
6c0e4a44c082 dblocks
Richard Westhaver <ellis@rwest.io>
parents: 623
diff changeset
171
 
666
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
172
 (defun org-graph-map-edges (function)
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
173
   "Eval FUNCTION once for each edge in node at point with point at start of the edge."
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
174
   (with-org-graph-edge-drawer (end)
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
175
     (re-search-backward (rx bol ?: (literal (org-graph-edge-drawer)) ?: eol) nil t)
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
176
     (goto-char (1+ (match-end 0)))
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
177
     (cl-loop while (> (point-max) end (point))
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
178
              collect (funcall function)
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
179
              do (next-line))))
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
180
 
667
bb8aa1eda12b graph, css vars, corfu-terminal fix
Richard Westhaver <ellis@rwest.io>
parents: 666
diff changeset
181
 ;; TODO 2024-09-23: 
bb8aa1eda12b graph, css vars, corfu-terminal fix
Richard Westhaver <ellis@rwest.io>
parents: 666
diff changeset
182
 (defun org-link-info (link)
bb8aa1eda12b graph, css vars, corfu-terminal fix
Richard Westhaver <ellis@rwest.io>
parents: 666
diff changeset
183
   (let ((path (org-element-property :path link))
bb8aa1eda12b graph, css vars, corfu-terminal fix
Richard Westhaver <ellis@rwest.io>
parents: 666
diff changeset
184
         (type (org-element-property :type link))
bb8aa1eda12b graph, css vars, corfu-terminal fix
Richard Westhaver <ellis@rwest.io>
parents: 666
diff changeset
185
         (desc (substring-no-properties (nth 2 link))))
bb8aa1eda12b graph, css vars, corfu-terminal fix
Richard Westhaver <ellis@rwest.io>
parents: 666
diff changeset
186
     (list type path desc)))
bb8aa1eda12b graph, css vars, corfu-terminal fix
Richard Westhaver <ellis@rwest.io>
parents: 666
diff changeset
187
 
bb8aa1eda12b graph, css vars, corfu-terminal fix
Richard Westhaver <ellis@rwest.io>
parents: 666
diff changeset
188
 ;; TODO 2024-09-22: 
bb8aa1eda12b graph, css vars, corfu-terminal fix
Richard Westhaver <ellis@rwest.io>
parents: 666
diff changeset
189
 (defun org-graph-infer-edges ()
bb8aa1eda12b graph, css vars, corfu-terminal fix
Richard Westhaver <ellis@rwest.io>
parents: 666
diff changeset
190
   "Infer edges from the contents of the node at point. The result of this
bb8aa1eda12b graph, css vars, corfu-terminal fix
Richard Westhaver <ellis@rwest.io>
parents: 666
diff changeset
191
 function is a list of org-graph-edge objects."
bb8aa1eda12b graph, css vars, corfu-terminal fix
Richard Westhaver <ellis@rwest.io>
parents: 666
diff changeset
192
   ;; collect links
bb8aa1eda12b graph, css vars, corfu-terminal fix
Richard Westhaver <ellis@rwest.io>
parents: 666
diff changeset
193
   (with-org-graph-edge-drawer (beg)
bb8aa1eda12b graph, css vars, corfu-terminal fix
Richard Westhaver <ellis@rwest.io>
parents: 666
diff changeset
194
     (org-element-map (org-element-parse-buffer) 'link
bb8aa1eda12b graph, css vars, corfu-terminal fix
Richard Westhaver <ellis@rwest.io>
parents: 666
diff changeset
195
       (lambda (link)
bb8aa1eda12b graph, css vars, corfu-terminal fix
Richard Westhaver <ellis@rwest.io>
parents: 666
diff changeset
196
         (print link)
bb8aa1eda12b graph, css vars, corfu-terminal fix
Richard Westhaver <ellis@rwest.io>
parents: 666
diff changeset
197
         ;; (org-graph-edge-link-builder (funcall 'org-element-create link))
bb8aa1eda12b graph, css vars, corfu-terminal fix
Richard Westhaver <ellis@rwest.io>
parents: 666
diff changeset
198
         ))))
bb8aa1eda12b graph, css vars, corfu-terminal fix
Richard Westhaver <ellis@rwest.io>
parents: 666
diff changeset
199
 
666
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
200
 (defun org-graph-reduce-edges (function)
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
201
   "Same as `cl-reduce' where SEQ is the list of edges at point. FUNCTION
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
202
 takes two `org-graph-edge' objects as input."
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
203
   (let ((edges (org-graph-map-edges 'org-graph-collect-edge)))
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
204
     (cl-reduce function edges)))
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
205
 
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
206
 (defun org-graph-collect-edges-at-point (&optional update)
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
207
   "Collect the contents of the EDGES drawer from node at point. When UPDATE
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
208
 is non-nil insert or update the node into the org-graph object specified
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
209
 or when 't' use the currently active org-graph."
666
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
210
   (let ((edges (org-graph-map-edges 'org-graph-collect-edge)))
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
211
     (when update
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
212
       (mapc (lambda (e)
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
213
               (puthash 
678
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
214
                (org-graph-edge-in e)
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
215
                e
666
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
216
                (org-graph-edges (if (eql t update) org-graph update))))
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
217
             edges))
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
218
     edges))
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
219
 
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
220
 (defun org-graph-edge-equal (a b)
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
221
   "Return non-nil if A and B are 'equal' org-graph-edge objects."
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
222
   (equal (org-graph-edge-out a) (org-graph-edge-out b)))
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
223
 
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
224
 (defun org-graph-edge-remove-duplicates ()
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
225
   "Remove duplicate edge entries from node at point."
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
226
   (org-graph-reduce-edges 
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
227
    (lambda (a b) 
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
228
      (when (org-graph-edge-equal a b)
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
229
        (let ((tsa (org-graph-edge-timestamp a))
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
230
              (tsb (org-graph-edge-timestamp b)))
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
231
          (goto-char (org-graph-edge-point (if (org-time> tsa tsb) b a)))
f15e0f021a64 more elisp
Richard Westhaver <ellis@rwest.io>
parents: 665
diff changeset
232
          (delete-line))))))
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
233
 
656
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
234
 (defun org-graph-edges-at-point (&optional update)
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
235
   "Return a list of `org-graph-edge' instances associated with the node at
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
236
 point. When UPDATE is non-nil insert or update the edges into the
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
237
 currently active org-graph."
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
238
   (interactive)
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
239
     (when (derived-mode-p 'org-mode)
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
240
       (org-graph-collect-edges-at-point update)))
656
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
241
 
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
242
 (defun org-graph-buffer-update (&optional buffer)
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
243
   "Map over an org buffer adding all nodes to the active org-graph."
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
244
   (interactive)
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
245
   (save-excursion
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
246
     (with-current-buffer (or buffer (current-buffer))
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
247
       ;; capture file node
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
248
       (goto-char (point-min))
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
249
       (org-graph-node-at-point t)
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
250
       (when (derived-mode-p 'org-mode)
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
251
         (org-map-entries (lambda () (org-graph-node-at-point t)))))))
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
252
 
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
253
 ;;; Edges
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
254
 ;; See https://github.com/toshism/org-super-links/blob/develop/org-super-links.el
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
255
 (declare-function org-make-link-description-function "ext:org-mode")
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
256
 
655
65102f74d1ae some optimizations, may have muddied the waters with cli-opt a bit though.. tbd
Richard Westhaver <ellis@rwest.io>
parents: 652
diff changeset
257
 (defvar org-graph-edge-drawer "EDGES"
652
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
258
   "Controls how/where to insert edges. If nil edges will just be inserted
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
259
 under the heading.")
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
260
 
655
65102f74d1ae some optimizations, may have muddied the waters with cli-opt a bit though.. tbd
Richard Westhaver <ellis@rwest.io>
parents: 652
diff changeset
261
 ;; TODO 2024-09-16: edge properties
652
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
262
 (defvar org-graph-edge-prefix 'org-graph-edge-prefix-timestamp
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
263
   "Prefix to insert before the edge.
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
264
 This can be a string, nil, or a function that takes no arguments and
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
265
 returns a string.
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
266
 
652
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
267
 Default is the function `org-graph-edge-prefix-timestamp'
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
268
 which returns an inactive timestamp formatted according to the variable
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
269
 `org-time-stamp-formats'.")
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
270
 
655
65102f74d1ae some optimizations, may have muddied the waters with cli-opt a bit though.. tbd
Richard Westhaver <ellis@rwest.io>
parents: 652
diff changeset
271
 ;;  TODO 2024-09-16: do we need this? what sort of information for a
65102f74d1ae some optimizations, may have muddied the waters with cli-opt a bit though.. tbd
Richard Westhaver <ellis@rwest.io>
parents: 652
diff changeset
272
 ;;  given edge would go in the postfix? this may be better suited as a
65102f74d1ae some optimizations, may have muddied the waters with cli-opt a bit though.. tbd
Richard Westhaver <ellis@rwest.io>
parents: 652
diff changeset
273
 ;;  per-edge value rather than global - maybe use for comments.
652
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
274
 (defvar org-graph-edge-postfix nil
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
275
   "Postfix to insert after the edge.
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
276
 This can be a string, nil, or a function that takes no arguments and
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
277
 returns a string")
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
278
 
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
279
 (defvar org-graph-edge-link-prefix nil
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
280
   "Prefix to insert before the link.
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
281
 This can be a string, nil, or a function that takes no arguments and
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
282
 returns a string")
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
283
 
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
284
 (defvar org-graph-edge-link-postfix nil
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
285
   "Postfix to insert after the link.
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
286
 This can be a string, nil, or a function that takes no arguments and
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
287
 returns a string")
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
288
 
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
289
 (defvar org-graph-edge-default-description-formatter org-make-link-description-function
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
290
   "What to use if no description is provided.
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
291
 This can be a string, nil or a function that accepts two arguments
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
292
 LINK and DESC and returns a string.
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
293
 
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
294
 nil will return the default desciption or the link.
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
295
 string will be used only as a default fall back if set.
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
296
 function will be called for every link.
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
297
 
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
298
 Default is the variable `org-make-link-desciption-function'.")
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
299
 
652
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
300
 (defvar org-graph-edge-search-function 'org-graph-edge-get-location
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
301
   "The interface to use for finding target links. If you provide a custom
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
302
 function it will be called with the `point` at the location the link
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
303
 should be inserted.  The only other requirement is that it should call
678
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
304
 the function `org-graph-edge-insert-link-marker' with a marker to the target
652
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
305
 link. AKA the place you want the edge.
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
306
 
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
307
 `org-graph-edge-get-location' internally uses `org-refile-get-location'.")
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
308
 
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
309
 (defvar org-graph-edge-pre-link-hook nil
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
310
   "Hook called before storing the link on the link side.
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
311
 This is called with point at the location where it was called.")
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
312
 
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
313
 (defvar org-graph-edge-pre-backlink-hook nil
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
314
   "Hook called before storing the link on the backlink side.
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
315
 This is called with point in the heading of the backlink.")
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
316
 
655
65102f74d1ae some optimizations, may have muddied the waters with cli-opt a bit though.. tbd
Richard Westhaver <ellis@rwest.io>
parents: 652
diff changeset
317
 (defvar org-graph-edge-indicator-alist
65102f74d1ae some optimizations, may have muddied the waters with cli-opt a bit though.. tbd
Richard Westhaver <ellis@rwest.io>
parents: 652
diff changeset
318
   '((link . "->")
65102f74d1ae some optimizations, may have muddied the waters with cli-opt a bit though.. tbd
Richard Westhaver <ellis@rwest.io>
parents: 652
diff changeset
319
     (backlink . "<-")
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
320
     (relation . "--")
655
65102f74d1ae some optimizations, may have muddied the waters with cli-opt a bit though.. tbd
Richard Westhaver <ellis@rwest.io>
parents: 652
diff changeset
321
     (parent . ">>")
65102f74d1ae some optimizations, may have muddied the waters with cli-opt a bit though.. tbd
Richard Westhaver <ellis@rwest.io>
parents: 652
diff changeset
322
     (child . "<<"))
65102f74d1ae some optimizations, may have muddied the waters with cli-opt a bit though.. tbd
Richard Westhaver <ellis@rwest.io>
parents: 652
diff changeset
323
   "An alist of (EDGE-TYPE . INDICATOR) pairs. Each INDICATOR is a string
65102f74d1ae some optimizations, may have muddied the waters with cli-opt a bit though.. tbd
Richard Westhaver <ellis@rwest.io>
parents: 652
diff changeset
324
 which will be printed between the properties and backlink of the
65102f74d1ae some optimizations, may have muddied the waters with cli-opt a bit though.. tbd
Richard Westhaver <ellis@rwest.io>
parents: 652
diff changeset
325
 associated EDGE-TYPE.")
65102f74d1ae some optimizations, may have muddied the waters with cli-opt a bit though.. tbd
Richard Westhaver <ellis@rwest.io>
parents: 652
diff changeset
326
 
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
327
 (defun org-graph-edge-arrow (sym)
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
328
   (cdr (assoc sym org-graph-edge-indicator-alist)))
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
329
 
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
330
 (defun org-graph-edge-arrow* (str)
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
331
   "Reverse lookup of edge arrow symbol."
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
332
   (car (rassoc str org-graph-edge-indicator-alist)))
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
333
 
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
334
 (defun org-graph-edge-get-location ()
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
335
   "Default for function `org-graph-edge-search-function' that reuses the `org-refile' machinery."
678
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
336
   (org-refile-get-location "Node"))
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
337
 
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
338
 (cl-defmacro with-org-graph-edge-drawer ((start &optional create) &rest body)
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
339
   "START is a symbol which is bound to the start of the edge drawer."
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
340
   (declare (indent 1))
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
341
   `(save-excursion
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
342
      (org-with-wide-buffer
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
343
       (let ((org-log-into-drawer (org-graph-edge-drawer)))
678
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
344
         (org-graph-narrow-to-node)
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
345
         (let ((,start (org-log-beginning ,create)))
678
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
346
           (when (or (re-search-forward (rx bol ?: "END" ?: eol) nil t)
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
347
                     (re-search-backward (rx bol ?: "END" ?: eol) nil t))
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
348
             (goto-char ,start)
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
349
             ,@body))))))
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
350
 
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
351
 (defun org-graph-edge-search-function ()
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
352
   "Call the search interface specified in variable `org-graph-edge-search-function'."
652
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
353
   (funcall org-graph-edge-search-function))
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
354
 
652
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
355
 (defun org-graph-edge-prefix ()
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
356
   "Return an appropriate string based on variable `org-graph-edge-prefix'."
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
357
   (cond ((equal org-graph-edge-prefix nil) "")
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
358
         ((stringp org-graph-edge-prefix) org-graph-edge-prefix)
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
359
         (t (funcall org-graph-edge-prefix))))
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
360
 
652
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
361
 (defun org-graph-edge-postfix ()
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
362
   "Return an appropriate string based on variable `org-graph-edge-postfix'."
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
363
   (cond ((equal org-graph-edge-postfix nil) "\n")
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
364
         ((stringp org-graph-edge-postfix) org-graph-edge-postfix)
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
365
         (t (funcall org-graph-edge-postfix))))
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
366
 
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
367
 (defun org-graph-edge-link-prefix ()
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
368
   "Return an appropriate string based on variable `org-graph-edge-link-prefix'."
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
369
   (cond ((equal org-graph-edge-link-prefix nil) "")
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
370
         ((stringp org-graph-edge-link-prefix) org-graph-edge-link-prefix)
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
371
         (t (funcall org-graph-edge-link-prefix))))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
372
 
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
373
 (defun org-graph-edge-link-postfix ()
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
374
   "Return an appropriate string based on variable `org-graph-edge-link-postfix'."
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
375
   (cond ((equal org-graph-edge-link-postfix nil) "")
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
376
         ((stringp org-graph-edge-link-postfix) org-graph-edge-link-postfix)
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
377
         (t (funcall org-graph-edge-link-postfix))))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
378
 
655
65102f74d1ae some optimizations, may have muddied the waters with cli-opt a bit though.. tbd
Richard Westhaver <ellis@rwest.io>
parents: 652
diff changeset
379
 ;; TODO 2024-09-16: edge-properties
652
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
380
 (defun org-graph-edge-prefix-timestamp ()
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
381
   "Return the default prefix string for an edge.
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
382
 Inactive timestamp formatted according to `org-time-stamp-formats'."
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
383
   (format-time-string (org-time-stamp-format t t) (current-time)))
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
384
 
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
385
 (defun org-graph-edge-default-description-formatter (link desc)
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
386
   "Return a string to use as the link desciption.
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
387
 LINK is the link target.  DESC is the provided desc."
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
388
   (let ((p org-graph-edge-default-description-formatter))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
389
     (cond ((equal p nil) (or desc link))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
390
           ((stringp p) (or desc p))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
391
           ((fboundp p) (funcall p link desc))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
392
           (t desc))))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
393
 
652
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
394
 (defun org-graph-edge-drawer ()
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
395
   "Name of the edge drawer, as a string, or nil.
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
396
 This is the value of variable
652
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
397
 `org-graph-edge-drawer'.  However, if the current
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
398
 entry has or inherits a EDGE_DRAWER property, it will be
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
399
 used instead of the default value."
652
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
400
   (let ((p (org-entry-get nil "EDGE_DRAWER" 'inherit t)))
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
401
     (cond ((equal p "nil") nil)
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
402
           ((stringp p) p)
655
65102f74d1ae some optimizations, may have muddied the waters with cli-opt a bit though.. tbd
Richard Westhaver <ellis@rwest.io>
parents: 652
diff changeset
403
           (t org-graph-edge-drawer))))
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
404
 
678
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
405
 (defun org-graph-narrow-to-node ()
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
406
   "Narrow to current heading, excluding subheadings."
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
407
   (org-narrow-to-subtree)
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
408
   (save-excursion
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
409
     (org-next-visible-heading 1)
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
410
     (narrow-to-region (point-min) (point))))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
411
 
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
412
 ;; delete related functions
678
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
413
 (defun org-graph-find-links (id)
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
414
   "Return link elements for ID."
678
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
415
     (org-graph-narrow-to-node)
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
416
     (let ((links
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
417
            (org-element-map (org-element-parse-buffer) 'link
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
418
              (lambda (link)
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
419
                (when (string= (org-element-property :path link) id)
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
420
                  link)))))
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
421
       (widen)
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
422
       links))
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
423
 
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
424
 (defun org-graph-edge--in-drawer-p ()
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
425
   "Return non-nil if point is in drawer. Value is element at point."
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
426
   (let ((element (org-element-at-point)))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
427
     (while (and element
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
428
                 (not (memq (org-element-type element) '(drawer property-drawer))))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
429
       (setq element (org-element-property :parent element)))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
430
     element))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
431
 
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
432
 (defun org-graph-edge--delete-link (link)
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
433
   "Delete the LINK. If point is in edges drawer, delete the entire line."
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
434
   (save-excursion
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
435
     (goto-char (org-element-property :begin link))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
436
     (if (org-graph-edge--in-drawer)
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
437
         (progn
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
438
           (kill-whole-line 1)
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
439
           (org-remove-empty-drawer-at (point)))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
440
       (delete-region (org-element-property :begin link) (org-element-property :end link)))))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
441
 
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
442
 (defun org-graph-edge--insert (link desc arrow &rest props)
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
443
   "Insert an edge at point. ARROW is a symbol representing the type of
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
444
 arrow to insert. The rest of the arguments are parsed as :KEY VAL pairs
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
445
 which are inserted with the edge."
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
446
   (insert (format "%s %s " (org-graph-edge-prefix)
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
447
                   (org-graph-edge-arrow arrow)))
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
448
   (org-insert-link nil link desc)
678
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
449
   (insert (org-graph-edge-link-postfix))
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
450
   (newline))
655
65102f74d1ae some optimizations, may have muddied the waters with cli-opt a bit though.. tbd
Richard Westhaver <ellis@rwest.io>
parents: 652
diff changeset
451
 
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
452
 (defun org-graph-edge-insert-related (link desc)
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
453
   "Insert a relation edge."
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
454
   (with-org-graph-edge-drawer (beg t)
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
455
     (org-graph-edge--insert link desc 'relation)                              
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
456
     (org-indent-region beg (point))))
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
457
 
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
458
 (defun org-graph-edge-insert-backlink (link desc)
678
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
459
   "Insert a backlink edge."
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
460
   (with-org-graph-edge-drawer (beg t)
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
461
     (let ((description (org-graph-edge-default-description-formatter link desc)))
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
462
       (org-graph-edge--insert link description 'backlink)
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
463
       (org-indent-region beg (point)))))
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
464
 
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
465
 (defun org-graph-edge-insert-link (link desc)
678
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
466
   "insert a forward link edge. When BACKLINK is non-nil also create a
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
467
 backlink at the node specified in LINK."
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
468
   (interactive)
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
469
   (with-org-graph-edge-drawer (beg t)
678
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
470
     (let ((description (org-graph-edge-default-description-formatter link desc)))
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
471
       (org-graph-edge--insert link desc 'link)
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
472
       (org-indent-region beg (point)))))
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
473
 
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
474
 (defun org-graph-edge-links-action (marker hooks)
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
475
   "Go to MARKER, run HOOKS and store a link."
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
476
   (with-current-buffer (marker-buffer marker)
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
477
     (save-excursion
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
478
       (save-restriction
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
479
         (widen) ;; buffer could be narrowed
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
480
         (goto-char (marker-position marker))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
481
         (run-hooks hooks)
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
482
         (call-interactively #'org-store-link)
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
483
         (pop org-stored-links)))))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
484
 
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
485
 (defun org-graph-edge-link-builder (link)
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
486
   "Format link description for LINK."
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
487
   (let* ((link-ref (car link))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
488
          (pre-desc (cadr link))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
489
          (description (org-graph-edge-default-description-formatter link-ref pre-desc)))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
490
     (cons link-ref description)))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
491
 
678
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
492
 (defun org-graph-edge-insert-link-marker (target &optional no-forward no-backward)
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
493
   "Insert link to marker TARGET and create an edge.
652
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
494
 Only create edges in files in `org-mode' or a derived mode, otherwise just
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
495
 act like a normal link.
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
496
 
678
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
497
 If NO-FORWARD is non-nil skip creating the forward link. If NO-BACKWARD
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
498
 is non-nil skip creating the backlink."
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
499
   (let* ((source (point-marker))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
500
          (source-link (org-graph-edge-links-action source 'org-graph-edge-pre-link-hook))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
501
          (target-link (org-graph-edge-links-action target 'org-graph-edge-pre-backlink-hook))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
502
          (source-formatted-link (org-graph-edge-link-builder source-link))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
503
          (target-formatted-link (org-graph-edge-link-builder target-link)))
678
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
504
     (unless no-backward
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
505
       (with-current-buffer (marker-buffer target)
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
506
         (save-excursion
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
507
           (save-restriction
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
508
             (widen) ;; buffer could be narrowed
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
509
             (goto-char (marker-position target))
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
510
             (when (derived-mode-p 'org-mode)
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
511
               (org-graph-edge-insert-backlink (car source-formatted-link) (cdr source-formatted-link)))))))
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
512
     (unless no-forward
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
513
       (with-current-buffer (marker-buffer source)
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
514
         (save-excursion
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
515
           (goto-char (marker-position source))
678
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
516
           (print target-formatted-link)
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
517
           (org-graph-edge-insert-link (car target-formatted-link) (cdr target-formatted-link)))))))
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
518
 
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
519
 ;;;###autoload
678
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
520
 (defun org-graph-edge-convert-link (&optional arg)
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
521
   "Convert a normal `org-mode' link at `point' to a graph link, ARG prefix.
678
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
522
 When called interactively with a `C-u' prefix argument do not modify
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
523
 existing link."
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
524
   (interactive "P")
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
525
   (let ((from-m (point-marker))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
526
         (target (save-window-excursion
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
527
                   (with-current-buffer (current-buffer)
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
528
                     (save-excursion
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
529
                       (org-open-at-point)
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
530
                       (point-marker))))))
678
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
531
     (org-graph-edge-insert-link-marker target arg)
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
532
     (goto-char (marker-position from-m)))
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
533
   (when (not arg)
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
534
     (let ((begin (org-element-property :begin (org-element-context)))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
535
           (end (org-element-property :end (org-element-context))))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
536
       (delete-region begin end))))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
537
 
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
538
 ;;;###autoload
655
65102f74d1ae some optimizations, may have muddied the waters with cli-opt a bit though.. tbd
Richard Westhaver <ellis@rwest.io>
parents: 652
diff changeset
539
 (defun org-graph-edge-delete ()
678
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
540
   "Delete the link at point, and the corresponding backlink.
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
541
 If no backlink exists, just delete link at point. This works from
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
542
 either side, and deletes both sides of a link."
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
543
   (interactive)
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
544
   (save-window-excursion
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
545
     (with-current-buffer (current-buffer)
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
546
       (save-excursion
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
547
         (let ((id (org-id-get (point))))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
548
           (org-open-at-point)
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
549
           (let ((link-elements (org-graph-find-edges id)))
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
550
             (if link-elements
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
551
                 (if (> (length link-elements) 1)
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
552
                     (error "Multiple links found.")
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
553
                   (org-graph-edge--delete-link (car link-elements)))
652
328e1ff73938 graph and cli updates
Richard Westhaver <ellis@rwest.io>
parents: 651
diff changeset
554
               (message "No edge found. Deleting active only.")))))))
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
555
   (org-graph-edge--delete-link (org-element-context)))
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
556
 
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
557
 ;;;###autoload
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
558
 (defun org-graph-edge-insert ()
678
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
559
   "Insert an edge from `org-stored-links'."
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
560
   (interactive)
665
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
561
   (if org-stored-links
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
562
       (progn
c60decbaae3d more graph updates
Richard Westhaver <ellis@rwest.io>
parents: 656
diff changeset
563
         (org-link-open (pop org-stored-links))
678
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
564
         (org-graph-edge-insert-link-marker (set-marker (make-marker) (point))))
656
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
565
     (org-graph-edge-link)))
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
566
 
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
567
 ;;;###autoload
678
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
568
 (defun org-graph-edge-link (&optional no-backlink)
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
569
   "Insert a link edge and add a backlink edge to the target heading. With
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
570
 'C-u' don't create a backlink to the target."
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
571
   (interactive)
678
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
572
   (let ((target (org-graph-edge-search-function)))
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
573
     (org-graph-edge-insert-link-marker (set-marker (make-marker) (car (cdddr target))
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
574
                                                    (get-file-buffer (car (cdr target))))
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
575
                                        nil no-backlink)))
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
576
 
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
577
 (defun org-graph-edge-backlink ()
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
578
   "Insert a backlink edge to the target heading from the current one."
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
579
   (interactive)
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
580
   (let ((target (org-graph-edge-search-function)))
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
581
     (org-graph-edge-insert-link-marker (set-marker (make-marker) (car (cdddr target))
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
582
                                                    (get-file-buffer (car (cdr target)))) 
2b7d5a8d63ac alien octets fix, workin with org-graph-db
Richard Westhaver <ellis@rwest.io>
parents: 667
diff changeset
583
                                        t)))
651
af486e0a40c9 multi-binaries, working on removing x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 638
diff changeset
584
 
656
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
585
 (defun org-dblock-write:links ()
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
586
   "Generate a 'links' block for the designated node.")
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
587
 
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
588
 (defun org-dblock-write:graph ()
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
589
   "Generate a 'graph' block for the designated set of nodes.")
b499d4bcfc39 removed x.lisp
Richard Westhaver <ellis@rwest.io>
parents: 655
diff changeset
590
 
623
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
591
 (provide 'graph)
a304c9713a51 init graph.el
Richard Westhaver <ellis@rwest.io>
parents:
diff changeset
592
 ;; graph.el ends here