Compare commits

..

1 Commits

Author SHA1 Message Date
contrapunctus 3176ef6b4a Begin migration 2020-05-13 10:59:36 +05:30
48 changed files with 3192 additions and 6358 deletions

4
.gitignore vendored
View File

@ -1,8 +1,4 @@
*
!*.org
!*.el
!contrapunctus
!snippets
!snippets/*
!snippets/*/*
.*

View File

@ -1,34 +0,0 @@
.phony: all setup tangle lint clean
all: setup tangle lint
setup:
emacs --batch --eval="(package-initialize)" \
--eval="(mapcar #'package-install '(indent-lint package-lint relint))"
# No -q or -Q, in case the user has a newer version of Org.
init-org.el:
emacs --batch \
--eval="(require 'ob-tangle)" \
--eval='(org-babel-tangle-file "init.org")'
tangle: init-org.el
lint-check-declare: tangle
emacs -q -Q --batch --eval='(check-declare-file "init.el")'
lint-checkdoc: tangle
emacs -q -Q --batch --eval='(checkdoc-file "init.el")'
lint-package-lint: setup tangle
emacs -Q --batch --eval='(package-initialize)' \
--eval="(require 'package-lint)" \
-f 'package-lint-batch-and-exit' "init.el"
lint-relint: setup tangle
emacs -q -Q --batch --eval='(relint-file "init.el")'
lint: lint-check-declare lint-checkdoc lint-package-lint lint-relint
clean-tangle:
-rm init.el

View File

@ -1,24 +0,0 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <https://unlicense.org>

View File

@ -1,15 +0,0 @@
;;;; Emacs Bookmark Format Version 1 ;;;; -*- coding: utf-8-emacs -*-
;;; This format is meant to be slightly human-readable;
;;; nevertheless, you probably don't want to edit it.
;;; -*- End Of Bookmark File Format Version Stamp -*-
(("rec"
(filename . "/media/data/phone/contrapunctus/Nokia 6.1/Android/data/net.osmand.plus/files/tracks/rec/")
(front-context-string . " /media/data/ph")
(rear-context-string)
(position . 1))
("screenshots"
(filename . "/media/data/contrapunctus/Pictures/screenshots/")
(front-context-string . " /media/data/co")
(rear-context-string)
(position . 1))
)

View File

@ -0,0 +1,195 @@
(use-package chronometrist
:ensure t
:load-path "~/.emacs.d/contrapunctus/chronometrist"
:hook
(chronometrist-kv-read-mode . visual-line-mode)
(kill-emacs-query-functions . chronometrist-query-stop)
: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-goals)
(setq chronometrist-goals-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")
(15 "Wikisource"))
alert-default-style 'libnotify
chronometrist-before-in-functions '()
chronometrist-after-in-functions '(;; chronometrist-tags-add
;; chronometrist-kv-add
contrapunctus-start-project
chronometrist-goals-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-goals-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 "")))))
(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/Khilona/Videos/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*")
(split-window-below)
(other-window 1)
(find-file "~/phone/Nokia 6.1/Documents/Markor/Computers/todo.md")
(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))))
(provide 'cp-chronometrist)

View File

@ -0,0 +1,47 @@
(use-package desktop
:init (desktop-save-mode t)
:config
(setq desktop-dirname "~/.emacs.d/desktop-save/"
desktop-save 'ask-if-new)
(-map (lambda (element)
(add-to-list 'desktop-globals-to-save element))
'(grep-history
grep-find-history
find-args-history
extended-command-history
read-expression-history
default-input-method
input-method-history
query-replace-history
compile-history
string-rectangle-history
regexp-history
dired-shell-command-history
dired-regexp-history
shell-command-history
org-tags-history
minibuffer-history
erc-server-history-list
cp/activity-history
LaTeX-environment-history)))
(desktop-save-mode t)
;; (add-to-list 'desktop-locals-to-save 'comint-input-ring)
(desktop-auto-save-enable)
(defun cp/backup-desktop-file ()
(let ((new-filename (->> (shell-command-to-string "date -Is")
(replace-regexp-in-string "\n" "")
(concat "~/.emacs.d/.emacs.desktop."))))
(copy-file "~/.emacs.d/.emacs.desktop" new-filename)))
(defun cp/cleanup-desktop-backups ()
(let ((desktop-file-backups (-> (concat "find ~/.emacs.d/ -maxdepth 1 -type f |"
" grep -E \"\.emacs\.desktop\.[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}[-+]?[0-9]{2}:?[0-9]{2}\"")
(shell-command-to-string )) )))
(if (> 10 )))
;; ;; this one created loads and loads of backups
;; (add-hook 'desktop-save-hook 'cp/backup-desktop-file)
;; ;; not enough space for this - wasteful
;; (add-hook 'kill-emacs-hook 'cp/backup-desktop-file)
(provide 'cp-desktop)

283
contrapunctus/cp-editing.el Normal file
View File

@ -0,0 +1,283 @@
;;;; Editing improvements
;; fix Emacs' definition of a sentence
(setq sentence-end-double-space nil)
;; the utter basics
(general-define-key
"C-h" 'backward-delete-char
"C-w" 'backward-kill-word
"C-u" 'cp-kill-line-0
;; A better solution would be to hack kill-line/kill-visual-line to
;; kill the region if a region is active. The flexibility of those
;; functions is very desirable - you can delete from point to line
;; end, clear a line to enter some other text on it (C-a C-k/"a k"),
;; or delete one or more whole lines (C-1 C-k/"1 k" or C-<num>
;; C-k/"<num> k").
"C-y" 'whole-line-or-region-yank
"C-S-k" 'whole-line-or-region-kill-region
"C-," 'backward-paragraph
"C-." 'forward-paragraph
"C-<" 'beginning-of-buffer
"C->" 'end-of-buffer)
(define-key isearch-mode-map (kbd "C-h") 'isearch-delete-char)
(defun cp-kill-line-0 ()
(interactive)
(kill-line 0))
(global-unset-key (kbd "C-x C-r"))
(general-define-key
:prefix "C-x C-r"
"C-i" 'string-insert-rectangle
"C-r" 'replace-rectangle
"C-k" 'kill-rectangle)
(defun cp/downcase-dwim (arg)
"Like `downcase-word', but if region is active, run
`downcase-region' instead. Unlike `downcase-region', rectangular
regions are handled correctly as well.")
;; open-line should always move to the beginning of the current line
;; first, so one can run it anywhere. I also want it to indent it to
;; the next or the previous line...
;; These affect org-meta-return and org-insert-heading-respect-content
;;
;; (defadvice open-line
;; (before open-line-bol activate)
;; (beginning-of-visual-line))
;; (defadvice open-line
;; (after open-line-indent activate)
;; (if (not (looking-at "\\** "))
;; (indent-for-tab-command)))
;; (global-set-key (kbd "C-o") 'open-line)
(defun cp/open-line ()
"The opposite of `cp/open-line-before'. Start a new line below
the current line, regardless of where point is in the current
line. Will not affect the content of the current line. Applies
the correct indentation according to the mode."
(interactive)
(progn
(end-of-line)
(electric-indent-just-newline t)
(indent-according-to-mode)))
(defun cp/open-line-before (arg)
"Like `open-line' but a bit more sane.
In org-mode, run org-open-line.
In other modes, insert a newline above the current line,
regardless of where point is in current line. Will not affect
content of current line. Applies the correct indentation
according to the mode."
(interactive "p")
(if (and (equal major-mode 'org-mode)
(org-at-table-p))
(org-open-line arg)
(progn
(beginning-of-line)
(electric-indent-just-newline t)
(forward-char -1)
(indent-according-to-mode))))
(global-set-key (kbd "C-o") 'cp/open-line-before)
;; I wish you could press e.g. S-o in god-mode to get C-S-o.
;; 10/10 would make life better.
(global-set-key (kbd "C-S-o") 'cp/open-line)
(setq dired-bind-jump nil)
(global-set-key (kbd "C-x C-j") 'join-line)
;; C-z (suspend-frame) is utterly useless and disruptive - good place to put universal-argument
(global-unset-key (kbd "C-z"))
(global-set-key (kbd "C-z") 'universal-argument)
(global-set-key (kbd "C-x C-z") 'repeat)
(global-set-key (kbd "C-x C-;") 'repeat-complex-command)
;; (defun cp-kill-line (&optional arg)
;; (interactive)
;; (if arg
;; (if mark-active
;; (kill-region arg)
;; (kill-line arg))
;; (if mark-active
;; (kill-region)
;; (kill-line))))
;; (global-set-key (kbd "C-k") 'cp-kill-line)
;; Chris Done (god-mode) recommends this, but Emacs' repeat command is almost useless...
;; (global-set-key (kbd "C-.") 'repeat)
;;;; I like the transpose commands
(global-unset-key (kbd "C-t"))
(general-define-key
:prefix "C-t"
"C-t C-c" 'transpose-chars
"C-t C-w" 'transpose-words
"C-t C-l" 'transpose-lines
"C-t C-s" 'transpose-sentences
"C-t C-e" 'transpose-sexps
"C-t C-p" 'transpose-paragraphs)
(global-set-key (kbd "C-M-h") 'er/expand-region)
(use-package dot-mode
:disabled
:hook (text-mode prog-mode LilyPond-mode)
:bind (:map dot-mode-map
("C-." . nil)
("M-." . dot-mode-execute)
("C-M-." . nil)))
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(require 'flex-isearch)
(flex-isearch-mode 1)
(general-define-key
"C-M-s" 'flex-isearch-forward
"C-M-r" 'flex-isearch-backward)
(with-eval-after-load 'iedit
(define-key iedit-mode-keymap (kbd "C-h") 'backward-delete-char))
(with-eval-after-load 'markdown-mode
(defun cp/copy-md-link (prefix-arg)
"Copy address of Markdown link after point in the current line.
If there is no link in the current line, or if the region is
active, or with a prefix arg - call
whole-line-or-region-kill-ring-save instead."
(interactive "P")
(save-excursion
(if (or (use-region-p)
prefix-arg
(not (re-search-line
;; 2018-03-21T22:47:55+0530 - fix bug where a line with parenthesized text would not be copied
;; "\("
;; 2018-07-22T10:20:03+0530
;; "\\[.*?\\](.*?)"
"\\[.*?\\]("
)))
(whole-line-or-region-kill-ring-save prefix-arg)
(let ((point-a (point)))
(forward-char -1)
(forward-sexp)
(copy-region-as-kill point-a (- (point) 1))))))
(cp-set-keys
:keymap markdown-mode-map
:bindings
`((,(kbd "M-w") cp/copy-md-link)
(,(kbd "TAB") markdown-cycle)
(,(kbd "C-c C-.") markdown-demote)
(,(kbd "C-c C-,") markdown-promote)
(,(kbd "C-c C-l") markdown-insert-link))))
(defun cp/copy-bus-entry ()
"For personal use, when working between Markdown and the OSM wiki."
(interactive)
(let ((point-a (region-beginning))
(point-b (region-end))
(point-b-line (line-number-at-pos)))
(query-replace "[ ]" "" nil point-a point-b)
(query-replace "[x]" "" nil point-a point-b)
(query-replace-regexp "^- " "" nil point-a point-b)
(goto-char (point-min))
(forward-line (- point-b-line 1))
(copy-region-as-kill point-a (point-at-bol))))
;; 2018-08-21T03:41:47+0530
(defun cp/copy-md-link (prefix-arg)
"Copy address of Markdown link after point in the current line.
If there is no link in the current line, or if the region is
active, or with a prefix arg - call
whole-line-or-region-kill-ring-save instead."
(interactive "P")
(save-excursion
(cond
((or (use-region-p) prefix-arg)
(whole-line-or-region-kill-ring-save prefix-arg))
((re-search-line "\\[.*?\\](")
(let ((point-a (point)))
(forward-char -1)
(forward-sexp)
(copy-region-as-kill point-a (- (point) 1))))
((re-search-line "http")
(kill-new (thing-at-point 'url)))
(t (whole-line-or-region-kill-ring-save prefix-arg)))))
;; 2018-08-28T22:50:43+0530
(defun cp/copy-buffer ()
(interactive)
(copy-region-as-kill (point-min) (point-max)))
(use-package multiple-cursors
:bind (("C-M-l" . #'mc/mark-previous-like-this-symbol)
("C-M-;" . #'mc/mark-next-like-this-symbol)
("C-M-'" . #'mc/mark-all-symbols-like-this)
("C-M-," . #'mc/mark-previous-word-like-this)
("C-M-." . #'mc/mark-next-word-like-this)
("C-M-/" . #'mc/mark-all-words-like-this)
("C-M-<" . #'mc/unmark-previous-like-this)
("C-M->" . #'mc/unmark-next-like-this)
("C-M-]" . #'mc-hide-unmatched-lines-mode)))
(defun cp/marked-files->markup-links-org (filenames)
(mapcar (lambda (filename)
(let ((link-pre "[[file:")
(link-post "][]]\n"))
(concat link-pre filename link-post)))
filenames))
(defun cp/marked-files->markup-links-md (filenames)
(mapcar (lambda (filename)
(if (member (downcase
(file-name-extension filename))
image-file-name-extensions)
(let ((link-pre "![](")
(link-post ")\n"))
(concat link-pre filename link-post))
(let ((link-pre "[](")
(link-post ")\n"))
(concat link-pre filename link-post))))
filenames))
;; BUG - (dired-get-marked-files) returns file name at point if none are marked
;; BUG - (dired-get-marked-files) always returns an alphabetically-sorted list, even when the Dired buffer is sorted by date
(defun cp/marked-files->markup-links ()
"From a Dired buffer, insert the file at point or marked files
as links into an Org or Markdown document."
(interactive)
(if (derived-mode-p 'dired-mode)
(let* ((filenames (dired-get-marked-files 'no-dir))
(other-buffer (->> (window-list)
(cadr)
(window-buffer)))
(other-buffer-mode (with-current-buffer other-buffer major-mode))
(two-window-op (and (= (length (window-list)) 2)
(member other-buffer-mode
'(org-mode markdown-mode))))
(output-buffer (if two-window-op
other-buffer
(read-buffer "Insert links in buffer: ")))
(output-mode (with-current-buffer output-buffer major-mode))
(output-text (case output-mode
('org-mode
(cp/marked-files->markup-links-org filenames))
('markdown-mode
(cp/marked-files->markup-links-md filenames))
(t (error "Only Markdown and Org are currently supported.")))))
(if two-window-op
(other-window 1)
(switch-to-buffer output-buffer))
(mapc #'insert output-text))
(user-error "Run this command from a Dired buffer with some marked files."))
(when markdown-inline-image-overlays
(markdown-display-inline-images)))

79
contrapunctus/cp-emms.el Normal file
View File

@ -0,0 +1,79 @@
;; 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)
("R" . #'emms-toggle-random-playlist)
("M-n" . #'emms-cue-next)
("M-p" . #'emms-cue-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))))))
;; 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)))
(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")
("u" #'emms-play-url)))
(provide 'cp-emms)

87
contrapunctus/cp-evil.el Normal file
View File

@ -0,0 +1,87 @@
(use-package evil
:disabled
:init (evil-mode 1)
;; Want something to switch between evil and god-mode, instead of this.
;; They say there's a plugin for it...
:bind
(("C-x e" evil-mode)
;;(global-set-key (kbd "g C-g") 'count-words-region)
(:map evil-normal-state-map
&allow-other-keys(;; ("<tab>" forward-button)
("zR" . 'yafolding-show-all)
("zM" . 'yafolding-hide-all)
("zo" . 'yafolding-show-element)
("zc" . 'yafolding-hide-element)
;; The story so far - in evil-normal-state-map, I set 'i' to
;; evil-previous-visual-line, 'k' to evil-next-visual-line,
;; 'j' to evil-backward-char. Note that I forgot to set 'h'
;; to insert at first...but that's not all - later I realized
;; this didn't affect Visual mode :p 4 more lines for that.
;; Next...d/c didn't work with ijkl. 4 more lines for
;; evil-operator-state-map. After that - you usually want
;; visual-line up/down movement, but _not_ when you hit d-j/k
;; (or d-i/k)! So, in evil-operator-state-map, i and k are
;; now vanilla evil-previous/next-line. Set gi/gk to
;; evil-previous/next-line in normal and visual states, and
;; to evil-previous/next-visual-line in operator state - 2
;; new lines to each group of 4.
("gi" . evil-previous-visual-line)
("gk" . evil-next-visual-line)
( "i" . evil-previous-line)
( "k" . evil-next-line)
( "j" . evil-backward-char)
( "h" . evil-insert)))
:map evil-visual-state-map
("gi" evil-previous-visual-line)
("gk" evil-next-visual-line)
("i" evil-previous-line)
("k" evil-next-line)
("j" evil-backward-char)
("h" evil-insert)
:map evil-operator-state-map
("gi" evil-previous-visual-line)
("gk" evil-next-visual-line)
("i" evil-previous-line)
("k" evil-next-line)
("j" evil-backward-char)
("h" evil-insert)
;; evil-inner-tag ?
("hW" evil-inner-WORD)
("hw" evil-inner-word)
("h\(" evil-inner-paren)
("h\)" evil-inner-paren)
("h\{" evil-inner-curly)
("h\}" evil-inner-curly)
("h<" evil-inner-angle)
("h>" evil-inner-angle)
("h\[" evil-inner-bracket)
("h\]" evil-inner-bracket)
("hs" evil-inner-sentence)
("hp" evil-inner-paragraph)
("h`" evil-inner-back-quote)
("h\"" evil-inner-double-quote)
("h'" evil-inner-single-quote)
:map evil-motion-state-map
("gi" evil-previous-visual-line)
("gk" evil-next-visual-line)))
;;;; set C-h to backspace when editing commands and searching
(defun kill-start-of-line ()
"Kill from point to start of line."
(interactive)
(kill-line 0))
(define-key evil-insert-state-map (kbd "C-u") 'kill-start-of-line))
;;;; evil-snipe
(with-eval-after-load 'evil-snipe
(setq evil-snipe-count-scope 'letters)
;; This doesn't take two chars by default, which combined with
;; unimplemented evil-snipe-count-scope 'vertical makes it nearly
;; useless as a replacement for fFtT;
(evil-snipe-replace-evil)
(global-evil-snipe-mode 1))
(evil-mode)

423
contrapunctus/cp-fm.el Normal file
View File

@ -0,0 +1,423 @@
;; -*- lexical-bindiing: t; -*-
;; TODO - function which deletes buffers (esp. files and dired buffers) above a certain size. Then, set that to a timer.
;;;; File management
(add-to-list 'load-path "~/.emacs.d/elisp-git/dired-toggle-sudo/")
(add-to-list 'load-path "~/.emacs.d/elisp-git/project-explorer/")
(use-package dired
:init (add-hook 'dired-mode-hook 'turn-on-launch-mode)
:config
(setq dired-listing-switches
;; by date
;; "-cgGhlt --group-directories-first --time-style=long-iso"
;; by name
"-cgGhl --group-directories-first --time-style=long-iso"
;; no -h
;; "-cgGl --group-directories-first --time-style=long-iso"
;; by date, no --group-directories-first
;; "-cgGhlt --time-style=long-iso"
)
:bind (("<f2> s" . sxiv)
:map dired-mode-map
("W" . wdired-change-to-wdired-mode)
("e" . #'cp/dired-do-ediff)
;; after learning that this copies whole paths with null
;; argument, this became a whole lot more useful
("C-w" . dired-copy-filename-as-kill)
("C-c C-f" . cp/corresponding-text-file)
("h" . cp/dired-toggle-hidden)
([mouse-2] . cp/dired-launch-or-open)
("C-j" . launch-files-dired)
("j" . launch-files-dired)
("M-s r" . dired-do-query-replace-regexp)
("M-s s" . dired-do-isearch-regexp)
("P" . emms-play-dired)
("I" . 'sxiv)
("X" . 'dired-do-flagged-delete))
:hook (dired-mode . (lambda () (dired-hide-details-mode t))))
(use-package dired-async
:init (dired-async-mode 1))
(use-package dired-x
:commands dired-jump
:bind ("C-x C-d" . dired-jump))
;; TODO - make launch-file suggest the path at point by default
(use-package launch
:commands turn-on-launch-mode launch-files-dired
:bind ("s-l" . launch-file))
(defun cp/open-random-file (&optional find-args dir cmd)
"Open a random file in DIR, prompting the user for it if not supplied."
(interactive)
(let* ((find-args (if find-args find-args " -type f "))
(dir (if dir dir
(read-directory-name "Directory: "
(if file-name-history
(car file-name-history)
default-directory)
nil t)))
(file-name (--> (expand-file-name dir)
(concat "find " "\"" it "\" "
find-args " | shuf | sed 1q")
(shell-command-to-string it)
(replace-regexp-in-string "\n" "" it))))
(if cmd
(async-shell-command (concat cmd " \"" file-name "\""))
(find-file file-name))))
(with-eval-after-load 'project-explorer
(global-set-key (kbd "<f5> e") 'project-explorer-toggle))
;; (require 'sudo-edit)
(defun cp/dired-ffmpeg (&optional format)
(interactive)
(let ((files (-map #'shell-quote-argument (dired-get-marked-files t)))
(format (if format format "mp3")))
(--map (let* ((fbasename (file-name-base it))
(new-name (concat fbasename "." format)))
(call-process "ffmpeg" nil "*dired-ffmpeg*" t
"-i" it "-ac" "2" "-f" format new-name))
files)))
(defvar cp/ffmpeg-max-processes 1
"Maximum number of simultaneous ffmpeg processes run by
`cp/dired-do-ffmpeg'. See also
`cp/ffmpeg-process-recount-interval'.")
(defvar cp/ffmpeg-process-recount-interval 10
"Time interval to check number of processes after, and maybe
start new processes. See TIME argument of `run-at-time' for
possible values.")
(defun cp/ffmpeg-process-count ()
(->>
(-map 'process-name (process-list))
(--count (string-match-p "^dired-ffmpeg" it))))
(defun cp/maybe-call-ffmpeg (shell-args)
(if (< (cp/ffmpeg-process-count) cp/ffmpeg-max-processes)
(apply 'start-process "dired-ffmpeg"
(generate-new-buffer-name "*dired-ffmpeg*")
"ffmpeg"
(split-string-and-unquote shell-args))
(run-at-time cp/ffmpeg-process-recount-interval
nil
(cp/maybe-call-ffmpeg shell-args))))
;; TODO - 1. process buffer does not update like ffmpeg run in the
;; terminal.
;; 2. don't make FORMAT arg compulsory - if omitted, create
;; unique file name based on original, with same extension
;; (`make-temp-name')
(defun cp/dired-do-ffmpeg (input-args output-args format)
"In Dired buffers, runs `ffmpeg' on each marked file, or, if no
marks are present, on the file at point.
Each input file will result in one output file. The output file
will have the same file name but FORMAT as the extension.
This command thus uses barely a fraction of what ffmpeg can do,
but hopefully it covers any and every one-file-in-one-file out
usage, which is most common for the author.
INPUT-ARGS and OUTPUT-ARGS can be left blank (\"\"). FORMAT is
presently necessary, and must not be the same as the input file.
ffmpeg must be installed on your system, of course."
(interactive "sInput arguments (optional) : \nsOutput arguments (optional) : \nsOutput format : ")
(let ((files (-map #'shell-quote-argument
(dired-get-marked-files t))))
(--map
(let* ((fbasename (file-name-base it))
(new-name (concat fbasename "." format))
(args (concat input-args " "
"-i " it " "
output-args " "
new-name)))
;; (with-output-to-temp-buffer "cp/dired-do-ffmpeg"
(cp/maybe-call-ffmpeg args)
;; )
)
files)))
;; (with-current-buffer "log"
;; (goto-char (point-max))
;; (insert
;; (concat
;; (propertize (format-time-string "%FT%T%z") 'face 'bold)
;; "\n"))
;; (start-file-process-shell-command "ls" "log" "ls -g ~/Urecord*")
;; (insert
;; (concat
;; "\n(cp/ffmpeg-process-count) - "
;; (number-to-string (cp/ffmpeg-process-count))
;; "\n(process-list) - \n"
;; (apply 'concat " " (-interpose "\n " (-map 'process-name (process-list))))
;; "\ntimer-list - \n"
;; (apply 'concat " " (-interpose "\n " (-map 'prin1-to-string timer-list)))
;; "\n\n"))
;; (set-window-point
;; (get-buffer-window "log")
;; (point-max))
;; (recenter))
;; (temp-buffer-window-show "*dired-ffmpeg*")
(defun cp/dired-do-ediff (&optional format)
"Ediff (first two or three) marked files."
(interactive)
(let* ((files (dired-get-marked-files t))
(file-1 (car files))
(files-dir default-directory))
;; 2018-04-08T11:31:20+0530 TODO - if there is only one marked
;; file, check the other window for a marked file and ediff with
;; that.
(case (length files)
(1 (progn
(other-window 1)
(let ((files2 (dired-get-marked-files t))
(files2-dir default-directory))
(if files2
(ediff (expand-file-name
(concat files-dir (car files)))
(expand-file-name
(concat files2-dir (car files2))))))))
(2 (ediff file-1
(cadr files)))
(t (ediff3 file-1
(cadr files)
(elt files 2))))))
;; (defvar count 0)
;; (defun timer-test (count)
;; (if (= count 5)
;; (progn
;; (message "count %s - finito" count)
;; (cancel-timer test-timer))
;; (progn
;; (message "incrementing count - %s" count)
;; (setq count (1+ count)))))
;; ;; works! -
;; (let ((a 1) (b 2))
;; (setq test-timer
;; (run-at-time 1 nil `(lambda () (message "%d" (+ ,a ,b))))))
;; ;; works
;; (let ((a 1))
;; (setq my-timer
;; (run-with-timer 5 5 (lambda ()
;; (message "I cancelled my-timer")
;; (cancel-timer my-timer)))))
;; ;; works
;; (setq my-timer
;; (run-with-timer 5 5 (lambda ()
;; (message "I cancelled my-timer")
;; (cancel-timer my-timer))))
;; ;; works
;; (defvar test t)
;; (defun process-queue ()
;; (if test
;; (progn
;; (message "process-queue says hi")
;; (run-with-timer 5 nil 'process-queue))
;; (message "process-queue says bye")))
;; (let ((a 1) (b 2) (time 5))
;; (setq test-timer
;; (run-at-time 5 5
;; `(lambda ()
;; (message "test-timer - %d" ,a)
;; (setq a (1+ ,a))))))
;; (progn
;; (run-at-time "2 sec" nil (lambda () (message "bye!")))
;; (message "hi!"))
(defun cp/nth-filename-this-line (&optional count)
(let ((file (buffer-substring-no-properties
(progn
(beginning-of-line)
(search-forward "/" nil t count)
(forward-char -1)
(point))
(or (progn
(re-search-forward " und /" (point-at-eol) t)
(re-search-backward " " nil t 2))
(progn
(re-search-forward " sind verschieden." (point-at-eol) t)
(re-search-backward " " nil t 2))
(- (point-at-eol) 1)))))
(if (file-exists-p file)
file
(replace-regexp-in-string ": " "/" file))))
(defun cp/copy-to-ehdd ()
"Copy files using file names from diff(1) output."
(interactive)
(re-search-forward "^Nur in /media/alpha/")
(let* ((file (cp/nth-filename-this-line))
(dest (replace-regexp-in-string "^/media/alpha/"
"/media/kashish-wd-1tb/alpha/"
file)))
(forward-line)
(if (file-directory-p file)
(copy-directory file dest t t t)
(copy-file file dest nil t t t))))
(defun cp/diff-ediff ()
(interactive)
(beginning-of-line)
(let ((file1 (cp/nth-filename-this-line))
(file2 (cp/nth-filename-this-line 2)))))
(defun cp/diff-show-file ()
(interactive)
(let ((file (cp/nth-filename-this-line)))
(dired-jump t file)
(message file)))
(with-eval-after-load 'diff-mode
(define-key diff-mode-map (kbd "C-o") 'cp/diff-show-file))
(defun cp/dired-update-all ()
(mapc (lambda (b)
(with-current-buffer b
(if (equal major-mode 'dired-mode)
(find-alternate-file (dired-current-directory)))))
(buffer-list)))
(defun cp/done-matches (&optional count)
(interactive "P")
(let ((case-fold-search nil)
(count (if count count 1)))
(flet ((done-matches-op
()
(when (re-search-forward "^/media/kashish-wd-1tb/alpha/kashish/new-stuff/7-music/playerdump/")
(let* ((para-start (progn
(re-search-backward "^[0-9]+ bytes each:$")
(point)))
(matches (progn (forward-line 1)
(count-lines (point)
(progn
(forward-paragraph)
(point))))))
(when (= matches 2)
(delete-region (point)
(progn
(forward-paragraph -1)
(point))))))))
(if (= count 0)
(while (not (eobp))
(done-matches-op))
(dotimes (i count)
(done-matches-op))))))
(defun cp/change-all-units ()
"for fdupes output"
(interactive)
(while (re-search-forward "^[0-9]+" nil t)
(shell-command-on-region (point-at-bol) (point) "numfmt --to=iec-i --suffix=B" nil t)
(forward-word)
(delete-region (point) (progn (forward-word) (point)))))
(defun cp/launch-file-archive ()
(interactive)
(launch-file
(concat
default-directory
(aref (archive-get-descr) 0))))
;; (define-key archive-mode-map (kbd "j") 'cp/launch-file-archive)
;; 2018-02-28T21:00:57+0530
(defun cp/corresponding-text-file ()
(interactive)
(save-excursion
(end-of-line)
(if (derived-mode-p 'dired-mode)
;; 2018-08-05T02:01:26+0530 - support directories too
(let* ((file-or-dir (dired-file-name-at-point))
(file (if (file-directory-p file-or-dir)
(replace-regexp-in-string "/$" "" file-or-dir)
file-or-dir)))
(find-file (concat file ".txt"))))))
;; 2018-06-23T09:57:34+0530
;; FIXME - probably very fragile, assumes a lot about dired-actual-switches
;; BUG - viewing hidden files is okay, but hiding them again never
;; seems to work without a find-alternate-file, which in turn
;; never seems to work non-interactively. Parts of dired-revert
;; seem relevant to this.
(defun cp/dired-toggle-hidden ()
"Toggle visibility of hidden files."
(interactive)
(if (string-match-p "-A" dired-listing-switches)
(setq dired-actual-switches
(replace-regexp-in-string "\\(-A\\).*\\'"
"-"
dired-listing-switches
nil nil 1))
(setq dired-actual-switches
(replace-regexp-in-string "\\(-\\).*\\'"
"-A"
dired-listing-switches
nil nil 1)))
;; (revert-buffer)
(dired-revert)
;; (find-alternate-file (dired-current-directory)) ;; no good at all
;; no good either
;; (let ((directory (dired-current-directory)))
;; (kill-this-buffer)
;; (dired directory))
)
;; 2018-07-09T23:22:17+0530
;; a little buggy wrt clicks
(defun cp/dired-launch-or-open (event)
(interactive "e")
;; if point is on a folder, open it with dired
;; otherwise, call launch-files-dired
(if (directory-name-p (dired-file-name-at-point))
(dired-find-file)
(launch-files-dired nil (dired-get-marked-files))))
(defun contrapunctus-delete-file-at-point (&optional prefix)
(interactive "P")
(let ((file (buffer-substring (point-at-bol)
(point-at-eol))))
(if (file-exists-p file)
(progn
(delete-file file)
(if prefix
;; delete current line
(delete-region (point-at-bol)
(1+ (point-at-eol)))
;; delete current paragraph
(mark-paragraph)
(delete-active-region)
(forward-line 2))
(message "Deleted %s" file))
(error "File %s does not exist!" file))))
(defun contrapunctus-file-at-point-exists-p ()
(interactive)
(let ((file (buffer-substring (point-at-bol)
(point-at-eol))))
(if (and (not (string-empty-p file))
(file-exists-p file))
(message "%s" t)
(error "File %S does not exist!" file))))

36
contrapunctus/cp-god.el Normal file
View File

@ -0,0 +1,36 @@
;; TODO - make mode-line indicator prominent by placing it first, like in Evil
(use-package god-mode
:disabled
:bind ("<escape>" . god-mode-all)
:init (god-mode-all)
:config
;; from https://github.com/chrisdone/god-mode#change-modeline-color
(defun c/god-mode-update-cursor ()
(cond (god-local-mode
(progn
(setq cursor-type 'box)
(set-face-background 'mode-line "black")
(set-face-background 'mode-line-inactive "black")))
(t
(progn
(setq cursor-type 'bar)
(set-face-background 'mode-line "dark red")
(set-face-background 'mode-line-inactive "dark red")))))
(add-hook 'god-mode-enabled-hook #'c/god-mode-update-cursor)
(add-hook 'god-mode-disabled-hook #'c/god-mode-update-cursor)
:custom
(god-exempt-major-modes nil)
(god-exempt-predicates nil))
;; for helm
;; (define-key helm-map (kbd "<escape>") 'god-local-mode)
(use-package god-mode-isearch
:bind
((:map isearch-mode-map
("<escape>" . god-mode-isearch-activate))
(:map god-mode-isearch-map
("<escape>" . god-mode-isearch-disable))))
(provide 'cp-god)

View File

@ -82,5 +82,3 @@
;; (gethash "ऩ्" (car indian-dev-itrans-v5-hash))
;; (gethash "न्ह" (car indian-dev-itrans-v5-hash))
;; (gethash "nh" (cdr indian-dev-itrans-v5-hash))
(provide 'cp-hindi)

View File

@ -31,6 +31,13 @@
:disabled
:bind ("M-x" . smex))
(use-package ido-mini
:bind (("C-x C-l" . ido-mini)
:map boon-x-map
("l" . ido-mini))
:config
(ivy-mode))
;; This creates a bug with shell completion if you're using ivy mode.
(unless (bound-and-true-p ivy-mode)
(setq completion-styles

165
contrapunctus/cp-lily.el Normal file
View File

@ -0,0 +1,165 @@
;;;; Hacks for Lilypond work
(use-package lilypond-mode
:bind
(("C-c C-i" . LilyPond-info)
("M-]" . set-selective-display)
:map LilyPond-mode-map
("M-p" . cp-backward-def)
("M-n" . cp-forward-def)
("M-P" . cp-upper-level)
("M-N" . cp-lower-level)
("C-c C-w" . cp-ly-wrap-para))
:commands LilyPond-mode
:config
(--map (add-hook 'LilyPond-mode-hook it)
'(subword-mode
(lambda () (turn-on-font-lock))))
(defalias 'string-to-int #'string-to-number)
:load-path "../user/"
:mode (("\\.ly$" . LilyPond-mode)
("\\.ily$" . LilyPond-mode)))
(defvar cp/ly-definition-rx
'(and bol
(1+ (any "a-z" "A-Z" "\\\\"))
(1+ (any "a-z" "A-Z" "\\\\" " "))
(any "{" "=" "#")))
(defun cp-backward-def ()
(interactive)
(unless (region-active-p)
(push-mark))
(re-search-backward (rx-to-string cp/ly-definition-rx)
nil t)
(beginning-of-line)
(recenter))
(defun cp-forward-def ()
(interactive)
(let* ((regex (rx-to-string cp/ly-definition-rx))
(count (if (looking-at-p regex) 2 1)))
(unless (region-active-p)
(push-mark))
;; (forward-char)
(if (not (re-search-forward regex nil t count))
(re-search-forward "^}" nil t))
;; (re-search-forward "^[\\a-zA-Z]" nil t)
(beginning-of-line)
(recenter)))
;; (defun cp-backward-def ()
;; (interactive)
;; (re-search-backward "\(^\\\\?[a-zA-Z]\|^ *\\[a-zA-Z]\)")
;; (beginning-of-line))
;; (defun cp-forward-def ()
;; (interactive)
;; (forward-char)
;; (re-search-forward "\(^\\\\?[a-zA-Z]\|^ *\\[a-zA-Z]\)")
;; (beginning-of-line))
(defun cp-upper-level ()
(interactive)
(re-search-backward "{"))
(defun cp-lower-level ()
(interactive)
(if (equal (string (char-after)) "{")
(forward-char))
(if (not (re-search-forward "{"))
(message "At deepest level."))
(backward-char))
;; (defun cp-lilypond-enclose-<< ()
;; (interactive)
;; (if (equal (string (char-after)) "\\")
;; (progn (insert "<< ")
;; (search-forward "{")
;; (backward-char)
;; (forward-sexp))))
;; if at a \new ... block - enclose expression
;; otherwise, enclose current position and after the first bar check
;; found
;; if region is active, enclose beginning and end
;; (defun cp-lilypond-enclose-<< ()
;; (interactive)
;; (if (equal (thing-at-point 'sexp)
;; "\\new")
;; (progn ;; (insert "<< ")
;; (newline-and-indent)
;; (search-forward "{")
;; (backward-char)
;; (forward-list)
;; ;; (forward-sexp))
;; )
;; ;; (let ((point1 (point)))
;; ;; (next-line)
;; ;; (goto-char point1))
;; ))
;; (define-key LilyPond-mode-map (kbd "<<")
;; 'cp-lilypond-enclose-<<)
;; If I change files, it's still main.ly that gets compiled; this is
;; good most of the time, but many times I want to compile a part-*
;; file instead. If we compile both main.ly and the respective part-*
;; file every time, it's wasteful. Having to select means giving up
;; the 'effortless-compilation' behaviour.
;; 2017-03-14T00:52:07+0530 - commented out, see cp/after-save
;; (defadvice LilyPond-save-buffer
;; (after lysb activate)
;; ;; (compile "make")
;; (cd (locate-dominating-file (buffer-file-name)
;; "main.ly"))
;; (compile (car compile-history)))
;;
;; (defadvice compile
;; (before compile activate)
;; (if (equal major-mode 'LilyPond-mode)
;; (cd (locate-dominating-file (buffer-file-name)
;; "main.ly"))))
;; TODO - refactor into one COND, with one case per operation.
;; TODO - operate on region as well.
(defun cp-ly-wrap-para (arg)
"Wrap current paragraph with -
\\relative c { ... } with no args,
\\repeat { ... } with universal argument,
and only braces - { ... } - with null argument.
Numeric arg wraps that many paragraphs.
TODO - wrap region if region active"
(interactive "P")
(let ((point-a (point)))
(beginning-of-line)
(unless (looking-at "[[:blank:]]*$")
;; go to start of paragraph or block, or previous blank line
(re-search-backward (rx (or (and bol (0+ blank) eol)
(and "{" eol))))
(end-of-line))
(newline-and-indent)
(insert (pcase arg
(`(,x) "\\repeat {")
(0 "{")
;; nil
(_ "\\relative c {")))
(let ((indent-start (point)))
(forward-paragraph (pcase arg
(`(,x) 1)
(_ (if (and arg (<= arg 0))
1 arg))))
(indent-region indent-start (point))
(insert "}")
(indent-for-tab-command)
(newline)
;; FIXME
(goto-char (pcase arg
(0 point-a)
(_ (- indent-start 2)))))))
;; TODO - cp-ly-new-var, bind to M-RET.
;; Exits current variable body, if in any, and inserts "| = \relative
;; c {\n\n \n}", where | is the cursor

97
contrapunctus/cp-lisp.el Normal file
View File

@ -0,0 +1,97 @@
;; (require 'chicken)
(setq print-length nil
eval-expression-print-length nil)
;; (require 'slime)
(require 'slime-autoloads)
(global-set-key (kbd "<f5> s") 'slime)
(with-eval-after-load 'slime
(slime-setup)
(setq inferior-lisp-program
;; "/usr/bin/sbcl"
"/usr/bin/ecl"
)
(cp-set-keys
:keymap slime-mode-map
:bindings
`((,(kbd "M-n") next-line)
(,(kbd "M-p") previous-line)
(,(kbd "SPC") self-insert-command))))
(defun set-cl-repl-keys ()
(if (or (cp-buffer-name-match-p "^\*inferior-lisp\*\\(<[0-9]*>\\)?")
(eq major-mode 'lisp-mode))
(progn
(local-set-key (kbd "TAB") 'completion-at-point)
(local-set-key (kbd "M-q") 'sp-indent-defun))))
(add-hook 'slime-connected-hook 'set-cl-repl-keys)
(add-hook 'comint-mode-hook 'set-cl-repl-keys)
(add-hook 'lisp-mode-hook 'set-cl-repl-keys)
(setq scheme-program-name "csi -:c")
(setq comint-prompt-read-only t)
(add-to-list 'auto-mode-alist '("\\.scm\\'" . scheme-mode))
;; (add-to-list 'auto-mode-alist '("\\.scm\\'" . geiser-mode))
;; (require 'geiser)
(use-package geiser
:commands (run-chicken run-guile geiser-mode))
;; (with-eval-after-load 'geiser-mode
;; (setq geiser-mode-smart-tab-p t)
;; (define-key geiser-mode-map (kbd "C-.") nil)
;; ;; (cp-set-keys
;; ;; :unset t
;; ;; :keymap geiser-mode-map
;; ;; :bindings
;; ;; `((,(kbd "C-."))))
;; )
(use-package scheme-mode
:defer t
:interpreter "csi")
(defun contrapunctus-lisp-copy (arg)
"Run `whole-line-or-region-copy-region-as-kill' if region is
active, else `sp-copy-sexp'."
(interactive "P")
(if (region-active-p)
(whole-line-or-region-copy-region-as-kill arg)
(sp-copy-sexp arg)))
(use-package elisp-mode
:diminish
:bind (:map emacs-lisp-mode-map
("<tab>" . completion-at-point)))
(use-package eldoc
:diminish
:if (featurep 'elisp-mode)
:init (add-hook 'emacs-lisp-mode-hook 'eldoc-mode)
:config (setq eldoc-idle-delay 0))
(defun colorize-compilation-buffer ()
(ansi-color-apply-on-region compilation-filter-start
(point)))
(add-hook 'compilation-filter-hook 'colorize-compilation-buffer)
(update-file-autoloads "~/.emacs.d/elisp-git/clojure-mode/clojure-mode.el"
t
"~/.emacs.d/elisp-git/clojure-mode/clojure-autoloads.el")
(load "clojure-autoloads")
;; (autoload 'clojure-mode "clojure-mode" nil t)
(with-eval-after-load "clojure-mode"
(require 'cider))
(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)))
(provide 'cp-lisp)

52
contrapunctus/cp-md.el Normal file
View File

@ -0,0 +1,52 @@
;; 2018-05-16T17:22:36+0530
(add-hook 'markdown-mode-hook '(lambda () (visual-fill-column-mode t)))
(add-hook 'markdown-mode-hook '(lambda () (visual-line-mode t)))
;; (add-hook 'markdown-mode-hook '(lambda () (turn-off-smartparens-mode)))
(use-package markdown-mode
:mode "\\.md\\'"
:init (add-hook 'markdown-mode-hook '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-c C-n" . markdown-cleanup-list-numbers)
("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
(re-search-line "http")
(forward-char -4)
(kill-new (thing-at-point 'url))))))

133
contrapunctus/cp-modal.el Normal file
View File

@ -0,0 +1,133 @@
;; modal editing configurations
;; normal boon config
(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)
("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))
(:map boon-x-map
("w" . 'write-file)
("s" . 'save-buffer)
("d" . 'dired-jump)
("e" . 'eval-last-sexp)
("f" . 'find-file)
("l" . 'ido-mini)
("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))
(add-to-list 'boon-special-conditions '(bound-and-true-p edebug-mode))
;; :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))
;; experimental boon+modalka config
(use-package boon
:ensure t
:disabled
:bind
("C-d" . 'boon-take-region)
("C-a" . 'boon-beginning-of-line)
("C-e" . 'boon-end-of-line)
("M-f" . 'boon-smarter-forward)
("M-b" . 'boon-smarter-backward))
;; experimental Emacs-flavored-Boon config
(use-package boon
:ensure t
:disabled
:bind
(:map boon-command-map
("n" . next-line)
("p" . previous-line)
("f" . 'forward-char)
("b" . 'backward-char)
("a" . 'boon-beginning-of-line)
("e" . 'boon-end-of-line)
("y" . 'boon-splice)
("r" . swiper)
("x l" . ido-mini)
("/" . undo-tree-undo)
("?" . undo-tree-redo))
(:map boon-x-map
("s" . #'save-buffer)
("d" . #'dired-jump))
:config
(use-package boon-qwerty)
(boon-mode))
(use-package modalka
:ensure t
:disabled
:bind
(("<escape>" . #'modalka-mode)
:map modalka-mode-map
("J" . #'join-line)
("P" . #'backward-paragraph)
("N" . #'forward-paragraph)
("M" . mark-sexp))
;; (2019-11-03) I'm pretty much using this to emulate `god-mode',
;; which was great, but is no longer actively developed and had no
;; support for non-Latin input methods.
:config
(let ((keybind-re (rx-to-string '(group-n 1 (or (and bow (1+ (char graph)) eow)
(and (1+ (char graph))))))))
(mapc
(lambda (actual)
(let ((target (replace-regexp-in-string keybind-re "C-\\1" actual)))
(modalka-define-kbd actual target)))
;; no "t", "x", or "c", because they are prefix keys used later
'("`" "1" "2" "3" "4" "5" "6" "7" "8" "9" "0" "-" "="
"q" "w" "e" "r" "y" "u" "i" "o" "p" "[" "]" "\\"
"a" "s" "d" "f" "h" "j" "k" "l" ";" "'"
"z" "v" "b" "n" "m" "," "." "/"
"<" ">" "?"
"SPC"
;; (2019-11-03) It's a little unfortunate that these cannot be
;; elided by entering ("x" "C-x") ("t" "C-t") ("c" "C-c") just
;; once :\ (I did try)
"x =" "x -" "x e" "x s" "x d"
"x f" "x l" "x x" "x c" "x v" "x b"
"t w" "t e" "t l"
"c n" "c ," "c ." "c p"
"c c n" "c h u" "c h m")))
(modalka-define-kbd "O" "C-S-o")
(setq-default cursor-type '(bar . 1))
(setq modalka-cursor-type 'box)
:hook
((text-mode . modalka-mode)
(prog-mode . modalka-mode)))
(provide 'cp-modal)

168
contrapunctus/cp-nav.el Normal file
View File

@ -0,0 +1,168 @@
(require 'cp)
;;;; Navigation improvements
(add-to-list 'load-path "~/.emacs.d/elisp-git/window-numbering/")
;; Vim-style prompt-less tag jumping
;; http://stackoverflow.com/questions/12074897/automatically-jump-to-tag-in-emacs
(global-unset-key (kbd "M-t"))
(defun find-tag-no-prompt-other-window ()
"Jump to the tag at point in the other window without prompting."
(interactive)
(find-tag-other-window (find-tag-default)))
(defun find-tag-no-prompt ()
"Jump to the tag at point without prompting."
(interactive)
(find-tag (find-tag-default)))
(cp-set-keys
:bindings
`((,(kbd "M-t M-t") find-tag-no-prompt-other-window)
(,(kbd "M-t M-g") find-tag-no-prompt)
(,(kbd "M-t M-p") pop-tag-mark)
(,(kbd "M-t M-f") find-tag)
(,(kbd "M-t M-s") tags-search)
(,(kbd "M-t M-c") tags-loop-continue)))
;; (require 'view)
;; (cp-set-keys
;; :bindings
;; `((,(kbd "C-v") View-scroll-half-page-forward)
;; (,(kbd "M-v") View-scroll-half-page-backward)))
;; ;; (cp-set-keys
;; ;; :bindings
;; ;; `((,(kbd "C-v") scroll-up)
;; ;; (,(kbd "M-v") scroll-down)))
;;;; Need to make maps for
;;;; mark-* commands (-sexp, -page, -word, etc)
;;;; mark ring
;;;; Other custom keys
(cp-set-keys
:bindings
`((,(kbd "C-x C-1") delete-other-windows)
(,(kbd "C-x C-2") split-window-below)
(,(kbd "C-x C-3") split-window-right)
(,(kbd "C-x C-0") delete-window)
(,(kbd "C-x C-4 C-f") find-file-other-window)
;; (,(kbd "C-`") point-to-register)
;; (,(kbd "C-'") jump-to-register)
(,(kbd "C-x C-d") dired-jump)
;; I usually keep Super for the window manager and global hotkeys...
(,(kbd "s-i") imenu)
;; keypad
;; set this to run whatever command is bound to C-c C-c, or maybe just C-c
;; see (info "(elisp)Translation Keymaps")
(,(kbd "<kp-divide>"))
(,(kbd "<kp-multiply>") cp/copy-buffer)
(,(kbd "<kp-subtract>") erc-track-switch-buffer)
(,(kbd "S-<kp-subtract>") cp-kill-buffer)
(,(kbd "<kp-home>") delete-other-windows)
(,(kbd "<kp-up>") split-window-below)
(,(kbd "<kp-prior>") split-window-right)
(,(kbd "<kp-begin>") ido-mini)
(,(kbd "<kp-add>") save-buffer)
(,(kbd "S-<kp-add>") (lambda () (interactive) (call-interactively (ert-run-tests-interactively t))))
(,(kbd "<kp-enter>") eval-defun)
(,(kbd "S-<kp-enter>") eval-buffer)
(,(kbd "C-S-<kp-enter>") toggle-debug-on-error)
(,(kbd "<kp-end>") select-window-1)
(,(kbd "<kp-down>") select-window-2)
(,(kbd "<kp-next>") select-window-3)
(,(kbd "<kp-insert>") chronometrist)
(,(kbd "C-<kp-insert>") chronometrist-report)
(,(kbd "<kp-delete>") abort-recursive-edit)))
(with-eval-after-load 'dired
(define-key dired-mode-map (kbd "b") 'dired-up-directory)
;; (add-hook 'dired-mode-hook 'visual-line-mode)
;(global-set-key (kbd "C-,") 'string-rectangle 'TAB)
)
(global-unset-key (kbd "C-x d"))
;; (require 'dired-toggle-sudo)
;; (define-key dired-mode-map (kbd "C-c C-s") 'dired-toggle-sudo)
;; (eval-after-load 'tramp
;; '(progn
;; ;; Allow to use: /sudo:user@host:/path/to/file
;; (add-to-list 'tramp-default-proxies-alist
;; '(".*" "\\`.+\\'" "/ssh:%h:"))))
(global-set-key (kbd "C-x df") 'delete-frame)
;;;; make-frame key is after Helm's config
;(setq compilation-read-command nil)
(defun cp-open-init ()
"Open the init.el file."
(interactive)
(find-file "~/.emacs.d/init.el"))
;; todo - store current file name → kill the buffer →
;; find-file-literally with the stored filename. also, find out if you
;; can open it without modes but with the proper encoding.
(defun cp-fcf-literally ()
"Find the current file literally. Like find-file-literally but
does not prompt for a file name."
(interactive)
(find-file-literally (buffer-file-name)))
(defun cp-kill-buffer ()
"Kill the current buffer without prompting."
(interactive)
(kill-buffer nil))
(autoload 'ibuffer "ibuffer" "ibuffer" t)
(global-set-key (kbd "C-x C-b") 'ibuffer)
(with-eval-after-load 'ibuffer
(cp-set-keys
:unset t
:keymap ibuffer-mode-map
:bindings
`((,(kbd "m"))
(,(kbd "U"))))
(cp-set-keys
:keymap ibuffer-mode-map
:bindings
`((,(kbd "m f") ibuffer-mark-by-file-name-regexp)
(,(kbd "m m") ibuffer-mark-by-mode-regexp)
(,(kbd "m n") ibuffer-mark-by-name-regexp)
(,(kbd "M") ibuffer-mark-forward)
(,(kbd "r") ibuffer-do-replace-regexp)
(,(kbd "U") ibuffer-unmark-all)))
(add-hook 'ibuffer-mode-hook 'ibuffer-set-filter-groups-by-mode))
;; (require 'win-switch)
;; (global-set-key "\C-xo" 'win-switch-dispatch)
;; (win-switch-setup-keys-ijkl)
;; (setq win-switch-idle-time 0.5)
;; (setq win-switch-other-window-first nil)
;; ;(setq win-switch-other-window-first nil)
(require 'window-numbering)
(window-numbering-mode 1)
(defun cp-maximize-window ()
"Run maximize-window if more than one window is present."
(interactive)
(if (> (length (window-list)) 1)
(maximize-window)))
(defun cp-minimize-window ()
"Run minimize-window if more than one window is present."
(interactive)
(if (> (length (window-list)) 1)
(minimize-window)))
(with-eval-after-load 'doc-view
(define-key doc-view-mode-map (kbd "=") 'doc-view-fit-height-to-window))
(with-eval-after-load 'view-mode
(define-key view-mode-map (kbd "x") nil)
(define-key view-mode-map (kbd "<backspace>") 'scroll-down-command))
(provide 'cp-nav)

210
contrapunctus/cp-org.el Normal file
View File

@ -0,0 +1,210 @@
(use-package org
:config
(general-def "<f5> o" 'org-mode)
(general-def org-mode-map
"C-," 'nil
"M-n" 'org-metadown
"M-p" 'org-metaup
"C-c C--" 'org-ctrl-c-minus
"C-c C-," 'org-metaleft
"C-c C-." 'org-metaright
;; "C-j" 'org-return
;; "C-m" 'org-return-indent
"C-c C-9" 'org-mark-ring-goto
"C-c C-/" 'org-sparse-tree
"M-w" 'cp-copy-line-or-link
"C-c C-]" 'org-set-tags
"C-M-x" 'cp/eval-sexp
"C-c C-o" 'cp/org-open
;; boon
"C-c C--" 'org-ctrl-c-minus
"C-c ]" 'org-set-tags)
(mapc (lambda (pair)
(add-to-list 'org-file-apps pair))
'(("txt" . emacs)
("org" . emacs)
;; ("pdf" . zathura)
("\\(?:gif\\|jpe?g\\|png\\)" . "sxiv -f %s")
;; (t . "xdg-open %s")
("pdf" . system)
;; ("pdf" . "zathura %s")
;; (auto-mode . emacs)
;; (system . "xdg-open %s")
(system . "zathura %s")
;; (t . system)
))
(setq org-todo-keywords '((sequence "TODO" "RESEARCH" "STARTED" "DONE"))
org-image-actual-width 400
org-cycle-include-plain-lists 'integrate
org-link-search-must-match-exact-headline nil
org-html-head
;; made to resemble Firefox's reader mode, dark setting
"<style type=text/css>
body {
margin: 40px auto;
max-width: 650px;
line-height: 1.6;
font-size: 18px;
color: #eeeeee !important;
padding: 0 10px;
background-color: #333333;
font-family: sans-serif;
}
h1,h2,h3 {
line-height: 1.2;
}
a,a:visited {
color: #07a;
}
img {
max-width: 80%;
height: auto;
width: auto\9; /* ie8 */
}
</style>"
;; ;; mix of motherfuckingwebsite.com + bettermotherfuckingwebsite.com + thebestmotherfucking.website
;; "<style type=text/css>
;; body {
;; margin: 40px auto;
;; max-width: 650px;
;; line-height: 1.6;
;; font-size: 18px;
;; color: #444;
;; padding: 0 10px;
;; background-color: #eeeeee;
;; font-family: sans-serif;
;; }
;; h1,h2,h3 {
;; line-height: 1.2;
;; }
;; a,a:visited {
;; color: #07a;
;; }
;; img {
;; max-width: 80%;
;; height: auto;
;; width: auto\9; /* ie8 */
;; }
;; </style>"
org-export-default-inline-image-rule
`(("https" .
,(format "\\.%s\\'"
(regexp-opt
'("png" "jpeg" "jpg" "gif" "tiff" "tif" "xbm"
"xpm" "pbm" "pgm" "ppm" "webp") t)))
("file" .
,(format "\\.%s\\'"
(regexp-opt
'("png" "jpeg" "jpg" "gif" "tiff" "tif" "xbm"
"xpm" "pbm" "pgm" "ppm" "webp") t))))))
;; (defun cp-org-expand-all ()
;; (interactive)
;; ;; todo - define inner recursive function
;; (beginning-of-buffer)
;; ;; todo - check if we are on a heading
;; (org-forward-heading-same-level)
;; ())
(defvar cp/org-heading-or-list-rx
'(and
;; headings
(zero-or-more "*")
(zero-or-more blank)
;; list items
(zero-or-one
(or "- " "+ " "* "
(and (one-or-more (char "0-9"))
(or ". " ") "))))
(zero-or-one (and "[" nonl "] "))))
(defun org-link-ahead-p (&optional link-type)
"Returns t if point is before an org-mode link, ignoring
whitespace and org-mode header and list syntax, else nil.
If LINK-TYPE is 'implicit, checks for an implicit link (one not
inside single or double brackets); otherwise, checks for links in
the form [[address][description]] and [[address]]."
(looking-at
(rx-to-string
(append cp/org-heading-or-list-rx
(if (eq link-type 'implicit)
'("http")
'("["))))))
(defun cp/org-open (&optional arg reference-buffer)
(interactive "P")
(save-excursion
(re-search-line
(rx-to-string
(append cp/org-heading-or-list-rx
'((or "[" "[[" "http")))))
(org-open-at-point arg reference-buffer)))
(defun cp-copy-line-or-link (prefix-arg)
"Copy address of org-mode link after point, ignoring whitespace,
link description (if any) and org-mode header and list syntax. If
not before a link, or with a prefix arg, call
`whole-line-or-region-kill-ring-save' instead.
BUG - improper behaviour with checkboxes.
2018-03-17T21:15:17+0530 - hopefully fixed now."
(interactive "P")
(let ((point-a (point)))
(cl-flet ((copy-to-closing-bracket
()
(let ((point-b (point)))
(re-search-forward "\\]")
(copy-region-as-kill point-b
(- (point) 1)))))
(if (save-excursion
(or (use-region-p)
prefix-arg
(re-search-line "\\[[-X ]\\]")))
(whole-line-or-region-kill-ring-save prefix-arg)
(cond ( ;; (org-link-ahead-p)
(re-search-line "\\[")
;; (if (looking-at "\\[")
;; (forward-char))
(forward-char)
(copy-to-closing-bracket)
(goto-char point-a))
( ;; (org-link-ahead-p 'implicit)
(re-search-line "http")
(backward-word)
(let ((point-b (point)))
(re-search-forward (rx (or eol (and printing " "))))
(copy-region-as-kill point-b
(point)))
(goto-char point-a))
;; TODO - org-previous-link will land you at the start
;; of the DESCRIPTION of the previous link, if it has
;; one, but to the user it will look like they are at
;; the start of the link. Add a case to handle this.
;; Does not work if there is an org TODO marker in a
;; header.
(t (whole-line-or-region-kill-ring-save prefix-arg)))))))
(defun cp/org-table-convert-tsv ()
(interactive)
(with-output-to-temp-buffer "cp/org-table-convert-tsv"
(->> (buffer-substring-no-properties (region-beginning) (region-end))
(replace-regexp-in-string "^| *" "")
(replace-regexp-in-string " *| *" " ")
(replace-regexp-in-string "^-.*$" "")))
(with-current-buffer "cp/org-table-convert-tsv"
(remove-hook 'before-save-hook 'delete-trailing-whitespace)
(write-file (read-from-minibuffer "Output filename: "))))
(provide 'cp-org)

264
contrapunctus/cp-parens.el Normal file
View File

@ -0,0 +1,264 @@
;; (require 'paredit)
;; (add-hook 'emacs-lisp-mode-hook 'paredit-mode)
;; (add-hook 'lisp-mode-hook 'paredit-mode)
;; (add-hook 'scheme-mode-hook 'paredit-mode)
;; (add-hook 'inferior-scheme-mode-hook 'paredit-mode)
;; (add-hook 'inferior-lisp-mode-hook 'paredit-mode)
;; (add-hook 'ielm-mode-hook 'paredit-mode)
;; (global-set-key (kbd "C-x C-p") 'paredit-mode)
;; (cp-set-keys
;; :keymap paredit-mode-map
;; :bindings
;; `((,(kbd "C-p") paredit-backward-down)
;; (,(kbd "C-n") paredit-forward-up)
;; (,(kbd "C-b") paredit-backward)
;; (,(kbd "C-f") paredit-forward)
;; (,(kbd "C-u") paredit-backward-up)
;; (,(kbd "C-d") paredit-forward-down)
;; (,(kbd "M-b") backward-char)
;; (,(kbd "M-f") forward-char)
;; (,(kbd "M-p") previous-line)
;; (,(kbd "M-n") next-line)
;; (,(kbd "M-u") paredit-kill-0)
;; (,(kbd "M-d") paredit-forward-delete)
;; (,(kbd "C-M-b") backward-word)
;; (,(kbd "C-M-f") forward-word)
;; (,(kbd "C-M-u") upcase-word)
;; (,(kbd "C-M-d") paredit-forward-kill-word)
;; (,(kbd "C-M-p") nil)
;; (,(kbd "C-M-n") nil)
;; (,(kbd "M-w") paredit-copy-as-kill)
;; (,(kbd "C-h") paredit-backward-delete)
;; (,(kbd "C-w") paredit-backward-kill-word)))
;; (cp-set-keys
;; :keymap comint-mode-map
;; :bindings
;; `((,(kbd "C-d") paredit-forward-down)
;; (,(kbd "C-M-p") comint-previous-input)
;; (,(kbd "C-M-n") comint-next-input)))
(defun cp/sp-after-colon-p (id action context)
(save-excursion
(forward-char -1)
(looking-at-p ":")))
(use-package smartparens
:load-path "~/.emacs.d/elisp-git/smartparens/"
:init
(smartparens-global-mode)
:config
(add-to-list 'sp-no-reindent-after-kill-modes 'markdown-mode)
:bind
(("M-<up>" . sp-splice-sexp-killing-backward)
:map smartparens-mode-map
("C-)" . sp-forward-slurp-sexp)
("C-(" . sp-backward-slurp-sexp)
("C-}" . sp-forward-barf-sexp)
("C-{" . sp-backward-barf-sexp)
("C-j" . sp-newline)
("C-|" . sp-join-sexp)
("C-k" . sp-kill-hybrid-sexp)
("C-h" . sp-backward-delete-char)
("<backspace>" . sp-backward-delete-char)
("C-w" . sp-backward-kill-word)
("<C-backspace>" . sp-backward-kill-word)
("M-DEL" . sp-backward-kill-word)
("M-d" . sp-kill-word)
("C-M-p" . sp-backward-down-sexp)
("C-M-n" . sp-backward-up-sexp)
("C-M-b" . sp-backward-sexp)
("C-M-f" . sp-forward-sexp)
("C-M-u" . sp-up-sexp)
("C-M-d" . sp-down-sexp)
("C-M-a" . sp-beginning-of-sexp)
("C-M-e" . sp-end-of-sexp)
("C-M-k" . sp-kill-sexp)
("C-M-w" . sp-copy-sexp)
:map emacs-lisp-mode-map
(";" . sp-comment))
:hook
(eval-expression-minibuffer-setup . smartparens-mode))
(require 'smartparens)
(require 'smartparens-config)
(smartparens-global-mode)
(add-hook 'paredit-mode-hook 'turn-off-smartparens-mode)
;; (sp-pair "(" ")" :trigger-wrap (kbd "M-(") :actions '(insert wrap autoskip navigate escape))
(sp-pair "(" ")" :wrap "M-(")
(sp-pair "[" "]" :wrap "M-[")
(sp-pair "\"" "\"" :wrap "M-\"")
;; (global-unset-key (kbd "M-\'"))
;; (sp-pair "\'" "\'" :wrap "M-\'") ;; buggy
(sp-pair "<" ">" :wrap "M-<")
(sp-pair "{" "}" :wrap "M-{")
;; (sp-pair "\\\\*" "\\\\*" :actions '(wrap))
;; (sp-pair "\\\\*" :wrap)
;; (sp-pair "\\\\/" :wrap)
;; commented out on 2017-06-06T19:25:13+0530 -
(add-hook 'erc-mode-hook 'smartparens-mode)
;; Disable inserting pair if preceded by : (e.g. in IRC smileys)
(defun cp-point-after-colon-p ()
(equal (string (char-before)) ":"))
;; (sp-pair "(" nil :unless '(cp-point-after-colon-p))
;;;; sp-backward-kill-word and subword-backward-kill conflict
;; (define-key emacs-lisp-mode-map (kbd "C-p") 'sp-previous-sexp)
;; (define-key emacs-lisp-mode-map (kbd "C-n") 'sp-next-sexp)
;; 2016-11-12 - trying something different, hopefully more consistent
(defun cp-setup-lisp-keys ()
;; (cp-set-keys
;; :keymap smartparens-mode-map
;; :bindings
;; `((,(kbd "C-M-b") nil)
;; (,(kbd "C-M-f") nil)
;; (,(kbd "C-M-u") nil)
;; (,(kbd "C-M-d") nil)
;; (,(kbd "C-M-p") nil)
;; (,(kbd "C-M-n") nil)))
;; (cp-set-keys
;; :keymap 'local
;; :bindings
;; `((,(kbd ";") sp-comment)
;; (,(kbd "C-p") sp-backward-down-sexp)
;; (,(kbd "C-n") sp-backward-up-sexp)
;; (,(kbd "C-b") sp-backward-sexp)
;; (,(kbd "C-f") sp-forward-sexp)
;; (,(kbd "C-u") sp-up-sexp)
;; (,(kbd "C-d") sp-down-sexp)
;; (,(kbd "C-a") sp-beginning-of-sexp)
;; (,(kbd "C-e") sp-end-of-sexp)
;; (,(kbd "C-k") sp-kill-sexp)
;; (,(kbd "M-w") sp-copy-sexp)
;; (,(kbd "C-h") sp-backward-delete-char)
;; (,(kbd "C-w") sp-backward-kill-word)
;; (,(kbd "M-q") sp-indent-defun)
;; (,(kbd "M-b") backward-char)
;; (,(kbd "M-f") forward-char)
;; (,(kbd "M-p") previous-line)
;; (,(kbd "M-n") next-line)
;; (,(kbd "M-u") cp-kill-line-0)
;; (,(kbd "M-d") sp-delete-char)
;; (,(kbd "M-a") beginning-of-line)
;; (,(kbd "M-e") end-of-line)
;; (,(kbd "C-M-b") backward-word)
;; (,(kbd "C-M-f") forward-word)
;; (,(kbd "C-M-u") upcase-word)
;; (,(kbd "C-M-d") sp-kill-word)))
;; (cp-set-keys
;; :keymap comint-mode-map
;; :bindings
;; `((,(kbd "C-d") sp-down-sexp)
;; (,(kbd "C-M-p") comint-previous-input)
;; (,(kbd "C-M-n") comint-next-input)))
(cp-set-keys
:keymap 'local
:bindings
`((,(kbd "M-q") sp-indent-defun)
(,(kbd "M-w") contrapunctus-lisp-copy)))
)
;; experiment
(defun cp/erc-sp-keys ()
(cp-set-keys
:keymap smartparens-mode-map
:unset t
:bindings
`((,(kbd "C-h"))
(,(kbd "C-w")))
;; `((,(kbd "C-h") backward-delete-char)
;; (,(kbd "C-w") backward-kill-word))
))
;; ;; 2016-11-06 - commented out to try a different, hopefully more consistent setup -
(add-hook 'emacs-lisp-mode-hook 'cp-setup-lisp-keys)
(add-hook 'lisp-mode-hook 'cp-setup-lisp-keys)
(add-hook 'scheme-mode-hook 'cp-setup-lisp-keys)
(add-hook 'inferior-scheme-mode-hook 'cp-setup-lisp-keys)
(add-hook 'ielm-mode-hook 'cp-setup-lisp-keys)
(add-hook 'eval-expression-minibuffer-setup-hook 'smartparens-mode)
(add-hook 'erc-mode 'cp/erc-sp-keys)
;; (add-hook 'eval-expression-minibuffer-setup-hook 'cp-setup-lisp-keys)
;; ielm
;; (require 'ielm)
;; (define-key ielm-map (kbd "C-p") 'sp-backward-down-sexp)
;; (define-key ielm-map (kbd "C-n") 'sp-backward-up-sexp)
;; (define-key ielm-map (kbd "C-b") 'sp-backward-sexp)
;; (define-key ielm-map (kbd "C-f") 'sp-forward-sexp)
;; (define-key ielm-map (kbd "C-u") 'sp-up-sexp)
;; (define-key ielm-map (kbd "C-d") 'sp-down-sexp)
;; (define-key comint-mode-map (kbd "C-d") 'sp-down-sexp)
;; (define-key ielm-map (kbd "C-a") 'sp-beginning-of-sexp)
;; (define-key ielm-map (kbd "C-e") 'sp-end-of-sexp)
;; (define-key ielm-map (kbd "C-k") 'sp-kill-sexp)
;; (define-key ielm-map (kbd "M-w") 'sp-copy-sexp)
;; (define-key ielm-map (kbd "C-h") 'sp-backward-delete-char)
;; (define-key ielm-map (kbd "C-w") 'sp-backward-kill-word)
;; (define-key ielm-map (kbd "M-b") 'backward-char)
;; (define-key ielm-map (kbd "M-f") 'forward-char)
;; (define-key ielm-map (kbd "M-p") 'previous-line)
;; (define-key ielm-map (kbd "M-n") 'next-line)
;; (define-key ielm-map (kbd "M-u") 'cp-kill-line-0)
;; (define-key ielm-map (kbd "C-k") 'sp-kill-sexp)
;; (define-key ielm-map (kbd "M-d") 'sp-delete-char)
;; (define-key ielm-map (kbd "C-M-b") 'backward-word)
;; (define-key ielm-map (kbd "C-M-f") 'forward-word)
;; (define-key ielm-map (kbd "C-M-u") 'upcase-word)
;; (define-key ielm-map (kbd "C-M-d") 'sp-kill-word)
;; (define-key ielm-map (kbd "C-M-p") nil)
;; (define-key ielm-map (kbd "C-M-n") nil)
;; (define-key comint-mode-map (kbd "C-M-p") 'comint-previous-input)
;; (define-key comint-mode-map (kbd "C-M-n") 'comint-next-input)
;; (define-key scheme-mode-map (kbd "C-p") 'sp-backward-down-sexp)
;; (define-key scheme-mode-map (kbd "C-n") 'paredit-forward-up)
;; (define-key scheme-mode-map (kbd "C-b") 'paredit-backward)
;; (define-key scheme-mode-map (kbd "C-f") 'sp-forward-sexp)
;; (define-key scheme-mode-map (kbd "C-u") 'paredit-backward-up)
;; (define-key scheme-mode-map (kbd "C-d") 'paredit-forward-down)
;; (define-key comint-mode-map (kbd "C-d") 'paredit-forward-down)
;; (define-key scheme-mode-map (kbd "M-b") 'backward-char)
;; (define-key scheme-mode-map (kbd "M-f") 'forward-char)
;; (define-key scheme-mode-map (kbd "M-p") 'previous-line)
;; (define-key scheme-mode-map (kbd "M-n") 'next-line)
;; ;; (define-key scheme-mode-map (kbd "M-u") 'paredit-kill-0)
;; (define-key scheme-mode-map (kbd "C-k") 'sp-kill-sexp)
;; (define-key scheme-mode-map (kbd "M-d") 'sp-delete-char)
;; (define-key scheme-mode-map (kbd "C-M-b") 'backward-word)
;; (define-key scheme-mode-map (kbd "C-M-f") 'forward-word)
;; (define-key scheme-mode-map (kbd "C-M-u") 'upcase-word)
;; (define-key scheme-mode-map (kbd "C-M-d") 'sp-kill-word)
;; (define-key scheme-mode-map (kbd "C-M-p") nil)
;; (define-key scheme-mode-map (kbd "C-M-n") nil)
;; (define-key comint-mode-map (kbd "C-M-p") 'comint-previous-input)
;; (define-key comint-mode-map (kbd "C-M-n") 'comint-next-input)
;; (define-key scheme-mode-map (kbd "M-w") 'paredit-copy-as-kill)
;; (define-key scheme-mode-map (kbd "C-h") 'paredit-backward-delete)
;; (define-key scheme-mode-map (kbd "C-w") 'paredit-backward-kill-word)

View File

@ -24,5 +24,3 @@
(define-key sfz-mode-map (kbd "M-p") 'sfz-prev-group)
(define-key sfz-mode-map (kbd "M-n") 'sfz-next-group)
(provide 'cp-sfz)

35
contrapunctus/cp-tex.el Normal file
View File

@ -0,0 +1,35 @@
(setq TeX-auto-save t
TeX-parse-self t
TeX-engine 'xetex
;; 2017-10-14T18:55:05+0530
TeX-view-program-selection '(((output-dvi has-no-display-manager)
"dvi2tty")
((output-dvi style-pstricks)
"dvips and gv")
(output-dvi "xdvi")
(output-pdf "Zathura")
(output-html "xdg-open")))
(add-hook 'tex-mode-hook 'TeX-source-correlate-mode)
;; 2017-10-19T09:19:34+0530 - these should be merged with
;; cp-forward-def/cp-backward-def in cp-lily...
(defun cp-backward-def ()
(interactive)
(push-mark)
(re-search-backward "\\\\scene" nil t)
(beginning-of-line)
(recenter))
(defun cp-forward-def ()
(interactive)
(push-mark)
(if (not (re-search-forward "\\\\scene" nil t 2))
(re-search-forward "\\end{document}" nil t))
(beginning-of-line)
(recenter))
(cp-set-keys
:keymap LaTeX-mode-map
:bindings
`((,(kbd "M-p") cp-backward-def)
(,(kbd "M-n") cp-forward-def)))

42
contrapunctus/cp-ui.el Normal file
View File

@ -0,0 +1,42 @@
;; Highlight current line
(global-hl-line-mode 1)
(defalias 'yes-or-no-p 'y-or-n-p)
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
;;;; Set theme
;(load-theme 'distinguished t)
;(require 'github-theme)
;(require 'heroku-theme)
;;;; Good theme but uses different font sizes in org-mode, and (I think) some weird non-monospace font
;; (require 'monokai-theme)
(require 'molokai-theme)
(enable-theme 'molokai)
;; (require 'fullscreen-mode)
;; (fullscreen-mode 1)
;; (require 'relative-line-numbers)
;; ;; old
;; ;; (setq relative-line-numbers-motion-function 'vertical-motion)
;; ;; new
;; (setq relative-line-numbers-motion-function 'forward-visible-line)
;; (global-relative-line-numbers-mode 1)
;; (add-hook 'shell-mode-hook 'previous-buffer)
;; ;; is this what deletes windows when you run a shell command?
;; (add-hook 'shell-mode-hook 'delete-other-windows)
;; 2018-08-26T22:39:09+0530
(defun cp/change-split ()
"Switch between two windows in horizontal layout and vice-versa."
(interactive)
(let (()))
;; if height of window > width, we're in a vertical split
;; otherwise we're in a horizontal split
)

144
contrapunctus/cp.el Normal file
View File

@ -0,0 +1,144 @@
(defun cp-global-set-many-keys (bindings)
"A clean way to define many keys using `global-set-key'.
BINDINGS must be in the form `((,(kbd \"...\") FN) ...)"
(mapc (lambda (b)
(global-set-key (car b) (cadr b)))
bindings))
(defun cp-define-many-keys (keymap bindings)
"A clean way to define many keys using `define-key'.
KEYMAP must be a valid keymap.
BINDINGS must be in the form `((,(kbd \"...\") FN) ...)"
(mapc (lambda (b)
(define-key keymap (car b) (cadr b)))
bindings))
(defun cp-local-set-many-keys (bindings)
"A clean way to define many keys using `local-set-key'.
BINDINGS must be in the form `((,(kbd \"...\") FN) ...)"
(mapc (lambda (b)
(local-set-key (car b) (cadr b)))
bindings))
(require 'cl-lib)
(cl-defun cp-set-keys (&key keymap unset bindings)
"A clean way to set/unset many keybindings.
BINDINGS specifies the functions and the keys they are to be
bound to. It must be an alist in the form -
`((,(kbd \"...\") FN)
...)
If KEYMAP is a symbol `global' or not supplied, the binding is
created by `global-set-key'.
If it is a symbol `local', the binding is created by
`local-set-key'.
Otherwise, it is assumed to be a keymap and the binding is
created with `define-key'.
If UNSET is non-nil, unset keybinds as specified by KEYMAP
instead of setting them. If a keymap is specified, the key is unset
by using define-key to set it to nil in the given keymap -
otherwise, global-unset-key or local-unset-key are used as
applicable."
(let ((key-function (if (not unset)
(pcase keymap
((or `global `nil) #'global-set-key)
(`local #'local-set-key)
(x #'define-key))
(pcase keymap
((or `global `nil) #'global-unset-key)
(`local #'local-unset-key)
(x #'define-key)))))
(if (eq key-function 'define-key)
(if unset
(mapc (lambda (b)
(funcall key-function keymap (car b) nil))
bindings)
(mapc (lambda (b)
(funcall key-function keymap (car b) (cadr b)))
bindings))
(if unset
(mapc (lambda (b)
(funcall key-function (car b)))
bindings)
(mapc (lambda (b)
(funcall key-function (car b) (cadr b)))
bindings)))))
;; ;; tests
;; (progn (cp-set-keys :keymap 'global ; not actually needed, e.g. see next call
;; :bindings `((,(kbd "<f6>") erc) (,(kbd "<f7>") eww)))
;; (and (equal 'erc (lookup-key (current-global-map) (kbd "<f6>")))
;; (equal 'eww (lookup-key (current-global-map) (kbd "<f7>")))))
;; (progn (cp-set-keys :unset t
;; :bindings `((,(kbd "<f6>") erc) (,(kbd "<f7>") eww)))
;; (and (equal nil (lookup-key (current-global-map) (kbd "<f6>")))
;; (equal nil (lookup-key (current-global-map) (kbd "<f7>")))))
;; (progn (cp-set-keys :keymap emacs-lisp-mode-map
;; :bindings `((,(kbd "<f6>") erc) (,(kbd "<f7>") eww)))
;; (and (equal 'erc (lookup-key emacs-lisp-mode-map (kbd "<f6>")))
;; (equal 'eww (lookup-key emacs-lisp-mode-map (kbd "<f7>")))))
;; (progn (cp-set-keys :keymap emacs-lisp-mode-map
;; :unset t
;; :bindings `((,(kbd "<f6>") erc) (,(kbd "<f7>") eww)))
;; (and (equal nil (lookup-key emacs-lisp-mode-map (kbd "<f6>")))
;; (equal nil (lookup-key emacs-lisp-mode-map (kbd "<f7>")))))
;; (progn (cp-set-keys :keymap 'local
;; :bindings `((,(kbd "<f6>") erc) (,(kbd "<f7>") eww)))
;; (and (equal 'erc (lookup-key emacs-lisp-mode-map (kbd "<f6>")))
;; (equal 'eww (lookup-key emacs-lisp-mode-map (kbd "<f7>")))))
;; (progn (cp-set-keys :keymap 'local
;; :unset t
;; :bindings `((,(kbd "<f6>") erc) (,(kbd "<f7>") eww)))
;; (and (equal nil (lookup-key emacs-lisp-mode-map (kbd "<f6>")))
;; (equal nil (lookup-key emacs-lisp-mode-map (kbd "<f7>")))))
(defun cp-get-buffer-regexp (regexp &optional all)
"Returns the name of the first buffer in the buffer list which matches REGEXP.
If ALL is non-nil, multiple matches will be returned as a list."
(let ((results (cl-remove-if-not (lambda (a)
(string-match regexp a))
(mapcar #'buffer-name (buffer-list)))))
(if all results (car results))))
(cl-defun cp-buffer-name-match-p (regexp &optional (string (buffer-name)))
"Checks if STRING matches REGEXP.
If STRING is not provided, uses the current buffer name."
(if (string-match regexp string) t nil))
(defun cp/random-elt (list)
"Retun a random element from LIST."
(nth (random (length list)) list))
(defun cp/map-two (fn list)
"Apply FN to the first two elements of LIST, then the second two, and so on."
(let ((newlist '()))
(while (not (= 0 (- (length list) 1)))
(setq newlist
(append
newlist (list
(funcall fn (car list) (cadr list)))))
(pop list))
newlist))
(defun cp/average (numbers)
(/ (-reduce '+ numbers)
(length numbers)))
(defun cp/pastebinit ()
(interactive)
(-> (shell-command-on-region
(if (region-active-p) (region-beginning) (point-min))
(if (region-active-p) (region-end) (point-max))
"pastebinit")
(kill-new)))
(defun ^ (base pwr)
(while (not (zerop pwr))
(setq base (* base base)
pwr (- pwr 1)))
base)
(provide 'cp)

View File

@ -1,50 +0,0 @@
/* made to resemble Firefox's reader mode, dark setting */
<style type=text/css>
body {
margin: 40px auto;
max-width: 650px;
line-height: 1.6;
font-size: 18px;
color: #eeeeee !important;
padding: 0 10px;
background-color: #333333;
font-family: sans-serif;
}
h1,h2,h3 {
line-height: 1.2;
}
a,a:visited {
color: #07a;
}
img {
max-width: 80%;
height: auto;
width: auto\9; /* ie8 */
}
</style>
/* mix of motherfuckingwebsite.com + bettermotherfuckingwebsite.com + thebestmotherfucking.website */
/* <style type=text/css> */
/* body { */
/* margin: 40px auto; */
/* max-width: 650px; */
/* line-height: 1.6; */
/* font-size: 18px; */
/* color: #444; */
/* padding: 0 10px; */
/* background-color: #eeeeee; */
/* font-family: sans-serif; */
/* } */
/* h1,h2,h3 { */
/* line-height: 1.2; */
/* } */
/* a,a:visited { */
/* color: #07a; */
/* } */
/* img { */
/* max-width: 80%; */
/* height: auto; */
/* width: auto\9; /\* ie8 *\/ */
/* } */
/* </style> */

686
init.el Normal file
View File

@ -0,0 +1,686 @@
;; -*- lexical-binding: t; -*-
;; 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
;; Reorganize into subdirectories?
;; text - org, md, tex
;; prog - lisp, lilypond
;; non-text - doc-view, emms
;; applications - eww, chronometrist, fm, irc
;; input - modal, hindi
;;;; Code:
(org-babel-load-file
(locate-user-emacs-file "init.org"))
(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 gc-cons-threshold 100000000
delete-by-moving-to-trash t
trash-directory "~/.trash/"
history-length 1000
use-file-dialog nil))
(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
:ensure t
:bind
("<f2> p" . ag)
("<f2> P" . ag-project-regexp)
:config
(setq ag-highlight-search t))
(require 'cp-modal)
(require 'cp-god)
(require 'cp-chronometrist)
(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)
(:map emacs-lisp-mode-map
("TAB" . company-indent-or-complete-common)
("C-i" . 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)
(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
:ensure t
:bind (("M-w" . easy-kill)
("M-d" . easy-kill-delete-region)))
(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)
(require 'cp-emms)
(use-package emr
:ensure t
:bind (:map prog-mode-map
("M-S-<return>" . emr-show-refactor-menu)))
(use-package eshell
:ensure t
:config (setq eshell-history-size 999))
(use-package eww
:ensure t
:bind
(:map eww-mode-map
("b" . #'eww-back-url)
("f" . #'eww-forward-url)
("v" . nil)))
(use-package flx-ido
:disabled
:ensure t
:init (flx-ido-mode 1)
(setq ido-enable-flex-matching t
ido-use-faces nil))
(use-package flx-isearch
:disabled
:ensure t
: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
(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 'markdown-mode-hook 'visual-fill-column-mode)
(add-hook 'text-mode-hook 'visual-line-mode)
(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)))
(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" '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)
(use-package iedit
:ensure t
:bind (("C-;" . #'iedit-mode)
("C-:" . #'iedit-mode-toggle-on-function)))
(use-package ivy
:ensure t
:commands ivy-mode
:init (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
(midnight . clean-buffer-list))
(use-package nodejs-repl
:ensure t
:config (setq nodejs-repl-command "nodejs"))
(use-package nov
:mode ("\\.epub\\'" . nov-mode))
(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" "\\.NEF$")))
(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")
(require 'cp-lisp)
(require 'cp-nav)
;; (ispell-change-dictionary "en")
(setq ispell-dictionary "en")
(use-package undo-tree
:commands global-undo-tree-mode
: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 ()
(let* ((file-path (buffer-file-name))
(file-path-shell (shell-quote-argument file-path)))
(case major-mode
('org-mode (org-html-export-to-html))
('LilyPond-mode (let ((project-dir (locate-dominating-file file-path
"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 " 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)
;; (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)))
(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))
(require 'cp-ido)
;;;; 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)
(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)
(require '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

6075
init.org

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: contrapunctus (tilde.team/~contrapunctus)
# name: cl-defgeneric
# key: dg
# --
(cl-defgeneric ${1:name} (${2:args})
"${3:docstring}"
$0)

View File

@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# contributor: contrapunctus (tilde.team/~contrapunctus)
# name: cl-defmethod
# key: dm
# --
(cl-defmethod ${1:name} (${2:args})
$0)

View File

@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: contrapunctus (tilde.team/~contrapunctus)
# name: defclass
# key: dc
# --
(defclass ${1:name} (${2:superclasses})
(${3:slots})
:documentation "${0:docstring}")

View File

@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: defcustom
# key: dc
# --
(defcustom ${1:symbol} ${2:standard}
"${3:doc}"$0)

View File

@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: defhydra
# key: dh
# --
(defhydra ${1:name} (${2:args})
${3:"docstring"}
$0)

View File

@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: find-file-noselect
# key: ffns
# --
(find-file-noselect ${1:file})$0

View File

@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: get-file-buffer
# key: gfb
# --
(get-file-buffer ${1:file})$0

View File

@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: goto-char-point-min
# key: gcpm
# --
(goto-char (point-min))

View File

@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: lambda
# key: l
# --
(lambda (${1:arg}) $0)

View File

@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: point-max
# key: pm
# --
(point-max)

View File

@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: read-current-buffer
# key: rcb
# --
(read (current-buffer))

View File

@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: with-slots
# key: ws
# --
(with-slots (${1:slots}) ${2:object})$0

View File

@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Mark Karpov
# name: my-defclass
# key: dc
# --
(defclass ${1:name} (${2:parents})
($0)${3:
(:documentation "${4:doc}")})

View File

@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: contrapunctus (tilde.team/~contrapunctus)
# name: defgeneric
# key: dg
# --
(defgeneric ${1:name} (${2:args})
"${3:docstring}")
$0

View File

@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# contributor: contrapunctus (tilde.team/~contrapunctus)
# name: my-defmethod
# key: dm
# --
(defmethod ${1:name} (${2:args})
$0)

View File

@ -1,12 +0,0 @@
# -*- mode: snippet -*-
# contributor: Mark Karpov
# name: my-defpackage
# key: dp
# --
(defpackage :${1:package}${2:
(:nicknames ${3:nicks})}${4:
(:use ${5:packages})}${6:
(:shadow ${7:packages})}${8:
(:export ${9:packages})}${10:
(:documentation "${11:doc}")})
$0

View File

@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# contributor: Mark Karpov
# name: my-in-package
# key: ip
# --
(in-package :${1:package})
$0

View File

@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: in-package
# key: ip
# --
(in-package :${0:package})

View File

@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: quickload
# key: qq
# --
(ql:quickload :${1:system} $0)

View File

@ -1,68 +0,0 @@
;;; -*- mode: emacs-lisp; -*-
emacs-lisp-mode
(dc "(defcustom " (s "symbol") " " (s "standard")
n> "\"" (s "docstring") "\""
n> ":type '" (s "type") ")")
(dg "(defgroup " p " nil\n \"" p "\"" n> ":group '" p n> ":prefix \"" p "-\")")
(cdg "(cl-defgeneric " p " (" ")" n> ")")
(cdm "(cl-defmethod " p " (" ")" n> ")")
(pm "(point-min)")
(pM "(point-max)")
(up "(use-package " (p "package") ")")
lisp-mode emacs-lisp-mode inferior-emacs-lisp-mode slime-repl-mode
(la "(lambda (" p ")" n> r> ")")
;; (l "(lambda (" (s "arguments") ") " (s "forms") ")")
(dv "(defvar " (p "symbol" symbol) " " (p "value")
n> "\"" (p "doc") "\"" ")")
(dm "(defmethod " (p "name") " (" (p "arguments") ")" n> q ")")
(df "(defun " (p "name") " (" (s "arguments") ")" n> r> ")")
(l "(let (" p ")" n> r> q ")")
(ls "(let* (" p ")" n> r> q ")")
(ws "(with-slots (" (p "slots") ") " (p "object") n> ")")
slime-repl-mode lisp-mode
(dc "(defclass " (p "symbol") " (" (s "superclasses") ")" n>
"(" p ")" q ")")
(s "(%" (s slot)
" :initarg :" (s slot) n>
" :accessor " (s slot) > ")")
(d ":documentation \"" (s "docstring") "\"")
(if ":initform " q)
(dg "(defgeneric " p " (" "))")
(qq "(ql:quickload '(" (p "packages") "))")
(dp "(defpackage :" (p "name")
n> "(:use :cl)" q ")")
(up "(use-package '(" (p "package") "))")
(ip "(in-package :" (p "package") ")")
(ln "(:local-nicknames (:" (p "nickname") " :" (p "package-name") ")" q ")")
(c "#+(or)")
;; print debugging
(pd "(format *debug-io* \"" q "~%\")")
(im "(:import-from :" (s "package") " #:" (s "symbol") ")")
(di "(:default-initargs " (s "initarg") ")")
(ii "(defmethod initialize-instance :after" n>
" ((" p ") &rest initargs &key &allow-other-keys)"
n> q ")")
(qu "(ql:update-all-dists)" n> "(ql:update-client)")
(dpmp
"(define-presentation-method present "
n> "(object (type " (p "t") ") (stream " (p "t") ") view &key acceptably for-context-type)"
n> q ")")
sql-mode
(ct "CREATE TABLE " (s "table") " ("
n " " (s "column") ","
n ");")
latex-mode
(be "\\begin{" (s env) "}" > n> r> "\\end{" (s env) "}")
(e "\\begin{enumerate}\n\\item " r> n> "\\end{enumerate}")
(i "\\begin{itemize}\n\\item " r> n> "\\end{itemize}")
texinfo-mode
(i "@include ")
org-mode
(b "[ ] ")