我想使用(yank)
在点处插入kill-ring的内容,但是如果在yanked文本的开头有空格,则应在插入之前将其删除。
如何做到这一点?
(我查看了save-excursion
和re-search-backward
,但无法让它发挥作用)..
答案 0 :(得分:2)
你可以尝试
(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)))))))
答案 1 :(得分:1)
这是一个可能的解决方案
(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))))