From 300cdc452130c2c6c7c76063abc3e9794edde29d Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Wed, 22 Oct 2014 21:11:05 -0400 Subject: Rewrite doi-at-point This stopped working when I upgraded to Emacs 24.4. Using 'url' with `thing-at-point' doesn't seem to work anymore, so instead use text properties. --- lisp/init-bib.el | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'lisp/init-bib.el') diff --git a/lisp/init-bib.el b/lisp/init-bib.el index ae15305..f254b0a 100644 --- a/lisp/init-bib.el +++ b/lisp/init-bib.el @@ -63,16 +63,12 @@ point." (browse-url (org-link-escape-browser (concat org-doi-server-url doi)))) (defun km/doi-at-point () - "Return DOI at point. -This is a hack that uses `(thing-at-point 'url)' and then removes -the leading 'http://'. The DOI format is not verified in any -way." + "Return DOI at point." (save-excursion - (when (equal (thing-at-point 'word) "doi") - (backward-word) - (re-search-forward "doi:[ \t\n]*")) - (--if-let (thing-at-point 'url) - (replace-regexp-in-string "http://" "" it) - (user-error "No DOI found at point")))) + (let ((doi (cadr (get-text-property (point) 'htmlize-link)))) + (when (or (not doi) + (not (string-prefix-p "doi:" doi))) + (user-error "No DOI found at point")) + (replace-regexp-in-string "doi:" "" doi)))) (provide 'init-bib) -- cgit v1.2.3