summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2014-10-22 21:11:05 -0400
committerKyle Meyer <kyle@kyleam.com>2014-10-22 21:15:59 -0400
commit300cdc452130c2c6c7c76063abc3e9794edde29d (patch)
treeab9e9ac0c557c6644aa8a76ac1172b01277eeb5c
parent0b2d1fed547aeea9716b59e66459c0857f7e31a6 (diff)
downloademacs.d-300cdc452130c2c6c7c76063abc3e9794edde29d.tar.gz
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.
-rw-r--r--lisp/init-bib.el16
1 files changed, 6 insertions, 10 deletions
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)