Created
January 26, 2015 14:10
-
-
Save xuchunyang/67d9f39c4ae7ce0be833 to your computer and use it in GitHub Desktop.
osx-dictionary-realtime.el
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(add-hook 'text-mode-hook | |
(lambda () | |
;; (remove-hook 'after-change-functions #'first-line-if-changed nil t) | |
(add-hook 'post-command-hook 'first-line-if-changed2 nil 'local))) | |
(defun first-line-if-changed (beg end len) | |
(save-excursion | |
(goto-char (point-min)) | |
(end-of-line) | |
(buffer-substring-no-properties (point-min) (point)))) | |
(defun first-line-if-changed2 () | |
(interactive) | |
(ignore-errors | |
(let ((word (thing-at-point 'word t))) | |
(with-current-buffer "*t*" | |
(erase-buffer) | |
(goto-char (point-min)) | |
(when (and word | |
(> (length word) 2) | |
(not (string= (thing-at-point 'word t) word))) | |
(insert (osx-dictionary--search word))))))) | |
(require 'osx-dictionary) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment