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: Fri, 08 Mar 2019 12:21:20 -0600 Message-ID: <87h8cdqlb3.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="40105"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: mu4e 1.1.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 Fri Mar 08 19:22:25 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 1h2K8W-000AKB-8B for geb-bug-gnu-emacs@m.gmane.org; Fri, 08 Mar 2019 19:22:24 +0100 Original-Received: from localhost ([127.0.0.1]:48113 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2K8V-00011O-56 for geb-bug-gnu-emacs@m.gmane.org; Fri, 08 Mar 2019 13:22:23 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:49421) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2K8C-0000xy-6b for bug-gnu-emacs@gnu.org; Fri, 08 Mar 2019 13:22:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2K8B-0000AG-6M for bug-gnu-emacs@gnu.org; Fri, 08 Mar 2019 13:22:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51320) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h2K8B-00009s-34 for bug-gnu-emacs@gnu.org; Fri, 08 Mar 2019 13:22:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1h2K8A-0008DB-OW for bug-gnu-emacs@gnu.org; Fri, 08 Mar 2019 13:22:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alex Branham Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 08 Mar 2019 18:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 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.155206929631514 (code B ref -1); Fri, 08 Mar 2019 18:22:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 8 Mar 2019 18:21:36 +0000 Original-Received: from localhost ([127.0.0.1]:36631 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h2K7j-0008CD-FE for submit@debbugs.gnu.org; Fri, 08 Mar 2019 13:21:35 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:34895) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h2K7h-0008Bv-IW for submit@debbugs.gnu.org; Fri, 08 Mar 2019 13:21:34 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:59619) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h2K7c-0008Js-Cb for submit@debbugs.gnu.org; Fri, 08 Mar 2019 13:21:28 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:49249) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2K7Z-0000Wl-Ul for bug-gnu-emacs@gnu.org; Fri, 08 Mar 2019 13:21:28 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2K7Y-0008H6-Sq for bug-gnu-emacs@gnu.org; Fri, 08 Mar 2019 13:21:25 -0500 Original-Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]:46239) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h2K7Y-0008G9-Ld for bug-gnu-emacs@gnu.org; Fri, 08 Mar 2019 13:21:24 -0500 Original-Received: by mail-ot1-x329.google.com with SMTP id c18so18150190otl.13 for ; Fri, 08 Mar 2019 10:21:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=user-agent:from:to:subject:date:message-id:mime-version; bh=Up2ogg63I35AhXEkdxWVX/N9UHaEOLWBrrrkVP9OP8A=; b=pEBEK1Y/AqdDA5cjFA/+/JggbDJichHjmQ+8/rtzaNXXE5sq1sfH0u2OBB/EPqT+C+ kRXcmMeFJ5FITegJi2VvcVsvnH+On8Y9JFssfgBlOhQdnT0rhwAkJVUBqPjMFwcn9roY NwEzdlbY1SakkTzSQ9TEFwI3DV4yb4QzSPhpvc0TM5/K5GJxYPNQFEB04KHyeD/vxh+j EWFGRN+DmuRSUEMetJHJeO+x2NOI02Ofd4IRaXr3b05ZCPcFZxxULJrsNsZf/FBOHI6E /4OwZmv8xir7lOPXoTRvfZJFHfbGOTdEASHwG7nZQHhpECixTDYGC68vq4tqWGUQxgkt kJPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:user-agent:from:to:subject:date:message-id :mime-version; bh=Up2ogg63I35AhXEkdxWVX/N9UHaEOLWBrrrkVP9OP8A=; b=tdTWLcXE2AhLMavwFx5rcjlZXrLYdgLq7rtzV7qcJpQKtKbp4GnwwkD4549fg4NOAb 0AY/7IDHd1ymRb38eQrub5329RxuqXechom0kCS8zxqG4sp+GFGEBmjY58jOWMn4aC9C yFzZ3JRAUEhkHvBWaDtP1F8nI8v2AybsfCzHS0+qwA0PLfrtSyKEAgZpULUnTqAug7Tx EfCukiHvz/2xYW1hKDvMLvz/cyBJtQ+7nsSgQru3bj6XWYBuwkex5TCUXiMZVefg6rwu WjIUFzdHSfFUysaqUfF2EupYNjv4nGhb8ct4puUcgcVGgWIvSwq7QO4K80nvxe/GMKAc cA5A== X-Gm-Message-State: APjAAAVPba2GJkkiX3NA6zN/bwXmchn7CJnGcRKuUjsb0AbLi4ueNbLl XvMSY2i6lDWoWza69UFPklb/cJnG X-Google-Smtp-Source: APXvYqyL6kB2IvowhnAJQAKPwjNDRVhhtH074g2uhG58fQ8PXoxfp5XQ9iHKx3OiJlk/1luSIrSEGw== X-Received: by 2002:a05:6830:1297:: with SMTP id z23mr13470007otp.257.1552069283086; Fri, 08 Mar 2019 10:21:23 -0800 (PST) Original-Received: from earth (cpe-70-114-192-208.austin.res.rr.com. [70.114.192.208]) by smtp.gmail.com with ESMTPSA id j18sm3256437otl.40.2019.03.08.10.21.21 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Mar 2019 10:21:22 -0800 (PST) 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:156156 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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=20eb4c1a9c8bcd2f5018150b0502e8ed945c181e74 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# =2D-- 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 =2D-- 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 characte= r. 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 var= iable." (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." 'wo= rd-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'. =2DIf 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)) =2D (old-indent (current-indentation))) + (old-indent (current-indentation)) + (syn (syntax-after (point)))) ;; Indent the line. (or (not (eq (indent--funcall-widened indent-line-function) 'noinden= t)) @@ -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)) =2D (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 wo= rd-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 =2D- 2.19.2 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEeEJ4XAMgliXNXicpHkInolPpmscFAlyCsqAACgkQHkInolPp msdkGQf/bC9TfBOy/3XXrdrrEjM3rMO+/9EYpgq/yHnqUa/ergq1oFeA9NR00gnS qrvQVeXKhM3yJ2aiT6SXp+rZYHE/Kw4As+3qbuqYXYHHtBC+ti+mNA1TNJuGqqgi qeUetS4jIBy3Es+UAf+suZk6FZpUrafOT2F6AChhhq1LI3SHRTWd/g5LBvZSZgbl lf27jNdDJn+TtNiAIhRiIWXN6wEOnEhgQ651ZGRMhjkM+n++R+od6SZm4pmA505U HMjqCgEFp0GEQ0HI2WXK5/8lRL/9/QQqzwplw6orTU5M5mRmPqywYipTTY3HaUH+ XaiJxhWZ6pIkbnKgKMFQS28k+iiP3g== =kepH -----END PGP SIGNATURE----- --=-=-=--