Created
July 27, 2020 19:28
-
-
Save progfolio/2871f12099be3913a1c61a3c3062f4fd to your computer and use it in GitHub Desktop.
doct-org-roam.el
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; doct-org-roam.el --- An org-roam extension for doct | |
;; Copyright (C) 2020 Nicholas Vollmer | |
;; Author: Nicholas Vollmer <[email protected]> | |
;; URL: https://github.com/progfolio/doct-org-roam | |
;; Created: July 27, 2020 | |
;; Keywords: org, org-roam, convenience | |
;; Package-Requires: ((emacs "26.1")) | |
;; Version: 0.0.0 | |
;; This file is not part of GNU Emacs. | |
;; This program is free software: you can redistribute it and/or modify | |
;; it under the terms of the GNU General Public License as published by | |
;; the Free Software Foundation, either version 3 of the License, or | |
;; (at your option) any later version. | |
;; This program is distributed in the hope that it will be useful, | |
;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
;; GNU General Public License for more details. | |
;; You should have received a copy of the GNU General Public License | |
;; along with this program. If not, see <https://www.gnu.org/licenses/>. | |
;;; Commentary: | |
;; This package adds support for an :org-roam keyword to doct's declarations. | |
;; Please see the docstring for `doct-org-roam' and `doct' for more information. | |
;;; Code: | |
(require 'doct) | |
(eval-when-compile (require 'subr-x)) | |
(defun doct-org-roam-convert (groups) | |
"Convert GROUPS of templates to `org-roam' compatible templates." | |
(setq doct-templates | |
(mapcar (lambda (template) | |
(if-let* ((props (nthcdr (if (= (length template) 4) 2 5) template)) | |
(org-roam-props (plist-get (plist-get props :doct) :org-roam))) | |
`(,@template ,@org-roam-props) | |
template)) | |
(doct-flatten-lists-in groups)))) | |
(defun doct-org-roam (declarations) | |
"Convert DECLARATIONS to `org-roam-capture-templates'. | |
DECLARATIONS must be of the same form that `doct' expects with | |
one addition: the :org-roam keyword. | |
The :org-roam keyword's value must be a plist mapping `org-roam''s | |
template syntax extensions (e.g. :file-name :head) to their appropriate values. | |
Note this does validate the :org-roam plist's values or keywords." | |
;;TODO: we should preserve doct-after-conversion-functions | |
;;in case user already has other functions set. | |
(let ((doct-after-conversion-functions (append '(doct-org-roam-convert) | |
doct-after-conversion-functions))) | |
(doct declarations))) | |
(provide 'doct-org-roam) | |
;;; doct-org-roam.el ends here |
Sorry, I stopped using org-roam
prior to even writing this.
Though, if it's just a matter or using a different keyword, this should still work.
If you can show me an example of the input you give to doct-org-roam
, and the output you expect to get vs. the output you actually get, I could probably fix it.
I've updated this gist to work with org-roam v2: https://gist.github.com/vherrmann/f9b21eeea7d7c9123dc400a30599d50d
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could I bug you for an update to the org-roam2 version of the templates.. I know they've added the :if-new property that has templates and files