From: John Kitchin Date: Sun, 25 Jan 2015 15:57:17 +0000 (-0500) Subject: tweaks getting minibuffer messages to work X-Git-Url: https://git.donarmstrong.com/?p=org-ref.git;a=commitdiff_plain;h=d832a3f74c8f41017016f79f3b6e2ad1677b4c0c tweaks getting minibuffer messages to work --- diff --git a/org-ref.org b/org-ref.org index ae39ab9..0561f76 100644 --- a/org-ref.org +++ b/org-ref.org @@ -2652,7 +2652,6 @@ Sometimes it may be helpful to manually change the order of citations. These fun (add-hook 'org-shiftleft-hook (lambda () (org-ref-swap-citation-link -1))) #+END_SRC - ** Lightweight messages about links To get a lighter weight message about the label, ref and cite links, we define a function that gives us the minibuffer message, without the menu. We add it to a hook that updates after every command, including cursor movements. @@ -2666,17 +2665,38 @@ ref:test citep:test label:rett (goto-char (point-min)) (when (re-search-forward (format "label:%s\\b" label) nil t) - (throw 'result (thing-at-point 'paragraph))) + (throw 'result (buffer-substring + (progn + (previous-line) + (beginning-of-line) + (point)) + (progn + (forward-line 4) + (point))))) (goto-char (point-min)) (when (re-search-forward (format "\\label{%s}" label) nil t) - (throw 'result (thing-at-point 'paragraph))) + (throw 'result (buffer-substring + (progn + (previous-line) + (beginning-of-line) + (point)) + (progn + (forward-line 4) + (point))))) (goto-char (point-min)) (when (re-search-forward (format "^#\\+label:\\s-*\\(%s\\)\\b" label) nil t) - (throw 'result (thing-at-point 'paragraph))) + (throw 'result (buffer-substring + (progn + (previous-line) + (beginning-of-line) + (point)) + (progn + (forward-line 4) + (point))))) (goto-char (point-min)) (when (re-search-forward @@ -2690,6 +2710,7 @@ ref:test citep:test label:rett (forward-line 4) (point)))))))) + (defun org-ref-link-message () "Print a minibuffer message about the link that point is on." (interactive) @@ -2703,7 +2724,6 @@ ref:test citep:test label:rett ;; message some context about the label we are referring to ((string= type "ref") -;; (message-box "%s" (org-element-property :path object)) (message (org-ref-get-label-context (org-element-property :path object)))) @@ -2711,6 +2731,7 @@ ref:test citep:test label:rett ((string= type "label") (let ((count (org-ref-count-labels (org-element-property :path object)))) + ;; get plurality on occurrence correct (message (concat (number-to-string count) " occurence" @@ -2718,6 +2739,7 @@ ref:test citep:test label:rett (> count 1)) "s")))))))) + (when org-ref-show-citation-on-enter (add-hook 'post-command-hook 'org-ref-link-message)) #+END_SRC