helm补全界面, 如果用户输入的内容没有匹配项, 并且回车, 这种情况的处理可以自定义吗?

helm默认行为好像就是退出, 什么也不做. 有没有接口可以自定义这种情况的处理? 比如调用一个用户指定的函数?

由相应的 Helm 自行处理,比如 helm-mini 中创建新 Buffer,其利用一个 dummy source,如:

(helm
 :sources
 (list
  (helm-build-sync-source "Names" :candidates '("Alice" "Bob"))
  (helm-build-dummy-source "New Name")))

我解决过类似的问题。

大概的情形是,helm 补全上屏的内容是裸的 snippet,没有展开。我拦截了 completion-at-point 对插入内容进行处理,因为 helm 菜单关闭后必然会回到 point:

(define-advice completion-at-point (:around (fn) expand-snippet)
  (let ((beg (point)))
    (funcall fn)
    (let* ((end (point))
           (str (replace-regexp-in-string
                 "${0}\\'"
                 "$0"
                 (buffer-substring-no-properties beg end))))
      (when (string-suffix-p "$0" str)
        (yas-expand-snippet str beg end)))))

如果你想要在没有匹配的时候阻止 helm 退出,这个方法就不适用了。

上午最后也是用了这个方法,还不错

可以参考楼上的方法

我明白你的需求了,要在 helm 退出之前进行处理,跟 helm-mini 是一样的。

是的, 不过我平时不用helm的一大堆自带命令, 只用了imenu, helm主要当作库来用.