我想在 using 处插入 kill-ring 的内容(yank)
,但是如果在被拉出的文本的开头有空格,则应在插入前将其删除。
如何才能做到这一点?
(我看过save-excursion
但re-search-backward
无法让它工作)..
你可以试试
(defun my-yank ()
(interactive)
(let ((start (point)))
(call-interactively 'yank)
(let ((end (point)))
(save-excursion
(goto-char start)
(delete-region (point)
(progn (skip-chars-forward " \t" end) (point)))))))
这是一个可能的解决方案
(defun yank-no-spaces (&optional arg)
(interactive "*P")
(yank arg)
(save-restriction
(save-excursion
(narrow-to-region (point) (mark))
(goto-char (point-min))
(just-one-space 0))))