summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2022-11-20 19:19:19 +0000
committerYann Herklotz <git@yannherklotz.com>2022-11-20 19:19:19 +0000
commitbf2f053d5462fe2a0824297de4a1b425725091f3 (patch)
tree453a5fa4e9264f4e23c664a282cd759ce2b606b3
parentcc377eda73d79a6bb92289ff1e8a335d58611159 (diff)
downloadymh-emacs-bf2f053d5462fe2a0824297de4a1b425725091f3.tar.gz
ymh-emacs-bf2f053d5462fe2a0824297de4a1b425725091f3.zip
Add documentation and reindent properly
-rw-r--r--init.el233
1 files changed, 117 insertions, 116 deletions
diff --git a/init.el b/init.el
index 8762251..de15961 100644
--- a/init.el
+++ b/init.el
@@ -6,6 +6,7 @@
(setq gc-cons-threshold (* 1024 1024 1024))
(defun ymhg/prev-window ()
+ "Go to the previous window using `other-window'."
(interactive)
(other-window -1))
@@ -25,13 +26,13 @@
(s-trim (shell-command-to-string (concat "pass show " query))))
(defun ymhg/apply-theme (appearance)
- "Load theme, taking current system APPEARANCE into consideration."
- (mapc #'disable-theme custom-enabled-themes)
- (pcase appearance
- ;;('light (load-theme 'modus-operandi t))
- ;;('dark (load-theme 'modus-vivendi t))
- ('light (load-theme 'ef-spring t))
- ('dark (load-theme 'ef-autumn t))))
+ "Load theme, taking current system APPEARANCE into consideration."
+ (mapc #'disable-theme custom-enabled-themes)
+ (pcase appearance
+ ;;('light (load-theme 'modus-operandi t))
+ ;;('dark (load-theme 'modus-vivendi t))
+ ('light (load-theme 'ef-spring t))
+ ('dark (load-theme 'ef-autumn t))))
(global-set-key (kbd "M-u") #'upcase-dwim)
(global-set-key (kbd "M-l") #'downcase-dwim)
@@ -184,17 +185,17 @@
:straight nil
:init
(setq browse-url-handlers
- '(("wikipedia\\.org" . eww-browse-url)
- ("yannherklotz\\.com" . eww-browse-url)
- ("ymhg\\.org" . eww-browse-url)
- ("archlinux\\.org" . eww-browse-url)
- ("sachachua\\.com" . eww-browse-url)
- ("comonad\\.com" . eww-browse-url)
- ("drewdevault\\.com" . eww-browse-url)
- ("wordpress\\.com" . eww-browse-url)
- ("mathbabe\\.org" . eww-browse-url)
- ("ethz\\.ch" . eww-browse-url)
- ("pragmaticemacs\\.com" . eww-browse-url))))
+ '(("wikipedia\\.org" . eww-browse-url)
+ ("yannherklotz\\.com" . eww-browse-url)
+ ("ymhg\\.org" . eww-browse-url)
+ ("archlinux\\.org" . eww-browse-url)
+ ("sachachua\\.com" . eww-browse-url)
+ ("comonad\\.com" . eww-browse-url)
+ ("drewdevault\\.com" . eww-browse-url)
+ ("wordpress\\.com" . eww-browse-url)
+ ("mathbabe\\.org" . eww-browse-url)
+ ("ethz\\.ch" . eww-browse-url)
+ ("pragmaticemacs\\.com" . eww-browse-url))))
(use-package message
:straight nil
@@ -634,9 +635,9 @@ https://yannherklotz.com"))
(:name "all recent" :query "date:last_month..this_month" :key "r")))
(setq notmuch-fcc-dirs
- '(("yann@yannherklotz.com" . "mailbox/Sent -inbox +sent -unread +mailbox -new")
- ("git@ymhg.org" . "mailbox/Sent -inbox +sent -unread +mailbox -new")
- ("yann.herklotz15@imperial.ac.uk" . "\"imperial/Sent Items\" -inbox +sent -unread +imperial -new")))
+ '(("yann@yannherklotz.com" . "mailbox/Sent -inbox +sent -unread +mailbox -new")
+ ("git@ymhg.org" . "mailbox/Sent -inbox +sent -unread +mailbox -new")
+ ("yann.herklotz15@imperial.ac.uk" . "\"imperial/Sent Items\" -inbox +sent -unread +imperial -new")))
(setq +notmuch-home-function (lambda () (notmuch-search "tag:inbox"))))
@@ -673,101 +674,101 @@ https://yannherklotz.com"))
(define-key ebib-index-mode-map "D" #'ebib-download-pdf-from-doi)
(defun sci-hub-pdf-url (doi)
- "Get url to the pdf from SCI-HUB using DOI."
- (setq *doi-utils-pdf-url* (concat "https://sci-hub.hkvisa.net/" doi) ;captcha
- *doi-utils-waiting* t
- )
- ;; try to find PDF url (if it exists)
- (url-retrieve (concat "https://sci-hub.hkvisa.net/" doi)
- (lambda (_)
- (goto-char (point-min))
- (while (search-forward-regexp
- "\\(https:\\|sci-hub.hkvisa.net/downloads\\).+download=true'" nil t)
- (let ((foundurl (match-string 0)))
- (message foundurl)
- (if (string-match "https:" foundurl)
- (setq *doi-utils-pdf-url* foundurl)
- (setq *doi-utils-pdf-url* (concat "https:" foundurl))))
- (setq *doi-utils-waiting* nil))))
- (while *doi-utils-waiting* (sleep-for 0.1))
- (replace-regexp-in-string "\\\\" "" *doi-utils-pdf-url*))
-
-(defun acm-pdf-url (doi)
- "Retrieve a DOI pdf from the ACM."
- (concat "https://dl.acm.org/doi/pdf/" doi))
-
-(defun ieee-pdf-url (doi)
- "Retrieve a DOI pdf from the IEEE."
- (when (string-match "\\.\\([0-9]*\\)$" doi)
- (let ((doi-bit (match-string 1 doi)))
- (concat "https://ieeexplore.ieee.org/stampPDF/getPDF.jsp?tp=&arnumber=" doi-bit "&ref="))))
-
-(defun springer-pdf-url (doi)
- "Retrieve a DOI pdf from the Springer."
- (concat "https://link.springer.com/content/pdf/" doi ".pdf"))
-
-(defun arxiv-pdf-url (epr)
- (concat "https://arxiv.org/pdf/" epr ".pdf"))
-
-(defun download-pdf-from-doi (key &optional doi publisher eprint journal organization url)
- "Download pdf from doi with KEY name."
- (let ((pub (or publisher ""))
- (epr (or eprint ""))
- (jour (or journal ""))
- (org (or organization ""))
- (link (or url "")))
- (url-copy-file (cond
- ((not doi) link)
- ((or (string-match "ACM" (s-upcase pub))
- (string-match "association for computing machinery" (s-downcase pub)))
- (acm-pdf-url doi))
- ((string-match "arxiv" (s-downcase pub))
- (arxiv-pdf-url epr))
- ((or (string-match "IEEE" (s-upcase pub))
- (string-match "IEEE" (s-upcase jour))
- (string-match "IEEE" (s-upcase org)))
- (ieee-pdf-url doi))
- ((string-match "springer" (s-downcase pub))
- (springer-pdf-url doi))
- (t (sci-hub-pdf-url doi)))
- (concat (car ebib-file-search-dirs) "/" key ".pdf"))))
-
-(defun download-pdf-from-link (link key)
- (url-copy-file link
- (concat (car ebib-file-search-dirs) "/" key ".pdf")))
-
-(defun download-pdf-from-downloads (key)
- (copy-file (concat "~/Downloads/" key ".pdf")
- (concat (car ebib-file-search-dirs) "/" key ".pdf") t))
-
-(defun get-bib-from-doi (doi)
- "Get the bibtex from DOI."
- (shell-command (concat "curl -L -H \"Accept: application/x-bibtex; charset=utf-8\" "
- "https://doi.org/" doi)))
-
-(defun ebib-download-pdf-from-doi ()
- "Download a PDF for the current entry."
- (interactive)
- (let* ((key (ebib--get-key-at-point))
- (doi (ebib-get-field-value "doi" key ebib--cur-db 'noerror 'unbraced 'xref))
- (publisher (ebib-get-field-value "publisher" key ebib--cur-db 'noerror 'unbraced 'xref))
- (eprinttype (ebib-get-field-value "eprinttype" key ebib--cur-db 'noerror 'unbraced 'xref))
- (eprint (ebib-get-field-value "eprint" key ebib--cur-db 'noerror 'unbraced 'xref))
- (journal (ebib-get-field-value "journal" key ebib--cur-db 'noerror 'unbraced 'xref))
- (journaltitle (ebib-get-field-value "journaltitle" key ebib--cur-db 'noerror 'unbraced 'xref))
- (organization (ebib-get-field-value "organization" key ebib--cur-db 'noerror 'unbraced 'xref))
- (url (ebib-get-field-value "url" key ebib--cur-db 'noerror 'unbraced 'xref)))
- (unless key
- (error "[Ebib] No key assigned to entry"))
- (download-pdf-from-doi key doi (or publisher eprinttype) eprint (or journal journaltitle) organization url)))
-
-(defun ebib-check-file ()
- "Download a PDF for the current entry."
- (interactive)
- (let ((key (ebib--get-key-at-point)))
- (unless (file-exists-p (concat (car ebib-file-search-dirs) "/" key ".pdf"))
- (error "[Ebib] No PDF found."))
- t)))
+ "Get url to the pdf from SCI-HUB using DOI."
+ (setq *doi-utils-pdf-url* (concat "https://sci-hub.hkvisa.net/" doi) ;captcha
+ *doi-utils-waiting* t
+ )
+ ;; try to find PDF url (if it exists)
+ (url-retrieve (concat "https://sci-hub.hkvisa.net/" doi)
+ (lambda (_)
+ (goto-char (point-min))
+ (while (search-forward-regexp
+ "\\(https:\\|sci-hub.hkvisa.net/downloads\\).+download=true'" nil t)
+ (let ((foundurl (match-string 0)))
+ (message foundurl)
+ (if (string-match "https:" foundurl)
+ (setq *doi-utils-pdf-url* foundurl)
+ (setq *doi-utils-pdf-url* (concat "https:" foundurl))))
+ (setq *doi-utils-waiting* nil))))
+ (while *doi-utils-waiting* (sleep-for 0.1))
+ (replace-regexp-in-string "\\\\" "" *doi-utils-pdf-url*))
+
+ (defun acm-pdf-url (doi)
+ "Retrieve a DOI pdf from the ACM."
+ (concat "https://dl.acm.org/doi/pdf/" doi))
+
+ (defun ieee-pdf-url (doi)
+ "Retrieve a DOI pdf from the IEEE."
+ (when (string-match "\\.\\([0-9]*\\)$" doi)
+ (let ((doi-bit (match-string 1 doi)))
+ (concat "https://ieeexplore.ieee.org/stampPDF/getPDF.jsp?tp=&arnumber=" doi-bit "&ref="))))
+
+ (defun springer-pdf-url (doi)
+ "Retrieve a DOI pdf from the Springer."
+ (concat "https://link.springer.com/content/pdf/" doi ".pdf"))
+
+ (defun arxiv-pdf-url (epr)
+ (concat "https://arxiv.org/pdf/" epr ".pdf"))
+
+ (defun download-pdf-from-doi (key &optional doi publisher eprint journal organization url)
+ "Download pdf from doi with KEY name."
+ (let ((pub (or publisher ""))
+ (epr (or eprint ""))
+ (jour (or journal ""))
+ (org (or organization ""))
+ (link (or url "")))
+ (url-copy-file (cond
+ ((not doi) link)
+ ((or (string-match "ACM" (s-upcase pub))
+ (string-match "association for computing machinery" (s-downcase pub)))
+ (acm-pdf-url doi))
+ ((string-match "arxiv" (s-downcase pub))
+ (arxiv-pdf-url epr))
+ ((or (string-match "IEEE" (s-upcase pub))
+ (string-match "IEEE" (s-upcase jour))
+ (string-match "IEEE" (s-upcase org)))
+ (ieee-pdf-url doi))
+ ((string-match "springer" (s-downcase pub))
+ (springer-pdf-url doi))
+ (t (sci-hub-pdf-url doi)))
+ (concat (car ebib-file-search-dirs) "/" key ".pdf"))))
+
+ (defun download-pdf-from-link (link key)
+ (url-copy-file link
+ (concat (car ebib-file-search-dirs) "/" key ".pdf")))
+
+ (defun download-pdf-from-downloads (key)
+ (copy-file (concat "~/Downloads/" key ".pdf")
+ (concat (car ebib-file-search-dirs) "/" key ".pdf") t))
+
+ (defun get-bib-from-doi (doi)
+ "Get the bibtex from DOI."
+ (shell-command (concat "curl -L -H \"Accept: application/x-bibtex; charset=utf-8\" "
+ "https://doi.org/" doi)))
+
+ (defun ebib-download-pdf-from-doi ()
+ "Download a PDF for the current entry."
+ (interactive)
+ (let* ((key (ebib--get-key-at-point))
+ (doi (ebib-get-field-value "doi" key ebib--cur-db 'noerror 'unbraced 'xref))
+ (publisher (ebib-get-field-value "publisher" key ebib--cur-db 'noerror 'unbraced 'xref))
+ (eprinttype (ebib-get-field-value "eprinttype" key ebib--cur-db 'noerror 'unbraced 'xref))
+ (eprint (ebib-get-field-value "eprint" key ebib--cur-db 'noerror 'unbraced 'xref))
+ (journal (ebib-get-field-value "journal" key ebib--cur-db 'noerror 'unbraced 'xref))
+ (journaltitle (ebib-get-field-value "journaltitle" key ebib--cur-db 'noerror 'unbraced 'xref))
+ (organization (ebib-get-field-value "organization" key ebib--cur-db 'noerror 'unbraced 'xref))
+ (url (ebib-get-field-value "url" key ebib--cur-db 'noerror 'unbraced 'xref)))
+ (unless key
+ (error "[Ebib] No key assigned to entry"))
+ (download-pdf-from-doi key doi (or publisher eprinttype) eprint (or journal journaltitle) organization url)))
+
+ (defun ebib-check-file ()
+ "Download a PDF for the current entry."
+ (interactive)
+ (let ((key (ebib--get-key-at-point)))
+ (unless (file-exists-p (concat (car ebib-file-search-dirs) "/" key ".pdf"))
+ (error "[Ebib] No PDF found."))
+ t)))
(use-package spell-fu
:config