欢迎试用 blink-search

其中google suggestion是只提供建议,还是可以用enter 打开chrome浏览器搜索?

目前是用 EAF 浏览器打开, 你可以定制 blink-search-browser-function 选项, 用你喜欢的浏览器打开 google 建议。

设置成下面时,没有反应?

(setq blink-search-browser-function 'browse-url-default-macosx-browser/browse-url-xdg-open)
1 个赞

自己先折腾吧,首先看看你的函数能不能打开一个url?

试用了下,确实快到不行,相当的爽 :joy: 。就是想问下自己加 backend 容易吗?因为粗看了一眼代码,似乎 backend 都是写死的? 我在 snails 里加了个自己写的 db 实现的 recentf ,效果如下图

比较特殊的地方大概有

  1. 以树的方式实现,所以顺序不能乱,这个似乎放在右侧相当合适?
  2. 可以用 / 为前缀过滤文件夹
  3. 每个文件共同的前缀会被提到父节点上,但要打开文件时还是需要找完整路径,比如例子第二行的 API-specification ,完整路径是 /home/weiss/weiss/digiVine/API-specification ,我在 snails 里是把这种搞成 API-specification &特殊符号& /home/weiss/weiss/digiVine/API-specification ,显示的时候只显示 &特殊符号& 左边,打开的时候看右边。不知道在 blink-search 里有什么实现方法?

自己写backend比较容易,但是要你探索下

我发现在 backend 的 el 文件中,一些后端使用 blink-search-call-async 调用函数。 其中有:


./blink-search-recent-file.el:100:      (blink-search-call-async "search_recent_file_update" (mapcar #'substring-no-properties recentf-list))
./blink-search-buffer-list.el:90:        (blink-search-call-async "search_sort_buffer_list_update" (mapcar #'buffer-name (append sort-tab-visible-buffers (buffer-list))))
./blink-search-buffer-list.el:91:      (blink-search-call-async "search_buffer_list_update" (mapcar #'buffer-name (buffer-list))))))
./blink-search-grep-pdf.el:37:    (blink-search-call-async "search_init_grep_pdf"
./blink-search-elisp-symbol.el:109:      (blink-search-call-async "search_elisp_symbol_update" symbols)
./blink-search-current-buffer.el:89:    (blink-search-call-async "search_init_current_buffer"
./blink-search-imenu.el:89:    (blink-search-call-async "search_imenu_update"

但是我发现 “search_recent_file_update” ,“search_sort_buffer_list_update” ,“search_buffer_list_update” ,“search_init_grep_pdf”,“search_elisp_symbol_update” , “search_init_current_buffer”, “search_imenu_update” 这些在 blink-search 包中所有的 Python 文件中都没有定义。

我很头大,难道有什么神奇魔法创造了这些函数吗?我看漏什么? 感觉在相关的后端 Python 文件中确实存在一些名字和以上接近的函数, 例如 /Users/c/emacs-config/default/elpa/28.2/develop/blink-search-20230207.210232/backend/search_grep_pdf.py 中:

    def init_dir(self, search_dir):
        self.search_paths = get_emacs_var("blink-search-grep-pdf-search-paths")
        self.search_paths = self.search_paths if self.search_paths else search_dir
        if type(self.search_paths) is str:
            self.search_paths = [self.search_paths]


/Users/c/emacs-config/default/elpa/28.2/develop/blink-search-20230207.210232/backend/blink-search-grep-pdf.el 中:

(defun blink-search-init-grep-pdf ()
  (when (blink-search-epc-live-p blink-search-epc-process)
    (blink-search-call-async "search_init_grep_pdf"
                             blink-search-grep-pdf-search-path)))

def init_dir 和 search_init_grep_pdf 就很像,同时 defun init_dir 定义的形参和

(blink-search-call-async "search_init_grep_pdf"
                             blink-search-grep-pdf-search-path)

调用具体的参数也对应得上。

但是为什么 init_dir 名字变成上面 search_init_grep_pdf 的可以被 blink-search-call-async 调用。求懒猫解惑。

今晚喝酒了,周末答你

看这行源码

我看明白了,所有以 update 结尾的都是 build_update_interface 新创建的。

“search_init_current_buffer” 也在 blink_search.py 文件中定义。

def search_init_current_buffer(self, buffer_name, buffer_content):
        self.search_start_buffer_name = buffer_name
        self.search_current_buffer.init_buffer(buffer_name, buffer_content)

最后剩下的一个 “search_init_grep_pdf” 应该是没有定义的, 所以

(defun blink-search-init-grep-pdf ()
  (when (blink-search-epc-live-p blink-search-epc-process)
    (blink-search-call-async "search_init_grep_pdf"
                             blink-search-grep-pdf-search-path)))

就没有意义。 应该删除吧。

我删除了,好像没有影响使用。

今天增加了一个 History 后端 Add history backend. · manateelazycat/blink-search@895239a · GitHub

就是 blink-search 会记录所有成功执行的命令, 方便下次再次搜索同样的命令, 提高命中率。

3 个赞

非常实用的功能

blink-search 已经有了 grep pdf 的后端,可以搜索PDF目录下所有PDF文件的关键字。

今天写了一个新的 PDF 后端, 只要当前 buffer 是一个 pdf 文件, PDF后端只会搜索当前 PDF 的文件内容。

如截图所示:

1 个赞

给PDF后端增加了 : prefix, 按 ; 前缀搜索所有PDF文件, 按 : 前缀搜索只搜索当前 PDF 文件。

1 个赞

话说 lsp bridge 和 blink search 这种可不可以直接把 python 相关的依赖放到库里不需要再安装的?

功能不同,没法提取共有库,python就是文件而已,不必太在意这些,git管理最简单。

调出 Blink-Search 总是大片空白, 卡住不动.

我自己用的系统是 macOS Sonoma, 之前已经安装过 eaf 的依赖, 还有 Blink-Search 的依赖也全部安装成功了.

我用 Doom Emacs, 版本是 29.1.

通过 toggle-error-and-bug 返回了错误信息, 希望大佬可以帮忙解读一下, 定位问题:

Debugger entered--Lisp error: (wrong-type-argument blink-search-epc-manager nil)
  signal(wrong-type-argument (blink-search-epc-manager nil))
  (or (progn (and (memq (type-of mngr) cl-struct-blink-search-epc-manager-tags) t)) (signal 'wrong-type-argument (list 'blink-search-epc-manager mngr)))
  (progn (or (progn (and (memq (type-of mngr) cl-struct-blink-search-epc-manager-tags) t)) (signal 'wrong-type-argument (list 'blink-search-epc-manager mngr))) (aref mngr 7))
  (let ((uid (blink-search-epc-uid)) (sessions (progn (or (progn (and (memq ... cl-struct-blink-search-epc-manager-tags) t)) (signal 'wrong-type-argument (list 'blink-search-epc-manager mngr))) (aref mngr 7))) (d (blink-search-deferred-new))) (setq sessions (cons (cons uid d) sessions)) (progn (or (progn (and (memq (type-of mngr) cl-struct-blink-search-epc-manager-tags) t)) (signal 'wrong-type-argument (list 'blink-search-epc-manager mngr))) (let* ((v mngr)) (aset v 7 sessions))) (blink-search-epc-manager-send mngr 'call uid method-name args) d)
  blink-search-epc-call-deferred(nil search ("n" 18 nil))
  (setq it (blink-search-epc-call-deferred blink-search-epc-process (read method) args))
  (let (it) (setq it (blink-search-epc-call-deferred blink-search-epc-process (read method) args)) it)
  blink-search-call-async("search" "n" 18 nil)
  (cond ((or (string-prefix-p "#" input) (string-prefix-p "#" input)) (blink-search-call-async "search" (substring input 1) (blink-search-get-row-number) (list "Current Buffer"))) ((or (string-prefix-p "!" input) (string-prefix-p "!" input)) (blink-search-call-async "search" (substring input 1) (blink-search-get-row-number) (list "Grep File"))) ((or (string-prefix-p ";" input) (string-prefix-p ";" input)) (blink-search-call-async "search" (substring input 1) (blink-search-get-row-number) (list "Grep PDF"))) ((or (string-prefix-p ":" input) (string-prefix-p ":" input)) (blink-search-call-async "search" (substring input 1) (blink-search-get-row-number) (list "PDF"))) (t (blink-search-call-async "search" input (blink-search-get-row-number) blink-search-search-backends)))
  (let* ((input (string-trim (save-current-buffer (set-buffer blink-search-input-buffer) (buffer-substring-no-properties (point-min) (point-max)))))) (cond ((or (string-prefix-p "#" input) (string-prefix-p "#" input)) (blink-search-call-async "search" (substring input 1) (blink-search-get-row-number) (list "Current Buffer"))) ((or (string-prefix-p "!" input) (string-prefix-p "!" input)) (blink-search-call-async "search" (substring input 1) (blink-search-get-row-number) (list "Grep File"))) ((or (string-prefix-p ";" input) (string-prefix-p ";" input)) (blink-search-call-async "search" (substring input 1) (blink-search-get-row-number) (list "Grep PDF"))) ((or (string-prefix-p ":" input) (string-prefix-p ":" input)) (blink-search-call-async "search" (substring input 1) (blink-search-get-row-number) (list "PDF"))) (t (blink-search-call-async "search" input (blink-search-get-row-number) blink-search-search-backends))))
  (progn (let* ((input (string-trim (save-current-buffer (set-buffer blink-search-input-buffer) (buffer-substring-no-properties (point-min) (point-max)))))) (cond ((or (string-prefix-p "#" input) (string-prefix-p "#" input)) (blink-search-call-async "search" (substring input 1) (blink-search-get-row-number) (list "Current Buffer"))) ((or (string-prefix-p "!" input) (string-prefix-p "!" input)) (blink-search-call-async "search" (substring input 1) (blink-search-get-row-number) (list "Grep File"))) ((or (string-prefix-p ";" input) (string-prefix-p ";" input)) (blink-search-call-async "search" (substring input 1) (blink-search-get-row-number) (list "Grep PDF"))) ((or (string-prefix-p ":" input) (string-prefix-p ":" input)) (blink-search-call-async "search" (substring input 1) (blink-search-get-row-number) (list "PDF"))) (t (blink-search-call-async "search" input (blink-search-get-row-number) blink-search-search-backends)))))
  (if (string-equal (buffer-name) blink-search-input-buffer) (progn (let* ((input (string-trim (save-current-buffer (set-buffer blink-search-input-buffer) (buffer-substring-no-properties ... ...))))) (cond ((or (string-prefix-p "#" input) (string-prefix-p "#" input)) (blink-search-call-async "search" (substring input 1) (blink-search-get-row-number) (list "Current Buffer"))) ((or (string-prefix-p "!" input) (string-prefix-p "!" input)) (blink-search-call-async "search" (substring input 1) (blink-search-get-row-number) (list "Grep File"))) ((or (string-prefix-p ";" input) (string-prefix-p ";" input)) (blink-search-call-async "search" (substring input 1) (blink-search-get-row-number) (list "Grep PDF"))) ((or (string-prefix-p ":" input) (string-prefix-p ":" input)) (blink-search-call-async "search" (substring input 1) (blink-search-get-row-number) (list "PDF"))) (t (blink-search-call-async "search" input (blink-search-get-row-number) blink-search-search-backends))))))
  blink-search-monitor-input(1 2 0)
  self-insert-command(1 110)
  funcall-interactively(self-insert-command 1 110)
  call-interactively(self-insert-command nil nil)
  command-execute(self-insert-command)

后台python服务没启动,检查Python路径吧

blink-search确实快哈。但是最近突然在我的linux电脑下blink-search使用正常,在mac电脑下启动会报错误:”Symbol’s value as variable is void: riables“。没有别的日志,只好通过二分查找大法最终确定是blink- search里的“(recentf-mode 1)”造成的。我的是mac14和emacs29.3版本。emacs也是通过brew安装的,不是自己编译的。

riables 这个错误, 看起来更像你的配置代码的 typo.