emacs-diffs
[Top][All Lists]
Advanced

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

master 47adea3a902: Modify LLDB command xcomplete to return a Lisp list


From: Gerd Moellmann
Subject: master 47adea3a902: Modify LLDB command xcomplete to return a Lisp list
Date: Tue, 17 Oct 2023 11:26:10 -0400 (EDT)

branch: master
commit 47adea3a902077d97f586257768f8540800d1a29
Author: Gerd Möllmann <gerd@gnu.org>
Commit: Gerd Möllmann <gerd@gnu.org>

    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 + ")")
 
 
 ########################################################################



reply via email to

[Prev in Thread] Current Thread [Next in Thread]