~willvaughn/.emacs.d

42a38fa5fae33b60e5641977d136328f3608334e — William Vaughn 6 months ago dc0444d
add custom org-mode code for link copying
1 files changed, 17 insertions(+), 3 deletions(-)

M lisp/wv-org.el
M lisp/wv-org.el => lisp/wv-org.el +17 -3
@@ 15,15 15,29 @@ Is relative to `org-directory'.")

(defvar wv-org/gcal-email)

(defun org-init-h ()
(defun wv-org/org-init-h ()
  (visual-line-mode +1))

(defun wv-org/org-copy-link-url ()
  "Copy plain url from an org link at point."
  (interactive)
  (kill-new (org-element-property :raw-link (org-element-context))))

(defun wv-org/org-copy-full-link ()
  "Copy org link at point, including formatting text, useful when copy/pasting within org-mode buffer."
  (interactive)
  (let ((begin (org-element-property :begin (org-element-context)))
        (end (org-element-property :end (org-element-context))))
    (kill-ring-save begin end)))

(use-package org
  :hook ((org-mode . org-init-h))
  :hook ((org-mode . wv-org/org-init-h))
  :bind (("C-c A" . org-agenda)
         ("C-c X" . org-capture)
         :map org-mode-map
         ("C-M-<return>" . org-insert-subheading))
         ("C-M-<return>" . org-insert-subheading)
         ("C-c l u" . wv-org/org-copy-link-url)
         ("C-c l c" . wv-org/org-copy-full-link))
  :config
  (setq org-directory wv-org/org-directory
        org-default-notes-file (expand-file-name wv-org/org-capture-notes-file org-directory)