如何在emacs-lisp中捕获字符串中替换regexp的结果



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

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

然而,在我的Scratch缓冲区中对此进行评估显示,没有删除任何空间。。

这里有一个更正:

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

interactive只对交互式命令有用,所以这里不需要它。还注意到评估顺序。

最新更新