You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

463 lines
12 KiB
EmacsLisp

;; It me
(setq user-mail-address "eheu48@gmail.com")
(setq user-full-name "Trémeur Karahés")
(setq calendar-latitude 54.59)
(setq calendar-longitude -5.83)
(setq calendar-location-name "Belfast")
;; do this now
(defun islin ()
"Return true if on linux"
(string-equal system-type "gnu/linux")
)
(defun iswin ()
"Return true if on windows"
(string-equal system-type "windows-nt")
)
(defun ismac ()
"Return true if on macos"
(string-equal system-type "darwin")
)
;; it's not 1986
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-language-environment 'utf-8)
(unless (iswin) (set-selection-coding-system 'utf-8))
(when (iswin) (set-selection-coding-system 'utf-16-le))
;; sonic arts
(setq ring-bell-function 'ignore)
(setq visible-bell t)
;; MELPA/use-package
(package-initialize)
;; (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")))
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/") t)
(setq package-check-signature nil)
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(require 'use-package-ensure)
(setq use-package-always-ensure t)
;; Misc
(setq completion-ignore-case t)
(setq read-file-name-completion-ignore-case t)
(setq read-buffer-completion-ignore-case t)
(setq inhibit-startup-screen t)
(tool-bar-mode -1)
(setq backup-directory-alist '(("." . "~/.emacs.d/backups")))
(require 'uniquify)
(setq uniquify-buffer-name-style 'forward)
(defun package--save-selected-packages (&rest opt) nil)
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(setq python-shell-interpreter "python3")
(when (islin)
(setq browse-url-browser-function 'browse-url-generic
4 years ago
browse-url-generic-program "google-chrome"
))
(when (ismac)
(setq ns-alternate-modifier 'meta)
(setq ns-right-alternate-modifier 'none))
(when (iswin)
(setq default-directory "~/"))
(when (islin)
(use-package lastfm))
;; Be quiet
(setq ad-redefinition-action 'accept)
(setq python-indent-guess-indent-offset-verbose nil)
(setq byte-compile-warnings '(cl-functions))
;; Minor modes
(use-package bibtex
:mode ("\\.bib" . bibtex-mode)
:config
(setq bibtex-dialect 'biblatex))
(use-package dimmer
;; dims inactive buffers
:init
(dimmer-mode t)
:config
(setq dimmer-fraction 0.4))
(use-package doom-modeline
;; nice-looking modeline
:init
(doom-modeline-mode 1)
:config
(setq doom-modeline-buffer-file-name-style 'buffer-name)
(setq doom-modeline-minor-modes t)
(setq doom-modeline-enable-word-count t)
(setq doom-modeline-continuous-word-count-modes '(markdown-mode gfm-mode))
(setq doom-modeline-buffer-encoding nil))
(electric-pair-mode 1)
;; automatic bracket/quote mark matching depending on mode
(use-package git-gutter
;; shows git diff in left margin
:config
(global-git-gutter-mode 1)
(set-face-foreground 'git-gutter:added "forest green")
(set-face-foreground 'git-gutter:modified "goldenrod")
(set-face-foreground 'git-gutter:deleted "brown")
(setq git-gutter:added-sign "+"
git-gutter:modified-sign "×"
git-gutter:deleted-sign "-"))
(use-package minions
;; lists minor modes in a menu
:config
(minions-mode))
(use-package paren
;; highlights matching bracket
:config
(show-paren-mode +1))
(use-package powershell)
;; for editing .ps1 files
(use-package rainbow-mode
;; colours css colours (≥ emacs26)
:hook
(css-mode . rainbow-mode))
(use-package recentf
;; access recent files in a list
:config
(recentf-mode 1)
(setq recentf-max-menu-items 20)
(setq recentf-max-saved-items 20)
(global-set-key "\C-x\ \C-r" 'recentf-open-files)
3 years ago
(add-to-list 'recentf-exclude
(expand-file-name "~/.emacs.d/elpa/*"))
(add-to-list 'recentf-exclude
(expand-file-name "~/.emacs.d/bookmarks"))
(add-to-list 'recentf-exclude
(expand-file-name "~/Documents/drive/org/elfeed/*")))
(use-package typo
;; smart quotes
:custom
(typo-global-mode 1)
:init
(add-hook 'org-mode-hook 'typo-mode))
(use-package yasnippet
;; shortcuts for common file contents per mode
:config
(setq yas-snippet-dirs '("~/.emacs.d/snippets")))
(yas-global-mode 1)
;; Major modes
(when (islin)
(use-package calibredb
:defer t
:config
(setq calibredb-root-dir "~/Documents/drive/calibre/ebooks")
(setq calibredb-db-dir (expand-file-name "metadata.db" calibredb-root-dir))
(setq calibredb-library-alist '(("~/Documents/drive/calibre/ebooks")
("~/Documents/drive/calibre/ffff")
("~/Documents/drive/calibre/ovely")))
(setq calibredb-sort-by 'author)
(setq calibredb-order 'asc))
(use-package nov
:init
(add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode)))
(defun my-nov-font-setup ()
(face-remap-add-relative 'variable-pitch :family "Liberation Serif"
:height 2.0))
(add-hook 'nov-mode-hook 'my-nov-font-setup))
3 years ago
(use-package deft
;; for searching journal files
:config
(setq deft-extensions '("org"))
(setq deft-directory "~/Documents/drive/org/journal")
(setq deft-ignore-file-regexp ".*[0-9][0-9][0-9][0-9]\.org") ;; lol
(setq deft-current-sort-method 'title)
(setq deft-recursive t))
(use-package markdown-mode
:mode (("README\\.md\\'" . gfm-mode)
("\\.md\\'" . markdown-mode)
("\\.markdown\\'" . markdown-mode))
:init
(add-hook 'markdown-mode-hook 'auto-fill-mode)
(add-hook 'markdown-mode-hook 'typo-mode)
:config
(setq markdown-command "pandoc")
(setq markdown-asymmetric-header t)
(setq markdown-css-paths `("https://fonts.googleapis.com/css?family=Fredoka+One|Raleway:400,400i,800" ,(expand-file-name "~/.emacs.d/export.css"))) ; does this work on windows?
:custom
(markdown-header-scaling t)
:custom-face
(markdown-header-face ((t (:inherit (default font-lock-function-name-face) :weight bold)))))
(use-package neotree
;; show filetree
:init
(global-set-key [f8] 'neotree-toggle)
:config
(setq neo-theme (if (display-graphic-p) 'icons 'arrow)))
(use-package org-noter
;; interleave replacement
:config
(setq org-noter-property-doc-file "INTERLEAVE_PDF"
org-noter-property-note-location "INTERLEAVE_PAGE_NOTE"))
(unless (iswin) (use-package pdf-tools
;; view pdfs
:config
(pdf-tools-install)
(define-key pdf-view-mode-map (kbd "C-s") 'isearch-forward)
(add-hook 'pdf-view-mode-hook (lambda () (cua-mode 0)))
(setq pdf-view-resize-factor 1.1)))
(when (iswin) (use-package doc-view
:config
(setq doc-view-ghostscript-program "gswin32c")))
(use-package tex
;; the big boy
:ensure auctex
:mode ("\\.tex\\'" . latex-mode)
:init
(add-hook 'LaTeX-mode-hook 'turn-on-auto-fill)
(add-hook 'TeX-after-compilation-finished-functions
#'TeX-revert-document-buffer)
:config
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)
(setq-default TeX-engine 'xetex)
(setq-default TeX-PDF-mode t)
(setq TeX-view-program-selection '((output-pdf "PDF Tools"))
TeX-source-correlate-start-server t))
;; org
(add-hook 'org-mode-hook 'org-indent-mode)
(add-hook 'org-mode-hook 'visual-line-mode)
(setq org-special-ctrl-a/e t)
(setq org-display-inline-images t)
(setq org-redisplay-inline-images t)
(setq org-startup-with-inline-images "inlineimages")
(setq org-image-actual-width '(300))
(load-file "~/.emacs.d/agenda-common.el")
;; for agenda things used in both emacs and batch
(when (islin)
(use-package org-modern
:hook
(org-mode . org-modern-mode)))
(use-package calfw
;; grid calendar that i forget to use
:bind ("C-c f" . cfw:open-org-calendar)
:config
(use-package calfw-org)
(setq cfw:org-overwrite-default-keybinding t
cfw:display-calendar-holidays nil
calendar-week-start-day 1))
(use-package org-agenda-property)
;; lets properties inherit
(use-package org-analyzer
;; time tracking visualiser
:config
(setq org-directory "~/Documents/drive/org"))
(unless (islin)
(use-package org-bullets
;; makes bullets look nice
:custom
(org-bullets-bullet-list '(""))
(org-ellipsis "")
:hook (org-mode . org-bullets-mode)))
(setq org-todo-keywords
'((sequence "TODO" "|" "DONE" "CANCELLED")))
(global-set-key (kbd "C-c a") 'org-agenda)
(setq calendar-week-start-day 1)
(setq org-agenda-start-on-weekday nil)
(setq org-agenda-files (list "~/Documents/drive/org/calendar"
"~/Documents/drive/org/period.org"))
(setq org-agenda-prefix-format
'((todo . "%-2c %b")
(tags . "%-2c %b")
(agenda . "%-2c %?-12t%?-12s")))
(setq org-use-property-inheritance (quote ("LOCATION")))
(setq org-agenda-todo-ignore-scheduled t)
(setq org-agenda-todo-ignore-deadlines t)
(setq org-export-headline-levels 6)
;; Elfeed
(use-package elfeed-org
:config
(elfeed-org)
(setq rmh-elfeed-org-files (list "~/Documents/drive/org/feeds.org")))
(defun elfeed-load-db-and-open ()
"Wrapper to load the elfeed db from disk before opening"
(interactive)
(elfeed-db-load)
(elfeed)
(elfeed-search-update--force)
(elfeed-update))
(global-set-key (kbd "C-x w") 'elfeed-load-db-and-open)
(defalias 'elfeed-toggle-star
(elfeed-expose #'elfeed-search-toggle-all 'star))
(eval-after-load 'elfeed-search
'(define-key elfeed-search-mode-map (kbd "m") 'elfeed-toggle-star))
(defun elfeed-save-db-and-bury ()
"Wrapper to save the elfeed db to disk before burying buffer"
(interactive)
(elfeed-db-save)
(quit-window))
(defun elfeed-search-format-date (date)
(format-time-string "%Y-%m-%d %H:%M" (seconds-to-time date)))
(use-package elfeed
:bind (:map elfeed-search-mode-map
("q" . elfeed-save-db-and-bury))
:custom
(elfeed-sort-order 'ascending)
(elfeed-db-directory "~/Documents/drive/org/elfeed"))
4 years ago
(add-hook 'elfeed-new-entry-hook
(elfeed-make-tagger :before "6 months ago"
:remove 'unread))
3 years ago
;; Email?
(when (islin)
(add-to-list 'load-path "/usr/share/emacs/site-lisp/mu4e")
(load-file "~/.emacs.d/mail.el")
(require 'mu4e) ;; this uses cl … hopefully will be updated in a later emacs version?
3 years ago
(setq send-mail-function 'smtpmail-send-it)
;; (load-file "~/.emacs.d/custom/dwpost.el")
)
3 years ago
;; Aesthetics
(use-package all-the-icons
;; shows nice icons in modeline + neotree
:config
3 years ago
(unless (iswin)
(when (not (member "all-the-icons" (font-family-list)))
(all-the-icons-install-fonts t)))); need to install fonts manually on windows
(use-package emojify
;; emoji support
:init
(add-hook 'after-init-hook #'global-emojify-mode))
(use-package hl-line
;; highlights current row
:config
(global-hl-line-mode 1))
(use-package tao-theme)
(load-theme 'tao-yang t)
;; (when (islin) ;; not working in emacs27?
;; (use-package xresources-theme)
;; ;; theme based on ~/.Xresources
;; )
(set-cursor-color "#61805c")
(set-face-attribute 'region nil :background "#fcf6a7")
(set-face-background 'hl-line "#ddffd6")
;; Fonts
(if (iswin)
(custom-set-faces
'(default ((t (:family "Noto Mono" :foundry "outline" :slant normal :weight normal :height 98 :width normal))))
'(italic ((t (:slant italic))))
'(variable-pitch ((t (:family "Noto Sans" :height 90))))
'(fixed-pitch ((t (:family "Noto Mono" :height 90))))))
(unless (iswin)
(custom-set-faces
'(italic ((t (:slant italic))))
'(variable-pitch ((t (:family "Noto Sans" :height 90))))
'(fixed-pitch ((t (:family "Noto Mono" :height 90))))))
(use-package mixed-pitch
;; intelligent face setting
:hook
(LaTeX-mode . mixed-pitch-mode)
(org-mode . mixed-pitch-mode)
(markdown-mode . mixed-pitch-mode))
;; Startup
(defun load-directory (dir)
(let ((load-it (lambda (f)
(load-file (concat (file-name-as-directory dir) f)))))
(mapc load-it (directory-files dir nil "\\.el$"))))
(load-directory "~/.emacs.d/custom/")
(setq initial-major-mode 'org-mode)
3 years ago
(unless (iswin)
(setq initial-scratch-message "\
#
"))
(when (iswin)
(setq initial-scratch-message "\
# obma emacs war microsoft beistry
"))
(org-reload)