optimize and use use-package
This commit is contained in:
parent
f6d3734a66
commit
7033155c6a
10 changed files with 296 additions and 92 deletions
8
.emacs.d/config/backups.el
Normal file
8
.emacs.d/config/backups.el
Normal file
|
@ -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)
|
83
.emacs.d/config/base.el
Normal file
83
.emacs.d/config/base.el
Normal file
|
@ -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))))
|
10
.emacs.d/config/calendar.el
Normal file
10
.emacs.d/config/calendar.el
Normal file
|
@ -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)
|
42
.emacs.d/config/dev.el
Normal file
42
.emacs.d/config/dev.el
Normal file
|
@ -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 "")))
|
64
.emacs.d/config/functions.el
Normal file
64
.emacs.d/config/functions.el
Normal file
|
@ -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)")))))
|
4
.emacs.d/config/org.el
Normal file
4
.emacs.d/config/org.el
Normal file
|
@ -0,0 +1,4 @@
|
|||
(use-package org
|
||||
:ensure t
|
||||
:init
|
||||
(setq org-directory "~/org/"))
|
7
.emacs.d/config/pass.el
Normal file
7
.emacs.d/config/pass.el
Normal file
|
@ -0,0 +1,7 @@
|
|||
(use-package pass
|
||||
:ensure t
|
||||
:config
|
||||
(setq password-store-password-length 32))
|
||||
|
||||
(use-package pinentry
|
||||
:ensure t)
|
9
.emacs.d/config/tramp.el
Normal file
9
.emacs.d/config/tramp.el
Normal file
|
@ -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")))))
|
Loading…
Add table
Add a link
Reference in a new issue