Browse Source

fix(gtk): properly execute M-x commands via Lua registry

Bernardo Magri 1 month ago
parent
commit
59ea2f57dd
2 changed files with 10 additions and 2 deletions
  1. 5 0
      init.lua
  2. 5 2
      src/gtk_editor.cpp

+ 5 - 0
init.lua

@@ -1138,6 +1138,11 @@ define_command("switch-buffer", function()
     editor:buffer_switch_mode() 
 end, "Switch buffer")
 
+-- Alias for switch-buffer to match Emacs expectations
+define_command("switch-to-buffer", function() 
+    editor:buffer_switch_mode() 
+end, "Switch buffer (Alias)")
+
 define_command("list-buffers", function() 
     -- Use existing implementation via keybinding or duplicate logic?
     -- Calling the function bound to C-x C-b if we can find it, or just define it here.

+ 5 - 2
src/gtk_editor.cpp

@@ -1314,8 +1314,11 @@ protected:
                     if (command_buffer_ == "quit" || command_buffer_ == "q") {
                         app_->quit();
                     } else {
-                        core_->lua_api()->execute(command_buffer_);
-                        message_line_ = "Executed: " + command_buffer_;
+                        // Use execute_extended_command from init.lua to handle M-x commands
+                        std::string lua_code = "execute_extended_command('" + command_buffer_ + "')";
+                        core_->lua_api()->execute(lua_code);
+                        // The message is usually set by the command itself, but we can show default success
+                        // message_line_ = "Executed: " + command_buffer_; 
                     }
                 } else if (mode_ == Mode::FindFile) {
                     if (core_->load_file(command_buffer_)) message_line_ = "Loaded";