Emacs: fixed skeleton-next-position

master
Pierre Neidhardt 2014-03-09 20:13:42 +01:00
parent 86633e6fbd
commit a4202b35c3
1 changed files with 11 additions and 12 deletions

View File

@ -359,24 +359,23 @@ Hook function for skeletons."
(set-marker (pop skeleton-markers) nil)) (set-marker (pop skeleton-markers) nil))
(setq skeleton-markers (setq skeleton-markers
(mapcar 'copy-marker (reverse skeleton-positions)))) (mapcar 'copy-marker (reverse skeleton-positions))))
;; TODO: skeleton move reverse does not work properly.
(defun skeleton-next-position (&optional reverse) (defun skeleton-next-position (&optional reverse)
"Skeleton movements through placeholders." "Skeleton movements through placeholders."
(interactive "P") (interactive "P")
(let ((positions (mapcar 'marker-position skeleton-markers)) (let ((positions (mapcar 'marker-position skeleton-markers))
(comp (if reverse '> '<)) (comp (if reverse '< '<=))
pos) pos prev)
(when positions (when positions
(if (catch 'break (setq pos (pop positions))
(while (setq pos (pop positions)) (while (and pos (funcall comp pos (point)))
(when (funcall comp (point) pos) (setq prev pos)
(throw 'break t)))) (setq pos (pop positions)))
(goto-char pos) (cond
(goto-char (marker-position ((and reverse prev) (goto-char prev))
(if reverse (reverse (goto-char (car (last skeleton-markers))))
(car (last skeleton-markers)) (pos (goto-char pos))
(car skeleton-markers)))))))) (t (goto-char (car skeleton-markers)))))))
;; Do not expand abbrevs in skeletons. Not sure it is useful. ;; Do not expand abbrevs in skeletons. Not sure it is useful.
;; (setq skeleton-further-elements '((abbrev-mode nil))) ;; (setq skeleton-further-elements '((abbrev-mode nil)))