dash-at-point.el
没这个功能,Alfred 插件包含了一个 dashAlfredWorkflow
命令行程序:
~ $ dashAlfredWorkflow 'c:puts' | xmllint --format -
<?xml version="1.0"?>
<items>
<item uid="dash-advanced://puts/Function/file:///Users/xcy/Library/Application%20Support/Dash/DocSets/C/C.docset/Contents/Resources/Documents/en.cppreference.com/w/c/io/puts.html" arg="0" autocomplete="puts">
<title>puts</title>
<text type="copy">puts</text>
<text type="largetype">puts</text>
<subtitle mod="cmd">Open "puts" in browser</subtitle>
<subtitle mod="alt">Copy "puts" to clipboard</subtitle>
<subtitle>C - puts</subtitle>
<icon>/Users/xcy/Library/Application Support/Dash/Data/Alfred/23b63e037093461f49ade2edbabf166c.png</icon>
<quicklookurl>http://127.0.0.1:59618/Dash/pcarilmq/en.cppreference.com/w/c/io/puts.html</quicklookurl>
</item>
<item uid="dash-advanced://fputs/Function/file:///Users/xcy/Library/Application%20Support/Dash/DocSets/C/C.docset/Contents/Resources/Documents/en.cppreference.com/w/c/io/fputs.html" arg="1" autocomplete="fputs">
<title>fputs</title>
<text type="copy">fputs</text>
<text type="largetype">fputs</text>
<subtitle mod="cmd">Open "fputs" in browser</subtitle>
<subtitle mod="alt">Copy "fputs" to clipboard</subtitle>
<subtitle>C - fputs</subtitle>
<icon>/Users/xcy/Library/Application Support/Dash/Data/Alfred/23b63e037093461f49ade2edbabf166c.png</icon>
<quicklookurl>http://127.0.0.1:59618/Dash/pcarilmq/en.cppreference.com/w/c/io/fputs.html</quicklookurl>
</item>
</items>
利用这个 dashAlfredWorkflow
以及 ivy
,Emacs 也可以搜索/补全 Dash 的条目了:
(defun chunyang-dash ()
(interactive)
(require 'dom)
(ivy-read
"Search Dash: "
(lambda (str)
(or
(ivy-more-chars)
(with-temp-buffer
;; dashAlfredWorkflow 'c:puts' | xmllint --format -
(if (zerop (call-process "dashAlfredWorkflow" nil t nil str))
(let* ((dom (libxml-parse-xml-region (point-min) (point-max)))
(items (dom-by-tag dom 'item)))
(cl-loop for item in items
for uid = (dom-attr item 'uid)
for quicklookurl = (dom-text (dom-child-by-tag item 'quicklookurl))
for title = (dom-text (dom-child-by-tag item 'title))
for subtitle = (dom-text (car (last (dom-by-tag item 'subtitle))))
for subtitle+face = (propertize subtitle 'face 'font-lock-comment-face)
collect (propertize (concat title " " subtitle+face)
'uid uid
'quicklookurl quicklookurl)))
(list
"Error: dashAlfredWorkflow fails"
""
(split-string (buffer-string) "\n"))))))
:dynamic-collection t
:action (lambda (x)
(call-process "open" nil nil nil (get-text-property 0 'uid x)))))
(ivy-set-actions
'chunyang-dash
'(("b"
(lambda (x)
(browse-url (get-text-property 0 'quicklookurl x)))
"browse url")))
效果图: