如何在emacs lisp中捕获replace-regexp-in-string的结果

时间:2013-12-02 16:25:06

标签: emacs elisp

我正在努力学习Emacs Lisp。我想从字符串中删除一些空格。我从以下测试用例开始:

(defun test-fun (str)
  (interactive)
  (let ((ss str)) 
       (replace-regexp-in-string "[ ]+" "" ss)
    (message ss)))
(test-fun "He   llo")

但是,在我的Scratch缓冲区中对此进行评估表明没有删除空格..

1 个答案:

答案 0 :(得分:2)

这是一个更正:

(defun test-fun (str)
  (let ((ss (replace-regexp-in-string "[ ]+" "" str)))
    (message ss)))

interactive仅对交互式命令有用,因此您不需要它。 另请注意评估顺序。