meow-edit / meow

Yet another modal editing on Emacs / 猫态编辑
GNU General Public License v3.0
1.07k stars 128 forks source link

Meow and DDSKK (Japanese Input) #540

Closed Zaijab closed 1 month ago

Zaijab commented 4 months ago

今日は、

I use Emacs to type in Japanese a lot. The easiest input method I have found is ddskk. However I notice some compatibility difficulty in using the non Latin modes. This is not very urgent, all issues with this compatibility can be resolved by first going into Latin mode with l and switching back when necessary.

For example, Type: C-x C-j to enter the Hiragana input mode (the cursor will change color but will remain a block / Meow Normal). Then move down using j (works fine). Try to move up using k (but will actually type k). Typing C-h k k (describe key then k) does show that k is bound to meow-prev. Using M-x meow-prev does not move the cursor anywhere but M-x meow-next does move the cursor down one line. This is in agreement with how j works but k doesn't.

I would like to know more about how I can begin debugging these issues. I am unfamiliar with what the call to meow-prev does which makes debugging tricky for a novice.

Here is my Meow configuration:

(setq meow-use-clipboard t)
(defun meow-setup ()
  (setq meow-cheatsheet-layout meow-cheatsheet-layout-qwerty)
  (meow-motion-overwrite-define-key
   '("j" . meow-next)
   '("k" . meow-prev)
   '("<escape>" . ignore))
  (meow-leader-define-key
   ;; SPC j/k will run the original command in MOTION state.
   '("j" . "H-j")
   '("k" . "H-k")
   ;; Use SPC (0-9) for digit arguments.
   '("1" . meow-digit-argument)
   '("2" . meow-digit-argument)
   '("3" . meow-digit-argument)
   '("4" . meow-digit-argument)
   '("5" . meow-digit-argument)
   '("6" . meow-digit-argument)
   '("7" . meow-digit-argument)
   '("8" . meow-digit-argument)
   '("9" . meow-digit-argument)
   '("0" . meow-digit-argument)
   '("/" . meow-keypad-describe-key)
   '("?" . meow-cheatsheet))
  (meow-normal-define-key
   '("0" . meow-expand-0)
   '("9" . meow-expand-9)
   '("8" . meow-expand-8)
   '("7" . meow-expand-7)
   '("6" . meow-expand-6)
   '("5" . meow-expand-5)
   '("4" . meow-expand-4)
   '("3" . meow-expand-3)
   '("2" . meow-expand-2)
   '("1" . meow-expand-1)
   '("-" . negative-argument)
   '(";" . meow-reverse)
   '("," . meow-inner-of-thing)
   '("." . meow-bounds-of-thing)
   '("[" . meow-beginning-of-thing)
   '("]" . meow-end-of-thing)
   '("a" . meow-append)
   '("A" . meow-open-below)
   '("b" . meow-back-word)
   '("B" . meow-back-symbol)
   '("c" . meow-change)
   '("d" . meow-delete)
   '("D" . meow-backward-delete)
   '("e" . meow-next-word)
   '("E" . meow-next-symbol)
   '("f" . meow-find)
   '("g" . meow-cancel-selection)
   '("G" . meow-grab)
   '("h" . meow-left)
   '("H" . meow-left-expand)
   '("i" . meow-insert)
   '("I" . meow-open-above)
   '("j" . meow-next)
   '("J" . meow-next-expand)
   '("k" . meow-prev)
   '("K" . meow-prev-expand)
   '("l" . meow-right)
   '("L" . meow-right-expand)
   '("m" . meow-join)
   '("n" . meow-search)
   '("o" . meow-block)
   '("O" . meow-to-block)
   '("p" . meow-yank)
   '("q" . meow-quit)
   '("Q" . meow-goto-line)
   '("r" . meow-replace)
   '("R" . meow-swap-grab)
   '("s" . meow-kill)
   '("t" . meow-till)
   '("u" . meow-undo)
   '("U" . meow-undo-in-selection)
   '("v" . meow-visit)
   '("w" . meow-mark-word)
   '("W" . meow-mark-symbol)
   '("x" . meow-line)
   '("X" . meow-goto-line)
   '("y" . meow-save)
   '("Y" . meow-sync-grab)
   '("z" . meow-pop-selection)
   '("'" . repeat)
   '("<escape>" . ignore)))
(require 'meow)
(meow-setup)
(meow-global-mode 1)
DogLooksGood commented 3 months ago

Hey! Can you provide more information about what C-x C-j does in your case? AFAIK it should open the dired with current directory even with input method enabled.

Zaijab commented 3 months ago

According to C-h k C-x C-j:

C-x C-j runs the command skk-mode (found in global-map), which is an autoloaded interactive native-compiled Lisp function in ‘skk.el’.

eshrh commented 1 month ago

I do not believe this is solvable on our side.

So, it's hard to change meow-prev. One option is to bind a different key (maybe some hyper key) to previous-line and then modify meow--kbd-backward-line to match. Another is to just straight up hack the skk function; from reading the code i think this should be safe:

(advice-add
 'skk-previous-candidate :around
 (lambda (func &optional arg)
   (interactive "p")
   (if (and (not (eq skk-henkan-mode 'active))
            (not (eq last-command 'skk-kakutei-henkan))
            last-command-event
            (eq last-command-event
                (seq-first (car (where-is-internal
                                 'meow-prev
                                 meow-normal-state-keymap)))))
       (previous-line)
     (funcall func arg))))
eshrh commented 1 month ago

I feel like skk is popular and important enough of a package that j/k not working is unacceptable. I added the code above as a shim.

Zaijab commented 1 month ago

This is awesome! The advice works well for me thus far. Thank you for your commitment to producing high quality free and open source software. I also appreciate the explanation as to what meow-prev does. I have learned a lot.