;; TODO - convert to use-package ;; TODO - drop cp/ prefix, use contrapunctus-, set up nameless package names ;; TODO - trying setting up xref (eval-when-compile (add-to-list 'load-path "~/.emacs.d/elisp-git/use-package/") (require 'use-package)) (use-package info :config (info-initialize) (add-to-list 'Info-directory-list "~/.emacs.d/info/") (add-to-list 'Info-directory-list "~/.emacs.d/elisp-git/geiser/doc/") :bind ((" i" . nil) (" i i" . info) (" i a" . info-apropos) (" i q" . (lambda () (interactive) (info "(emacs)"))) (" i w" . (lambda () (interactive) (info "(elisp)"))) (" i l" . (lambda () (interactive) (info "(lilypond-notation)"))) (" i r" . (lambda () (interactive) (info "(lilypond-learning)"))) (" i s" . (lambda () (interactive) (info "(stumpwm)"))) (" i o" . (lambda () (interactive) (info "(org)"))) (" i g" . (lambda () (interactive) (info "(guile)")))) :bind (:map Info-mode-map ("b" . Info-history-back) ("f" . Info-history-forward))) (use-package time :config (setq display-time-next-load-average t) (add-to-list 'display-time-world-list '("Europe/Berlin" "Berlin"))) ;; (toggle-debug-on-error) (setenv "PATH" (concat "/home/anon/bin:" (getenv "PATH"))) (setenv "EDITOR" "emacsclient") ;; what on earth is this message after every init - ;; ad-handle-definition: `tramp-read-passwd' got redefined ;; ;; (profiler-start 'cpu) ;; (toggle-debug-on-error) ;; ;; (toggle-debug-on-quit) ;; from https://github.com/jorgenschaefer/Config/blob/master/emacs.el#L796-L800 (mapc (lambda (path) (when (file-directory-p path) (add-to-list 'load-path path) (dolist (dirname (directory-files path t "^[^.]")) (when (file-directory-p dirname) (let ((try1 (concat dirname "/elisp")) (try2 (concat dirname "/lisp"))) (add-to-list 'load-path (cond ((file-exists-p try1) try1) ((file-exists-p try2) try2) (t dirname)))))))) '("~/.emacs.d/elisp-git/" "~/.emacs.d/contrapunctus" "~/.emacs.d/elpa/")) (require 'dash) (require 's) (require 'visual-fill-column) ;; (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/") (add-to-list 'load-path "~/.emacs.d/contrapunctus/fin/") (add-to-list 'load-path "~/.emacs.d/contrapunctus/ido-mini/") (add-to-list 'load-path "~/.emacs.d/contrapunctus/timeclock-ui/") (load "cp") ;; (if (not (server-running-p)) (server-start)) (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 "") 'keyboard-quit) (global-set-key (kbd "") 'cp/eval-sexp) (global-set-key (kbd "M-") 'dired-jump) (global-set-key (kbd "") 'save-buffer) (global-set-key (kbd "M-") 'find-file) (global-set-key (kbd "") 'ido-mini) (global-set-key (kbd "M-") 'ibuffer) (global-set-key (kbd "") 'smex) (global-set-key (kbd "M-") '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) ;; 2018-07-26T19:57:29+0530 (add-hook 'markdown-mode-hook '(lambda () (visual-fill-column-mode t))) (add-hook 'text-mode-hook '(lambda () (visual-line-mode t))) (load "cp-md") (defun cp/turn-on-truncate-lines () (setq truncate-lines 1)) (defun cp/add-to-hooks (function hooks) (-map (lambda (hook) (add-hook hook function)) hooks)) (defun cp/remove-from-hooks (function hooks) (-map (lambda (hook) (remove-hook hook function)) hooks)) (cp/add-to-hooks 'cp/turn-on-truncate-lines '(dired-mode-hook text-mode-hook prog-mode-hook diff-mode-hook message-mode-hook)) (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) ;; commented out on 2018-03-19T14:18:34+0530 ;; (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) (defun cp-insert-timestamp () (interactive) (insert (format-time-string "%FT%T%z"))) (autoload 'ag-regexp "ag" "ag" t) (with-eval-after-load 'ag (setq ag-highlight-search t ag-arguments '("--smart-case" "--nogroup" "--column" "-z" "--"))) (require 'fin) (defun cp/eval-sexp (arg) "In emacs-lisp-mode, just run eval-defun. In other modes - jump to first Lisp expression in current line and eval it." (interactive "P") (save-excursion (cond ((or (equal major-mode 'emacs-lisp-mode) (equal major-mode 'lisp-interaction-mode)) (eval-defun arg)) ((re-search-line "(") (progn (forward-char -1) (forward-sexp) (eval-last-sexp arg))) (t nil)))) (use-package nameless :commands nameless-mode :init (add-hook 'emacs-lisp-mode-hook 'nameless-mode) (add-hook 'ert-results-mode-hook 'nameless-mode) :bind (:map emacs-lisp-mode-map ("C-c C-n" . nameless-mode))) (cp-set-keys :bindings `((,(kbd "M-") compile) (,(kbd " ") imenu) ;; (,(kbd " p") grep) (,(kbd " p") ag-regexp) (,(kbd " o") find-grep) (,(kbd " i") find-dired) (,(kbd " h") proced) (,(kbd "M-") run-chicken) (,(kbd "M-") run-lisp) (,(kbd " ") eval-buffer) (,(kbd "M-") ielm) (,(kbd " i") cp-open-init) (,(kbd " p") list-packages) (,(kbd " v") visual-line-mode) (,(kbd " f") cp-fcf-literally) (,(kbd " f") fundamental-mode) (,(kbd " t") text-mode) (,(kbd " c") calendar) ;; (,(kbd "s-k") cp-kill-buffer) (,(kbd "s-k") bury-buffer) (,(kbd "C-x k") cp-kill-buffer) (,(kbd "C-`") eshell) (,(kbd " T") cp-insert-timestamp) (,(kbd " l") find-library))) (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-itrans") (setq backup-by-copying t backup-directory-alist '(("." . "~/.emacs.d/saves/")) delete-old-versions t kept-new-versions 2 kept-old-versions 2 version-control t) (setq browse-url-browser-function 'browse-url-xdg-open) (require 'package) (let* ((no-ssl (and (memq system-type '(windows-nt ms-dos)) (not (gnutls-available-p)))) (proto (if no-ssl "http" "https"))) ;; 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 '("gnu" . (concat proto "://elpa.gnu.org/packages/"))))) (package-initialize) (use-package company :diminish company-mode :commands global-company-mode :init (global-company-mode)) (use-package company-emoji :if (featurep 'company) :config (add-to-list 'company-backends 'company-emoji)) ;; (load "cp-adb") (load "cp-editing") ;; (load "cp-evil") (load "cp-god") (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") (use-package undo-tree :if (not (featurep 'evil)) :diminish undo-tree-mode :init (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) ;; ) (defun cp/after-save () (case major-mode ('org-mode (org-html-export-to-html)) ('LilyPond-mode (let ((project-dir (locate-dominating-file (buffer-file-name) "main.ly"))) (when project-dir (cd project-dir)) (compile (car compile-history)))) ('latex-mode (if (file-exists-p "Makefile") (compile "make -k") (compile (concat "xelatex \"" (buffer-file-name) "\"")))) ('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-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 " 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) ;; (setq magit-git-output-coding-system 'utf-8 ;; magit-git-global-arguments (append magit-git-global-arguments '("-c" "i18n.logOutputEncoding=utf-8"))) ) (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" recentf-exclude '("\.html\\(\.orig\\)?$" "\.jpe?g$" "\.png$" "\.mp4$" "\.etc" "\.umstuff")) (add-hook 'kill-emacs-hook 'recentf-cleanup) (global-set-key (kbd "C-x C-r C-o") 'recentf-open-files) (load "cp-ido") (load "cp-desktop") (require 'timeclock-list) (require 'timeclock-report) (add-hook 'kill-emacs-query-functions 'timeclock-query-out) (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 ;; nicked from wasamasa's init - https://github.com/wasamasa/dotemacs/blob/934d0b37692d62fe9af56b52accac5bcd4445ae3/init.org (setq default-frame-alist '((font . "DejaVu Sans Mono-10.5"))) (defun my-fix-emojis (&optional frame) (set-fontset-font "fontset-default" nil "Symbola" frame 'append)) (my-fix-emojis) (add-hook 'after-make-frame-functions 'my-fix-emojis) ;; (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))) (setq custom-file "~/.emacs.d/custom.el") (load custom-file) (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 'scroll-left 'disabled nil) (put 'erc-remove-text-properties-region 'disabled nil)