From: John Kitchin Date: Wed, 17 Dec 2014 17:35:03 +0000 (-0500) Subject: a lot of changes X-Git-Url: https://git.donarmstrong.com/?p=org-ref.git;a=commitdiff_plain;h=ad7c11c8f600449f84d6fb623bf1d992b6f380b9 a lot of changes 1. removed reftex setup. it was causing an error for me, and it didn't seem to be doing anythin. 2. add support for labels in link completion 3. minor change to menu string to use jmax-bibtex menu 4. support for index and glossary links 5. small fix to swap reference function --- diff --git a/org-ref.org b/org-ref.org index 30bf030..25a267e 100644 --- a/org-ref.org +++ b/org-ref.org @@ -179,12 +179,16 @@ We need a hook variable to store user-defined bibtex entry cleaning functions We setup reftex here. We use a custom insert cite link function defined here: [[*org-ref-insert-cite-link][org-ref-insert-cite-link]]. We setup reftex to use our org citation format. #+BEGIN_SRC emacs-lisp :tangle org-ref.el +(require 'reftex) (defun org-mode-reftex-setup () - (load-library "reftex") (and (buffer-file-name) (file-exists-p (buffer-file-name)) (global-auto-revert-mode t) - (reftex-parse-all)) + ;; I do not remember why I put this next line in. It doesn't + ;; work for org-files. Nothing very bad happens, but it gives + ;; an annoying error. Commenting it out for now. + ;(reftex-parse-all) + ) (make-local-variable 'reftex-cite-format) (setq reftex-cite-format 'org) (define-key org-mode-map (kbd org-ref-insert-cite-key) 'org-ref-insert-cite-link)) @@ -974,7 +978,18 @@ At the moment, ref links are not usable for section links. You need [[#CUSTOM_ID (format "\\ref{%s}" keyword))))) #+END_SRC -It would be nice to use completion to enter a ref link, where a list of labels is provided. The following code searches the buffer for labels, custom_ids, and table names as potential items to make a ref link to. +It would be nice to use completion to enter a ref link, where a list of labels is provided. The following code searches the buffer for org and latex labels, custom_ids, and table names as potential items to make a ref link to. + +#+BEGIN_SRC emacs-lisp :tangle org-ref.el +(defun org-ref-get-org-labels () + "find #+LABEL: labels" + (save-excursion + (goto-char (point-min)) + (let ((matches '())) + (while (re-search-forward "^#\\+label:\\s-+\\(.*\\)\\b" (point-max) t) + (add-to-list 'matches (match-string-no-properties 1) t)) +matches))) +#+END_SRC #+BEGIN_SRC emacs-lisp :tangle org-ref.el (defun org-ref-get-custom-ids () @@ -991,7 +1006,7 @@ results)) Here we get a list of the labels defined as raw latex labels, e.g. \label{eqtre}. #+BEGIN_SRC emacs-lisp :tangle org-ref.el (defun org-ref-get-latex-labels () -(save-excursion + (save-excursion (goto-char (point-min)) (let ((matches '())) (while (re-search-forward "\\\\label{\\([a-zA-z0-9:-]*\\)}" (point-max) t) @@ -1020,7 +1035,7 @@ Now, we can put all the labels together which will give us a list of candidates. (let ((matches '())) (while (re-search-forward "label:\\([a-zA-z0-9:-]*\\)" (point-max) t) (add-to-list 'matches (match-string-no-properties 1) t)) - (append matches (org-ref-get-latex-labels) (org-ref-get-tblnames) (org-ref-get-custom-ids)))))) + (append matches (org-ref-get-org-labels) (org-ref-get-latex-labels) (org-ref-get-tblnames) (org-ref-get-custom-ids)))))) #+END_SRC Now we create the completion function. This works from the org-machinery, e.g. if you type C-c C-l to insert a link, and use completion by pressing tab. @@ -1173,7 +1188,6 @@ This is just the LaTeX ref for equations. On export, the reference is enclosed i (format "\\eqref{%s}" keyword))))) #+END_SRC - ** cite This is the main reason this library exists. We want the following behavior. A cite link should be able to contain multiple bibtex keys. You should be able to click on the link, and get a brief citation of the entry for that key, and a menu of options to open the bibtex file, open a pdf if you have it, open your notes on the entry, or open a url if it exists. You should be able to insert new references onto an existing cite link, or create new ones easily. The following code implements these features. @@ -1356,11 +1370,15 @@ we check to see if there is pdf, and if the key actually exists in the bibliogra (with-temp-buffer (insert-file-contents bibfile) (bibtex-search-entry key) - (org-ref-bib-citation)))) + (concat + (org-ref-bib-citation) + "\n" + "in: " bibfile) + ))) citation) "no key found")) - (setq menu-string (mapconcat 'identity (list m2 "\n" m1 m3 m4 m5 "(q)uit") " ")) + (setq menu-string (mapconcat 'identity (list m2 "\n" m1 m3 m4 m5 "(m)enu" "(q)uit") " ")) menu-string)) #+END_SRC @@ -1407,6 +1425,7 @@ We need some convenience functions to open act on the citation at point. These w (browse-url (format "http://dx.doi.org/%s" doi))) (throw 'done nil)))))))) + (defun org-ref-open-notes-at-point () "open the notes for bibtex key under point." (interactive) @@ -1419,6 +1438,7 @@ We need some convenience functions to open act on the citation at point. These w (bibtex-search-entry key) (org-ref-open-bibtex-notes))))) + (defun org-ref-citation-at-point () "give message of current citation at point" (interactive) @@ -1432,6 +1452,7 @@ We need some convenience functions to open act on the citation at point. These w (bibtex-search-entry key) (org-ref-bib-citation)))))) + (defun org-ref-open-citation-at-point () "open bibtex file to key at point" (interactive) @@ -1467,8 +1488,7 @@ you select your option with a single key press." ;; cite ((= choice ?c) - (org-ref-citation-at-point)) - + (org-ref-citation-at-point)) ;; quit ((or @@ -1489,9 +1509,16 @@ you select your option with a single key press." ((= choice ?u) (org-ref-open-url-at-point)) + ;; jmax-bibtex menu + ((= choice ?m) + (save-window-excursion + (set-buffer (find-file-noselect bibfile)) + ;; get to bibtex entry and use menu there + (bibtex-search-entry key) + (jmax-bibtex))) + ;; anything else we just quit. - (t (message ""))))) - + (t (message ""))))) #+END_SRC *** A function to format a cite link @@ -1704,6 +1731,273 @@ org-mode already defines a store link function for bibtex entries. It does not s (car org-stored-links))) #+END_SRC +** Index entries +org-ref minimally supports index entries. To make an index in a file, you should put in the LaTeX header these lines + + +#+LATEX_HEADER: \usepackage{makeidx} +#+LATEX_HEADER: \makeindex + + +Finally, put \makeindex at the end of the document where you want the index to appear. You will need to run the makeindex program at an appropriate point in your LaTeX to pdf, or use ox-manuscript, which will do it for you. + + +Use index links to create entries (see http://en.wikibooks.org/wiki/LaTeX/Indexing). Clicking on an index link runs occur on the buffer for the entry. The link exports to LaTeX. Some links may need to be enclosed in double brackets if they have spaces in them. + + +index:hello +index:hello!Peter +[[index:hello!Sam@\textsl{Sam}]] +[[index:Lin@\textbf{Lin}]] +[[index:Joe|textit]] +[[index:Lin@\textbf{Lin}]] +[[index:Peter|see {hello}]] +[[index:Jen|seealso{Jenny}]] + +index:encodings!input!cp850 + +#+BEGIN_SRC emacs-lisp :tangle org-ref.el +(org-add-link-type + "index" + (lambda (path) + (occur path)) + + (lambda (path desc format) + (cond + ((eq format 'latex) + (format "\\index{%s}" path))))) + +;; this will generate a temporary index of entries in the file. +(org-add-link-type + "printindex" + (lambda (path) + (let ((*index-links* '()) + (*initial-letters* '())) + + ;; get links + (org-element-map (org-element-parse-buffer) 'link + (lambda (link) + (let ((type (nth 0 link)) + (plist (nth 1 link))) + + (when (equal (plist-get plist ':type) "index") + (add-to-list + '*index-links* + (cons (plist-get plist :path) + (format + "[[elisp:(progn (switch-to-buffer \"%s\") (goto-char %s))][%s]]" +(current-buffer) + (plist-get plist :begin) ;; position of link + ;; grab a description + (save-excursion + (goto-char (plist-get plist :begin)) + (if (thing-at-point 'sentence) + ;; get a sentence + (replace-regexp-in-string + "\n" "" (thing-at-point 'sentence)) + ;; or call it a link + "link"))))))))) + + ;; sort the links + (setq *index-links* (cl-sort *index-links* 'string-lessp :key 'car)) + + ;; now first letters + (dolist (link *index-links*) + (add-to-list '*initial-letters* (substring (car link) 0 1) t)) + + ;; now create the index + (switch-to-buffer (get-buffer-create "*index*")) + (org-mode) + (erase-buffer) + (insert "#+TITLE: Index\n\n") + (dolist (letter *initial-letters*) + (insert (format "* %s\n" (upcase letter))) + ;; now process the links + (while (and + ,*index-links* + (string= letter (substring (car (car *index-links*)) 0 1))) + (let ((link (pop *index-links*))) + (insert (format "%s %s\n\n" (car link) (cdr link)))))) + (switch-to-buffer "*index*"))) + ;; formatting + (lambda (path desc format) + (cond + ((eq format 'latex) + (format "\\printindex"))))) +#+END_SRC + +#+RESULTS: +| lambda | (path) | (let ((*index-links* (quote nil)) (*initial-letters* (quote nil))) (org-element-map (org-element-parse-buffer) (quote link) (lambda (link) (let ((type (nth 0 link)) (plist (nth 1 link))) (when (equal (plist-get plist (quote :type)) index) (add-to-list (quote *index-links*) (cons (plist-get plist :path) (format [[elisp:(progn (switch-to-buffer "%s") (goto-char %s))][%s]] (current-buffer) (plist-get plist :begin) (save-excursion (goto-char (plist-get plist :begin)) (if (thing-at-point (quote sentence)) (replace-regexp-in-string \n (thing-at-point (quote sentence))) link))))))))) (setq *index-links* (cl-sort *index-links* (quote string-lessp) :key (quote car))) (dolist (link *index-links*) (add-to-list (quote *initial-letters*) (substring (car link) 0 1) t)) (switch-to-buffer (get-buffer-create *index*)) (org-mode) (erase-buffer) (insert #+TITLE: Index\n\n) (dolist (letter *initial-letters*) (insert (format * %s\n (upcase letter))) (while (and *index-links* (string= letter (substring (car (car *index-links*)) 0 1))) (let ((link (pop *index-links*))) (insert (format %s %s\n\n (car link) (cdr link)))))) (switch-to-buffer *index*)) | +| lambda | (path desc format) | (cond ((eq format (quote latex)) (format \printindex))) | + +** Glossary +org-ref provides some minimal support for a glossary. See http://en.wikibooks.org/wiki/LaTeX/Glossary for details. You need to put these lines in the header. + +#+LATEX_HEADER: \usepackage{glossaries} +#+LATEX_HEADER: \makeglossaries + +And at the end of the document put \makeglossaries. + +#+BEGIN_SRC emacs-lisp :tangle org-ref.el +(org-add-link-type + "newglossaryentry" + nil ;; no follow action + (lambda (path desc format) + (cond + ((eq format 'latex) + (format "\\newglossaryentry{%s}{%s}" path desc))))) + + +;; link to entry +(org-add-link-type + "gls" + nil ;; no follow action + (lambda (path desc format) + (cond + ((eq format 'latex) + (format "\\gls{%s}" path))))) + +;; plural +(org-add-link-type + "glspl" + nil ;; no follow action + (lambda (path desc format) + (cond + ((eq format 'latex) + (format "\\glspl{%s}" path))))) + +;; capitalized link +(org-add-link-type + "Gls" + nil ;; no follow action + (lambda (path desc format) + (cond + ((eq format 'latex) + (format "\\Gls{%s}" path))))) + +;; capitalized link +(org-add-link-type + "Glspl" + nil ;; no follow action + (lambda (path desc format) + (cond + ((eq format 'latex) + (format "\\Glspl{%s}" path))))) +#+END_SRC + +#+RESULTS: +| Glspl | nil | (lambda (path desc format) (cond ((eq format (quote latex)) (format \Glspl{%s} path)))) | +| Gls | nil | (lambda (path desc format) (cond ((eq format (quote latex)) (format \Gls{%s} path)))) | +| glspl | nil | (lambda (path desc format) (cond ((eq format (quote latex)) (format \glspl{%s} path)))) | +| gls | nil | (lambda (path desc format) (cond ((eq format (quote latex)) (format \gls{%s} path)))) | +| newglossaryentry | nil | (lambda (path desc format) (cond ((eq format (quote latex)) (format \newglossaryentry{%s}{%s} path desc)))) | +| google | (lambda (link-string) (browse-url (format http://www.google.com/search?q=%s (url-hexify-string link-string)))) | nil | +| ResearcherID | (lambda (link-string) (browse-url (format http://www.researcherid.com/rid/%s link-string))) | nil | +| orcid | (lambda (link-string) (browse-url (format http://orcid.org/%s link-string))) | nil | +| message | org-mac-message-open | nil | +| mac-outlook | org-mac-outlook-message-open | nil | +| skim | org-mac-skim-open | nil | +| addressbook | org-mac-addressbook-item-open | nil | +| x-together-item | org-mac-together-item-open | nil | +| ans | (lambda (path) (let* ((fields (split-string path ::)) (label (nth 0 fields)) (data (nth 1 fields)) (data-file (format %s-%s.dat tq-userid label))) (let ((temp-file data-file) (temp-buffer (get-buffer-create (generate-new-buffer-name *temp file*)))) (unwind-protect (prog1 (save-current-buffer (set-buffer temp-buffer) (insert data)) (save-current-buffer (set-buffer temp-buffer) (write-region nil nil temp-file nil 0))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))) (mygit (format git add %s data-file)) (mygit (format git commit -m "%s" data-file)) (mygit git push origin master))) | nil | +| mc | (lambda (link) (org-entry-put (point) ANSWER link) (save-restriction (save-excursion (org-narrow-to-subtree) (goto-char (point-max)) (if (bolp) nil (insert \n)) (insert (format # you chose %s link))))) | nil | +| exercise | (lambda (arg) (tq-check-internet) (tq-get-assignment arg)) | nil | +| solution | (lambda (label) (tq-check-internet) (let ((default-directory (file-name-as-directory (expand-file-name tq-root-directory)))) (if (file-exists-p solutions) nil (make-directory solutions)) (let ((default-directory (file-name-as-directory (expand-file-name solutions)))) (if (file-exists-p label) (progn (find-file (concat label / label .org)) (tq-update)) (mygit (format git clone %s@%s:solutions/%s tq-current-course tq-git-server label)) (find-file (concat label / label .org)))))) | nil | +| assignment | (lambda (arg) (tq-check-internet) (tq-get-assignment arg)) | nil | +| doi | doi-link-menu | nil | +| bibentry | org-ref-cite-onclick-minibuffer-menu | org-ref-format-bibentry | +| Autocites | org-ref-cite-onclick-minibuffer-menu | org-ref-format-Autocites | +| autocites | org-ref-cite-onclick-minibuffer-menu | org-ref-format-autocites | +| supercites | org-ref-cite-onclick-minibuffer-menu | org-ref-format-supercites | +| Textcites | org-ref-cite-onclick-minibuffer-menu | org-ref-format-Textcites | +| textcites | org-ref-cite-onclick-minibuffer-menu | org-ref-format-textcites | +| Smartcites | org-ref-cite-onclick-minibuffer-menu | org-ref-format-Smartcites | +| smartcites | org-ref-cite-onclick-minibuffer-menu | org-ref-format-smartcites | +| footcitetexts | org-ref-cite-onclick-minibuffer-menu | org-ref-format-footcitetexts | +| footcites | org-ref-cite-onclick-minibuffer-menu | org-ref-format-footcites | +| Parencites | org-ref-cite-onclick-minibuffer-menu | org-ref-format-Parencites | +| parencites | org-ref-cite-onclick-minibuffer-menu | org-ref-format-parencites | +| Cites | org-ref-cite-onclick-minibuffer-menu | org-ref-format-Cites | +| cites | org-ref-cite-onclick-minibuffer-menu | org-ref-format-cites | +| fnotecite | org-ref-cite-onclick-minibuffer-menu | org-ref-format-fnotecite | +| Pnotecite | org-ref-cite-onclick-minibuffer-menu | org-ref-format-Pnotecite | +| pnotecite | org-ref-cite-onclick-minibuffer-menu | org-ref-format-pnotecite | +| Notecite | org-ref-cite-onclick-minibuffer-menu | org-ref-format-Notecite | +| notecite | org-ref-cite-onclick-minibuffer-menu | org-ref-format-notecite | +| footfullcite | org-ref-cite-onclick-minibuffer-menu | org-ref-format-footfullcite | +| fullcite | org-ref-cite-onclick-minibuffer-menu | org-ref-format-fullcite | +| citeurl | org-ref-cite-onclick-minibuffer-menu | org-ref-format-citeurl | +| citedate* | org-ref-cite-onclick-minibuffer-menu | org-ref-format-citedate* | +| citedate | org-ref-cite-onclick-minibuffer-menu | org-ref-format-citedate | +| citetitle* | org-ref-cite-onclick-minibuffer-menu | org-ref-format-citetitle* | +| citetitle | org-ref-cite-onclick-minibuffer-menu | org-ref-format-citetitle | +| Citeauthor* | org-ref-cite-onclick-minibuffer-menu | org-ref-format-Citeauthor* | +| Autocite* | org-ref-cite-onclick-minibuffer-menu | org-ref-format-Autocite* | +| autocite* | org-ref-cite-onclick-minibuffer-menu | org-ref-format-autocite* | +| Autocite | org-ref-cite-onclick-minibuffer-menu | org-ref-format-Autocite | +| autocite | org-ref-cite-onclick-minibuffer-menu | org-ref-format-autocite | +| supercite | org-ref-cite-onclick-minibuffer-menu | org-ref-format-supercite | +| parencite* | org-ref-cite-onclick-minibuffer-menu | org-ref-format-parencite* | +| cite* | org-ref-cite-onclick-minibuffer-menu | org-ref-format-cite* | +| Smartcite | org-ref-cite-onclick-minibuffer-menu | org-ref-format-Smartcite | +| smartcite | org-ref-cite-onclick-minibuffer-menu | org-ref-format-smartcite | +| Textcite | org-ref-cite-onclick-minibuffer-menu | org-ref-format-Textcite | +| textcite | org-ref-cite-onclick-minibuffer-menu | org-ref-format-textcite | +| footcitetext | org-ref-cite-onclick-minibuffer-menu | org-ref-format-footcitetext | +| footcite | org-ref-cite-onclick-minibuffer-menu | org-ref-format-footcite | +| Parencite | org-ref-cite-onclick-minibuffer-menu | org-ref-format-Parencite | +| parencite | org-ref-cite-onclick-minibuffer-menu | org-ref-format-parencite | +| Cite | org-ref-cite-onclick-minibuffer-menu | org-ref-format-Cite | +| Citeauthor | org-ref-cite-onclick-minibuffer-menu | org-ref-format-Citeauthor | +| Citealp | org-ref-cite-onclick-minibuffer-menu | org-ref-format-Citealp | +| Citealt | org-ref-cite-onclick-minibuffer-menu | org-ref-format-Citealt | +| Citep | org-ref-cite-onclick-minibuffer-menu | org-ref-format-Citep | +| Citet | org-ref-cite-onclick-minibuffer-menu | org-ref-format-Citet | +| citeyear* | org-ref-cite-onclick-minibuffer-menu | org-ref-format-citeyear* | +| citeyear | org-ref-cite-onclick-minibuffer-menu | org-ref-format-citeyear | +| citeauthor* | org-ref-cite-onclick-minibuffer-menu | org-ref-format-citeauthor* | +| citeauthor | org-ref-cite-onclick-minibuffer-menu | org-ref-format-citeauthor | +| citetext | org-ref-cite-onclick-minibuffer-menu | org-ref-format-citetext | +| citenum | org-ref-cite-onclick-minibuffer-menu | org-ref-format-citenum | +| citealp* | org-ref-cite-onclick-minibuffer-menu | org-ref-format-citealp* | +| citealp | org-ref-cite-onclick-minibuffer-menu | org-ref-format-citealp | +| citealt* | org-ref-cite-onclick-minibuffer-menu | org-ref-format-citealt* | +| citealt | org-ref-cite-onclick-minibuffer-menu | org-ref-format-citealt | +| citep* | org-ref-cite-onclick-minibuffer-menu | org-ref-format-citep* | +| citep | org-ref-cite-onclick-minibuffer-menu | org-ref-format-citep | +| citet* | org-ref-cite-onclick-minibuffer-menu | org-ref-format-citet* | +| citet | org-ref-cite-onclick-minibuffer-menu | org-ref-format-citet | +| nocite | org-ref-cite-onclick-minibuffer-menu | org-ref-format-nocite | +| cite | org-ref-cite-onclick-minibuffer-menu | org-ref-format-cite | +| eqref | (lambda (label) on clicking goto the label. Navigate back with C-c & (org-mark-ring-push) (widen) (goto-char (point-min)) (if (or (re-search-forward (format label:%s label) nil t) (re-search-forward (format \label{%s} label) nil t) (re-search-forward (format ^#\+label:\s-*\(%s\)\b label) nil t)) nil (org-mark-ring-goto) (error %s not found label)) (message go back with (org-mark-ring-goto) `C-c &`)) | (lambda (keyword desc format) (cond ((eq format (quote html)) (format (%s) path)) ((eq format (quote latex)) (format \eqref{%s} keyword)))) | +| nameref | (lambda (label) on clicking goto the label. Navigate back with C-c & (org-mark-ring-push) (widen) (if (or (progn (goto-char (point-min)) (re-search-forward (format \label{%s} label) nil t))) nil (org-mark-ring-goto) (error %s not found label)) (message go back with (org-mark-ring-goto) `C-c &`)) | (lambda (keyword desc format) (cond ((eq format (quote html)) (format (%s) path)) ((eq format (quote latex)) (format \nameref{%s} keyword)))) | +| pageref | (lambda (label) on clicking goto the label. Navigate back with C-c & (org-mark-ring-push) (widen) (if (or (progn (goto-char (point-min)) (re-search-forward (format label:%s\b label) nil t)) (progn (goto-char (point-min)) (re-search-forward (format \label{%s} label) nil t)) (progn (goto-char (point-min)) (re-search-forward (format ^#\+label:\s-*\(%s\)\b label) nil t)) (progn (goto-char (point-min)) (re-search-forward (format ^#\+tblname:\s-*\(%s\)\b label) nil t))) nil (org-mark-ring-goto) (error %s not found label)) (message go back with (org-mark-ring-goto) `C-c &`)) | (lambda (keyword desc format) (cond ((eq format (quote html)) (format (%s) path)) ((eq format (quote latex)) (format \pageref{%s} keyword)))) | +| ref | (lambda (label) on clicking goto the label. Navigate back with C-c & (org-mark-ring-push) (widen) (if (or (progn (goto-char (point-min)) (re-search-forward (format label:%s\b label) nil t)) (progn (goto-char (point-min)) (re-search-forward (format \label{%s} label) nil t)) (progn (goto-char (point-min)) (re-search-forward (format ^#\+label:\s-*\(%s\)\b label) nil t)) (progn (goto-char (point-min)) (re-search-forward (format ^#\+tblname:\s-*\(%s\)\b label) nil t))) nil (org-mark-ring-goto) (error %s not found label)) (org-show-entry) (message go back with (org-mark-ring-goto) `C-c &`)) | (lambda (keyword desc format) (cond ((eq format (quote html)) (format (%s) path)) ((eq format (quote latex)) (format \ref{%s} keyword)))) | +| label | (lambda (label) on clicking count the number of label tags used in the buffer. A number greater than one means multiple labels! (message (format %s occurences (+ (count-matches (format label:%s\b[^-:] label) (point-min) (point-max) t) (count-matches (format ^#\+tblname:\s-*%s\b[^-:] label) (point-min) (point-max) t) (count-matches (format \label{%s}\b label) (point-min) (point-max) t) (count-matches (format ^#\+label:\s-*%s\b[^-:] label) (point-min) (point-max) t))))) | (lambda (keyword desc format) (cond ((eq format (quote html)) (format () path)) ((eq format (quote latex)) (format \label{%s} keyword)))) | +| list-of-tables | org-ref-list-of-tables | (lambda (keyword desc format) (cond ((eq format (quote latex)) (format \listoftables)))) | +| list-of-figures | org-ref-list-of-figures | (lambda (keyword desc format) (cond ((eq format (quote latex)) (format \listoffigures)))) | +| addbibresource | (lambda (link-string) (let* ((bibfile) (object (org-element-context)) (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))) (set (make-local-variable (quote reftex-default-addbibresource)) (split-string (org-element-property :path object) ,)) (save-excursion (if (search-forward , link-string-end 1 1) (setq key-end (- (match-end 0) 1)) (setq key-end (point)))) (save-excursion (if (search-backward , link-string-beginning 1 1) (setq key-beginning (+ (match-beginning 0) 1)) (setq key-beginning (point)))) (setq bibfile (org-ref-strip-string (buffer-substring key-beginning key-end))) (find-file bibfile))) | (lambda (keyword desc format) (cond ((eq format (quote html)) (format )) ((eq format (quote latex)) (format \addbibresource{%s} keyword)))) | +| bibliographystyle | (lambda (arg) (message Nothing implemented for clicking here.)) | (lambda (keyword desc format) (cond ((eq format (quote latex)) (format \bibliographystyle{%s} keyword)))) | +| printbibliography | (lambda (arg) (message Nothing implemented for clicking here.)) | (lambda (keyword desc format) (cond ((eq format (quote org)) (org-ref-get-org-bibliography)) ((eq format (quote html)) (org-ref-get-html-bibliography)) ((eq format (quote latex)) \printbibliography))) | +| nobibliography | (lambda (link-string) (let* ((bibfile) (object (org-element-context)) (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))) (set (make-local-variable (quote reftex-default-bibliography)) (split-string (org-element-property :path object) ,)) (save-excursion (if (search-forward , link-string-end 1 1) (setq key-end (- (match-end 0) 1)) (setq key-end (point)))) (save-excursion (if (search-backward , link-string-beginning 1 1) (setq key-beginning (+ (match-beginning 0) 1)) (setq key-beginning (point)))) (setq bibfile (org-ref-strip-string (buffer-substring key-beginning key-end))) (find-file bibfile))) | (lambda (keyword desc format) (cond ((eq format (quote org)) (org-ref-get-org-bibliography)) ((eq format (quote ascii)) (org-ref-get-ascii-bibliography)) ((eq format (quote html)) (org-ref-get-html-bibliography)) ((eq format (quote latex)) (format \nobibliography{%s} (replace-regexp-in-string \.bib (mapconcat (quote identity) (mapcar (quote expand-file-name) (split-string keyword ,)) ,)))))) | +| bibliography | (lambda (link-string) (let* ((bibfile) (object (org-element-context)) (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))) (set (make-local-variable (quote reftex-default-bibliography)) (split-string (org-element-property :path object) ,)) (save-excursion (if (search-forward , link-string-end 1 1) (setq key-end (- (match-end 0) 1)) (setq key-end (point)))) (save-excursion (if (search-backward , link-string-beginning 1 1) (setq key-beginning (+ (match-beginning 0) 1)) (setq key-beginning (point)))) (setq bibfile (org-ref-strip-string (buffer-substring key-beginning key-end))) (find-file bibfile))) | (lambda (keyword desc format) (cond ((eq format (quote org)) (org-ref-get-org-bibliography)) ((eq format (quote ascii)) (org-ref-get-ascii-bibliography)) ((eq format (quote html)) (org-ref-get-html-bibliography)) ((eq format (quote latex)) (format \bibliography{%s} (replace-regexp-in-string \.bib (mapconcat (quote identity) (mapcar (quote expand-file-name) (split-string keyword ,)) ,)))))) | +| rmail | org-rmail-open | nil | +| mhe | org-mhe-open | nil | +| irc | org-irc-visit | nil | +| info | org-info-open | nil | +| gnus | org-gnus-open | nil | +| docview | org-docview-open | org-docview-export | +| bibtex | org-bibtex-open | nil | +| bbdb | org-bbdb-open | org-bbdb-export | +| pydoc | (lambda (link-string) (shell-command (format python -m pydoc %s link-string))) | nil | +| index | (lambda (path) (tq-index) (occur path)) | nil | +| attachfile | (lambda (link-string) (org-open-file link-string)) | (lambda (keyword desc format) (cond ((eq format (quote html)) (format )) ((eq format (quote latex)) (format \attachfile{%s} keyword)))) | +| msx | org-msx-open | nil | +| id | org-id-open | nil | +| file+emacs | org-open-file-with-emacs | nil | +| file+sys | org-open-file-with-system | nil | + + * Utilities ** create simple text citation from bibtex entry @@ -2322,7 +2616,7 @@ Sometimes it may be helpful to manually change the order of citations. These fun (org-ref-swap-keys i (- i 1) keys)) (setq keys (mapconcat 'identity keys ",")) ;; and replace the link with the sorted keys - (cl--set-buffer-substring begin end (concat type ":" keys)) + (cl--set-buffer-substring begin end (concat type ":" keys " ")) ;; now go forward to key so we can move with the key (re-search-forward key) (goto-char (match-beginning 0))))) @@ -2354,7 +2648,6 @@ I like convenience. Here are some aliases for faster typing. (provide 'org-ref) #+END_SRC - * Build :noexport: [[elisp:(progn (org-babel-tangle) (load-file "org-ref.el"))]]