smzht / qmk_ergodash_emacs_keymap

a personal keymap for ergodash with emacs keybinding feature

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

qmk_ergodash_emacs_keymap

Summary

This module implements an Emacs key-binding mode for Windows, as a part of a personal keymap (Japanese) for ergodash/rev1.

The Emacs part is provided in separate files:

  • process_emacs.c
  • process_emacs.h

so that they can be used in other keymaps, too.

Limitation

  • This module does not support non-basic keycodes (ex. tapping / one-shot features such as LT, MT, MO, etc) that are used to generate basic keycodes as a result of some processing. This is because such features are handled in the later stage of process_record_* chain, and there is no chance for this module to handle the resulting basic keycodes generated by those features. However, there is a way to use the tapping feature: a method similar to the one used in keymap.c can be employed, where tapping is handled within process_record_mytap() and the generated basic keycodes are passed to process_record_emacs() to allow for this module to handle them. A limitation of this method is that it cannot support key-repeat by OS because the tapping will only be sent when the key is released.

  • If this module is used, Windows' ALT+(key) menu (ex. ALT+F for File menu) will be disabled. Although, 'ALT single tap + (key)' should still be available.

Tap and hold behavior of Mod keys (since bd51617, 2021/07/23)

When USE_TAP_HOLD_ALT_CTL is defined, the press / release of Alt and Ctrl keys are not sent immediately to the host: they will be sent only when other non-modifier key is pressed / released. This behavior is to avoid:

  • Context menus that are activated when Ctrl is held (seen with Word, PowerPoint)
  • Alt menu of Windows (When Alt is pressed, the menu bar is focused)

However, we sometimes need to press Alt or Ctrl solely: ex. hold a Ctrl key when selecting multiple items on a list control. For those cases, please use tap & hold of the modifier key, and then the key press / release of them will be sent immediately to the host.

Also, there is another case where the tap and hold behavior is not suitable: Alt+tab's and Ctrl+tab's. In these key sequences, it would be very annoying if the Alt or the Ctrl key was not held automatically. So, an exceptional code has been added to hold Alt or Ctrl presses when KC_TAB is pressed.

How to use Emacs mode

Because QMK is changing actively, this repository is not a fork of the entire qmk_firmware repository, but is a submodule which is expected to be cloned under some specific keymap directory.

For example:

$ cd qmk_firmware/keyboards/ergodash/rev1/keymaps/
$ git submodule add https://github.com/orihikarna/qmk_ergodash_emacs_keymap.git your_keymap_name

To enable the Emacs mode in your keymap, include process_emacs.h in keymap.c as:

#include QMK_KEYBOARD_H
#include "keymap_jp.h"
#include "process_emacs.h"

and, then call process_record_emacs() in the beginning of process_record_user() as follows:

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  if (process_record_emacs(keycode, record) == false) {
    return false;
  }
  ...
}

Also, do not forget to add the source file to rules.mk:

...

SRC += process_emacs.c

List of defined Emacs key bindings

In the following tables, the asterisks '*' mean that the modifier keys that follow them will be kept pressed/released during the translation. For example, C-m will be translated to Enter as shown in the fifth row of the table below (Default mode), and '-*S-*M' part means that Shift and Alt keys may be either pressed / released state and the state will be kept through the translation. Therefore, if Alt(Meta) key was pressed when C-m was pressed, namely when C-M-m was pressed, this will be translated to M-Enter: Alt will be pressed, and Shift released.

Default mode

Input Translation Description
C-q Toggle Emacs mode
C-x Enter C-x prefix mode
C-' ' Enter mark selection mode
C-g Esc Cancel
C-*S-*M-m *S-*M-Enter Enter
C-*S-*M-a *S-*M-Home Beginning
C-*S-*M-e *S-*M-End End
C-*S-*M-f *S-*M--> Right
C-*S-*M-b *S-*M-<- Left
C-*S-*M-p *S-*M-^ Up
C-*S-*M-n *S-*M-v Down
C-*S-*M-r *S-*M-PageUp Page up
C-*S-*M-v *S-*M-PageDown Page down
M-*S-f *S-C-'->' Next word
M-*S-b *S-C-'<-' Previous word
C-*S-d *S-Del Delete
C-h BS Backspace
C-s C-f Forward search -> Find
C-o Ent, Up, End Open line
C-k S-End, C-x Kill line
C-t S-Right, C-x, Left, C-v, Right Swap chars
M-d CS-Right, C-x Kill word
C-*S-i *S-Tab Tab
C-w C-x Cut
M-w C-c Copy
C-y C-v Paste
M-y C-y Redo
S-M-, C-Home Top
S-M-. C-End Bottom

In addition, here are defined MacOS style shortcuts although these are not Emacsen.

Input Translation Description
M-z C-z Undo
M-x C-x Cut
M-c C-c Copy
M-v C-v Paste
M-a C-a All
M-s C-s Save
SM-z C-y Redo
M-n C-n New
M-o C-o Open

And finally, toggle Japanese IME (when USE_JP is defined).

Input Translation Description
C-; 全角半角 Toggle Japanese IME

C-x prefix mode

Input Translation Description
C-q Toggle Emacs mode
C-s C-s Save
C-f C-o Open
C-c M-F Close
u C-z Undo
h C-a Select all

Mark selection mode

If backlight is enabled by rules.mk, the backlight will be toggled to show that this module is in the mark selection mode.

Input Translation Description
C-q Toggle Emacs mode
C-g Right Cancel mark selection mode
C-w C-x, Left, Right Cut
M-w C-c, Left Copy
C-a S-Home Beginning
C-e S-End End
C-f S-'->' Right
C-b S-'<-' Left
C-p S-'^' Up
C-n S-'v' Down
CS-v S-PageUp Page up
C-v S-PageDown Page down
M-F SC-'->' Next word
M-b SC-'<-' Previous word
SM-, SC-Home Top
SM-. SC-End Bottom
<- S-'<-' Left
-> S-'->' Right
^ S-'^' Up
v S-'v' Down

About

a personal keymap for ergodash with emacs keybinding feature


Languages

Language:C 99.7%Language:Makefile 0.3%