351 (end-of-line)) |
351 (end-of-line)) |
352 (re-search-backward "^\\([^ ].*\\)$" limit) |
352 (re-search-backward "^\\([^ ].*\\)$" limit) |
353 (match-string 1) |
353 (match-string 1) |
354 ))) |
354 ))) |
355 |
355 |
|
356 (defun gadict-copy-pronunciation (&optional headword) |
|
357 "Copy existing pronunciation of selected region or current word to `kill-ring'." |
|
358 (interactive |
|
359 (list (if (use-region-p) |
|
360 (buffer-substring region-beginning region-end) |
|
361 (thing-at-point 'word)))) |
|
362 (save-excursion |
|
363 (gadict-search-floor headword) |
|
364 (when (search-forward-regexp "\\[\\([^]]+\\)]") |
|
365 (kill-new (match-string 1))))) |
|
366 |
356 (defun gadict-setup-keymap () |
367 (defun gadict-setup-keymap () |
357 "Setup gadict keymap." |
368 "Setup gadict keymap." |
358 (define-key (current-local-map) [M-return] 'gadict-search) |
|
359 (define-key (current-local-map) [S-return] 'gadict-insert-translation) |
369 (define-key (current-local-map) [S-return] 'gadict-insert-translation) |
360 (define-key (current-local-map) [C-return] 'gadict-insert-template-in-order)) |
370 (define-key (current-local-map) [C-return] 'gadict-insert-template-in-order) |
|
371 (define-key (current-local-map) [C-S-return] 'gadict-search) |
|
372 (define-key (current-local-map) [M-return] 'gadict-copy-pronunciation)) |
361 |
373 |
362 ;;;###autoload |
374 ;;;###autoload |
363 (define-derived-mode gadict-mode fundamental-mode "gadict" |
375 (define-derived-mode gadict-mode fundamental-mode "gadict" |
364 "Derived mode for editing gadict dictionary source files." |
376 "Derived mode for editing gadict dictionary source files." |
365 (gadict-setup-fontlock) |
377 (gadict-setup-fontlock) |