dependency adder for module edna
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.6 KiB

;;; dame-org-ql.el --- Dependency adding for module edna -*- lexical-binding: t; -*-
;; Copyright (C) 2020 DrOps
;; Author: DrOps <>
;; Version: 0.1
;; Package-Requires: (org)
;; URL:
;; Keywords: convenience, edna
;; 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
;; 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 <>.
;;; Commentary:
;; The most overly ambitiously named package to help you make dependencies for org-edna.
;; I should describe how it actually works here.
;;; Code:
(defvar helm-org-ql-actions)
(declare-function sl--insert-link "org-super-links")
(declare-function helm-org-ql "ext:helm-org-ql")
(declare-function org-agenda-files "ext:org-mode")
(defun sl-buffer-mode (&optional buffer-or-name)
"Return the major mode associated with a buffer.
If BUFFER-OR-NAME is nil return current buffer's mode."
(buffer-local-value 'major-mode
(if buffer-or-name (get-buffer buffer-or-name) (current-buffer))))
(defun sl-get-search-buffers ()
"Return the buffers to provide to `helm-org-ql`.
If the current buffer is an `org-mode` buffer add it to `org-agenda-files`.
Else just return `org-agenda-files`"
;; this needs to add the buffer you were on before opening a capture
;; template too (if it's an org mode file)
(if (and (string= (sl-buffer-mode) "org-mode") (buffer-file-name))
(cons (buffer-file-name) (org-agenda-files))
(defun sl-link-search-interface-ql ()
"Setup the helm-org-ql search interface."
(add-to-list 'helm-org-ql-actions '("super-link-temp" . sl-insert-link-org-ql-action) nil)
(helm-org-ql (sl-get-search-buffers))
(pop helm-org-ql-actions))
(with-eval-after-load "helm-org-ql"
(add-to-list 'helm-org-ql-actions '("Super Link" . sl-insert-link-org-ql-action) t))
(defun sl-insert-link-org-ql-action (marker)
"Wrapper for `sl--insert-link` for org-ql integration.
MARKER is the point at first char in the selected heading."
(sl--insert-link marker))
(provide 'dame-org-ql)
;;; org-super-links-org-ql.el ends here