mirror of
https://github.com/abo-abo/avy.git
synced 2025-10-15 06:03:04 +00:00
avy.el (avy-pop-mark): use own history for points and windows
* avy.el (avy-action-goto): Don't save mark here, since the window was already changed. (avy--process): Set mark here. (avy-ring): New defvar. (avy-push-mark): New defun. (avy-pop-mark): Use `avy-ring' unless it's empty. Then use the mark ring. Fixes #88 Re #69 Re #81
This commit is contained in:
parent
1e578a147a
commit
a86bdee66c
27
avy.el
27
avy.el
@ -47,6 +47,7 @@
|
|||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
(require 'cl-lib)
|
(require 'cl-lib)
|
||||||
|
(require 'ring)
|
||||||
|
|
||||||
;;* Customization
|
;;* Customization
|
||||||
(defgroup avy nil
|
(defgroup avy nil
|
||||||
@ -452,9 +453,6 @@ Set `avy-style' according to COMMMAND as well."
|
|||||||
|
|
||||||
(defun avy-action-goto (pt)
|
(defun avy-action-goto (pt)
|
||||||
"Goto PT."
|
"Goto PT."
|
||||||
(unless (or (= pt (point))
|
|
||||||
(region-active-p))
|
|
||||||
(push-mark))
|
|
||||||
(goto-char pt))
|
(goto-char pt))
|
||||||
|
|
||||||
(defun avy-action-mark (pt)
|
(defun avy-action-mark (pt)
|
||||||
@ -506,6 +504,7 @@ Use OVERLAY-FN to visualize the decision overlay."
|
|||||||
;; ignore exit from `avy-handler-function'
|
;; ignore exit from `avy-handler-function'
|
||||||
((eq res 'exit))
|
((eq res 'exit))
|
||||||
(t
|
(t
|
||||||
|
(avy-push-mark)
|
||||||
(when (and (consp res)
|
(when (and (consp res)
|
||||||
(windowp (cdr res)))
|
(windowp (cdr res)))
|
||||||
(let* ((window (cdr res))
|
(let* ((window (cdr res))
|
||||||
@ -944,7 +943,7 @@ The window scope is determined by `avy-all-windows' (ARG negates it)."
|
|||||||
(let ((line (read-from-minibuffer
|
(let ((line (read-from-minibuffer
|
||||||
"Goto line: " (string char))))
|
"Goto line: " (string char))))
|
||||||
(when line
|
(when line
|
||||||
(push-mark)
|
(avy-push-mark)
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(forward-line (1- (string-to-number line)))
|
(forward-line (1- (string-to-number line)))
|
||||||
(throw 'done 'exit))))))
|
(throw 'done 'exit))))))
|
||||||
@ -1028,10 +1027,26 @@ The window scope is determined by `avy-all-windows' (ARG negates it)."
|
|||||||
arg
|
arg
|
||||||
avy-style))))
|
avy-style))))
|
||||||
|
|
||||||
|
(defvar avy-ring (make-ring 20)
|
||||||
|
"Hold the window and point history.")
|
||||||
|
|
||||||
|
(defun avy-push-mark ()
|
||||||
|
"Store the current point and window."
|
||||||
|
(ring-insert avy-ring
|
||||||
|
(cons (point) (selected-window))))
|
||||||
|
|
||||||
(defun avy-pop-mark ()
|
(defun avy-pop-mark ()
|
||||||
"Jump back to the last location of `push-mark'."
|
"Jump back to the last location of `avy-push-mark'."
|
||||||
(interactive)
|
(interactive)
|
||||||
(set-mark-command 4))
|
(let (res)
|
||||||
|
(condition-case nil
|
||||||
|
(progn
|
||||||
|
(while (not (window-live-p
|
||||||
|
(cdr (setq res (ring-remove avy-ring 0))))))
|
||||||
|
(select-window (cdr res))
|
||||||
|
(goto-char (car res)))
|
||||||
|
(error
|
||||||
|
(set-mark-command 4)))))
|
||||||
|
|
||||||
(define-obsolete-function-alias
|
(define-obsolete-function-alias
|
||||||
'avy--goto 'identity "0.3.0"
|
'avy--goto 'identity "0.3.0"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user