diff --git a/AVY.org b/AVY.org new file mode 100644 index 0000000..a23c403 --- /dev/null +++ b/AVY.org @@ -0,0 +1,129 @@ +:PROPERTIES: +:ID: d9246843-e229-4f53-b75d-0cac546f353b +:END: +#+title: AVY + +AVY is a powerful Emacs library that allows you to jump to any visible character in a buffer with efficient tree searches. + +The core idea that makes Avy a powerful tool is [[id:65391d4b-e2b4-4a71-9d98-100cbc9772b4][the filter - select - act paradigm]]. + + +*Usage :* +1. call avy-goto-char-time - I have bound it to SPC a a +2. /filter/ by typing the characters of stings you want to go to +3. A decision tree appears at all matching points in the frame +4. Now before typing the decision /select/ the action + + default (do nothing) - will go to position + ? - display all possible actions, runs avy-show-dispatch-help +5. /act/ by entering your decision + +#+begin_src elisp +(use-package avy + :config + (setq avy-timeout-seconds 0.3) + + (setq avy-keys '(?q ?e ?r ?y ?u ?o ?p + ?a ?s ?d ?f ?g ?h ?j + ?k ?l ?' ?x ?c ?v ?b + ?n ?, ?/)) + + ;; overrides the function in avy.el, type ? before the decesion phase to call + (defun avy-show-dispatch-help () + (let* ((len (length "avy-action-")) + (fw (frame-width)) + (raw-strings (mapcar + (lambda (x) + (format "%2s: %-19s" + (propertize + (char-to-string (car x)) + 'face 'aw-key-face) + (substring (symbol-name (cdr x)) len))) + avy-dispatch-alist)) + (max-len (1+ (apply #'max (mapcar #'length raw-strings)))) + (strings-len (length raw-strings)) + (per-row (floor fw max-len)) + display-strings) + (cl-loop for string in raw-strings + for N from 1 to strings-len do + (push (concat string " ") display-strings) + (when (= (mod N per-row) 0) (push "\n" display-strings))) + (message "%s" (apply #'concat (nreverse display-strings))))) + + +;; Kill text ---------------------------------------------------- +(defun avy-action-kill-whole-line (pt) + (save-excursion + (goto-char pt) + (kill-whole-line)) + (select-window + (cdr + (ring-ref avy-ring 0))) + t) + +(setf (alist-get ?k avy-dispatch-alist) 'avy-action-kill-stay + (alist-get ?K avy-dispatch-alist) 'avy-action-kill-whole-line) + + +;; Copy text ----------------------------------------------------- +(defun avy-action-copy-whole-line (pt) + (save-excursion + (goto-char pt) + (cl-destructuring-bind (start . end) + (bounds-of-thing-at-point 'line) + (copy-region-as-kill start end))) + (select-window + (cdr + (ring-ref avy-ring 0))) + t) + +(setf (alist-get ?w avy-dispatch-alist) 'avy-action-copy + (alist-get ?W avy-dispatch-alist) 'avy-action-copy-whole-line) + + +;; Yank text ----------------------------------------------------- +(defun avy-action-yank-whole-line (pt) + (avy-action-copy-whole-line pt) + (save-excursion (yank)) + t) + +(setf (alist-get ?y avy-dispatch-alist) 'avy-action-yank + (alist-get ?Y avy-dispatch-alist) 'avy-action-yank-whole-line) + +;; Transpose/Move text -------------------------------------------- +(defun avy-action-teleport-whole-line (pt) + (avy-action-kill-whole-line pt) + (save-excursion (yank)) t) + +(setf (alist-get ?t avy-dispatch-alist) 'avy-action-teleport + (alist-get ?T avy-dispatch-alist) 'avy-action-teleport-whole-line) + +;; Mark text ------------------------------------------------------ +(defun avy-action-mark-to-char (pt) + (activate-mark) + (goto-char pt)) + +(setf (alist-get ? avy-dispatch-alist) 'avy-action-mark-to-char) + + +;; Flyspell words -------------------------------------------------- +(defun avy-action-flyspell (pt) + (save-excursion + (goto-char pt) + (when (require 'flyspell nil t) + (flyspell-auto-correct-word))) + (select-window + (cdr (ring-ref avy-ring 0))) + t) + +;; Bind to semicolon (flyspell uses C-;) +(setf (alist-get ?\; avy-dispatch-alist) 'avy-action-flyspell) + +) +#+end_src +** References ++ https://karthinks.com/software/avy-can-do-anything/index.html ++ https://github.com/abo-abo/avy ++ https://github.com/abo-abo/avy/wiki/defcustom ++ https://gist.github.com/karthink/af013ffd77fe09e67360f040b57b4c7b + diff --git a/Emacs/README.org b/Emacs/README.org deleted file mode 100644 index 99b5078..0000000 --- a/Emacs/README.org +++ /dev/null @@ -1,6 +0,0 @@ -:PROPERTIES: -:ID: 1245040a-0412-45cd-b4de-81026f06422a -:END: -#+title: Emacs - -Emacs is much more than just a text editor. diff --git a/Index.org b/Index.org new file mode 100644 index 0000000..816a618 --- /dev/null +++ b/Index.org @@ -0,0 +1,14 @@ +:PROPERTIES: +:ID: 020c5410-998b-46fb-8c5e-59013dd30db4 +:END: +#+title: Index +#+hugo_section: ./ + +These are my thoughts. + +I use org-roam to manage these thoughts and ox-hugo along with quartz to publish them. + +For more details see +* Topics +Here are some topics I think about +** [[id:0a87430b-6616-4f92-8ecc-22ceeebf43c6][Emacs]] diff --git a/My_Emacs_Config.org b/My_Emacs_Config.org new file mode 100644 index 0000000..50d3b04 --- /dev/null +++ b/My_Emacs_Config.org @@ -0,0 +1,10 @@ +:PROPERTIES: +:ID: 43f5a7d2-4e8c-4d61-b333-8993d2aefbf6 +:END: +#+title: My_Emacs_Config + +Here is my emacs config with commentary. + +TODO This is a work in progress - I am adding packages one by one after cleaning some of the code and fixing bugs + +* [[id:d9246843-e229-4f53-b75d-0cac546f353b][AVY]] diff --git a/README.org b/README.org index d5929b2..20875b9 100644 --- a/README.org +++ b/README.org @@ -1,9 +1 @@ -:PROPERTIES: -:ID: 020c5410-998b-46fb-8c5e-59013dd30db4 -:END: -#+title: Notes - -These will be some notes on various topics I like. - -* Topics -** [[file:Emacs/README.org][Emacs]] +These are my thoughts in the form of a [[https://www.orgroam.com/][org roam]] database. diff --git a/emacs.org b/emacs.org new file mode 100644 index 0000000..c07f040 --- /dev/null +++ b/emacs.org @@ -0,0 +1,8 @@ +:PROPERTIES: +:ID: 0a87430b-6616-4f92-8ecc-22ceeebf43c6 +:END: +#+title: Emacs + +Emacs is much more than just a text editor. + +Here is my [[id:43f5a7d2-4e8c-4d61-b333-8993d2aefbf6][My Emacs Config]] diff --git a/index.org b/index.org new file mode 100644 index 0000000..7aed748 --- /dev/null +++ b/index.org @@ -0,0 +1,14 @@ +:PROPERTIES: +:ID: 020c5410-998b-46fb-8c5e-59013dd30db4 +:END: +#+title: index +#+hugo_section: ./ + +These are my thoughts. + +I use org-roam to manage these thoughts and ox-hugo along with quartz to publish them. + +For more details see +* Topics +Here are some topics I think about +** [[id:0a87430b-6616-4f92-8ecc-22ceeebf43c6][Emacs]] diff --git a/the_filter-select-act_paradigm.org b/the_filter-select-act_paradigm.org new file mode 100644 index 0000000..0ad84f0 --- /dev/null +++ b/the_filter-select-act_paradigm.org @@ -0,0 +1,11 @@ +:PROPERTIES: +:ID: 65391d4b-e2b4-4a71-9d98-100cbc9772b4 +:END: +#+title: the_filter-select-act_paradigm + +The filter - select - act paradigm/pattern is powerful abstraction used in [[id:0a87430b-6616-4f92-8ecc-22ceeebf43c6][Emacs]] and many of its packages like [[id:d9246843-e229-4f53-b75d-0cac546f353b][AVY]]. + +It is a philosophy that not only makes string manipulation efficient but allows one to really utilize emacs the way it is ment to be used, like a single mutable state, not just some willy nilly text editor. + +* References ++ https://karthinks.com/software/avy-can-do-anything/index.html