ahmed-shariff / org-roam-ql

Query language for org-roam
GNU General Public License v3.0
88 stars 5 forks source link
emacs org-mode org-roam query-language

+author: Shariff AM Faleel

+language: en

+HTML:
org-roam-ql
org-roam-ql-ql

+TITLE: org-roam-ql - query language for org-roam

This package provides an interface to easily query and display results from your ~org-roam~ database.

You can query org-roam with ~org-roam-ql-search~. The results are displayed in an org-roam-like buffer. org-roam-ql also comes with a transient that can be used to modify the results viewed. The transient can be activated with ~v~. You can modify the title (~t~), query (~q~), sort (~s~) and specify if the query is a subquery (apply query on the results of the buffer) or query against the whole org-roam database (~i~). Refreshing the buffer (~r~) will display the updated results.

[[images/demo4.gif]]

The transient is available in the org-roam buffer as well, this allows you to start a query from the results in the org-roam buffer. You also can view the results in an agenda-like buffer (~S~). When entering a query in any interactive function of org-roam-ql, it also has completion-at-point. ~org-roam-ql~ buffer also supports bookmark, i.e., you can set a bookmark by calling ~bookmark-set~. For convenience, the transient also has a shortcut for that (~b~).

[[images/demo6.gif]]

Example configuration:

+begin_src emacs-lisp

(use-package org-roam-ql ;; If using straight :straight (org-roam-ql :type git :host github :repo "ahmed-shariff/org-roam-ql" :files (:defaults (:exclude "org-roam-ql-ql.el"))) ;; If using quelpa :quelpa (org-roam-ql :fetcher github :repo "ahmed-shariff/org-roam-ql" :files (:defaults (:exclude "org-roam-ql-ql.el"))) ;; Simple configuration :after (org-roam) :bind ((:map org-roam-mode-map ;; Have org-roam-ql's transient available in org-roam-mode buffers ("v" . org-roam-ql-buffer-dispatch) :map minibuffer-mode-map ;; Be able to add titles in queries while in minibuffer. ;; This is similar to `org-roam-node-insert', but adds ;; only title as a string. ("C-c n i" . org-roam-ql-insert-node-title))))

+end_src

** Adding a sorting function

** Org dynamic block Similar to ~org-ql~, ~org-roam-ql~ also provides a dynamic block. The header parameters are as follows:

If no-link is not provided as a parameter, the first column is a link to the node. Since it is an id link, it will be a backlink to the node.

Following is an example of a dynamic block and its result.

[[file:images/dynamic-block.jpg]]

+begin_src emacs-lisp

(use-package org-roam-ql-ql ;; If using straight :straight (org-roam-ql-ql :type git :host github :repo "ahmed-shariff/org-roam-ql" :files (:defaults (:exclude "org-roam-ql.el"))) ;; If using quelpa :quelpa (org-roam-ql-ql :fetcher github :repo "ahmed-shariff/org-roam-ql" :files (:defaults (:exclude "org-roam-ql.el"))) ;; Simple config :after (org-ql org-roam-ql) :config (org-roam-ql-ql-init))

+end_src

Note that org-ql works only with org entries, i.e., heading nodes. Hence, if there are any file nodes in the result, they will not be displayed. To be clear about that, when org-roam-ql results are displayed in an org-ql-view buffer, a warning is added to the end mentioning how many file nodes were there in the result. If the extension is loaded, you may view the org-roam-ql results with ~Q~ from the org-roam-ql transient. An org-ql-view can be viewed in an org-roam-like buffer with ~R~ from the org-ql-view transient.

[[images/demo5.gif]]