mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 21:13:04 +00:00
overlapped snippet navigation.
This commit is contained in:
parent
d781580ab0
commit
fb5bc52bb6
24
yasnippet.el
24
yasnippet.el
@ -251,6 +251,7 @@ will be deleted before inserting template."
|
|||||||
|
|
||||||
(let ((key (buffer-substring-no-properties start end))
|
(let ((key (buffer-substring-no-properties start end))
|
||||||
(original-undo-list buffer-undo-list)
|
(original-undo-list buffer-undo-list)
|
||||||
|
(inhibit-modification-hooks t)
|
||||||
(length (- end start))
|
(length (- end start))
|
||||||
(column (current-column)))
|
(column (current-column)))
|
||||||
(save-restriction
|
(save-restriction
|
||||||
@ -405,6 +406,23 @@ will be deleted before inserting template."
|
|||||||
(setq snippet-overlay overlay)))))
|
(setq snippet-overlay overlay)))))
|
||||||
snippet-overlay))
|
snippet-overlay))
|
||||||
|
|
||||||
|
(defun yas/current-overlay-for-navigation ()
|
||||||
|
"Get current overlay for navigation. Might be overlay at current or previous point."
|
||||||
|
(let ((overlay1 (yas/current-snippet-overlay))
|
||||||
|
(overlay2 (if (bobp)
|
||||||
|
nil
|
||||||
|
(yas/current-snippet-overlay (- (point) 1)))))
|
||||||
|
(if (null overlay1)
|
||||||
|
overlay2
|
||||||
|
(if (or (null overlay2)
|
||||||
|
(eq (overlay-get overlay1 'yas/snippet)
|
||||||
|
(overlay-get overlay2 'yas/snippet)))
|
||||||
|
overlay1
|
||||||
|
(if (> (yas/snippet-id (overlay-get overlay2 'yas/snippet))
|
||||||
|
(yas/snippet-id (overlay-get overlay1 'yas/snippet)))
|
||||||
|
overlay2
|
||||||
|
overlay1)))))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; User level functions
|
;; User level functions
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
@ -427,8 +445,7 @@ otherwise, nil returned."
|
|||||||
(defun yas/next-field-group ()
|
(defun yas/next-field-group ()
|
||||||
"Navigate to next field group. If there's none, exit the snippet."
|
"Navigate to next field group. If there's none, exit the snippet."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((overlay (or (yas/current-snippet-overlay)
|
(let ((overlay (yas/current-overlay-for-navigation)))
|
||||||
(yas/current-snippet-overlay (- (point) 1)))))
|
|
||||||
(if overlay
|
(if overlay
|
||||||
(let ((next (yas/group-next
|
(let ((next (yas/group-next
|
||||||
(overlay-get overlay 'yas/group))))
|
(overlay-get overlay 'yas/group))))
|
||||||
@ -442,8 +459,7 @@ otherwise, nil returned."
|
|||||||
(defun yas/prev-field-group ()
|
(defun yas/prev-field-group ()
|
||||||
"Navigate to prev field group. If there's none, exit the snippet."
|
"Navigate to prev field group. If there's none, exit the snippet."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((overlay (or (yas/current-snippet-overlay)
|
(let ((overlay (yas/current-overlay-for-navigation)))
|
||||||
(yas/current-snippet-overlay (- (point) 1)))))
|
|
||||||
(if overlay
|
(if overlay
|
||||||
(let ((prev (yas/group-prev
|
(let ((prev (yas/group-prev
|
||||||
(overlay-get overlay 'yas/group))))
|
(overlay-get overlay 'yas/group))))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user