diff options
| author | Kรฉvin Le Gouguec <kevin.legouguec@gmail.com> | 2020-09-18 13:14:24 +0200 |
|---|---|---|
| committer | Kรฉvin Le Gouguec <kevin.legouguec@gmail.com> | 2020-09-18 13:16:00 +0200 |
| commit | 998ed49ccad7ecab877e37beda650fbc159ac83b (patch) | |
| tree | 4728f3e8ff88116234d68e72c4ac1f01adb0ccb9 | |
| parent | da46ec7e05870a6403049c353672814177f1a30c (diff) | |
| download | dotfiles-998ed49ccad7ecab877e37beda650fbc159ac83b.tar.xz | |
Tweak input method management
- Stop requiring quail, since all functions I need are autoloaded.
- Reformat quail-define-package clause ala TeX.
Using the "UTF-8" language environment means the input method now
shows up on C-h L UTF-8.
- Since I might define more input methods, use a more "specific" name.
- Move comment about user bindings where it belongs.
- Make a proper defun, so that which-key can tell me which binding
activates which method.
- Note that docstrings could cross-reference input methods, if not for
help-xref-mule-regexp.
| -rw-r--r-- | .emacs | 40 |
1 files changed, 23 insertions, 17 deletions
@@ -47,12 +47,12 @@ ;; Hopefully these will be easier to remember than TeX commands: -(require 'quail) -(quail-define-package "my/input-method" "symbols" "๐ฐ" t - "Input arbitrary symbols with other arbitrary symbols.") +(quail-define-package + "my/symbols" "UTF-8" "๐ฐ" t + "Input arbitrary Unicode symbols with other arbitrary symbols.") (mapc (lambda (item) - (quail-defrule (car item) (cdr item) "my/input-method")) + (quail-defrule (car item) (cdr item) "my/symbols")) (list ;; Punctuation '("..." ?โฆ) @@ -67,17 +67,21 @@ ;; Pictograms '("/!\\" ?โ ))) -;; C-c [[:alpha:]] is reserved for users - let's make good use of it. - -(defun my/make-toggle-input-method (input-method) - (lambda () - (:documentation (format "Toggle `%s' input method." input-method)) - (interactive) - ;; `current-input-method' is a string; if INPUT-METHOD is a - ;; symbol, neither eq, eql nor equal would return t. - (if (string= current-input-method input-method) - (deactivate-input-method) - (set-input-method input-method t)))) +(defmacro my/make-input-toggle (input-method) + (let ((fsym (intern (format "my/toggle-input-%s" input-method))) + ;; Unfortunately, by default `help-make-xrefs' does not try to + ;; cross-reference input methods, as `help-xref-mule-regexp' + ;; is nil. This can be worked around by setting this variable + ;; to `help-xref-mule-regexp-template'. + (doc (format "Toggle `%s' input method." input-method))) + `(defun ,fsym () + ,doc + (interactive) + ;; `current-input-method' is a string; if INPUT-METHOD is a + ;; symbol, neither eq, eql nor equal would return t. + (if (string= current-input-method ',input-method) + (deactivate-input-method) + (set-input-method ',input-method t))))) (defun my/set-tab-width (&optional arg) (interactive "P") @@ -123,12 +127,14 @@ (require 'project) (magit-status (project-prompt-project-dir))) +;; C-c [[:alpha:]] is reserved for users - let's make good use of it. + (global-set-key (kbd "C-c c") 'compile) (global-set-key (kbd "C-c d t") 'toggle-truncate-lines) (global-set-key (kbd "C-c d v") 'visual-line-mode) (global-set-key (kbd "C-c e f") 'auto-fill-mode) -(global-set-key (kbd "C-c i t") (my/make-toggle-input-method 'TeX)) -(global-set-key (kbd "C-c i u") (my/make-toggle-input-method 'my/input-method)) +(global-set-key (kbd "C-c i t") (my/make-input-toggle TeX)) +(global-set-key (kbd "C-c i u") (my/make-input-toggle my/symbols)) (global-set-key (kbd "C-c k f") 'my/kill-ring-filename) (global-set-key (kbd "C-c k |") 'my/kill-ring-pipe-region) (global-set-key (kbd "C-c k !") 'my/kill-ring-shell) |
