下面是 Emacs 的一种输入法,可以反向输入文本:
(defun reverse-input-method (key)
(if buffer-read-only
(list key)
(if (setq new key)
(list new ?\2) ;; ?\2 == backwards char
(list key ?\2))))
(defun reverse-input-activate (&optional arg)
"Activate reverse-im input method.
With arg, activate reverse-im input method if and only if arg is
positive.
While this input method is active, the variable
`input-method-function' is bound to the function
`reverse-input-method'."
(if (and arg
(< (prefix-numeric-value arg) 0))
(unwind-protect
(progn
(quail-hide-guidance)
(quail-delete-overlays)
(setq describe-current-input-method-function nil))
(kill-local-variable 'input-method-function))
(setq inactivate-current-input-method-function 'reverse-input-inactivate)
(setq describe-current-input-method-function 'reversr-input-help)
(quail-delete-overlays)
(if (eq (selected-window) (minibuffer-window))
(add-hook 'minibuffer-exit-hook 'quail-exit-from-minibuffer))
(set (make-local-variable 'input-method-function)
'reverse-input-method)))
(defun reverse-input-inactivate ()
"Inactivate reverse-im input method."
(interactive)
(reverse-input-activate -1))
(defun reverse-input-help ()
(interactive)
(with-output-to-temp-buffer "*Help*"
(princ "Inserts text in reverse order.")))
(provide 'reverse-im)
(register-input-method "reverse-im" "UTF-8" 'reverse-input-activate "<<"
"Input method for \"typing characters in reverse\".")
例如,您可以将其保存在 ~/.emacs.d/reverse-im/reverse-im.el 中,然后将这些行添加到 .emacs
(add-to-list 'load-path (expand-file-name "~/.emacs.d/reverse-im/"))
(require 'reverse-im)
然后在您需要编辑文本时使用KeySnail Firefox 插件调用 emacs(您需要在 .bashrc 中设置文本编辑器或任何用于将 shell 变量存储到emacsclient
并使用KeySnail 的K2Emacs插件,或修改您的 .keysnail。 js 在需要时调用 Emacs。
Vim 有一个类似的插件叫做 Vimperator,但我没有使用它。