Skip to content

Instantly share code, notes, and snippets.

@tmalsburg
Last active April 16, 2024 09:27
Show Gist options
  • Select an option

  • Save tmalsburg/c4e8c9bc9a94a7f9faea21f1c7b2cd0f to your computer and use it in GitHub Desktop.

Select an option

Save tmalsburg/c4e8c9bc9a94a7f9faea21f1c7b2cd0f to your computer and use it in GitHub Desktop.

Revisions

  1. tmalsburg revised this gist Apr 11, 2024. 1 changed file with 6 additions and 3 deletions.
    9 changes: 6 additions & 3 deletions insert_bibtex_from_doi.el
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,20 @@
    (require 'url-http)

    (defun tmalsburg-insert-bibtex-from-doi ()
    (defun insert-bibtex-from-doi ()
    (interactive)
    (let* ((doi (string-trim (gui-get-primary-selection)))
    (url (concat "https://doi.org/" doi))
    (url (if (string-prefix-p "https://doi.org/" doi)
    doi
    (concat "https://doi.org/" doi)))
    (url-request-method "GET")
    (url-mime-accept-string "application/x-bibtex"))
    (insert
    (with-current-buffer (url-retrieve-synchronously url t)
    (with-current-buffer (url-retrieve-synchronously url t)
    (goto-char (point-min))
    (while (not (looking-at "\n"))
    (forward-line 1))
    (let ((string (buffer-substring-no-properties (point) (point-max))))
    (kill-buffer)
    (decode-coding-string (string-trim string) 'utf-8))))
    (bibtex-clean-entry t)))

  2. tmalsburg revised this gist Apr 11, 2024. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions insert_bibtex_from_doi.el
    Original file line number Diff line number Diff line change
    @@ -8,11 +8,10 @@
    (url-mime-accept-string "application/x-bibtex"))
    (insert
    (with-current-buffer (url-retrieve-synchronously url t)
    ;; (re-search-forward "^$" nil t)
    (goto-char (point-min))
    (while (not (looking-at "\n"))
    (forward-line 1))
    (let ((string (buffer-substring-no-properties (point) (point-max))))
    (kill-buffer)
    (string-trim string))))
    (decode-coding-string (string-trim string) 'utf-8))))
    (bibtex-clean-entry t)))
  3. tmalsburg revised this gist Apr 10, 2024. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions insert_bibtex_from_doi.el
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,18 @@
    (require 'url-http)

    (defun insert-bibtex-from-doi ()
    (defun tmalsburg-insert-bibtex-from-doi ()
    (interactive)
    (let* ((doi (string-trim (gui-get-primary-selection)))
    (url (concat "https://doi.org/" doi))
    (url-request-method "GET")
    (url-mime-accept-string "application/x-bibtex"))
    (insert
    (with-current-buffer (url-retrieve-synchronously url t)
    ;; (re-search-forward "^$" nil t)
    (goto-char (point-min))
    (while (not (looking-at "\n"))
    (forward-line 1))
    (let ((string (buffer-substring-no-properties (point) (point-max))))
    (kill-buffer)
    (string-trim string))))))
    (string-trim string))))
    (bibtex-clean-entry t)))
  4. tmalsburg revised this gist Apr 10, 2024. No changes.
  5. tmalsburg renamed this gist Apr 10, 2024. 1 changed file with 1 addition and 1 deletion.
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    (require 'url-http)

    (defun tmalsburg-insert-bibtex-from-doi ()
    (defun insert-bibtex-from-doi ()
    (interactive)
    (let* ((doi (string-trim (gui-get-primary-selection)))
    (url (concat "https://doi.org/" doi))
  6. tmalsburg created this gist Apr 10, 2024.
    16 changes: 16 additions & 0 deletions tmalsburg_insert_bibtex_from_doi.el
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    (require 'url-http)

    (defun tmalsburg-insert-bibtex-from-doi ()
    (interactive)
    (let* ((doi (string-trim (gui-get-primary-selection)))
    (url (concat "https://doi.org/" doi))
    (url-request-method "GET")
    (url-mime-accept-string "application/x-bibtex"))
    (insert
    (with-current-buffer (url-retrieve-synchronously url t)
    (goto-char (point-min))
    (while (not (looking-at "\n"))
    (forward-line 1))
    (let ((string (buffer-substring-no-properties (point) (point-max))))
    (kill-buffer)
    (string-trim string))))))