123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 |
- ;; Platform-specific stuff!!!!
- (setq document-view "setsid -w xdg-open %s"
- pdf-viewer "Evince" ; for C-c C-v LaTeX forward search
- keepass-folder "~/Syncthing/keepass/"
- bibliography-folder "~/Documents/bibliography/"
- biblio-key (kbd "<f12>") ; use <apps> for the menu button in
- ; other OS's, or for example <f12> for
- ; Termux and see its wiki for showing
- ; this button on its interface. Also
- ; <X86Launch1> works in Mate desktop,
- ; but not terminals.
- windmove-key 'shift ; for 'shift, see
- ; https://emacs.stackexchange.com/a/54002
- ;; browse-url-browser-function 'browse-url-xdg-open ; in termux
- org-replace-disputed-keys t ; for windmove when using 'shift
- want-to-use-xclip nil ; termux clipboard, install termux-api too
- )
- ;; Computed stuff:
- (setq own-calendar-file (concat keepass-folder "calendar.org")
- own-bookmark-file (concat keepass-folder "bookmarks.org")
- bibliography-file (concat bibliography-folder "references.bib")
- bibliography-pdf-folder (concat bibliography-folder "bibtex-pdfs/")
- bibliography-notes (concat bibliography-folder "notes.org"))
- ;; Defer loading packages unless daemon
- (setq use-package-always-demand (daemonp))
- ;; Always revert files, i.e. reload them to buffers if emacs notices
- ;; them changing by e.g. an external program.
- (global-auto-revert-mode 1)
- ;; Load the MELPA package library
- (require 'package)
- (add-to-list 'package-archives '("melpa"
- . "https://melpa.org/packages/") t)
- (package-initialize)
- ;; Download and load use-package
- (unless (package-installed-p 'use-package)
- (package-install 'use-package))
- ;;;;;;;;;;;;;;;;;;;;;;;
- ;;;; Email related ;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;
- (setq mail-user-agent 'gnus-user-agent
- epg-pinentry-mode 'loopback) ; Avoids GPG password input entry
- ; issue in emacs termux. Might need
- ; to edit .gnupeg/gpg-agent.conf
- ; and add "allow-emacs-pinentry"
- ;; BBDB settings
- (use-package bbdb
- :ensure t
- :custom
- (bbdb-file (concat keepass-folder "bbdb"))
- (bbdb-mua-pop-up t) ; Display BBDB in popup window
- (bbdb-mua-pop-up-window-size 3)
- (bbdb-mua-update-interactive-p
- '(query . create)) ; Look for existing contact, interactively
- ; prompt to create
- :config
- (bbdb-initialize 'gnus 'message)
- (bbdb-mua-auto-update-init 'gnus 'message))
- ;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;; Appearance related ;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Nyan-mode.
- (use-package nyan-mode
- :ensure t
- :config
- (nyan-mode 1)
- (nyan-start-animation)
- ;; Install sox in termux to play music and uncomment below.
- ;; (defun nyan-start-music ()
- ;; (interactive)
- ;; (unless nyan-music-process
- ;; (setq nyan-music-process (start-process-shell-command "nyan-music" "nyan-music" (concat "play " +nyan-music+ " repeat 9001")))))
- )
- ;; Theme
- (use-package nord-theme ; Good candidates: nord-theme, dracula-theme
- :ensure t
- :config
- (enable-theme 'nord))
- ;; Color issues
- (setq shr-use-colors nil) ; Don't use text color when rendering html
- ; using shr (links ok)
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;; Emacs buffer etc. behaviour ;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Expand region
- (use-package expand-region
- :ensure t
- :config
- (global-set-key (kbd "<f11>") 'er/expand-region)
- (delete-selection-mode t) ; typed text replaces the selection
- )
- ;; Smartparens
- (use-package smartparens
- :ensure t
- :hook
- ((lisp-mode emacs-lisp-mode gfm-mode markdown-mode LaTeX-mode)
- . show-paren-mode)
- ((lisp-mode emacs-lisp-mode gfm-mode markdown-mode LaTeX-mode)
- . smartparens-mode)
- :config
- (sp-local-pair '(lisp-mode emacs-lisp-mode) "'" nil :actions nil)
- (sp-local-pair '(lisp-mode emacs-lisp-mode) "`" nil :actions nil)
- )
- (winner-mode t) ; C-c ←/→ for going between used window configurations
- (setq-default word-wrap t)
- (defun unfill-paragraph () ; for copy-pasting to external program
- "Takes a multi-line paragraph and makes it into a single line of text."
- (interactive)
- (let ((fill-column (point-max)))
- (fill-paragraph nil)))
- (define-key global-map "\M-Q" 'unfill-paragraph) ; alt+shift+q
- ;; Sort words
- ;; https://www.emacswiki.org/emacs/SortWords
- (defun sort-words (reverse beg end)
- "Sort words in region alphabetically, in REVERSE if negative.
- Prefixed with negative \\[universal-argument], sorts in reverse.
-
- The variable `sort-fold-case' determines whether alphabetic case
- affects the sort order.
-
- See `sort-regexp-fields'."
- (interactive "*P\nr")
- (sort-regexp-fields reverse "\\w+" "\\&" beg end))
- (windmove-default-keybindings windmove-key)
- (setq mouse-yank-at-point t) ; Use current cursor position for middle
- ; mouse pasting instead of jumping to new
- ; location then paste
- ;; F9 opens file where we save www-bookmarks
- (global-set-key (kbd "<f9>") (lambda() (interactive)(find-file own-bookmark-file)))
- ;; Xclip
- (when want-to-use-xclip
- (use-package xclip
- :ensure t
- :config
- (xclip-mode 1)
- ))
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;; Coding related ;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;
- (global-set-key "\C-x\C-m" 'compile) ; C-x C-m compile
- (setq compilation-read-command nil ; compile with "make -k"
- compilation-scroll-output t) ; autoscroll compilation buffer
- (use-package magit
- :ensure t
- :bind
- ("C-x g" . magit-status))
- (use-package company ; Company (complete anything) mode
- :ensure t
- :hook
- ((latex-mode LaTeX-mode emacs-lisp-mode) . company-mode)
- ((latex-mode LaTeX-mode) . (lambda ()
- (set (make-local-variable 'company-backends)
- '((company-dabbrev)))))
- :custom
- (company-tooltip-align-annotations 1)
- (company-minimum-prefix-length 1)
- (company-idle-delay 0.0)
- (company-selection-wrap-around t)
- (company-dabbrev-ignore-case nil)
- (company-dabbrev-downcase nil)
- :config
- (company-tng-mode)
- (define-key company-active-map [up] nil)
- (define-key company-active-map [down] nil))
- (use-package slime ; SLIME (Common LISP)
- :ensure t
- :custom
- (inferior-lisp-program "clisp")
- :config
- (slime-setup '(slime-fancy)))
- (use-package slime-company
- :ensure t
- :after (slime company)
- :custom
- (slime-company-completion 'fuzzy)
- :config
- (slime-setup '(slime-company)))
- (use-package geiser-chez ; For Chez Scheme, start M-x run-geiser
- :ensure t)
- (use-package markdown-mode
- :ensure t
- :mode ("README\\.md\\'" . gfm-mode)
- :custom
- (markdown-command "pandoc"))
- ;; Indentation & behaviour
- (setq-default indent-tabs-mode nil
- standard-indent 2)
- ;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;; LaTeX / math related ;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (add-to-list 'auto-mode-alist '("\\.m\\'" . octave-mode))
- (setq bibtex-align-at-equal-sign t) ; align = in bibtex using C-c C-q
- (use-package tex
- :ensure auctex
- :custom
- (TeX-source-correlate-mode t) ; for forward search
- :config
- (add-to-list 'TeX-view-program-selection
- `(output-pdf ,pdf-viewer)) ; ` is like quote but allows
- ; evaluation inside using ,
- :hook
- ; Make \ part of words in LaTeX-mode
- ((latex-mode LaTeX-mode) . (lambda () (modify-syntax-entry
- (string-to-char TeX-esc)
- "w"
- LaTeX-mode-syntax-table))))
- (use-package reftex
- :ensure t
- :hook
- ((latex-mode LaTeX-mode) . turn-on-reftex))
- (use-package bibtex
- :custom
- ;; Ignore only lower case title words instead of all non-uppercased
- ;; ones when generating keys for bibtex
- (bibtex-autokey-titleword-ignore
- '("A" "An" "On" "The" "Eine?" "Der" "Die" "Das" "[[:lower:]].*" ".*[^[:upper:][:lower:]0-9].*")))
- ;; Helm-bibtex
- (use-package helm-bibtex
- :ensure t
- :demand t ; otherwise biblio-key will be bound to void
- :init ; can't have a form like biblio-key under :bind
- (bind-key biblio-key 'helm-command-prefix)
- :config
- (define-key helm-command-map biblio-key 'helm-resume)
- :bind
- (:map helm-command-map
- ("b" . helm-bibtex)
- ("B" . helm-bibtex-with-local-bibliography)
- ("n" . helm-bibtex-with-notes))
- ;; (define-key helm-command-map (kbd "<f12>") 'helm-resume)
- :custom
- (bibtex-completion-bibliography
- (list ; needs (list ...) for new org-ref to work
- bibliography-file))
- (bibtex-completion-library-path
- (list ; needs (list ...) for new org-ref to work
- bibliography-pdf-folder))
- (bibtex-completion-pdf-extension '(".pdf" ".djvu"))
- (bibtex-completion-pdf-open-function 'org-open-file)
- (bibtex-completion-notes-path bibliography-notes)
- (bibtex-completion-additional-search-fields '(keywords tags))
- (bibtex-completion-pdf-field "File")
- (bibtex-completion-pdf-symbol "⌘")
- (bibtex-completion-notes-symbol "✎")
- )
- (use-package org-ref ; Includes doi-utils
- :ensure t
- :custom
- ;; Words which shouldn't be capitalized in titles
- (org-ref-lower-case-words '("a" "an" "at" "on" "and" "for" "the" "of" "in"))
- ;; Allow the following fields Into Title Case of the Following Items
- (org-ref-title-case-types '(("article" "title")
- ("book" "booktitle")
- ("misc" "title")))
- ;; Don't convert ä,ö,å, etc when org-ref-clean-bibtex-entry
- (org-ref-clean-bibtex-entry-hook
- '(org-ref-bibtex-format-url-if-doi orcb-key-comma orcb-& orcb-% org-ref-title-case orcb-clean-year orcb-key orcb-clean-doi orcb-clean-pages orcb-check-journal org-ref-sort-bibtex-entry orcb-fix-spacing orcb-download-pdf)))
- (use-package scihub
- :ensure t
- :custom
- (scihub-download-directory (car bibtex-completion-library-path))
- (scihub-open-after-download nil)
- (scihub-fetch-domain 'scihub-fetch-domains-lovescihub))
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;; Org-mode related ;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;
- (use-package org
- :ensure t
- :bind
- ("C-c l" . org-store-link)
- ("C-c a" . org-agenda)
- ("C-c c" . org-capture)
- :custom
- (org-agenda-files (list own-calendar-file))
- (org-agenda-start-on-weekday 1) ; nil means current day
- (org-agenda-span 7)
- (org-refile-targets '((org-agenda-files :maxlevel . 9)))
- (org-reverse-note-order t) ; refiles to top instead of bottom
- (org-archive-reversed-order t) ; same for archiving with C-c C-x A
- (org-refile-use-outline-path t)
- (org-todo-keywords
- '((sequence "TODO(t)" "WAIT(w!/!)" "MEET(m)" "IDEA(i)"
- "|" "DONE(d)" "CANCELLED(c@)")))
- (org-log-done 'time)
- ;; See see http://cachestocaches.com/2016/9/my-workflow-org-agenda/
- (org-capture-templates
- '(("t" "todo" entry (file+headline own-calendar-file "Unclassified")
- "* TODO %? %A")
- ("m" "Meeting" entry (file+headline own-calendar-file "Unclassified")
- "* MEET %? %A")
- ("b" "Bookmark" entry (file+headline own-bookmark-file "Bookmarks")
- "* %x %?%^g\n:PROPERTIES:\n:CREATED: %U\n:END:\n\n" :empty-lines-before 1)
- ("n" "Pdf note from email" plain (file bibliography-file)
- "@misc{????,\nauthor = {%^{author}},\nday = %^{day},\nmonth = %^{month},\nyear = %^{year},\ntags = {%^{comma-separated tags}},\ntitle = {%\\4/%\\3/%\\2 Notes - %^{topic (remember to save the PDF from email!!)}},\nurl = %l\n}\n\n" :empty-lines 1 :before-finalize org-ref-clean-bibtex-entry :immediate-finish 1)))
- ;; Org & agendar look
- (org-todo-keyword-faces '(("MEET" .
- (:foreground "#486f66"
- :background "#f4bbce"
- :weight ultra-bold))))
- (org-agenda-prefix-format
- '((agenda . " %i %?-12t% s") ; default: " %i %-12:c%?-12t% s"
- (todo . " %i %-12:c")
- (tags . " %i %-12:c")
- (search . " %i %-12:c")))
- (org-agenda-remove-tags t)
- :config
- ;; Open pdf & djvu outside emacs
- (defun alist-set (KEY PROP ALIST)
- (set ALIST (assoc-delete-all KEY (symbol-value ALIST)))
- (add-to-list ALIST (cons KEY PROP)))
- (alist-set "\\.pdf\\'" document-view 'org-file-apps)
- (alist-set "\\.djvu\\'" document-view 'org-file-apps)
- ;; C-c C- s RET inserts block. See ":exports both" for results.
- (org-babel-do-load-languages
- 'org-babel-load-languages
- '((calc . t)
- (octave . t)
- (R . t)
- (python . t) ; see https://emacs.stackexchange.com/a/64539
- (shell . t)))
- (setq org-babel-python-command
- "python3") ; add ":python python" to block for python2
- )
- ;;;;;;;;;;;;;;;;;;;;;;;;;;
- (custom-set-variables
- ;; custom-set-variables was added by Custom.
- ;; If you edit it by hand, you could mess it up, so be careful.
- ;; Your init file should contain only one such instance.
- ;; If there is more than one, they won't work right.
- '(bbdb-mua-interactive-action '(query . create) nil nil "Customized with use-package bbdb")
- '(custom-safe-themes
- '("4c7228157ba3a48c288ad8ef83c490b94cb29ef01236205e360c2c4db200bb18" default)))
- (custom-set-faces
- ;; custom-set-faces was added by Custom.
- ;; If you edit it by hand, you could mess it up, so be careful.
- ;; Your init file should contain only one such instance.
- ;; If there is more than one, they won't work right.
- )
|