想到了,先kill一下再undo-tree-undo
,计算一下kill前后buffer的总长度,测试了一下这样不支持visual-state,normal-state和operator-state都行:
(defun jjpandari/goto-kill-end (kill-fun forward?)
"When supplied with a kill function `kill-fun', go to the point the kill function kills to."
(let* ((old-max (point-max))
(new-max (progn (funcall kill-fun) (point-max)))
(kill-end (progn
(undo-tree-undo)
(funcall (if forward? '+ '-) (point) (abs (- new-max old-max))))))
(goto-char kill-end)))
(defun jjpandari/goto-end-of-sexp ()
"Go to the end of current expression."
(interactive)
(jjpandari/goto-kill-end 'paredit-kill+ t))
(defun jjpandari/goto-beginning-of-sexp ()
"Go to the end of current expression."
(interactive)
(jjpandari/goto-kill-end 'fontux/paredit-kill-backward nil))
paredit-kill+
和fontux/paredit-kill-backward
看这个帖子
另外elisp风格的变量forward?
应该叫forwardp
?但是我看p
结尾的好像都是函数,不知道变量应该怎么取名。