dotemacs/init.el

446 lines
17 KiB
EmacsLisp

(add-to-list 'load-path "~/.emacs.d/elisp-git/color-moccur/")
(add-to-list 'load-path "~/.emacs.d/elisp-git/magit/lisp/")
;; (add-to-list 'load-path "~/.emacs.d/elisp-git/yafolding.el/")
(add-to-list 'load-path "~/.emacs.d/elisp-git/es-lib/")
(add-to-list 'load-path "~/.emacs.d/elisp-git/es-windows")
(add-to-list 'load-path "~/.emacs.d/elisp-git/slime/")
(add-to-list 'load-path "~/.emacs.d/elisp-git/Emacs-wgrep/")
(add-to-list 'load-path "~/.emacs.d/user/")
(add-to-list 'load-path "~/.emacs.d/contrapunctus/")
(defun cp-global-set-many-keys (bindings)
"A clean way to define many keys using `global-set-key'.
BINDINGS must be in the form `((,(kbd \"...\") FN) ...)"
(mapc (lambda (b)
(global-set-key (car b) (cadr b)))
bindings))
(defun cp-define-many-keys (keymap bindings)
"A clean way to define many keys using `define-key'.
KEYMAP must be a valid keymap.
BINDINGS must be in the form `((,(kbd \"...\") FN) ...)"
(mapc (lambda (b)
(define-key keymap (car b) (cadr b)))
bindings))
(defun cp-local-set-many-keys (bindings)
"A clean way to define many keys using `local-set-key'.
BINDINGS must be in the form `((,(kbd \"...\") FN) ...)"
(mapc (lambda (b)
(local-set-key (car b) (cadr b)))
bindings))
(require 'cl)
(cl-defun cp-set-keys (&key keymap unset bindings)
"A clean way to set/unset many keybindings.
BINDINGS specifies the functions and the keys they are to be
bound to. It must be an alist in the form -
`((,(kbd \"...\") FN) ...)
If KEYMAP is a symbol `global' or not supplied, the binding is
created by `global-set-key'.
If it is a symbol `local', the binding is created by
`local-set-key'.
Otherwise, it is assumed to be a keymap and the binding is
created with `define-key'.
If UNSET is non-nil, unset keybinds as specified by KEYMAP
instead of setting them. If a keymap is specified, the key is unset
by using define-key to set it to nil in the given keymap -
otherwise, global-unset-key or local-unset-key are used as
applicable."
(let ((key-function (if (not unset)
(pcase keymap
((or `global `nil) #'global-set-key)
(`local #'local-set-key)
(x #'define-key))
(pcase keymap
((or `global `nil) #'global-unset-key)
(`local #'local-unset-key)
(x #'define-key)))))
(if (eq key-function 'define-key)
(if unset
(mapc (lambda (b)
(funcall key-function keymap (car b) nil))
bindings)
(mapc (lambda (b)
(funcall key-function keymap (car b) (cadr b)))
bindings))
(if unset
(mapc (lambda (b)
(funcall key-function (car b)))
bindings)
(mapc (lambda (b)
(funcall key-function (car b) (cadr b)))
bindings)))))
;; tests
(progn (cp-set-keys :keymap 'global ; not actually needed, e.g. see next call
:bindings `((,(kbd "<f6>") erc) (,(kbd "<f7>") eww)))
(and (equal 'erc (lookup-key (current-global-map) (kbd "<f6>")))
(equal 'eww (lookup-key (current-global-map) (kbd "<f7>")))))
(progn (cp-set-keys :unset t
:bindings `((,(kbd "<f6>") erc) (,(kbd "<f7>") eww)))
(and (equal nil (lookup-key (current-global-map) (kbd "<f6>")))
(equal nil (lookup-key (current-global-map) (kbd "<f7>")))))
(progn (cp-set-keys :keymap emacs-lisp-mode-map
:bindings `((,(kbd "<f6>") erc) (,(kbd "<f7>") eww)))
(and (equal 'erc (lookup-key emacs-lisp-mode-map (kbd "<f6>")))
(equal 'eww (lookup-key emacs-lisp-mode-map (kbd "<f7>")))))
(progn (cp-set-keys :keymap emacs-lisp-mode-map
:unset t
:bindings `((,(kbd "<f6>") erc) (,(kbd "<f7>") eww)))
(and (equal nil (lookup-key emacs-lisp-mode-map (kbd "<f6>")))
(equal nil (lookup-key emacs-lisp-mode-map (kbd "<f7>")))))
(progn (cp-set-keys :keymap 'local
:bindings `((,(kbd "<f6>") erc) (,(kbd "<f7>") eww)))
(and (equal 'erc (lookup-key emacs-lisp-mode-map (kbd "<f6>")))
(equal 'eww (lookup-key emacs-lisp-mode-map (kbd "<f7>")))))
(progn (cp-set-keys :keymap 'local
:unset t
:bindings `((,(kbd "<f6>") erc) (,(kbd "<f7>") eww)))
(and (equal nil (lookup-key emacs-lisp-mode-map (kbd "<f6>")))
(equal nil (lookup-key emacs-lisp-mode-map (kbd "<f7>")))))
;;;; UTF-8 magic
(setq locale-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
;;;; Linewrapping
(defun line-trunc-set ()
(visual-line-mode -1)
;(setq-default truncate-partial-width-windows t)
;(setq-default truncate-lines t))
(setq truncate-partial-width-windows t)
(setq truncate-lines t))
;; (defun line-trunc-set ()
;; (interactive)
;; (if (or truncate-lines
;; visual-line-mode)
;; (progn
;; (visual-line-mode -1)
;; (setq truncate-lines t))
;; (progn
;; (visual-line-mode 1)
;; (setq truncate-lines nil))))
;(add-hook 'text-mode-hook 'line-trunc-set)
(add-hook 'emacs-lisp-mode-hook 'line-trunc-set)
(add-hook 'org-mode-hook 'visual-line-mode)
(add-hook 'erc-mode-hook 'visual-line-mode)
;(global-set-key (kbd "C-x t") 'toggle-truncate-lines)
(global-visual-line-mode 1)
(add-hook 'markdown-mode-hook 'auto-fill-mode)
(add-hook 'text-mode-hook 'auto-fill-mode)
;; (add-hook 'paredit-mode-hook 'auto-fill-mode)
;;;; Tab settings
(setq default-tab-width 4)
;(define-key text-mode-map (kbd "TAB") 'self-insert-command)
(setq-default indent-tabs-mode nil)
;;;; Fix scrolling
(setq scroll-conservatively 10000
scroll-preserve-screen-position t)
(setq auto-window-vscroll nil)
;;; Recenter screen on isearch matches
(add-hook 'isearch-mode-hook 'recenter)
(add-hook 'isearch-update-post-hook 'recenter)
(defadvice isearch-repeat-forward
(after isearch-repeat-forward-recenter activate) (recenter))
(defadvice isearch-repeat-backward
(after isearch-repeat-backward-recenter activate) (recenter))
(ad-activate 'isearch-repeat-forward)
(ad-activate 'isearch-repeat-backward)
(global-set-key (kbd "C-s") 'isearch-forward-regexp)
(global-set-key (kbd "C-r") 'isearch-backward-regexp)
;;;; While we're at it, let's add that to next-error as well
;;;; (this affects jumping to match from M-x grep , too)
(add-hook 'next-error-hook 'recenter)
;;;; ...and to magit-toggle-section
;;; It'd be really cool to (recenter 3) when you /open/ a section,
;;; and (recenter) when you close a section
(defadvice magit-section-toggle
(after magit-section-toggle-recenter activate) (recenter 3))
(ad-activate 'magit-section-toggle)
(defadvice magit-unstage-item
(after magit-unstage-item-move) (next-line))
(ad-activate 'magit-unstage-item)
(defadvice magit-goto-next-section
(after magit-next-section-recenter activate) (recenter 3))
(ad-activate 'magit-goto-next-section)
(defadvice magit-goto-previous-section
(after magit-previous-section-recenter activate) (recenter 3))
(ad-activate 'magit-goto-previous-section)
(require 'info)
(defun cp-info-emacs ()
(interactive) (info "(emacs)"))
(defun cp-info-elisp ()
(interactive) (info "(elisp)"))
(defun cp-info-lilyref ()
(interactive) (info "(lilypond-notation)"))
(defun cp-info-lilylearn ()
(interactive) (info "(lilypond-learning)"))
(global-unset-key (kbd "<f1> i"))
(cp-set-keys
:bindings
`((,(kbd "M-<f2>") compile)
(,(kbd "<f2> p") grep)
(,(kbd "<f2> o") find-grep)
(,(kbd "<f2> i") find-dired)
(,(kbd "M-<f3>") run-scheme)
(,(kbd "M-<f4>") run-lisp)
(,(kbd "<f5> <f5>") eval-buffer)
(,(kbd "M-<f5>") ielm)
(,(kbd "<f5> i") cp-open-init)
(,(kbd "<f5> p") list-packages)
(,(kbd "<f5> v") visual-line-mode)
(,(kbd "<f5> f") cp-fcf-literally)
(,(kbd "<f5> c") calendar)
(,(kbd "s-k") cp-kill-buffer)
(,(kbd "C-`") eshell)
(,(kbd "<f1> i i") info)
(,(kbd "<f1> i a") info-apropos)
(,(kbd "<f1> i q") cp-info-emacs)
(,(kbd "<f1> i w") cp-info-elisp)
(,(kbd "<f1> i e") cp-info-lilyref)
(,(kbd "<f1> i r") cp-info-lilylearn)))
(cp-set-keys
:keymap Info-mode-map
:bindings
`((,(kbd "b") Info-history-back)
(,(kbd "f") Info-history-forward)))
(setq eshell-history-size nil)
;; More convenient Unicode keys
(global-unset-key (kbd "M-["))
(cp-set-keys
:bindings
`((,(kbd "M-[ a") ,(kbd "ä"))
(,(kbd "M-[ A") ,(kbd "Ä"))
(,(kbd "M-[ u") ,(kbd "ü"))
(,(kbd "M-[ U") ,(kbd "Ü"))
(,(kbd "M-[ o") ,(kbd "ö"))
(,(kbd "M-[ O") ,(kbd "Ö"))
(,(kbd "M-[ s") ,(kbd "ß"))
(,(kbd "M-[ r") ,(kbd ""))
(,(kbd "M-[ e") ,(kbd ""))
(,(kbd "M-[ b") ,(kbd ""))
(,(kbd "M-[ f") ,(kbd ""))
(,(kbd "M-[ p") ,(kbd ""))
(,(kbd "M-[ n") ,(kbd ""))
(,(kbd "M-[ t") ,(kbd ""))
(,(kbd "M-[ l") ,(kbd "λ"))
(,(kbd "M-[ F") ,(kbd "ƒ"))))
(setq backup-by-copying t
backup-directory-alist
'(("." . "~/.emacs.d/saves/"))
delete-old-versions t
kept-new-versions 6
kept-old-versions 2
version-control t)
(setq browse-url-browser-function 'browse-url-xdg-open)
(require 'time)
(setq display-time-next-load-average t)
(add-to-list 'display-time-world-list '("Europe/Berlin" "Berlin"))
;;;; Marmalade
(require 'package)
(add-to-list 'package-archives
'("marmalade" . "https://marmalade-repo.org/packages/"))
;//// //// //// //// //// ////
;//// PACKAGE INITIALIZE ////
;//// //// //// //// //// ////
(package-initialize)
(load "cp-adb")
(load "cp-editing")
;; (load "cp-evil")
(load "cp-fm")
(load "cp-lily")
(load "cp-lisp")
(load "cp-nav")
(load "cp-ui")
;; Comment out if using Evil, uncomment if not
(require 'undo-tree)
(global-undo-tree-mode)
(require 'org)
(global-set-key (kbd "<f5> o") 'org-mode)
;(setq org-M-RET-may-split-line 'nil)
(add-hook 'org-mode-hook 'org-display-inline-images)
(cp-set-keys
:keymap org-mode-map
:bindings
`((,(kbd "C-,") nil)
(,(kbd "M-n") org-metadown)
(,(kbd "M-p") org-metaup)
(,(kbd "C-c C--") org-ctrl-c-minus)
(,(kbd "C-c C-,") org-metaleft)
(,(kbd "C-c C-.") org-metaright)
;; (,(kbd "C-j") org-return)
;; (,(kbd "C-m") org-return-indent)
))
;; (defun contrapunctus-org-expand-all ()
;; (interactive)
;; ;; todo - define inner recursive function
;; (beginning-of-buffer)
;; ;; todo - check if we are on a heading
;; (org-forward-heading-same-level)
;; ())
(require 'ace-jump-mode)
;(define-key global-map (kbd "C-c SPC") 'ace-jump-mode)
(global-set-key (kbd "M-SPC") 'ace-jump-mode)
(load "cp-helm")
(load "cp-god")
(load "cp-irc")
(load "cp-parens")
(require 'magit)
(global-set-key (kbd "<f5> m") 'magit-status)
(global-set-key (kbd "C-x m") 'magit-status)
(define-key magit-mode-map (kbd "C-n") 'next-line)
(define-key magit-mode-map (kbd "C-p") 'previous-line)
(require 'markdown-mode)
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
(require 'recentf)
(recentf-mode 1)
(setq recentf-max-menu-items 500)
(setq recentf-max-saved-items nil)
(setq recentf-save-file "/home/anon/.emacs.d/recentf")
(global-set-key (kbd "C-x C-r C-o") 'recentf-open-files)
(require 'session)
(add-hook 'after-init-hook 'session-initialize)
(require 'stumpwm-mode)
(setq stumpwm-shell-program
"~/git/stumpwm-contrib/util/stumpish/stumpish")
;; I'd love to know how to automatically set some modes for some
;; specific files (i.e. by name of file). Start stumpwm-mode when I
;; open ~/.stumpwmrc, disable visual lines and enable truncate lines
;; for some files, etc...
;;;; text size change
(set-face-attribute 'default nil :font "-outline-Bitstream Vera Sans Mono-normal-normal-normal-mono-12-*-*-*-c-*-iso8859-1")
(require 'wgrep)
;; (require 'yafolding)
;; (add-hook 'prog-mode-hook
;; (lambda () (yafolding-mode)))
(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.
'(ansi-color-faces-vector
[default bold shadow italic underline bold bold-italic bold])
'(ansi-term-color-vector
[unspecified "#1F1611" "#660000" "#144212" "#EFC232" "#5798AE" "#BE73FD" "#93C1BC" "#E6E1DC"])
'(compilation-message-face (quote default))
'(completion-styles (quote (partial-completion basic emacs22)))
'(custom-safe-themes
(quote
("3cd28471e80be3bd2657ca3f03fbb2884ab669662271794360866ab60b6cb6e6" "47160226d9b534d26067fcfb07f6bc1ea5922d9caafd29536c1a212e1cef571b" "f0ea6118d1414b24c2e4babdc8e252707727e7b4ff2e791129f240a2b3093e32" "bf4097b29a98d5653e10a97cf3436c6b57dfb4750be6b083ca353fea06efe2be" "57f8801351e8b7677923c9fe547f7e19f38c99b80d68c34da6fa9b94dc6d3297" "5d9351cd410bff7119978f8e69e4315fd1339aa7b3af6d398c5ca6fac7fd53c7" "70cf411fbf9512a4da81aa1e87b064d3a3f0a47b19d7a4850578c8d64cac2353" "e35ef4f72931a774769da2b0c863e11d94e60a9ad97fb9734e8b28c7ee40f49b" "96efbabfb6516f7375cdf85e7781fe7b7249b6e8114676d65337a1ffe78b78d9" "4aee8551b53a43a883cb0b7f3255d6859d766b6c5e14bcb01bed572fcbef4328" "d809ca3cef02087b48f3f94279b86feca896f544ae4a82b523fba823206b6040" "a507b9ca4a605d5256716da70961741b9ef9ec3246041a4eb776102e8df18418" "2affb26fb9a1b9325f05f4233d08ccbba7ec6e0c99c64681895219f964aac7af" "65ae93029a583d69a3781b26044601e85e2d32be8f525988e196ba2cb644ce6a" "0795e2c85394140788d72d34969be4acb305e4a54149e7237787d9df27832fbb" "8aebf25556399b58091e533e455dd50a6a9cba958cc4ebb0aab175863c25b9a4" "47bff723f2aca3a9a5726abcc52a7cc4192b556dd80b3f773589994d2ed24d16" "013e87003e1e965d8ad78ee5b8927e743f940c7679959149bbee9a15bd286689" "ad9fc392386f4859d28fe4ef3803585b51557838dbc072762117adad37e83585" "1011be33e9843afd22d8d26b031fbbb59036b1ce537d0b250347c19e1bd959d0" "784d5ee4d33befba6a21702ead67f98346770be7cc17ab64952ae3866a403743" "930a202ae41cb4417a89bc3a6f969ebb7fcea5ffa9df6e7313df4f7a2a631434" "0e121ff9bef6937edad8dfcff7d88ac9219b5b4f1570fd1702e546a80dba0832" "442c946bc5c40902e11b0a56bd12edc4d00d7e1c982233545979968e02deb2bc" "e16a771a13a202ee6e276d06098bc77f008b73bbac4d526f160faa2d76c1dd0e" "9eb5269753c507a2b48d74228b32dcfbb3d1dbfd30c66c0efed8218d28b8f0dc" "c4e6fe8f5728a5d5fd0e92538f68c3b4e8b218bcfb5e07d8afff8731cc5f3df0" "c739f435660ca9d9e77312cbb878d5d7fd31e386a7758c982fa54a49ffd47f6e" "97a2b10275e3e5c67f46ddaac0ec7969aeb35068c03ec4157cf4887c401e74b1" "024b0033a950d6a40bbbf2b1604075e6c457d40de0b52debe3ae994f88c09a4a" default)))
'(debug-on-error nil)
'(diary-entry-marker (quote font-lock-variable-name-face))
'(dired-listing-switches "-ahl --group-directories-first --time-style=long-iso")
'(fci-rule-character-color "#452E2E")
'(gnus-logo-colors (quote ("#0d7b72" "#adadad")))
'(helm-completing-read-handlers-alist
(quote
((describe-function . helm-completing-read-symbols)
(describe-variable . helm-completing-read-symbols)
(debug-on-entry . helm-completing-read-symbols)
(find-function . helm-completing-read-symbols)
(find-tag . helm-completing-read-with-cands-in-buffer)
(ffap-alternate-file)
(tmm-menubar)
(completon-at-point . f))))
'(highlight-changes-colors (quote ("#FD5FF0" "#AE81FF")))
'(highlight-tail-colors
(quote
(("#49483E" . 0)
("#67930F" . 20)
("#349B8D" . 30)
("#21889B" . 50)
("#968B26" . 60)
("#A45E0A" . 70)
("#A41F99" . 85)
("#49483E" . 100))))
'(org-html-infojs-options
(quote
((path . "/media/alpha/kashish/4_txt_files/org-info.js")
(view . "overview")
(toc . :with-toc)
(ftoc . "0")
(tdepth . "max")
(sdepth . "max")
(mouse . "underline")
(buttons . "0")
(ltoc . "1")
(up . :html-link-up)
(home . :html-link-home))))
'(session-registers (quote (t 45 61 92 96 region (97 . 122))))
'(session-use-package t nil (session))
'(syslog-debug-face
(quote
((t :background unspecified :foreground "#A1EFE4" :weight bold))))
'(syslog-error-face
(quote
((t :background unspecified :foreground "#F92672" :weight bold))))
'(syslog-hour-face (quote ((t :background unspecified :foreground "#A6E22E"))))
'(syslog-info-face
(quote
((t :background unspecified :foreground "#66D9EF" :weight bold))))
'(syslog-ip-face (quote ((t :background unspecified :foreground "#E6DB74"))))
'(syslog-su-face (quote ((t :background unspecified :foreground "#FD5FF0"))))
'(syslog-warn-face
(quote
((t :background unspecified :foreground "#FD971F" :weight bold))))
'(weechat-color-list
(quote
(unspecified "#272822" "#49483E" "#A20C41" "#F92672" "#67930F" "#A6E22E" "#968B26" "#E6DB74" "#21889B" "#66D9EF" "#A41F99" "#FD5FF0" "#349B8D" "#A1EFE4" "#F8F8F2" "#F8F8F0")))
'(yafolding-ellipsis-content "
..."))
(custom-set-faces
;; custom-set-faces 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.
'(magit-item-highlight ((t nil))))
(put 'downcase-region 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'set-goal-column 'disabled nil)