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

1317 lines
38 KiB

;;; init --- Summary
;;; Commentary:
;;; Code:
(setq custom-file (concat user-emacs-directory "customizations.el"))
(load custom-file)
;; Initialize the package system and use-package
(setq load-prefer-newer t)
(require 'package)
(add-to-list 'package-archives
'("gnu" . ""))
(add-to-list 'package-archives
'("melpa-stable" . "") t)
(add-to-list 'package-archives
'("melpa" . "") t)
(add-to-list 'package-archives
'("marmalade" . "") t)
(add-to-list 'package-archives
'("org" . "") t)
7 years ago
(setq-default use-package-always-ensure t)
(unless (package-installed-p 'use-package)
(package-install 'use-package))
(use-package use-package
:pin melpa-stable)
;; Set up my personal keymap early so I can use it in use-package
;; calls
(defvar gpolonkai/pers-map (make-sparse-keymap)
"My own, personal, keymap!")
(define-prefix-command 'gpolonkai/pers-map)
(define-key ctl-x-map "t" 'gpolonkai/pers-map)
;; Add path to my custom lisp functions
(add-to-list 'load-path (concat
(convert-standard-filename "lisp/")))
;; Load my own functions
(load "gnu-c-header")
(load "round-number-to-decimals")
(load "zim")
(load "enclose-string")
(load "buf-manipulation")
(load "text-manip")
(load "frame-manip")
(load "file-manip")
(load "window-manip")
;; Define aliases
(defalias 'yes-or-no-p 'y-or-n-p)
(set-face-attribute 'default t :font "Hack-10")
(set-frame-font "Hack-10" nil t)
8 years ago
;; UI hacks: turn off the scroll bar (thats why Nyan-cat is here),
;; the toolbar (I dont really use it), and the menu bar (I rarely use
;; it, and in those rare occasions I can simply turn it on)
(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))
;; Maximize the frame
(set-frame-parameter nil 'fullscreen 'maximized)
(defun termux-p ()
"Check if Emacs is running under Termux."
(regexp-quote "/com.termux/")
(expand-file-name "~")))
;; Load some custom libraries
(use-package thingatpt
:ensure nil)
(use-package helm
(require 'helm-config)
(setq helm-M-x-fuzzy-match t
helm-buffers-fuzzy-matching t
helm-recentf-fuzzy-match t)
(helm-mode t)
(("M-x" . helm-M-x)
:map ctl-x-map
("C-f" . helm-find-files)
("b" . helm-mini)
:map helm-map
("/" . gpolonkai/helm-ff-slash-dir-complete)))
(use-package helm-swoop
(("M-i" . helm-swoop)))
(use-package ggtags
(add-hook 'c-mode-hook
(lambda ()
(ggtags-mode t)))
(add-hook 'c-mode-common-hook
(lambda ()
(when (derived-mode-p 'c-mode 'c++-mode 'java-mode)
(ggtags-mode t)))))
(use-package helm-gtags
(setq-default helm-gtags-auto-update t
helm-gtags-ignore-case t
helm-gtags-path-style 'relative)
(add-hook 'c-mode-hook
(lambda ()
(helm-gtags-mode t)))
(:map helm-gtags-mode-map
("M-t" . helm-gtags-find-tag)
("M-r" . helm-gtags-find-rtag)
("M-s" . helm-gtags-find-symbol)
("M-g M-p" . helm-gtags-parse-file)
("C-c <" . helm-gtags-previous-history)
("C-c >" . helm-gtags-next-history)
("M-," . helm-gtags-pop-stack)))
;; Whitespace mode
;; It is turned on by default, and can be toggled with F10
(use-package whitespace
(global-whitespace-mode 1)
(setq whitespace-line-column 100)
(([f10] . whitespace-mode)
([(shift f10)] . global-whitespace-mode)))
;; Multiple cursors
(use-package multiple-cursors
(defvar gpolonkai/mc-prefix-map (make-sparse-keymap)
"Prefix keymap for multiple-cursors")
(define-prefix-command 'gpolonkai/mc-prefix-map)
(define-key global-map (kbd "C-c m") 'gpolonkai/mc-prefix-map)
(add-hook 'multiple-cursors-mode-enabled-hook
(lambda ()
(setq blink-matching-paren nil)))
(add-hook 'multiple-cursors-mode-disabled-hook
(lambda ()
(setq blink-matching-paren t)))
:bind (:map gpolonkai/mc-prefix-map
("t" . mc/mark-all-like-this)
("m" . mc/mark-all-like-this-dwim)
("l" . mc/edit-lines)
("e" . mc/edit-ends-of-lines)
("a" . mc/edit-beginnings-of-lines)
("n" . mc/mark-next-like-this)
("p" . mc/mark-previous-like-this)
("s" . mc/mark-sgml-tag-pair)
("d" . mc/mark-all-like-this-in-defun)))
(use-package eshell
(add-hook 'eshell-mode-hook
(lambda () (local-set-key (kbd "C-d") #'eshell-C-d)))
(:map gpolonkai/pers-map
("e" . eshell)))
;; Save place
(use-package saveplace
(setq-default save-place t)
(setq save-place-file (expand-file-name ".places" user-emacs-directory)))
;; Nyanyanyanyanya
(use-package nyan-mode
(setq-default nyan-animate-nyancat t
nyan-wavy-trail t)
(nyan-mode t))
(when (display-graphic-p)
(use-package nyan-prompt
:disabled t
(add-hook 'eshell-load-hook 'nyan-prompt-enable)))
;; Zone!
(when (display-graphic-p)
(use-package zone-nyan
(setq-default zone-nyan-hide-progress t)
(setq zone-programs (vconcat zone-programs [zone-nyan]))))
(defun gpolonkai/zone-enable ()
"Enable zoning out."
(zone-when-idle 60)
(message "I will zone out after idling for 60 seconds."))
(use-package zone
(zone-when-idle 60)
(:map gpolonkai/pers-map
("zi" . gpolonkai/zone-enable)
("zq" . zone-leave-me-alone)))
;; Magit and friends
(use-package magit
(setq magit-auto-revert-mode nil)
(setq magit-last-seen-setup-instructions "1.4.0")
(:map ctl-x-map
("g" . magit-status)))
(use-package origami
(define-prefix-command 'origami-mode-map)
(define-key ctl-x-map (kbd "C-z") 'origami-mode-map)
(:map origami-mode-map
("o" . origami-open-node)
("O" . origami-open-node-recursively)
("c" . origami-close-node)
("C" . origami-close-node-recursively)
("a" . origami-toggle-node)
("A" . origami-recursively-toggle-node)
("R" . origami-open-all-nodes)
("M" . origami-close-all-nodes)
("v" . origami-show-only-node)
("k" . origami-previous-fold)
("j" . origami-forward-fold)
("x" . origami-reset)))
(use-package helm-ag
(:map gpolonkai/pers-map
("s" . helm-do-ag)))
(use-package smartparens
(show-smartparens-global-mode t)
(add-hook 'prog-mode-hook
(add-hook 'markdown-mode-hook
(([f9] . smartparens-strict-mode)
("C-c s u" . sp-unwrap-sexp)
("C-c s k" . sp-kill-sexp)))
8 years ago
(use-package smart-mode-line
(add-to-list 'sml/replacer-regexp-list
'("^~/Projects/" ":Proj:")
(add-to-list 'sml/replacer-regexp-list
'("^~/Projektek/" ":Proj:")
(add-to-list 'sml/replacer-regexp-list
(list (concat "^" (regexp-quote user-documents-directory))
(add-to-list 'sml/replacer-regexp-list
'("^:Proj:jekyll/" ":Blog:")
(add-to-list 'sml/replacer-regexp-list
(list "^:Proj:python/" ":Proj:Py:")
(setq-default header-line-format
(vc-mode vc-mode)
(delete '(vc-mode vc-mode) mode-line-format)
(delete 'mode-line-frame-identification mode-line-format)
(delete 'mode-line-buffer-identification mode-line-format)
(delete 'mode-line-position mode-line-format)
(delete 'mode-line-mule-info mode-line-format)
(delete 'mode-line-modified mode-line-format)
(delete 'mode-line-client mode-line-format)
(delete 'mode-line-remote mode-line-format)
;; Add sml/pre-id-separator after mode-line-front-space
(let* ((front-space-position (1+ (cl-position 'mode-line-front-space mode-line-format)))
(mode-line-rest (nthcdr front-space-position mode-line-format))
(mode-line-beg (subseq mode-line-format 0 front-space-position)))
(setq-default mode-line-format (nconc mode-line-beg
(list sml/pre-id-separator)
(use-package company
(setq company-idle-delay nil
company-frontends '(company-pseudo-tooltip-frontend
(use-package helm-company
(:map company-mode-map
("C-c j" . helm-company)
:map company-active-map
("C-c j" . helm-company)))
(use-package projectile
:pin melpa-stable
(projectile-global-mode t))
(use-package helm-projectile
(setq projectile-completion-system 'helm)
(use-package drag-stuff
(drag-stuff-global-mode t)
;; Git gutter
;; If we are in text-only mode, there is no fringe.
(let ((gitgutter-package
(if (display-graphic-p)
(eval `(use-package ,gitgutter-package
(global-git-gutter-mode t)
(:map gpolonkai/pers-map
("gg" . git-gutter:update-all-windows)
("gn" . git-gutter:next-hunk)
("gp" . git-gutter:previous-hunk)))))
;; From gmane.emacs.orgmode
;; (
(defun f-ediff-org-showhide (buf command &rest cmdargs)
"If buffer BUF exists and in `org-mode', execute COMMAND with CMDARGS."
(when buf
(when (eq (buffer-local-value 'major-mode (get-buffer buf)) 'org-mode)
(set-buffer buf)
(apply command cmdargs)))))
(defun f-ediff-org-unfold-tree-element ()
"Unfold tree at diff location."
(f-ediff-org-showhide ediff-buffer-A 'org-reveal)
(f-ediff-org-showhide ediff-buffer-B 'org-reveal)
(f-ediff-org-showhide ediff-buffer-C 'org-reveal))
(defun f-ediff-org-fold-tree ()
"Fold tree back to top level."
(f-ediff-org-showhide ediff-buffer-A 'hide-sublevels 1)
(f-ediff-org-showhide ediff-buffer-B 'hide-sublevels 1)
(f-ediff-org-showhide ediff-buffer-C 'hide-sublevels 1))
;; Org mode
(use-package org
(require 'xdg-paths)
(setq-default org-crypt-key "B0740C4C"
org-default-notes-file (concat user-documents-directory
org-directory (concat user-documents-directory
(convert-standard-filename "/orgmode/"))
org-agenda-files (concat user-documents-directory
org-ellipsis "…#"
org-startup-folded 'content
org-mobile-directory (concat user-documents-directory
org-mobile-inbox-for-pull (concat
org-log-done 'time
org-src-preserve-indentation t
org-log-into-drawer t
org-tags-column 0
org-startup-indented t)
(require 'ox-md)
(unless (boundp 'org-capture-templates)
(setq org-capture-templates nil))
(add-to-list 'org-capture-templates
'("p" "Blog post"
entry (file+olp+datetree (concat org-directory ""))
"* %^{Title} :blog:\n :PROPERTIES:\n :on: %T\n :END:\n %i%?"))
(add-to-list 'org-capture-templates
'("g" "GT2 note"
entry (file+headline (concat org-directory "")
"** %^{Title}\n :PROPERTIES:\n :on: %T\n :END:\n %i%?"))
(setq org-time-stamp-formats '("<%Y-%m-%d>" . "<%Y-%m-%d %H:%M>")
org-todo-keywords '((sequence "TODO(t)"
org-goto-interface 'outline-path-completion
org-goto-max-level 10
org-html-checkbox-type 'unicode
'((unicode (on . "<span class=\"task-done\">☑</span>")
(off . "<span class=\"task-todo\">☐</span>")
(trans . "<span class=\"task-in-progress\">▣</span>")))
org-src-window-setup 'current-window)
(add-hook 'ediff-select-hook 'f-ediff-org-unfold-tree-element)
(add-hook 'ediff-unselect-hook 'f-ediff-org-fold-tree)
(:map gpolonkai/pers-map
("a" . org-agenda-list)
("c" . org-capture)
("l" . org-store-link)
:map org-mode-map
("SPC" . org-space-key)
("C-c l" . org-toggle-link-display)
("C-a" . gpolonkai/move-to-beginning-of-line)
("C-e" . gpolonkai/move-to-end-of-line)))
(use-package org-bullets
(add-hook 'org-mode-hook
(lambda ()
(if (display-graphic-p) org-bullets-mode))))
;; Waka-waka
(use-package wakatime-mode
(setq-default wakatime-cli-path (executable-find "wakatime"))
(global-wakatime-mode t))
(use-package ace-window
(setq aw-background nil
aw-dispatch-always t)
(add-to-list 'aw-dispatch-alist
'(?s gpolonkai/scroll-window-up " Scroll window up")
(add-to-list 'aw-dispatch-alist
'(?S gpolonkai/scroll-window-down " Scroll window down")
(add-to-list 'aw-dispatch-alist
'(?q gpolonkai/bury-window " Bury (quit) window")
(:map ctl-x-map
("o" . ace-window)))
(use-package avy
(("M-g c" . avy-goto-char)
("C-'" . avy-goto-char-2)
("M-g f" . avy-goto-line)
("M-g w" . avy-goto-word-1)
("M-g e" . avy-goto-word-0)))
(use-package diminish
:defer t)
(use-package focus
(([f8] . focus-mode)))
(use-package coffee-mode)
(use-package command-log-mode)
(use-package company-c-headers)
(use-package company-shell)
(use-package electric-case
(add-hook 'c-mode-hook 'electric-case-c-init))
(use-package electric-operator
(add-hook 'c-mode-common-hook 'electric-operator-mode)
;; Apply electric-operator-mode to vala-mode, too
(apply #'electric-operator-add-rules-for-mode 'vala-mode
(use-package emamux)
(use-package flycheck
(use-package flycheck-pkg-config)
(use-package git-messenger
(:map gpolonkai/pers-map
("gm" . git-messenger:popup-message)))
(use-package git-timemachine
(([f6] . git-timemachine-toggle)))
(use-package gitconfig-mode)
(use-package gitignore-mode)
(use-package gnugo)
(use-package gobgen)
(use-package goto-last-change
(("M-g /" . goto-last-change)))
(use-package helm-chrome)
(use-package helm-flycheck)
(use-package helm-flyspell
(:map flyspell-mode-map
("C-M-i" . helm-flyspell-correct)))
(use-package helm-github-stars
(setq-default helm-github-stars-username "gergelypolonkai"))
(use-package helm-google)
(use-package hyde)
(use-package id-manager
(load "idm")
(setq idm-database-file (expand-file-name "idm-db.gpg" user-emacs-directory))
(:map gpolonkai/pers-map
("i" . idm-open-list-command)))
(use-package identica-mode)
(use-package jinja2-mode)
(use-package js2-mode
:pin melpa-stable)
(use-package json-mode)
(use-package markdown-mode
(push '("\\.markdown\\'" . markdown-mode) auto-mode-alist)
(push '("\\.md\\'" . markdown-mode) auto-mode-alist))
(use-package mc-extras
(:map mc/keymap
("C-c m =" . mc/compare-chars)))
(use-package ng2-mode)
(use-package org-projectile)
(use-package sass-mode)
(use-package smart-mode-line-powerline-theme
(setq-default sml/theme 'powerline))
(use-package spinner)
(use-package sx
(:map gpolonkai/pers-map
("qi" . sx-inbox)
("qs" . sx-search)))
(use-package typescript-mode)
(use-package vala-mode
(add-to-list 'auto-mode-alist '("\\.vala\\'" . vala-mode)))
(use-package xlicense)
(use-package yaml-mode
(add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode)))
(use-package helm-smex
(("M-S-x" . helm-smex)))
(use-package ediff
(setq-default ediff-merge-split-window-function 'split-window-horizontally
ediff-split-window-function 'split-window-vertically
ediff-window-setup-function 'ediff-setup-windows-plain))
(use-package plantuml-mode
(setq plantuml-jar-path
;; Make sure we have a download location even if XDG is not
;; working
((xdg-user-dir "DOWNLOAD")
(concat (xdg-user-dir "DOWNLOAD") "/plantuml.jar"))
(defvaralias 'org-plantuml-jar-path 'plantuml-jar-path)
'((plantuml . t))))
(use-package org-random-todo
;; Dont bug me too often…
(setq org-random-todo-how-often 3600)
(:map gpolonkai/pers-map
("r" . org-random-todo)))
(use-package calendar
:ensure nil
(setq calendar-week-start-day 1
calendar-latitude 47.4
calendar-longitude 19.0
calendar-location-name "Budapest, Hungary"
calendar-time-zone 60
calendar-standard-time-zone-name "CET"
calendar-daylight-time-zone-name "CEST"))
(use-package yasnippet
(yas-global-mode 1))
(use-package vala-snippets
(use-package hungarian-holidays
(use-package beacon
(beacon-mode 1)
(:map gpolonkai/pers-map
("b" . beacon-blink)))
(use-package flyspell