;;; evil-leap.el --- Evil's answer to Neovim's answer to the mouse -*- lexical-binding: t; -*- ;; ;; Copyright (C) 2024 Madeleine Sydney ;; ;; Author: Madeleine Sydney ;; Maintainer: Madeleine Sydney ;; Created: October 06, 2024 ;; Modified: October 06, 2024 ;; Version: 0.0.1 ;; Keywords: evil movement ;; Homepage: https://github.com/crumbtoo/leap.el ;; Package-Requires: ((emacs "24.3")) ;; ;; This file is not part of GNU Emacs. ;; ;;; Commentary: ;; ;; ;; ;;; Code: (defcustom evil-leap-safe-labels (string-to-list "sfnut/SFNLHMUGTZ?") "TODO A list of characters that you will never use immediately after an evil-leap jump." :group 'evil-leap :type "List of characters") (defcustom evil-leap-labels (string-to-list "sfnjklhodweimbuyvrgtaqpcxz/SFNJKLHODWEIMBUYVRGTAQPCXZ?") ;; (append evil-leap-safe-labels ;; (string-to-list "jklhodweimbyvrgaqpcxzJKODWEIBYVRAQPCX")) "TODO A list of characters to use as labels." :group 'evil-leap :type "List of characters") ;; (defun evil-leap--collect-keys (&optional forward?) ;; (let ((collected-keys nil)) ;; (dolist (i '(0 1) collected-keys) ;; (let ((prompt (format ">%s" (mapconcat #'char-to-string collected-keys)))) ;; (appendq! collected-keys (list (evil-read-key prompt))))))) (defcustom evil-leap-character-aspect-ratio 0.3 "TODO" :group 'evil-leap :type "Number") (defcustom evil-leap-equivalence-classes '((?\s ?\n ?\t ?\r)) "TODO" :group 'evil-leap :type "List of lists of characters") (defun evil-leap--gather-targets-forward (regexp) (let ((end-of-visible (window-end)) targets) (save-excursion (while (re-search-forward regexp end-of-visible t) (save-excursion (goto-char (match-beginning 0)) (push (list (point) (current-column) (line-number-at-pos)) targets)))) (reverse targets))) (defun evil-leap--euclidean-distance (x1 y1 x2 y2) (let* ((width (abs (- x1 x2))) (height (* (abs (- y1 y2)) evil-leap-character-aspect-ratio)) (hypotenuse (sqrt (+ (* width width) (* height height))))) hypotenuse)) (defun evil-leap--sort-by-euclidean-distance-from-point (targets) (let ((point-x (current-column)) (point-y (line-number-at-pos))) (sort targets :lessp (lambda (pos1 pos2) (pcase-let ((`(,_ ,pos1-x ,pos1-y) pos1) (`(,_ ,pos2-x ,pos2-y) pos2)) (< (evil-leap--euclidean-distance point-x point-y pos1-x pos1-y) (evil-leap--euclidean-distance point-x point-y pos2-x pos2-y))))))) ;; (defun evil-leap--label-targets (targets) ;; (let ((ht (make-hash-table :test 'equal))) ;; (dolist (c )))) ;; define-inline? (defun evil-leap-jump-to (target) (goto-char (car target))) (defun evil-leap (&rest args) "TODO Something something something. Keyword arguments :backward-p BOOL :action ACTION :targets TARGETS A list of targets, or a Lisp procedure returning such a list. Each target should be a list of form (POS LINE COLUMN . XS)." (let ((backward-p (plist-get args :backward-p)) (action (or (plist-get args :action) #'evil-leap-jump-to)) (targets (plist-get args :targets))) )) (evil-define-motion evil-leap-s (count keys) "TODO" :jump t :type 'exclusive (interactive) (evil-leap--collect-keys)) (provide 'evil-leap) ;;; evil-leap.el ends here