dotemacs/init.el

983 lines
32 KiB
EmacsLisp

;; TODO - convert to use-package
;; TODO - drop cp/ prefix, use contrapunctus-, set up nameless package
;; names
;; TODO - create wrapper for
;; xref-find-definitions/xref-find-definitions-other-window
;; TODO - make ag suggest my last isearch term
;; TODO - make a completing prompt for Info manuals instead of the
;; current approach of either opening info and searching for a manual
;; or binding calls to (info "(something)") to keys.
;; TODO - add idle timer for recentf-cleanup
;; TODO - write command to deduce actions for directory based on
;; contents. e.g. if a directory has only/mostly videos, run `vlc
;; --recursive expand <dir>', mostly images - `sxiv -for <dir>', etc.
;; With prefix arg or when confused, ask for command (with
;; completion).
;; TODO - lets write something quicker to find files. Don't ask for
;; directory * - just start in the current working directory. Update
;; results as we type (after a little delay). Don't make user input
;; arguments to find(1) * - by default, search the whole path, put
;; filename matches first, path matches later.
;;
;; * maybe only with prefix arg.
;; TODO - stop desktop-save from saving my buffers - just save history etc (persp-mode?)
;; TODO - make idle timer to find all local git repos with uncommited changes
;;;; Code:
(eval-when-compile
(add-to-list 'load-path "~/.emacs.d/elisp-git/use-package/")
(require 'use-package))
;; 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/"
"~/.emacs.d/user"))
(load "cp-ui")
(require 'atomic-chrome)
(atomic-chrome-start-server)
(setq atomic-chrome-url-major-mode-alist
'(("wikisource" . mediawiki-mode)))
(use-package emacs
:config
(setq delete-by-moving-to-trash t
trash-directory "~/.trash/"))
(use-package ag
:ensure t
:bind
("<f2> p" . ag)
("<f2> P" . ag-project-regexp)
:config
(setq ag-highlight-search t))
(require 'cp-modal)
(require 'cp-god)
(use-package chronometrist
:ensure t
:commands chronometrist-assist
:load-path "~/.emacs.d/contrapunctus/chronometrist"
:hook
(kill-emacs-query-functions . 'timeclock-query-out)
:bind ("<f9>" . #'chronometrist)
;; (:map chronometrist-mode-map
;; ("RET" . #'chronometrist-toggle-project-no-reason)
;; ("M-RET" . #'chronometrist-toggle-project)
;; ([mouse-1] . #'chronometrist-toggle-project-no-reason)
;; ([mouse-3] . #'chronometrist-toggle-project))
:config
(require 'chronometrist-targets)
(setq chronometrist-time-targets-list
'((15 "Arrangement/new edition")
(15 "Aural exercises")
(15 "Transcription"
"Music theory")
(30 "Composing"
"Writing"
"Recording")
(15 "Data organization"
"Physical organization"
"Khilona archiving")
(60 "Exercise")
(120 "Guitar")
(90 "Reading")
(60 "Singing")
(20 "Subtitles")
(15 "Acting")
(30 "Keyboard"))
alert-default-style 'libnotify
chronometrist-before-in-functions '()
chronometrist-after-in-functions '(;; chronometrist-tags-add
;; chronometrist-kv-add
contrapunctus-start-project
chronometrist-run-alert-timers)
chronometrist-before-out-functions '(contrapunctus-before-project-stop
chronometrist-tags-add
chronometrist-kv-add)
chronometrist-after-out-functions '(contrapunctus-after-project-stop
chronometrist-stop-alert-timers)
chronometrist-activity-indicator
(lambda ()
(thread-first (chronometrist-last-expr)
(plist-put :stop (chronometrist-format-time-iso8601))
chronometrist-interval
cadr
chronometrist-seconds-to-hms
(chronometrist-format-time ""))))
(add-hook 'chronometrist-kv-read-mode-hook 'visual-line-mode)
(add-hook 'kill-emacs-query-functions 'chronometrist-query-stop))
(defun contrapunctus-find-two-files-other-window (file-1 file-2)
"Open FILE-1 and FILE-2 in new windows.
FILE-1 will appear above FILE-2."
(find-file-other-window file-2)
(split-window-below)
(find-file file-1))
(defun cp-outline-open-heading (n)
(goto-char (point-min))
(outline-next-visible-heading n)
(outline-show-subtree))
(defun contrapunctus-start-project (project)
(delete-other-windows)
(pcase project
("Arrangement/new edition"
(find-file-other-window "~/Documents/Text Files/music_stuff/arrange.org"))
("Composing"
(find-file-other-window "~/1-music-notation/2-my-compositions/2019/2019-03 Kahe Natak Karte Ho Ji/Kahe Natak Karte Ho Ji?.org")
(cp-outline-open-heading 1))
("Data organization"
(find-dired "~/" "-name \'dl\' -size +0c"))
("Exercise"
(let* ((path-1 "~/Documents/Text Files/ma/practice.org")
(path-2 "~/Documents/Text Files/ma/0shoto-syllabus.org")
(file-1 (file-name-nondirectory path-1))
(file-2 (file-name-nondirectory path-2)))
(contrapunctus-find-two-files-other-window path-1 path-2)
(select-window (get-buffer-window file-1))))
("Guitar"
(let* ((path-1 "~/Sync/Scores/guitar-solo/repertoire.org")
(path-2 "~/Sync/Scores/guitar-duo/repertoire.org")
(weekday (elt (decode-time) 6))
(week (string-to-number (format-time-string "%U"))))
(contrapunctus-find-two-files-other-window path-1 path-2)
(select-window (get-buffer-window (get-file-buffer path-1)))
(org-match-sparse-tree nil "perform")))
("Keyboard"
(find-file-other-window "~/Documents/Text Files/music_stuff/piano.org")
(outline-show-subtree))
("Khilona archiving"
(find-file-other-window "/home/anon/Documents/sync/Khilona/")
(split-window-below)
(other-window 1)
(find-file "/home/anon/Videos/Khilona/Me?/")
(other-window 1)
(find-file "/home/anon/Documents/Text Files/khilona/2011 Me?/script/script.tex"))
("OSM"
;; (async-shell-command "java -jar ~/josm-tested.jar" " *JOSM*" " *JOSM errors*")
;; (delete-window (get-buffer-window " *JOSM*"))
(contrapunctus-find-two-files-other-window "~/phone/Nokia 6.1/Android/data/net.osmand.plus/files/"
;; "~/phone/Nokia 6.1/external/DCIM/OpenCamera/osm/"
"~/phone/Nokia 6.1/Documents/Markor/OSM/TODO.md"))
;; https://github.com/bbatsov/emacs-lisp-style-guide#comment-annotations
("Programming"
(grep (->> '("grep" "--color" "-EnHiIR" "-e '(TODO|FIXME|OPTIMIZE|HACK|REVIEW)'"
"--exclude=\"*.html\""
"--exclude-dir=\".git\""
"~/.emacs.d/contrapunctus/"
"~/Documents/Text\\ Files/programming/")
(-interpose " ")
(apply #'concat)))
(switch-to-buffer "*grep*")
(delete-other-windows))
("Singing"
(find-file-other-window "~/Sync/Scores/voice/repertoire.org"))
("Subtitles"
(find-file-other-window "~/Music/0-classical/vocal/musical/Company/"))
("Theatre rehearsal"
(contrapunctus-find-two-files-other-window
"~/Documents/Text Files/khilona/voices.org"
"~/1-music-notation/2-my-compositions/2019/2019-03 Kahe Natak Karte Ho Ji/Kahe Natak Karte Ho Ji.org"))
("Transcription"
(find-file-other-window "~/phone/Nokia 6.1/Documents/Markor/Music/transcriptions.md"))
("Wiktionary"
(find-file-other-window "~/phone/Nokia 6.1/Documents/Markor/Languages/hindi.md"))
("Writing"
(find-file-other-window "/home/anon/phone/Nokia 6.1/Documents/Markor/Songs or Poems/"))))
(autoload 'magit-anything-modified-p "magit")
(defun contrapunctus-commit-prompt ()
(if (magit-anything-modified-p)
(if (yes-or-no-p
(concat "You have uncommitted changes in "
default-directory
". Really clock out? "))
t
(magit-status)
nil)
t))
(defun contrapunctus-before-project-stop (project)
(if (member project '("Composing"
"Khilona archiving"
"Programming"))
(contrapunctus-commit-prompt)
;; all functions in `chronometrist-before-project-stop-functions'
;; must return t for successful clock-out
t))
(require 'request)
(require 'esxml-query)
(defun contrapunctus-after-project-stop (project)
(pcase project
("OSM"
(delete-other-windows)
;; What should we do when there's no network connectivity?
;; Ideally - note the clock-out time, and retry every five
;; minutes. When connected, request the changesets, look for the
;; first changeset with a "created_at" which is less than the
;; clock-out time.
(request
"https://api.openstreetmap.org/api/0.6/changesets"
:params '(("display_name" . "contrapunctus"))
:parser (lambda () (libxml-parse-xml-region (point) (point-max)))
:success
(cl-function
(lambda (&key data &allow-other-keys)
(let* ((latest-changeset (-> data
(esxml-node-children)
(car)))
(comment (->> latest-changeset
(esxml-query "[k=comment]")
(esxml-node-attributes)
(cdr)
(car)
(cdr)))
(id (-> latest-changeset
(esxml-node-attributes)
(car)
(cdr))))
(chronometrist-append-to-last-expr nil
`(:osm-url ,(concat "https://www.openstreetmap.org/changeset/" id)
:osm-comment ,comment)))))))
(_ (delete-other-windows))))
;; (add-hook 'first-change-hook 'chronometrist-assist)
(use-package comint
:bind (:map comint-mode-map
("M-p" . #'comint-previous-matching-input-from-input)
("M-n" . #'comint-next-matching-input-from-input)))
(use-package company
:ensure t
:diminish company-mode
:commands global-company-mode
:init (global-company-mode)
:bind ("TAB" . company-indent-or-complete-common))
(use-package company-emoji
:ensure t
:if (featurep 'company)
:config (add-to-list 'company-backends 'company-emoji))
(use-package counsel
:ensure t
:bind ("M-x" . counsel-M-x)
:config
(setq counsel-find-file-ignore-regexp "\\`\\."))
;; (use-package elsa
;; :commands flycheck-elsa-setup)
(use-package elfeed
:bind (:map elfeed-show-mode-map
("v" . nil))
:config
(add-to-list 'boon-special-mode-list 'elfeed-show-mode)
(add-to-list 'boon-special-mode-list 'elfeed-search-mode))
(use-package hydra
:ensure t
:commands defhydra)
;; TODO - make toggle command for emms-start/emms-stop
;; TODO - change mode line display - don't show the whole file path, just the name
(use-package emms
:ensure t
:bind
("<f2> e" . #'hydra-emms/body)
("<f2> E" . #'emms)
(:map emms-playlist-mode-map
("0" . #'emms-volume-raise)
("9" . #'emms-volume-lower)
("<up>" . #'emms-volume-raise)
("<down>" . #'emms-volume-lower)
("<left>" . #'emms-seek-backward)
("<right>" . #'emms-seek-forward)
("n" . #'next-line)
("p" . #'previous-line)
("N" . #'emms-next)
("P" . #'emms-previous)
("SPC" . #'emms-pause))
(:map dired-mode-map
("E" . #'hydra-emms/body))
:commands (emms-all
emms
emms-play-dired
emms-add-dired)
:config (emms-all)
(emms-default-players)
(setq emms-player-mpv-parameters
(lambda ()
(append
'("--fs"
"--quiet"
"--really-quiet"
"--force-window=yes"
"-ao=jack,alsa"
;; "--loop-file=inf"
)
(let* ((dir (->> (emms-playlist-current-selected-track)
(alist-get 'name)
(file-name-directory)))
(subs-in-dir (f-glob "*.srt" dir))
(subs-in-subdir (f-glob "*/*.srt" dir)))
(->> (append subs-in-dir subs-in-subdir)
(-interpose ":")
(append '("--sub-files="))
(apply #'concat)
(list))))))
;; (--map (add-to-list 'emms-player-mpv-parameters it)
;; '("--fs"))
(defun contrapunctus-emms-toggle-player ()
(interactive)
(if emms-player-stopped-p
(emms-start)
(emms-stop)))
(setq emms-playlist-buffer-name "EMMS Playlist")
:init (defhydra hydra-emms ()
("e" #'emms "EMMS")
("n" #'emms-next "Next")
("p" #'emms-previous "Previous")
("SPC" #'emms-pause "Pause")
("s" #'contrapunctus-emms-toggle-player "Start/Stop")
("0" #'emms-volume-raise)
("9" #'emms-volume-lower)
("<up>" #'emms-volume-raise)
("<down>" #'emms-volume-lower)
("<left>" #'emms-seek-backward)
("<right>" #'emms-seek-forward)
("l" #'emms-play-dired "Play file (dired)")
("a" #'emms-add-dired "Add file (dired)")
("A" #'emms-add-directory-tree "Add directory")))
(use-package emr
:ensure t
:bind (:map prog-mode-map
("M-S-<return>" . emr-show-refactor-menu)))
(use-package eshell
:config (setq eshell-history-size 999)
:bind (:map eshell-mode-map
("M-p" . #'comint-previous-matching-input-from-input)
("M-n" . #'comint-next-matching-input-from-input)))
(use-package eww
:ensure t
:bind
(:map eww-mode-map
("b" . #'eww-back-url)
("f" . #'eww-forward-url)
("v" . nil)))
(use-package flx-ido
:ensure t
:disabled
:init (flx-ido-mode 1)
(setq ido-enable-flex-matching t
ido-use-faces nil))
(use-package flx-isearch
:ensure t
:disabled
:init (setq gc-cons-threshold 400000000)
:bind
("C-s" . #'flx-isearch-forward)
("C-r" . #'flx-isearch-backward))
;; (use-package flycheck
;; :ensure t
;; :init (global-flycheck-mode))
;; (use-package flycheck-elsa
;; :hook (emacs-lisp-mode . flycheck-elsa-setup))
(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)
(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/")
(load "cp")
;; (if (not (server-running-p)) (server-start))
(server-start)
(use-package general
:commands general-define-key)
;; 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
;; 2020-01-07T12:43:41+0530
;; update to use general, add M-f8 binding
(general-define-key
"<f8>" 'keyboard-quit
"M-<f8>" 'eval-defun
"M-<f9>" 'dired-jump
"<f10>" 'save-buffer
"M-<f10>" 'find-file
"<f11>" 'ido-mini
"M-<f11>" 'ibuffer
"<f12>" 'execute-extended-command
"M-<f12>" 'text-scale-adjust
"C-c C-j" 'join-line
"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)
(toggle-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
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")))
(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 helpful
:ensure t
:bind (("<f1> <f1>" . #'helpful-at-point)
("<f1> f" . #'helpful-callable)
("<f1> c" . #'helpful-command)
("<f1> k" . #'helpful-key)
("<f1> v" . #'helpful-variable)))
(use-package ibuffer
:bind
(:map ibuffer-mode-map
("X" . 'ibuffer-do-kill-on-deletion-marks)))
(use-package info
:ensure t
:config
(info-initialize)
(--map (add-to-list #'Info-directory-list it)
'("~/.emacs.d/info/"
"~/.emacs.d/elisp-git/geiser/doc/"
"~/lilypond/usr/share/info/"))
:bind
(("<f1> i" . nil)
("<f1> i i" . info)
("<f1> i a" . info-apropos)
("<f1> i q" . (lambda () (interactive) (info "(emacs)")))
("<f1> i w" . (lambda () (interactive) (info "(elisp)")))
("<f1> i l" . (lambda () (interactive) (info "(lilypond-notation)")))
("<f1> i r" . (lambda () (interactive) (info "(lilypond-learning)")))
("<f1> i s" . (lambda () (interactive) (info "(stumpwm)")))
("<f1> i o" . (lambda () (interactive) (info "(org)")))
("<f1> i g" . (lambda () (interactive) (info "(guile)"))))
:bind
(:map Info-mode-map
("b" . Info-history-back)
("f" . Info-history-forward)))
(require 'general)
(general-define-key
;; "s-k" 'cp-kill-buffer
"s-k" 'bury-buffer
"C-x k" 'cp-kill-buffer
"C-`" 'shell
"M-<f2>" 'compile
"M-<f3>" 'run-chicken
"M-<f4>" 'run-lisp
"M-<f5>" 'ielm)
(general-define-key
:prefix "<f1>"
"M" 'describe-mode
"m" 'woman
"l" 'find-library)
(general-define-key
:prefix "<f2>"
;; "<f2>" 'imenu
"<f2>" 'xref-find-definitions
"r" 'xref-find-references
"m" 'imenu
;; "p" 'grep
"p" 'ag-regexp
"o" 'find-grep
"i" 'find-dired
"h" 'proced)
(general-define-key
:prefix "<f5>"
"<f5>" 'eval-buffer
"i" 'cp-open-init
"v" 'visual-line-mode
"f" 'cp-fcf-literally
"f" 'fundamental-mode
"t" 'text-mode
"T" 'cp-insert-timestamp
"c" 'calendar)
(general-define-key
;; [down-mouse-1] 'mouse-set-point
;; [up-mouse-1] 'er/expand-region
[s-mouse-3] 'bury-buffer
[mouse-8] 'delete-window
;; (kbd "<mouse-9>") 'keyboard-quit
;; [mouse-9] 'buffer-menu
[mouse-9] 'ibuffer
[C-mouse-9] 'recentf-open-files
[M-mouse-4] 'next-buffer
[M-mouse-5] 'previous-buffer
[M-mouse-8] 'split-window-right
[M-mouse-9] 'split-window-below
;; quitting from helm-mini - whether with keyboard-quit or
;; keyboard-escape-quit - "banishes" the mouse pointer to the
;; top-right corner!? wtf, helm.
;; (kbd "s-<mouse-9>") 'helm-mini
))
(with-eval-after-load 'help-mode
(cp-set-keys
:keymap help-mode-map
:bindings
`((,(kbd "b") help-go-back)
(,(kbd "f") help-go-forward))))
;; More convenient Unicode keys
(global-unset-key (kbd "M-["))
(cp-set-keys
:bindings
`((,(kbd "C-' r") ,(kbd ""))
(,(kbd "C-' 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-' l") ,(kbd "λ"))
(,(kbd "C-' F") ,(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 iedit
:ensure t
:bind (("C-;" . #'iedit-mode)
("C-:" . #'iedit-mode-toggle-on-function)))
(use-package ivy
:ensure t
:commands ivy-mode)
(use-package jabber
:ensure t
:disabled
:commands jabber-connect
:config (global-unset-key (kbd "C-x C-j"))
(global-set-key (kbd "C-x C-j") 'join-line)
(setq jabber-history-enabled t
jabber-history-muc-enabled t
jabber-alert-presence-message-function nil))
(use-package magit
:ensure t
:bind (("<f5> m" . #'magit-status)
:map magit-status-mode-map
;; ([mouse-3] . 'magit-section-toggle)
([down-mouse-3] . 'mouse-set-point)
([up-mouse-3] . 'magit-section-toggle))
:commands magit-status
:hook
(magit-post-stage . (lambda () (recenter))))
(use-package mediawiki
:ensure t
:commands mediawiki-mode)
(use-package midnight
:ensure t
:init
(midnight-mode)
:config
(setq clean-buffer-list-kill-regexps '("")
clean-buffer-list-delay-general 7
clean-buffer-list-delay-special (* 60 60 24 7))
:hook
(use-package nameless
:ensure t
: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)))
(use-package nodejs-repl
:ensure t
:config (setq nodejs-repl-command "nodejs"))
(use-package package
:config
(when (featurep 'boon)
(general-def package-menu-mode-map
"X" 'package-menu-execute)))
(use-package paradox
:ensure t
:bind
("<f5> p" . #'paradox-list-packages)
:config (setq paradox-execute-asynchronously t)
(when (featurep 'boon)
(general-def paradox-menu-mode-map
"X" 'package-menu-execute)))
(use-package powerline
:ensure t)
(use-package rainbow-delimiters
:ensure t
:hook (prog-mode . rainbow-delimiters-mode))
(use-package swiper
:ensure t
:bind (("C-s" . swiper)
("C-r" . swiper-backward))
:config (add-to-list 'desktop-globals-to-save 'swiper-history))
(use-package sxiv
:config (setq sxiv-exclude-strings '("meh")))
(use-package time
:ensure t
:config
(setq display-time-next-load-average t)
(add-to-list 'zoneinfo-style-world-list '("Europe/Berlin" "Berlin")))
;; (load "cp-adb")
(load "cp-editing")
;; (load "cp-evil")
(load "cp-fm")
(load "cp-lily")
(load "cp-sfz")
(load "cp-lisp")
(load "cp-nav")
;; (ispell-change-dictionary "en")
(setq ispell-dictionary "en")
(use-package undo-tree
:ensure t
: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))
(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 (car compile-history))
(compile (concat "xelatex \"" (buffer-file-name)
"\""))))
;; ('markdown-mode (markdown-export))
('c-mode (compile (concat "gcc -static -o "
(shell-quote-argument
(file-name-base))
" "
(shell-quote-argument
(buffer-file-name)))))))
(add-hook 'after-save-hook 'cp/after-save)
;; (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"))))
(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")
(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)
(mapc (lambda (command)
(put command 'disabled nil))
'(downcase-region
upcase-region
set-goal-column
scroll-left
erc-remove-text-properties-region))
(require 'cp-org)
(load "cp-desktop")
;; (toggle-debug-on-quit)
;; (profiler-stop)
;; (emacs-init-time)
;; (profiler-report)
;; Local Variables:
;; nameless-current-name: "contrapunctus"
;; End:
(provide 'init)
;;; init.el ends here