Skip to content

Instantly share code, notes, and snippets.

@sierpinskiii
Last active December 15, 2021 00:09
Show Gist options
  • Save sierpinskiii/63430ffff4681c5a9a1589d6f65acdfd to your computer and use it in GitHub Desktop.
Save sierpinskiii/63430ffff4681c5a9a1589d6f65acdfd to your computer and use it in GitHub Desktop.
;; LightRoFIME: Ring of Favorite Input MEthods, modified by shchoi
;; RoFIME created by slomo at KLDP https://kldp.org/node/109184
;; Modified by shchoi https://web.sfc.keio.ac.jp/~t21526hc/blog/
;; Set your favorite input methods
(setq favorite-input-methods
'(nil "korean-hangul" "japanese"))
(setq default-input-method "korean-hangul")
;; Set key bindings
(global-set-key (kbd "S-SPC") 'toggle-the-other-input-method)
(global-set-key (kbd "C-S-SPC") 'toggle-ring-structure)
;; load settings
(cond
((boundp 'favorite-input-methods)
(setq input-method-ring favorite-input-methods))
(T (setq input-method-ring () )))
(cond
((boundp 'default-input-method)
(add-to-list 'input-method-ring default-input-method)))
;; functions
(defun rofime-swap-heads (ring)
(cons (cadr ring)
(cons (car ring)
(cddr ring))))
(defun rofime-swap-the-ends (ring)
(append (last ring)
(append (reverse (cdr (reverse (cdr ring))))
(list (car ring)))))
(defun rofime-rotate (ring)
(if (< (length ring) 2) ring
(append (cdr ring) (list (car ring)))))
(defun rofime-add (ime)
(add-to-list 'input-method-ring ime))
(defun rofime-message () (interactive)
(message "%S" input-method-ring))
(defun toggle-the-other-input-method() (interactive)
(rofime-add current-input-method)
(setq input-method-ring
(rofime-swap-heads input-method-ring))
(set-input-method (car input-method-ring))
(rofime-message))
(defun rofime-rotate-the-others (ring)
(cons (car ring)
(rofime-rotate (cdr ring))))
(defun toggle-ring-structure () (interactive)
(if (equal (car input-method-ring) nil)
(setq input-method-ring
(rofime-rotate-the-others (reverse input-method-ring)))
(setq input-method-ring
(rofime-swap-the-ends input-method-ring)))
(set-input-method (car input-method-ring))
(rofime-message))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment