From 47adea3a902077d97f586257768f8540800d1a29 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gerd=20M=C3=B6llmann?= Date: Tue, 17 Oct 2023 17:23:33 +0200 Subject: [PATCH] Modify LLDB command xcomplete to return a Lisp list * etc/emacs_lldb.py (xcomplete): Return a Lisp list. Add a comment explaining the return value. --- etc/emacs_lldb.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/etc/emacs_lldb.py b/etc/emacs_lldb.py index a4f066b79de..f2c7a7987c7 100644 --- a/etc/emacs_lldb.py +++ b/etc/emacs_lldb.py @@ -203,14 +203,34 @@ def xdebug_print(debugger, command, result, internal_dict): """Print Lisp_Objects using safe_debug_print()""" debugger.HandleCommand(f"expr safe_debug_print({command})") +# According to SBCommanInterpreter.cpp, the return value of +# HandleCompletions is as follows: +# +# Index 1 to the end contain all the completions. +# +# At index 0: +# +# If all completions have a common prefix, this is the shortest +# completion, with the common prefix removed from it. +# +# If it is the completion for a whole word, a space is added at the +# end. +# +# So, the prefix is what could be added to make the command partially +# complete. +# +# If there is no common prefix, index 0 has an empty string "". + def xcomplete(debugger, command, result, internal_dict): """Print completions for COMMAND.""" interpreter = debugger.GetCommandInterpreter() string_list = lldb.SBStringList() interpreter.HandleCompletion(command, len(command), len(command), -1, string_list) + list = "" for i in range(string_list.GetSize()): - result.AppendMessage(string_list.GetStringAtIndex(i)) + list += '"' + string_list.GetStringAtIndex(i) + '" ' + result.AppendMessage("(" + list + ")") ######################################################################## -- 2.39.2