edlin(3)

πŸ“¦
version 26.2.5.21 Β· 2 versions
, in fedora 43, fedora 44

πŸ’– edlin(3) β€” Erlang Module Definition πŸ’–

okay bestie, gather round, because this one is literally the line and input interpreter for the Erlang shell 🫢 and yes it's as iconic as it sounds.


✨ NAME ✨

edlin β€” the line and input interpretter for the erlang shell. πŸŽ€

(yes, "interpretter" with two t's, that's how it's written, no I will not be fixing it, we respect the source πŸ’…)


🌸 DESCRIPTION 🌸

so like. this module reads input, handles any escape sequences that have been configured via edlin_key, and then outputs action requests. and those action requests? they get handled either by the group modules or the user_drv. that's the whole vibe. ✨


πŸ”‘ KEY CONFIGURATION πŸ”‘

ok so you CAN set up a custom key configuration that overrides the default key configuration. the way you do it is by setting the stdlib application parameter shell_keymap before Erlang is started. 🫢

and if you want the same keymap in all Erlang shells (yes, all of them, main character consistency πŸ‘‘) you can do that by putting a config file in your user's home directory and then setting ERL_FLAGS to load it at startup. for example:

$ cat $HOME/.erlang_keymap.config
[{stdlib,
  [{shell_keymap,
    #{ normal => #{ "\^[A" => clear } }
  }]
}].
$ ERL_FLAGS="-config $HOME/.erlang_keymap" erl

the current keymap configuration can be fetched through edlin:keymap(). and listen β€” if a custom keymap or keymap file is specified, then it will be merged with the default keymap. it doesn't replace it. it's giving collaborative, not competitive πŸ’–

the keymap is a map of maps where the keys in the parent map correspond to different editing modes in the shell. the valid modes currently supported are normal and search. πŸ“

the keys in the child maps are the escape sequences that are sent from the terminal when a key is pressed, and each value is a valid action as seen below. ⌨️

the default atom is used to specify that an action should happen when a key is pressed that does not have any mapping. typically used to exit a mode. πŸ™ˆ

See tty - A Command-Line Interface for more information about the default keymap. ngl, go read it, it's the lore.

πŸŽ€ ACTIONS πŸŽ€

the commands below are the built-in action requests for switching input modes on the normal shell or navigating, or manipulating the line feed. the line feed supports multiple lines. πŸ”₯

  • auto_blink β€” automatically close the closest matching opening parenthesis.
  • backward_char β€” move backward one character.
  • backward_delete_char β€” delete the character behind the cursor.
  • backward_delete_word β€” delete the word behind the cursor.
  • backward_kill_line β€” delete all characters from the cursor to the beginning of the line and save them in the kill buffer.
  • backward_kill_word β€” delete the word behind the cursor and save it in the kill buffer.
  • backward_line β€” move backward one line.
  • backward_word β€” move backward one word.
  • beginning_of_expression β€” move to the beginning of the expression.
  • beginning_of_line β€” move to the beginning of the line.
  • clear β€” clear the screen.
  • clear_line β€” clear the current expression.
  • end_of_expression β€” move to the end of the expression.
  • end_of_line β€” move to the end of the line.
  • forward_char β€” move forward one character.
  • forward_delete_char β€” delete the character under the cursor.
  • forward_line β€” move forward one line.
  • forward_word β€” move forward one word.
  • history_down β€” move to the next item in the history.
  • history_up β€” move to the previous item in the history.
  • kill_line β€” delete all characters from the cursor to the end of the line and save them in the kill buffer.
  • kill_word β€” delete the word under the cursor and save it in the kill buffer.
  • new_line_finish β€” add a newline at the end of the line and try to evaluate the current expression.
  • newline β€” add a newline at the cursor position.
  • open_editor β€” open the current line in an editor e.g. EDITOR="code -w" opens a buffer in vs code. > note that you need to pass a flag to the editor so that it signals the shell when you close the buffer. don't skip this part bestie, it's the whole trick 🫢
  • redraw_line β€” redraw the current line.
  • search_cancel β€” cancel the current search.
  • search_found β€” accept the current search result and submit it.
  • search_quit β€” accept the current search result, but edit it before submitting.
  • search β€” enter search mode, search the history.
  • search_down β€” skip to the next line in the history that matches the current search expression.
  • search_up β€” skip to the previous line in the history that matches the current search expression.
  • tab_expand_full β€” output all possible tab completions.
  • tab_expand_quit β€” go back to normal mode.
  • tab_expand β€” autocomplete the current word, or show 5 lines of possible completions.
  • transpose_char β€” swap the character behind the cursor with the one in front of it.
  • transpose_word β€” swap the word behind the cursor with the one in front of it.
  • yank β€” insert the contents of the kill buffer at the cursor position.

πŸ¦‹ DATA TYPES πŸ¦‹

keymap()

keymap() = #{atom() => #{string() | default => atom()}}

a map of maps for each shell mode containing key, action pairs. that's it, that's the type, she's simple and she slays πŸ’…


πŸ‘‘ EXPORTS πŸ‘‘

keymap() -> keymap()

Types:

keymap() = #{atom() => #{string() | default => atom()}}

get the current keymap used in the shell. πŸ” each key in the parent map represents a shell mode e.g. normal or search. each map associated with the shell modes contains key sequences represented as strings, paired with an action, which is one of the valid actions mentioned above. ⭐


and that's the whole page bestie, you ate it, you understood it, periodt. πŸ’–

this has been brought to you by Ericsson AB, running stdlib 5.2.3.6, and it's edlin(3) β€” version dropped, date stamped, legacy secured. mwah πŸ’‹βœ¨
πŸ“¦ where this page comes from