{"action":"created","issue":{"url":"https://api.github.com/repos/jkitchin/org-ref/issues/55","labels_url":"https://api.github.com/repos/jkitchin/org-ref/issues/55/labels{/name}","comments_url":"https://api.github.com/repos/jkitchin/org-ref/issues/55/comments","events_url":"https://api.github.com/repos/jkitchin/org-ref/issues/55/events","html_url":"https://github.com/jkitchin/org-ref/issues/55","id":106968057,"number":55,"title":"Invalid search bound (wrong side of point)","user":{"login":"brabalan","id":1021637,"avatar_url":"https://avatars.githubusercontent.com/u/1021637?v=3","gravatar_id":"","url":"https://api.github.com/users/brabalan","html_url":"https://github.com/brabalan","followers_url":"https://api.github.com/users/brabalan/followers","following_url":"https://api.github.com/users/brabalan/following{/other_user}","gists_url":"https://api.github.com/users/brabalan/gists{/gist_id}","starred_url":"https://api.github.com/users/brabalan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brabalan/subscriptions","organizations_url":"https://api.github.com/users/brabalan/orgs","repos_url":"https://api.github.com/users/brabalan/repos","events_url":"https://api.github.com/users/brabalan/events{/privacy}","received_events_url":"https://api.github.com/users/brabalan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-17T12:00:58Z","updated_at":"2015-09-18T09:25:31Z","closed_at":null,"body":"I have the following error when I put the point on the right of an org-ref link. For instance with the following link:\r\n``` org-mode\r\n[[cite:OConnor2011]] \r\n```\r\nIf I put the cursor on the very right, then hit right arrow again to make sure I’m after the link, I get the following backtrace:\r\n```\r\nDebugger entered--Lisp error: (error \"Invalid search bound (wrong side of point)\")\r\n  search-forward(\",\" 33319 t 1)\r\n  (if (search-forward \",\" link-string-end t 1) (setq key-end (- (match-end 0) 1)) (setq key-end link-string-end))\r\n  (save-excursion (if (search-forward \",\" link-string-end t 1) (setq key-end (- (match-end 0) 1)) (setq key-end link-string-end)))\r\n  (let (key-beginning key-end) (save-excursion (if (search-forward \",\" link-string-end t 1) (setq key-end (- (match-end 0) 1)) (setq key-end link-string-end))) (save-excursion (if (search-backward \",\" link-string-beginning 1 1) (setq key-beginning (+ (match-beginning 0) 1)) (setq key-beginning link-string-beginning))) (let ((bibtex-key (org-ref-strip-string (buffer-substring key-beginning key-end)))) (set-text-properties 0 (length bibtex-key) nil bibtex-key) bibtex-key))\r\n  (let (link-string-beginning link-string-end) (save-excursion (goto-char (org-element-property :begin object)) (search-forward link-string nil nil 1) (setq link-string-beginning (match-beginning 0)) (setq link-string-end (match-end 0))) (let (key-beginning key-end) (save-excursion (if (search-forward \",\" link-string-end t 1) (setq key-end (- (match-end 0) 1)) (setq key-end link-string-end))) (save-excursion (if (search-backward \",\" link-string-beginning 1 1) (setq key-beginning (+ (match-beginning 0) 1)) (setq key-beginning link-string-beginning))) (let ((bibtex-key (org-ref-strip-string (buffer-substring key-beginning key-end)))) (set-text-properties 0 (length bibtex-key) nil bibtex-key) bibtex-key)))\r\n  (progn (let (link-string-beginning link-string-end) (save-excursion (goto-char (org-element-property :begin object)) (search-forward link-string nil nil 1) (setq link-string-beginning (match-beginning 0)) (setq link-string-end (match-end 0))) (let (key-beginning key-end) (save-excursion (if (search-forward \",\" link-string-end t 1) (setq key-end (- (match-end 0) 1)) (setq key-end link-string-end))) (save-excursion (if (search-backward \",\" link-string-beginning 1 1) (setq key-beginning (+ (match-beginning 0) 1)) (setq key-beginning link-string-beginning))) (let ((bibtex-key (org-ref-strip-string (buffer-substring key-beginning key-end)))) (set-text-properties 0 (length bibtex-key) nil bibtex-key) bibtex-key))))\r\n  (if (not (org-element-property :contents-begin object)) (progn (let (link-string-beginning link-string-end) (save-excursion (goto-char (org-element-property :begin object)) (search-forward link-string nil nil 1) (setq link-string-beginning (match-beginning 0)) (setq link-string-end (match-end 0))) (let (key-beginning key-end) (save-excursion (if (search-forward \",\" link-string-end t 1) (setq key-end (- ... 1)) (setq key-end link-string-end))) (save-excursion (if (search-backward \",\" link-string-beginning 1 1) (setq key-beginning (+ ... 1)) (setq key-beginning link-string-beginning))) (let ((bibtex-key (org-ref-strip-string ...))) (set-text-properties 0 (length bibtex-key) nil bibtex-key) bibtex-key)))) link-string)\r\n  (let* ((object (org-element-context)) (link-string (org-element-property :path object))) (let ((cp (point))) (goto-char (org-element-property :begin object)) (search-forward link-string (org-element-property :end object)) (goto-char (match-beginning 0)) (if (< cp (point)) nil (goto-char cp))) (if (not (org-element-property :contents-begin object)) (progn (let (link-string-beginning link-string-end) (save-excursion (goto-char (org-element-property :begin object)) (search-forward link-string nil nil 1) (setq link-string-beginning (match-beginning 0)) (setq link-string-end (match-end 0))) (let (key-beginning key-end) (save-excursion (if (search-forward \",\" link-string-end t 1) (setq key-end ...) (setq key-end link-string-end))) (save-excursion (if (search-backward \",\" link-string-beginning 1 1) (setq key-beginning ...) (setq key-beginning link-string-beginning))) (let ((bibtex-key ...)) (set-text-properties 0 (length bibtex-key) nil bibtex-key) bibtex-key)))) link-string))\r\n  org-ref-get-bibtex-key-under-cursor()\r\n  (setq key (org-ref-get-bibtex-key-under-cursor))\r\n  (if key nil (setq key (org-ref-get-bibtex-key-under-cursor)))\r\n  (let ((org-ref-bibliography-files (org-ref-find-bibliography)) (file)) (if key nil (setq key (org-ref-get-bibtex-key-under-cursor))) (setq file (catch (quote result) (let* ((--cl-var-- org-ref-bibliography-files) (file nil)) (while (consp --cl-var--) (setq file (car --cl-var--)) (if (org-ref-key-in-file-p key (file-truename file)) (throw (quote result) file)) (setq --cl-var-- (cdr --cl-var--))) nil))) (cons key file))\r\n  org-ref-get-bibtex-key-and-file()\r\n  (let* ((results (org-ref-get-bibtex-key-and-file)) (key (car results)) (bibfile (cdr results))) (if bibfile (save-excursion (let ((temp-buffer (generate-new-buffer \" *temp*\"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (insert-file-contents bibfile) (bibtex-set-dialect ... t) (bibtex-search-entry key) (org-ref-bib-citation)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))))) \"!!! No entry found !!!\"))\r\n  org-ref-get-citation-string-at-point()\r\n  (message (org-ref-get-citation-string-at-point))\r\n  (cond ((-contains\\? org-ref-cite-types type) (message (org-ref-get-citation-string-at-point))) ((string= type \"ref\") (message \"%scount: %s\" (org-ref-get-label-context (org-element-property :path object)) (org-ref-count-labels (org-element-property :path object)))) ((string= type \"eqref\") (message \"%scount: %s\" (org-ref-get-label-context (org-element-property :path object)) (org-ref-count-labels (org-element-property :path object)))) ((string= type \"label\") (let ((count (org-ref-count-labels (org-element-property :path object)))) (message (concat (number-to-string count) \" occurence\" (if (or (= count 0) (> count 1)) (progn \"s\")))))) ((string= type \"custom-id\") (save-excursion (org-open-link-from-string (format \"[[#%s]]\" (org-element-property :path object))) (message \"%s\" (org-get-heading)))) ((string= type \"bibliography\") (let* ((bibfile) (object (org-element-context)) (link-string (org-element-property :path object)) (link-string-beginning) (link-string-end)) (save-excursion (goto-char (org-element-property :begin object)) (search-forward link-string nil nil 1) (setq link-string-beginning (match-beginning 0)) (setq link-string-end (match-end 0))) (if (> link-string-beginning (point)) (progn (goto-char link-string-beginning))) (let (key-beginning key-end) (save-excursion (if (search-forward \",\" link-string-end 1 1) (setq key-end (- ... 1)) (setq key-end (point)))) (save-excursion (if (search-backward \",\" link-string-beginning 1 1) (setq key-beginning (+ ... 1)) (setq key-beginning (point)))) (setq bibfile (org-ref-strip-string (buffer-substring key-beginning key-end))) (if (file-exists-p bibfile) (message \"%s exists.\" bibfile) (message \"!!! %s NOT FOUND !!!\" bibfile))))))\r\n  (save-excursion (cond ((-contains\\? org-ref-cite-types type) (message (org-ref-get-citation-string-at-point))) ((string= type \"ref\") (message \"%scount: %s\" (org-ref-get-label-context (org-element-property :path object)) (org-ref-count-labels (org-element-property :path object)))) ((string= type \"eqref\") (message \"%scount: %s\" (org-ref-get-label-context (org-element-property :path object)) (org-ref-count-labels (org-element-property :path object)))) ((string= type \"label\") (let ((count (org-ref-count-labels (org-element-property :path object)))) (message (concat (number-to-string count) \" occurence\" (if (or ... ...) (progn \"s\")))))) ((string= type \"custom-id\") (save-excursion (org-open-link-from-string (format \"[[#%s]]\" (org-element-property :path object))) (message \"%s\" (org-get-heading)))) ((string= type \"bibliography\") (let* ((bibfile) (object (org-element-context)) (link-string (org-element-property :path object)) (link-string-beginning) (link-string-end)) (save-excursion (goto-char (org-element-property :begin object)) (search-forward link-string nil nil 1) (setq link-string-beginning (match-beginning 0)) (setq link-string-end (match-end 0))) (if (> link-string-beginning (point)) (progn (goto-char link-string-beginning))) (let (key-beginning key-end) (save-excursion (if (search-forward \",\" link-string-end 1 1) (setq key-end ...) (setq key-end ...))) (save-excursion (if (search-backward \",\" link-string-beginning 1 1) (setq key-beginning ...) (setq key-beginning ...))) (setq bibfile (org-ref-strip-string (buffer-substring key-beginning key-end))) (if (file-exists-p bibfile) (message \"%s exists.\" bibfile) (message \"!!! %s NOT FOUND !!!\" bibfile)))))))\r\n  (let* ((object (org-element-context)) (type (org-element-property :type object))) (save-excursion (cond ((-contains\\? org-ref-cite-types type) (message (org-ref-get-citation-string-at-point))) ((string= type \"ref\") (message \"%scount: %s\" (org-ref-get-label-context (org-element-property :path object)) (org-ref-count-labels (org-element-property :path object)))) ((string= type \"eqref\") (message \"%scount: %s\" (org-ref-get-label-context (org-element-property :path object)) (org-ref-count-labels (org-element-property :path object)))) ((string= type \"label\") (let ((count (org-ref-count-labels ...))) (message (concat (number-to-string count) \" occurence\" (if ... ...))))) ((string= type \"custom-id\") (save-excursion (org-open-link-from-string (format \"[[#%s]]\" (org-element-property :path object))) (message \"%s\" (org-get-heading)))) ((string= type \"bibliography\") (let* ((bibfile) (object (org-element-context)) (link-string (org-element-property :path object)) (link-string-beginning) (link-string-end)) (save-excursion (goto-char (org-element-property :begin object)) (search-forward link-string nil nil 1) (setq link-string-beginning (match-beginning 0)) (setq link-string-end (match-end 0))) (if (> link-string-beginning (point)) (progn (goto-char link-string-beginning))) (let (key-beginning key-end) (save-excursion (if ... ... ...)) (save-excursion (if ... ... ...)) (setq bibfile (org-ref-strip-string ...)) (if (file-exists-p bibfile) (message \"%s exists.\" bibfile) (message \"!!! %s NOT FOUND !!!\" bibfile))))))))\r\n  (progn (let* ((object (org-element-context)) (type (org-element-property :type object))) (save-excursion (cond ((-contains\\? org-ref-cite-types type) (message (org-ref-get-citation-string-at-point))) ((string= type \"ref\") (message \"%scount: %s\" (org-ref-get-label-context (org-element-property :path object)) (org-ref-count-labels (org-element-property :path object)))) ((string= type \"eqref\") (message \"%scount: %s\" (org-ref-get-label-context (org-element-property :path object)) (org-ref-count-labels (org-element-property :path object)))) ((string= type \"label\") (let ((count ...)) (message (concat ... \" occurence\" ...)))) ((string= type \"custom-id\") (save-excursion (org-open-link-from-string (format \"[[#%s]]\" ...)) (message \"%s\" (org-get-heading)))) ((string= type \"bibliography\") (let* ((bibfile) (object ...) (link-string ...) (link-string-beginning) (link-string-end)) (save-excursion (goto-char ...) (search-forward link-string nil nil 1) (setq link-string-beginning ...) (setq link-string-end ...)) (if (> link-string-beginning ...) (progn ...)) (let (key-beginning key-end) (save-excursion ...) (save-excursion ...) (setq bibfile ...) (if ... ... ...))))))))\r\n  (if (eq major-mode (quote org-mode)) (progn (let* ((object (org-element-context)) (type (org-element-property :type object))) (save-excursion (cond ((-contains\\? org-ref-cite-types type) (message (org-ref-get-citation-string-at-point))) ((string= type \"ref\") (message \"%scount: %s\" (org-ref-get-label-context ...) (org-ref-count-labels ...))) ((string= type \"eqref\") (message \"%scount: %s\" (org-ref-get-label-context ...) (org-ref-count-labels ...))) ((string= type \"label\") (let (...) (message ...))) ((string= type \"custom-id\") (save-excursion (org-open-link-from-string ...) (message \"%s\" ...))) ((string= type \"bibliography\") (let* (... ... ... ... ...) (save-excursion ... ... ... ...) (if ... ...) (let ... ... ... ... ...))))))))\r\n  (save-restriction (widen) (if (eq major-mode (quote org-mode)) (progn (let* ((object (org-element-context)) (type (org-element-property :type object))) (save-excursion (cond ((-contains\\? org-ref-cite-types type) (message ...)) ((string= type \"ref\") (message \"%scount: %s\" ... ...)) ((string= type \"eqref\") (message \"%scount: %s\" ... ...)) ((string= type \"label\") (let ... ...)) ((string= type \"custom-id\") (save-excursion ... ...)) ((string= type \"bibliography\") (let* ... ... ... ...))))))))\r\n  org-ref-link-message()\r\n  apply(org-ref-link-message nil)\r\n  byte-code(\"r\\301\b\\302H\b\\303H\\\"\\210)\\301\\207\" [timer apply 5 6] 4)\r\n  timer-event-handler([t 0 0 500000 t org-ref-link-message nil idle 0])\r\n```"},"comment":{"url":"https://api.github.com/repos/jkitchin/org-ref/issues/comments/141395434","html_url":"https://github.com/jkitchin/org-ref/issues/55#issuecomment-141395434","issue_url":"https://api.github.com/repos/jkitchin/org-ref/issues/55","id":141395434,"user":{"login":"brabalan","id":1021637,"avatar_url":"https://avatars.githubusercontent.com/u/1021637?v=3","gravatar_id":"","url":"https://api.github.com/users/brabalan","html_url":"https://github.com/brabalan","followers_url":"https://api.github.com/users/brabalan/followers","following_url":"https://api.github.com/users/brabalan/following{/other_user}","gists_url":"https://api.github.com/users/brabalan/gists{/gist_id}","starred_url":"https://api.github.com/users/brabalan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brabalan/subscriptions","organizations_url":"https://api.github.com/users/brabalan/orgs","repos_url":"https://api.github.com/users/brabalan/repos","events_url":"https://api.github.com/users/brabalan/events{/privacy}","received_events_url":"https://api.github.com/users/brabalan/received_events","type":"User","site_admin":false},"created_at":"2015-09-18T09:25:31Z","updated_at":"2015-09-18T09:25:31Z","body":"I can reproduce this with the following setup.\r\nFile orgref.org\r\n``` org-mode\r\n[[cite:OConnor2011]] [[file:~/Documents/BibDeskDocs/OConnor2011.pdf][pdf]] [[file:~/Documents/BibDeskDocs/OConnor2011-appendices.pdf][arxiv version with appendices]]\r\n```\r\n\r\nFile orgref.bib\r\n``` bibtex\r\n@Article{OConnor2011,\r\n\tdoi = {10.1017/S0960129511000132},\r\n\tyear = {2011},\r\n\tpages = {861--882},\r\n\tnumber = {4},\r\n\tvolume = {21},\r\n\tjournaltitle = {Mathematical Structures in Computer Science},\r\n\ttitle = {Classical Mathematics for a Constructive World},\r\n\tauthor = {Russel O'Connor}\r\n}\r\n```\r\n\r\nFile orgref.el\r\n``` emacs-lisp\r\n(setq emacsd-dir \"/Users/schmitta/.emacs.d/\")\r\n\r\n;; org-setup\r\n(add-to-list 'load-path (concat emacsd-dir \"org/emacs/site-lisp/org\"))\r\n(require 'org)\r\n\r\n(setq package-user-dir (concat emacsd-dir \"elpa\"))\r\n(package-initialize)\r\n\r\n(add-to-list 'load-path \"~/projets/org-ref\")\r\n(require 'org-ref)\r\n\r\n(setq org-ref-default-bibliography '(\"~/tmp/orgref.bib\"))\r\n```\r\n\r\nIf I start emacs like this\r\n```\r\nopen /Applications/Emacs.app -n --args -Q -l ~/tmp/orgref.el ~/tmp/orgref.org\r\n```\r\n\r\nAfter a short while I see the reference echoed at the bottom. If I move the cursor to the 'p' of “pdf”, then move one left to the space, then I see the error. Note that I only see the error when I get to that point from the right."}}