emacs.d/init.el
2020-04-16 16:20:26 +02:00

144 lines
5 KiB
EmacsLisp
Executable file

(require 'server)
(unless (server-running-p) (server-start))
;; ==================== GLOBAL KEYS ==================== ;;
(global-set-key (kbd "C-c l") 'org-store-link)
(global-set-key (kbd "C-c a") 'org-agenda)
(global-set-key (kbd "C-c c") 'org-capture)
(global-set-key (kbd "C-c b") 'org-switchb)
(global-set-key (kbd "C-c C-x m") 'org-pomodoro)
(global-set-key (kbd "C-x g") 'magit-status)
(global-set-key (kbd "C-x M-g") 'magit-dispatch)
(global-set-key (kbd "M-i") 'imenu)
(global-set-key (kbd "C-c n") 'newsticker-start)
(global-set-key (kbd "M-o") 'ace-window)
;; (global-unset-key "\C-z")
(require 'package)
;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
(not (gnutls-available-p))))
(proto (if no-ssl "http" "https")))
(when no-ssl
(warn "\
Your version of Emacs does not support SSL connections,
which is unsafe because it allows man-in-the-middle attacks.
There are two things you can do about this warning:
1. Install an Emacs version that does support SSL and be safe.
2. Remove this warning from your init file so you won't see it again."))
;; Comment/uncomment these two lines to enable/disable MELPA and MELPA Stable as desired
(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 (cons "gnu" (concat proto "://elpa.gnu.org/packages/")))))
(package-initialize)
(setq custom-file "~/.emacs.d/bundle/custom.el")
(load custom-file :noerror)
(when (eq system-type 'gnu/linux)
(load-theme 'nord))
(unless (eq system-type 'gnu/linux)
(load-theme 'nord))
(add-to-list 'load-path (expand-file-name "~/.emacs.d/bundle"))
(require 'bundles)
(ivy-mode 1)
(projectile-mode +1)
;; UTF-8 FTW
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(setq default-buffer-file-coding-system 'utf-8)
(defalias 'yes-or-no-p 'y-or-n-p)
(with-current-buffer "*scratch*" (emacs-lock-mode 'kill))
(defun copy-whole-buffer ()
"Copy entire buffer to clipboard"
(interactive)
(clipboard-kill-ring-save (point-min) (point-max)))
(put 'narrow-to-region 'disabled nil)
(put 'narrow-to-page 'disabled nil)
(put 'upcase-region 'disabled nil)
(defun duplicate-line()
(interactive)
(move-beginning-of-line 1)
(kill-line)
(yank)
(open-line 1)
(next-line 1)
(yank)
)
(add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode))
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
;; slime
(setq slime-contribs '(slime-fancy))
(defun git-blame-line ()
"Runs `git blame` on the current line and
adds the commit id to the kill ring"
(interactive)
(let* ((line-number (save-excursion
(goto-char (point-at-bol))
(+ 1 (count-lines 1 (point)))))
(line-arg (format "%d,%d" line-number line-number))
(commit-buf (generate-new-buffer "*git-blame-line-commit*")))
(call-process "git" nil commit-buf nil
"blame" (buffer-file-name) "-L" line-arg)
(let* ((commit-id (with-current-buffer commit-buf
(buffer-substring 1 9)))
(log-buf (generate-new-buffer "*git-blame-line-log*")))
(kill-new commit-id)
(call-process "git" nil log-buf nil
"log" "-1" "--pretty=%h %an %s" commit-id)
(with-current-buffer log-buf
(message "Line %d: %s" line-number (buffer-string)))
(kill-buffer log-buf))
(kill-buffer commit-buf)))
(defun org-dblock-write:rangereport (params)
"Display day-by-day time reports."
(let* ((ts (plist-get params :tstart))
(te (plist-get params :tend))
(start (time-to-seconds
(apply 'encode-time (org-parse-time-string ts))))
(end (time-to-seconds
(apply 'encode-time (org-parse-time-string te))))
day-numbers)
(setq params (plist-put params :tstart nil))
(setq params (plist-put params :end nil))
(while (<= start end)
(save-excursion
(insert "\n\n"
(format-time-string (car org-time-stamp-formats)
(seconds-to-time start))
"----------------\n")
(org-dblock-write:clocktable
(plist-put
(plist-put
params
:tstart
(format-time-string (car org-time-stamp-formats)
(seconds-to-time start)))
:tend
(format-time-string (car org-time-stamp-formats)
(seconds-to-time end))))
(setq start (+ 86400 start))))))
;; Local Variables:
;; mode: emacs-lisp
;; coding: utf-8-unix
;; End: