Skip to content
zero-input-quickdial.el 1.69 KiB
Newer Older
;;; zero-input-quickdial --- quickdial input method written as an emacs minor mode. -*- lexical-binding: t -*-

;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;     http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.

;;; Commentary:

;; To use this input method,
;; M-x zero-input-quickdial-mode    ; turn on IM
;; type 1 will insert one
;; type 2 will insert two
;; type 3 will insert three.
;; M-x zero-input-quickdial-mode    ; turn off IM
;; This is just a demo of how Emacs minor mode can work as input method.
Yuanle Song's avatar
Yuanle Song committed

;;; Code:

(defun zero-input-quickdial-insert-one ()
  "Insert \"one\"."
Yuanle Song's avatar
Yuanle Song committed
  (interactive)
  (insert "one"))

(defun zero-input-quickdial-insert-two ()
  "Insert \"two\"."
Yuanle Song's avatar
Yuanle Song committed
  (interactive)
  (insert "two"))

(defun zero-input-quickdial-insert-three ()
  "Insert \"three\"."
Yuanle Song's avatar
Yuanle Song committed
  (interactive)
  (insert "three"))

(defvar zero-input-quickdial-mode-map
    (49 . zero-input-quickdial-insert-one)
    (50 . zero-input-quickdial-insert-two)
    (51 . zero-input-quickdial-insert-three))
  "Keymap for zero-input-quickdial-mode.")
Yuanle Song's avatar
Yuanle Song committed

(define-minor-mode zero-input-quickdial-mode
Yuanle Song's avatar
Yuanle Song committed
  "a simple input method written as an emacs minor mode"
  nil
  " Quickdial"
  zero-input-quickdial-mode-map)
Yuanle Song's avatar
Yuanle Song committed

(provide 'zero-input-quickdial)
;;; zero-input-quickdial.el ends here