]> git.donarmstrong.com Git - org-ref.git/commitdiff
add function to give message when on a cite link.
authorJohn Kitchin <jkitchin@andrew.cmu.edu>
Sun, 25 Jan 2015 00:34:49 +0000 (19:34 -0500)
committerJohn Kitchin <jkitchin@andrew.cmu.edu>
Sun, 25 Jan 2015 00:34:49 +0000 (19:34 -0500)
and customization variables to turn it off.

org-ref.org

index c0529c1c5ae00f6c74131ad4623add2a718c8565..0908cd4aeed87971cda7770d3a37ca6eafaebbe5 100644 (file)
@@ -38,11 +38,11 @@ This document is an experiment at creating a literate program to provide similar
 
 ;;; Commentary:
 ;;
 
 ;;; Commentary:
 ;;
-;; Lisp code to setup bibliography cite, ref and label org-mode links.
-;; also sets up reftex for org-mode. The links are clickable and do
-;; things that are useful. You should really read org-ref.org for details.
+;; Lisp code to setup bibliography cite, ref and label org-mode links.  also
+;; sets up reftex and helm for org-mode citations. The links are clickable and
+;; do things that are useful. You should really read org-ref.org for details.
 ;;
 ;;
-;; Package-Requires: ((dash))
+;; Package-Requires: ((dash) (helm) (helm-bibtex))
 #+END_SRC
 
 ** requires
 #+END_SRC
 
 ** requires
@@ -51,6 +51,8 @@ The only external require is reftex-cite
 #+BEGIN_SRC emacs-lisp  :tangle org-ref.el
 (require 'reftex-cite)
 (require 'dash)
 #+BEGIN_SRC emacs-lisp  :tangle org-ref.el
 (require 'reftex-cite)
 (require 'dash)
+(require 'helm)
+(require 'helm-bibtex
 #+END_SRC
 
 ** Custom variables
 #+END_SRC
 
 ** Custom variables
@@ -113,25 +115,36 @@ There are some variables needed later to tell this library where you store your
     ;;(org-tree-to-indirect-buffer)
     (outline-previous-visible-heading 1)
     (recenter-top-bottom 0))
     ;;(org-tree-to-indirect-buffer)
     (outline-previous-visible-heading 1)
     (recenter-top-bottom 0))
-  "User-defined way to open a notes entry. This is excecuted after the entry is found, with the cursor at the beginning of the headline. The default setting fully expands the notes, and moves the headline to the top of the buffer")
+  "User-defined way to open a notes entry. This is excecuted after the entry is found, with the cursor at the beginning of the headline. The default setting fully expands the notes, and moves the headline to the top of the buffer"
+:type 'function
+:group 'org-ref)
 
 
 (defcustom org-ref-open-pdf-function
    'org-ref-open-pdf-at-point
 "User-defined function to open a pdf from a link. The function must get the key at point, and derive a path to the pdf file, then open it. The default function is `org-ref-open-pdf-at-point'."
 
 
 (defcustom org-ref-open-pdf-function
    'org-ref-open-pdf-at-point
 "User-defined function to open a pdf from a link. The function must get the key at point, and derive a path to the pdf file, then open it. The default function is `org-ref-open-pdf-at-point'."
-  :type 'function)
+  :type 'function
+  :group 'org-ref)
 
 
 (defcustom org-ref-insert-cite-function
   'helm-bibtex
   "Function to call to insert citation links. The default is `helm-bibtex'. org-ref modifies helm-bibtex a little bit to give org-mode citations, and to reorder default actions. You may use `org-ref-insert-cite-link' if you like the reftex interface."
 
 
 (defcustom org-ref-insert-cite-function
   'helm-bibtex
   "Function to call to insert citation links. The default is `helm-bibtex'. org-ref modifies helm-bibtex a little bit to give org-mode citations, and to reorder default actions. You may use `org-ref-insert-cite-link' if you like the reftex interface."
- :type 'function)
+ :type 'function
+ :group 'org-ref)
 
 
 (defcustom org-ref-cite-onclick-function
   'org-ref-cite-click-helm
   "Function that runs when you click on a cite link. The function must take no arguments. You may also use `org-ref-cite-onclick-minibuffer-menu' if you do not like helm."
 
 
 (defcustom org-ref-cite-onclick-function
   'org-ref-cite-click-helm
   "Function that runs when you click on a cite link. The function must take no arguments. You may also use `org-ref-cite-onclick-minibuffer-menu' if you do not like helm."
- :type 'function)
+ :type 'function
+ :group 'org-ref)
+
+(defcustom org-ref-show-citation-on-enter t
+  "If non-nil add a hook function to show the citation summary in
+  the minibuffer just by putting the cursor in a link"
+ :group 'org-ref)
+
 #+END_SRC
 
 This next variable determines the citation types that are available in org-ref. Links for each one are automatically generated, and completion functions are automatically generated. Users may add to this list in their own init files.
 #+END_SRC
 
 This next variable determines the citation types that are available in org-ref. Links for each one are automatically generated, and completion functions are automatically generated. Users may add to this list in their own init files.
@@ -2827,7 +2840,7 @@ Now, let us define a function that inserts the cite links:
 ** A helm click menu
 
 #+BEGIN_SRC emacs-lisp :tangle org-ref.el
 ** A helm click menu
 
 #+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun test ()
+(defun org-ref-get-citation-string-at-point ()
   (interactive)
   (let* ((results (org-ref-get-bibtex-key-and-file))
         (key (car results))
   (interactive)
   (let* ((results (org-ref-get-bibtex-key-and-file))
         (key (car results))
@@ -2939,7 +2952,7 @@ This is a list of cons cells '((\"description\" . action)). The action function
 1. get name and candidates before entering helm because we need the org-buffer.
 2. switch back to the org buffer before evaluating the action. most of them need the point and buffer."
   (interactive)
 1. get name and candidates before entering helm because we need the org-buffer.
 2. switch back to the org buffer before evaluating the action. most of them need the point and buffer."
   (interactive)
-  (let ((name (test))
+  (let ((name (org-ref-get-citation-string-at-point))
        (candidates (org-ref-cite-candidates))
        (cb (current-buffer)))
 
        (candidates (org-ref-cite-candidates))
        (cb (current-buffer)))
 
@@ -2959,6 +2972,20 @@ This is a list of cons cells '((\"description\" . action)). The action function
 #+RESULTS:
 : org-ref-cite-click-helm
 
 #+RESULTS:
 : org-ref-cite-click-helm
 
+To get a lighter weight message about the cite link, 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.
+
+#+BEGIN_SRC emacs-lisp :tangle org-ref.el
+(defun org-ref-cite-link-p () (interactive)
+       (let* ((object (org-element-context))
+             (type (org-element-property :type object)))
+        ;;   We only want this to work on citation links
+        (when (-contains? org-ref-cite-types type)
+          (message (org-ref-get-citation-string-at-point)))))
+
+(when org-ref-show-citation-on-enter
+ (add-hook 'post-command-hook 'org-ref-cite-link-p))
+#+END_SRC
+
 * End of code
 #+BEGIN_SRC emacs-lisp :tangle org-ref.el
 (provide 'org-ref)
 * End of code
 #+BEGIN_SRC emacs-lisp :tangle org-ref.el
 (provide 'org-ref)