[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/pyim bfa1166: Add pyim-hacks.el
From: |
ELPA Syncer |
Subject: |
[elpa] externals/pyim bfa1166: Add pyim-hacks.el |
Date: |
Tue, 19 Oct 2021 22:57:35 -0400 (EDT) |
branch: externals/pyim
commit bfa1166e57b378c27303ad682dae386771308807
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>
Add pyim-hacks.el
---
pyim-common.el | 49 ++++++++---------------------------------
pyim-hacks.el | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
pyim.el | 11 ++--------
3 files changed, 80 insertions(+), 49 deletions(-)
diff --git a/pyim-common.el b/pyim-common.el
index cfc18b2..dc7db58 100644
--- a/pyim-common.el
+++ b/pyim-common.el
@@ -164,46 +164,15 @@ for example: https://github.com/ch11ng/exwm/pull/831";
(funcall in l1 l2))))
(defun pyim-add-unread-command-events (key &optional reset)
- "Add KEY to `unread-command-events', ensuring that it is not recorded.
-
-If KEY is a character, it is prepended to `unread-command-events'
-as a cons cell of the form (no-record . KEY).
-
-If KEY is a vector of events, the events in the vector are
-prepended to `unread-command-events', after converting each event
-to a cons cell of the form (no-record . EVENT).
-
-Pyim puts keys back in `unread-command-events' to be handled
-again, and when it does this these keys have already been
-recorded in the recent keys and in the keyboard macro being
-defined, which means that recording them again creates
-duplicates. When RESET is non-nil, the events in
-`unread-command-events' are first discarded.
-
-This function is a fork of `quail-add-unread-command-events'."
- (let ((ssh-run-p (or (getenv "SSH_CLIENT")
- (getenv "SSH_TTY"))))
- (when reset
- (setq unread-command-events nil))
- (setq unread-command-events
- (if (characterp key)
- (cons
- (if ssh-run-p
- ;; FIXME: When user use Xshell or MobaXTerm, error
"<no-record>
- ;; is undefined" will be exist, this may be not a pyim's
bug.
- ;; but I do not know how to solve this problem, so I do
this ugly
- ;; hack, and wait others help ...
- ;; 1. https://github.com/tumashu/pyim/issues/402
- ;; 2.
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=bd5c7404195e45f11946b4e0933a1f8b697d8b87x
- key
- (cons 'no-record key))
- unread-command-events)
- (append (mapcan (lambda (e)
- (list (if ssh-run-p
- e
- (cons 'no-record e))))
- (append key nil))
- unread-command-events)))))
+ "This function is a fork of `quail-add-unread-command-events'."
+ (when reset
+ (setq unread-command-events nil))
+ (setq unread-command-events
+ (if (characterp key)
+ (cons (cons 'no-record key) unread-command-events)
+ (append (mapcan (lambda (e) (list (cons 'no-record e)))
+ (append key nil))
+ unread-command-events))))
;; * Footer
(provide 'pyim-common)
diff --git a/pyim-hacks.el b/pyim-hacks.el
new file mode 100644
index 0000000..c668643
--- /dev/null
+++ b/pyim-hacks.el
@@ -0,0 +1,69 @@
+;;; pyim-hacks.el --- hacks for pyim -*- lexical-binding: t; -*-
+
+;; * Header
+;; Copyright (C) 2015-2021 Free Software Foundation, Inc.
+
+;; Author: Feng Shu <tumashu@163.com>
+;; Maintainer: Feng Shu <tumashu@163.com>
+;; URL: https://github.com/tumashu/pyim
+;; Keywords: convenience, Chinese, pinyin, input-method
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; * 说明文档 :doc:
+;; This file has common utilities used by pyim
+
+;;; Code:
+;; * 代码 :code:
+
+;; ** Evil hack
+(defun pyim-hacks-deactivate-input-method (orig_func)
+ (let ((deactivate-current-input-method-function
+ (or deactivate-current-input-method-function #'ignore)))
+ (funcall orig_func)))
+
+(defvar pyim-hacks-for-ssh nil
+ "Hack of [<no-record> is undefined
#402](https://github.com/tumashu/pyim/issues/402)
+
+When user use Xshell or MobaXTerm, error '<no-record> is undefined' will be
+exist, this may be not a pyim's bug. but I do not know how to solve this
+problem, so I do this ugly hack, and wait others help ...
+1. https://github.com/tumashu/pyim/issues/402
+2.
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=bd5c7404195e45f11946b4e0933a1f8b697d8b87x";)
+
+(defun pyim-hacks-add-unread-command-events (orig_func key &optional reset)
+ "Advice function of `pyim-add-unread-command-events'."
+ (if (not pyim-hacks-for-ssh)
+ (funcall orig_func key reset)
+ (when reset
+ (setq unread-command-events nil))
+ (setq unread-command-events
+ (if (characterp key)
+ (cons key unread-command-events)
+ (append (mapcan (lambda (e) (list e)))
+ (append key nil))
+ unread-command-events))))
+
+(with-eval-after-load "pyim"
+ (advice-add 'deactivate-input-method :around
#'pyim-hacks-deactivate-input-method)
+ (advice-add 'pyim-add-unread-command-events :around
#'pyim-hacks-add-unread-command-events))
+
+;; * Footer
+(provide 'pyim-hacks)
+
+;;; pyim-hacks.el ends here
diff --git a/pyim.el b/pyim.el
index f0b096c..a6699d5 100644
--- a/pyim.el
+++ b/pyim.el
@@ -826,15 +826,8 @@ FILE 的格式与 `pyim-dcache-export' 生成的文件格式相同,
;; ** pyim 探针
(require 'pyim-probe)
-;; ** Evil hack
-(defun pyim-hack-deactivate-input-method (orig_func)
- (let ((deactivate-current-input-method-function
- (or deactivate-current-input-method-function #'ignore)))
- (funcall orig_func)))
-
-(with-eval-after-load
- (advice-add 'deactivate-input-method :around
#'pyim-hack-deactivate-input-method))
-
+;; ** pyim hacks
+(require 'pyim-hacks)
;; * Footer
(provide 'pyim)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/pyim bfa1166: Add pyim-hacks.el,
ELPA Syncer <=