lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


After some experimentation and a certain amount of help from various people,
I managed to get emacs on windows hooked up to ldb, although I find the
performance sluggish in comparison with vim.

I downloaded emacsclientw (and, indeed, the rest of the emacs install) from
http://ourcomments.org/Emacs/EmacsW32.html and more or less followed
the instructions from http://www.emacswiki.org/cgi-bin/emacs-en/EmacsW32
The rest was just trial and error and asking questions on irc, and I
ended up with the following (you'll have to adjust it for the location
of the emacsclientw executable, of course). The truly bizarre command
line is the only way I could find to get quoting to work with the
Windows shell, but there may well be a better way.

I also had to change the .emacs file installed by emacsw32 to not
maximize the gvim window on startup:

 '(emacsw32-max-frames nil)

Here's the ldb-config.lua file:

local FNLN = 'cmd /c ""u:\\program
files\\emacs\\emacs\\bin\\emacsclientw.exe" '..
             '--eval '..
             '"(let ((buffer (find-file-noselect %s)) '..
             '       (pop-up-frames nil) '..
             '       (display-buffer-reuse-frames t)) '..
             '   (set-buffer buffer) '..
             '   (select-window (display-buffer buffer nil 0)) '..
             '   (goto-line %d))""'
local osexec = os.execute

-- Open an emacs window and allow 1 second for it to open before the first
line
-- is reached.
--osexec('emacs --funcall=server-start &')
--osexec('sleep 1')

local function quotefn(filename)
  filename = ("%q"):format(filename)
  return '\\'..filename:sub(1,-2)..'\\"'
end

return {
  PROMPT =  "(ldb) ",
  PROMPT2 = "  >>> ",

  input = function(prompt)
    io.write(prompt); return io.read"*l"
  end,

  output = print,

  error = print,

  edit = function(filename, lineno)
     return osexec(FNLN:format(quotefn(filename), lineno))
  end,

  enterframe = function(state)
    local filename = state.here.source:match"^@(.*)"
    if filename then
       osexec(FNLN:format(quotefn(filename), state.here.currentline or 1))
    end
  end,

  load_plugins = function()
    require"ldb-break"
  end
}