2020-03-28 13:16:28 +00:00
|
|
|
;;; org-roam-macs.el --- Roam Research replica with Org-mode -*- coding: utf-8; lexical-binding: t -*-
|
|
|
|
|
|
|
|
;; Copyright © 2020 Jethro Kuan <jethrokuan95@gmail.com>
|
|
|
|
|
|
|
|
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
2020-05-10 05:48:16 +00:00
|
|
|
;; URL: https://github.com/org-roam/org-roam
|
2020-03-28 13:16:28 +00:00
|
|
|
;; Keywords: org-mode, roam, convenience
|
2020-04-21 12:50:24 +00:00
|
|
|
;; Version: 1.1.0
|
2020-03-28 13:16:28 +00:00
|
|
|
;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (s "1.12.0") (org "9.3") (emacsql "3.0.0") (emacsql-sqlite "1.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, 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 GNU Emacs; see the file COPYING. If not, write to the
|
|
|
|
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
;; Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
;;
|
|
|
|
;; This library implements macros used throughout org-roam
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
;;; Code:
|
|
|
|
;;;; Library Requires
|
|
|
|
|
2020-05-10 08:44:28 +00:00
|
|
|
(defvar org-roam-verbose)
|
|
|
|
|
2020-03-28 13:16:28 +00:00
|
|
|
(defmacro org-roam--with-temp-buffer (&rest body)
|
|
|
|
"Execute BODY within a temp buffer.
|
|
|
|
Like `with-temp-buffer', but propagates `org-roam-directory'."
|
|
|
|
(declare (indent 0) (debug t))
|
|
|
|
(let ((current-org-roam-directory (make-symbol "current-org-roam-directory")))
|
|
|
|
`(let ((,current-org-roam-directory org-roam-directory))
|
|
|
|
(with-temp-buffer
|
|
|
|
(let ((org-roam-directory ,current-org-roam-directory))
|
|
|
|
,@body)))))
|
|
|
|
|
2020-05-09 10:08:08 +00:00
|
|
|
(defmacro org-roam--with-template-error (templates &rest body)
|
|
|
|
"Eval BODY, and point to TEMPLATES on error.
|
|
|
|
Provides more informative error messages so that users know where
|
|
|
|
to look.
|
|
|
|
|
|
|
|
\(fn TEMPLATES BODY...)"
|
|
|
|
(declare (debug (form body)) (indent 1))
|
|
|
|
`(condition-case err
|
|
|
|
,@body
|
|
|
|
(error (user-error "%s. Please adjust `%s'"
|
|
|
|
(error-message-string err)
|
|
|
|
,templates))))
|
|
|
|
|
2020-05-10 08:44:28 +00:00
|
|
|
(defmacro org-roam-message (format-string &rest args)
|
|
|
|
"Message MSG with ARGS when `org-roam-verbose' is true."
|
|
|
|
(declare (indent 0) (debug t))
|
|
|
|
`(when org-roam-verbose
|
|
|
|
(message (concat "(org-roam) " ,format-string) ,@args)))
|
2020-05-09 10:08:08 +00:00
|
|
|
|
2020-03-28 13:16:28 +00:00
|
|
|
(provide 'org-roam-macs)
|
|
|
|
|
|
|
|
;;; org-roam-macs.el ends here
|