dotemacs/init.el

483 lines
18 KiB
EmacsLisp

;; ;; (profiler-start 'cpu)
;; (toggle-debug-on-error)
;; ;; (toggle-debug-on-quit)
;; from https://github.com/jorgenschaefer/Config/blob/master/emacs.el#L796-L800
(when (file-directory-p "~/.emacs.d/elisp-git/")
(add-to-list 'load-path "~/.emacs.d/elisp-git/")
(dolist (dirname (directory-files "~/.emacs.d/elisp-git/" t "^[^.]"))
(when (file-directory-p dirname)
(if (string-match "magit$" dirname)
(add-to-list 'load-path (concat dirname "/lisp"))
(add-to-list 'load-path dirname)))))
(require 'dash)
;; (add-to-list 'load-path "~/.emacs.d/elisp-git/yafolding.el/")
(add-to-list 'load-path "~/.emacs.d/user/")
(add-to-list 'load-path "~/.emacs.d/contrapunctus/")
(load "cp")
(server-start)
;; 2017-06-09T00:24:36+0530
;; my laptop's X, W, and G keys gave up the ghost
;; temporary bindings, till my laptop keyboard is fixed
(global-set-key (kbd "<f8>") 'keyboard-quit)
(global-set-key (kbd "<f9>") 'cp/eval-sexp)
(global-set-key (kbd "M-<f9>") 'dired-jump)
(global-set-key (kbd "<f10>") 'save-buffer)
(global-set-key (kbd "M-<f10>") 'find-file)
(global-set-key (kbd "<f11>") 'ido-mini)
(global-set-key (kbd "M-<f11>") 'ibuffer)
(global-set-key (kbd "<f12>") 'smex)
(global-set-key (kbd "M-<f12>") 'text-scale-adjust)
(global-set-key (kbd "C-c C-j") 'join-line)
(global-set-key (kbd "C-c C-r") (lambda () (interactive) (revert-buffer t t)))
;;;; 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)
(add-hook 'dired-mode-hook (lambda () (setq truncate-lines 1)))
(add-hook 'text-mode-hook (lambda () (setq truncate-lines 1)))
(add-hook 'prog-mode-hook (lambda () (setq truncate-lines 1)))
(add-hook 'diff-mode-hook (lambda () (setq truncate-lines 1)))
(global-visual-line-mode -1)
(setq truncate-partial-width-windows nil
truncate-lines t)
(add-hook 'erc-mode-hook 'visual-line-mode)
(add-hook 'comint-mode-hook 'visual-line-mode)
(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)
(setq 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)
(with-eval-after-load 'info
(info-initialize)
(add-to-list 'Info-directory-list "~/.emacs.d/info/")
(cp-set-keys
:keymap Info-mode-map
:bindings
`((,(kbd "b") Info-history-back)
(,(kbd "f") Info-history-forward))))
(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"))
(defun cp-insert-timestamp ()
(interactive)
(insert (format-time-string "%FT%T%z")))
(autoload 'ag "ag" "ag" t)
(cp-set-keys
:bindings
`((,(kbd "M-<f2>") compile)
;; (,(kbd "<f2> p") grep)
(,(kbd "<f2> p") ag)
(,(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 "s-k") bury-buffer)
(,(kbd "C-x 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 l") (lambda () (interactive) (info "(lilypond-notation)")))
;; (,(kbd "<f1> i r") cp-info-lilylearn)
(,(kbd "<f5> t") cp-insert-timestamp)
(,(kbd "<f1> i s") (lambda () (interactive) (info "(stumpwm)")))
(,(kbd "<f1> i o") (lambda () (interactive) (info "(org)")))))
(load "cp-mouse")
(with-eval-after-load 'help-mode
(cp-set-keys
:keymap help-mode-map
:bindings
`((,(kbd "b") help-go-back)
(,(kbd "f") help-go-forward))))
(setq eshell-history-size nil)
;; More convenient Unicode keys
(global-unset-key (kbd "M-["))
(cp-set-keys
:bindings
`((,(kbd "C-' a") ,(kbd "ä"))
(,(kbd "C-' A") ,(kbd "Ä"))
(,(kbd "C-' u") ,(kbd "ü"))
(,(kbd "C-' U") ,(kbd "Ü"))
(,(kbd "C-' o") ,(kbd "ö"))
(,(kbd "C-' O") ,(kbd "Ö"))
(,(kbd "C-' s") ,(kbd "ß"))
(,(kbd "C-' r") ,(kbd ""))
(,(kbd "C-' e") ,(kbd ""))
(,(kbd "C-' b") ,(kbd ""))
(,(kbd "C-' f") ,(kbd ""))
(,(kbd "C-' p") ,(kbd ""))
(,(kbd "C-' n") ,(kbd ""))
(,(kbd "C-' t") ,(kbd ""))
(,(kbd "C-' l") ,(kbd "λ"))
(,(kbd "C-' F") ,(kbd "ƒ"))
(,(kbd "C-' C-r") ,(kbd ""))))
(setq default-input-method "devanagari-inscript")
(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)
(with-eval-after-load 'time
(setq display-time-next-load-average t)
(add-to-list 'display-time-world-list '("Europe/Berlin" "Berlin")))
;;;; Marmalade
(with-eval-after-load 'package
(add-to-list 'package-archives
'("marmalade" . "https://marmalade-repo.org/packages/")))
(package-initialize)
;; (load "cp-adb")
(load "cp-editing")
;; (load "cp-evil")
(load "cp-fm")
(load "cp-lily")
(load "cp-sfz")
(load "cp-lisp")
(load "cp-nav")
(load "cp-ui")
;; (ispell-change-dictionary "en")
(setq ispell-dictionary "en")
;; Comment out if using Evil, uncomment if not
(require 'undo-tree)
(global-undo-tree-mode)
(with-eval-after-load 'text-mode
(define-key text-mode-map (kbd "M-p") 'org-drag-line-backward)
(define-key text-mode-map (kbd "M-n") 'org-drag-line-forward))
(load "cp-org")
(autoload 'byte-recompile-file "bytecomp" "byte-recompile-file" t)
;; (2017-12-29T13:21:57+0530
;; TODO - watch Org and MD files and recompile it if they are newer
;; than their associated HTML files (e.g. I edited the source on a
;; phone and synced it back to the laptop)
;; see (info "(elisp) File Notifications")
;; and (describe-function 'file-newer-than-file-p)
;; )
;; (2018-01-05T13:59:39+0530
;; maybe also recompile and eval elisp files?
;; )
(defun cp/after-save ()
(case major-mode
('org-mode (org-html-export-to-html))
('emacs-lisp-mode (byte-compile-file (buffer-name)))
('LilyPond-mode (let ((project-dir (locate-dominating-file (buffer-file-name) "main.ly")))
(when project-dir
(cd project-dir))
(compile (car compile-history))))
;; 2017-10-15T17:09:03+0530
('latex-mode (if (file-exists-p "Makefile")
(compile "make -k")
(compile (concat "xelatex \"" (buffer-file-name)
"\""))))
;; 2017-12-27T12:08:40+0530
('markdown-mode (markdown-export))))
(add-hook 'after-save-hook 'cp/after-save)
(require 'ace-jump-mode)
;(define-key global-map (kbd "C-c SPC") 'ace-jump-mode)
(global-set-key (kbd "S-SPC") 'ace-jump-mode)
;; (load "cp-helm")
(load "cp-god")
(load "cp-hindi")
(load "cp-irc")
(load "cp-parens")
(load "cp-playlist")
(require 'keyfreq)
(keyfreq-mode 1)
(keyfreq-autosave-mode 1)
;; ;; disabled on 2017-08-18T19:39:21+0530, no longer interested
;; (open-dribble-file (concat "~/.emacs.d/keylogs/"
;; (format-time-string "%Y%m%d-%H%M%S")
;; ".txt"))
;; 2017-10-14T15:22:56+0530 - I suspect devanagari-itrans tires the
;; left hand faster than the right - let's find out!
(add-hook
'input-method-activate-hook
(lambda ()
(open-dribble-file
(concat
"~/.emacs.d/keylogs/"
(format-time-string "%Y%m%d-%H%M%S")
"-"
current-input-method
".txt"))))
(add-hook
'input-method-deactivate-hook
(lambda () (open-dribble-file nil)))
;; (add-hook
;; 'kill-emacs-hook
;; (lambda () (shell-command (concat "cat ~/.emacs.d/keylogs/"
;; (format-time-string "%Y%m%d*")
;; " && ls"))))
(autoload 'magit-status "magit" "magit" t)
(global-set-key (kbd "<f5> m") 'magit-status)
(with-eval-after-load 'magit
(define-key magit-mode-map (kbd "C-n") 'next-line)
(define-key magit-mode-map (kbd "C-p") 'previous-line))
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
(setq recentf-auto-cleanup 'never)
(require 'recentf)
(recentf-mode 1)
(setq recentf-max-menu-items 500
recentf-max-saved-items 1000
recentf-save-file "/home/anon/.emacs.d/recentf")
(add-hook 'kill-emacs-hook 'recentf-cleanup)
(global-set-key (kbd "C-x C-r C-o") 'recentf-open-files)
;; (require 'session)
;; (add-hook 'after-init-hook 'session-initialize)
(desktop-save-mode t)
(setq history-length 250)
(add-to-list 'desktop-globals-to-save 'grep-history)
(add-to-list 'desktop-globals-to-save 'grep-find-history)
(add-to-list 'desktop-globals-to-save 'find-args-history)
(add-to-list 'desktop-globals-to-save 'extended-command-history)
(add-to-list 'desktop-globals-to-save 'read-expression-history)
(add-to-list 'desktop-globals-to-save 'input-method-history)
(add-to-list 'desktop-globals-to-save 'query-replace-history)
(add-to-list 'desktop-globals-to-save 'compile-history)
(add-to-list 'desktop-globals-to-save 'string-rectangle-history)
(add-to-list 'desktop-globals-to-save 'regexp-history)
(add-to-list 'desktop-globals-to-save 'dired-shell-command-history)
(add-to-list 'desktop-globals-to-save 'shell-command-history)
(add-to-list 'desktop-globals-to-save 'org-tags-history)
(desktop-auto-save-enable)
(setq desktop-save t
use-file-dialog nil)
(with-eval-after-load 'stumpwm-mode
(setq stumpwm-shell-program
"~/git/stumpwm-contrib/util/stumpish/stumpish"))
(autoload 'stumpwm-mode "stumpwm-mode" "stumpwm-mode" t)
(add-to-list 'auto-mode-alist '("\\.stumpwmrc$" . stumpwm-mode))
;; 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))
'(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)
;; (toggle-debug-on-quit)
;; (profiler-stop)
;; (emacs-init-time)
;; (profiler-report)
(put 'erc-remove-text-properties-region 'disabled nil)