Commit 922fa1ef authored by Xander van der Goot's avatar Xander van der Goot Committed by Jason Blevins

Update for Org 9.0 links and fix org-deft-store-link

In Org 9.0, org-add-link-type is replaced by org-link-set-parameters.

Closes #40

Also, deft-filename-at-point and deft-directory did not handle file path the same
way. This is solved by using file-name-nondirectory instead.
parent 86825cd4
......@@ -1708,8 +1708,7 @@ Otherwise, quick create a new file."
(defun org-deft-store-link ()
"Store the Deft widget at point as an org-mode link."
(when (equal major-mode 'deft-mode)
(let ((link (concat "deft:" (substring (deft-filename-at-point)
(1+ (length deft-directory)))))
(let ((link (concat "deft:" (file-name-nondirectory (deft-filename-at-point))))
(title (deft-file-title (deft-filename-at-point))))
:type "deft"
......@@ -1717,13 +1716,19 @@ Otherwise, quick create a new file."
:description title))))
(with-eval-after-load 'org
(lambda (handle)
(expand-file-name handle deft-directory)))))
(add-hook 'org-store-link-functions 'org-deft-store-link)
(if (fboundp 'org-link-set-parameters)
"deft" :follow 'deft--org-follow-link :store 'org-deft-store-link)
(lambda (handle)
(expand-file-name handle deft-directory))))
(add-hook 'org-store-link-functions 'org-deft-store-link)))
(defun deft--org-follow-link (handle)
(expand-file-name handle deft-directory)))
;;; Mode definition
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment