123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322 |
- (require 'url)
- (autoload 'url-unhex-string "url")
- (defun bzg/org-annotation-helper (info)
- "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, title and selection (if any).
- annotation:// squirrel away a link of the form [[url][title]] that can
- be used later with \\[org-insert-link]."
- (interactive)
- (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)
- (exchange-point-and-mark t)
- (org-remember nil ?w)
- (kill-buffer b)
- )
- ((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)
|