From 682f548dde543b817be475a4611591cca2cbe4ec Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Tue, 13 Nov 2018 11:12:49 +0100 Subject: [PATCH] update avy. Signed-off-by: Andreas Gerler --- elpa/avy-20171230.220/avy-pkg.el | 2 - .../avy-autoloads.el | 30 +- elpa/avy-20181009.1648/avy-pkg.el | 2 + .../avy.el | 257 ++++++++++++------ 4 files changed, 193 insertions(+), 98 deletions(-) delete mode 100644 elpa/avy-20171230.220/avy-pkg.el rename elpa/{avy-20171230.220 => avy-20181009.1648}/avy-autoloads.el (89%) create mode 100644 elpa/avy-20181009.1648/avy-pkg.el rename elpa/{avy-20171230.220 => avy-20181009.1648}/avy.el (92%) diff --git a/elpa/avy-20171230.220/avy-pkg.el b/elpa/avy-20171230.220/avy-pkg.el deleted file mode 100644 index e509bb5c..00000000 --- a/elpa/avy-20171230.220/avy-pkg.el +++ /dev/null @@ -1,2 +0,0 @@ -;;; -*- no-byte-compile: t -*- -(define-package "avy" "20171230.220" "Jump to arbitrary positions in visible text and select text quickly." '((emacs "24.1") (cl-lib "0.5")) :commit "34d3531a3cd35ae6b9e8dbc37343c027504fdcb0" :url "https://github.com/abo-abo/avy" :keywords '("point" "location")) diff --git a/elpa/avy-20171230.220/avy-autoloads.el b/elpa/avy-20181009.1648/avy-autoloads.el similarity index 89% rename from elpa/avy-20171230.220/avy-autoloads.el rename to elpa/avy-20181009.1648/avy-autoloads.el index adef5c90..e0b0fa3a 100644 --- a/elpa/avy-20171230.220/avy-autoloads.el +++ b/elpa/avy-20181009.1648/avy-autoloads.el @@ -1,9 +1,12 @@ ;;; avy-autoloads.el --- automatically extracted autoloads ;; ;;; Code: -(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path)))) + +(add-to-list 'load-path (directory-file-name + (or (file-name-directory #$) (car load-path)))) + -;;;### (autoloads nil "avy" "avy.el" (23115 25984 207150 608000)) +;;;### (autoloads nil "avy" "avy.el" (0 0 0 0)) ;;; Generated autoloads from avy.el (autoload 'avy-goto-char "avy" "\ @@ -110,13 +113,14 @@ When ARG is non-nil, do the opposite of `avy-all-windows'. (autoload 'avy-goto-subword-0 "avy" "\ Jump to a word or subword start. - The window scope is determined by `avy-all-windows' (ARG negates it). When PREDICATE is non-nil it's a function of zero parameters that should return true. -\(fn &optional ARG PREDICATE)" t nil) +BEG and END narrow the scope where candidates are searched. + +\(fn &optional ARG PREDICATE BEG END)" t nil) (autoload 'avy-goto-subword-1 "avy" "\ Jump to the currently visible CHAR at a subword start. @@ -146,13 +150,24 @@ Otherwise, forward to `goto-line' with ARG. (autoload 'avy-goto-line-above "avy" "\ Goto visible line above the cursor. +OFFSET changes the distance between the closest key to the cursor and +the cursor +When BOTTOM-UP is non-nil, display avy candidates from top to bottom -\(fn)" t nil) +\(fn &optional OFFSET BOTTOM-UP)" t nil) (autoload 'avy-goto-line-below "avy" "\ Goto visible line below the cursor. +OFFSET changes the distance between the closest key to the cursor and +the cursor +When BOTTOM-UP is non-nil, display avy candidates from top to bottom -\(fn)" t nil) +\(fn &optional OFFSET BOTTOM-UP)" t nil) + +(autoload 'avy-goto-end-of-line "avy" "\ +Call `avy-goto-line' and move to the end of the line. + +\(fn &optional ARG)" t nil) (autoload 'avy-copy-line "avy" "\ Copy a selected line above the current line. @@ -236,11 +251,14 @@ The window scope is determined by `avy-all-windows' (ARG negates it). \(fn &optional ARG)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "avy" '("avy-"))) + ;;;*** ;; Local Variables: ;; version-control: never ;; no-byte-compile: t ;; no-update-autoloads: t +;; coding: utf-8 ;; End: ;;; avy-autoloads.el ends here diff --git a/elpa/avy-20181009.1648/avy-pkg.el b/elpa/avy-20181009.1648/avy-pkg.el new file mode 100644 index 00000000..c14b2f0a --- /dev/null +++ b/elpa/avy-20181009.1648/avy-pkg.el @@ -0,0 +1,2 @@ +;;; -*- no-byte-compile: t -*- +(define-package "avy" "20181009.1648" "Jump to arbitrary positions in visible text and select text quickly." '((emacs "24.1") (cl-lib "0.5")) :commit "df4c4ac488ee59bc44f8658d9fcca0c86fb32c5c" :keywords '("point" "location") :authors '(("Oleh Krehel" . "ohwoeowho@gmail.com")) :maintainer '("Oleh Krehel" . "ohwoeowho@gmail.com") :url "https://github.com/abo-abo/avy") diff --git a/elpa/avy-20171230.220/avy.el b/elpa/avy-20181009.1648/avy.el similarity index 92% rename from elpa/avy-20171230.220/avy.el rename to elpa/avy-20181009.1648/avy.el index 9ddf2399..be6a9b5a 100644 --- a/elpa/avy-20171230.220/avy.el +++ b/elpa/avy-20181009.1648/avy.el @@ -4,7 +4,7 @@ ;; Author: Oleh Krehel ;; URL: https://github.com/abo-abo/avy -;; Package-Version: 20171230.220 +;; Package-Version: 20181009.1648 ;; Version: 0.4.0 ;; Package-Requires: ((emacs "24.1") (cl-lib "0.5")) ;; Keywords: point, location @@ -79,29 +79,39 @@ keys different than the following: a, e, i, o, u, y" (character :tag "char") (symbol :tag "non-printing key")))) +(defconst avy--key-type + '(choice :tag "Command" + (const avy-goto-char) + (const avy-goto-char-2) + (const avy-isearch) + (const avy-goto-line) + (const avy-goto-subword-0) + (const avy-goto-subword-1) + (const avy-goto-word-0) + (const avy-goto-word-1) + (const avy-copy-line) + (const avy-copy-region) + (const avy-move-line) + (const avy-move-region) + (const avy-kill-whole-line) + (const avy-kill-region) + (const avy-kill-ring-save-whole-line) + (const avy-kill-ring-save-region) + (function :tag "Other command"))) + (defcustom avy-keys-alist nil "Alist of avy-jump commands to `avy-keys' overriding the default `avy-keys'." - :type '(alist - :key-type (choice :tag "Command" - (const avy-goto-char) - (const avy-goto-char-2) - (const avy-isearch) - (const avy-goto-line) - (const avy-goto-subword-0) - (const avy-goto-subword-1) - (const avy-goto-word-0) - (const avy-goto-word-1) - (const avy-copy-line) - (const avy-copy-region) - (const avy-move-line) - (const avy-move-region) - (const avy-kill-whole-line) - (const avy-kill-region) - (const avy-kill-ring-save-whole-line) - (const avy-kill-ring-save-region) - (function :tag "Other command")) + :type `(alist + :key-type ,avy--key-type :value-type (repeat :tag "Keys" character))) +(defcustom avy-orders-alist '((avy-goto-char . avy-order-closest)) + "Alist of candidate ordering functions. +Usually, candidates appear in their point position order." + :type `(alist + :key-type ,avy--key-type + :value-type function)) + (defcustom avy-words '("am" "by" "if" "is" "it" "my" "ox" "up" "ace" "act" "add" "age" "ago" "aim" "air" "ale" "all" "and" "ant" "any" @@ -183,7 +193,8 @@ If the commands isn't on the list, `avy-style' is used." (?m . avy-action-mark) (?n . avy-action-copy) (?y . avy-action-yank) - (?i . avy-action-ispell)) + (?i . avy-action-ispell) + (?z . avy-action-zap-to-char)) "List of actions for `avy-handler-default'. Each item is (KEY . ACTION). When KEY not on `avy-keys' is @@ -234,6 +245,16 @@ When nil, punctuation chars will not be matched. Typically, these modes don't use the text representation." :type 'list) +(defcustom avy-single-candidate-jump t + "In case there is only one candidate jumps directly to it." + :type 'boolean) + +(defcustom avy-del-last-char-by '(8 127) + "List of event types, i.e. key presses, that delete the last +character read. The default represents `C-h' and `DEL'. See +`event-convert-list'." + :type 'list) + (defvar avy-ring (make-ring 20) "Hold the window and point history.") @@ -362,11 +383,22 @@ SEQ-LEN is how many elements of KEYS it takes to identify a match." lst (cdr lst)))))) (nreverse path-alist))) +(defun avy-order-closest (x) + (abs (- (caar x) (point)))) + +(defvar avy-command nil + "Store the current command symbol. +E.g. 'avy-goto-line or 'avy-goto-char.") + (defun avy-tree (lst keys) "Coerce LST into a balanced tree. The degree of the tree is the length of KEYS. KEYS are placed appropriately on internal nodes." - (let ((len (length keys))) + (let* ((len (length keys)) + (order-fn (cdr (assq avy-command avy-orders-alist))) + (lst (if order-fn + (cl-sort lst #'< :key order-fn) + lst))) (cl-labels ((rd (ls) (let ((ln (length ls))) @@ -605,10 +637,6 @@ multiple DISPLAY-FN invocations." Commands using `avy-with' macro can be resumed." (interactive)) -(defvar avy-command nil - "Store the current command symbol. -E.g. 'avy-goto-line or 'avy-goto-char.") - (defmacro avy-with (command &rest body) "Set `avy-keys' according to COMMAND and execute BODY. Set `avy-style' according to COMMMAND as well." @@ -688,6 +716,12 @@ Set `avy-style' according to COMMMAND as well." (ring-ref avy-ring 0))) t) +(defun avy-action-zap-to-char (pt) + "Kill from point up to PT." + (if (> pt (point)) + (kill-region (point) pt) + (kill-region pt (point)))) + (defun avy-action-teleport (pt) "Kill sexp starting on PT and yank into the current location." (avy-action-kill-stay pt) @@ -719,6 +753,29 @@ Set `avy-style' according to COMMMAND as well." (when (looking-at-p "\\b") (ispell-word))))))) +(defun avy--process-1 (candidates overlay-fn) + (let ((len (length candidates))) + (cond ((= len 0) + nil) + ((and (= len 1) avy-single-candidate-jump) + (car candidates)) + (t + (unwind-protect + (progn + (avy--make-backgrounds + (avy-window-list)) + (cond ((eq avy-style 'de-bruijn) + (avy-read-de-bruijn + candidates avy-keys)) + ((eq avy-style 'words) + (avy-read-words + candidates avy-words)) + (t + (avy-read (avy-tree candidates avy-keys) + overlay-fn + #'avy--remove-leading-chars)))) + (avy--done)))))) + (defun avy--process (candidates overlay-fn) "Select one of CANDIDATES using `avy-read'. Use OVERLAY-FN to visualize the decision overlay." @@ -727,47 +784,31 @@ Use OVERLAY-FN to visualize the decision overlay." (setq candidates (mapcar (lambda (x) (cons x (selected-window))) candidates))) - (let ((len (length candidates)) - (cands (copy-sequence candidates)) - res) - (if (= len 0) - (message "zero candidates") - (if (= len 1) - (setq res (car candidates)) - (unwind-protect - (progn - (avy--make-backgrounds - (avy-window-list)) - (setq res (cond ((eq avy-style 'de-bruijn) - (avy-read-de-bruijn - candidates avy-keys)) - ((eq avy-style 'words) - (avy-read-words - candidates avy-words)) - (t - (avy-read (avy-tree candidates avy-keys) - overlay-fn - #'avy--remove-leading-chars))))) - (avy--done))) - (cond ((eq res 'restart) - (avy--process cands overlay-fn)) - ;; ignore exit from `avy-handler-function' - ((eq res 'exit)) - (t - (avy-push-mark) - (when (and (consp res) - (windowp (cdr res))) - (let* ((window (cdr res)) - (frame (window-frame window))) - (unless (equal frame (selected-frame)) - (select-frame-set-input-focus frame)) - (select-window window)) - (setq res (car res))) - - (funcall (or avy-action 'avy-action-goto) - (if (consp res) - (car res) - res))))))) + (let ((original-cands (copy-sequence candidates)) + (res (avy--process-1 candidates overlay-fn))) + (cond + ((null res) + (message "zero candidates") + t) + ((eq res 'restart) + (avy--process original-cands overlay-fn)) + ;; ignore exit from `avy-handler-function' + ((eq res 'exit)) + (t + (avy-push-mark) + (when (and (consp res) + (windowp (cdr res))) + (let* ((window (cdr res)) + (frame (window-frame window))) + (unless (equal frame (selected-frame)) + (select-frame-set-input-focus frame)) + (select-window window)) + (setq res (car res))) + + (funcall (or avy-action 'avy-action-goto) + (if (consp res) + (car res) + res)))))) (defvar avy--overlays-back nil "Hold overlays for when `avy-background' is t.") @@ -1335,13 +1376,14 @@ This variable is used by `avy-goto-subword-0' and `avy-goto-subword-1'." :type '(repeat character)) ;;;###autoload -(defun avy-goto-subword-0 (&optional arg predicate) +(defun avy-goto-subword-0 (&optional arg predicate beg end) "Jump to a word or subword start. - The window scope is determined by `avy-all-windows' (ARG negates it). When PREDICATE is non-nil it's a function of zero parameters that -should return true." +should return true. + +BEG and END narrow the scope where candidates are searched." (interactive "P") (require 'subword) (avy-with avy-goto-subword-0 @@ -1354,10 +1396,10 @@ should return true." (dolist (char avy-subword-extra-word-chars) (modify-syntax-entry char "w" syn-tbl)) (with-syntax-table syn-tbl - (let ((ws (window-start)) + (let ((ws (or beg (window-start))) window-cands) (save-excursion - (goto-char (window-end (selected-window) t)) + (goto-char (or end (window-end (selected-window) t))) (subword-backward) (while (> (point) ws) (when (or (null predicate) @@ -1398,11 +1440,16 @@ Which one depends on variable `subword-mode'." (defvar visual-line-mode) -(defun avy--line-cands (&optional arg beg end) +(defcustom avy-indent-line-overlay nil + "When non-nil, `avy-goto-line' will display the line overlay next to the first non-whitespace character of each line." + :type 'boolean) + +(defun avy--line-cands (&optional arg beg end bottom-up) "Get candidates for selecting a line. The window scope is determined by `avy-all-windows'. When ARG is non-nil, do the opposite of `avy-all-windows'. -BEG and END narrow the scope where candidates are searched." +BEG and END narrow the scope where candidates are searched. +When BOTTOM-UP is non-nil, display avy candidates from top to bottom" (let (candidates) (avy-dowindows arg (let ((ws (or beg (window-start)))) @@ -1416,14 +1463,19 @@ BEG and END narrow the scope where candidates are searched." (push (cons (if (eq avy-style 'post) (line-end-position) - (point)) + (save-excursion + (when avy-indent-line-overlay + (skip-chars-forward " \t")) + (point))) (selected-window)) candidates)) (if visual-line-mode (progn (setq temporary-goal-column 0) (line-move-visual 1 t)) (forward-line 1))))))) - (nreverse candidates))) + (if bottom-up + candidates + (nreverse candidates)))) (defun avy--linum-strings () "Get strings for `avy-linum-mode'." @@ -1508,14 +1560,15 @@ BEG and END narrow the scope where candidates are searched." (frame-char-width))))) (set-window-margins win width (cdr (window-margins win))))) -(defun avy--line (&optional arg beg end) +(defun avy--line (&optional arg beg end bottom-up) "Select a line. The window scope is determined by `avy-all-windows'. When ARG is non-nil, do the opposite of `avy-all-windows'. -BEG and END narrow the scope where candidates are searched." +BEG and END narrow the scope where candidates are searched. +When BOTTOM-UP is non-nil, display avy candidates from top to bottom" (let ((avy-action #'identity)) (avy--process - (avy--line-cands arg beg end) + (avy--line-cands arg beg end bottom-up) (if avy-linum-mode (progn (message "Goto line:") 'ignore) @@ -1559,23 +1612,35 @@ Otherwise, forward to `goto-line' with ARG." (avy-action-goto r)))))) ;;;###autoload -(defun avy-goto-line-above () - "Goto visible line above the cursor." +(defun avy-goto-line-above (&optional offset bottom-up) + "Goto visible line above the cursor. +OFFSET changes the distance between the closest key to the cursor and +the cursor +When BOTTOM-UP is non-nil, display avy candidates from top to bottom" (interactive) + (if offset + (setq offset (+ 2 (- offset)))) (let* ((avy-all-windows nil) (r (avy--line nil (window-start) - (line-beginning-position)))) + (line-beginning-position (or offset 1)) + bottom-up))) (unless (eq r t) (avy-action-goto r)))) ;;;###autoload -(defun avy-goto-line-below () - "Goto visible line below the cursor." +(defun avy-goto-line-below (&optional offset bottom-up) + "Goto visible line below the cursor. +OFFSET changes the distance between the closest key to the cursor and +the cursor +When BOTTOM-UP is non-nil, display avy candidates from top to bottom" (interactive) + (if offset + (setq offset (+ offset 1))) (let* ((avy-all-windows nil) (r (avy--line - nil (line-beginning-position 2) - (window-end (selected-window) t)))) + nil (line-beginning-position (or offset 2)) + (window-end (selected-window) t) + bottom-up))) (unless (eq r t) (avy-action-goto r)))) @@ -1585,6 +1650,13 @@ Otherwise, forward to `goto-line' with ARG." (const :tag "Above" above) (const :tag "Below" below))) +;;;###autoload +(defun avy-goto-end-of-line (&optional arg) + "Call `avy-goto-line' and move to the end of the line." + (interactive "p") + (avy-goto-line arg) + (end-of-line)) + ;;;###autoload (defun avy-copy-line (arg) "Copy a selected line above the current line. @@ -1817,8 +1889,9 @@ newline." (defun avy--read-candidates (&optional re-builder) "Read as many chars as possible and return their occurrences. At least one char must be read, and then repeatedly one next char -may be read if it is entered before `avy-timeout-seconds'. `C-h' -or `DEL' deletes the last char entered, and `RET' exits with the +may be read if it is entered before `avy-timeout-seconds'. Any +key defined in `avy-del-last-char-by' (by default `C-h' and `DEL') +deletes the last char entered, and `RET' exits with the currently read string immediately instead of waiting for another char for `avy-timeout-seconds'. The format of the result is the same as that of `avy--regex-candidates'. @@ -1834,7 +1907,8 @@ Otherwise, the whole regex is highlighted." (progn (while (and (not break) (setq char - (read-char (format "char%s: " + (read-char (format "%d char%s: " + (length overlays) (if (string= str "") str (format " (%s)" str))) @@ -1852,10 +1926,13 @@ Otherwise, the whole regex is highlighted." (setq break t) (setq str (concat str (list ?\n))))) ;; Handle C-h, DEL - ((memq char '(8 127)) + ((memq char avy-del-last-char-by) (let ((l (length str))) (when (>= l 1) (setq str (substring str 0 (1- l)))))) + ;; Handle ESC + ((= char 27) + (keyboard-quit)) (t (setq str (concat str (list char))))) ;; Highlight -- 2.47.3