From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11699 invoked by alias); 20 May 2014 19:12:22 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 11688 invoked by uid 89); 20 May 2014 19:12:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 20 May 2014 19:12:21 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4KJCJ2X023993 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 20 May 2014 15:12:20 -0400 Received: from barimba (ovpn-113-182.phx2.redhat.com [10.3.113.182]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s4KJCIjX029954 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Tue, 20 May 2014 15:12:19 -0400 From: Tom Tromey To: Sergio Durigan Junior Cc: GDB Patches , Phil Muldoon Subject: Re: [PATCH] PR python/16699: GDB Python command completion with overriden complete vs. completer class References: <87a9btqhe3.fsf@fleche.redhat.com> Date: Tue, 20 May 2014 19:12:00 -0000 In-Reply-To: (Sergio Durigan Junior's message of "Fri, 02 May 2014 21:04:15 -0300") Message-ID: <87y4xwqn71.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2014-05/txt/msg00441.txt.bz2 >>>>> "Sergio" == Sergio Durigan Junior writes: Sergio> Unfortunately I couldn't come up with a good way to do that. readline Sergio> messes with the text/word being parsed while it is parsing them, so it Sergio> is hard to restart the parsing because we may not have the full context Sergio> in all situations. Or at least that's what I found. I looked through the readline docs here. Ok, I see now, the completion API is irredeemably wacky. Sergio> But I fixed my patch according to your comment above, and I think now it Sergio> is right. What I did is simple: instead of providing dummy arguments to Sergio> the completer, I am now passing the real arguments. As far as I have Sergio> tested, it works. Cute. Sergio> What do you think? Is it too hacky? Someday we will invent a hackiness metric to let us know for sure. "M(h) is greater than 0.98! Patch rejected by the robot." Seriously, at first I thought this was probably a bad idea. And it is a little weird, since first it word-breaks some random way, then redoes the breaking later. Is there a way to call the Python function just once and store the results in the non-enum-return case? Since otherwise it seems that every completion request requires two calls to a possibly-expensive-though-we-hope-not completer. Anyway I'm ok-enough with it I suppose. Sergio> +void Sergio> +set_cmd_completer_handle_brkchars (struct cmd_list_element *cmd, Sergio> + void (*completer_handle_brkchars) (struct cmd_list_element *self, Sergio> + const char *text, Sergio> + const char *word)) Sergio> +{ Sergio> + cmd->completer_handle_brkchars = completer_handle_brkchars; /* Ok. */ I think the "Ok" comment usually is there as a note to the ARI. However, does ARI actually check this line? If not -> no comment needed. Sergio> +/* Set the completer_handle_brkchars callback. */ Sergio> + Sergio> +extern void set_cmd_completer_handle_brkchars (struct cmd_list_element *, Sergio> + void (*f) Sergio> + (struct cmd_list_element *, Sergio> + const char *, Sergio> + const char *)); I think the "f" argument should have type "completer_ftype *" rather than being spelled out. Sergio> +static void Sergio> +cmdpy_completer_handle_brkchars (struct cmd_list_element *command, Sergio> + const char *text, const char *word) Sergio> +{ Sergio> + cmdpy_object *obj = (cmdpy_object *) get_cmd_context (command); Sergio> + PyObject *textobj, *wordobj, *resultobj = NULL; Sergio> + /* const char dummy_text[] = "dummytext"; Sergio> + const char dummy_word[] = "dummyword"; */ No need for the commented-out bits. Sergio> +# This one should always pass. Sergio> +send_gdb "completefileinit ${testdir_complete}\t" Sergio> +gdb_test_multiple "" "completefileinit completion" { Sergio> + -re "^completefileinit ${testdir_regex}$" { Sergio> + pass "completefileinit completion" Sergio> + } FWIW I generally find it simpler to test the "complete" command rather than the send_gdb dance. Either way is ok though. Tom