Skip to content

Commit

Permalink
Add `insert-translated-name-in-comment-buffer-p' option to make engli…
Browse files Browse the repository at this point in the history
…sh assistants available in magit.
  • Loading branch information
manateelazycat committed Sep 24, 2018
1 parent 51e409a commit 2aad385
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions insert-translated-name.el
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
;; Maintainer: Andy Stewart <lazycat.manatee@gmail.com>
;; Copyright (C) 2018, Andy Stewart, all rights reserved.
;; Created: 2018-09-22 10:54:16
;; Version: 0.7
;; Last-Updated: 2018-09-24 19:06:19
;; Version: 0.8
;; Last-Updated: 2018-09-25 00:41:36
;; By: Andy Stewart
;; URL: http://www.emacswiki.org/emacs/download/insert-translated-name.el
;; Keywords:
Expand Down Expand Up @@ -66,6 +66,9 @@

;;; Change log:
;;
;; 2018/09/25
;; * Add `insert-translated-name-in-comment-buffer-p' option to make english assistants available in magit.
;;
;; 2018/09/24
;; * Add option `insert-translated-name-translate-engine' and default use Google.
;; * Support pyim now.
Expand Down Expand Up @@ -121,7 +124,8 @@
(defun insert-translated-name-insert ()
(interactive)
(if (or (insert-translated-name-in-string-p)
(insert-translated-name-in-comment-p))
(insert-translated-name-in-comment-p)
(insert-translated-name-in-comment-buffer-p))
(insert-translated-name-insert-comment)
(insert-translated-name-active
(cond ((insert-translated-name-match-modes insert-translated-name-line-style-mode-list)
Expand Down Expand Up @@ -284,6 +288,12 @@
(beginning-of-defun)
(parse-partial-sexp (point) point)))

(defun insert-translated-name-in-comment-buffer-p ()
(and (string-equal (buffer-name) "COMMIT_EDITMSG")
(save-excursion
(goto-char (point-min))
(search-forward-regexp "#\\s-Please\\s-enter\\s-the\\s-commit\\s-message\\s-for\\s-your\\s-changes." nil t))))

(defun insert-translated-name-in-string-p (&optional state)
"True if the parse state is within a double-quote-delimited string.
If no parse state is supplied, compute one from the beginning of the
Expand Down

0 comments on commit 2aad385

Please sign in to comment.