dotemacs/init.el

1333 lines
43 KiB
EmacsLisp

(use-package cp-ui
:demand
:load-path "~/.emacs.d/contrapunctus/")
(use-package ediff
:config
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
;; boon-like bindings
(add-hook 'ediff-keymap-setup-hook
(lambda ()
(define-key ediff-mode-map (kbd "i") 'ediff-previous-difference)
(define-key ediff-mode-map (kbd "o") 'ediff-next-difference))))
(require 'atomic-chrome)
(atomic-chrome-start-server)
(setq atomic-chrome-url-major-mode-alist
'(("wikisource" . mediawiki-mode)))
(use-package emacs
:config
(setq gc-cons-threshold 100000000
delete-by-moving-to-trash t
trash-directory "~/.trash/"
history-length 1000
use-file-dialog nil)
(setq-default undo-limit (* 80 1000)))
(use-package esup
:config (setq esup-depth 0))
(use-package doc-view
:config
(setq doc-view-resolution 300))
(use-package gnutls
:config
;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=36749
(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"))
(use-package ag
:bind
("<f2> p" . ag)
("<f2> P" . ag-project-regexp)
:config
(setq ag-highlight-search t))
(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/")
(use-package ido-mini
:load-path "~/.emacs.d/contrapunctus/ido-mini/"
:bind (("C-x C-l" . ido-mini)
:map boon-command-map
("J" . ido-mini))
:config
(ivy-mode))
(load "cp")
;; (if (not (server-running-p)) (server-start))
(server-start)
(use-package boon
:ensure t
:commands (boon-mode)
:bind
(:map boon-command-map
("C-l" . recenter-top-bottom)
("r" . swiper)
("/" . undo-tree-undo)
("?" . undo-tree-redo)
("G" . join-line) ;; mnemonic - Glue (I'd like to bind J and
;; : to sentence movement once I extend
;; Boon to select by sentence movement)
;; ("TAB" . 'company-indent-or-complete-common)
;; ;; this works, but also breaks unfolding in org mode :\
;; ("<tab>" . 'company-indent-or-complete-common)
("C" . 'boon-toggle-comment)
("t" . nil)
("t w" . 'transpose-words)
("t e" . 'transpose-sexps)
("t l" . 'transpose-lines)
("t p" . 'transpose-paragraphs)
("t c" . 'transpose-chars)
("\\" . projectile-command-map)
("(" . boon-navigate-backward)
(")" . boon-navigate-forward)
("e r" . swiper-thing-at-point)
("M" . ido-mini)
("J" . ido-mini))
(:map boon-x-map
("w" . 'write-file)
("s" . 'save-buffer)
("d" . 'dired-jump)
("e" . 'eval-last-sexp)
("f" . 'find-file)
("c" . 'kill-emacs)
("v" . 'find-alternate-file)
("b" . 'ibuffer)
("=" . text-scale-adjust)
("-" . text-scale-adjust))
:config
(use-package boon-qwerty)
;; (add-to-list 'boon-enclosures `(40 "(" ")")) ;; 40 = (
;; (use-package boon-powerline)
;; (boon-powerline-theme)
(mapc (lambda (mode)
(add-to-list 'boon-special-mode-list mode))
'(emms-playlist-mode
emms-browser-mode
edebug-mode
sldb-mode
macrostep-mode
view-mode
slime-popup-buffer-mode
finder-mode))
(dolist (var '((bound-and-true-p edebug-mode)
(bound-and-true-p view-mode)
(bound-and-true-p macrostep-mode)
(bound-and-true-p slime-popup-buffer-mode)))
(add-to-list 'boon-special-conditions var))
(setq hi-lock-auto-select-face t)
(define-key boon-command-map (kbd "x d f") nil)
(general-def boon-command-map
"M" 'ido-mini
"J" 'ido-mini
"x d" 'dired-jump)
;; :hook
;; ((text-mode . turn-on-boon-mode)
;; (prog-mode . turn-on-boon-mode)
;; (shell-mode . turn-on-boon-mode)
;; (helpful-mode . turn-on-boon-mode)
;; (fundamental-mode . turn-on-boon-mode))
:init
(boon-mode))
(use-package choice
:load-path "~/.emacs.d/contrapunctus/choice/")
(use-package chronometrist
;; :disabled t
:load-path "~/.emacs.d/contrapunctus/chronometrist/elisp/"
:hook
(chronometrist-kv-read-mode . visual-line-mode)
(chronometrist-sexp-mode . auto-revert-mode)
(chronometrist-sexp-mode . visual-line-mode)
(kill-emacs-query-functions . chronometrist-query-stop)
:bind (("<f9>" . chronometrist)
("<kp-insert>" . chronometrist))
:config
(require 'chronometrist-key-values)
(setq chronometrist-before-in-functions '()
chronometrist-after-in-functions '(;; chronometrist-tags-add
;; chronometrist-kv-add
contrapunctus-start-project)
chronometrist-before-out-functions '(contrapunctus-before-project-stop
;; chronometrist-tags-add
;; chronometrist-tag-choice
chronometrist-key-values-unified-choice
;; chronometrist-kv-add
;; chronometrist-skip-query-reset
)
chronometrist-after-out-functions '(contrapunctus-after-project-stop)
chronometrist-activity-indicator 'contrapunctus-chronometrist-activity-indicator))
(use-package chronometrist-goal
:load-path "~/.emacs.d/contrapunctus/chronometrist-goal/"
:hook (chronometrist-mode . chronometrist-goal-minor-mode)
:config
(setq chronometrist-goal-list
'((15 "Arrangement/new edition")
(15 "Aural exercises")
(15 "Transcription" "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")
(15 "Wikisource"))
alert-default-style 'libnotify))
(defun contrapunctus-chronometrist-activity-indicator ()
(thread-last (plist-put (chronometrist-last)
:stop (chronometrist-format-time-iso8601))
list
chronometrist-events-to-durations
(-reduce #'+)
truncate
chronometrist-format-time))
(defun contrapunctus-find-two-files (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"
(delete-other-windows)
(find-file
"~/1-music-notation/4-my-arrangements/2020/2020-11-27 Winterreise/01 Gute Nacht/music/")
(launch-file
"~/1-music-notation/4-my-arrangements/2020/2020-11-27 Winterreise/01 Gute Nacht/output/01 Gute Nacht-pacON.pdf")
(launch-file
"~/Sync/Scores/voice/Schubert, Franz/IMSLP570459-PMLP2203-D_911,_Winterreise.pdf"))
("Aural exercises"
(find-file-other-window "~/phone/Nokia 6.1/Documents/Markor/Music/Analyse.md"))
("Composing"
(find-file-other-window
"~/1-music-notation/2-my-compositions/2017/2017-02 The Rainbow Flower/1 Chhutti Ka Din/music/"))
("Data organization"
(find-dired "~/" "-name \\'dl\\' -size +0c"))
("Digitization"
(find-file "~/Documents/Text Files/latex/Don't, Mr. Disraeli!/dont-mr-disraeli.tex")
(split-window-below)
(find-file "~/Pictures/1280px-KB_Programmer_Dvorak.svg.png"))
("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 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 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 "~/Documents/sync/Khilona/")
(split-window-below)
(other-window 1)
(find-file "~/Khilona/Videos/Me?/")
(other-window 1)
(find-file "~/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 "~/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"))
("Programming"
(launch-file "~/git/cl/McCLIM/Documentation/Manual/Texinfo/mcclim.pdf")
(find-file-other-window "~/phone/Nokia 6.1/Documents/Markor/Computers/todo.md"))
("Singing"
(find-file-other-window "~/Sync/Scores/voice/repertoire.org"))
("Subtitles"
;; (find-file-other-window "~/Music/0-classical/vocal/musical/Company/")
(start-process "subtitleeditor" nil "subtitleeditor" "/home/khilona/Videos/Peer Gynt/peer-gynt.srt"))
("Teaching"
(find-file-other-window "~/Documents/Text Files/students/")
;; (launch-file "~/Sync/Scores/voice/jingle-bell-rock.pdf")
)
("Theatre rehearsal"
(contrapunctus-find-two-files
"~/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")
(emms-play-file "~/Music/christmas/Glee - Jingle Bell Rock (Lyrics)-VfLf7A_-1Vw.webm")
(find-file "~/1-music-notation/3-my-transcriptions/Glee - Jingle Bell Rock/music/")
(launch-file "~/1-music-notation/3-my-transcriptions/Glee - Jingle Bell Rock/output/Glee - Jingle Bell Rock-pacON.pdf"))
("Video editing"
(start-process "flatpak" (generate-new-buffer-name "kdenlive")
"flatpak" "run" "org.kde.kdenlive"
"/home/khilona/Videos/ghar ghar theatre 3/ggt3.kdenlive")
(find-alternate-file-other-window "/home/khilona/Videos/ghar ghar theatre 3/"
;; "/home/khilona/Videos/podcast/"
))
("Wiktionary"
(find-file-other-window
"~/phone/Nokia 6.1/Documents/Markor/Languages/hindi.md"))
("Writing"
(find-file-other-window
"~/phone/Nokia 6.1/Documents/Markor/Songs or Poems/"))))
(autoload 'magit-anything-modified-p "magit")
(defun contrapunctus-commit-prompt ()
"Prompt user if `default-directory' is a dirty Git repository.
Return t if the user answers yes, if the repository is clean, or
if there is no Git repository.
Return nil (and run `magit-status') if the user answers no."
(cond ((not (magit-anything-modified-p)) t)
((yes-or-no-p
(format "You have uncommitted changes in %S. Really clock out? "
default-directory)) t)
(t (magit-status) nil)))
(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))))
(defun contrapunctus-count-expressions ()
(interactive)
(chronometrist-sexp-in-file chronometrist-file
(goto-char (point-min))
(cl-loop with count = 0
while (ignore-errors (read (current-buffer)))
do (cl-incf count)
finally do (message "%s" count))))
;; Wrote these two as potential alternatives to `org-babel-tangle',
;; which was far slower than I'd like (took around 20s for
;; chronometrist.org when I checked during the migration process, and
;; 43s after the migration was complete.) These, on the other hand,
;; are almost instant, but I don't use them anywhere because I run a
;; sed script as a file local variable.
(defun chronometrist-tangle ()
(goto-char (point-min))
(cl-loop with source
while (not (eobp))
when (looking-at-p (rx (and line-start (zero-or-more blank) line-end)))
concat (progn
(forward-line 1)
(buffer-substring-no-properties
(point)
(cl-loop while (not (eobp))
if (looking-at-p (rx (and line-start
(zero-or-more blank)
line-end)))
do (cl-return (point))
else do (forward-line 1)))) into source
do (forward-line 1)
finally do
(with-current-buffer (find-file-noselect "chronometrist.el")
(delete-region (point-min) (point-max))
(insert source)
(save-buffer))))
(defun chronometrist-tangle-sed ()
(let* ((file-path (buffer-file-name
(current-buffer)))
(base (file-name-base file-path)))
(when (equal "chronometrist.org" (file-name-nondirectory file-path))
(start-process-shell-command
"sed-tangle"
(generate-new-buffer-name "sed-tangle")
(format "sed -n '/#+BEGIN_SRC emacs-lisp$/,/#+END_SRC$/{//!p;}' ~s.org > ~s.el" base base)))))
(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-emoji
:hook (text-mode . company-emoji-init)
:config (add-to-list 'company-backends 'company-emoji))
(use-package counsel
:bind ("M-x" . counsel-M-x)
:config
(setq counsel-find-file-ignore-regexp "\\`\\."))
;; (use-package elsa
;; :commands flycheck-elsa-setup)
(global-set-key (kbd "M-w") 'kill-ring-save)
(define-key emacs-lisp-mode-map (kbd "M-w") nil)
;; ;; M-d is useful in the minibuffer
;; (define-key emacs-lisp-mode-map (kbd "M-d") nil)
;; (global-set-key (kbd "M-d") 'easy-kill-delete-region)
(use-package easy-kill
:disabled
:bind (("M-w" . easy-kill)
("M-d" . easy-kill-delete-region)))
(use-package hydra
:commands defhydra)
(defhydra contrapunctus-general (:color blue)
"What command?"
("c" chronometrist "chronometrist")
("G" elpher "elpher")
("o" cp-org/body "org")
("p" cp/prog-hydra "programming")
("i" (find-file "~/.emacs.d/init.org") "open init")
("l" launch-file "launch-file")
("s" save-buffer "save")
("k" (kill-buffer (current-buffer)) "kill")
("d" dired-jump "dired-jump")
("E" toggle-debug-on-error "tdoe")
("Q" toggle-debug-on-quit "tdoq")
("m" magit-status "magit"))
(use-package emms
:after hydra
:bind
("<f2> e" . #'hydra-emms/body)
("<f2> E" . #'emms)
(:map dired-mode-map
("E" . #'hydra-emms/body))
:commands
(emms-minimalistic emms emms-play-dired emms-add-dired)
:config
(emms-minimalistic)
(emms-default-players)
(setq emms-player-mpv-parameters
(lambda ()
(append
'("--fs"
"--quiet"
"--really-quiet"
;; "--vid=no"
"--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))))))
;; ;; This won't work for `emms-random', because it runs in a `save-excursion'
;; (add-to-list 'emms-playlist-selection-changed-hook 'emms-playlist-mode-center-current)
;; (--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)))
: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")
("u" #'emms-play-url)))
(use-package emms-playlist-mode
:bind
(: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)
("R" . #'emms-toggle-random-playlist)
("M-n" . #'emms-cue-next)
("M-p" . #'emms-cue-previous)
("SPC" . #'emms-pause))
:config
(setq emms-playlist-buffer-name "EMMS Playlist"))
(use-package emms-info-tinytag
:init
(setq emms-info-functions '(emms-info-tinytag))
:config
(setq emms-info-tinytag-python-name "python3"))
(use-package eshell
:config (setq eshell-history-size 999))
(use-package eww
:config
(setq shr-image-animate nil)
:bind
;; start boon-specific config
(:map shr-map
("v" . nil))
(:map shr-image-map
("i" . nil)
("v" . nil))
(:map eww-link-keymap
("i" . nil)
("v" . nil))
;; end boon-specific config
(:map eww-mode-map
("b" . #'eww-back-url)
("f" . #'eww-forward-url)
("v" . nil)))
(use-package url-cookie
:config
(setq url-cookie-confirmation t))
(use-package elpher
:bind (:map elpher-mode-map
("n" . elpher-next-link)
("p" . elpher-prev-link)
("b" . elpher-back)
("w" . elpher-copy-current-url)
("W" . elpher-copy-link-url)))
(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 jabber
: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 image-mode
:bind
(:map image-map
("o" . nil))
(:map image-mode-map
("o" . nil)))
(use-package flx-ido
:disabled
:init (flx-ido-mode 1)
(setq ido-enable-flex-matching t
ido-use-faces nil))
(use-package flx-isearch
:disabled
: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)
;; (add-to-list 'load-path "~/.emacs.d/elisp-git/yafolding.el/")
(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))
;; for swapped parenthesis and square brackets layout
"C-)" 'abort-recursive-edit)
;;;; 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)
(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 'text-mode-hook 'visual-line-mode)
(cl-loop for hook in
'(dired-mode-hook prog-mode-hook diff-mode-hook message-mode-hook)
do (add-hook hook (lambda () (toggle-truncate-lines 1))))
(global-visual-line-mode -1)
(use-package markdown-mode
:mode "\\.md\\'"
:hook
(markdown-mode . (lambda ()
(make-local-variable 'before-save-hook)
(add-hook 'before-save-hook 'markdown-cleanup-list-numbers)))
(markdown-mode . markdown-display-inline-images)
:config (setq markdown-command "cmark"
markdown-css-paths '("style.css")
markdown-display-remote-images t
markdown-max-image-size '(500 . 500)
;; reflows text to suit different screens
markdown-xhtml-header-content
(concat "<meta name=\"viewport\" "
"content=\"width=device-width, "
"initial-scale=1.0, "
"user-scalable=yes\" />"))
(when (featurep 'boon)
(general-def markdown-mode-map
"C-c ," 'markdown-promote
"C-c ." 'markdown-demote
"C-c C-e" 'markdown-export))
(setq-default ;; markdown-hide-markup t ;; has a bug with heading cycling
markdown-hide-urls t)
:bind
(:map markdown-mode-map
;; ("M-n" . org-drag-element-forward)
;; ("M-p" . org-drag-element-backward)
;; ("C-c C-o" . markdown-follow-link-at-point)
("M-n" . markdown-move-down)
("M-p" . markdown-move-up)
("C-c C--" . org-cycle-list-bullet)
([mouse-1] . markdown-cycle)
("C-c C-x C-n" . markdown-next-link)
("C-c C-x C-p" . markdown-previous-link)
("C-c C-h C-u" . #'markdown-toggle-url-hiding)
("C-c C-h C-m" . #'markdown-toggle-markup-hiding)
("C-c C-h C-i" . #'markdown-toggle-inline-images)
("C-c C-r" . #'reverse-region)))
(defun cp/copy-line-or-md-link (prefix-arg)
(interactive "P")
(save-excursion
(beginning-of-line)
(if (looking-at-p ".*http")
(progn
(cp/re-search-line "http")
(forward-char -4)
(kill-new (thing-at-point 'url))))))
(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)
(setq scroll-conservatively 10000
scroll-preserve-screen-position t
auto-window-vscroll nil)
(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)
(defun cp-insert-timestamp ()
(interactive)
(insert (format-time-string "%FT%T%z")))
(defun cp-insert-date ()
(interactive)
(insert (format-time-string "%F")))
(use-package time
:config
(setq display-time-next-load-average t)
(add-to-list 'zoneinfo-style-world-list '("Europe/Berlin" "Berlin")))
(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))
((cp/re-search-line "(")
(progn
(forward-char -1)
(forward-sexp)
(eval-last-sexp arg)))
(t nil))))
(use-package helpful
: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
:config
(info-initialize)
(cl-loop for dir in
'("~/.emacs.d/info/"
"~/.emacs.d/elisp-git/geiser/doc/"
"~/lilypond/usr/share/info/")
do (add-to-list #'Info-directory-list dir))
: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)))
(general-define-key
;; "s-k" 'cp-kill-buffer
"s-k" 'bury-buffer
"C-x k" 'cp-kill-buffer
"C-`" 'shell
"M-`" 'eshell
"M-<f2>" 'compile
"M-<f3>" 'run-chicken
"M-<f4>" 'run-lisp
"M-<f5>" 'ielm)
(general-define-key
:prefix "<f1>"
"M" 'describe-mode
"m" 'man
"l" 'find-library)
(general-define-key
:prefix "<f2>"
;; "<f2>" 'imenu
"<f2>" 'xref-find-definitions
"r" 'xref-find-references
"m" 'imenu
;; "p" 'grep
"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
"d" 'cp-insert-date
"c" 'calendar
"p" 'list-packages)
(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
)
(use-package help-mode
:bind
(:map help-mode-map
("b" . help-go-back)
("f" . help-go-forward)))
(global-unset-key (kbd "M-["))
(general-def
"C-' r" (kbd "")
"C-' C-r" (kbd "")
"C-' e" (kbd "")
"C-' b" (kbd "")
"C-' f" (kbd "")
"C-' p" (kbd "")
"C-' n" (kbd "")
"C-' l" (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)
(use-package browse-url
:config
(defun cp-copy-url (url &rest args)
(with-temp-buffer
(insert url)
(kill-ring-save (point-min) (point-max)))
(message "Copied %s to kill ring" url))
(setq browse-url-browser-function #'cp-copy-url))
(use-package ivy
:commands ivy-mode
:init (ivy-mode)
:config
(setq ivy-re-builders-alist
'((t . ivy--regex-ignore-order))))
(use-package magit
:bind (("<f5> m" . #'magit-status)
:map magit-revision-mode-map
;; boon
("o" . magit-section-forward)
("i" . magit-section-backward)
:map magit-status-mode-map
;; boon
("o" . magit-section-forward)
("i" . magit-section-backward)
;; ([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)))
:config
(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))
(use-package mediawiki
:commands mediawiki-mode)
(use-package midnight
:init
(midnight-mode)
:config
(setq clean-buffer-list-kill-regexps '("")
clean-buffer-list-delay-general 1
clean-buffer-list-delay-special (* 60 60 12))
:hook
(midnight . clean-buffer-list))
(use-package rainbow-delimiters
:hook (prog-mode . rainbow-delimiters-mode))
(use-package company
:diminish company-mode
:commands global-company-mode
:init (global-company-mode)
:bind ;; ("TAB" . company-indent-or-complete-common)
(:map emacs-lisp-mode-map
("TAB" . company-indent-or-complete-common)
("C-i" . company-indent-or-complete-common))
(:map c-mode-map
("TAB" . company-indent-or-complete-common)
("C-i" . company-indent-or-complete-common))
:config
(add-to-list 'company-backends 'company-irony))
(use-package feature-mode
:mode "\\.feature$")
(defun cp/compile-project (file cmd)
"Locate directory with FILE and run compile command CMD."
(cd (locate-dominating-file default-directory file))
(compile cmd))
(defhydra cp-prog (:color blue)
"Which language?"
("e" cp-el/body "Emacs Lisp")
("c" cp-cs/body "CHICKEN Scheme")
("g" cp-guile/body "Guile")
("L" cp-ly/body "Lilypond")
("l" cp-cl/body "Common Lisp")
("o" cp-org/body "Org")
("p" cp-prolog/body "Prolog")
("u" contrapunctus-general/body "up" :color blue)
("s" save-buffer "save")
("k" (kill-buffer (current-buffer)) "kill")
("E" toggle-debug-on-error "tdoe")
("Q" toggle-debug-on-quit "tdoq")
("m" magit-status "Magit"))
(defun cp/prog-hydra ()
(interactive)
(cond ((or (derived-mode-p 'emacs-lisp-mode 'ielm-mode)
;; ;; Similar problems with this as the f-glob below;
;; ;; e.g. false positive if you have a .dir-locals.el in
;; ;; a project...
;; (f-glob "*.el")
)
(cp-el/body))
(;; (or (locate-dominating-file default-directory "build.scm")
;; (locate-dominating-file default-directory "main.ly"))
(derived-mode-p 'LilyPond-mode)
(cp-ly/body))
((and (featurep 'geiser) geiser-mode)
(cond ((equal 'chicken geiser-impl--implementation)
(cp-cs/body))
((equal 'guile geiser-impl--implementation)
(cp-guile/body))
(t (error "Couldn't detect Scheme implementation."))))
((derived-mode-p 'lisp-mode 'slime-repl-mode)
(cp-cl/body))
((derived-mode-p 'org-mode)
(cp-org/body))
((derived-mode-p 'prog-mode)
(cp-prog/body))
(t (contrapunctus-general/body))))
(define-key boon-command-map (kbd "m") #'cp/prog-hydra)
(use-package elisp-mode
:diminish
:bind
(:map emacs-lisp-mode-map
("<tab>" . 'company-indent-or-complete-common)
("<C-tab>" . 'outline-toggle-children)
("M-n" . 'outline-next-heading)
("M-p" . 'outline-previous-heading)
("M-m" . macrostep-expand))
:config
(put 'cl-loop 'lisp-indent-function 'defun)
(setq print-length nil
eval-expression-print-length nil))
(use-package eldoc
:diminish
:if (featurep 'elisp-mode)
:init (add-hook 'emacs-lisp-mode-hook 'eldoc-mode)
:config (setq eldoc-idle-delay 0))
(use-package emr
:bind (:map prog-mode-map
("M-S-<return>" . emr-show-refactor-menu)))
(use-package nameless
:commands nameless-mode
:hook
(ert-results-mode . nameless-mode)
(emacs-lisp-mode . nameless-mode)
:bind (:map emacs-lisp-mode-map
("C-c C-n" . nameless-mode)))
(use-package explain-pause-mode
:load-path "/home/anon/.emacs.d/elisp-git/explain-pause-mode/"
:disabled t
:diminish
:commands explain-pause-mode
:init (explain-pause-mode))
(defhydra cp-el-eval (:color blue)
("b" eval-buffer "buffer")
("e" eval-defun "defun")
("l" eval-last-sexp "last sexp"))
(defhydra cp-el (:color blue)
"Emacs Lisp"
("r" ielm "REPL")
("e" cp-el-eval/body "Eval")
("h" helpful-at-point "Help")
("j" xref-find-definitions "Jump to definition")
("d" (funcall-interactively #'eval-defun t) "Debug")
("c" (cp/compile-project "Cask" "cask build") "Compile")
("C" (cp/compile-project "Cask" "cask clean-elc") "clean")
("t" (cp/compile-project "Cask" "cask exec buttercup -L . --traceback pretty") "Test")
("u" cp-prog/body "up" :color blue)
("s" save-buffer "save")
("k" (kill-buffer (current-buffer)) "kill")
("E" toggle-debug-on-error "tdoe")
("Q" toggle-debug-on-quit "tdoq")
("m" magit-status "Magit"))
(defhydra cp-cl-eval (:color blue)
("b" slime-eval-buffer "buffer")
("e" slime-eval-defun "defun"))
(defhydra cp-cl-doc (:color blue)
("d" slime-documentation "slime")
("e" slime-documentation-lookup "CLHS"))
(defhydra cp-cl (:color blue)
"Common Lisp"
("C" slime-connect "connect")
("d" cp-cl-doc/body "Documentation")
("e" cp-cl-eval/body "Eval")
("r" slime "REPL")
("u" cp-prog/body "up" :color blue)
("s" save-buffer "save")
("m" magit-status "Magit"))
(defhydra cp-scm-eval (:color blue)
("b" geiser-eval-buffer "buffer")
("e" geiser-eval-definition "defun"))
(defhydra cp-cs (:color blue)
"CHICKEN Scheme"
("e" cp-scm-eval/body "Eval")
("r" run-chicken "REPL")
("m" magit-status "Magit")
("u" cp-prog/body "up" :color blue))
(defhydra cp-guile (:color blue)
"Guile"
("e" cp-scm-eval/body "Eval")
("r" run-guile "REPL")
("m" magit-status "Magit")
("G" elpher "Elpher")
("u" cp-prog/body "up" :color blue))
(defhydra cp-ly (:color blue)
"Lilypond"
("c" (cp/compile-project "main.ly" "~/bin/mkly dev") "Compile")
("m" magit-status "Magit")
("G" elpher "Elpher")
("u" cp-prog/body "up" :color blue))
(use-package ediprolog
:commands ediprolog-dwim)
(defhydra cp-prolog (:color blue)
"Prolog"
("u" cp-prog/body "up" :color blue)
("r" ediprolog-dwim "REPL"))
(use-package cc-mode)
(use-package irony-eldoc
:hook
(c-mode . irony-eldoc))
(use-package irony
:config
(add-hook 'irony-mode-hook #'irony-eldoc))
(use-package company-irony)
(use-package rtags
:hook
(c-mode . rtags-call-rc)
:config
(setq rtags-rc-binary-name "rtags-rc"
rtags-rdm-binary-name "rtags-rdm")
:bind
(:map c-mode-map
("<f2> <f2>" . rtags-find-symbol-at-point)))
(use-package nodejs-repl
:disabled
:config (setq nodejs-repl-command "nodejs"))
(use-package nov
:mode ("\\.epub\\'" . nov-mode))
(use-package package
:bind
(:map package-menu-mode-map
("c" . package-autoremove))
:config
(when (featurep 'boon)
(general-def package-menu-mode-map
"X" 'package-menu-execute)))
(use-package feather
:diminish
:hook (package-menu-mode . feather-mode)
:bind ("<f5> p " . list-packages))
(use-package swiper
:bind
(("C-s" . swiper)
("C-r" . swiper-backward))
:config
(setq swiper-action-recenter t))
(use-package powerline)
(use-package sxiv
:config (setq sxiv-exclude-strings '("meh" "\\.NEF$")))
;; (load "cp-adb")
(require 'cp-editing)
;; (load "cp-evil")
(require 'cp-fm)
(require 'cp-lily)
(require 'cp-sfz)
(require 'cp-lisp)
(require 'cp-nav)
;; (ispell-change-dictionary "en")
(setq ispell-dictionary "en")
(use-package undo-tree
:commands global-undo-tree-mode
: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 ()
(let* ((file-path (buffer-file-name))
(file-path-shell (shell-quote-argument file-path)))
(cl-case major-mode
;; ;; This would be more useful if it was only displayed when
;; ;; tests failed. But even a constantly failing test result
;; ;; being shown each time you save can be annoying.
;; ('emacs-lisp-mode (let ((project-dir (locate-dominating-file file-path "Cask")))
;; (when project-dir
;; (cd project-dir)
;; (compile "cask exec buttercup -L . --traceback pretty"))))
('org-mode
(pcase (file-name-nondirectory
(buffer-file-name
(current-buffer)))
((or "chronometrist.org" "chronometrist-key-values.org" "init.org") t)
(_ (org-html-export-to-html))))
('LilyPond-mode
(let ((project-dir (locate-dominating-file file-path ;; "build.scm""
"mkly-rules.scm")))
(when project-dir
(cd project-dir)
(compile "~/bin/mkly dev"
;; "./build.scm main pac=on"
))))
('latex-mode
(if (file-exists-p "Makefile")
(compile (car compile-history))
(compile (concat "xelatex " file-path-shell))))
;; ('markdown-mode (markdown-export))
('c-mode
(compile (concat "gcc -static -o "
(shell-quote-argument
(file-name-base))
" "
file-path-shell))))))
(add-hook 'after-save-hook 'cp/after-save)
(use-package compile
:config
;; (add-hook 'compilation-start-hook
;; (lambda (proc)
;; (delete-other-windows)))
(setq compilation-always-kill t))
(require 'cp-hindi)
(require 'cp-parens)
(use-package keyfreq
:disabled
:init
(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!
;; ;; 2020-08-05T16:28:07+0530 commented out, no longer interested
;; (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)))
(use-package recentf
:init (recentf-mode 1)
:bind ("C-x C-r C-o" . recentf-open-files)
:config
(setq recentf-auto-cleanup 'never
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"))
:hook
(kill-emacs . recentf-cleanup))
;;;; 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")
(use-package wgrep
:commands (wgrep-change-to-wgrep-mode))
(setq custom-file "~/.emacs.d/custom.el")
(load custom-file)
(require 'doom-themes)
(load-theme 'doom-acario-dark)
(mapc (lambda (command)
(put command 'disabled nil))
'(downcase-region
upcase-region
set-goal-column
scroll-left
erc-remove-text-properties-region))
(require 'cp-org)
(require 'cp-desktop)
(require 'cp-mail)
(put 'list-timers 'disabled nil)
(setq gc-cons-threshold 400000)
;; (toggle-debug-on-quit)
;; (profiler-stop)
;; (emacs-init-time)
;; (profiler-report)
(provide 'init)
;;; init.el ends here