forked from mirrors/org-mode
org-capture: Fix clipboard history with %^C or %^L place holders
* lisp/org-capture.el (org-capture--clipboards): New variable. (org-capture-fill-template): Use new variable. Reported-by: Allen Li <darkfeline@felesatra.moe> <http://permalink.gmane.org/gmane.emacs.orgmode/113020>
This commit is contained in:
parent
166364bc96
commit
03873f070c
|
@ -1549,6 +1549,9 @@ Lisp programs can force the template by setting KEYS to a string."
|
||||||
'(("C" "Customize org-capture-templates")
|
'(("C" "Customize org-capture-templates")
|
||||||
("q" "Abort"))))))
|
("q" "Abort"))))))
|
||||||
|
|
||||||
|
(defvar org-capture--clipboards nil
|
||||||
|
"List various clipboards values.")
|
||||||
|
|
||||||
(defun org-capture-fill-template (&optional template initial annotation)
|
(defun org-capture-fill-template (&optional template initial annotation)
|
||||||
"Fill a template and return the filled template as a string.
|
"Fill a template and return the filled template as a string.
|
||||||
The template may still contain \"%?\" for cursor positioning."
|
The template may still contain \"%?\" for cursor positioning."
|
||||||
|
@ -1597,7 +1600,8 @@ The template may still contain \"%?\" for cursor positioning."
|
||||||
org-clock-heading)))
|
org-clock-heading)))
|
||||||
(v-f (or (org-capture-get :original-file-nondirectory) ""))
|
(v-f (or (org-capture-get :original-file-nondirectory) ""))
|
||||||
(v-F (or (org-capture-get :original-file) ""))
|
(v-F (or (org-capture-get :original-file) ""))
|
||||||
(clipboards (delq nil
|
(org-capture--clipboards
|
||||||
|
(delq nil
|
||||||
(list v-i
|
(list v-i
|
||||||
(org-get-x-clipboard 'PRIMARY)
|
(org-get-x-clipboard 'PRIMARY)
|
||||||
(org-get-x-clipboard 'CLIPBOARD)
|
(org-get-x-clipboard 'CLIPBOARD)
|
||||||
|
@ -1742,24 +1746,21 @@ The template may still contain \"%?\" for cursor positioning."
|
||||||
(and (org-at-heading-p)
|
(and (org-at-heading-p)
|
||||||
(let ((org-ignore-region t))
|
(let ((org-ignore-region t))
|
||||||
(org-set-tags nil 'align))))))
|
(org-set-tags nil 'align))))))
|
||||||
("C"
|
((or "C" "L")
|
||||||
(cond
|
(let ((insert-fun (if (equal key "C") #'insert
|
||||||
((= (length clipboards) 1) (insert (car clipboards)))
|
(lambda (s) (org-insert-link 0 s))))
|
||||||
((> (length clipboards) 1)
|
(first-value (car org-capture--clipboards)))
|
||||||
(insert (read-string "Clipboard/kill value: "
|
(pcase (length org-capture--clipboards)
|
||||||
(car clipboards)
|
(nil nil)
|
||||||
'(clipboards . 1)
|
(`(,value) (funcall insert-fun value))
|
||||||
(car clipboards))))))
|
(`(,first-value . ,_)
|
||||||
("L"
|
(funcall insert-fun
|
||||||
(cond ((= (length clipboards) 1)
|
|
||||||
(org-insert-link 0 (car clipboards)))
|
|
||||||
((> (length clipboards) 1)
|
|
||||||
(org-insert-link
|
|
||||||
0
|
|
||||||
(read-string "Clipboard/kill value: "
|
(read-string "Clipboard/kill value: "
|
||||||
(car clipboards)
|
first-value
|
||||||
'(clipboards . 1)
|
'org-capture--clipboards
|
||||||
(car clipboards))))))
|
first-value)))
|
||||||
|
(_ (error "Invalid `org-capture--clipboards' value: %S"
|
||||||
|
org-capture--clipboards)))))
|
||||||
("p" (org-set-property prompt nil))
|
("p" (org-set-property prompt nil))
|
||||||
((guard key)
|
((guard key)
|
||||||
;; These are the date/time related ones.
|
;; These are the date/time related ones.
|
||||||
|
|
Loading…
Reference in New Issue