From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#50470: 27.1; 'company-mode' 'eshell' Date: Sat, 22 Jan 2022 22:23:42 -0500 Message-ID: References: <87h7evegav.fsf@debian-BULLSEYE-live-builder-AMD64> <154bd0e9-2779-5a28-5587-a845a982e39f@yandex.ru> <815516d6-262b-4ef1-786e-ec5b4199847c@yandex.ru> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5727"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Christophe , 50470@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jan 23 04:24:43 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nBTUe-0001Fn-VB for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 23 Jan 2022 04:24:41 +0100 Original-Received: from localhost ([::1]:45808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nBTUd-0000ZE-GJ for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 22 Jan 2022 22:24:39 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:55310) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nBTU3-0000Yr-4k for bug-gnu-emacs@gnu.org; Sat, 22 Jan 2022 22:24:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45436) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nBTU2-0005a0-RS for bug-gnu-emacs@gnu.org; Sat, 22 Jan 2022 22:24:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nBTU2-0007n0-Hs for bug-gnu-emacs@gnu.org; Sat, 22 Jan 2022 22:24:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 23 Jan 2022 03:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50470 X-GNU-PR-Package: emacs Original-Received: via spool by 50470-submit@debbugs.gnu.org id=B50470.164290823529929 (code B ref 50470); Sun, 23 Jan 2022 03:24:02 +0000 Original-Received: (at 50470) by debbugs.gnu.org; 23 Jan 2022 03:23:55 +0000 Original-Received: from localhost ([127.0.0.1]:38339 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nBTTu-0007me-Nj for submit@debbugs.gnu.org; Sat, 22 Jan 2022 22:23:55 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:43230) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nBTTs-0007m9-Oo for 50470@debbugs.gnu.org; Sat, 22 Jan 2022 22:23:53 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 3920E100189; Sat, 22 Jan 2022 22:23:46 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 6FD83100134; Sat, 22 Jan 2022 22:23:44 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1642908224; bh=HZuJvKD3Dtw4TxQZr6P3GMw9DuzhCNI1ixYRGmwZ+Nw=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=mJJuX/SwsCziNuOzPtq6ZBxjaWjNId4snT0UNEt/tE8ESfVVH0vymo03Whhfms05+ 36necgjxrTQThq8EK1Q6ovlDDS+WQAl1L7pwFN2pDZzeaMZIgn3ZDGjRxbZ7hxg1Dp pxd3axsEQJu5yRcYv1fLH/LMzfR49SUr08p8rZLZD2FaMp0mAagPlxU1RQR+oKysp0 JXLfITB/L+p4cvE/MCL5TDeq8mGIeoyXmPctWDVeTObjdQJTsqVvEosG3xdKwSYBdP Ok+8YJAAVGKpcvyzXuaz7FFnSOgPKa9KQVAHYVGf1O8/BRJUBo2yb/ogy5Uuj85D9n TF16P4UgvDeng== Original-Received: from ceviche (unknown [216.154.30.173]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 1B8AC1206A6; Sat, 22 Jan 2022 22:23:44 -0500 (EST) In-Reply-To: <815516d6-262b-4ef1-786e-ec5b4199847c@yandex.ru> (Dmitry Gutov's message of "Mon, 6 Dec 2021 01:06:33 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:224882 Archived-At: > Some new details, from > https://github.com/company-mode/company-mode/discussions/1276: > > When this happens (the user types a quote character and the tab character is > inserted), there is a message in the echo area: > > Completion function pcomplete-completions-at-point uses a deprecated > calling convention > > I'm going to add Stefan to Cc in case maybe he had a quick fix in mind, > since I saw him reply to a similar-ish bug report about > pcomplete integration. I think I managed to reproduce the problem and get a good backtrace for the above with: src/emacs -Q -l .../company/company-autoloads.el \ -f eshell -f company-mode \ --eval '(advice-add `pcomplete-completions-at-point :around (lambda (orig-fun &rest args) (let ((buffer-read-only t) (debug-on-signal t)) (apply orig-fun args))))' \ --eval '(setq debug-on-error t debug-on-signal nil debug-ignored-errors nil)' \ -l company.el \ --eval "(progn (sit-for 1) (insert \"echo '\") \ (company-idle-begin (current-buffer) \ (selected-window)\ (buffer-chars-modified-tick)\ (point)))" And the 100% untested patch below is a suggestion for how to try and fix those kinds of bugs. Can someone try and maybe make it work? Stefan diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el index c6a51b1793..bc35c92493 100644 --- a/lisp/eshell/em-cmpl.el +++ b/lisp/eshell/em-cmpl.el @@ -311,18 +311,24 @@ eshell-completion-help (describe-prefix-bindings) (call-interactively 'pcomplete-help))) +(defun eshell--pcomplete-insert-tab () + (if (not pcomplete-allow-modifications) + (throw 'pcompleted nil) + (insert-and-inherit "\t") + (throw 'pcompleted t))) + (defun eshell-complete-parse-arguments () "Parse the command line arguments for `pcomplete-argument'." (when (and eshell-no-completion-during-jobs (eshell-interactive-process)) - (insert-and-inherit "\t") - (throw 'pcompleted t)) + (eshell--pcomplete-insert-tab)) (let ((end (point-marker)) (begin (save-excursion (eshell-bol) (point))) (posns (list t)) args delim) - (when (memq this-command '(pcomplete-expand - pcomplete-expand-and-complete)) + (when (and pcomplete-allow-modifications + (memq this-command '(pcomplete-expand + pcomplete-expand-and-complete))) (run-hook-with-args 'eshell-expand-input-functions begin end) (if (= begin end) (end-of-line)) @@ -335,14 +341,11 @@ eshell-complete-parse-arguments (setq begin (1+ (cadr delim)) args (eshell-parse-arguments begin end))) ((eq (car delim) ?\() - (eshell-complete-lisp-symbol) - (throw 'pcompleted t)) + (throw 'pcompleted (elisp-completion-at-point))) (t - (insert-and-inherit "\t") - (throw 'pcompleted t)))) + (eshell--pcomplete-insert-tab)))) (when (get-text-property (1- end) 'comment) - (insert-and-inherit "\t") - (throw 'pcompleted t)) + (eshell--pcomplete-insert-tab)) (let ((pos begin)) (while (< pos end) (if (get-text-property pos 'arg-begin) diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el index 289312e0bb..f9c5b00719 100644 --- a/lisp/pcomplete.el +++ b/lisp/pcomplete.el @@ -189,6 +189,16 @@ pcomplete-expand-before-complete `pcomplete-parse-arguments-function'." :type 'boolean) +(defvar pcomplete-allow-modifications nil + "If non-nil, allow effects in `pcomplete-parse-arguments-function'. +For the `pcomplete' command, it was common for functions in +`pcomplete-parse-arguments-function' to make modifications to the +buffer, like expanding variables are such. +For `completion-at-point-functions', this is not an option any more, so +this variable is used to tell `pcomplete-parse-arguments-function' +whether it can do the modifications like it used to, or whether +it should refrain from doing so.") + (defcustom pcomplete-parse-arguments-function #'pcomplete-parse-buffer-arguments "A function to call to parse the current line's arguments. @@ -392,6 +402,9 @@ pcomplete-completions-at-point ;; imposing the pcomplete UI over the standard UI. (catch 'pcompleted (let* ((pcomplete-stub) + (buffer-read-only + ;; Make sure the function obeys `pcomplete-allow-modifications'. + (if pcomplete-allow-modifications buffer-read-only t)) pcomplete-seen pcomplete-norm-func pcomplete-args pcomplete-last pcomplete-index (pcomplete-autolist pcomplete-autolist) @@ -526,6 +539,7 @@ pcomplete pcomplete-last-completion-raw nil) (catch 'pcompleted (let* ((pcomplete-stub) + (pcomplete-allow-modifications t) pcomplete-seen pcomplete-norm-func pcomplete-args pcomplete-last pcomplete-index (pcomplete-autolist pcomplete-autolist)