dotemacs/init.el

820 lines
28 KiB
EmacsLisp
Raw Normal View History

2018-09-07 17:06:18 +00:00
;; TODO - convert to use-package
2018-09-11 16:28:16 +00:00
;; TODO - drop cp/ prefix, use contrapunctus-, set up nameless package
;; names
;; TODO - create wrapper for
;; xref-find-definitions/xref-find-definitions-other-window
2018-09-07 17:06:18 +00:00
;; TODO - make ag suggest my last isearch term
2018-09-14 07:43:07 +00:00
;; 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.
2018-09-18 11:07:52 +00:00
;; TODO - add idle timer for recentf-cleanup
2018-09-14 07:43:07 +00:00
2018-09-18 11:07:52 +00:00
;; 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).
2018-09-18 18:44:12 +00:00
;; 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.
2018-09-19 05:08:46 +00:00
;; TODO - an 'inspect'/'examine' command. Actually, more like a 'help
;; for thing at point' - if it's a variable, run describe-variable
;; with that as the default suggestion. Likewise for functions, faces,
;; libraries (features), etc.
;; 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
2018-09-19 05:08:46 +00:00
2019-09-12 15:23:07 +00:00
;;;; Code:
(eval-when-compile
(add-to-list 'load-path "~/.emacs.d/elisp-git/use-package/")
(require 'use-package))
2019-08-16 09:06:05 +00:00
;; 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"))
2019-10-09 04:45:40 +00:00
(require 'atomic-chrome)
(atomic-chrome-start-server)
2019-10-09 04:54:17 +00:00
(setq atomic-chrome-url-major-mode-alist
'(("wikisource" . mediawiki-mode)))
2019-10-09 04:45:40 +00:00
2019-10-25 11:53:07 +00:00
(use-package midnight
: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
(midnight . clean-buffer-list))
(use-package hydra
:commands defhydra)
2019-08-16 09:06:05 +00:00
;; TODO - make toggle command for emms-start/emms-stop
;; TODO - change mode line display - don't show the whole file path, just the name
2019-08-16 09:06:05 +00:00
(use-package emms
:bind (("<f2> E" . #'emms)
("<kp-add>" . #'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))
:commands (emms-all
emms
emms-play-dired
emms-add-dired)
:config (emms-all)
(emms-default-players)
(--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
(global-map "<f2> e")
("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")))
2019-08-16 09:06:05 +00:00
2019-02-14 09:57:02 +00:00
(use-package eww
:bind
(:map eww-mode-map
("b" . #'eww-back-url)
("f" . #'eww-forward-url)
("v" . nil)))
(use-package info
2018-09-14 07:43:07 +00:00
:config
(info-initialize)
2019-01-10 03:52:26 +00:00
(--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)))
2018-09-06 10:57:04 +00:00
(use-package time
:config
(setq display-time-next-load-average t)
(add-to-list 'zoneinfo-style-world-list '("Europe/Berlin" "Berlin")))
2018-09-06 10:57:04 +00:00
2018-09-04 06:06:48 +00:00
(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
2016-06-13 16:35:57 +00:00
;; ;; (profiler-start 'cpu)
;; (toggle-debug-on-error)
;; ;; (toggle-debug-on-quit)
2016-06-12 07:36:15 +00:00
(require 'dash)
2018-09-04 06:06:48 +00:00
(require 's)
(require 'visual-fill-column)
2015-11-19 23:08:43 +00:00
;; (add-to-list 'load-path "~/.emacs.d/elisp-git/yafolding.el/")
2015-01-30 05:10:28 +00:00
(add-to-list 'load-path "~/.emacs.d/user/")
(add-to-list 'load-path "~/.emacs.d/contrapunctus/")
2018-09-04 06:06:48 +00:00
(add-to-list 'load-path "~/.emacs.d/contrapunctus/fin/")
2018-09-04 17:07:12 +00:00
(add-to-list 'load-path "~/.emacs.d/contrapunctus/ido-mini/")
2018-09-27 21:45:21 +00:00
(use-package chronometrist
2019-01-16 09:41:35 +00:00
:commands chronometrist-assist
:load-path "~/.emacs.d/contrapunctus/chronometrist"
2018-09-27 21:45:21 +00:00
:hook (kill-emacs-query-functions . #'timeclock-query-out)
2019-01-10 03:54:57 +00:00
: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))
2019-08-05 21:44:56 +00:00
:config (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")
(15 "Acting")
(30 "Keyboard"))))
2018-09-27 21:45:21 +00:00
2019-08-06 08:31:43 +00:00
(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))
2019-09-12 15:18:35 +00:00
(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
2019-06-07 08:14:59 +00:00
("Composing"
2019-08-08 08:26:03 +00:00
(find-file-other-window "~/1-music-notation/2-my-compositions/2019/03-rahasya-pancham-veda-ka/rahasya.org")
2019-09-12 15:18:35 +00:00
(cp-outline-open-heading 1))
("Data organization"
(find-dired "~/" "-name \'dl\' -size +0c"))
("Exercise"
2019-08-16 09:50:40 +00:00
(let* ((path-1 "~/Documents/Text Files/ma/practice.org")
2019-08-06 08:31:43 +00:00
(path-2 "~/Documents/Text Files/ma/0shoto.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))
(select-window (get-buffer-window file-2))
2019-09-12 15:18:35 +00:00
(cp-outline-open-heading 1)))
("Guitar"
2019-08-12 16:50:24 +00:00
(let* ((path-1 "~/Sync/Scores/solo.org")
(file-1 (file-name-nondirectory path-1))
(weekday (elt (decode-time) 6))
(week (string-to-number (format-time-string "%U"))))
(contrapunctus-find-two-files-other-window path-1
2019-08-08 08:26:03 +00:00
"~/Documents/Text Files/music_stuff/guitar-duo.org")
(select-window (get-buffer-window file-1))
(org-match-sparse-tree nil (pcase weekday
((or 1 3 5)
(pcase week
((pred oddp) "g1")
((pred evenp) "g2")))
((or 2 4)
(pcase week
((pred oddp) "g2")
((pred evenp) "g1")))
(6 "saturday")
(0 "sunday")))))
("Keyboard"
2019-08-12 05:43:52 +00:00
(find-file-other-window "~/Documents/Text Files/music_stuff/piano.org")
(outline-show-subtree))
2018-10-06 19:13:51 +00:00
("OSM"
;; (async-shell-command "java -jar ~/josm-tested.jar" " *JOSM*" " *JOSM errors*")
;; (delete-window (get-buffer-window " *JOSM*"))
2019-08-08 08:26:03 +00:00
(contrapunctus-find-two-files-other-window "~/phone/Nokia 6.1/Android/data/net.osmand.plus/files/"
"~/phone/Nokia 6.1/external/DCIM/OpenCamera/osm/"))
;; 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"
2019-08-06 08:31:43 +00:00
(find-file-other-window "~/Sync/Scores/voice.org"))
("Theatre rehearsal"
(contrapunctus-find-two-files-other-window
"~/Documents/Text Files/khilona/voices.org"
"~/1-music-notation/2-my-compositions/2019/03-rahasya-pancham-veda-ka/rahasya.org"))))
2018-09-27 21:45:21 +00:00
(autoload 'magit-anything-modified-p "magit")
(defun contrapunctus-commit-prompt ()
(if (magit-anything-modified-p)
2019-08-12 05:43:30 +00:00
(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))
2019-01-12 21:51:16 +00:00
(require 'request)
(require 'esxml-query)
(defun contrapunctus-after-project-stop (project)
2018-10-06 19:13:51 +00:00
(pcase project
("OSM"
(delete-other-windows)
2019-01-12 21:51:16 +00:00
;; 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.
2018-10-06 19:13:51 +00:00
(setq chronometrist-before-in-functions '(contrapunctus-start-project)
chronometrist-after-in-functions nil
(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
`(:changeset-url ,(concat "https://www.openstreetmap.org/changeset/" id)
:changeset-comment ,comment)))))))
(_ (delete-other-windows))))
chronometrist-before-out-functions '(contrapunctus-before-project-stop
chronometrist-kv-read)
chronometrist-after-out-functions '(contrapunctus-after-project-stop))
2019-01-16 09:41:35 +00:00
;; (add-hook 'first-change-hook 'chronometrist-assist)
(load "cp")
2015-11-26 23:31:14 +00:00
2018-09-04 06:06:48 +00:00
;; (if (not (server-running-p)) (server-start))
2016-06-12 07:36:51 +00:00
(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 "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)
2015-06-22 09:15:28 +00:00
;;;; Linewrapping
2015-11-19 22:48:35 +00:00
;; (defun line-trunc-set ()
2016-06-12 07:37:27 +00:00
;; (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-09-04 06:06:48 +00:00
;; 2018-07-26T19:57:29+0530
2018-09-22 04:06:58 +00:00
(add-hook 'markdown-mode-hook #'(lambda () (visual-fill-column-mode t)))
(add-hook 'text-mode-hook #'(lambda () (visual-line-mode t)))
2018-09-04 06:06:48 +00:00
(load "cp-md")
(defun cp/turn-on-truncate-lines ()
2019-08-13 09:49:59 +00:00
;; (setq truncate-lines 1)
(toggle-truncate-lines 1))
2018-09-04 06:06:48 +00:00
(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))
2019-08-13 09:49:59 +00:00
(cp/add-to-hooks 'cp/turn-on-truncate-lines '(dired-mode-hook
prog-mode-hook
diff-mode-hook
message-mode-hook))
2016-06-12 07:37:27 +00:00
(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)
2018-09-04 06:06:48 +00:00
;; 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)
2015-11-22 22:58:01 +00:00
;; (add-hook 'paredit-mode-hook 'auto-fill-mode)
;;;; Tab settings
2016-06-13 16:35:57 +00:00
;; (setq default-tab-width 4)
(setq tab-width 4)
2015-01-30 05:11:52 +00:00
;(define-key text-mode-map (kbd "TAB") 'self-insert-command)
(setq-default indent-tabs-mode nil)
;;;; Fix scrolling
2015-03-24 06:09:37 +00:00
(setq scroll-conservatively 10000
scroll-preserve-screen-position t)
(setq auto-window-vscroll nil)
2015-03-23 21:32:55 +00:00
;;; Recenter screen on isearch matches
(add-hook 'isearch-mode-hook 'recenter)
(add-hook 'isearch-update-post-hook 'recenter)
(defadvice isearch-repeat-forward
2015-11-24 21:03:33 +00:00
(after isearch-repeat-forward-recenter activate) (recenter))
2015-03-23 21:32:55 +00:00
(defadvice isearch-repeat-backward
2015-11-24 21:03:33 +00:00
(after isearch-repeat-backward-recenter activate) (recenter))
2015-03-23 21:32:55 +00:00
(ad-activate 'isearch-repeat-forward)
(ad-activate 'isearch-repeat-backward)
2015-06-22 09:27:50 +00:00
(global-set-key (kbd "C-s") 'isearch-forward-regexp)
(global-set-key (kbd "C-r") 'isearch-backward-regexp)
2015-03-23 21:32:55 +00:00
;;;; 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
2015-10-12 10:41:21 +00:00
(defadvice magit-section-toggle
2015-11-24 21:03:33 +00:00
(after magit-section-toggle-recenter activate) (recenter 3))
2015-10-12 10:41:21 +00:00
(ad-activate 'magit-section-toggle)
2015-03-23 21:32:55 +00:00
(defadvice magit-unstage-item
2015-11-24 21:03:33 +00:00
(after magit-unstage-item-move) (next-line))
2015-03-23 21:32:55 +00:00
(ad-activate 'magit-unstage-item)
(defadvice magit-goto-next-section
2015-11-24 21:03:33 +00:00
(after magit-next-section-recenter activate) (recenter 3))
(ad-activate 'magit-goto-next-section)
(defadvice magit-goto-previous-section
2015-11-24 21:03:33 +00:00
(after magit-previous-section-recenter activate) (recenter 3))
(ad-activate 'magit-goto-previous-section)
2015-03-23 21:32:55 +00:00
(defun cp-insert-timestamp ()
(interactive)
(insert (format-time-string "%FT%T%z")))
(use-package ag
2019-01-10 04:10:37 +00:00
:bind ("<f2> p" . ag) ("<f2> P" . ag-project-regexp)
:config (setq ag-highlight-search t))
2018-09-04 06:06:48 +00:00
(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))))
2016-10-19 11:38:52 +00:00
(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)))
2015-11-26 23:31:14 +00:00
(cp-set-keys
:bindings
2018-09-25 18:58:12 +00:00
`((,(kbd "<f1> M") describe-mode)
(,(kbd "<f1> m") woman)
2018-09-18 11:07:52 +00:00
(,(kbd "M-<f2>") compile)
2018-09-11 16:28:16 +00:00
;; (,(kbd "<f2> <f2>") imenu)
(,(kbd "<f2> <f2>") xref-find-definitions)
(,(kbd "<f2> r") xref-find-references)
2019-08-08 08:22:36 +00:00
(,(kbd "<f2> m") imenu)
2016-10-19 11:38:52 +00:00
;; (,(kbd "<f2> p") grep)
2018-09-18 11:07:52 +00:00
(,(kbd "<f2> p") ag-regexp)
(,(kbd "<f2> o") find-grep)
(,(kbd "<f2> i") find-dired)
(,(kbd "<f2> h") proced)
(,(kbd "M-<f3>") run-chicken)
(,(kbd "M-<f4>") run-lisp)
2015-11-25 22:58:19 +00:00
(,(kbd "<f5> <f5>") eval-buffer)
(,(kbd "M-<f5>") ielm)
(,(kbd "<f5> i") cp-open-init)
(,(kbd "<f5> v") visual-line-mode)
(,(kbd "<f5> f") cp-fcf-literally)
2018-09-04 06:06:48 +00:00
(,(kbd "<f5> f") fundamental-mode)
(,(kbd "<f5> t") text-mode)
(,(kbd "<f5> c") calendar)
;; (,(kbd "s-k") cp-kill-buffer)
(,(kbd "s-k") bury-buffer)
(,(kbd "C-x k") cp-kill-buffer)
(,(kbd "C-`") shell)
2018-09-10 07:34:16 +00:00
(,(kbd "<f5> T") cp-insert-timestamp)
(,(kbd "<f1> l") find-library)))
2015-11-25 22:58:19 +00:00
(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))))
2015-11-30 18:09:11 +00:00
2019-09-12 15:17:23 +00:00
(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 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)))
2015-11-25 22:58:19 +00:00
;; More convenient Unicode keys
(global-unset-key (kbd "M-["))
2015-11-26 23:31:14 +00:00
(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 "ƒ"))))
2018-09-04 06:06:48 +00:00
(setq default-input-method "devanagari-itrans")
2015-03-24 06:06:58 +00:00
(setq backup-by-copying t
2018-09-04 06:06:48 +00:00
backup-directory-alist '(("." . "~/.emacs.d/saves/"))
2016-06-13 16:35:57 +00:00
delete-old-versions t
2018-09-04 06:06:48 +00:00
kept-new-versions 2
2016-06-13 16:35:57 +00:00
kept-old-versions 2
version-control t)
2015-01-30 23:10:11 +00:00
2015-03-23 22:08:10 +00:00
(setq browse-url-browser-function 'browse-url-xdg-open)
2018-09-07 10:25:36 +00:00
(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/")))))
2014-09-29 18:37:30 +00:00
(package-initialize)
2018-09-10 10:07:43 +00:00
(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))
2018-09-14 07:43:07 +00:00
(use-package emr
:bind (:map prog-mode-map
("M-S-<return>" . emr-show-refactor-menu)))
2018-09-13 18:14:13 +00:00
(use-package flx-isearch
:disabled
2018-09-13 18:14:13 +00:00
:init (setq gc-cons-threshold 40000000)
:bind ("C-s" . #'flx-isearch-forward)
("C-r" . #'flx-isearch-backward))
(use-package flx-ido
:disabled
2018-09-13 18:14:13 +00:00
:init (flx-ido-mode 1)
(setq ido-enable-flex-matching t)
(setq ido-use-faces nil))
2019-09-12 15:23:07 +00:00
(use-package flycheck
:ensure t
:init (global-flycheck-mode))
2019-09-12 15:25:48 +00:00
(use-package flycheck-elsa
:hook (emacs-lisp-mode . #'flycheck-elsa-setup))
2018-09-25 19:01:22 +00:00
(use-package helpful
:bind (("<f1> <f1>" . #'helpful-at-point)
("<f1> f" . #'helpful-callable)
2018-09-25 19:01:22 +00:00
("<f1> c" . #'helpful-command)
("<f1> k" . #'helpful-key)
("<f1> v" . #'helpful-variable)))
(use-package iedit
:bind (("C-;" . #'iedit-mode)
("C-:" . #'iedit-mode-toggle-on-function)))
2019-10-26 04:27:51 +00:00
(use-package ivy
:commands ivy-mode)
(use-package jabber
2018-10-06 19:13:51 +00:00
:disabled
:config (global-unset-key (kbd "C-x C-j")))
2019-10-09 04:54:17 +00:00
(use-package mediawiki
:commands mediawiki-mode)
2018-09-19 04:35:11 +00:00
(use-package nodejs-repl
:config (setq nodejs-repl-command "nodejs"))
2018-09-14 07:43:07 +00:00
(use-package paradox
2019-08-10 08:11:27 +00:00
:bind ("<f5> p" . #'paradox-list-packages)
2018-09-14 07:43:07 +00:00
:config (setq paradox-execute-asynchronously t))
2019-08-10 08:11:47 +00:00
(use-package rainbow-delimiters
:hook (prog-mode . rainbow-delimiters-mode))
2019-10-26 04:27:51 +00:00
(use-package swiper
:bind (("C-s" . swiper)
("C-r" . swiper-backward)))
;; (load "cp-adb")
2015-11-25 23:33:55 +00:00
(load "cp-editing")
2015-11-24 21:05:41 +00:00
;; (load "cp-evil")
(load "cp-god")
(load "cp-fm")
(load "cp-lily")
(load "cp-sfz")
(load "cp-lisp")
(load "cp-nav")
(load "cp-ui")
2015-06-22 09:15:28 +00:00
2016-06-13 16:35:57 +00:00
;; (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))
2015-03-23 21:35:14 +00:00
(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
2019-01-18 10:06:39 +00:00
('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")
2019-06-07 08:16:45 +00:00
(compile (car compile-history))
2019-01-18 10:06:39 +00:00
(compile (concat "xelatex \"" (buffer-file-name)
"\""))))
2019-08-11 12:29:53 +00:00
;; ('markdown-mode (markdown-export))
2019-01-18 10:06:39 +00:00
('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)
2016-06-12 07:38:38 +00:00
;; (load "cp-helm")
(load "cp-hindi")
2015-11-24 21:12:10 +00:00
(load "cp-irc")
2015-11-25 23:33:55 +00:00
(load "cp-parens")
(load "cp-playlist")
2015-06-22 09:15:28 +00:00
2016-06-12 07:36:15 +00:00
(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"))
2016-06-12 07:36:15 +00:00
;; 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"))))
2019-08-16 09:49:39 +00:00
(use-package magit
: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)
2015-03-23 22:56:08 +00:00
(setq recentf-auto-cleanup 'never)
2014-09-29 18:37:30 +00:00
(require 'recentf)
(recentf-mode 1)
2015-11-26 23:33:25 +00:00
(setq recentf-max-menu-items 500
recentf-max-saved-items 1000
2018-09-04 06:06:48 +00:00
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)
2015-06-22 09:29:04 +00:00
(global-set-key (kbd "C-x C-r C-o") 'recentf-open-files)
2018-09-04 06:06:48 +00:00
(load "cp-ido")
(load "cp-desktop")
(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))
2015-06-26 07:16:14 +00:00
;; 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...
2015-03-23 22:08:10 +00:00
2015-03-24 06:09:37 +00:00
;;;; text size change
2018-09-04 06:06:48 +00:00
;; 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)
2015-11-19 23:08:43 +00:00
;; (require 'yafolding)
;; (add-hook 'prog-mode-hook
;; (lambda () (yafolding-mode)))
2018-09-06 07:34:07 +00:00
(setq custom-file "~/.emacs.d/custom.el")
(load custom-file)
2015-03-23 23:02:16 +00:00
(put 'downcase-region 'disabled nil)
2015-06-22 09:57:30 +00:00
(put 'upcase-region 'disabled nil)
(put 'set-goal-column 'disabled nil)
2016-06-13 16:35:57 +00:00
;; (toggle-debug-on-quit)
;; (profiler-stop)
;; (emacs-init-time)
;; (profiler-report)
2018-09-04 06:06:48 +00:00
(put 'scroll-left 'disabled nil)
(put 'erc-remove-text-properties-region 'disabled nil)
;; Local Variables:
;; nameless-current-name: "contrapunctus"
;; End: