From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alex Branham Newsgroups: gmane.emacs.bugs Subject: bug#34787: New defcustom to govern TAB completion Date: Sat, 25 May 2019 08:05:59 -0500 Message-ID: <87a7favg3s.fsf@gmail.com> References: <87h8cdqlb3.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="122825"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: mu4e 1.2.0; emacs 27.0.50 To: 34787@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat May 25 15:08:17 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hUWPI-000Vp1-M5 for geb-bug-gnu-emacs@m.gmane.org; Sat, 25 May 2019 15:08:16 +0200 Original-Received: from localhost ([127.0.0.1]:42009 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hUWPH-0005Yb-Ke for geb-bug-gnu-emacs@m.gmane.org; Sat, 25 May 2019 09:08:15 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:47051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hUWP5-0005YL-PQ for bug-gnu-emacs@gnu.org; Sat, 25 May 2019 09:08:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hUWP4-0004tN-72 for bug-gnu-emacs@gnu.org; Sat, 25 May 2019 09:08:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34843) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hUWP4-0004tB-2s for bug-gnu-emacs@gnu.org; Sat, 25 May 2019 09:08:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hUWP3-0003l6-SS for bug-gnu-emacs@gnu.org; Sat, 25 May 2019 09:08:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alex Branham Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 25 May 2019 13:08:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34787 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.155878962514378 (code B ref -1); Sat, 25 May 2019 13:08:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 25 May 2019 13:07:05 +0000 Original-Received: from localhost ([127.0.0.1]:48385 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hUWO9-0003jp-DQ for submit@debbugs.gnu.org; Sat, 25 May 2019 09:07:05 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:60552) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hUWO4-0003jG-Dg for submit@debbugs.gnu.org; Sat, 25 May 2019 09:07:01 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:59897) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hUWNv-0003sF-2b for submit@debbugs.gnu.org; Sat, 25 May 2019 09:06:52 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:46657) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hUWNs-0005Q4-Ku for bug-gnu-emacs@gnu.org; Sat, 25 May 2019 09:06:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hUWNq-0003og-3T for bug-gnu-emacs@gnu.org; Sat, 25 May 2019 09:06:48 -0400 Original-Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]:38222) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hUWNm-0003Hc-JN for bug-gnu-emacs@gnu.org; Sat, 25 May 2019 09:06:43 -0400 Original-Received: by mail-ot1-x32f.google.com with SMTP id s19so11121873otq.5 for ; Sat, 25 May 2019 06:06:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:subject:in-reply-to:date:message-id :mime-version; bh=sKHzMBgZLvRSPz20CGIUVdhXh20HPNoPO76AW5KLTXE=; b=WAKVX3ZfbOmfWZbiyodXC83zwvUKHmwHNv1jjBK9r2oqkZ06zGsNxKfNZVQE+QtX1X JL8MAPjsEwAlL3x+1+sLEYSW5szlhT8I9q7zaXwDZ5SDGz3WSyrYp/YHuUGPtp8m7hhY d/8LIoEUYuPpaphdWUGRIqMY366Wqx1xs3sU+JiH7jsoBz3qOySugVZqphjW1lydLVkI dp10ZIxob2n2aPTHxbvAuYXMmemCqGMr7dQzr7GceEPHf2rCF2THWHxknGMd1ugTDm7N qCm2j5sIvMP6Xyf38es3Tr7lT6zOjg/HygbQsRnHekTJedEfIWPQi0sTsLWHd4xmKTGr qhyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:subject :in-reply-to:date:message-id:mime-version; bh=sKHzMBgZLvRSPz20CGIUVdhXh20HPNoPO76AW5KLTXE=; b=RHq1gVJ8lyWLk8L/FLrxFSmPuCOZ1DuCOffj4Sm68eKt5tH+7s+IrD+QRTmCbH5aEj FdQcD7iGBONZfYKUGv/8kjTL04T8Q2R443dnjORmHGPefvdkYQxOCQv3ClKoAj+owNAF ZHMgEMBGFkGBJGtpB9rTY6hyODRSAV1Tt0EY++XdvlVkgirkztPr/9B5pArne+V979qw Fue/uOXnydw80588oi9lI0glyT6KZkW1GeUhHjxyuRz9N+r8XjEdTNDdo8rBg2jHSq7H oyPum/Vley7YwMUo7KigheJIp3SJvWb/OVJTZort5gKiBNWYJiQ0nKI7mc6Cjdus7rDl IMZA== X-Gm-Message-State: APjAAAWJKwzlZ3w/ZEe8lQtlEJYLGE2eoNmunuenPWC2T4al6OAaUvY3 s+SRAFW4krlkyhOQyNlrfNPHEBga X-Google-Smtp-Source: APXvYqwLN3Xpm7L089UBiNZXrXMsAWG/JFaeQymRYdRG2JdQ5KvwqVr7BEuApfSzhSjKL/TACl0Cpg== X-Received: by 2002:a9d:5e19:: with SMTP id d25mr17612089oti.316.1558789562790; Sat, 25 May 2019 06:06:02 -0700 (PDT) Original-Received: from mars (cpe-70-114-192-208.austin.res.rr.com. [70.114.192.208]) by smtp.gmail.com with ESMTPSA id 43sm1989046oth.47.2019.05.25.06.06.00 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 25 May 2019 06:06:01 -0700 (PDT) In-reply-to: <87h8cdqlb3.fsf@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:159752 Archived-At: Hi - Just following up on this since I didn't hear back. If people are interested, great. If not, I can close this bug report. As a quick reminder/TLDR - the proposal is to add a defcustom that governs whether TAB offers completion when hit the first time. The thinking is that if point is in the middle of a word, you may not want completion. Thanks, Alex On Fri 08 Mar 2019 at 12:21, Alex Branham wrote: > Hello - > > In ESS, we have 'ess-first-tab-never-complete' which governs whether TAB > offers completion. The gist of it is that if you're in a buffer (with | > representing point): > > (def|var foo) > > and you hit TAB, you might not want completion offered. I've put > together a patch that incorporates this into Emacs by adding a new > defcustom `tab-first-completion'. The values are currently based on > ESS's implementation, though we can certainly change that if we want. > Perhaps it should be a function that receives one argument (position) > and if it returns non-nil, then we complete? > > Is this something people would be interested in adding? > > Thanks, > Alex > > > From eb4c1a9c8bcd2f5018150b0502e8ed945c181e74 Mon Sep 17 00:00:00 2001 > From: Alex Branham > Date: Fri, 8 Mar 2019 12:09:04 -0600 > Subject: [PATCH] New defcustom tab-first-completion > > * lisp/indent.el (tab-always-indent): Mention 'tab-first-completion'. > (tab-first-completion): New defcustom. > (indent-for-tab-command): Use 'tab-first-completion'. > > Bug# > --- > lisp/indent.el | 40 +++++++++++++++++++++++++++++++++++++--- > 1 file changed, 37 insertions(+), 3 deletions(-) > > diff --git a/lisp/indent.el b/lisp/indent.el > index 34757a43d7..08087effa6 100644 > --- a/lisp/indent.el > +++ b/lisp/indent.el > @@ -51,6 +51,7 @@ If nil, hitting TAB indents the current line if point is at the left margin > or in the line's indentation, otherwise it inserts a \"real\" TAB character. > If `complete', TAB first tries to indent the current line, and if the line > was already indented, then try to complete the thing at point. > +See also `tab-first-completion'. > > Some programming language modes have their own variable to control this, > e.g., `c-tab-always-indent', and do not respect this variable." > @@ -60,6 +61,27 @@ e.g., `c-tab-always-indent', and do not respect this variable." > (const :tag "Indent if inside indentation, else TAB" nil) > (const :tag "Indent, or if already indented complete" complete))) > > +(defcustom tab-first-completion nil > + "Governs the behavior of TAB completion on the first press of the key. > +When nil, complete. When `eol', only complete if point is at the > +end of a line. When `word', complete unless the next character > +has word syntax (according to `syntax-after'). When > +`word-or-paren', complete unless the next character is part of a > +word or a parenthesis. When `word-or-paren-or-punct', complete > +unless the next character is part of a word, parenthesis, or > +punctuation. Typing TAB a second time always results in > +completion. > + > +This variable has no effect unless `tab-always-indent' is `complete'." > + :group 'indent > + :type '(choice > + (const :tag "Always complete" nil) > + (const :tag "Unless at the end of a line" 'eol) > + (const :tag "Unless looking at a word" 'word) > + (const :tag "Unless at a word or parenthesis" 'word-or-paren) > + (const :tag "Unless at a word, parenthesis, or punctuation." 'word-or-paren-or-punct)) > + :version "27.1") > + > > (defun indent-according-to-mode () > "Indent line in proper way for current major mode. > @@ -111,7 +133,7 @@ or performs symbol completion, depending on `tab-always-indent'. > The function called to actually indent the line or insert a tab > is given by the variable `indent-line-function'. > > -If a prefix argument is given, after this function indents the > +If a prefix argument is given (ARG), after this function indents the > current line or inserts a tab, it also rigidly indents the entire > balanced expression which starts at the beginning of the current > line, to reflect the current line's indentation. > @@ -139,7 +161,8 @@ prefix argument is ignored." > (t > (let ((old-tick (buffer-chars-modified-tick)) > (old-point (point)) > - (old-indent (current-indentation))) > + (old-indent (current-indentation)) > + (syn (syntax-after (point)))) > > ;; Indent the line. > (or (not (eq (indent--funcall-widened indent-line-function) 'noindent)) > @@ -152,7 +175,18 @@ prefix argument is ignored." > ;; If the text was already indented right, try completion. > ((and (eq tab-always-indent 'complete) > (eq old-point (point)) > - (eq old-tick (buffer-chars-modified-tick))) > + (eq old-tick (buffer-chars-modified-tick)) > + (or (null tab-first-completion) > + (eq last-command this-command) > + (and (equal tab-first-completion 'eol) > + (eolp)) > + (and (member tab-first-completion '(word word-or-paren word-or-paren-or-punct)) > + (not (member 2 syn))) > + (and (member tab-first-completion '(word-or-paren word-or-paren-or-punct)) > + (not (or (member 4 syn) > + (member 5 syn)))) > + (and (equal tab-first-completion 'word-or-paren-or-punct) > + (not (member 1 syn))))) > (completion-at-point)) > > ;; If a prefix argument was given, rigidly indent the following