123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520 |
- ;; 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")
- gtd-folder (concat keepass-folder "gtd/")
- gtd-inbox (concat gtd-folder "inbox.org")
- gtd-gtd (concat gtd-folder "gtd.org")
- gtd-someday (concat gtd-folder "someday.org")
- gtd-archive (concat gtd-folder "archive.org")
- gtd-tickler (concat gtd-folder "tickler.org")
- bibliography-file (concat bibliography-folder "references.bib")
- bibliography-pdf-folder (concat bibliography-folder "bibtex-pdfs/")
- bibliography-notes (concat bibliography-folder "bibtex-notes/"))
- ;; 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))
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; General text file handling ;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Coding system
- (modify-coding-system-alist 'file "" 'utf-8)
- (setq-default buffer-file-coding-system 'utf-8)
- (add-to-list 'safe-local-variable-values '(buffer-file-coding-system . utf-8))
- ;; Backups into ~/.emacs-saves
- (unless (file-exists-p "~/.saves-emacs")
- (make-directory "~/.saves-emacs"))
- (setq backup-directory-alist '(("." . "~/.saves-emacs"))
- backup-by-copying t
- delete-old-versions t
- kept-new-versions 6
- kept-old-versions 2
- version-control t)
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;
- ;;;; 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)
- (use-package theme-changer
- :ensure t
- :after nord-theme
- :config
- (setq calendar-location-name "Espoo")
- (setq calendar-latitude 60.18)
- (setq calendar-longitude 24.82)
- (change-theme nil 'nord))
- ;; Color issues
- (setq shr-use-colors nil) ; Don't use text color when rendering html
- ; using shr (links ok)
- ;; Olivetti mode for org-mode etc long texts.
- ;; Add
- ;; ((nil . ((fill-column . 80)
- ;; (mode . olivetti))))
- ;; inside a folder's .dir-locals.el to use olivetti for all files there
- (use-package olivetti
- :ensure t
- :hook
- ((latex-mode LaTeX-mode) . olivetti-mode))
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;; 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)
- )
- ;; Helm (completion framework)
- (use-package helm
- :ensure t
- :bind (("M-x" . helm-M-x))
- :custom
- (helm-move-to-line-cycle-in-source nil)
- :config
- (helm-mode 1))
- (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)
- :custom
- (magit-diff-refine-hunk 'all))
- (use-package abridge-diff
- :ensure t
- :after magit
- :init (abridge-diff-mode 1))
- (use-package company ; Company (complete anything) mode
- :ensure t
- :hook
- (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
- (if (display-graphic-p)
- (progn
- (use-package pdf-tools
- :ensure t
- :config
- (pdf-tools-install :no-query))
- (use-package org-noter
- :ensure t
- :after (pdf-tools)
- :custom
- (org-noter-notes-search-path (list bibliography-notes)))))
- (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 xenops
- :ensure t
- :config
- (defun my-buffer-face-mode-lm ()
- "Set font to Latin Modern Roman size 12 in the current buffer"
- (interactive)
- (setq buffer-face-mode-face '(:family "LM Roman 10" :foundry "outline" :slant normal :weight regular :height 120 :width normal))
- (buffer-face-mode))
- (add-hook 'xenops-mode-hook 'my-buffer-face-mode-lm)
- )
- (use-package cdlatex
- :ensure t
- :hook
- ((latex-mode LaTeX-mode) . cdlatex-mode)
- :config
- (add-hook 'cdlatex-tab-hook 'LaTeX-indent-line)
- (setq cdlatex-env-alist
- '(("definition" "\\begin{definition} AUTOLABEL\n?\n\\end{definition}\n" nil)
- ("theorem" "\\begin{theorem} AUTOLABEL\n?\n\\end{theorem}\n" nil)
- ("lemma" "\\begin{lemma} AUTOLABEL\n?\n\\end{lemma}\n" nil)))
- (setq cdlatex-command-alist
- '(("def" "Insert definition env" "" cdlatex-environment ("definition") t nil)
- ("thm" "Insert theorem env" "" cdlatex-environment ("theorem") t nil)
- ("lem" "Insert lemma env" "" cdlatex-environment ("lemma") t nil)
- ("wt" "Insert \\widetilde{}" "\\widetilde{?}" cdlatex-position-cursor nil nil t))))
- (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)))
- (use-package emacsql-sqlite-builtin :ensure t)
- (use-package org-roam
- :ensure t
- :after emacsql-sqlite-builtin
- :init
- (setq org-roam-database-connector 'sqlite-builtin)
- :custom
- (org-roam-directory bibliography-notes)
- (org-roam-capture-templates
- `(("d" "default" plain "%?"
- :target (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}")
- :unnarrowed t)
- ("b" "bibliography notes" plain ; Org-noter integration
- (file ,(concat bibliography-notes "notes-template.org"))
- :target (file+head "${citekey}.org" "#+title: ${title}\n")
- :unnarrowed t)))
- :config
- (org-roam-db-autosync-mode 1))
- (use-package org-roam-bibtex
- :ensure t
- :custom
- (orb-preformat-keywords '("citekey" "title" "url" "author-or-editor" "keywords" "file")) ; customisation for notes, org-noter integration
- (orb-process-file-keyword t)
- (orb-attached-file-extensions '("pdf"))
- ;;(bibtex-completion-edit-notes-function 'bibtex-completion-edit-notes-default) ; default to org-ref for notes
- (bibtex-completion-edit-notes-function 'orb-bibtex-completion-edit-note) ; use org-roam-capture-templates for notes
- :config
- (require 'org-ref))
- (use-package org-roam-ui
- :ensure t
- :after org-roam
- :custom
- (org-roam-ui-sync-theme t)
- (org-roam-ui-follow t)
- (org-roam-ui-update-on-save t)
- (org-roam-ui-open-on-start t))
- (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
- gtd-inbox
- gtd-gtd
- gtd-tickler
- gtd-someday))
- (org-agenda-start-on-weekday 1) ; nil means current day
- (org-agenda-span 7)
- (org-refile-targets '((org-agenda-files :maxlevel . 9)
- (gtd-inbox :maxlevel . 3)
- (gtd-someday :maxlevel . 2)
- (gtd-tickler :maxlevel . 2)
- (gtd-archive :level . 1)))
- (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)"
- "|" "DONE(d)" "CANCELLED(c@)")))
- (org-todo-repeat-to-state t)
- (org-log-done 'time)
- ;; See see http://cachestocaches.com/2016/9/my-workflow-org-agenda/
- (org-capture-templates
- `(("t" "Todo [gtd inbox]" entry (file+headline ,gtd-inbox "Tasks")
- "* TODO %i%? %A")
- ("T" "Tickler" entry (file+headline ,gtd-tickler "Tickler")
- "* %i%? \n%T")
- ("m" "Meeting" entry (file+headline ,gtd-inbox "Tasks")
- "* MEET %i%? %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-format-latex-options '(:foreground default
- :background default
- :scale 1.0
- :html-foreground "Black"
- :html-background "Transparent"
- :html-scale 1.0
- :matchers ("begin" "$1" "$" "$$" "\\(" "\\[")))
- (org-outline-path-complete-in-steps nil) ; for completions to work in Helm
- :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
- ;; Automagically save org-buffers after org-refile moves stuff
- (defun my-org-refile (&optional goto default-buffer rfloc msg)
- (interactive "P")
- "Does an ~org-refile~ and then a ~org-save-all-org-buffers~."
- (org-refile goto default-buffer rfloc msg) (org-save-all-org-buffers))
- (define-key org-mode-map (kbd "C-c C-w") 'my-org-refile)
- ;; F8 opens GTD file
- (global-set-key (kbd "<f8>") (lambda() (interactive)(find-file gtd-gtd)))
- )
- (use-package helm-org
- :ensure t
- :after (org helm)
- :config
- (add-to-list 'helm-completing-read-handlers-alist '(org-capture . helm-org-completing-read-tags))
- (add-to-list 'helm-completing-read-handlers-alist '(org-set-tags . helm-org-completing-read-tags)))
- (use-package suomalainen-kalenteri
- :ensure t
- :config
- (set-face-attribute 'org-agenda-calendar-sexp nil
- :inherit 'org-level-2)
- )
- ;;;;;;;;;;;;;;;;;;;;;;;;;;
|