diff --git a/.emacs.d/config/backups.el b/.emacs.d/config/backups.el new file mode 100644 index 0000000..387270f --- /dev/null +++ b/.emacs.d/config/backups.el @@ -0,0 +1,8 @@ +;; configure backups +(setq backup-directory-alist '(("." . "~/.emacs.d/backups/")) + backup-by-copying t + delete-old-versions t + kept-new-versions 16 + kept-old-versions 8 + version-control t + tramp-backup-directory-alist backup-directory-alist) diff --git a/.emacs.d/config/base.el b/.emacs.d/config/base.el new file mode 100644 index 0000000..7506051 --- /dev/null +++ b/.emacs.d/config/base.el @@ -0,0 +1,83 @@ +;; use UTF-8 for file name encoding +(setq file-name-coding-system 'utf-8) +(prefer-coding-system 'utf-8) + +;; enable some commands disabled by default +(put 'narrow-to-region 'disabled nil) +(put 'upcase-region 'disabled nil) +(put 'downcase-region 'disabled nil) + +;; no fancy graphic stuff, you don't want to use the mouse anyway, do +;; you? +(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1)) +(if (fboundp 'tool-bar-mode) (tool-bar-mode -1)) +(if (fboundp 'menu-bar-mode) (menu-bar-mode -1)) +(setq use-dialog-box nil) + +;; add key sequences +(global-set-key "\C-c\l" 'goto-line) + +;; syntax coloring +(global-font-lock-mode t) + +;; paren matching +(show-paren-mode t) + +;; display of current function (which-function-mode) +(which-function-mode 1) + +;; VC is mostly useless for modern DVCSs +(setq vc-handled-backends nil) + +;; configure the browser +(setq browse-url-browser-function 'browse-url-generic + browse-url-generic-program "qutebrowser") + +;; use space instead of tabs +(setq-default indent-tabs-mode nil) + +;; yank at cursor not mouse pointer +(setq mouse-yank-at-point t) + +;; make the screen go down with one line & mouse wheel support +(setq scroll-step 1) +(mouse-wheel-mode t) + +;; clipboard yanking is possible with middle mouse button now +(setq x-select-enable-clipboard t + x-select-enable-primary t) + +;; enhanced buffer switching with shift + arrows +(windmove-default-keybindings) + +;; resize cursor to character +(setq x-stretch-cursor t) + +;; set tab width to 4 whitespaces +(setq tab-width 4) +(setq-default c-basic-offset tab-width) +(setq-default cperl-indent-level tab-width) + +;; More history +(setq-default history-length 1000) + +;; delete trailing whitespaces before saving +(add-hook 'before-save-hook 'delete-trailing-whitespace) + +;; add newlines at eof +(setq require-final-newline t) +;; (setq mode-require-final-newline t) + +;; enable number-modes +(setq line-number-mode t) +(setq column-number-mode t) + +;; show paren mode +(setq show-paren-mode t) + +;; no am/pm in timestamps +(setq display-time-24hr-format t) + +;; configure theme +(custom-set-variables + '(custom-enabled-themes (quote (tango-dark)))) diff --git a/.emacs.d/config/calendar.el b/.emacs.d/config/calendar.el new file mode 100644 index 0000000..3646e12 --- /dev/null +++ b/.emacs.d/config/calendar.el @@ -0,0 +1,10 @@ +;; calender week starts with mo +(setq european-calender-style t) + +;; ;; european calendar +;; (add-hook 'calendar-load-hook +;; (lambda() +;; (calendar-set-date-style 'european))) + +;; start with monday +(setq calendar-week-start-day 1) diff --git a/.emacs.d/config/dev.el b/.emacs.d/config/dev.el new file mode 100644 index 0000000..d77d5f6 --- /dev/null +++ b/.emacs.d/config/dev.el @@ -0,0 +1,42 @@ +;; magit +(use-package magit + :ensure t + :init + ;; (taken from :open https://r0tty.org/git/dotfiles/emacs/tree/.emacs.d/config/development.el) + (defun vcsh (repo) + "Invoke magit on a vcsh repo. This requires an appropriate entry in `tramp-methods'." + (interactive (let ((repos (delq nil + (mapcar #'(lambda (name) + (if (string-match ".git$" name) + (substring name 0 -4) + nil)) + (directory-files "~/.config/vcsh/repo.d"))))) + (list (completing-read "Repository: " repos nil t)))) + (magit-status-internal (format "/vcsh:%s:" repo)))) + +;; rust +(use-package cargo :ensure t) +(use-package flycheck-rust :ensure t) + +;; start cargo +(add-hook 'rust-mode-hook 'cargo-minor-mode) + +;; yaml +(use-package yaml-mode :ensure t) +(use-package flycheck-yamllint :ensure t) + +;; paredit +(autoload 'enable-paredit-mode "paredit" "Turn on pseudo-structural editing of Lisp code." t) +(add-hook 'emacs-lisp-mode-hook #'enable-paredit-mode) +(add-hook 'eval-expression-minibuffer-setup-hook #'enable-paredit-mode) +(add-hook 'ielm-mode-hook #'enable-paredit-mode) +(add-hook 'lisp-mode-hook #'enable-paredit-mode) +(add-hook 'lisp-interaction-mode-hook #'enable-paredit-mode) +(add-hook 'scheme-mode-hook #'enable-paredit-mode) + +;; Hack to show only files known to git inside dired; needs the +;; `git-find' shell script shim (taken from :open https://r0tty.org/git/dotfiles/emacs/tree/.emacs.d/config/development.el) +(defun git-dired (dir) + (interactive (list (read-directory-name "Find files in directory: " nil "" t))) + (let ((find-program "git-find")) + (find-dired dir ""))) diff --git a/.emacs.d/config/functions.el b/.emacs.d/config/functions.el new file mode 100644 index 0000000..1ca3e0d --- /dev/null +++ b/.emacs.d/config/functions.el @@ -0,0 +1,64 @@ +;; additional functions +;; taken from https://r0tty.org/git/dotfiles/emacs +(defvar revert-some-buffers-action-alist + '((?\C-r + (lambda (buf) + (view-buffer buf + (lambda (ignore) + (exit-recursive-edit))) + (recursive-edit) + ;; Return nil to ask about BUF again. + nil) + "view this buffer") + (?d (lambda (buf) + (save-window-excursion + (diff-buffer-with-file buf)) + (view-buffer (get-buffer-create "*Diff*") + (lambda (ignore) (exit-recursive-edit))) + (recursive-edit) + nil) + "view changes in this buffer")) + "ACTION-ALIST argument used in call to `map-y-or-n-p'.") + +;; Code/docstring taken from Emacs' `save-some-buffers' and hacked. +(defun revert-some-buffers (&optional arg pred) + "Revert some modified file-visiting buffers. Asks user about each one. +You can answer `y' to revert, `n' not to revert, `C-r' to look at the +buffer in question with `view-buffer' before deciding or `d' to +view the differences using `diff-buffer-with-file'. + +Optional argument (the prefix) non-nil means revert all with no questions. +Optional second argument PRED determines which buffers are considered: +If PRED is nil, all the file-visiting buffers are considered. +If PRED is t, then certain non-file buffers will also be considered. +If PRED is a zero-argument function, it indicates for each buffer whether +to consider it or not when called with that buffer current." + (interactive "P") + (save-window-excursion + (let (queried files-done) + ;; Ask about those buffers that merit it, + ;; and record the number thus reverted. + (setq files-done + (map-y-or-n-p + (function + (lambda (buffer) + (and (not (buffer-modified-p buffer)) + (not (buffer-base-buffer buffer)) + (buffer-file-name buffer) + (not (verify-visited-file-modtime buffer)) + (file-exists-p (buffer-file-name buffer)) + (or (not (functionp pred)) + (with-current-buffer buffer (funcall pred))) + (if arg + t + (setq queried t) + (format "Revert file %s? " (buffer-file-name buffer)))))) + (function + (lambda (buffer) + (set-buffer buffer) + (revert-buffer 'ignore-auto 'dont-ask 'preserve-modes))) + (buffer-list) + '("buffer" "buffers" "save") + revert-some-buffers-action-alist)) + (or queried (> files-done 0) + (message "(No files need reverting)"))))) diff --git a/.emacs.d/config/org.el b/.emacs.d/config/org.el new file mode 100644 index 0000000..9aa1d70 --- /dev/null +++ b/.emacs.d/config/org.el @@ -0,0 +1,4 @@ +(use-package org + :ensure t + :init + (setq org-directory "~/org/")) diff --git a/.emacs.d/config/pass.el b/.emacs.d/config/pass.el new file mode 100644 index 0000000..c2dc99c --- /dev/null +++ b/.emacs.d/config/pass.el @@ -0,0 +1,7 @@ +(use-package pass + :ensure t + :config + (setq password-store-password-length 32)) + +(use-package pinentry + :ensure t) diff --git a/.emacs.d/config/tramp.el b/.emacs.d/config/tramp.el new file mode 100644 index 0000000..60bb211 --- /dev/null +++ b/.emacs.d/config/tramp.el @@ -0,0 +1,9 @@ +(use-package tramp + :config + (setq tramp-default-method "ssh") + (add-to-list 'tramp-methods '("vcsh" + (tramp-login-program "vcsh") + (tramp-login-args (("enter") + ("%h"))) + (tramp-remote-shell "/bin/sh") + (tramp-remote-shell-args ("-c"))))) diff --git a/.emacs.d/init.el b/.emacs.d/init.el index b55d47e..2c7a85d 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -1,105 +1,73 @@ ;;;; ;;;;;; -*- Mode: Emacs-Lisp -*- ;;;; +;; package config +;; We want certificate verification for the repositories, see +;; for +;; the issues involved. Note that on Debian, `gnutls-trustfiles' has +;; reasonable settings, so we don't need to customize that. +(setq tls-checktrust t) +(setq gnutls-verify-error t) -;; melpa and elpa +(setq tls-program + '("gnutls-cli --x509cafile /etc/ssl/certs/ca-certificates.crt -p %p %h")) + +;; Do package initialization now, so we can require packages from config snippets +(setq package-enable-at-startup nil) (require 'package) -(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos)) - (not (gnutls-available-p)))) - (proto (if no-ssl "http" "https"))) - (add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t) - ;; (add-to-list 'package-archives (cons "melpa-stable" (concat proto "://stable.melpa.org/packages/")) t) - (when (< emacs-major-version 24) - ;; for important compatibility libraries like cl-lib - (add-to-list 'package-archives '("gnu" . (concat proto "://elpa.gnu.org/packages/"))))) +(setq package-archives + '(("gnu" . "https://elpa.gnu.org/packages/") + ("melpa" . "https://melpa.org/packages/"))) + +;; ;; package list to install +;; (setq package-list '(use-package)) + +;; activate packages (package-initialize) -;; use space instead of tabs -(setq-default indent-tabs-mode nil) +;; ;; fetch list of available packages +;; (unless package-archive-contents +;; (package-refresh-contents)) -;; resize cursor to character -(setq x-stretch-cursor t) +;; ;; install missing packages +;; (dolist (package package-list) +;; (unless (package-installed-p package) +;; (package-install package))) -;; set tab width to 4 whitespaces -(setq tab-width 4) -(defvaralias 'c-basic-offset 'tab-width) -(defvaralias 'cperl-indent-level 'tab-width) +;; configure packages (taken from https://r0tty.org/git/dotfiles/emacs) +(require 'use-package) -;; delete trailing whitespaces before saving -(add-hook 'before-save-hook 'delete-trailing-whitespace) +;; Config snippets loading; this provides an easy way to define +;; 'configuration snippets' for use with a specific package (that may +;; be not installed), and enable loading that snippet when its +;; basename (specified as a symbol) is part of the variable +;; config-snippets. +(defgroup config-snippets nil + "Configuration snippets -- elisp files that are loaded at startup.") -;; add newlines at eof -(setq require-final-newline t) -;; (setq mode-require-final-newline t) +(defcustom config-snippets '() + "Specifies the config snippets to be loaded at startup. +Elements may be strings (interpreted as literal filenames) or +symbols, which are converted to strings, and suffixed with \".el\"." + :group 'config-snippets + :type '(repeat (choice symbol string))) -;; theme -(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. - '(column-number-mode t) - '(custom-enabled-themes (quote (tango-dark))) - '(menu-bar-mode nil) - '(package-selected-packages - (quote - (wanderlust flycheck-rust cargo flycheck-yamllint yaml-mode pass pinentry magit org))) - '(scroll-bar-mode nil) - '(show-paren-mode t) - '(tool-bar-mode nil)) +(defcustom config-snippet-path '("~/.emacs.d/config/") + "Specifies the path in which config snippets are searched" + :group 'config-snippets + :type '(repeat directory)) -;; yank at cursor not mouse pointer -(setq mouse-yank-at-point t) +(setq config-snippets '(base backups calendar dev functions org pass wl)) -;; make the screen go down with one line & mouse wheel support -(setq scroll-step 1) -(mouse-wheel-mode t) - -;; use UTF-8 for file name encoding -(setq file-name-coding-system 'utf-8) -(prefer-coding-system 'utf-8) - -;; enable line, linum and column numbering -(line-number-mode 1) -(column-number-mode 1) - -;; enhanced buffer switching -(windmove-default-keybindings) - -;; display of current function (which-function-mode) -(which-function-mode 1) - -;; no am/pm in timestamps -(setq display-time-24hr-format t) - -;; clipboard yanking is possible with middle mouse button now -(setq x-select-enable-clipboard t - x-select-enable-primary t) - -;; enable some commands disabled by default -(put 'narrow-to-region 'disabled nil) -(put 'upcase-region 'disabled nil) -(put 'downcase-region 'disabled nil) - -;; handle backups -(setq backup-directory-alist '(("." . "~/.emacs.d/backups/")) - backup-by-copying t - delete-old-versions t - kept-new-versions 6 - kept-old-versions 2 - version-control t - tramp-backup-directory-alist backup-directory-alist) - -;; tramp mode ssh (faster) -(setq tramp-default-method "ssh") - -;; set pass default password length -(setq password-store-password-length 32) - -;; load wanderlust -(autoload 'wl "wl" "Wanderlust" t) - -;; include other configs -;; calendar-mode -(if (file-exists-p "~/.emacs.d/calendar.el") - (load-file "~/.emacs.d/calendar.el")) +(message "Loading\nconfig-snippets: %s\nconfig-snippets-path: %s" config-snippets config-snippet-path) +(dolist (snippet config-snippets) + (message "snippet: %s" snippet) + (dolist (dir config-snippet-path) + (message "dir: %s" dir) + (let ((file-name (expand-file-name (concat dir (if (symbolp snippet) + (concat (symbol-name snippet) ".el") + snippet))))) + (message "loading file") + (if (file-readable-p file-name) + (load-file file-name) + (message "Config snippet not found: %s" snippet))))) diff --git a/.gitignore.d/emacs b/.gitignore.d/emacs index ec89850..b7bb977 100644 --- a/.gitignore.d/emacs +++ b/.gitignore.d/emacs @@ -1,6 +1,15 @@ * !/.emacs.d -!/.emacs.d/calendar.el +!/.emacs.d/config +!/.emacs.d/config/backups.el +!/.emacs.d/config/base.el +!/.emacs.d/config/calendar.el +!/.emacs.d/config/dev.el +!/.emacs.d/config/functions.el +!/.emacs.d/config/org.el +!/.emacs.d/config/pass.el +!/.emacs.d/config/tramp.el +!/.emacs.d/config/wl.el !/.emacs.d/init.el !/.folders !/.gitignore.d