Copy existing pronunciation of selected region or current word to `kill-ring'.
--- a/contrib/gadict.el Fri Mar 17 18:54:55 2017 +0200
+++ b/contrib/gadict.el Fri Mar 17 21:07:20 2017 +0200
@@ -353,11 +353,23 @@
(match-string 1)
)))
+(defun gadict-copy-pronunciation (&optional headword)
+ "Copy existing pronunciation of selected region or current word to `kill-ring'."
+ (interactive
+ (list (if (use-region-p)
+ (buffer-substring region-beginning region-end)
+ (thing-at-point 'word))))
+ (save-excursion
+ (gadict-search-floor headword)
+ (when (search-forward-regexp "\\[\\([^]]+\\)]")
+ (kill-new (match-string 1)))))
+
(defun gadict-setup-keymap ()
"Setup gadict keymap."
- (define-key (current-local-map) [M-return] 'gadict-search)
(define-key (current-local-map) [S-return] 'gadict-insert-translation)
- (define-key (current-local-map) [C-return] 'gadict-insert-template-in-order))
+ (define-key (current-local-map) [C-return] 'gadict-insert-template-in-order)
+ (define-key (current-local-map) [C-S-return] 'gadict-search)
+ (define-key (current-local-map) [M-return] 'gadict-copy-pronunciation))
;;;###autoload
(define-derived-mode gadict-mode fundamental-mode "gadict"