;; ------------------------------------- ;; Security (setq network-security-level 'paranoid) ;; asks for certificate verification on each SSL connection, option to save configuration

;; ------------------------------------- ;; Preparation

;; Add local load paths (add-to-list 'load-path "~/.emacs.d/lisp") (let ((default-directory "~/.emacs.d/lisp/")) (normal-top-level-add-subdirs-to-load-path)) (add-to-list 'custom-theme-load-path "~/.emacs.d/themes")

;; Enable package.el, default package manager (require 'package) (package-initialize)

;; Ensure every package from ELPA is installed and if not, prompt for installation. (defun ensure-package-installed (&rest packages) (mapcar (lambda (package) (unless (package-installed-p package) (package-install package))) packages))

;; ELPA packages list (ensure-package-installed 'dash 'company 'adjust-parens 'async 'org)

;; ------------------------------------- ;; Configuration of built-in and ELPA packages

;; Elisp format (require 'elisp-format)

;; Recent files (recentf-mode 1) (setq recentf-max-menu-items 10) (global-set-key "\C-x\ \C-r" 'recentf-open-files)

;; Completion framework (add-hook 'after-init-hook 'global-company-mode) (setq company-minimum-prefix-length 2) (setq company-dabbrev-downcase nil) (setq company-show-numbers t)

;; Automatic parenthesis, duh (adjust-parens (add-hook 'emacs-lisp-mode-hook #'adjust-parens-mode) (local-set-key (kbd "TAB") 'lisp-indent-adjust-parens) (local-set-key (kbd "") 'lisp-dedent-adjust-parens)

;; Some packages can make use of this, for example company-mode (dired-async-mode 1)

;; Emacs org mode (add-to-list 'auto-mode-alist '("\.org\'" . org-mode)) (global-set-key "\C-cl" 'org-store-link) (global-set-key "\C-ca" 'org-agenda)

;; ------------------------------------- ;; Configuration of third party packages copied to "~/.emacs.d/lisp" from "~/.emacs.d/third_party_repositories"

;; God mode - reduces key chords usage (require 'god-mode) (setq god-exempt-major-modes nil) (setq god-exempt-predicates nil) (global-set-key (kbd "") 'god-mode-all)

;; Solarized theme (setq solarized-high-contrast-mode-line t) (setq x-underline-at-descent-line t) (setq solarized-use-variable-pitch nil) (load-theme 'solarized-dark t)

;; Emacs Multimedia System (require 'emms-setup) (emms-all) (emms-default-players) (emms-history-load)

;; ------------------------------------- ;; Programming and sysadmin stuff

;TODO

;; ------------------------------------- ;; Basic adjustments (set-language-environment "UTF-8") ;; Set input (setq tramp-default-method "ssh") ;; Default connection method for TRAMP - remote files plugin (add-hook 'focus-out-hook 'garbage-collect) ;; garbage collect when Emacs is not in focus (set-default 'truncate-lines t) ;; Turn off line wrapping by default (when (fboundp 'winner-mode) ;; I don't remember (winner-mode 1))

;; ------------------------------------- ;; Custom keybinds (global-set-key (kbd "C-c w") 'toggle-truncate-lines) ;; wrap (global-set-key (kbd "C-c e") 'eshell) ;; Emacs shell shortcut (global-set-key (kbd "C-c t") 'term) ;; ANSI term (global-set-key (kbd "C-c x") 'browse-url-at-point) ;; Open link under cursor (global-set-key (kbd "C-x p") 'proced) ;; System monitor

;; Visual ;(toggle-frame-maximized) ;; Maximize Emacs on startup (set-frame-font "Hack 9" nil t) ;; Set font (menu-bar-mode -1) ;; Remove menu bar (tool-bar-mode -1) ;; Remove toolbar (scroll-bar-mode -1) ;; Remove scrollbar (setq inhibit-startup-message t) ;; Disable startup message (setq ring-bell-function 'ignore) ;; Disable raping your ears with error ring tone (setq initial-scratch-message nil) ;; Disable text in scratch (setq initial-major-mode 'org-mode) ;; Set scratch buffer major mode to org-mode (setq confirm-kill-emacs #'y-or-n-p) ;; Confirm kill Emacs (global-prettify-symbols-mode +1) ;; Make symbols pretty e.g. lamba

;; ------------------------------------- ;; Custom functions

;; Close everything without closing Emacs (defun close-all-buffers () (interactive) (mapc 'kill-buffer (buffer-list))) (global-set-key (kbd "\C-c\ \c") 'close-all-buffers)

;; Set Emacs window title to current file path (setq frame-title-format '("" invocation-name ": " (:eval (if (buffer-file-name) (abbreviate-file-name (buffer-file-name)) "%b"))))

;; Change mini buffer startup message (defun display-startup-echo-area-message () (message "..."))

;; y/n for yes/no confirmation dial (defalias 'yes-or-no-p 'y-or-n-p)

;; Page scroll (defun gcm-scroll-down () (interactive) (scroll-up 4)) (defun gcm-scroll-up () (interactive) (scroll-down 4)) (global-set-key (kbd "M-p") 'gcm-scroll-up) (global-set-key (kbd "M-n") 'gcm-scroll-down)

;; Term paste (eval-after-load "term" '(define-key term-raw-map (kbd "C-c C-y") 'term-paste))

;; Puts temporary autosave files in one directory, so they do not clutter whole filesystem (defvar user-temporary-file-directory "~/.emacs-autosaves/") (make-directory user-temporary-file-directory t) (setq backup-by-copying t) (setq backup-directory-alist (("." . ,user-temporary-file-directory) (tramp-file-name-regexp nil))) (setq auto-save-list-file-prefix (concat user-temporary-file-directory ".auto-saves-")) (setq auto-save-file-name-transforms((".*" ,user-temporary-file-directory t)))

;; ------------------------------------- ;; Eshell stuff

;; Prompt (setq eshell-prompt-regexp "^[^#$\n]*[#$] " eshell-prompt-function (lambda nil (concat "[" (user-login-name) "@" (system-name) " " (if (string= (eshell/pwd) (getenv "HOME")) "~" (eshell/basename (eshell/pwd))) "]" (if (= (user-uid) 0) "# " "$ "))))

;; Quick Eshell per buffer (defun eshell-here () (interactive) (let ((parent (if (buffer-file-name) (file-name-directory (buffer-file-name)) default-directory)) (height (/ (window-total-height) 3)) (name (car (last (split-string parent "/" t))))) (split-window-vertically (- height)) (other-window 1) (eshell "new") (rename-buffer (concat "eshell: " name "*")) (insert (concat "ls")) (eshell-send-input))) (global-set-key (kbd "C-!") 'eshell-here) (defun eshell/x () "type x in eshell to exit" (delete-window) (eshell/exit))