Page 1 of 1

emacs line kill and paste

Posted: Fri Jun 13, 2008 3:22 pm
by greenhobby
Hi,

I'm interested in using Zeus editor in emacs mode. I use the ctrl-k and ctrl-y all the time to remove lines and paste elsewhere. It seems as though this feature doesn't quite exist in the emacs emulation. Under gnu emacs ctrl-k will kill the contents of the line, and another ctrl-k will delete the blank line left from the previous ctrl-k. crtl-y behaves a bit weird as well.

Am I doing something wrong? This feature alone will dictate my purchase. I use Linux/emacs a bit and have to be able to have this feature working the same as Linux.

thanks and regards,
gh

Posted: Sun Jun 15, 2008 11:41 pm
by jussij
Under gnu emacs ctrl-k will kill the contents of the line, and another ctrl-k will delete the blank line left from the previous ctrl-k.
Based on your description of the required Emacs functionalitty I think the following emacs_cut.lua macro will do something similar:

Code: Select all

function key_macro()
  -- macro only works for documents
  local document = is_document()

  -- macro only works for read/write documents.
  local locked = is_read_only()

  if (locked == 1) or (document == 0) then
    -- can't run astyle.exe on current document
    message("This macro can only be run with a named, writable document file.")
    beep()
  else
    -- disable screen updates
    screen_update_disable()

    -- get a copy of the current line
    local text = get_line_text()

    -- see if the current line is empty
    if string.len(text) == 0 then
        -- delete the current line
        LineDelete()
    else
        -- save the current cursor
        cursor_save()

        -- add the text to the clipboard
        set_clipboard_text(text)

        -- replae the line with an empty line
        LineDelete()
        MoveLineHome()
        EnterOpen()

        -- restore original cursor
        cursor_restore()
    end

    -- restore screen updates
    screen_update_enable()
  end
end

key_macro() -- run the macro
All you need do save the code to the Zeus zScript directory and then bind it to the keybaord using the Options, Editor Options menu, Keyboard Mapping panel.
crtl-y behaves a bit weird as well.
It should be possible to right a similar Lua macro to implement the required clipboard paste functionality.

Cheers Jussi