123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- (require 'url)
- (autoload 'url-unhex-string "url")
- (defun bzg/org-annotation-helper (info)
- (interactive)
- "Process an externally passed remember:// style url.
- URLSTRING consists of a protocol part and a url and title,
- separated by ::remember::
- The protocol types currently recognized are:
- remember:// start `remember' with the url and title
- annotation:// similar to `org-annotation-as-kill'."
- (let ((remember-annotation-functions nil))
-
-
- (if (string-match "^\\([^:]*\\):\\(/*\\)\\(.*\\)" info)
- (let* ((b (get-buffer-create "*org-ann*"))
- (proto (match-string 1 info))
- (url_title_region (match-string 3 info))
- (splitparts (split-string url_title_region "::remember::"))
- (url (url-unhex-string (car splitparts)))
- (type (if (string-match "^\\([a-z]+\\):" url)
- (match-string 1 url)))
- (title (cadr splitparts))
- (region (url-unhex-string (caddr splitparts)))
- orglink)
- (setq title (if (> (length title) 0) (url-unhex-string title)))
- (setq orglink (org-make-link-string url title))
- (org-store-link-props :type type
- :link url
- :region region
- :description title)
- (setq org-stored-links
- (cons (list url title) org-stored-links))
-
- (raise-frame)
- (cond ((equal proto "remember")
- (kill-new orglink)
- (set-buffer b)
- (set-mark (point))
- (insert region)
- (org-remember nil ?w))
- ((equal proto "annotation")
- (message "Copied '%s' to the kill-ring." orglink)
- (kill-new orglink))
- (t (error "unrecognized org-helper protocol"))))
- (error "could not parse argument")))
- )
- (provide 'org-annotation-helper)
|