code: def newline_with_copy_margin(event):
      """
      Preserve margin and cursor position when using
      Control-O to insert a newline in EMACS mode
      """
      b = event.current_buffer
      cursor_start_pos = b.document.cursor_position_col
      b.newline(copy_margin=True)
      b.cursor_up(count=1)
      cursor_end_pos = b.document.cursor_position_col
      if cursor_start_pos != cursor_end_pos:
          pos_diff = cursor_start_pos - cursor_end_pos
          b.cursor_right(count=pos_diff)
  
imports: import signal
  import sys
  from prompt_toolkit.enums import DEFAULT_BUFFER, SEARCH_BUFFER
  from prompt_toolkit.filters import HasFocus, HasSelection, Condition, ViInsertMode, EmacsInsertMode, HasCompletions
  from prompt_toolkit.filters.cli import ViMode
  from prompt_toolkit.keys import Keys
  from prompt_toolkit.key_binding.bindings.completion import display_completions_like_readline
  from IPython.utils.decorators import undoc
label_desc: Use image node_id 12 for calling a global function with example usage: newline_with_copy_margin(event) without return types