Skip to content

Manual §5 Emacs Mode

Koichi Murase edited this page Mar 8, 2023 · 8 revisions

[ 日本語 | English ] ≫ Manual [§1 Intro | §2 Color | §3 Bind | §4 Edit | §5 Emacs | §6 Vim | §7 Comp | §8 Misc]

5. Emacs editing mode

Emacs editing mode is essentially the same as what is described in §4 Editing. The specific bindings in Emacs editing mode explained here.

5.1 Editing

Character insert and delete

Key combination Widget Description
C-q, C-v emacs/quoted-insert Insert the next key-input characters literally
paste_begin emacs/bracketed-paste Start Bracketed Paste Mode
C-d delete-region-or delete-forward-char-or-exit Delete the selection or the forward character, or exit the shell

Undo & Redo

Key combination Widget Description
C-_, C-DEL, C-BS, C-/, C-x u, C-x C-u emacs/undo Undo
C-x U, C-x C-S-u emacs/redo Redo
M-r emacs/revert Restore the original text

Internal use

Key combination Widget
__attach__ safe/__attach__
__before_widget__ emacs/__before_widget__
__after_widget__ emacs/__after_widget__
C-</kbd>, C-^ bell

5.2 Shell operations

Expansions

Key combination Widget Description
M-^ history-expand-line Perform history expansions
SP magic-space Perform expansions and insert a space
/ magic-slash Perform named directory expansions (sabbrev expansions starting with ~) and insert a slash
M-C-e shell-expand-line Perform shell expansions
M-& tilde-expand Perform tilde expansions

Run command or cancel

Key combination Widget Description
C-c discard-line Discard the contents of the current line
C-j, C-RET accept-line Execute the current line
C-m, RET accept-single-line-or-newline Execute the current line (in single-line mode) or insert a newline
C-o accept-and-next Execute the current line and go to the next history entry
C-x C-e edit-and-execute-command Edit and execute the current command
M-# insert-comment Insert comments
C-g, C-x C-g, C-M-g bell Cancel

Miscellaneous

Key combination Widget Description
C-l clear-screen Clear screen and redraw the line
C-M-l redraw-line Redraw the line
f1 command-help Show help of the current command
C-x C-v display-shell-version Display the shell version
C-z, M-z (command) fg Resume the stopped job

5.3 Settings specific to Emacs editing mode

Settings specific to Emacs editing mode can be performed through the hook keymap_emacs_load.

# blerc (Example)

function my/emacs-load-hook {
  # Settings for Emacs editing mode
  ...
}

blehook/eval-after-load keymap_emacs my/emacs-load-hook
# ble-0.3 and before
# ble/array#push _ble_keymap_emacs_load_hook my/emacs-load-hook

5.3.1 Bleopt prompt_emacs_mode_indicator (Prompt string) (v0.4)

This option specifies the content of the mode indicator shown in the information line as a prompt sequence.

[ Note: Please specify the following settings through the hook keymap_emacs_load. See the code example at the section beginning. ]

# hook:keymap_emacs_load

# default
bleopt prompt_emacs_mode_indicator='\q{keymap:emacs/mode-indicator}'

5.3.2 Prompt sequence \q{keymap:emacs/mode-indicator} (v0.4)

This is expanded to the mode name and hints in the multiline editing mode. When it is not in the multiline editing mode, this is expanded to an empty string.

\q{keymap:emacs/mode-indicator}  # Example result: -- MULTILINE -- (RET or C-m: insert a newline, C-j: run)

5.3.3 Bleopt keymap_emacs_mode_string_multiline (ANSI escape sequences) (v0.4)

This option specifies the mode name in the multiline editing mode used by the prompt sequence \q{keymap:emacs/mode-indicator}.

[ Note: Please specify the following settings through the hook keymap_emacs_load. See the code example at the section beginning. ]

# hook:keymap_emacs_load

# default
bleopt keymap_emacs_mode_string_multiline=$'\e[1m-- MULTILINE --\e[m'

# Do not show the mode string in the multiline editing mode
bleopt keymap_emacs_mode_string_multiline=

[ 日本語 | English ] ≫ Manual [§1 Intro | §2 Color | §3 Bind | §4 Edit | §5 Emacs | §6 Vim | §7 Comp | §8 Misc]