Skip to content

Commit

Permalink
fix org insert heading
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandrogallo committed Feb 20, 2024
1 parent 08b2f36 commit a396a45
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 22 deletions.
12 changes: 6 additions & 6 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ And to add these kind of lines you can use this function
(insert "#+transclude: [[papis:")
(insert (papis-doc-id doc))
(insert "][")
(insert (papis--doc-get doc "title"))
(insert (papis-doc-get doc "title"))
(insert "]]")
(insert " :expand-links")
(org-transclusion-add))
Expand Down Expand Up @@ -505,11 +505,11 @@ You can use the following function to create a link with properties
#+begin_src emacs-lisp
(defun papis-org-insert-heading (doc)
(interactive (list (papis--read-doc)))
(let ((title (papis--doc-get doc "title"))
(author (papis--doc-get doc "author"))
(year (papis--doc-get doc "year"))
(doi (papis--doc-get doc "doi"))
(papis-id (papis--doc-get doc "papis_id")))
(let ((title (papis-doc-get doc "title"))
(author (papis-doc-get doc "author"))
(year (papis-doc-get doc "year"))
(doi (papis-doc-get doc "doi"))
(papis-id (papis-doc-get doc "papis_id")))
(org-insert-heading)
(insert (format "[[papis:%s][%s]]" papis-id title))
(org-set-property "PAPIS_ID" papis-id)
Expand Down
54 changes: 38 additions & 16 deletions papis.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

;; Generalities

;; - We interact with papis through the papis' json exporter.
;; - We use ~org-links~ to get information directly from papis.
Expand All @@ -18,6 +18,9 @@
"https://github.com/papis/papis.el"))
;; Generalities:1 ends here

;; Variables


;; [[file:README.org::*Variables][Variables:1]]
(defvar papis--temp-output-file nil
"This variable holds the papis temporary output file where the json
Expand Down Expand Up @@ -56,6 +59,8 @@
:group 'papis)
;; =papis-library=:2 ends here

;; Document

;; [[file:README.org::*Document][Document:1]]
(defun papis-doc-get-folder (doc)
(papis-doc-get doc "_papis_local_folder"))
Expand Down Expand Up @@ -89,7 +94,7 @@
(papis--cmd (concat "update --doc-folder " folder))))
;; Document:3 ends here


;; Introduction
;; Most papis commands will need a query, the macro =@papis-query= will
;; take care of having the same query prompt in all commands.

Expand All @@ -98,9 +103,9 @@
`(interactive ,papis--query-prompt))
;; Introduction:1 ends here


;; The main interface with papis commands will be =papis--cmd=
;; which is a function intended for library writers.
;; Issuing commands to the shell
;; The main interface with papis commands will be =papis--cmd=
;; which is a function intended for library writers.

;; [[file:README.org::*Issuing commands to the shell][Issuing commands to the shell:1]]
(cl-defun papis--cmd (cmd &optional with-stdout)
Expand All @@ -117,7 +122,7 @@
full-cmd)))
;; Issuing commands to the shell:1 ends here


;; =papis-query=

;; A papis document object is represented in =papis.el=
;; as a =hashtable=, and the command that turns a query
Expand All @@ -143,7 +148,7 @@
:doc-folder doc-folder)))
;; =papis-query=:1 ends here


;; =papis-open=

;; The cornerstone of papis is opening documents, in emacs
;; the command is also available:
Expand Down Expand Up @@ -182,6 +187,9 @@
(find-file file)))
;; =papis-open=:1 ends here

;; Notes


;; [[file:README.org::*Notes][Notes:1]]
(defcustom papis-edit-new-notes-hook nil
"Hook for when a new note file is being edited.
Expand Down Expand Up @@ -230,7 +238,7 @@
(find-file notes-path))))
;; Notes:1 ends here


;; TODO =papis-edit=

;; You can edit the info files using =papis-edit=,
;; notice that commiting the
Expand All @@ -256,6 +264,9 @@
(papis-edit-mode)))
;; =papis-edit=:1 ends here

;; =papis-exec=


;; [[file:README.org::*=papis-exec=][=papis-exec=:1]]
(defun papis-exec (python-file &optional arguments)
(let ((fmt "exec %s %s"))
Expand All @@ -265,6 +276,9 @@
t)))
;; =papis-exec=:1 ends here

;; =papis-export=


;; [[file:README.org::*=papis-export=][=papis-export=:1]]
(progn
(defmacro papis--make-exporter (format-name)
Expand All @@ -286,7 +300,7 @@
(papis--make-exporter json))
;; =papis-export=:1 ends here


;; Document reader

;; The main dynamic searcher used in =papis.el= uses
;; the function =papis-default-read-format-function=.
Expand Down Expand Up @@ -354,6 +368,9 @@
formatted-results)))))))
;; Document reader:2 ends here

;; =papis=


;; [[file:README.org::*=papis=][=papis=:1]]
(require 'ol-doi)
(org-link-set-parameters "papis"
Expand All @@ -378,7 +395,7 @@
(doi (org-link-doi-export doi description format info)))))
;; =papis=:1 ends here


;; Paper sections
;; When doing research, often you would like to create some notes on every paper
;; and write some sections with the section titles being links to the papers
;; with some properties so that you can use org-mode's colum mode.
Expand All @@ -389,11 +406,11 @@
;; [[file:README.org::*Paper sections][Paper sections:1]]
(defun papis-org-insert-heading (doc)
(interactive (list (papis--read-doc)))
(let ((title (papis--doc-get doc "title"))
(author (papis--doc-get doc "author"))
(year (papis--doc-get doc "year"))
(doi (papis--doc-get doc "doi"))
(papis-id (papis--doc-get doc "papis_id")))
(let ((title (papis-doc-get doc "title"))
(author (papis-doc-get doc "author"))
(year (papis-doc-get doc "year"))
(doi (papis-doc-get doc "doi"))
(papis-id (papis-doc-get doc "papis_id")))
(org-insert-heading)
(insert (format "[[papis:%s][%s]]" papis-id title))
(org-set-property "PAPIS_ID" papis-id)
Expand All @@ -418,7 +435,7 @@
(_ (completing-read "" files)))))
;; Open pdfs:2 ends here


;; Citations
;; In general it is recommended to use the citation mechanisms of
;; =org-ref=, however, if for some reason you would like to cite
;; directly from =papis=, you can use the function
Expand Down Expand Up @@ -486,6 +503,9 @@ for d in docs:
(papis-exec py-script (s-join " " refs))))
;; Convert references into bibtex entries:3 ends here

;; The =papis-bibtex-refs= dynamic block


;; [[file:README.org::*The =papis-bibtex-refs= dynamic block][The =papis-bibtex-refs= dynamic block:1]]
(defun papis-create-papis-bibtex-refs-dblock (bibfile)
(insert (format "#+begin: papis-bibtex-refs :tangle %s" bibfile))
Expand Down Expand Up @@ -518,6 +538,8 @@ for d in docs:
(insert "#+end_src\n"))
;; The =papis-bibtex-refs= dynamic block:2 ends here

;; End

;; [[file:README.org::*End][End:1]]
(provide 'papis)
;; End:1 ends here

0 comments on commit a396a45

Please sign in to comment.