ストリングのリストを引数にとって割り当てられたキーを連続して押すと順番に入力するコマンド関数を返す関数
(eval-when-compile (require 'cl)) (defun my-chr (list-of-string) (lexical-let ((los list-of-string) (last-word "") (count 0)) (lambda () (interactive) (if (eq this-command real-last-command) (incf count) (setq count 0)) (when (>= count (length los)) (setq count 0)) (let ((word (nth count los))) (when (eq this-command real-last-command) (delete-backward-char (length last-word))) (setq last-word word) (insert word))))) ;; (global-set-key (kbd "=") (my-chr '(" = " " == " " === ")))
クロージャーです。