diff --git a/init.el b/init.el index 6141a61..3b73108 100644 --- a/init.el +++ b/init.el @@ -567,7 +567,9 @@ search commands like `db/helm-shortcuts’." db/pretty-print-xml db/bookmark-add-external db/bookmark-add-url - db/lookup-smime-key)) + db/lookup-smime-key + db/org-onenote-open + db/org-outlook-open)) (use-package hydra :commands (defhydra)) @@ -643,6 +645,16 @@ search commands like `db/helm-shortcuts’." hydra-org-clock/body db/make-org-capture-frame)) +(defcustom db/path-to-onenote "c:/Program Files (x86)/Microsoft Office/Office15/ONENOTE.EXE" + "Path to OneNote executable, for opening corresponding org-mode links." + :group 'personal-settings + :type 'file) + +(defcustom db/path-to-outlook "c:/Program Files (x86)/Microsoft Office/Office15/OUTLOOK.EXE" + "Path to Outlook executable, for opening corresponding org-mode links." + :group 'personal-settings + :type 'file) + (use-package org :commands (org-store-link) :bind (:map org-mode-map @@ -762,6 +774,11 @@ search commands like `db/helm-shortcuts’." (when (eq system-type 'cygwin) (add-to-list 'org-file-apps '(t . "cygstart %s") t)) + ;; Custom link types for Windows + (when (eq system-type 'windows-nt) + (org-link-set-parameters "onenote" :follow #'db/org-onenote-open) + (org-link-set-parameters "outlook" :follow #'db/org-outlook-open)) + ;; Skip some org mode regions to be skipped by ispell (add-hook 'org-mode-hook #'endless/org-ispell) diff --git a/site-lisp/db-utils.el b/site-lisp/db-utils.el index 82ff474..359ae37 100644 --- a/site-lisp/db-utils.el +++ b/site-lisp/db-utils.el @@ -507,6 +507,18 @@ This is done only if the value of this variable is not null." (call-process "xrandr" nil nil nil "--output" "HDMI-3" "--off")) +(defun db/org-onenote-open (path) + "Visit OneNote document on PATH." + (unless (file-executable-p db/path-to-onenote) + (user-error "Path for OneNote is not executable, please customize `db/path-to-onenote’.")) + (start-process "OneNote" nil db/path-to-onenote "/hyperlink" path)) + +(defun db/org-outlook-open (id) + "Open the Outlook item identified by ID. + ID should be an Outlook GUID." + (unless (file-executable-p db/path-to-outlook) + (user-error "Path for Outlook is not executable, please customize `db/path-to-outlook’.")) + (w32-shell-execute "open" db/path-to-outlook (concat "/select outlook:" id))) ;;; Bookmarks