在 Emacs 配置文件中加入以下代码
(global-set-key (kbd "C-c d") 'kid-sdcv-to-buffer) (defun kid-sdcv-to-buffer () (interactive) (let ((word (if mark-active (buffer-substring-no-properties (region-beginning) (region-end)) (current-word nil t)))) (setq word (read-string (format "Search the dictionary for (default %s): " word) nil nil word)) (set-buffer (get-buffer-create "*sdcv*")) (buffer-disable-undo) (erase-buffer) (let ((process (start-process-shell-command "sdcv" "*sdcv*" "sdcv" "-n" word))) (set-process-sentinel process (lambda (process signal) (when (memq (process-status process) '(exit signal)) (unless (string= (buffer-name) "*sdcv*") (setq kid-sdcv-window-configuration (current-window-configuration)) (switch-to-buffer-other-window "*sdcv*") (local-set-key (kbd "d") 'kid-sdcv-to-buffer) (local-set-key (kbd "q") (lambda () (interactive) (bury-buffer) (unless (null (cdr (window-list))) ; only one window (delete-window))))) (goto-char (point-min))))))))