Last active
August 29, 2015 14:01
-
-
Save ryseto/d6f477e7196f51b6f1fe to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(defun MyTool-speech-word() | |
"Speak words." | |
(interactive) | |
(let* ((str (url-hexify-string (string-word-or-region)))) | |
(process-kill-without-query | |
(start-process-shell-command "speech" nil | |
"/usr/bin/say -r 150" (concat "\"" str "\"" ))))) | |
(defun string-word-or-region () | |
"If a region is selected, the text string of the region is returned. | |
Otherwise, the text string of the word is returnd." | |
(let ((editable (not buffer-read-only)) | |
(pt (save-excursion (mouse-set-point last-nonmenu-event))) | |
beg end) | |
(if (and mark-active | |
(<= (region-beginning) pt) (<= pt (region-end)) ) | |
(setq beg (region-beginning) | |
end (region-end)) | |
(save-excursion | |
(goto-char pt) | |
(backward-char 1) | |
(setq end (progn (forward-word) (point))) | |
(setq beg (progn (backward-word) (point))))) | |
(buffer-substring-no-properties beg end))) | |
(define-key global-map (kbd "C-c s") 'MyTool-speech-word) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment