2021-02-16 17:54:41 +00:00
#+TODO : TODO WIP WISH CLEANUP FIXME REVIEW |
2021-11-15 16:56:21 +00:00
#+OPTIONS : use-property-inheritance:t
2021-11-22 13:02:31 +00:00
#+PROPERTY : header-args :load yes :tangle init-org.el :comments link
2021-02-16 13:33:44 +00:00
2021-02-18 05:16:36 +00:00
=org-babel-tangle= takes nearly 27 seconds to tangle this file, at the time of writing. So for a brief while I used this sed script instead -
# eval: (progn (make-local-variable 'after-save-hook) (add-hook 'after-save-hook (lambda () (start-process-shell-command "sed-tangle" "sed-tangle" "sed -n -e '/#+BEGIN_SRC emacs-lisp$/,/#+END_SRC$/{//!p;}' init.org > init.el"))))
2021-08-04 08:34:12 +00:00
2021-02-18 05:16:36 +00:00
But after ironing out [[https://github.com/jingtaozf/literate-elisp/issues/7 ][some issues ]], I switched back to =literate-elisp= . It /does/ interoperate with the rest of Emacs, just be sure to not get any errors in your init!
2021-02-17 09:33:54 +00:00
2021-08-04 08:34:12 +00:00
Ever since I discovered Kmonad and used it to have Space trigger Ctrl when held, consequently making Ctrl the modifier requiring the least movement to hold, I've been using a lot more Ctrl-based bindings. Keep that in mind as you evaluate this configuration.
2021-11-18 09:28:23 +00:00
* use-package
#+BEGIN_SRC emacs-lisp
(eval-when-compile
(add-to-list 'load-path "~/.emacs.d/elisp-git/use-package/ ")
(require 'use-package))
#+END_SRC
2021-09-25 15:29:39 +00:00
* TODO dvorak [60%]
2021-02-19 07:26:09 +00:00
At first I decided to remap all Emacs, Boon, and Hydra bindings, but it turned out to not be my idea of fun. I wrote boon-dvorak, and let [most of] the others be.
2021-02-20 06:55:20 +00:00
(QWERTY) C-w, C-u, and C-h are probably best left as they are, since they are also present in other applications.
2021-02-19 07:26:09 +00:00
1. [X] M-n, M-p, -> M-r, M-c
2. [X] M-q -> M-'
2021-02-19 15:58:27 +00:00
3. [X] M--
2021-02-19 07:26:09 +00:00
4. [ ] multiple-cursors
2021-02-19 15:58:27 +00:00
5. [ ] boon-c-god is bound to "j", which emulates QWERTY "c", but the bindings after it do not. Thus, to input "C-c C-c", one must press "j c" in Dvorak. Yuck.
2021-02-20 06:19:14 +00:00
6. [ ] M-n M-n not getting bound to font-lock-fontify-block ?
7. [ ] binding C-d to keyboard-quit in the minibuffer
2021-02-19 07:26:09 +00:00
2021-02-18 22:34:51 +00:00
#+BEGIN_SRC emacs-lisp
2021-02-19 07:26:09 +00:00
(general-auto-unbind-keys)
2021-02-19 15:58:27 +00:00
;; Most if not all of these are translations of their earlier QWERTY bindings.
2021-02-18 22:34:51 +00:00
(general-def
2021-02-21 22:37:31 +00:00
"M-h" 'default-indent-new-line ;; see also org-mode
2021-05-15 14:57:39 +00:00
"M-'" 'fill-paragraph
2021-02-19 07:26:09 +00:00
"C-j" 'ctl-x-map
2021-02-20 06:19:14 +00:00
"M-n M-n" 'font-lock-fontify-block
;; basic Modifier-based editing commands
2021-02-19 15:58:27 +00:00
;; "C-d" 'backward-delete-char ;; unnecessary - QWERTY C-h is merely next to your index finger, but Dvorak C-h is directly under it
"C-," 'backward-kill-word
2021-02-20 06:19:14 +00:00
;; ;; Emacs-like
"M-e" 'kill-word
"C-e" 'delete-char
"M-x" 'backward-word ;; !!!
"M-u" 'forward-word
"M-q" 'execute-extended-command
;; "C-x" 'forward-char
;; ;; Boon-like
;; "M-h" 'forward-word
;; "M-s" 'forward-word
"C-n" 'forward-char
"C-t" 'backward-char)
2021-02-20 13:41:46 +00:00
(bind-keys
2021-02-22 08:56:57 +00:00
("C-h" . backward-delete-char) ;; see also ivy, company
:map text-mode-map
;; Boon already binds xref-find-definitions to f
;; see also latex-mode
2021-04-03 09:01:32 +00:00
("M-." . forward-sentence)
2021-02-22 08:56:57 +00:00
)
2021-02-19 15:58:27 +00:00
;; ;; The old C-n/C-p/M-n/M-p were not the most comfortable to begin with, so I take this opportunity to bind them to something consistent with Boon
2021-02-20 06:19:14 +00:00
(general-def minibuffer-local-map
"C-c" 'previous-line
"C-r" 'next-line
"M-c" 'previous-history-element
2021-04-03 09:01:32 +00:00
"M-r" 'next-history-element
"M-p" 'previous-matching-history-element)
2021-02-20 06:19:14 +00:00
(general-def read-expression-map ;; not sure if this works
"C-c" 'previous-line
"C-r" 'next-line
"M-c" 'previous-history-element
"M-r" 'next-history-element)
2021-02-19 07:26:09 +00:00
(general-auto-unbind-keys t)
2021-02-18 22:34:51 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
* ido-mini
2021-07-30 06:46:37 +00:00
This needs to be before =boon= /=exwm= , or you get a "failed to define function ido-mini" error when you press the keybinding.
2021-07-30 02:32:15 +00:00
#+BEGIN_SRC emacs-lisp
2021-07-30 06:46:37 +00:00
(use-package ido-mini
:demand
:load-path "~/.emacs.d/contrapunctus/ido-mini/ "
2021-07-31 00:27:22 +00:00
:bind ("C-x C-l" . ido-mini)
2021-07-30 02:32:15 +00:00
:config
2021-07-30 06:46:37 +00:00
(ivy-mode))
#+END_SRC
2021-11-15 16:56:21 +00:00
* exwm :disabled:
:PROPERTIES:
2021-11-22 13:02:31 +00:00
:literate-load: no
2021-11-15 16:56:21 +00:00
:header-args: :load no :tangle no
:END:
2021-11-22 13:02:31 +00:00
#+BEGIN_SRC emacs-lisp :load no
2021-07-30 06:46:37 +00:00
(setq exwm-input-global-keys
'(([?\C-1] . select-window-1)
([?\C-2] . select-window-2)
([?\C-3] . select-window-3)
([?\C-4] . select-window-4)
2021-08-08 17:42:33 +00:00
2021-08-11 18:16:51 +00:00
([?\C-7] . select-window-1)
([?\C-8] . select-window-2)
([?\C-9] . select-window-3)
([?\C-0] . select-window-4)
2021-08-04 08:37:36 +00:00
([?\C-\\] . toggle-input-method)
2021-08-08 17:42:33 +00:00
([?\C-`] . shell)
2021-07-30 18:50:39 +00:00
2021-08-04 08:58:27 +00:00
([?\s-q] . exwm-input-toggle-keyboard)
2021-08-28 08:51:06 +00:00
([?\s-j] . split-window-below)
([?\s-k] . split-window-right)
2021-08-04 09:08:05 +00:00
([?\s-x] . delete-other-windows)
2021-08-04 08:58:27 +00:00
2021-08-08 17:44:20 +00:00
([?\s-b] . delete-other-windows)
2021-08-01 18:17:30 +00:00
([?\s-m] . contrapunctus-general-hydra/body)
([?\s-w] . ido-mini)
2021-08-08 17:44:20 +00:00
([?\s-v] . exwm-input-toggle-keyboard)))
2021-08-04 08:58:27 +00:00
#+END_SRC
Use window title for buffer names.
2021-11-22 13:02:31 +00:00
#+BEGIN_SRC emacs-lisp :load no
2021-09-01 12:14:07 +00:00
(require 'exwm)
2021-07-30 08:18:10 +00:00
(add-hook 'exwm-update-title-hook
2021-07-30 06:46:37 +00:00
(lambda ()
2021-07-30 08:18:10 +00:00
(exwm-workspace-rename-buffer exwm-title)))
2021-07-30 06:46:37 +00:00
(exwm-enable)
2021-07-30 23:37:29 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
** Helpers
2021-07-30 23:37:29 +00:00
A less repetitive way to start processes. Also enables Boon in the process buffer, so I can easy navigate it, copy text in it, or switch away from it.
2021-11-22 13:02:31 +00:00
#+BEGIN_SRC emacs-lisp :load no
2021-07-30 09:13:20 +00:00
(defun my-start-process (program &optional name &rest args)
2021-07-30 23:37:29 +00:00
"Run PROGRAM with ARGS in buffer NAME."
2021-07-30 09:13:20 +00:00
(interactive "P")
(let* ((name (if name name program))
(proc-buffer (generate-new-buffer-name name)))
(apply #'start-process name proc-buffer program args)
(with-current-buffer proc-buffer (boon-mode))))
2021-07-30 23:37:29 +00:00
#+END_SRC
2021-07-30 09:13:20 +00:00
2021-09-01 12:24:07 +00:00
This is useful even without EXWM - switching does not work (...yet?), but I can launch apps via Hydra, and the output goes into the familiar environment of an Emacs buffer.
2021-11-22 13:02:31 +00:00
#+BEGIN_SRC emacs-lisp :load no
2021-07-31 14:35:22 +00:00
(defun my-start-app-or-switch (program &optional class-re title-re name &rest args)
"Switch to EXWM buffer matching CLASS-RE or TITLE-RE, or run PROGRAM with ARGS.
NAME is the name of the process and its buffer."
2021-07-30 23:37:29 +00:00
(let* ((name (if name name program))
2021-07-31 14:35:22 +00:00
(regex (or class-re title-re program))
2021-09-01 12:14:07 +00:00
(buffer (when (featurep 'exwm)
(seq-find
(lambda (buffer)
(with-current-buffer buffer
(if title-re
(and exwm-title
(string-match-p title-re exwm-title))
(and exwm-class-name
(string-match-p regex exwm-class-name)))))
(buffer-list)))))
2021-07-30 23:37:29 +00:00
(if buffer (switch-to-buffer buffer)
(apply #'my-start-process program name args))))
#+END_SRC
2021-09-25 15:29:39 +00:00
** Startup programs
2021-11-22 13:02:31 +00:00
#+BEGIN_SRC emacs-lisp :load no
2021-11-15 16:56:21 +00:00
(my-start-process (expand-file-name "~/bin/kmonad") "kmonad" (expand-file-name "~ /kmonad-tvs.kbd"))
(my-start-process (expand-file-name "~/bin/kmonad") "kmonad" (expand-file-name "~ /kmonad-legion.kbd"))
2021-07-30 09:13:20 +00:00
(my-start-process "transmission-gtk")
(my-start-process "gajim")
2021-07-31 11:57:51 +00:00
(my-start-process "/usr/lib/notification-daemon/notification-daemon")
2021-07-30 02:32:15 +00:00
#+END_SRC
2021-07-31 14:58:56 +00:00
2021-09-25 15:29:39 +00:00
** volume
2021-07-31 14:58:56 +00:00
#+BEGIN_SRC emacs-lisp
(use-package volume
:bind
(:map volume-mode-map
("c" . volume-raise)
("r" . volume-lower)
("C-c" . volume-raise-10)
("C-r" . volume-lower-10)))
#+END_SRC
2021-09-25 15:29:39 +00:00
* user interface
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
(use-package cp-ui
:demand
:load-path "~/.emacs.d/contrapunctus/ ")
2021-02-17 10:51:12 +00:00
2021-07-30 06:46:37 +00:00
(add-to-list 'load-path "~/.emacs.d/user/ ")
2021-02-16 13:33:44 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
* ediff
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
(use-package ediff
:config
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
;; boon-like bindings
(add-hook 'ediff-keymap-setup-hook
(lambda ()
2021-02-18 22:34:51 +00:00
(define-key ediff-mode-map (kbd "c") 'ediff-previous-difference)
(define-key ediff-mode-map (kbd "r") 'ediff-next-difference))))
2021-02-17 10:51:12 +00:00
2021-02-16 13:33:44 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
* atomic-chrome
2021-11-19 19:58:04 +00:00
Doesn't work in my current main browser (Tor Browser), and thus barely used of late...
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
2021-11-19 19:58:04 +00:00
(use-package atomic-chrome
:demand t
:init (atomic-chrome-start-server)
:config
(setq atomic-chrome-url-major-mode-alist
'(("wikisource" . mediawiki-mode))))
2021-02-16 13:33:44 +00:00
#+END_SRC
2021-11-19 19:58:04 +00:00
2021-09-25 15:29:39 +00:00
* emacs settings
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
(use-package emacs
:config
(setq gc-cons-threshold 100000000
delete-by-moving-to-trash t
trash-directory "~/.trash/ "
2021-08-04 08:35:10 +00:00
history-length 10000
2021-09-04 14:14:05 +00:00
use-file-dialog nil
load-prefer-newer t)
2021-02-16 13:33:44 +00:00
(setq-default undo-limit (* 80 1000)))
2021-02-17 10:51:12 +00:00
2021-02-16 13:33:44 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
* esup, the Emacs StartUp Profiler
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
(use-package esup
:config (setq esup-depth 0))
2021-02-17 10:51:12 +00:00
2021-02-16 13:33:44 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
* doc-view
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
(use-package doc-view
:config
(setq doc-view-resolution 300))
2021-02-17 10:51:12 +00:00
2021-02-16 13:33:44 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
* gnutls
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
(use-package gnutls
:config
;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=36749
(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"))
2021-02-17 10:51:12 +00:00
2021-02-16 13:33:44 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
* Searching
** ag, the Silver Searcher
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
(use-package ag
:bind
("<f2 > p" . ag)
("<f2 > P" . ag-project-regexp)
:config
(setq ag-highlight-search t))
2021-02-17 10:51:12 +00:00
2021-02-16 13:33:44 +00:00
#+END_SRC
2021-02-18 09:31:40 +00:00
2021-09-25 15:29:39 +00:00
** Swiper
2021-07-25 15:10:18 +00:00
#+BEGIN_SRC emacs-lisp
(use-package swiper
:bind
(("C-s" . swiper)
("C-r" . swiper-backward)
:map swiper-map
("C-c" . previous-line))
:config
(setq swiper-action-recenter t))
#+END_SRC
2021-02-17 13:34:55 +00:00
**
#+BEGIN_SRC emacs-lisp
(load "cp")
;; (if (not (server-running-p)) (server-start))
(server-start)
#+END_SRC
2021-09-25 15:29:39 +00:00
* modal editing
** active boon config
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
2021-02-16 14:55:24 +00:00
(use-package boon
:ensure t
:commands (boon-mode)
2021-02-18 22:34:51 +00:00
:load-path "~/.emacs.d/elisp-git/boon"
2021-02-16 14:55:24 +00:00
:bind
(:map boon-command-map
("C-l" . recenter-top-bottom)
2021-02-18 22:34:51 +00:00
("p" . swiper)
("I" . join-line)
;; ("TAB" . 'company-indent-or-complete-common) ;; this works,
;; but also breaks unfolding in org mode :\ ("<tab >" .
;; 'company-indent-or-complete-common)
("J" . 'boon-toggle-comment)
("y" . nil)
("y w" . 'transpose-words)
("y e" . 'transpose-sexps)
("y l" . 'transpose-lines)
("y p" . 'transpose-paragraphs)
("y c" . 'transpose-chars)
;; ("\\" . projectile-command-map) ;; error - define this in projectile's `use-package'
2021-02-16 14:55:24 +00:00
("(" . boon-navigate-backward)
(")" . boon-navigate-forward)
2021-02-18 22:34:51 +00:00
(". p" . swiper-thing-at-point)
2021-02-17 13:34:55 +00:00
("M" . ido-mini)
2021-02-19 07:35:10 +00:00
("H" . ido-mini)
;; these I prefer in their Dvorak positions rather than their QWERTY positions
("/" . undo-tree-undo)
("?" . undo-tree-redo)
("z" . boon-repeat-command))
2021-02-16 14:55:24 +00:00
(:map boon-x-map
2021-02-18 22:34:51 +00:00
("," . 'write-file)
("o" . 'save-buffer)
("e" . 'dired-jump)
("." . 'eval-last-sexp)
("u" . 'find-file)
("j" . 'kill-emacs)
("x" . 'ibuffer)
(")" . text-scale-adjust)
("(" . text-scale-adjust))
2021-02-16 14:55:24 +00:00
:config
2021-02-18 22:34:51 +00:00
(require 'boon-dvorak)
2021-02-16 14:55:24 +00:00
;; (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
2021-02-17 13:34:55 +00:00
edebug-mode
2021-02-16 14:55:24 +00:00
sldb-mode
macrostep-mode
view-mode
slime-popup-buffer-mode
finder-mode))
(dolist (var '((bound-and-true-p edebug-mode)
(bound-and-true-p view-mode)
(bound-and-true-p macrostep-mode)
(bound-and-true-p slime-popup-buffer-mode)))
(add-to-list 'boon-special-conditions var))
(setq hi-lock-auto-select-face t)
2021-02-18 05:16:36 +00:00
;; (define-key boon-command-map (kbd "x d f") nil)
2021-02-17 10:53:38 +00:00
(general-def boon-command-map
"M" 'ido-mini
2021-02-18 22:34:51 +00:00
"H" 'ido-mini
2021-02-18 05:16:36 +00:00
;; "x d" 'dired-jump
)
2021-02-16 14:55:24 +00:00
;; :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))
#+END_SRC
2021-09-25 15:29:39 +00:00
** experimental boon+modalka config :disabled:
2021-02-16 14:55:24 +00:00
#+BEGIN_SRC emacs-lisp :load no
(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))
#+END_SRC
2021-09-25 15:29:39 +00:00
** experimental Emacs-flavored-Boon config :disabled:
2021-02-16 14:55:24 +00:00
#+BEGIN_SRC emacs-lisp :load no
(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))
#+END_SRC
2021-09-25 15:29:39 +00:00
** modalka :disabled:
2021-02-16 14:55:24 +00:00
<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.
#+BEGIN_SRC emacs-lisp :load no
(use-package modalka
:disabled
:bind
(("<escape >" . #'modalka-mode)
:map modalka-mode-map
("J" . #'join-line)
("P" . #'backward-paragraph)
("N" . #'forward-paragraph)
("M" . mark-sexp))
: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)))
2021-02-16 13:33:44 +00:00
(require 'cp-god)
#+END_SRC
2021-02-18 09:31:40 +00:00
2021-09-25 15:29:39 +00:00
* Applications
2021-09-17 17:41:34 +00:00
#+BEGIN_SRC emacs-lisp
2021-09-18 07:43:05 +00:00
(defun my-find-file* (&rest paths)
(mapc #'find-file paths))
2021-09-17 17:41:34 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
** time tracking - chronometrist
2021-02-16 14:55:24 +00:00
choice.el is required by =chronometrist-key-values=
2021-09-25 15:29:39 +00:00
*** goal
2021-06-03 06:02:47 +00:00
#+BEGIN_SRC emacs-lisp
(use-package chronometrist-goal
:load-path "~/.emacs.d/contrapunctus/chronometrist-goal/ "
:hook (chronometrist-mode . chronometrist-goal-minor-mode)
:config
(setq chronometrist-goal-list
'((30 "Arrangement/new edition")
(15 "Aural exercises")
(15 "Transcription" "Theory")
;; was 30 before, but that was too little for composing
(60 "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))
#+END_SRC
2021-09-25 15:29:39 +00:00
*** spark
2021-06-03 06:02:47 +00:00
#+BEGIN_SRC emacs-lisp
(use-package chronometrist-spark
:hook (chronometrist-mode . chronometrist-spark-minor-mode)
2021-07-06 00:56:14 +00:00
:config (setq chronometrist-spark-length (* 7 4)))
2021-06-03 06:02:47 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
*** chronometrist
2021-02-16 14:55:24 +00:00
#+BEGIN_SRC emacs-lisp
(use-package chronometrist
;; :disabled t
:load-path "~/.emacs.d/contrapunctus/chronometrist/elisp/ "
2021-06-03 06:02:47 +00:00
:init
(chronometrist-goal-minor-mode)
(chronometrist-spark-minor-mode)
2021-02-16 14:55:24 +00:00
:hook
(chronometrist-kv-read-mode . visual-line-mode)
(chronometrist-sexp-mode . auto-revert-mode)
(chronometrist-sexp-mode . visual-line-mode)
(kill-emacs-query-functions . chronometrist-query-stop)
:bind (("<f9 >" . chronometrist)
2021-05-25 19:21:06 +00:00
("<kp-insert >" . chronometrist)
(:map chronometrist-mode-map
("c" . previous-line)
2021-05-27 12:59:03 +00:00
("r" . next-line)
("R" . chronometrist-report)
("d" . chronometrist-details))
2021-05-25 19:21:06 +00:00
(:map chronometrist-report-mode-map
("h" . chronometrist-report-previous-week)
("s" . chronometrist-report-next-week)))
2021-02-16 14:55:24 +00:00
:config
2021-11-06 13:23:49 +00:00
(setq chronometrist-active-backend :plist-group
chronometrist-before-in-functions '()
2021-02-16 14:55:24 +00:00
chronometrist-after-in-functions '(;; chronometrist-tags-add
;; chronometrist-kv-add
contrapunctus-start-project)
chronometrist-before-out-functions '(contrapunctus-before-project-stop
;; chronometrist-tags-add
;; chronometrist-tag-choice
2021-05-25 19:21:06 +00:00
chronometrist-key-values-unified-prompt
2021-02-16 14:55:24 +00:00
;; chronometrist-kv-add
;; chronometrist-skip-query-reset
)
chronometrist-after-out-functions '(contrapunctus-after-project-stop)
2021-05-25 19:21:06 +00:00
chronometrist-activity-indicator 'contrapunctus-chronometrist-activity-indicator
2021-05-28 18:28:59 +00:00
chronometrist-details-display-key-values #'contrapunctus-display-key-values-function
chronometrist-details-schema `[("#" 3 t)
("Task" 20 t)
("Tags" 20 t)
("Details" 55 t)
("Duration" 20 t :right-align t :pad-right 3)
("Time" 10 t)]))
2021-05-25 19:21:06 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
**** activity-indicator
2021-05-25 19:21:06 +00:00
#+BEGIN_SRC emacs-lisp
2021-02-16 14:55:24 +00:00
(defun contrapunctus-chronometrist-activity-indicator ()
2021-12-02 15:23:32 +00:00
(--> (chronometrist-latest-record (chronometrist-active-backend))
(plist-put it :stop (chronometrist-format-time-iso8601))
2021-08-03 00:05:20 +00:00
(list it)
(chronometrist-events-to-durations it)
(-reduce #'+ it)
(truncate it)
(chronometrist-format-duration it)))
2021-05-25 19:21:06 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
**** find-two-files
2021-05-25 19:21:06 +00:00
#+BEGIN_SRC emacs-lisp
2021-02-16 14:55:24 +00:00
(defun contrapunctus-find-two-files (file-1 file-2)
"Open FILE-1 and FILE-2 in new windows.
FILE-1 will appear above FILE-2."
(find-file-other-window file-2)
(split-window-below)
(find-file file-1))
2021-05-25 19:21:06 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
**** outline-open-heading
2021-05-25 19:21:06 +00:00
#+BEGIN_SRC emacs-lisp
2021-02-16 14:55:24 +00:00
(defun cp-outline-open-heading (n)
(goto-char (point-min))
(outline-next-visible-heading n)
(outline-show-subtree))
2021-04-03 08:56:09 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
**** start-project
2021-09-22 14:02:16 +00:00
#+BEGIN_SRC emacs-lisp
(defvar my-arrangement-frameset
[frameset
1 (24907 10263 320473 920000) nil nil nil nil
((((minibuffer . t)
(undecorated)
(override-redirect)
(font . "-PfEd-DejaVu Sans Mono-normal-normal-normal-*-14-* -*-*-m-0-iso10646-1")
(font-parameter . "DejaVu Sans Mono-10.5")
(border-width . 0)
(internal-border-width . 0)
(right-divider-width . 0)
(bottom-divider-width . 0)
(vertical-scroll-bars)
(horizontal-scroll-bars)
(foreground-color . "#d6d6d4")
(background-color . "#1c1e1f")
(mouse-color . "black")
(border-color . "black")
(screen-gamma)
(line-spacing)
(left-fringe . 4)
(right-fringe . 4)
(no-special-glyphs)
(scroll-bar-foreground)
(scroll-bar-background)
(menu-bar-lines . 1)
(tab-bar-lines . 0)
(height . 40)
(tool-bar-lines . 0)
(title)
(wait-for-wm . t)
(tool-bar-position . top)
(inhibit-double-buffering)
(icon-type . t)
(auto-raise)
(auto-lower)
(cursor-type . box)
(scroll-bar-width . 16)
(scroll-bar-height . 16)
(alpha)
(no-focus-on-map)
(no-accept-focus)
(fullscreen . maximized)
(visibility . t)
(skip-taskbar)
(z-group)
(display-type . color)
(background-mode . dark)
(cursor-color . "#fb2874")
(sticky)
(environment)
(last-focus-update . t)
(powerline-cache)
(frameset--id . "6557-E2CE-3D63-0FD0")
(frameset--mini t . t)
(width . 169)
(modeline . t)
(unsplittable)
(left . 0)
(top . 0)
(icon-name)
(display . ":0.0")
(explicit-name))
((min-height . 8)
(min-width . 20)
(min-height-ignore . 4)
(min-width-ignore . 6)
(min-height-safe . 2)
(min-width-safe . 4)
(min-pixel-height . 136)
(min-pixel-width . 160)
(min-pixel-height-ignore . 68)
(min-pixel-width-ignore . 48)
(min-pixel-height-safe . 34)
(min-pixel-width-safe . 32))
vc (pixel-width . 1366)
(pixel-height . 669)
(total-width . 171)
(total-height . 39)
(normal-height . 1.0)
(normal-width . 1.0)
(combination-limit)
(hc
(pixel-width . 1366)
(pixel-height . 507)
(total-width . 171)
(total-height . 29)
(normal-height . 0.7661169415292354)
(normal-width . 1.0)
(combination-limit)
(leaf (pixel-width . 686)
(pixel-height . 507)
(total-width . 86)
(total-height . 29)
(normal-height . 1.0)
(normal-width . 0.5)
(buffer "2021-09-12 Songs of Travel-pacON.pdf"
(selected)
(hscroll . 0)
(fringes 4 4 nil nil)
(margins nil)
(scroll-bars nil 0 t nil 0 t nil)
(vscroll . 0)
(dedicated)
(point . 1)
(start . 1)))
(leaf (last . t)
(pixel-width . 680)
(pixel-height . 507)
(total-width . 85)
(total-height . 29)
(normal-height . 1.0)
(normal-width . 0.5)
(buffer "IMSLP89688-PMLP183796-SongsOfTravel.pdf"
(selected)
(hscroll . 0)
(fringes 4 4 nil nil)
(margins nil)
(scroll-bars nil 0 t nil 0 t nil)
(vscroll . 0)
(dedicated)
(point . 1)
(start . 1))))
(leaf (last . t)
(pixel-width . 1366)
(pixel-height . 162)
(total-width . 171)
(total-height . 9)
(normal-height . 0.23388305847076465)
(normal-width . 1.0)
(buffer "guitar.ly"
(selected . t)
(hscroll . 0)
(fringes 4 4 nil nil)
(margins nil)
(scroll-bars nil 0 t nil 0 t nil)
(vscroll . 0)
(dedicated)
(point . 1)
(start . 1)))))])
#+END_SRC
2021-11-06 13:24:30 +00:00
#+BEGIN_SRC emacs-lisp
(defvar my-composition-frameset
[frameset
1 (24936 2014 421002 849000) nil nil nil nil
((((minibuffer . t)
(undecorated)
(override-redirect)
(font . "-PfEd-DejaVu Sans Mono-normal-normal-normal-*-14-* -*-*-m-0-iso10646-1")
(font-parameter . "DejaVu Sans Mono-10.5")
(border-width . 0)
(internal-border-width . 0)
(right-divider-width . 0)
(bottom-divider-width . 0)
(vertical-scroll-bars)
(horizontal-scroll-bars)
(foreground-color . "#d6d6d4")
(background-color . "#1c1e1f")
(mouse-color . "black")
(border-color . "black")
(screen-gamma)
(line-spacing)
(left-fringe . 4)
(right-fringe . 4)
(no-special-glyphs)
(scroll-bar-foreground)
(scroll-bar-background)
(menu-bar-lines . 1)
(tab-bar-lines . 0)
(height . 40)
(tool-bar-lines . 0)
(title)
(wait-for-wm . t)
(tool-bar-position . top)
(inhibit-double-buffering)
(icon-type . t)
(auto-raise)
(auto-lower)
(cursor-type . box)
(scroll-bar-width . 16)
(scroll-bar-height . 16)
(alpha)
(no-focus-on-map)
(no-accept-focus)
(fullscreen . maximized)
(visibility . t)
(skip-taskbar)
(z-group)
(display-type . color)
(background-mode . dark)
(cursor-color . "#fb2874")
(sticky)
(environment)
(last-focus-update . t)
(powerline-cache)
(frameset--id . "3226-BFF7-1499-D0C7")
(frameset--mini t . t)
(modeline . t)
(unsplittable)
(icon-name)
(display . ":0.0")
(explicit-name)
(width . 169)
(left . 0)
(top . 0))
((min-height . 8)
(min-width . 20)
(min-height-ignore . 4)
(min-width-ignore . 6)
(min-height-safe . 2)
(min-width-safe . 4)
(min-pixel-height . 136)
(min-pixel-width . 160)
(min-pixel-height-ignore . 68)
(min-pixel-width-ignore . 48)
(min-pixel-height-safe . 34)
(min-pixel-width-safe . 32))
vc
(pixel-width . 1366)
(pixel-height . 669)
(total-width . 171)
(total-height . 39)
(normal-height . 1.0)
(normal-width . 1.0)
(combination-limit)
(leaf
(pixel-width . 1366)
(pixel-height . 326)
(total-width . 171)
(total-height . 19)
(normal-height . 0.5)
(normal-width . 1.0)
(buffer
"1 Koi Hamen Bataaega Kya-pacON.pdf"
(selected)
(hscroll . 0)
(fringes 4 4 nil nil)
(margins nil)
(scroll-bars nil 0 t nil 0 t nil)
(vscroll . 70)
(dedicated)
(point . 1)
(start . 1))
(prev-buffers
("init.org[emacs-lisp]" 21939 22524)
("music" 1 326)
("1 Koi Hamen Bataaega Kya-pacON.pdf" 1 1)))
(hc (last . t)
(pixel-width . 1366)
(pixel-height . 343)
(total-width . 171)
(total-height . 20)
(normal-height . 0.5)
(normal-width . 1.0)
(combination-limit)
(leaf
(pixel-width . 686)
(pixel-height . 343)
(total-width . 86)
(total-height . 20)
(normal-height . 1.0)
(normal-width . 0.5)
(buffer "music"
(selected . t)
(hscroll . 0)
(fringes 4 4 nil nil)
(margins nil)
(scroll-bars nil 0 t nil 0 t nil)
(vscroll . 0)
(dedicated)
(point . 326)
(start . 1))
(prev-buffers
("1 Koi Hamen Bataaega Kya" 1 205)
("output" 1 386)
("1 Koi Hamen Bataaega Kya-pacON.pdf" 1 1)))
(leaf
(last . t)
(pixel-width . 680)
(pixel-height . 343)
(total-width . 85)
(total-height . 20)
(normal-height . 1.0)
(normal-width . 0.5)
(buffer "music"
(selected)
(hscroll . 0)
(fringes 4 4 nil nil)
(margins nil)
(scroll-bars nil 0 t nil 0 t nil)
(vscroll . 0)
(dedicated)
(point . 326)
(start . 1))
(prev-buffers
("1 Koi Hamen Bataaega Kya" 1 205)
("output" 1 386))))))])
#+END_SRC
2021-04-03 08:56:09 +00:00
#+BEGIN_SRC emacs-lisp
2021-02-16 14:55:24 +00:00
(defun contrapunctus-start-project (project)
(delete-other-windows)
(pcase project
2021-03-21 07:00:43 +00:00
("Acting"
2021-09-17 17:41:34 +00:00
(find-file
2021-09-18 07:43:05 +00:00
"/media/data/anon/Documents/sync/Wilde, Oscar/The Importance of Being Earnest/gutenberg-script.txt"))
2021-02-16 14:55:24 +00:00
("Arrangement/new edition"
2021-09-18 07:43:05 +00:00
(my-find-file*
2021-09-22 14:02:16 +00:00
"/media/data/anon/1-music-scores/4-my-arrangements/2021/2021-09-12 Songs of Travel/1 The Vagabond/music/guitar.ly"
"/media/data/anon/1-music-scores/4-my-arrangements/2021/2021-09-12 Songs of Travel/output/2021-09-12 Songs of Travel-pacON.pdf"
2021-11-18 09:29:49 +00:00
"~/Sync/Scores/voice/Vaughan Williams/IMSLP89688-PMLP183796-SongsOfTravel.pdf")
2021-09-22 14:02:16 +00:00
(frameset-restore my-arrangement-frameset :reuse-frames t))
2021-02-16 14:55:24 +00:00
("Aural exercises"
2021-09-18 07:43:05 +00:00
(find-file-other-window "/media/data/anon/Documents/Text Files/music_stuff/harmonic-analysis.org"))
2021-11-06 13:24:30 +00:00
((or "Sequencing" "Composing")
2021-11-18 09:29:49 +00:00
(find-file-other-window "~/1-music-scores/2-my-compositions/composition-portfolio.org")
2021-11-06 13:24:30 +00:00
(frameset-restore my-composition-frameset :reuse-frames t))
2021-02-16 14:55:24 +00:00
("Data organization"
2021-04-03 08:56:09 +00:00
(find-dired "/media/data/anon/ " "-name \\'dl\\' -size +0c"))
2021-02-16 14:55:24 +00:00
("Digitization"
2021-09-18 07:43:05 +00:00
(my-find-file*
"/media/data/anon/Documents/Text Files/latex/Don't, Mr. Disraeli!/dont-mr-disraeli.tex"
"/media/data/anon/Documents/Text Files/latex/Don't, Mr. Disraeli!/dont-mr-disraeli.pdf"))
2021-05-25 19:21:06 +00:00
("Exercise" (chronometrist-key-values-unified-prompt "Exercise")
2021-09-15 14:12:15 +00:00
(chronometrist-edit-file (chronometrist-active-backend)))
2021-02-16 14:55:24 +00:00
("Guitar"
2021-11-08 12:29:11 +00:00
(let* ((path-1 "~/Sync/Scores/guitar-solo/repertoire.org")
(path-2 "~/Sync/Scores/guitar-duo/repertoire.org")
2021-02-16 14:55:24 +00:00
(weekday (elt (decode-time) 6))
(week (string-to-number (format-time-string "%U"))))
(contrapunctus-find-two-files path-1 path-2)
(select-window (get-buffer-window (get-file-buffer path-1)))
(org-match-sparse-tree nil "perform")))
("Keyboard"
2021-09-18 07:43:05 +00:00
(find-file-other-window "/media/data/anon/Documents/Text Files/music_stuff/piano.org")
2021-02-16 14:55:24 +00:00
(outline-show-subtree))
("Khilona archiving"
2021-04-03 08:56:09 +00:00
(find-file-other-window "/media/data/anon/Documents/sync/Khilona/ ")
2021-02-16 14:55:24 +00:00
(split-window-below)
(other-window 1)
(find-file "~/Khilona/Videos/Me?/ ")
(other-window 1)
2021-04-03 08:56:09 +00:00
(find-file "/media/data/anon/Documents/Text Files/khilona/2011 Me?/script/script.tex"))
2021-02-16 14:55:24 +00:00
("OSM"
;; (async-shell-command "java -jar ~/josm-tested.jar" " *JOSM* " " *JOSM errors* ")
;; (delete-window (get-buffer-window " *JOSM* "))
2021-05-25 19:21:06 +00:00
(contrapunctus-find-two-files "/media/data/phone/anon/Nokia 6.1/Android/data/net.osmand.plus/files/ "
;; "/media/data/phone/anon/Nokia 6.1/external/DCIM/OpenCamera/osm/ "
"/media/data/phone/anon/Nokia 6.1/Documents/Markor/OSM/TODO.md"))
2021-02-16 14:55:24 +00:00
("Programming"
2021-09-17 17:41:34 +00:00
;; (eww-open-file "/media/data/anon/git/cl/McCLIM/Documentation/Manual/mcclim.html")
2021-03-21 07:00:43 +00:00
(find-file-other-window
2021-05-25 19:21:06 +00:00
"/media/data/phone/anon/Nokia 6.1/Documents/Markor/Computers/todo.md"))
2021-06-03 06:02:47 +00:00
("Reading"
2021-09-18 07:43:05 +00:00
(find-file-other-window "/media/data/anon/Documents/sync/ "))
2021-05-25 19:21:06 +00:00
("Recording"
2021-09-17 17:41:34 +00:00
(find-file-other-window
2021-09-18 07:43:05 +00:00
"/media/data/anon/8-music-production/1-my-creations/BWV 1006a/1 Prelude/ "))
2021-02-16 14:55:24 +00:00
("Singing"
2021-09-17 17:41:34 +00:00
(find-file-other-window
2021-11-18 09:29:49 +00:00
"~/Sync/Scores/voice/repertoire.org"))
2021-02-16 14:55:24 +00:00
("Subtitles"
2021-04-03 08:56:09 +00:00
;; (find-file-other-window "/media/data/anon/Music/0-classical/vocal/musical/Company/ ")
2021-05-25 19:21:06 +00:00
(start-process "subtitleeditor" nil "subtitleeditor" "/media/data/khilona/Videos/Peer Gynt/peer-gynt.srt"))
2021-02-16 14:55:24 +00:00
("Teaching"
2021-09-18 07:43:05 +00:00
(find-file-other-window "/media/data/anon/Documents/Text Files/students/ ")
2021-04-03 08:56:09 +00:00
;; (launch-file "/media/data/anon/Sync/Scores/voice/jingle-bell-rock.pdf")
2021-02-16 14:55:24 +00:00
)
("Theatre rehearsal"
(contrapunctus-find-two-files
2021-09-18 07:43:05 +00:00
"/media/data/anon/Documents/Text Files/khilona/voices.org"
"/media/data/anon/1-music-scores/2-my-compositions/2019/2019-03 Kahe Natak Karte Ho Ji/Kahe Natak Karte Ho Ji.org"))
2021-02-16 14:55:24 +00:00
("Transcription"
;; (find-file-other-window
2021-05-25 19:21:06 +00:00
;; "/media/data/phone/anon/Nokia 6.1/Documents/Markor/Music/transcriptions.md")
2021-09-17 17:41:34 +00:00
;; (emms-play-file "/media/data/anon/Music/Hallelujah Rufus Wainwright-xR0DKOGco_o.opus")
2021-09-18 07:43:05 +00:00
(my-find-file*
"/media/data/anon/1-music-scores/4-my-arrangements/2021/2021-03-11 Hallelujah/output/2021-03-11 Hallelujah-pacON.pdf"
"/media/data/anon/1-music-scores/4-my-arrangements/2021/ "))
2021-02-16 14:55:24 +00:00
("Video editing"
2021-05-27 12:57:02 +00:00
(start-process "kdenlive" (generate-new-buffer-name "kdenlive")
;; "flatpak" "run" "org.kde.kdenlive"
"kdenlive"
;; "/home/khilona/Videos/ghar ghar theatre 3/ggt3.kdenlive"
"/media/data/khilona/Videos/podcast/episode 3/episode 3.kdenlive")
2021-05-25 19:21:06 +00:00
(find-file-other-window ;; "/home/khilona/Videos/ghar ghar theatre 3/ "
"/media/data/khilona/Videos/podcast/ "))
2021-02-16 14:55:24 +00:00
("Wiktionary"
(find-file-other-window
2021-09-18 07:43:05 +00:00
"/media/data/phone/anon/Nokia 6.1/Documents/Markor/Languages/hindi.md"))
2021-02-16 14:55:24 +00:00
("Writing"
(find-file-other-window
2021-05-25 19:21:06 +00:00
"/media/data/phone/anon/Nokia 6.1/Documents/Markor/Songs or Poems/ "))))
#+END_SRC
2021-09-25 15:29:39 +00:00
**** commit-prompt
2021-05-25 19:21:06 +00:00
#+BEGIN_SRC emacs-lisp
2021-02-16 14:55:24 +00:00
(autoload 'magit-anything-modified-p "magit")
(defun contrapunctus-commit-prompt ()
"Prompt user if `default-directory' is a dirty Git repository.
Return t if the user answers yes, if the repository is clean, or
if there is no Git repository.
Return nil (and run `magit-status') if the user answers no."
(cond ((not (magit-anything-modified-p)) t)
((yes-or-no-p
(format "You have uncommitted changes in %S. Really clock out? "
default-directory)) t)
(t (magit-status) nil)))
2021-05-25 19:21:06 +00:00
#+END_SRC
2021-02-16 14:55:24 +00:00
2021-09-25 15:29:39 +00:00
**** before-project-stop
2021-05-25 19:21:06 +00:00
#+BEGIN_SRC emacs-lisp
2021-02-16 14:55:24 +00:00
(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))
2021-05-25 19:21:06 +00:00
#+END_SRC
2021-02-16 14:55:24 +00:00
2021-09-25 15:29:39 +00:00
**** after-project-stop
2021-11-06 10:04:39 +00:00
FIXME -
1. instead of changing the last plist, change the last plist with name "OSM" and without tags or key-values (because a new plist may have been inserted in the meantime)
2021-05-25 19:21:06 +00:00
#+BEGIN_SRC emacs-lisp
2021-08-03 00:04:55 +00:00
(use-package request)
(use-package esxml-query)
2021-08-02 18:49:14 +00:00
(defun my-get-changeset-comment (changeset)
(->> (esxml-query "[k=comment]" changeset)
(esxml-node-attributes)
(alist-get 'v)))
(defun my-make-osm-url (id)
(concat "https://www.openstreetmap.org/changeset/ " id))
2021-09-15 14:12:15 +00:00
(defun my-get-saved-changeset-id (backend)
2021-08-03 00:04:05 +00:00
(-let* (((&plist :changesets saved-changesets)
2021-11-06 10:04:39 +00:00
(cl-loop for plist in
2021-08-03 14:54:37 +00:00
;; the very latest OSM plist is the one we just created -
;; we want the one before that
2021-11-06 10:04:39 +00:00
(rest (chronometrist-to-list backend))
2021-08-30 18:01:33 +00:00
when (and (equal "OSM" (plist-get plist :name))
;; ignore plists without a :changesets keyword
(plist-get plist :changesets))
2021-08-03 00:04:05 +00:00
return plist))
(((&plist :osm-url last-url)) (last saved-changesets)))
(when last-url
2021-08-03 14:54:37 +00:00
(first (last (split-string last-url "/"))))))
(cl-defun my-save-osm-details (&key data &allow-other-keys)
2021-09-15 14:12:15 +00:00
(-let* ((backend (chronometrist-active-backend))
(last-id (my-get-saved-changeset-id backend))
2021-08-03 14:54:37 +00:00
(response-changesets (esxml-node-children data))
(new-changesets
(if last-id
(cl-loop with id
for changeset in response-changesets do
2021-09-15 14:12:15 +00:00
(setq id (alist-get 'id
(esxml-node-attributes changeset)))
2021-08-03 14:54:37 +00:00
if (equal id last-id)
return (reverse changesets)
else collect
(list
:osm-url
(my-make-osm-url id)
:osm-comment
(my-get-changeset-comment changeset)) into changesets)
;; no changeset information in file - just use
;; the latest changeset from the response
(let* ((changeset (first response-changesets))
2021-09-15 14:12:15 +00:00
(id (alist-get 'id (esxml-node-attributes changeset)))
2021-08-03 14:54:37 +00:00
(comment (my-get-changeset-comment changeset)))
`((:osm-url ,(my-make-osm-url id)
2021-09-15 14:12:15 +00:00
:osm-comment ,comment)))))
(new-plist (chronometrist-plist-update
(chronometrist-latest-record (chronometrist-active-backend))
`(:changesets ,new-changesets))))
2021-11-06 10:04:39 +00:00
;; (message "Last changeset ID - %s" last-id)
2021-09-15 14:12:15 +00:00
(chronometrist-replace-last (chronometrist-active-backend) new-plist)))
2021-08-03 00:04:05 +00:00
(defun my-save-osm-changeset-details ()
2021-09-15 14:12:15 +00:00
"Save OSM changeset details in the Chronometrist file."
2021-08-03 00:04:05 +00:00
(request
"https://api.openstreetmap.org/api/0.6/changesets"
:params '(("display_name" . "contrapunctus"))
:parser (lambda () (libxml-parse-xml-region (point) (point-max)))
2021-08-03 14:54:37 +00:00
:success #'my-save-osm-details))
2021-08-03 00:04:05 +00:00
2021-02-16 14:55:24 +00:00
(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.
2021-08-03 00:04:05 +00:00
(my-save-osm-changeset-details))
2021-02-16 14:55:24 +00:00
(_ (delete-other-windows))))
2021-05-25 19:21:06 +00:00
#+END_SRC
2021-02-16 14:55:24 +00:00
2021-09-25 15:29:39 +00:00
**** display-key-values
2021-08-02 16:19:06 +00:00
Schema I use for plists - values can be -
1. integer
2. ="string"= | =("list" "of" "strings")=
3. =(INTEGER . "string")=
4. mixed alist - elements can be either #1 or #2
5. a plist, or a list of plists
Programming - =:project= , [ =:component= ,] =:feature=
What if...
1. =(a b c)= -> ="a, b, c"=
2. =(a . b)= -> ="a b"= (e.g. =(a (b . c) d)= -> ="a, b c, d"= )
3. sublist - recurse
2021-05-25 19:21:06 +00:00
#+BEGIN_SRC emacs-lisp
2021-06-27 09:31:26 +00:00
;; (contrapunctus-objects-to-string " - " nil) => ""
;; (contrapunctus-objects-to-string " - " 1) => "1"
2021-05-27 12:56:39 +00:00
(defun contrapunctus-objects-to-string (separator &rest args)
2021-06-27 09:31:26 +00:00
"Return ARGS as a string, removing nil values."
2021-05-27 12:56:39 +00:00
(mapconcat (lambda (elt)
(format "%s" elt))
(flatten-list
(seq-filter #'identity args))
separator))
2021-07-31 16:46:40 +00:00
(defun contrapunctus-display-key-values-helper (list)
(cl-loop for elt in list
collect
(cond ((stringp elt) elt)
2021-12-02 15:23:32 +00:00
((chronometrist-pp-pair-p elt)
2021-07-31 16:46:40 +00:00
(format "%s %s" (car elt) (cdr elt)))
((listp elt)
(contrapunctus-display-key-values-function elt))
(t "")) into strings
finally return
(mapconcat #'identity (seq-filter #'identity strings) ", ")))
2021-07-31 00:04:16 +00:00
2021-05-26 04:40:02 +00:00
(defun contrapunctus-display-key-values-function (plist)
"Function used to print key-values in `chronometrist-details' buffers."
2021-07-31 00:04:16 +00:00
(let ((values (seq-remove #'keywordp (chronometrist-plist-key-values plist))))
(contrapunctus-display-key-values-helper values)))
2021-05-27 12:56:39 +00:00
2021-05-25 19:21:06 +00:00
#+END_SRC
2021-07-09 16:00:19 +00:00
2021-09-25 15:29:39 +00:00
*** key-values
2021-05-25 19:21:06 +00:00
#+BEGIN_SRC emacs-lisp
(use-package chronometrist-key-values
2021-05-28 18:28:59 +00:00
:after chronometrist
2021-05-25 19:21:06 +00:00
:load-path "~/.emacs.d/contrapunctus/chronometrist/elisp/ ")
#+END_SRC
2021-09-25 15:29:39 +00:00
*** count-expressions
*** tangling
2021-05-25 19:21:06 +00:00
Wrote these two as potential alternatives to `org-babel-tangle', which was far slower than I'd like (took around 20s for chronometrist.org when I checked during the migration process, and 43s after the migration was complete.) These, on the other hand, are almost instant, but I don't use them anywhere because I run a sed script as a file local variable.
#+BEGIN_SRC emacs-lisp
2021-02-16 14:55:24 +00:00
(defun chronometrist-tangle ()
(goto-char (point-min))
(cl-loop with source
while (not (eobp))
2021-02-17 09:23:39 +00:00
when (looking-at-p (rx (and line-start (zero-or-more blank) line-end)))
2021-02-16 14:55:24 +00:00
concat (progn
(forward-line 1)
(buffer-substring-no-properties
(point)
(cl-loop while (not (eobp))
if (looking-at-p (rx (and line-start
(zero-or-more blank)
line-end)))
do (cl-return (point))
else do (forward-line 1)))) into source
do (forward-line 1)
finally do
(with-current-buffer (find-file-noselect "chronometrist.el")
(delete-region (point-min) (point-max))
(insert source)
(save-buffer))))
(defun chronometrist-tangle-sed ()
(let* ((file-path (buffer-file-name
(current-buffer)))
(base (file-name-base file-path)))
(when (equal "chronometrist.org" (file-name-nondirectory file-path))
(start-process-shell-command
"sed-tangle"
(generate-new-buffer-name "sed-tangle")
(format "sed -n '/#+BEGIN_SRC emacs-lisp$/ ,/#+END_SRC$/ {//!p;}' ~s.org > ~s.el" base base)))))
2021-02-17 10:51:12 +00:00
2021-04-16 04:09:48 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
*** querying data
2021-04-16 04:09:48 +00:00
An example of querying the Chronometrist file data - finding out how much time I've spent on tasks matching a certain criteria.
2021-09-15 14:12:15 +00:00
2021-04-16 04:09:48 +00:00
#+BEGIN_SRC emacs-lisp :tangle no :load no
2021-09-15 14:12:15 +00:00
(chronometrist-loop-records for plist in chronometrist-file
2021-04-16 04:09:48 +00:00
with count = 0
when (and (equal (plist-get plist :name) "Composing")
(equal (plist-get plist :song) "आदि काल से आज तलक"))
sum (chronometrist-interval plist) into seconds
and do (cl-incf count)
finally return
2021-07-06 01:11:00 +00:00
(unless (zerop seconds)
(format "%s over %s days."
(ts-human-format-duration seconds)
count)))
#+END_SRC
Intervals and durations for task Exercise.
#+BEGIN_SRC emacs-lisp :tangle no :load no
2021-09-15 14:12:15 +00:00
(chronometrist-loop-records for plist in chronometrist-file
2021-07-06 01:11:00 +00:00
with count = 0
when
(equal (plist-get plist :name) "Exercise")
collect
(let* ((plist (copy-list plist))
(interval-seconds (chronometrist-interval plist))
(start (plist-get plist :start)))
(plist-put plist :duration (ts-human-format-duration interval-seconds))
(plist-put plist :date (seq-take start 10))
(chronometrist-plist-remove plist :start :stop)))
#+END_SRC
2021-04-16 04:09:48 +00:00
2021-07-06 01:11:00 +00:00
Unique key-values for task "Exercise"
#+BEGIN_SRC emacs-lisp :tangle no :load no
2021-09-15 14:12:15 +00:00
(chronometrist-loop-records for plist in chronometrist-file
2021-07-06 01:11:00 +00:00
when
(equal (plist-get plist :name) "Exercise")
collect (chronometrist-plist-key-values plist) into key-values
finally do
(let ((buffer (get-buffer-create (generate-new-buffer-name "chronometrist-query"))))
(with-current-buffer buffer
(->> (cl-remove-duplicates key-values)
(seq-filter #'identity)
(format "%S")
(insert))
(emacs-lisp-mode)
(switch-to-buffer buffer))))
2021-02-16 14:55:24 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
** WISH emms
2021-02-16 14:55:24 +00:00
1. [ ] make toggle command for emms-start/emms-stop
2. [ ] change mode line display - don't show the whole file path, just the name
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
2021-02-16 14:55:24 +00:00
(use-package emms
:after hydra
:bind
2021-02-18 21:31:06 +00:00
("<f2 > e" . #'contrapunctus-emms-hydra/body)
2021-02-16 14:55:24 +00:00
("<f2 > E" . #'emms)
(:map dired-mode-map
2021-02-18 21:31:06 +00:00
("E" . #'contrapunctus-emms-hydra/body))
2021-02-16 14:55:24 +00:00
:commands
(emms-minimalistic emms emms-play-dired emms-add-dired)
:config
(emms-minimalistic)
(emms-default-players)
(setq emms-player-mpv-parameters
(lambda ()
(append
2021-08-30 19:23:58 +00:00
'("--quiet"
2021-02-16 14:55:24 +00:00
"--really-quiet"
;; "--vid=no"
"--force-window=yes"
"-ao=jack,alsa"
;; "--loop-file=inf"
)
2021-09-22 03:57:15 +00:00
;; (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)))
)))
2021-02-16 14:55:24 +00:00
;; ;; 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)))
2021-02-18 21:31:06 +00:00
:init (defhydra contrapunctus-emms-hydra ()
2021-02-16 14:55:24 +00:00
("e" #'emms "EMMS")
("n" #'emms-next "Next")
("p" #'emms-previous "Previous")
("SPC" #'emms-pause "Pause")
("s" #'contrapunctus-emms-toggle-player "Start/Stop")
("0" #'emms-volume-raise)
("9" #'emms-volume-lower)
("<up >" #'emms-volume-raise)
("<down >" #'emms-volume-lower)
("<left >" #'emms-seek-backward)
("<right >" #'emms-seek-forward)
("l" #'emms-play-dired "Play file (dired)")
("a" #'emms-add-dired "Add file (dired)")
("A" #'emms-add-directory-tree "Add directory")
("u" #'emms-play-url)))
(use-package emms-playlist-mode
:bind
(:map emms-playlist-mode-map
("0" . #'emms-volume-raise)
("9" . #'emms-volume-lower)
("<up >" . #'emms-volume-raise)
("<down >" . #'emms-volume-lower)
("<left >" . #'emms-seek-backward)
("<right >" . #'emms-seek-forward)
2021-05-15 15:06:42 +00:00
("r" . #'next-line)
("c" . #'previous-line)
("R" . #'emms-next)
("C" . #'emms-previous)
("C-r" . #'emms-toggle-random-playlist)
("M-r" . #'emms-random)
("M-c" . #'emms-playlist-mode-center-current)
("SPC" . #'emms-pause)
("K" . #'emms-playlist-clear))
2021-02-16 14:55:24 +00:00
:config
(setq emms-playlist-buffer-name "EMMS Playlist"))
2021-02-16 13:33:44 +00:00
2021-02-16 14:55:24 +00:00
(use-package emms-info-tinytag
:init
(setq emms-info-functions '(emms-info-tinytag))
:config
(setq emms-info-tinytag-python-name "python3"))
#+END_SRC
2021-09-25 15:29:39 +00:00
** Internet
*** eww
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
(use-package eww
2021-08-14 20:07:21 +00:00
:hook
(eww-after-render . visual-line-mode)
(eww-after-render . visual-fill-column-mode)
2021-02-16 13:33:44 +00:00
:config
2021-08-14 20:07:21 +00:00
(setq shr-image-animate nil
shr-width -1)
2021-02-16 13:33:44 +00:00
:bind
2021-02-16 14:55:24 +00:00
;; start boon-specific config
2021-02-16 13:33:44 +00:00
(:map shr-map
("v" . nil))
(:map shr-image-map
("i" . nil)
("v" . nil))
(:map eww-link-keymap
("i" . nil)
("v" . nil))
(:map eww-mode-map
2021-08-17 07:07:04 +00:00
("h" . #'eww-back-url)
("s" . #'eww-forward-url)
("c" . #'shr-previous-link)
("r" . #'shr-next-link)
("v" . nil))
;; end boon-specific config
)
2021-02-17 10:51:12 +00:00
2021-08-14 19:38:07 +00:00
(defun my-eww ()
(interactive)
(cond ((derived-mode-p 'dired-mode)
(eww-open-file
(dired-file-name-at-point)))
((derived-mode-p 'html-mode)
(eww-open-file (buffer-file-name)))
(t (call-interactively #'eww))))
2021-02-16 13:33:44 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
*** url-cookie
2021-02-16 14:55:24 +00:00
Ask for confirmation before saving cookies. I'd rather just disallow them all though 🤔
#+BEGIN_SRC emacs-lisp
(use-package url-cookie
:config
(setq url-cookie-confirmation t))
2021-02-17 10:51:12 +00:00
2021-02-16 14:55:24 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
*** elpher
2021-02-17 12:09:41 +00:00
#+BEGIN_SRC emacs-lisp
(use-package elpher
:bind (:map elpher-mode-map
2021-07-06 01:11:53 +00:00
("r" . elpher-next-link)
("c" . elpher-prev-link)
2021-02-18 22:34:51 +00:00
("h" . elpher-back)
2021-07-06 01:11:53 +00:00
("s" . push-button)
2021-02-17 12:09:41 +00:00
("w" . elpher-copy-current-url)
2021-12-02 04:54:26 +00:00
("W" . elpher-copy-link-url)
("g" . elpher-reload)))
2021-02-17 12:09:41 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
*** elfeed
2021-02-17 12:09:41 +00:00
#+BEGIN_SRC emacs-lisp
(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))
#+END_SRC
2021-09-25 15:29:39 +00:00
*** jabber
2021-02-17 12:09:41 +00:00
#+BEGIN_SRC emacs-lisp
(use-package jabber
2021-11-18 09:29:49 +00:00
:load-path "~/.emacs.d/elisp-git/emacs-jabber-wgreenhouse/ "
2021-02-17 12:09:41 +00:00
: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
2021-04-09 08:40:00 +00:00
jabber-alert-presence-message-function nil
jabber-account-list '(("contrapunctus@jabjab.de")))
(add-to-list 'jabber-post-connect-hooks 'jabber-enable-carbons))
2021-02-17 12:09:41 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
** sxiv
2021-02-18 09:31:40 +00:00
#+BEGIN_SRC emacs-lisp
(use-package sxiv
2021-03-11 00:44:13 +00:00
:load-path "~/.emacs.d/contrapunctus/sxiv/ "
:config (setq sxiv-exclude-strings '("meh" "\\.NEF$"))
:bind ("<f2 > s" . sxiv)
(:map dired-mode-map
("I" . sxiv)))
2021-02-18 09:31:40 +00:00
#+END_SRC
**
#+BEGIN_SRC emacs-lisp
;; (load "cp-adb")
#+END_SRC
**
#+BEGIN_SRC emacs-lisp
(require 'cp-editing)
;; (load "cp-evil")
(require 'cp-lily)
(require 'cp-sfz)
(require 'cp-lisp)
;; (ispell-change-dictionary "en")
(setq ispell-dictionary "en")
2021-02-20 13:44:12 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
** TODO emacsshot
2021-02-20 13:44:12 +00:00
PR ideas
1. [ ] create directories in save path if they don't exist
2. [ ] grammar - "written /path/to/file"
#+BEGIN_SRC emacs-lisp
(use-package emacsshot
:config
(setq emacsshot-with-timestamp t
2021-04-03 08:56:09 +00:00
emacsshot-snap-window-filename "/media/data/anon/Pictures/screenshots/emacsshot/emacsshot.png"))
2021-02-18 09:31:40 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
** File management
2021-03-11 00:44:13 +00:00
#+BEGIN_SRC emacs-lisp
(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
"-Achl --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
(: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" . dired-hide-dotfiles-mode)
("H" . dired-omit-mode)
([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)
("X" . dired-do-flagged-delete)
("M-n" . dired-next-marked-file)
("M-p" . dired-prev-marked-file)
2021-03-12 06:15:16 +00:00
("I" . sxiv)
("c" . dired-previous-line)
("r" . dired-next-line))
2021-03-11 00:44:13 +00:00
: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))
#+END_SRC
#+BEGIN_SRC emacs-lisp
;; 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))
#+END_SRC
#+BEGIN_SRC emacs-lisp
(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))))
#+END_SRC
#+BEGIN_SRC emacs-lisp
;; (with-eval-after-load 'project-explorer
;; (global-set-key (kbd "<f5 > e") 'project-explorer-toggle))
(use-package dired-hide-dotfiles
:hook (dired-mode . (lambda () (dired-hide-dotfiles-mode))))
;; (require 'sudo-edit)
(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.
(cl-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))))))
(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-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))))
#+END_SRC
#+BEGIN_SRC emacs-lisp
(use-package contrasync
:load-path "~/.emacs.d/contrapunctus/contrasync/ "
:config
(setq contrasync-disk-path "/media/anon/kash-sg-2tb/ "
contrasync-source-paths
`("~/.emacs.d/ "
2021-04-03 08:56:09 +00:00
"/media/data/anon/1-music-notation/ "
"/media/data/anon/Documents/ "
2021-03-11 00:44:13 +00:00
"~/.config/ "
"~/.local/ "
2021-04-03 08:56:09 +00:00
("/media/data/anon/phone/Nokia 6.1/ " ,contrasync-disk-path "phone/Nokia 6.1/ "))))
2021-03-11 00:44:13 +00:00
(use-package peep-dired
:disabled
;; ;; didn't work too well 🤔
;; :config
;; (setq peep-dired-cleanup-eagerly t)
:hook
(dired-mode . peep-dired))
#+END_SRC
2021-09-25 15:29:39 +00:00
** mail
2021-03-16 07:09:27 +00:00
#+BEGIN_SRC emacs-lisp
(use-package wl
:disabled
:config
(setq wl-icon-directory "~/.emacs.d/wl/icons"
wl-smtp-posting-server "disroot.org"))
(use-package mew
:disabled
:config
(setq mew-user "contrapunctus"
mew-name mew-user
mew-mail-domain "disroot.org"
mew-proto "%"
mew-smtp-server mew-mail-domain
mew-imap-server mew-mail-domain))
(use-package gnus
:init ;; I composed an email without loading Gnus, and it wasn't
;; saved in my sent folder; here's hoping that changing :config to
;; :init will do it.
(setq gnus-select-method '(nnnil "")
gnus-secondary-select-methods '((nnml "")
(nnimap "disroot.org")
;; (nnimap "imap.gmail.com"
;; (nnimap-stream starttls))
)
user-mail-address "contrapunctus@disroot.org"
user-full-name "contrapunctus"
gnus-mime-display-multipart-related-as-mixed t
smiley-style 'medium
message-send-mail-function 'smtpmail-send-it
;; gnus-message-archive-method '(nnimap "disroot.org")
gnus-message-archive-group "nnimap+disroot.org:Sent"))
(use-package message
:hook
(message-mode . (lambda () (auto-fill-mode -1)))
(message-mode . visual-fill-column-mode))
#+END_SRC
2021-09-25 15:29:39 +00:00
** pdf-tools
2021-08-21 13:52:29 +00:00
#+BEGIN_SRC emacs-lisp
(use-package pdf-tools
:init (pdf-tools-install)
:hook
(pdf-view-mode . auto-revert-mode)
(pdf-view-mode . pdf-view-midnight-minor-mode)
2021-12-02 15:44:45 +00:00
:bind
(:map pdf-view-mode-map
("h" . pdf-history-backward)
("s" . pdf-history-forward)
("c" . pdf-view-scroll-down-or-previous-page)
("r" . pdf-view-scroll-up-or-next-page)
("C-s" . isearch-forward))
:config
(setq-default pdf-view-display-size 'fit-height))
2021-08-21 13:52:29 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
** proced
2021-07-31 09:24:36 +00:00
#+BEGIN_SRC emacs-lisp
(use-package proced
:config
(setq proced-auto-update-flag t))
#+END_SRC
2021-09-25 15:29:39 +00:00
* comint
2021-02-18 09:31:40 +00:00
#+BEGIN_SRC emacs-lisp
(use-package comint
:bind (:map comint-mode-map
2021-04-03 09:01:32 +00:00
("M-p" . comint-history-isearch-backward-regexp) ;; QWERTY "r"
2021-02-21 22:51:51 +00:00
("M-c" . comint-previous-matching-input-from-input)
("M-r" . comint-next-matching-input-from-input)
2021-04-03 09:01:32 +00:00
("C-c C-s" . comint-next-prompt)
("C-c C-h" . comint-previous-prompt)))
2021-02-18 09:31:40 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
* company-emoji
2021-02-18 09:31:40 +00:00
#+BEGIN_SRC emacs-lisp
(use-package company-emoji
:hook (text-mode . company-emoji-init)
:config (add-to-list 'company-backends 'company-emoji))
#+END_SRC
2021-09-25 15:29:39 +00:00
* counsel
2021-02-18 09:31:40 +00:00
#+BEGIN_SRC emacs-lisp
(use-package counsel
:bind ("M-x" . counsel-M-x)
:config
(setq counsel-find-file-ignore-regexp "\\`\\."))
;; (use-package elsa
;; :commands flycheck-elsa-setup)
#+END_SRC
2021-09-25 15:29:39 +00:00
* misc keybindings
2021-02-18 09:31:40 +00:00
#+BEGIN_SRC emacs-lisp
(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)
#+END_SRC
2021-09-25 15:29:39 +00:00
* easy-kill :disabled:editing:
2021-02-18 09:31:40 +00:00
#+BEGIN_SRC emacs-lisp
(use-package easy-kill
:disabled
:bind (("M-w" . easy-kill)
("M-d" . easy-kill-delete-region)))
#+END_SRC
2021-09-25 15:29:39 +00:00
* TODO hydra [0%]
2021-02-18 09:31:40 +00:00
I started off using Hydra for programming modes, when I noticed that Elisp, Common Lisp, and Scheme all had some semantically-analogous operations with different names, which could be abstracted away behind a generic interface. Then, around the time I got into using Org for literate programs, I added an Org hydra, and then a general hydra for frequently-used operations.
Add these common operations to the hydra -
1. [X] =enlarge-window= , =enlarge-window-horizontally=
2. [X] =save-buffer= , =kill-buffer=
3. [ ] switch to last buffer, such that pressing it twice brings you back to the original buffer. Bind to "m" (same key as the one to launch the Hydra), moving magit to "M".
* Trickier to implement than I thought.
4. [X] =toggle-debug-on-error=
2021-03-08 20:42:19 +00:00
5. [X] "insert" hydra, for timestamps, dates; in Elisp, insert as strings; in Org, in angular brackets; etc
2021-08-01 07:57:08 +00:00
6. [X] remove duplication
2021-02-18 09:31:40 +00:00
#+BEGIN_SRC emacs-lisp
2021-02-19 20:06:37 +00:00
(use-package hydra :commands defhydra)
2021-08-01 07:57:08 +00:00
2021-08-03 01:00:22 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
** common hydra heads
2021-08-03 01:00:22 +00:00
#+BEGIN_SRC emacs-lisp
2021-08-01 07:57:08 +00:00
(defvar my-hydra-common-heads
'(("0" delete-window "delete this" :color red)
("1" delete-other-windows "delete others" :color red)
("2" split-window-below "split below" :color red)
("3" split-window-right "split right" :color red)
2021-08-09 13:17:59 +00:00
("+" text-scale-increase "zoom in" :color red)
("-" text-scale-decrease "zoom out" :color red)
("=" (text-scale-increase 0) "zoom reset" :color red)
2021-08-01 07:57:08 +00:00
("a" my-app-hydra/body "applications")
("z" my-app-hydra/body "applications")
("C" contrapunctus-mc-hydra/body "multiple cursors")
("d" dired-jump "dired-jump")
("D" (cp-insert-timestamp t) "date")
2021-08-17 09:28:15 +00:00
("f" my-search-hydra/body "find")
2021-08-01 07:57:08 +00:00
("i" (find-file "~/.emacs.d/init.org") "open init")
("I" contrapunctus-info-hydra/body "Info")
("k" (kill-buffer (current-buffer)) "kill" :color red)
2021-08-01 08:53:03 +00:00
("m" my-buffer-switch "Switch buffers")
2021-08-01 07:57:08 +00:00
("N" contrapunctus-line-display-hydra/body "line display")
("o" save-buffer "save")
2021-12-04 06:14:35 +00:00
("s" imenus "imenus")
2021-08-03 14:57:27 +00:00
("S" imenu-list "sidebar")
2021-08-01 07:57:08 +00:00
("T" cp-insert-timestamp "timestamp")
("u" find-file "new")
("U" launch-file "launch-file")
("v" volume "volume")
("C-v" find-alternate-file "revert")
("w" contrapunctus-window-hydra/body "window")))
(defmacro my-defhydra (name body docstring &rest unique-forms)
(declare (indent defun))
`(defhydra ,name ,body
,docstring
,@unique-forms
,@my-hydra-common-heads))
2021-02-19 20:06:37 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
** Line display
2021-02-19 20:06:37 +00:00
#+BEGIN_SRC emacs-lisp
2021-02-18 09:31:40 +00:00
(defhydra contrapunctus-line-display-hydra (:color red)
"Line display"
2021-04-03 09:01:32 +00:00
("a" adaptive-wrap-prefix-mode "adaptive-prefix-wrap")
2021-06-14 11:09:20 +00:00
("c" visual-fill-column-mode "visual-fill-column")
("k" visual-line-mode "visual-line")
("o" org-indent-mode "org-indent-mode")
("t" toggle-truncate-lines "truncate"))
2021-02-19 20:06:37 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
** Window
2021-02-19 20:06:37 +00:00
#+BEGIN_SRC emacs-lisp
2021-02-18 09:31:40 +00:00
(defhydra contrapunctus-window-hydra (:color red)
"Window"
2021-06-14 11:08:45 +00:00
("e" delete-window "delete this") ;; QWERTY d
("o" delete-other-windows "delete others")
2021-06-30 22:12:22 +00:00
("z" delete-window "delete this")
("v" delete-other-windows "delete others")
2021-06-14 11:08:45 +00:00
("t" split-window-below "split below")
("n" split-window-right "split right")
2021-03-15 13:23:07 +00:00
("c" enlarge-window "increase height")
("r" shrink-window "decrease height")
2021-06-14 11:08:45 +00:00
("h" enlarge-window-horizontally "increase width")
2021-12-02 12:30:57 +00:00
("s" shrink-window-horizontally "decrease width")
("b" balance-windows "balance"))
2021-02-19 20:06:37 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
** multiple cursors
2021-02-19 23:25:55 +00:00
#+BEGIN_SRC emacs-lisp
(defhydra contrapunctus-mc-hydra (:color red :hint none)
"
_a_ : previous word ^^^^ _h_ : previous whole symbol
_,_ : all words ^_i_ : insert letters^ _c_ : all symbols
_._ : words in defun ^_d_ : insert numbers^ _r_ : symbols in defun
2021-02-20 05:14:13 +00:00
_u_ : next word ^_l_ : edit lines^ _s_ : next whole symbol
2021-02-19 23:25:55 +00:00
"
2021-02-20 05:14:13 +00:00
("l" mc/edit-lines)
2021-02-19 23:25:55 +00:00
("a" mc/mark-previous-word-like-this)
("," mc/mark-all-words-like-this)
("." mc/mark-all-words-like-this-in-defun)
("u" mc/mark-next-word-like-this)
;; ("a" mc/mark-previous-like-this-word "previous word")
;; ("u" mc/mark-next-like-this-word "next word")
("h" mc/mark-previous-symbol-like-this)
("c" mc/mark-all-symbols-like-this)
("r" mc/mark-all-symbols-like-this-in-defun)
("s" mc/mark-next-symbol-like-this)
;; ("s" mc/mark-previous-like-this-symbol "previous symbol")
;; ("h" mc/mark-next-like-this-symbol "next symbol")
("d" mc/insert-numbers)
("i" mc/insert-letters))
#+END_SRC
2021-09-25 15:29:39 +00:00
** info
2021-02-21 22:50:08 +00:00
#+BEGIN_SRC emacs-lisp
(defhydra contrapunctus-info-hydra (:color blue)
"Info"
("i" info "info")
("a" info-apropos "apropos")
("E" (info "(emacs)") "Emacs")
("e" (info "(elisp)") "Elisp")
("l" (info "(lilypond-notation)") "Lilypond notation")
("L" (info "(lilypond-learning)") "Lilypond learning")
("o" (info "(org)") "Org")
2021-08-28 08:51:57 +00:00
("g" (info "(guile)") "Guile")
("t" (info "(texinfo)") "Texinfo"))
2021-02-21 22:50:08 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
** Help
2021-07-31 15:04:44 +00:00
#+BEGIN_SRC emacs-lisp
(defhydra my-help-hydra (:color blue)
"Help:"
("l" find-library "library")
2021-08-02 03:37:29 +00:00
("v" helpful-variable "variable")
2021-09-01 12:16:57 +00:00
("f" helpful-callable "function")
2021-08-02 03:37:29 +00:00
("k" helpful-key "key")
2021-08-04 08:52:20 +00:00
("h" helpful-at-point "here")
2021-12-04 06:14:07 +00:00
("m" man "man page")
("c" describe-char "character"))
2021-07-31 15:04:44 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
** Search
2021-08-17 09:28:15 +00:00
#+BEGIN_SRC emacs-lisp
(defhydra my-search-hydra (:color blue)
"Search command:"
("f" find-dired "find-dired")
("g" grep "grep")
2021-12-02 04:53:57 +00:00
("r" rgrep "rgrep")
2021-08-17 09:28:15 +00:00
("a" ag "ag")
("h" find-grep "find-grep"))
#+END_SRC
2021-09-25 15:29:39 +00:00
** General
2021-08-23 20:02:12 +00:00
#+BEGIN_SRC emacs-lisp
(require 'anaphora)
(defun my-compile-project (file &optional prefix cmd)
"Switch to ancestor directory with FILE and run compile command CMD.
If CMD is not supplied, run `compile-command'.
With PREFIX argument and CMD not supplied - prompt for command."
(interactive "fDominating File: \nP")
2021-09-01 12:20:29 +00:00
(save-window-excursion
2021-08-23 20:02:12 +00:00
(awhen (locate-dominating-file default-directory file)
(cd it)
(compile
2021-09-15 14:10:26 +00:00
(cond (prefix
(compilation-read-command
(or cmd "")))
2021-08-30 19:27:03 +00:00
(cmd cmd)
2021-08-23 20:02:12 +00:00
(t compile-command))))))
#+END_SRC
2021-02-19 20:06:37 +00:00
#+BEGIN_SRC emacs-lisp
2021-08-01 07:57:08 +00:00
(my-defhydra contrapunctus-general-hydra (:color blue)
2021-02-18 09:31:40 +00:00
"What command?"
2021-09-01 12:20:09 +00:00
("b" (my-compile-project "Makefile") "compile")
("B" (my-compile-project "Makefile" t) "compile (prompt)")
2021-08-16 04:58:15 +00:00
("h" my-help-hydra/body "Help")
2021-06-14 11:09:20 +00:00
("E" toggle-debug-on-error "tdoe")
2021-08-01 07:57:08 +00:00
("Q" toggle-debug-on-quit "tdoq"))
2021-02-19 20:06:37 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
** applications
2021-07-30 09:54:53 +00:00
#+BEGIN_SRC emacs-lisp
2021-07-31 13:08:02 +00:00
(defhydra my-app-hydra (:color blue)
2021-07-30 09:54:53 +00:00
"What application?"
2021-07-31 09:42:48 +00:00
;; built-in
("c" chronometrist "chronometrist")
("e" elpher "elpher")
2021-08-08 18:11:35 +00:00
("i" sxiv "sxiv")
2021-07-31 09:42:48 +00:00
("l" proced "list processes")
("m" magit-status "magit")
("p" list-packages "packages")
2021-09-01 12:19:28 +00:00
("j" (my-start-app-or-switch
2021-09-22 03:56:07 +00:00
"java" nil nil "josm"
2021-09-01 12:19:28 +00:00
"-jar" (expand-file-name "~/josm-tested.jar"))
"JOSM")
2021-07-31 09:42:48 +00:00
;; less-used
2021-08-01 07:57:08 +00:00
("J" my-jabber-hydra/body "Jabber")
2021-07-31 09:42:48 +00:00
("E" contrapunctus-emms-hydra/body "emms")
;; external
2021-09-01 12:19:28 +00:00
("g" (my-start-app-or-switch "gajim" nil "^Gajim$") "Gajim")
2021-07-31 14:35:22 +00:00
("b" (my-start-app-or-switch
"/media/data/anon/ext/tor-browser_en-US/Browser/start-tor-browser"
"^Tor Browser$")
2021-07-30 13:20:55 +00:00
"Tor Browser")
2021-07-31 14:35:22 +00:00
("B" (my-start-app-or-switch
"/media/data/anon/ext/firefox/firefox" "firefox")
"Firefox")
2021-07-30 23:37:29 +00:00
("k" (my-start-app-or-switch "keepassxc") "KeePassXC")
2021-07-31 14:35:22 +00:00
("t" (my-start-app-or-switch "xfce4-terminal") "terminal")
2021-08-03 01:13:23 +00:00
("T" (my-start-app-or-switch "transmission-gtk") "bittorrent")
2021-08-14 19:38:07 +00:00
("s" (my-start-app-or-switch "xfce4-screenshooter") "screenshot")
2021-09-01 12:19:28 +00:00
("q" (my-start-app-or-switch "qtractor") "Qtractor")
2021-08-14 19:38:07 +00:00
("w" my-eww "eww"))
2021-07-30 09:54:53 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
** org
2021-02-19 20:06:37 +00:00
#+BEGIN_SRC emacs-lisp
2021-11-18 09:48:11 +00:00
(defun my-compile-org-lp (&optional prefix)
2021-08-08 18:08:50 +00:00
(interactive)
2021-11-21 19:56:42 +00:00
(my-compile-project "Makefile" prefix "make -Bk tangle compile"))
2021-12-02 04:52:56 +00:00
(defhydra my-literate-elisp-hydra (:color blue)
"Literate Elisp"
("l" (literate-elisp-load (buffer-file-name)) "load")
("b" (literate-elisp-byte-compile-file (buffer-file-name)) "byte-compile"))
2021-08-08 18:08:50 +00:00
2021-08-01 07:57:08 +00:00
(my-defhydra my-org-hydra (:color blue)
2021-02-19 08:13:53 +00:00
"Org"
2021-12-02 04:52:56 +00:00
("L" my-literate-elisp-hydra/body "literate-elisp")
2021-02-19 08:13:53 +00:00
("p" org-set-property "property")
2021-08-03 01:00:22 +00:00
("l" my-org-hydra-block/body "source block")
2021-08-01 07:57:08 +00:00
("t" my-org-hydra-set-tags "tags")
2021-08-03 01:01:05 +00:00
("C-t" org-todo "todo" :color red)
2021-08-01 07:57:08 +00:00
("n" my-org-hydra-nav/body "navigation")
2021-11-18 09:48:11 +00:00
("b" (my-compile-org-lp) "compile")
("B" (my-compile-org-lp t) "compile (prompt)")
2021-08-03 01:00:22 +00:00
("C-b" contrapunctus-async-tangle "babel-tangle")
2021-09-22 03:53:03 +00:00
("e" my-org-eval-hydra/body "eval")
2021-02-19 08:13:53 +00:00
2021-08-16 04:58:15 +00:00
("h" my-help-hydra/body "Help")
2021-06-17 11:20:19 +00:00
("E" toggle-debug-on-error "tdoe")
2021-08-01 07:57:08 +00:00
("Q" toggle-debug-on-quit "tdoq"))
2021-09-22 03:53:03 +00:00
#+END_SRC
2021-08-01 07:57:08 +00:00
2021-09-25 15:29:39 +00:00
*** eval
2021-09-22 03:53:03 +00:00
#+BEGIN_SRC emacs-lisp
(defhydra my-org-eval-hydra (:color blue)
"Eval"
("e" org-babel-execute-src-block "eval block"))
2021-02-19 20:06:37 +00:00
#+END_SRC
2021-09-22 03:53:03 +00:00
2021-09-25 15:29:39 +00:00
*** org block
2021-02-19 20:40:34 +00:00
#+BEGIN_SRC emacs-lisp
2021-08-01 07:57:08 +00:00
(defhydra my-org-hydra-block (:color blue)
2021-02-19 20:40:34 +00:00
"Org source block"
2021-08-01 07:57:08 +00:00
("e" (my-org-hydra-insert-block "SRC" "emacs-lisp") "Emacs Lisp")
("t" (my-org-hydra-insert-block "SRC" "emacs-lisp :tangle test :load test") "Emacs Lisp test")
("E" (my-org-hydra-insert-block "SRC" "emacs-lisp :tangle no :load no") "Emacs Lisp example")
2021-09-22 03:53:03 +00:00
("h" (my-org-hydra-insert-block "SRC" "sh") "Shell")
2021-08-01 07:57:08 +00:00
("o" (my-org-hydra-insert-block "QUOTE") "quote")
2021-08-08 18:09:55 +00:00
("v" (my-org-hydra-insert-block "VERSE") "verse")
("s" (my-org-hydra-insert-block "SRC" "scheme") "Scheme"))
2021-08-01 07:57:08 +00:00
2021-02-19 20:40:34 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
*** org navigation
2021-02-19 20:40:34 +00:00
#+BEGIN_SRC emacs-lisp
2021-08-01 07:57:08 +00:00
(defhydra my-org-hydra-nav (:color red)
2021-02-19 20:40:34 +00:00
"Navigation"
2021-06-17 11:25:25 +00:00
;; movement
2021-02-19 20:40:34 +00:00
("c" org-previous-visible-heading "previous heading")
("r" org-next-visible-heading "next heading")
("h" outline-up-heading "up heading")
("t" org-backward-heading-same-level "backward heading")
("n" org-forward-heading-same-level "forward heading")
2021-06-17 11:25:25 +00:00
;; folding
("k" outline-show-branches "branches")
("<tab >" org-cycle "cycle")
;; modification
2021-08-03 01:12:47 +00:00
("C" org-metaup "drag backward")
("R" org-metadown "drag forward")
2021-12-02 04:55:47 +00:00
("H" org-metaleft "promote")
("S" org-metaright "demote"))
2021-02-19 20:40:34 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
** jabber
2021-04-09 08:39:37 +00:00
#+BEGIN_SRC emacs-lisp
2021-08-01 07:57:08 +00:00
(my-defhydra my-jabber-hydra (:color blue)
2021-04-09 08:39:37 +00:00
"Jabber"
("c" jabber-connect "connect")
("r" jabber-display-roster "roster")
("n" jabber-activity-switch-to "next" :color red)
("E" toggle-debug-on-error "tdoe")
2021-08-01 07:57:08 +00:00
("Q" toggle-debug-on-quit "tdoq"))
2021-04-09 08:39:37 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
** Emacs Lisp
2021-02-19 20:06:37 +00:00
#+BEGIN_SRC emacs-lisp
2021-08-01 07:57:08 +00:00
(my-defhydra my-elisp-hydra (:color blue)
2021-02-19 20:06:37 +00:00
"Emacs Lisp"
2021-08-03 01:00:22 +00:00
("c" my-elisp-bytecomp-hydra/body "byte compile")
2021-08-08 18:08:50 +00:00
("b" my-compile-org-lp "compile")
2021-12-02 12:31:25 +00:00
("B" (my-compile-org-lp t) "compile (prompt)")
2021-08-03 01:00:22 +00:00
("C-b" contrapunctus-async-tangle "babel-tangle")
2021-08-01 07:57:08 +00:00
("e" my-elisp-hydra-eval/body "Eval")
("E" my-elisp-hydra-debug/body "Debug")
2021-08-16 04:58:15 +00:00
("h" my-help-hydra/body "Help")
2021-02-19 20:06:37 +00:00
("j" xref-find-definitions "Jump to definition")
2021-06-17 11:20:48 +00:00
("J" org-babel-tangle-jump-to-org "Jump to definition (Org)")
2021-08-01 07:57:08 +00:00
("r" ielm "REPL")
("t" contrapunctus-el-test/body "Test"))
2021-02-19 20:06:37 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
*** eval
2021-02-19 20:06:37 +00:00
#+BEGIN_SRC emacs-lisp
2021-08-01 07:57:08 +00:00
(defhydra my-elisp-hydra-eval (:color blue)
2021-02-19 23:25:55 +00:00
("b" eval-buffer "buffer")
("e" eval-defun "defun")
("l" eval-last-sexp "last sexp"))
2021-02-19 20:06:37 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
*** unit testing
2021-02-19 20:06:37 +00:00
#+BEGIN_SRC emacs-lisp
2021-02-19 23:25:55 +00:00
(defhydra contrapunctus-el-test (:color blue)
2021-08-03 09:41:25 +00:00
("e" (my-compile-project "Cask" "cask exec buttercup -L . --traceback pretty") "buttercup")
2021-02-19 23:25:55 +00:00
("r" ert "ert"))
2021-02-19 20:06:37 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
*** debug
2021-02-21 22:59:30 +00:00
#+BEGIN_SRC emacs-lisp
2021-08-01 07:57:08 +00:00
(defhydra my-elisp-hydra-debug (:color blue)
2021-02-21 22:59:30 +00:00
"Debug"
2021-04-03 09:01:32 +00:00
("e" (funcall-interactively #'eval-defun t) "edebug")
2021-02-21 22:59:30 +00:00
("o" toggle-debug-on-error "tdoe")
("u" toggle-debug-on-quit "tdoq"))
#+END_SRC
2021-09-25 15:29:39 +00:00
*** byte-compile
2021-08-03 01:00:22 +00:00
#+BEGIN_SRC emacs-lisp
(defhydra my-elisp-bytecomp-hydra (:color blue)
"Byte compile"
("d" byte-recompile-directory "directory")
2021-12-02 12:31:41 +00:00
("c" (byte-compile-file (buffer-file-name)) "file")
("r" (byte-recompile-file (buffer-file-name)) "recompile")
2021-08-03 01:00:22 +00:00
("R" byte-force-recompile "force recompile"))
#+END_SRC
2021-09-25 15:29:39 +00:00
** Common Lisp
2021-02-19 20:06:37 +00:00
#+BEGIN_SRC emacs-lisp
2021-08-01 07:57:08 +00:00
(my-defhydra my-cl-hydra (:color blue)
2021-02-19 20:06:37 +00:00
"Common Lisp"
2021-08-17 09:29:13 +00:00
("R" slime-connect "connect")
2021-08-16 04:58:15 +00:00
("h" my-cl-help-hydra/body "Documentation")
2021-08-01 07:57:08 +00:00
("e" my-cl-hydra-eval/body "Eval")
2021-08-16 04:58:15 +00:00
("E" toggle-debug-on-error "tdoe")
("Q" toggle-debug-on-quit "tdoq")
2021-08-01 07:57:08 +00:00
("r" slime "REPL"))
2021-02-19 20:06:37 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
*** eval
2021-02-19 23:25:55 +00:00
#+BEGIN_SRC emacs-lisp
2021-08-01 07:57:08 +00:00
(defhydra my-cl-hydra-eval (:color blue)
2021-02-19 23:25:55 +00:00
("b" slime-eval-buffer "buffer")
2021-12-02 04:52:56 +00:00
("e" slime-eval-defun "defun")
("l" slime-eval-last-expression "last expression"))
2021-02-19 23:25:55 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
*** help
2021-02-19 23:25:55 +00:00
#+BEGIN_SRC emacs-lisp
2021-08-16 04:58:15 +00:00
(defhydra my-cl-help-hydra (:color blue)
("s" slime-documentation "slime")
("h" slime-documentation-lookup "CLHS")
2021-08-17 09:28:42 +00:00
("l" find-library "library")
("v" helpful-variable "variable")
("f" helpful-function "function")
("k" helpful-key "key")
2021-08-16 04:58:15 +00:00
("m" man "man page"))
2021-02-19 23:25:55 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
** Scheme
*** eval
2021-02-19 20:06:37 +00:00
#+BEGIN_SRC emacs-lisp
(defhydra cp-scm-eval (:color blue)
("b" geiser-eval-buffer "buffer")
2021-03-08 20:57:53 +00:00
("e" geiser-eval-definition "defun")
2021-08-01 07:57:08 +00:00
("l" geiser-eval-last-sexp "last sexp")
("E" toggle-debug-on-error "tdoe")
("Q" toggle-debug-on-quit "tdoq"))
2021-02-19 20:06:37 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
*** CHICKEN Scheme
2021-02-19 20:06:37 +00:00
#+BEGIN_SRC emacs-lisp
2021-08-01 07:57:08 +00:00
(my-defhydra my-chicken-hydra (:color blue)
2021-02-19 20:06:37 +00:00
"CHICKEN Scheme"
("e" cp-scm-eval/body "Eval")
("r" run-chicken "REPL")
2021-08-16 04:58:15 +00:00
("h" my-help-hydra/body "Help")
2021-08-01 07:57:08 +00:00
("E" toggle-debug-on-error "tdoe")
("Q" toggle-debug-on-quit "tdoq"))
2021-02-19 20:06:37 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
*** Guile
2021-02-19 20:06:37 +00:00
#+BEGIN_SRC emacs-lisp
2021-08-01 07:57:08 +00:00
(my-defhydra cp-guile (:color blue)
2021-02-19 20:06:37 +00:00
"Guile"
("e" cp-scm-eval/body "Eval")
("r" run-guile "REPL")
2021-08-16 04:58:15 +00:00
("h" my-help-hydra/body "Help")
2021-07-23 13:58:03 +00:00
("E" toggle-debug-on-error "tdoe")
2021-08-01 07:57:08 +00:00
("Q" toggle-debug-on-quit "tdoq"))
2021-02-19 20:06:37 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
** Lilypond
2021-02-19 20:06:37 +00:00
#+BEGIN_SRC emacs-lisp
2021-08-01 07:57:08 +00:00
(my-defhydra my-lilypond-hydra (:color blue)
2021-02-19 20:06:37 +00:00
"Lilypond"
2021-09-01 12:20:09 +00:00
("b" (my-compile-project "main.ly" nil "./mkly dev") "Compile")
("B" (my-compile-project "main.ly" t "./mkly dev") "Compile")
2021-08-16 04:58:15 +00:00
("h" my-help-hydra/body "Help")
2021-08-01 07:57:08 +00:00
("E" toggle-debug-on-error "tdoe")
("Q" toggle-debug-on-quit "tdoq"))
2021-02-19 20:06:37 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
** Prolog
2021-02-19 20:06:37 +00:00
#+BEGIN_SRC emacs-lisp
2021-08-01 07:57:08 +00:00
(my-defhydra my-prolog-hydra (:color blue)
2021-02-19 20:06:37 +00:00
"Prolog"
("r" ediprolog-dwim "REPL")
2021-08-01 07:57:08 +00:00
("E" toggle-debug-on-error "tdoe")
("Q" toggle-debug-on-quit "tdoq"))
2021-02-19 20:06:37 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
** Programming
2021-05-28 08:15:31 +00:00
Don't try to check if there are files with a certain extension...it will lead to false positives.
2021-02-19 20:06:37 +00:00
#+BEGIN_SRC emacs-lisp
2021-07-31 09:56:42 +00:00
(defun my-dispatch-hydra ()
2021-02-19 08:13:53 +00:00
(interactive)
2021-06-14 10:04:11 +00:00
(cond ((derived-mode-p 'emacs-lisp-mode
'inferior-emacs-lisp-mode
'debugger-mode)
2021-08-01 07:57:08 +00:00
(my-elisp-hydra/body))
2021-02-19 08:13:53 +00:00
(;; (or (locate-dominating-file default-directory "build.scm")
;; (locate-dominating-file default-directory "main.ly"))
(derived-mode-p 'LilyPond-mode)
2021-08-01 07:57:08 +00:00
(my-lilypond-hydra/body))
2021-06-14 10:04:11 +00:00
((and (featurep 'geiser)
(bound-and-true-p geiser-mode))
2021-08-11 17:57:06 +00:00
(cond ((eq 'chicken geiser-scheme-implementation)
2021-08-01 07:57:08 +00:00
(my-chicken-hydra/body))
2021-08-11 17:57:06 +00:00
((eq 'guile geiser-scheme-implementation)
2021-02-19 08:13:53 +00:00
(cp-guile/body))
2021-09-01 12:21:22 +00:00
(t (contrapunctus-general-hydra/body))))
2021-02-19 08:13:53 +00:00
((derived-mode-p 'lisp-mode 'slime-repl-mode)
2021-08-01 07:57:08 +00:00
(my-cl-hydra/body))
2021-07-31 09:56:42 +00:00
((derived-mode-p 'prolog-mode)
2021-08-01 07:57:08 +00:00
(my-prolog-hydra/body))
2021-02-19 08:13:53 +00:00
((derived-mode-p 'org-mode)
2021-08-01 07:57:08 +00:00
(my-org-hydra/body))
2021-09-21 08:17:13 +00:00
((derived-mode-p 'sh-mode)
(my-shell-hydra/body))
2021-05-15 15:07:16 +00:00
(t (contrapunctus-general-hydra/body))))
2021-02-19 08:13:53 +00:00
2021-07-31 09:56:42 +00:00
(define-key boon-command-map (kbd "m") #'my-dispatch-hydra)
(global-set-key (kbd "C-s") #'my-dispatch-hydra)
(define-key boon-command-map (kbd "C-s") #'my-dispatch-hydra)
2021-02-19 08:13:53 +00:00
2021-02-18 09:31:40 +00:00
#+END_SRC
2021-09-21 08:17:13 +00:00
2021-09-25 15:29:39 +00:00
** shell
2021-09-21 08:17:13 +00:00
#+BEGIN_SRC emacs-lisp
(my-defhydra my-shell-hydra (:color blue)
"Shell"
2021-11-18 09:48:11 +00:00
("e" my-shell-eval-hydra/body "eval")
("h" my-help-hydra/body "Help"))
2021-09-21 08:17:13 +00:00
(defhydra my-shell-eval-hydra (:color blue)
"Evaluate"
("b" org-babel-execute-src-block "source block"))
#+END_SRC
2021-09-25 15:29:39 +00:00
* eshell
2021-02-18 09:31:40 +00:00
#+BEGIN_SRC emacs-lisp
(use-package eshell
:config (setq eshell-history-size 999))
#+END_SRC
2021-09-25 15:29:39 +00:00
* image-mode
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
(use-package image-mode
:bind
(:map image-map
2021-04-03 09:01:32 +00:00
("o" . nil)
("r" . nil))
2021-02-16 13:33:44 +00:00
(:map image-mode-map
2021-04-03 09:01:32 +00:00
("o" . nil)
("r" . nil)))
2021-02-17 10:51:12 +00:00
2021-02-16 13:33:44 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
* flx-ido :disabled:
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
(use-package flx-ido
:disabled
:init (flx-ido-mode 1)
(setq ido-enable-flex-matching t
ido-use-faces nil))
2021-02-17 10:51:12 +00:00
2021-02-16 13:33:44 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
* flx-isearch :disabled:
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
(use-package flx-isearch
:disabled
:bind
("C-s" . #'flx-isearch-forward)
("C-r" . #'flx-isearch-backward))
;; (use-package flycheck
;; :ensure t
;; :init (global-flycheck-mode))
;; (use-package flycheck-elsa
;; :hook (emacs-lisp-mode . flycheck-elsa-setup))
#+END_SRC
2021-09-25 15:29:39 +00:00
* environment variables
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
2021-11-18 09:29:49 +00:00
(setenv "PATH" (concat "~/bin:" (getenv "PATH")))
2021-02-16 13:33:44 +00:00
(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)
#+END_SRC
#+BEGIN_SRC emacs-lisp
;; (add-to-list 'load-path "~/.emacs.d/elisp-git/yafolding.el/ ")
#+END_SRC
2021-09-25 15:29:39 +00:00
* general (keybindings)
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
(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
#+END_SRC
#+BEGIN_SRC emacs-lisp
(general-define-key
"<f8 >" 'keyboard-quit
"M-<f8 >" 'eval-defun
"M-<f9 >" 'dired-jump
"<f10 >" 'save-buffer
"M-<f10 >" 'find-file
"<f11 >" 'ido-mini
"M-<f11 >" 'ibuffer
"<f12 >" 'execute-extended-command
"M-<f12 >" 'text-scale-adjust
"C-c C-j" 'join-line
"C-c C-r" (lambda () (interactive) (revert-buffer t t))
;; for swapped parenthesis and square brackets layout
"C-)" 'abort-recursive-edit)
#+END_SRC
2021-12-02 04:47:50 +00:00
2021-09-25 15:29:39 +00:00
* UTF-8 incantations
2021-12-02 04:47:50 +00:00
:PROPERTIES:
:CUSTOM_ID: UTF-8 incantations
:END:
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
2021-12-02 04:47:50 +00:00
(setq locale-coding-system 'utf-8
file-name-coding-system 'utf-8
buffer-file-coding-system 'utf-8)
2021-02-16 13:33:44 +00:00
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
2021-02-17 10:51:12 +00:00
2021-02-16 13:33:44 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
* Linewrapping
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
(add-hook 'erc-mode-hook 'visual-line-mode)
(add-hook 'text-mode-hook 'visual-line-mode)
2021-02-17 10:51:12 +00:00
2021-06-06 02:11:21 +00:00
(use-package visual-fill-column
:hook
(markdown-mode . visual-fill-column-mode)
(markdown-mode . visual-line-mode)
2021-07-06 01:12:44 +00:00
(org-mode . visual-line-mode)
(org-mode . visual-fill-column-mode)
2021-08-14 20:07:21 +00:00
(message-mode . visual-fill-column-mode))
2021-06-06 02:11:21 +00:00
2021-02-16 13:33:44 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
* Navigation
2021-08-03 01:12:05 +00:00
#+BEGIN_SRC emacs-lisp
2021-07-25 15:17:21 +00:00
;; 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")
))
(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))
2021-07-25 15:24:40 +00:00
(use-package ibuffer
:bind (("C-x C-b" . ibuffer)
:map ibuffer-mode-map
("m" . nil)
("U" . nil)
("m f" . ibuffer-mark-by-file-name-regexp)
("m m" . ibuffer-mark-by-mode-regexp)
("m n" . ibuffer-mark-by-name-regexp)
("M" . ibuffer-mark-forward)
("r" . ibuffer-do-replace-regexp)
("U" . ibuffer-unmark-all))
:hook (ibuffer-mode . ibuffer-set-filter-groups-by-mode))
2021-07-25 15:17:21 +00:00
;; (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)
2021-07-25 15:25:49 +00:00
(use-package window-numbering
2021-07-26 11:40:20 +00:00
:commands (window-numbering-mode)
:init (window-numbering-mode 1)
:bind (:map window-numbering-keymap
("M-1" . nil) ("M-2" . nil) ("M-3" . nil)
("M-4" . nil) ("M-5" . nil) ("M-6" . nil)
("M-7" . nil) ("M-8" . nil) ("M-9" . nil)
("C-1" . select-window-1)
("C-2" . select-window-2)
("C-3" . select-window-3)
("C-4" . select-window-4)
("C-5" . select-window-5)
("C-6" . select-window-6)
2021-12-02 15:57:07 +00:00
;; for one-handed operation with the right hand
("C-7" . select-window-1)
("C-8" . select-window-2)
("C-9" . select-window-3)))
2021-07-25 15:17:21 +00:00
(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))
(use-package view-mode
:bind
(:map view-mode-map
("x" . nil)
("<backspace >" . scroll-down-command)
("SPC" . scroll-up-command)))
#+END_SRC
2021-09-25 15:29:39 +00:00
** outline-minor-mode
2021-08-11 17:39:36 +00:00
#+BEGIN_SRC emacs-lisp
(use-package outline
:hook (adoc-mode . outline-minor-mode)
(gemini-mode . outline-minor-mode)
;; Does this cause this error?
;; Polymode error (pm--mode-setup ’ org-mode): ‘ recenter’ ing a window that does not display current-buffer.
;; (outline-view-change . (lambda () (recenter 3)))
:bind (:map outline-minor-mode-map
("TAB" . contrapunctus-outline-indent-or-toggle-children)
;; this (rather than `outline-show-children') seems to
;; be the equivalent of `org-show-subtree'
("C-c C-k" . outline-show-branches)
;; wow, in adoc-mode these also replace the first letter of the heading with an "e"... 😒
;; ("C-c ," . outline-promote)
;; ("C-c ." . outline-demote)
)
("C-c ," . adoc-demote)
("C-c ." . adoc-promote)
("C-c C-c" . outline-previous-heading)
("C-c C-r" . outline-next-heading)
("C-c C-h" . nil)
("C-c C-h" . outline-up-heading))
#+END_SRC
#+BEGIN_SRC emacs-lisp
(defun contrapunctus-outline-indent-or-toggle-children ()
(interactive)
(if (save-excursion
(goto-char (point-at-bol))
(looking-at-p outline-regexp))
(outline-toggle-children)
(indent-for-tab-command)))
#+END_SRC
2021-09-25 15:29:39 +00:00
** outshine
2021-08-11 17:39:36 +00:00
#+BEGIN_SRC emacs-lisp
(use-package outshine
:commands (outshine-mode))
#+END_SRC
2021-09-25 15:29:39 +00:00
* scrolling
2021-07-25 15:17:21 +00:00
#+BEGIN_SRC emacs-lisp
(setq scroll-conservatively 10000
scroll-preserve-screen-position t
auto-window-vscroll nil)
#+END_SRC
2021-09-25 15:29:39 +00:00
* Recenter screen on isearch matches
2021-07-25 15:17:21 +00:00
#+BEGIN_SRC emacs-lisp
(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)
#+END_SRC
**
#+BEGIN_SRC emacs-lisp
(global-set-key (kbd "C-s") 'isearch-forward-regexp)
#+END_SRC
**
#+BEGIN_SRC emacs-lisp
(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)
#+END_SRC
**
#+BEGIN_SRC emacs-lisp
(add-hook 'next-error-hook 'recenter)
#+END_SRC
2021-09-25 15:29:39 +00:00
* date and time
2021-07-25 15:17:21 +00:00
#+BEGIN_SRC emacs-lisp
(defun cp-insert-timestamp (&optional date-only-p)
"Insert current date and time in ISO-8601 format in the current buffer."
(interactive)
(let ((timestamp (format-time-string
(if date-only-p "%F" "%FT%T%z"))))
(cond ((derived-mode-p 'emacs-lisp-mode)
(insert "\"" timestamp "\""))
(t (insert timestamp)))))
(use-package time
:config
(setq display-time-next-load-average t)
(add-to-list 'zoneinfo-style-world-list '("Europe/Berlin" "Berlin")))
#+END_SRC
**
#+BEGIN_SRC emacs-lisp
(defun cp/eval-sexp (arg)
"In emacs-lisp-mode, just run eval-defun.
In other modes - jump to first Lisp expression in current line
and eval it."
(interactive "P")
(save-excursion
(cond ((or
(equal major-mode 'emacs-lisp-mode)
(equal major-mode 'lisp-interaction-mode))
(eval-defun arg))
((cp/re-search-line "(")
(progn
(forward-char -1)
(forward-sexp)
(eval-last-sexp arg)))
(t nil))))
#+END_SRC
2021-09-25 15:29:39 +00:00
* helpful
2021-07-25 15:17:21 +00:00
#+BEGIN_SRC emacs-lisp
(use-package helpful
:bind (("<f1 > <f1 >" . #'helpful-at-point)
("<f1 > f" . #'helpful-callable)
("<f1 > c" . #'helpful-command)
("<f1 > k" . #'helpful-key)
("<f1 > v" . #'helpful-variable)))
#+END_SRC
2021-09-25 15:29:39 +00:00
* Buffer management
2021-08-01 08:53:03 +00:00
#+BEGIN_SRC emacs-lisp
(defun my-buffer-switch ()
(interactive)
(let ((buffers (remove-if (lambda (buffer)
(or (string-match-p "^ " (buffer-name buffer))
(get-buffer-window-list buffer)))
(buffer-list))))
(switch-to-buffer (first buffers))))
#+END_SRC
2021-09-25 15:29:39 +00:00
** ibuffer
2021-07-25 15:17:21 +00:00
#+BEGIN_SRC emacs-lisp
(use-package ibuffer
:bind
(:map ibuffer-mode-map
("X" . 'ibuffer-do-kill-on-deletion-marks))) ;; Boon hijacks the x key.
#+END_SRC
2021-09-25 15:29:39 +00:00
* info
2021-07-25 15:17:21 +00:00
#+BEGIN_SRC emacs-lisp
(use-package info
:config
(info-initialize)
(cl-loop for dir in
'("~/.emacs.d/info/ "
"~/.emacs.d/elisp-git/geiser/doc/ "
"~/lilypond/usr/share/info/ ")
do (add-to-list #'Info-directory-list dir))
:bind
(:map Info-mode-map
("b" . Info-history-back)
("f" . Info-history-forward)))
#+END_SRC
**
#+BEGIN_SRC emacs-lisp
(general-define-key
"C-x k" 'cp-kill-buffer
"C-`" 'shell
"M-`" 'eshell
"M-<f2 >" 'compile
"M-<f3 >" 'run-chicken
"M-<f4 >" 'run-lisp
"M-<f5 >" 'ielm)
#+END_SRC
**
#+BEGIN_SRC emacs-lisp
(general-define-key
:prefix "<f1 >"
"M" 'describe-mode
"m" 'man
"l" 'find-library)
#+END_SRC
**
#+BEGIN_SRC emacs-lisp
(general-define-key
:prefix "<f2 >"
;; "<f2 >" 'imenu
"<f2 >" 'xref-find-definitions
"r" 'xref-find-references
"m" 'imenu
;; "p" 'grep
"o" 'find-grep
"i" 'find-dired
"h" 'proced)
#+END_SRC
**
#+BEGIN_SRC emacs-lisp
(general-define-key
:prefix "<f5 >"
"<f5 >" 'eval-buffer
"i" 'cp-open-init
"v" 'visual-line-mode
"f" 'cp-fcf-literally
"f" 'fundamental-mode
"t" 'text-mode
"T" 'cp-insert-timestamp
"d" 'cp-insert-date
"c" 'calendar
"p" 'list-packages)
#+END_SRC
**
#+BEGIN_SRC emacs-lisp
(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
)
#+END_SRC
2021-09-25 15:29:39 +00:00
* help-mode
2021-07-25 15:17:21 +00:00
#+BEGIN_SRC emacs-lisp
(use-package help-mode
:bind
(:map help-mode-map
("b" . help-go-back)
("f" . help-go-forward)))
#+END_SRC
2021-09-25 15:29:39 +00:00
* Unicode keys
2021-07-25 15:17:21 +00:00
#+BEGIN_SRC emacs-lisp
(general-auto-unbind-keys)
(general-def
2021-11-29 20:18:13 +00:00
:prefix "C-t"
2021-12-04 06:07:43 +00:00
;; currency
"r" [?₹] "- L" [?£] "L -" [?£] "e" [?€]
2021-12-03 13:00:20 +00:00
"- m" [?—] "- n" [?– ] "m -" [?—] "n -" [?– ]
2021-09-22 03:53:46 +00:00
"t" [?™]
2021-07-25 15:17:21 +00:00
;; German
2021-12-04 06:07:43 +00:00
"\" a" [?ä] "a \"" [?ä] "\" A" [?Ä] "A \"" [?Ä]
"\" e" [?ë] "e \"" [?ë] "\" E" [?Ë] "E \"" [?Ë]
"\" o" [?ö] "o \"" [?ö] "\" O" [?Ö] "O \"" [?Ö]
"\" u" [?ü] "u \"" [?ü] "\" U" [?Ü] "U \"" [?Ü]
2021-12-02 09:24:28 +00:00
;; ;; " a/e/o/u are slow to type...
;; "a" [?ä] "A" [?Ä]
;; "e" [?ë] "E" [?Ë]
;; "o" [?ö] "O" [?Ö]
;; "u" [?ü] "U" [?Ü]
;; but "o" conflicts with "o o" for °, so...
2021-12-04 06:07:43 +00:00
"u a" [?ä] "u A" [?Ä]
"u e" [?ë] "u E" [?Ë]
"u o" [?ö] "u O" [?Ö]
"u u" [?ü] "u U" [?Ü]
2021-07-25 15:17:21 +00:00
"s s" [?ß]
;; French
", c" [?ç] "c ," [?ç] ", C" [?ç] "C ," [?Ç]
2021-12-03 13:00:20 +00:00
"' e" [?é] "e '" [?é]
"e `" [?è] "` e" [?è]
"e ^" [?ê] "^ e" [?ê]
"' a" [?á] "a '" [?á]
"a `" [?à] "` a" [?à]
"a ^" [?â] "^ a" [?â]
2021-08-11 18:04:00 +00:00
"~ n" [?ñ] "n ~ " [?ñ]
"~ N" [?Ñ] "N ~ " [?Ñ]
2021-07-25 15:17:21 +00:00
"o e" [?œ]
2021-09-01 12:21:08 +00:00
"o o" [?°] "x" [?× ]
2021-07-25 15:17:21 +00:00
"1 2" [?½] "1 3" [?⅓] "1 4" [?¼]
"2 3" [?⅔] "2 5" [?⅖]
"3 4" [?¾] "3 5" [?⅗]
"4 5" [?⅘]
2021-11-19 19:56:59 +00:00
"b" [?♭] "#" [?♯]
2021-07-25 15:17:21 +00:00
2021-12-04 06:07:43 +00:00
"< -" [?←] "- >" [?→]
2021-07-25 15:17:21 +00:00
"^ |" [?↑] "| ^" [?↑]
"v |" [?↓] "| v" [?↓]
", \\" [?λ] "l" [?λ]
2021-12-04 06:07:43 +00:00
"f" [?ƒ])
2021-07-25 15:17:21 +00:00
(general-auto-unbind-keys t)
(setq default-input-method "devanagari-itrans")
#+END_SRC
Suggestion by lampilelo for extending =iso-transl-ctl-x-8-map= (https://dpaste.com/BAQUXSDVL.txt)
#+BEGIN_SRC emacs-lisp :tangle no
(eval-after-load 'iso-transl
'(let ((map (make-sparse-keymap)))
(define-key map (kbd "c") [?č])
(define-key map (kbd "C") [?Č])
(define-key iso-transl-ctl-x-8-map (kbd "v") map)))
#+END_SRC
2021-09-25 15:29:39 +00:00
* backup configuration
2021-07-25 15:17:21 +00:00
#+BEGIN_SRC emacs-lisp
(setq backup-by-copying t
backup-directory-alist '(("." . "~/.emacs.d/saves/ "))
2021-11-22 13:01:41 +00:00
kept-new-versions 50
kept-old-versions 50
2021-07-25 15:17:21 +00:00
version-control t)
2021-11-22 13:01:41 +00:00
#+END_SRC
2021-07-25 15:17:21 +00:00
2021-11-22 13:01:41 +00:00
https://stackoverflow.com/questions/6916529/how-can-i-make-emacs-backup-every-time-i-save
#+BEGIN_SRC emacs-lisp
(defun my-force-backup ()
(setq buffer-backed-up nil))
2021-07-25 15:17:21 +00:00
#+END_SRC
2021-11-22 13:01:41 +00:00
2021-09-25 15:29:39 +00:00
* browse-url
2021-07-25 15:17:21 +00:00
SLIME opens CLHS links in Firefox, but I'd rather open them in Tor Browser; Tor Browser, however, does not permit other applications to open tabs in a running instance. So I wrote this to copy the links automatically instead.
#+BEGIN_SRC emacs-lisp
(use-package browse-url
:config
(defun cp-copy-url (url &rest args)
(with-temp-buffer
(insert url)
(kill-ring-save (point-min) (point-max)))
(message "Copied %s to kill ring" url))
(setq browse-url-browser-function #'cp-copy-url))
#+END_SRC
2021-09-25 15:29:39 +00:00
* Ivy
2021-07-25 15:17:21 +00:00
#+BEGIN_SRC emacs-lisp
(use-package ivy
:commands ivy-mode
:init (ivy-mode)
:bind (:map ivy-minibuffer-map
2021-12-02 09:28:20 +00:00
("C-h" . ivy-backward-delete-char)
("C-c" . previous-line)
("C-r" . next-line)
("M-c" . ivy-previous-history-element)
("M-r" . ivy-next-history-element))
2021-07-25 15:17:21 +00:00
:config
(setq ivy-re-builders-alist
'((t . ivy--regex-ignore-order))))
2021-12-04 06:06:56 +00:00
#+END_SRC
2021-07-25 15:17:21 +00:00
2021-12-04 06:06:56 +00:00
** ivy-xref
#+BEGIN_SRC emacs-lisp
(use-package ivy-xref
:config
(setq xref-show-definitions-function #'ivy-xref-show-defs))
2021-07-25 15:17:21 +00:00
#+END_SRC
2021-12-04 06:06:56 +00:00
2021-09-25 15:29:39 +00:00
* TODO magit [0%]
2021-07-25 15:17:21 +00:00
1. [ ] It'd be really cool to =(recenter 3)= when you /open/ a section, and =(recenter)= when you close a section
2. [ ] binding "c" to magit-section-backward and "j" to magit-commit means I can't nonchalantly hit "c c" to commit like before...it becomes "j c" :\
#+BEGIN_SRC emacs-lisp
(use-package magit
:bind (;; boon-like keys
:map magit-mode-map
("r" . magit-section-forward)
("c" . magit-section-backward)
("C" . magit-commit)
("R" . magit-rebase)
:map magit-diff-section-base-map
("C" . magit-commit)
("R" . magit-rebase)
:map magit-status-mode-map
;; ([mouse-3] . 'magit-section-toggle)
([down-mouse-3] . 'mouse-set-point)
([up-mouse-3] . 'magit-section-toggle)
("C" . magit-commit))
:commands magit-status
:hook
2021-08-04 08:51:55 +00:00
(magit-mode . visual-line-mode)
2021-07-25 15:17:21 +00:00
(magit-post-stage . (lambda () (recenter)))
:config
2021-08-04 08:51:55 +00:00
(cl-loop for symbol in '(magit-section-toggle
magit-section-forward
magit-section-backward)
2021-08-11 18:06:49 +00:00
do (advice-add symbol :after (lambda (&rest r) (recenter 3))))
2021-08-04 08:51:55 +00:00
(advice-add 'magit-unstage-item :after (next-line)))
2021-07-25 15:17:21 +00:00
#+END_SRC
#+BEGIN_SRC emacs-lisp
(use-package git-commit
:bind
(:map git-commit-mode-map
("M-c" . git-commit-prev-message)
("M-r" . git-commit-next-message)))
#+END_SRC
2021-09-25 15:29:39 +00:00
* markup
** Org
2021-02-18 05:26:52 +00:00
#+BEGIN_SRC emacs-lisp
(use-package org
2021-07-25 15:17:21 +00:00
:load-path "~/.emacs.d/elisp-git/org-mode"
:hook (org-mode . contrapunctus-disable-nameless-key)
2021-11-19 19:56:43 +00:00
(org-mode . auto-revert-mode)
2021-02-18 05:26:52 +00:00
:commands (org-drag-line-backward org-drag-line-forward)
2021-04-03 09:01:32 +00:00
:bind (("C-c C-h" . nil)
:map org-mode-map
("C-c C-c" . org-previous-visible-heading)
("C-c C-r" . org-next-visible-heading)
("C-c C-s" . org-forward-heading-same-level)
;; does not work...
2021-07-25 15:17:21 +00:00
("C-c C-h" . org-backward-heading-same-level)
("C-c C-j" . org-ctrl-c-ctrl-c)) ;; "c c" in boon/dvorak
2021-02-18 05:26:52 +00:00
:config
(general-def "<f5 > o" 'org-mode)
(general-def org-mode-map
"C-," 'nil
2021-02-20 06:02:25 +00:00
"M-r" 'org-metadown
"M-c" 'org-metaup
2021-02-18 05:26:52 +00:00
"C-c C--" 'org-ctrl-c-minus
"C-c C-," 'org-metaleft
"C-c C-." 'org-metaright
;; "C-j" 'org-return
2021-04-03 09:01:32 +00:00
;; "C-m" 'org-return-indent
2021-02-18 05:26:52 +00:00
"C-c C-9" 'org-mark-ring-goto
"C-c C-/" 'org-sparse-tree
"M-w" 'cp-copy-line-or-link
"C-M-x" 'cp/eval-sexp
2021-11-18 09:44:48 +00:00
"C-c C-o" 'my-org-open
2021-02-18 05:26:52 +00:00
;; boon
"C-c C--" 'org-ctrl-c-minus
"C-c ," 'org-metaleft
2021-02-21 22:37:31 +00:00
"C-c ." 'org-metaright
"M-h" 'default-indent-new-line)
2021-02-18 05:26:52 +00:00
(mapc (lambda (pair)
(add-to-list 'org-file-apps pair))
'(("txt" . emacs)
("org" . emacs)
2021-08-21 13:46:47 +00:00
("pdf" . emacs)
2021-02-18 05:26:52 +00:00
("\\(?:gif\\|jpe?g\\|png\\)" . "sxiv -f %s")
;; (t . "xdg-open %s")
))
(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
2021-07-25 15:17:21 +00:00
org-html-head "<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\" / >"
org-html-self-link-headlines t
2021-02-18 05:26:52 +00:00
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"
2021-09-15 14:08:47 +00:00
"xpm" "pbm" "pgm" "ppm" "webp") t))))
org-link-file-path-type 'relative)
2021-02-18 05:26:52 +00:00
;; https://lists.gnu.org/archive/html/emacs-orgmode/2018-02/msg00082.html
2021-07-31 09:27:57 +00:00
(defun my-export-link-helper (link desc format)
(cond
((eq format 'html)
(format "<a href=\"%s\" >%s</a >" link desc))
((eq format 'latex)
;; (format "\\href{%s}{%s}" link desc)
(format "\\url{%s}" link))
(t ;; `ascii', `md', `hugo', etc.
(format "[%s](%s)" desc link))))
2021-07-29 18:01:24 +00:00
(defun my-export-gemini-link (link desc format)
2021-05-28 08:13:51 +00:00
"Create export version of LINK and DESC to FORMAT."
2021-07-25 15:17:21 +00:00
(let ((link (concat "gemini:" link)))
2021-07-31 09:27:57 +00:00
(my-export-link-helper link desc format)))
2021-07-29 18:01:24 +00:00
(org-link-set-parameters "gemini" :export #'my-export-gemini-link)
2021-07-31 09:27:57 +00:00
(defun my-export-xmpp-link (link desc format)
"Create export version of LINK and DESC to FORMAT."
(let ((link (concat "xmpp:" link)))
(my-export-link-helper link desc format)))
(org-link-set-parameters "xmpp" :export #'my-export-xmpp-link)
2021-07-25 15:17:21 +00:00
(defun contrapunctus-disable-nameless-key ()
(define-key nameless-mode-map (kbd "C-c C--") nil)))
2021-02-18 05:26:52 +00:00
2021-08-01 07:57:08 +00:00
(defun my-org-hydra-insert-block (type &optional lang)
2021-03-11 00:47:14 +00:00
"Insert block of TYPE at point, or at beginning and end of region.
TYPE should be an Org block type, e.g. SRC, QUOTE, etc.
If TYPE is SRC, LANG should be the name of the language as a string, e.g. \"emacs-lisp\"."
(let* ((column (- (point) (point-at-bol)))
2021-11-28 05:18:56 +00:00
(indent (make-string column ?\s))
2021-03-10 14:55:12 +00:00
(region-start (region-beginning))
(region-end (region-end))
(start-string (format "#+BEGIN_%s %s\n" type
(if (stringp lang) lang "")))
2021-11-28 05:18:56 +00:00
(end-string (format "%s#+END_%s\n" indent type)))
2021-03-11 00:47:14 +00:00
;; create a block around a region - preserve position of point
2021-03-10 14:55:12 +00:00
(cond ((region-active-p)
(save-excursion
2021-03-11 00:47:14 +00:00
;; inserting at region-start would make region-end
;; invalid, so we insert at the end first
2021-03-10 14:55:12 +00:00
(goto-char region-end)
(insert end-string "\n")
(goto-char region-start)
(insert start-string)))
2021-03-11 00:47:14 +00:00
;; new empty block - insert the block syntax and place point
;; inside the block
(t (insert start-string)
2021-03-10 14:55:12 +00:00
(let ((point-inside-block (point)))
2021-03-11 00:47:14 +00:00
(insert "\n" end-string)
2021-03-10 14:55:12 +00:00
(goto-char point-inside-block)
(insert indent))))))
2021-02-18 05:26:52 +00:00
;; (use-package org-src-mode
;; :hook (org-src-mode . (lambda () (when (derived-mode-p 'emacs-lisp-mode)))))
2021-08-01 07:57:08 +00:00
;; (defun my-org-hydra-expand-all ()
2021-02-18 05:26:52 +00:00
;; (interactive)
;; ;; todo - define inner recursive function
;; (beginning-of-buffer)
;; ;; todo - check if we are on a heading
;; (org-forward-heading-same-level)
;; ())
;; I dislike having to navigate within a line to reach a link - with
;; this command I just need to be on the same line as the link.
2021-11-18 09:44:48 +00:00
(defun my-org-open (&optional arg reference-buffer)
2021-02-18 05:26:52 +00:00
(interactive "P")
(beginning-of-visual-line)
(unless (looking-at-p (rx-to-string '(or "http" "[")))
(org-next-link))
(org-open-at-point))
(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
(cp/re-search-line "\\[[-X ]\\]")))
(whole-line-or-region-kill-ring-save prefix-arg)
(cond ( ;; (cp/org-link-ahead-p)
(cp/re-search-line "\\[")
;; (if (looking-at "\\[")
;; (forward-char))
(forward-char)
(copy-to-closing-bracket)
(goto-char point-a))
( ;; (cp/org-link-ahead-p 'implicit)
(cp/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: "))))
2021-08-01 07:57:08 +00:00
(defun my-org-hydra-set-tags ()
2021-02-18 05:26:52 +00:00
(interactive)
(let ((all-tags (org-get-buffer-tags))
(current-tags (org-get-tags)))
(save-excursion
(org-back-to-heading)
(org-set-tags
(completing-read-multiple
2021-07-25 15:17:21 +00:00
"Tag: " all-tags nil 'confirm
(mapconcat #'identity current-tags ",")
'org-tags-history)))))
2021-02-16 13:33:44 +00:00
#+END_SRC
#+BEGIN_SRC emacs-lisp
2021-07-25 15:17:21 +00:00
(defun contrapunctus-org-insert-timestamp ()
(save-excursion
(insert "\n" "<" (format-time-string "%FT%T%z") " >")))
2021-07-29 18:01:24 +00:00
(add-hook 'org-insert-heading-hook #'contrapunctus-org-insert-timestamp)
2021-02-16 13:33:44 +00:00
2021-07-25 15:17:21 +00:00
(use-package org-indent
:hook (org-mode . org-indent-mode))
2021-02-16 13:33:44 +00:00
2021-07-25 15:17:21 +00:00
(use-package ox-texinfo)
2021-02-16 13:33:44 +00:00
#+END_SRC
2021-09-22 03:53:03 +00:00
From https://emacs.stackexchange.com/questions/20577/org-babel-load-all-languages-on-demand
#+BEGIN_SRC emacs-lisp
(defadvice org-babel-execute-src-block (around load-language nil activate)
"Load language if needed"
(let ((language (org-element-property :language (org-element-at-point))))
2021-09-22 03:55:01 +00:00
(unless (cdr (assoc (intern language)
org-babel-load-languages))
(add-to-list 'org-babel-load-languages
(cons (intern language) t))
(org-babel-do-load-languages 'org-babel-load-languages
org-babel-load-languages))
2021-09-22 03:53:03 +00:00
ad-do-it))
#+END_SRC
2021-09-25 15:29:39 +00:00
*** org-html-themify
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
2021-07-25 15:17:21 +00:00
(use-package org-html-themify
:disabled t
:load-path "~/.emacs.d/elisp-git/org-html-themify/ "
:load-path "~/.emacs.d/elisp-git/hexrgb/ "
:hook (org-mode . org-html-themify-mode)
:config
(setq org-html-themify-themes
'((dark . doom-molokai))))
2021-02-16 13:33:44 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
*** ox-publish
2021-07-29 17:58:52 +00:00
#+BEGIN_SRC emacs-lisp
(use-package ox-publish
:config
(require 'ox-gemini)
(setq org-publish-project-alist
'(("tilde.team-html"
:base-directory
"/media/data/anon/Documents/Text Files/homepage/contrapunctus/org/ "
:publishing-directory
"/ssh:contrapunctus@tilde.team:/home/contrapunctus/public_html/ "
:recursive t
:publishing-function org-html-publish-to-html)
("tilde.team-gmi"
:base-directory
"/media/data/anon/Documents/Text Files/homepage/contrapunctus/org/ "
:publishing-directory
"/ssh:contrapunctus@tilde.team:/home/contrapunctus/public_gemini/ "
:recursive t
:publishing-function org-gemini-publish-to-gemini))))
(defun my-org-publish-html (plist filename pub-dir)
)
#+END_SRC
2021-09-25 15:29:39 +00:00
** markdown-mode :editing:
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
2021-07-25 15:17:21 +00:00
(use-package markdown-mode
:mode "\\.md\\'"
:hook
(markdown-mode . (lambda ()
(make-local-variable 'before-save-hook)
(add-hook 'before-save-hook 'markdown-cleanup-list-numbers)))
(markdown-mode . markdown-display-inline-images)
:config (setq markdown-command "cmark"
markdown-css-paths '("style.css")
markdown-display-remote-images t
markdown-max-image-size '(500 . 500)
;; reflows text to suit different screens
markdown-xhtml-header-content
(concat "<meta name=\"viewport\" "
"content=\"width=device-width, "
"initial-scale=1.0, "
"user-scalable=yes\" />"))
(when (featurep 'boon)
(general-def markdown-mode-map
"C-c ," 'markdown-promote
"C-c ." 'markdown-demote
"C-c C-e" 'markdown-export))
(setq-default ;; markdown-hide-markup t ;; has a bug with heading cycling
markdown-hide-urls t)
:bind
(:map markdown-mode-map
;; ("M-n" . org-drag-element-forward)
;; ("M-p" . org-drag-element-backward)
;; ("C-c C-o" . markdown-follow-link-at-point)
("M-r" . markdown-move-down)
("M-c" . markdown-move-up)
("C-c C--" . org-cycle-list-bullet)
([mouse-1] . markdown-cycle)
("C-c C-x C-n" . markdown-next-link)
("C-c C-x C-p" . markdown-previous-link)
2021-06-06 02:12:54 +00:00
2021-07-25 15:17:21 +00:00
("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)))
2021-02-17 14:24:49 +00:00
2021-07-25 15:17:21 +00:00
(defun cp/copy-line-or-md-link (prefix-arg)
(interactive "P")
(save-excursion
(beginning-of-line)
(if (looking-at-p ".*http")
(progn
(cp/re-search-line "http")
(forward-char -4)
(kill-new (thing-at-point 'url))))))
2021-02-17 14:24:49 +00:00
#+END_SRC
2021-02-16 13:33:44 +00:00
2021-07-25 15:17:21 +00:00
**
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
2021-07-25 15:17:21 +00:00
(add-hook 'erc-mode-hook 'visual-line-mode)
2021-02-16 13:33:44 +00:00
#+END_SRC
2021-07-25 15:17:21 +00:00
**
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
2021-07-25 15:17:21 +00:00
(add-hook 'comint-mode-hook 'visual-line-mode)
2021-02-17 13:34:55 +00:00
2021-07-25 15:17:21 +00:00
;; commented out on 2018-03-19T14:18:34+0530
;; (add-hook 'markdown-mode-hook 'auto-fill-mode)
;; (add-hook 'text-mode-hook 'auto-fill-mode)
;; (add-hook 'paredit-mode-hook 'auto-fill-mode)
;;;; Tab settings
;; (setq default-tab-width 4)
2021-02-16 13:33:44 +00:00
#+END_SRC
2021-07-25 15:17:21 +00:00
**
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
2021-07-25 15:17:21 +00:00
(setq tab-width 4)
;(define-key text-mode-map (kbd "TAB") 'self-insert-command)
2021-02-16 17:54:41 +00:00
#+END_SRC
2021-07-25 15:17:21 +00:00
**
2021-02-21 23:04:24 +00:00
#+BEGIN_SRC emacs-lisp
2021-07-25 15:17:21 +00:00
(setq-default indent-tabs-mode nil)
2021-02-21 23:04:24 +00:00
#+END_SRC
2021-07-25 15:17:21 +00:00
2021-09-25 15:29:39 +00:00
** mediawiki-mode
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
(use-package mediawiki
:commands mediawiki-mode)
2021-02-17 10:51:12 +00:00
2021-02-16 13:33:44 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
** asciidoc-mode
2021-06-06 02:12:19 +00:00
Used by Eldev documentation.
#+BEGIN_SRC emacs-lisp
(use-package adoc-mode
:mode "\\.adoc$")
#+END_SRC
2021-09-25 15:29:39 +00:00
** gemini-mode
2021-07-23 14:01:45 +00:00
<2021-07-12T16:06:08+0530 >
#+BEGIN_SRC emacs-lisp
(use-package gemini-mode
:hook (gemini-mode . (lambda ()
(make-local-variable 'outline-regexp)
(setq outline-regexp "[#]+")))
:bind (:map gemini-mode-map
("TAB" . contrapunctus-outline-indent-or-toggle-children))
:config)
#+END_SRC
2021-09-25 15:29:39 +00:00
** TODO LaTeX
2021-08-03 01:12:05 +00:00
1. [ ] merge personal commands with those in Lilypond mode
#+BEGIN_SRC emacs-lisp
(use-package auctex
:hook ((tex-mode . TeX-source-correlate-mode))
:bind (:map LaTeX-mode-map
("M-c" . cp-backward-def)
("M-r" . cp-forward-def)
("M-." . forward-sentence))
:config
(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"))
)
;; 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)))
#+END_SRC
2021-09-25 15:29:39 +00:00
* midnight-mode
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
(use-package midnight
:init
(midnight-mode)
:config
(setq clean-buffer-list-kill-regexps '("")
clean-buffer-list-delay-general 1
clean-buffer-list-delay-special (* 60 60 12))
2021-08-21 20:07:07 +00:00
(add-to-list 'clean-buffer-list-kill-never-buffer-names "Gajim")
2021-02-16 13:33:44 +00:00
:hook
(midnight . clean-buffer-list))
2021-02-17 10:51:12 +00:00
2021-02-16 13:33:44 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
* Programming
** FIXME common [%]
*** swap keys :disabled:
2021-02-20 05:12:11 +00:00
1. [X] =keyswap-mode= swaps numeric keys with symbols by default. We want to swap just () with [] (to begin with), but the code below doesn't work, for some reason.
2. [ ] Does not always work in the minibuffer, namely =eval-expression=
2021-02-18 20:39:40 +00:00
Swap [] with () in programming and text modes.
pjb suggested a different approach [[http://paste.lisp.org/display/10157 ][here ]], which is basically -
#+BEGIN_SRC emacs-lisp :tangle no :load no
(defun contrapunctus-swap-brackets-parens ()
(interactive)
(keyboard-translate ?\( ?\[)
(keyboard-translate ?\) ?\])
(keyboard-translate ?\[ ?\()
(keyboard-translate ?\] ?\)))
(add-hook 'prog-mode-hook 'contrapunctus-swap-brackets-parens)
(add-hook 'text-mode-hook 'contrapunctus-swap-brackets-parens)
(defun normal-brackets-parens ()
(interactive)
(keyboard-translate ?\( ?\()
(keyboard-translate ?\) ?\))
(keyboard-translate ?\[ ?\[)
(keyboard-translate ?\] ?\]))
#+END_SRC
...which I tried, but experienced some subtle bugs, and luckily I got keyswap mode to work the way I wanted - no number-symbol switching, just parens and brackets.
2021-02-18 12:03:42 +00:00
#+BEGIN_SRC emacs-lisp
2021-02-18 20:39:40 +00:00
(use-package keyswap
2021-07-07 02:00:22 +00:00
:disabled t
2021-02-21 22:44:09 +00:00
:hook ((minibuffer-setup-hook . contrapunctus-swap-brackets-parens) ;; probably unnecessary
2021-02-20 05:12:11 +00:00
(eval-expression-minibuffer-setup-hook . contrapunctus-swap-brackets-parens)
(prog-mode . contrapunctus-swap-brackets-parens)
(text-mode . contrapunctus-swap-brackets-parens)
2021-04-06 09:30:27 +00:00
2021-02-18 20:39:40 +00:00
(emacs-lisp-mode . keyswap-colon-semicolon)
2021-04-06 09:30:27 +00:00
(ielm-mode . contrapunctus-swap-brackets-parens)
2021-04-03 08:56:59 +00:00
(ielm-mode . keyswap-colon-semicolon)
2021-04-06 09:30:27 +00:00
2021-02-18 20:39:40 +00:00
(lisp-mode . keyswap-colon-semicolon)
2021-04-03 08:56:59 +00:00
(slime-repl-mode . contrapunctus-swap-brackets-parens)
2021-06-13 11:53:44 +00:00
(slime-repl-mode . keyswap-colon-semicolon)
2021-04-06 09:30:27 +00:00
2021-04-03 08:56:59 +00:00
(scheme-mode . keyswap-colon-semicolon)
(geiser-repl-mode . contrapunctus-swap-brackets-parens)
(geiser-repl-mode . keyswap-colon-semicolon))
2021-02-18 12:03:42 +00:00
:config
2021-02-21 22:44:09 +00:00
(defun contrapunctus-keyswap-common ()
2021-02-20 05:12:11 +00:00
(setq-local keyswap-pairs nil) ;; dont swap numbers and symbols
2021-02-18 21:28:20 +00:00
(keyswap-mode))
2021-02-18 12:03:42 +00:00
(defun contrapunctus-swap-brackets-parens ()
2021-02-18 20:39:40 +00:00
;; (message "keyswap-pairs is %s" keyswap-pairs)
2021-02-21 22:44:09 +00:00
(contrapunctus-keyswap-common)
2021-02-18 12:03:42 +00:00
(keyswap-add-pairs ?\[ ?\()
(keyswap-add-pairs ?\] ?\))
(keyswap-update-keys)))
2021-02-20 05:50:26 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
*** other things
2021-02-20 05:50:26 +00:00
#+BEGIN_SRC emacs-lisp
2021-02-18 12:15:17 +00:00
(use-package projectile
:hook (prog-mode . projectile-mode)
:bind (:map boon-command-map
("\\" . projectile-command-map)))
2021-02-20 05:50:26 +00:00
#+END_SRC
2021-02-18 12:15:17 +00:00
2021-02-20 05:50:26 +00:00
#+BEGIN_SRC emacs-lisp
2021-02-17 12:09:41 +00:00
(use-package rainbow-delimiters
:hook (prog-mode . rainbow-delimiters-mode))
2021-02-20 05:50:26 +00:00
#+END_SRC
2021-02-17 12:09:41 +00:00
2021-02-20 05:50:26 +00:00
#+BEGIN_SRC emacs-lisp
2021-02-17 12:09:41 +00:00
(use-package company
:diminish company-mode
2021-07-24 08:01:31 +00:00
:hook (prog-mode . company-mode)
2021-02-17 12:09:41 +00:00
: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))
2021-02-19 07:26:09 +00:00
(:map company-active-map
2021-08-21 14:29:29 +00:00
("C-c" . company-select-previous)
("C-r" . company-select-next)
2021-08-04 09:16:52 +00:00
("C-h" . backward-delete-char)
2021-08-21 14:29:29 +00:00
("C-w" . backward-kill-word)
;; the following is necessary to shadow the window-switching
;; keybindings on the same keys
("C-1" . company-complete-quick-access)
("C-2" . company-complete-quick-access)
("C-3" . company-complete-quick-access)
("C-4" . company-complete-quick-access)
("C-5" . company-complete-quick-access)
("C-6" . company-complete-quick-access)
("C-7" . company-complete-quick-access)
("C-8" . company-complete-quick-access)
("C-9" . company-complete-quick-access)
("C-0" . company-complete-quick-access))
2021-02-18 05:16:36 +00:00
;; Error (use-package): company/:catch: Symbol’ s value as variable is void: c-mode-map
;; (:map c-mode-map
;; ("TAB" . company-indent-or-complete-common)
;; ("C-i" . company-indent-or-complete-common))
2021-02-17 12:09:41 +00:00
:config
2021-08-04 09:17:29 +00:00
(add-to-list 'company-backends 'company-irony)
2021-08-21 14:29:29 +00:00
(setq company-backends (remove 'company-etags company-backends)
company-show-quick-access t)
(customize-set-variable company-quick-access-modifier 'control))
2021-02-20 05:50:26 +00:00
#+END_SRC
2021-02-17 12:09:41 +00:00
2021-02-20 05:50:26 +00:00
#+BEGIN_SRC emacs-lisp
2021-02-17 12:09:41 +00:00
(use-package feature-mode
:mode "\\.feature$")
2021-02-20 05:50:26 +00:00
#+END_SRC
2021-02-17 12:09:41 +00:00
2021-02-20 05:50:26 +00:00
#+BEGIN_SRC emacs-lisp
2021-02-17 12:09:41 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
*** smartparens
2021-02-20 05:50:26 +00:00
#+BEGIN_SRC emacs-lisp
(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)
2021-07-06 16:17:53 +00:00
;; (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)
;; 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)
2021-02-20 05:50:26 +00:00
:bind
(("M-<up >" . sp-splice-sexp-killing-backward)
2021-05-15 14:57:39 +00:00
:map prog-mode-map
("M-'" . sp-indent-defun)
2021-02-20 05:50:26 +00:00
: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)
2021-02-20 06:19:14 +00:00
("M-e" . sp-kill-word)
2021-02-20 05:50:26 +00:00
("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
2021-07-06 16:17:53 +00:00
(eval-expression-minibuffer-setup . smartparens-mode)
(paredit-mode . turn-off-smartparens-mode)
(erc-mode . smartparens-mode))
2021-02-20 05:50:26 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
*** lispy
2021-07-09 01:46:43 +00:00
Create advice for =lispy-pair= - if =lispy--in-string-or-comment-p= is true, self-insert (which =smartparens= will add the closing pair for)
2021-02-20 05:50:26 +00:00
2021-07-06 01:43:26 +00:00
#+BEGIN_SRC emacs-lisp
(use-package lispy
2021-07-30 03:47:07 +00:00
:hook
(emacs-lisp-mode . lispy-mode)
2021-07-31 16:46:03 +00:00
(inferior-emacs-lisp-mode . lispy-mode)
2021-07-29 18:01:53 +00:00
(lisp-mode . lispy-mode)
(scheme-mode . lispy-mode)
2021-11-19 19:56:10 +00:00
(slime-repl-mode . lispy-mode)
2021-07-06 15:25:23 +00:00
;; Boon-style keys on Dvorak
:bind
(:map lispy-mode-map
;; change HJKL to Boon-like (QWERTY) KIOL
("t" . special-lispy-left) ;; QWERTY K
("n" . special-lispy-right) ;; QWERTY L
("c" . special-lispy-up) ;; QWERTY I
("r" . special-lispy-down) ;; QWERTY O
;; bind the replaced commands to Dvorak HJKL
("h" . special-lispy-teleport)
("j" . special-lispy-occur)
("k" . special-lispy-clone)
("l" . special-lispy-new-copy)
;; Lispy shadows this, but it's essential for Org literate programs
("M-o" . nil)
2021-07-30 03:47:07 +00:00
("M-o M-o" . font-lock-fontify-block)
;; It does not insert a pair in strings or comments. I want
;; that. I'll let smartparens take care of it.
("(" . self-insert-command))
;; :config (setq lispy-mode-map-c-digits nil)
:config
2021-07-31 00:08:54 +00:00
;; (dolist (key '("C-1" "C-2" "C-3" "C-4"))
;; (define-key lispy-mode-map-c-digits (kbd key) nil))
(lispy-set-key-theme '(lispy special)))
2021-07-30 03:47:07 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
*** treemacs
2021-07-08 20:26:50 +00:00
#+BEGIN_SRC emacs-lisp
(use-package treemacs
2021-11-18 09:47:03 +00:00
:disabled t
2021-07-08 20:26:50 +00:00
:bind (:map treemacs-mode-map
([mouse-1] . #'treemacs-single-click-expand-action))
:config
(treemacs-tag-follow-mode)
(treemacs-toggle-fixed-width)
(setq treemacs-tag-follow-delay 0))
2021-07-06 15:25:23 +00:00
2021-07-06 01:43:26 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
*** imenu
2021-07-08 20:26:50 +00:00
#+BEGIN_SRC emacs-lisp
(use-package imenu
2021-12-04 06:14:35 +00:00
:config
(setq imenu-auto-rescan t
org-imenu-depth 5))
#+END_SRC
2021-07-06 01:43:26 +00:00
2021-12-04 06:14:35 +00:00
**** imenus
#+BEGIN_SRC emacs-lisp
(use-package imenus
:commands imenus)
2021-07-08 20:26:50 +00:00
#+END_SRC
2021-12-04 06:14:35 +00:00
2021-09-25 15:29:39 +00:00
*** side-hustle
2021-07-08 20:26:50 +00:00
#+BEGIN_SRC emacs-lisp
(use-package side-hustle
2021-11-18 09:47:03 +00:00
:disabled t
2021-07-08 20:26:50 +00:00
:bind
(:map side-hustle-mode-map
(("r" . next-line)
("c" . previous-line))))
#+END_SRC
2021-09-25 15:29:39 +00:00
** Emacs Lisp
2021-02-17 12:09:41 +00:00
#+BEGIN_SRC emacs-lisp
(use-package elisp-mode
:diminish
:bind
(:map emacs-lisp-mode-map
("<tab >" . 'company-indent-or-complete-common)
("<C-tab >" . 'outline-toggle-children)
("M-n" . 'outline-next-heading)
("M-p" . 'outline-previous-heading)
("M-m" . macrostep-expand))
:config
(put 'cl-loop 'lisp-indent-function 'defun)
(setq print-length nil
eval-expression-print-length nil))
#+END_SRC
2021-06-13 11:53:16 +00:00
#+BEGIN_SRC emacs-lisp
(use-package ielm
:bind (:map ielm-map
("M-'" . sp-indent-defun)))
#+END_SRC
2021-11-15 17:32:40 +00:00
*** literate-elisp
#+BEGIN_SRC emacs-lisp
(use-package literate-elisp
:commands (literate-elisp-load))
#+END_SRC
2021-09-25 15:29:39 +00:00
*** eldoc
2021-02-17 12:09:41 +00:00
#+BEGIN_SRC emacs-lisp
(use-package eldoc
:diminish
:if (featurep 'elisp-mode)
:init (add-hook 'emacs-lisp-mode-hook 'eldoc-mode)
:config (setq eldoc-idle-delay 0))
#+END_SRC
2021-09-25 15:29:39 +00:00
*** emr - emacs refactor
2021-02-17 12:09:41 +00:00
#+BEGIN_SRC emacs-lisp
(use-package emr
:bind (:map prog-mode-map
("M-S-<return >" . emr-show-refactor-menu)))
#+END_SRC
2021-09-25 15:29:39 +00:00
*** nameless-mode
2021-02-17 12:09:41 +00:00
#+BEGIN_SRC emacs-lisp
(use-package nameless
:commands nameless-mode
:hook
(ert-results-mode . nameless-mode)
(emacs-lisp-mode . nameless-mode)
2021-07-06 00:52:06 +00:00
(org-mode . nameless-mode)
2021-02-17 12:09:41 +00:00
:bind (:map emacs-lisp-mode-map
2021-12-02 04:55:10 +00:00
("C-c C-n" . nameless-mode)
("C-c C--" . nameless-insert-name)))
2021-02-17 12:09:41 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
*** explain-pause-mode
2021-02-17 12:09:41 +00:00
#+BEGIN_SRC emacs-lisp
(use-package explain-pause-mode
2021-11-18 09:29:49 +00:00
:load-path "~/.emacs.d/elisp-git/explain-pause-mode/ "
2021-02-17 12:09:41 +00:00
:disabled t
:diminish
:commands explain-pause-mode
:init (explain-pause-mode))
#+END_SRC
2021-09-25 15:29:39 +00:00
*** async-tangle
2021-07-07 04:15:24 +00:00
#+BEGIN_SRC emacs-lisp
(defun contrapunctus-async-tangle (&optional prefix)
(interactive "P")
(let ((proc-buffer (get-buffer-create "*async-tangle-process* "))
(file-name (buffer-file-name))
(file-name-no-ext (file-name-sans-extension
(buffer-file-name)))
2021-07-12 03:25:06 +00:00
(old-win (selected-window)))
2021-07-07 04:15:24 +00:00
(start-process
"async-tangle" proc-buffer "emacs" "-q" "-Q" "--batch"
"--eval=(require 'ob-tangle)"
(format "--eval=(org-babel-tangle-file \"%s\")"
file-name file-name-no-ext))
2021-07-12 03:25:06 +00:00
;; don't create window if buffer already visible
(unless (get-buffer-window-list proc-buffer)
;; to avoid messing up my usual two-windows-same-buffer setup
(select-window (split-window-below))
(switch-to-buffer proc-buffer)
;; so I can access my Hydra to switch back
(boon-mode))
;; (select-window old-win)
))
2021-07-07 04:15:24 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
** Common Lisp
2021-02-17 12:09:41 +00:00
#+BEGIN_SRC emacs-lisp
2021-02-19 20:06:37 +00:00
(use-package redshank
:hook (slime-mode . redshank-mode))
2021-02-17 12:09:41 +00:00
2021-02-19 20:06:37 +00:00
(use-package slime
:commands (slime-eval-buffer slime-eval-defun)
:bind
(:map slime-mode-map
("M-n" . next-line)
("M-p" . previous-line)
("SPC" . self-insert-command)
("<f1 > <f1 >" . slime-documentation))
2021-04-03 09:01:32 +00:00
(:map slime-repl-mode-map
("M-p" . slime-repl-previous-matching-input) ;; QWERTY "r"
("M-c" . slime-repl-previous-input)
("M-r" . slime-repl-next-input))
2021-02-19 20:06:37 +00:00
:config
2021-11-18 09:42:55 +00:00
(setq slime-contribs (cons 'slime-tramp slime-contribs))
(slime-setup slime-contribs)
2021-11-19 19:55:09 +00:00
(setq inferior-lisp-program
2021-02-19 20:06:37 +00:00
;; "/usr/bin/ecl"
2021-11-19 19:55:09 +00:00
"sbcl"
2021-02-19 20:06:37 +00:00
slime-net-coding-system 'utf-8-unix)
(defun cp-slime-completion-in-region (_fn completions start end)
(funcall completion-in-region-function start end completions))
(advice-add 'slime-display-or-scroll-completions
:around #'cp-slime-completion-in-region)
(add-to-list 'slime-filename-translations
(slime-create-filename-translator
:machine-instance "tilde"
:remote-host "tilde.team"
:username "contrapunctus")))
(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-'") '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)
2021-02-17 12:09:41 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
** Scheme
*** CHICKEN Scheme
*** Guile
** Lilypond
** Prolog
2021-02-17 12:09:41 +00:00
#+BEGIN_SRC emacs-lisp
(use-package ediprolog
:commands ediprolog-dwim)
#+END_SRC
2021-09-25 15:29:39 +00:00
** c
2021-02-17 12:09:41 +00:00
#+BEGIN_SRC emacs-lisp
2021-11-19 19:54:52 +00:00
(use-package cc-mode
2021-02-18 05:16:36 +00:00
:bind (:map c-mode-map
("TAB" . company-indent-or-complete-common)
("C-i" . company-indent-or-complete-common)))
2021-02-17 12:09:41 +00:00
(use-package irony-eldoc
:hook
(c-mode . irony-eldoc))
(use-package irony
:config
(add-hook 'irony-mode-hook #'irony-eldoc))
(use-package company-irony)
(use-package rtags
:hook
(c-mode . rtags-call-rc)
:config
(setq rtags-rc-binary-name "rtags-rc"
rtags-rdm-binary-name "rtags-rdm")
:bind
(:map c-mode-map
("<f2 > <f2 >" . rtags-find-symbol-at-point)))
#+END_SRC
2021-09-25 15:29:39 +00:00
** nodejs-repl :disabled:
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
(use-package nodejs-repl
:disabled
:config (setq nodejs-repl-command "nodejs"))
2021-02-17 10:51:12 +00:00
2021-02-16 13:33:44 +00:00
#+END_SRC
2021-11-18 09:31:24 +00:00
** web development
https://emacs.cafe/emacs/javascript/setup/2017/04/23/emacs-setup-javascript.html
Potentially useful - https://www.draketo.de/software/emacs-javascript.html
#+BEGIN_SRC emacs-lisp
(use-package js2-mode
:mode ("\\.js\\'" . js2-mode)
;; Better imenu
:hook (js2-mode-hook . js2-imenu-extras-mode))
(use-package js2-refactor
:hook (js2-mode-hook . js2-refactor-mode))
2021-11-19 19:53:49 +00:00
(use-package tern)
2021-11-18 09:31:24 +00:00
(use-package company-tern
2021-11-19 19:53:49 +00:00
:load-path "~/.emacs.d/elisp-git/company-tern/ "
2021-11-18 09:31:24 +00:00
:init (add-to-list 'company-backends 'company-tern))
(use-package skewer-mode
:hook (js2-mode-hook . skewer-mode))
#+END_SRC
2021-09-25 15:29:39 +00:00
* nov.el
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
(use-package nov
2021-03-26 03:36:13 +00:00
:mode ("\\.epub\\'" . nov-mode)
2021-11-18 09:43:45 +00:00
:hook (nov-mode . visual-line-mode)
2021-03-26 03:36:13 +00:00
:bind
(:map nov-mode-map
;; make (Boon) c and r work even when point is in a link
("c" . nil)
("r" . nil)
("y" . nov-copy-url)
2021-11-18 09:43:45 +00:00
("c" . nov-previous-document)
("r" . nov-next-document)
("h" . nov-history-back)
("s" . nov-history-forward)
2021-08-08 17:56:21 +00:00
("T" . nov-goto-toc)
("m" . my-dispatch-hydra)))
2021-02-17 10:51:12 +00:00
2021-02-16 13:33:44 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
* package
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
(use-package package
:bind
(:map package-menu-mode-map
2021-11-18 09:30:29 +00:00
("k" . package-autoremove)
("c" . previous-line)
("r" . next-line))
2021-02-16 13:33:44 +00:00
:config
(when (featurep 'boon)
(general-def package-menu-mode-map
"X" 'package-menu-execute)))
2021-02-17 10:51:12 +00:00
2021-02-16 13:33:44 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
* feather
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
(use-package feather
:diminish
:hook (package-menu-mode . feather-mode)
:bind ("<f5 > p " . list-packages))
2021-02-17 10:51:12 +00:00
2021-02-16 13:33:44 +00:00
#+END_SRC
**
#+BEGIN_SRC emacs-lisp
2021-02-17 12:09:41 +00:00
2021-02-17 10:51:12 +00:00
2021-02-16 13:33:44 +00:00
#+END_SRC
**
2021-09-25 15:29:39 +00:00
* mode line
** powerline :disabled:
2021-02-17 10:51:12 +00:00
#+BEGIN_SRC emacs-lisp
(use-package powerline)
#+END_SRC
2021-09-25 15:29:39 +00:00
* undo-tree
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
(use-package undo-tree
:commands global-undo-tree-mode
:if (not (featurep 'evil))
:diminish undo-tree-mode
:init (global-undo-tree-mode))
2021-02-17 10:51:12 +00:00
2021-02-16 13:33:44 +00:00
#+END_SRC
**
#+BEGIN_SRC emacs-lisp
(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))
#+END_SRC
**
#+BEGIN_SRC emacs-lisp
(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)
;; )
#+END_SRC
**
#+BEGIN_SRC emacs-lisp
(defun cp/after-save ()
(let* ((file-path (buffer-file-name))
(file-path-shell (shell-quote-argument file-path)))
(cl-case major-mode
;; ;; This would be more useful if it was only displayed when
;; ;; tests failed. But even a constantly failing test result
;; ;; being shown each time you save can be annoying.
;; ('emacs-lisp-mode (let ((project-dir (locate-dominating-file file-path "Cask")))
;; (when project-dir
;; (cd project-dir)
;; (compile "cask exec buttercup -L . --traceback pretty"))))
2021-03-21 10:41:02 +00:00
;; ;; Handy as long as my only means of viewing Org data on mobile was the HTML export; not so much since I have Orgzly
;; ('org-mode
;; (pcase (file-name-nondirectory
;; (buffer-file-name
;; (current-buffer)))
;; ((or "chronometrist.org" "chronometrist-key-values.org" "init.org") t)
;; (_ (org-html-export-to-html))))
2021-02-16 13:33:44 +00:00
('LilyPond-mode
2021-09-01 12:18:35 +00:00
(my-compile-project "mkly" nil "./mkly dev"))
2021-02-16 13:33:44 +00:00
('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)
2021-02-17 10:51:12 +00:00
2021-02-16 13:33:44 +00:00
#+END_SRC
2021-11-22 04:42:03 +00:00
** compile
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
(use-package compile
:config
;; (add-hook 'compilation-start-hook
;; (lambda (proc)
;; (delete-other-windows)))
(setq compilation-always-kill t))
2021-11-22 04:42:03 +00:00
#+END_SRC
2021-02-17 10:51:12 +00:00
2021-11-22 04:42:03 +00:00
*** jump to Org LP from compilation output
:PROPERTIES:
:CUSTOM_ID: compile-org-lp-jump
:END:
2021-11-20 19:14:18 +00:00
2021-11-22 04:42:03 +00:00
#+BEGIN_SRC emacs-lisp
(defun my-org-lp-goto-error (oldfn &optional prefix &rest args)
2021-11-22 13:01:09 +00:00
"Make `compile-goto-error' lead to an Org literate program, if present.
This is meant to be used as `:around' advice for `compile-goto-error'.
OLDFN is `compile-goto-error'.
With PREFIX arg, just run `compile-goto-error' as though unadvised.
ARGS are ignored."
2021-11-22 04:42:03 +00:00
(interactive "P")
(if prefix
2021-11-20 19:14:18 +00:00
(funcall oldfn)
2021-11-22 13:01:09 +00:00
(let (buffer position column tangled-file-exists-p)
2021-11-22 04:42:03 +00:00
(save-window-excursion
(funcall oldfn)
(setq column (- (point) (point-at-bol)))
;; `compile-goto-error' might be called from the output of
;; `literate-elisp-byte-compile-file', which means
;; `org-babel-tangle-jump-to-org' would error
(when (ignore-errors (org-babel-tangle-jump-to-org))
(setq buffer (current-buffer)
position (point)
2021-11-22 13:01:09 +00:00
tangled-file-exists-p t)))
2021-11-22 04:42:03 +00:00
;; back to where we started - the `compilation-mode' buffer
2021-11-22 13:01:09 +00:00
(if tangled-file-exists-p
2021-11-22 04:42:03 +00:00
(let ((org-window (get-buffer-window buffer)))
;; if the Org buffer is visible, switch to its window
(if (window-live-p org-window)
(select-window org-window)
(switch-to-buffer buffer))
(goto-char (+ position column)))
(funcall oldfn)))))
2021-11-20 19:14:18 +00:00
(advice-add 'compile-goto-error :around #'my-org-lp-goto-error)
;; (advice-remove 'compile-goto-error #'my-org-lp-goto-error)
2021-02-16 13:33:44 +00:00
#+END_SRC
**
#+BEGIN_SRC emacs-lisp
(require 'cp-hindi)
2021-07-06 16:17:53 +00:00
;; (require 'cp-parens)
2021-02-17 10:51:12 +00:00
2021-02-16 13:33:44 +00:00
#+END_SRC
**
#+BEGIN_SRC emacs-lisp
(use-package keyfreq
:disabled
:init
(keyfreq-mode 1)
(keyfreq-autosave-mode 1))
;; ;; disabled on 2017-08-18T19:39:21+0530, no longer interested
;; (open-dribble-file (concat "~/.emacs.d/keylogs/ "
;; (format-time-string "%Y%m%d-%H%M%S")
;; ".txt"))
;; 2017-10-14T15:22:56+0530 - I suspect devanagari-itrans tires the
;; left hand faster than the right - let's find out!
;; ;; 2020-08-05T16:28:07+0530 commented out, no longer interested
;; (add-hook
;; 'input-method-activate-hook
;; (lambda ()
;; (open-dribble-file
;; (concat
;; "~/.emacs.d/keylogs/ "
;; (format-time-string "%Y%m%d-%H%M%S")
;; "-"
;; current-input-method
;; ".txt"))))
;; (add-hook
;; 'input-method-deactivate-hook
;; (lambda () (open-dribble-file nil)))
2021-02-17 10:51:12 +00:00
2021-02-16 13:33:44 +00:00
#+END_SRC
2021-09-25 15:29:39 +00:00
* recentf
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
(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
2021-11-07 11:27:16 +00:00
recentf-save-file (locate-user-emacs-file "recentf")
2021-02-16 13:33:44 +00:00
recentf-exclude '("\\.html\\(\\.orig\\)?$"
"\\.jpe?g$"
"\\.png$"
"\\.mp4$"
"\\.etc"
"\\.umstuff"))
:hook
(kill-emacs . recentf-cleanup))
2021-02-17 10:51:12 +00:00
2021-02-16 13:33:44 +00:00
#+END_SRC
**
#+BEGIN_SRC emacs-lisp
2021-02-17 10:12:43 +00:00
2021-02-16 13:33:44 +00:00
;;;; text size change
;; nicked from wasamasa's init - https://github.com/wasamasa/dotemacs/blob/934d0b37692d62fe9af56b52accac5bcd4445ae3/init.org
#+END_SRC
**
#+BEGIN_SRC emacs-lisp
(setq default-frame-alist '((font . "DejaVu Sans Mono-10.5")))
#+END_SRC
**
#+BEGIN_SRC emacs-lisp
(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")
#+END_SRC
**
#+BEGIN_SRC emacs-lisp
(use-package wgrep
:commands (wgrep-change-to-wgrep-mode))
#+END_SRC
2021-09-25 15:29:39 +00:00
* custom.el
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
(setq custom-file "~/.emacs.d/custom.el")
(load custom-file)
#+END_SRC
2021-09-25 15:29:39 +00:00
* Theme
2021-02-17 09:50:52 +00:00
Must put this after loading the custom file, or I get prompted about the theme each time.
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
2021-02-17 09:50:52 +00:00
(require 'doom-themes)
2021-06-06 02:11:52 +00:00
#+END_SRC
#+BEGIN_SRC emacs-lisp :load no
2021-02-17 09:50:52 +00:00
(load-theme 'doom-acario-dark)
2021-02-16 13:33:44 +00:00
#+END_SRC
2021-06-06 02:11:52 +00:00
Similar to doom-acario-dark, with paler colors. But Org headlines are all much too similar for my liking.
#+BEGIN_SRC emacs-lisp :load no
(load-theme 'doom-material)
#+END_SRC
#+BEGIN_SRC emacs-lisp
(load-theme 'doom-molokai)
#+END_SRC
2021-09-25 15:29:39 +00:00
* enabling disabled commands
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
(mapc (lambda (command)
(put command 'disabled nil))
'(downcase-region
upcase-region
set-goal-column
scroll-left
erc-remove-text-properties-region))
#+END_SRC
2021-09-25 15:29:39 +00:00
* desktop - session management
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
2021-03-16 07:09:27 +00:00
(use-package desktop
:init
(desktop-save-mode t)
(desktop-auto-save-enable)
:config
(setq desktop-dirname "~/.emacs.d/desktop-save/ "
desktop-save 'ask-if-new
;; don't save buffers, just the history
desktop-files-not-to-save ""
2021-09-01 20:13:38 +00:00
desktop-buffers-not-to-save ""
desktop-restore-frames nil)
2021-03-16 07:09:27 +00:00
(cl-loop for var in
'(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
2021-03-16 07:11:42 +00:00
swiper-history
counsel-M-x-history)
2021-03-16 07:09:27 +00:00
do (add-to-list 'desktop-globals-to-save var)))
;; (add-to-list 'desktop-locals-to-save 'comint-input-ring)
(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)
2021-02-16 13:33:44 +00:00
#+END_SRC
**
#+BEGIN_SRC emacs-lisp
(put 'list-timers 'disabled nil)
#+END_SRC
2021-09-25 15:29:39 +00:00
* GC reset
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
(setq gc-cons-threshold 400000)
;; (toggle-debug-on-quit)
;; (profiler-stop)
;; (emacs-init-time)
;; (profiler-report)
#+END_SRC
2021-09-25 15:29:39 +00:00
* The End
2021-02-16 13:33:44 +00:00
#+BEGIN_SRC emacs-lisp
(provide 'init)
;;; init.el ends here
#+END_SRC
2021-02-17 09:50:52 +00:00
# Local Variables:
# nameless-current-name: "contrapunctus"
# eval: (visual-fill-column-mode -1)
# eval: (nameless-mode)
# End: