summary refs log tree commit diff
path: root/emacs/custom/my-org.el
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--emacs/custom/my-org.el65
1 files changed, 42 insertions, 23 deletions
diff --git a/emacs/custom/my-org.el b/emacs/custom/my-org.el
index 1c68600..81f7a07 100644
--- a/emacs/custom/my-org.el
+++ b/emacs/custom/my-org.el
@@ -2,10 +2,30 @@
 ;;; Commentary:
 ;;; Code:
 
-;; (require 'fcuny-vars)
-;; (require 'fcuny-clipboard)
-
 (require 'use-package)
+(require 's)
+
+(defvar my/org-directory
+  (if (memq window-system '(mac ns))
+      (expand-file-name "~/workspace/notebooks/")
+    (expand-file-name "~/documents/notes/")))
+
+(defun my/clipboard-get-contents ()
+  "Return the contents of the system clipboard as a string."
+  (condition-case nil
+      (cond
+       ((fboundp 'ns-get-pasteboard)
+        (ns-get-pasteboard))
+       ((and (featurep 'mac)
+             (fboundp 'gui-get-selection))
+        (gui-get-selection 'CLIPBOARD 'NSStringPboardType))
+       ((and (featurep 'mac)
+             (fboundp 'x-get-selection))
+        (x-get-selection 'CLIPBOARD 'NSStringPboardType))
+       ((fboundp 'gui-get-selection)
+        (gui-get-selection 'CLIPBOARD (or x-select-request-type 'UTF8_STRING)))
+       (t
+        (error "Clipboard support not available")))))
 
 (use-package org-ml
   :ensure t)
@@ -42,7 +62,7 @@
                                load-language-list)
 
   :custom
-  ;; (org-directory fcuny/org-directory)
+  (org-directory my/org-directory)
   ;; hide emphasis markup
   (org-hide-emphasis-markers t)
 
@@ -98,8 +118,7 @@
 
   ;; entries
   (org-blank-before-new-entry nil)
-  (org-blank-before-new-entry (quote ((heading . nil)
-				                      (plain-list-item . nil))))
+  (org-blank-before-new-entry (quote ((heading . nil) (plain-list-item . nil))))
 
   ;; see https://github.com/abo-abo/swiper/issues/986
   (org-goto-interface 'outline-path-completion)
@@ -138,26 +157,26 @@
                         ((org-agenda-overriding-header "Not yet started")
                          (org-agenda-skip-function '(org-agenda-skip-entry-if 'deadline 'scheduled))))))))
 
-;; (defun fcuny/org-capture/link ()
-;;   "Make a TODO entry with a link in clipboard.
-;; The page title is used as an entry heading."
-;;   (let* ((url-string (s-trim (fcuny/clipboard-get-contents)))
-;;          (pdf (string-suffix-p "pdf" url-string)))
-;;     (unless pdf
-;;       (let ((page-title (org-web-tools--html-title (org-web-tools--get-url url-string))))
-;;         (concat "* "
-;;                 page-title
-;;                 "\t%^g"
-;;                 "\n:PROPERTIES:\n:CREATED: %T\n:URL: "
-;;                 url-string
-;;                 "\n:END:\n%?")))))
-
 (use-package org-web-tools
   :ensure t)
 
 (use-package org-capture
   :ensure nil
-  :after (org)
+  :after (org org-web-tools)
+  :preface
+  (defun my/org-capture-link ()
+  "Make a TODO entry with a link in clipboard.
+The page title is used as an entry heading."
+  (let* ((url-string (s-trim (my/clipboard-get-contents)))
+         (pdf (string-suffix-p "pdf" url-string)))
+    (unless pdf
+      (let ((page-title (org-web-tools--html-title (org-web-tools--get-url url-string))))
+        (concat "* "
+                page-title
+                "\t%^g"
+                "\n:PROPERTIES:\n:CREATED: %T\n:URL: "
+                url-string
+                "\n:END:\n%?")))))
   :custom
   (org-capture-templates
    `(("t" "Todo" entry (file "inbox.org")
@@ -166,8 +185,8 @@
      ("n" "Note" entry (file "notes.org")
       "* %?\n:PROPERTIES:\n:CREATED: %T\n:END:\n")
 
-     ;; ("l" "Bookmark" entry (file "bookmarks.org")
-     ;;  (function fcuny/org-capture/link))
+     ("l" "Bookmark" entry (file "bookmarks.org")
+      (function my/org-capture-link))
 
      ("j" "Journal" entry
       (file+olp+datetree "journal.org")