From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: Christophe <ch.bollard@laposte.net>, 50470@debbugs.gnu.org
Subject: bug#50470: 27.1; 'company-mode' 'eshell'
Date: Sat, 22 Jan 2022 22:23:42 -0500 [thread overview]
Message-ID: <jwvk0ercrp5.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <815516d6-262b-4ef1-786e-ec5b4199847c@yandex.ru> (Dmitry Gutov's message of "Mon, 6 Dec 2021 01:06:33 +0300")
> 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)
next prev parent reply other threads:[~2022-01-23 3:23 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-08 6:23 bug#50470: 27.1; 'company-mode' 'eshell' Christophe via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-08 16:00 ` bug#50470: eshell Christophe via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-08 16:07 ` Christophe via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-09 1:57 ` bug#50470: 27.1; 'company-mode' 'eshell' Dmitry Gutov
2021-09-09 5:48 ` Christophe via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-09 12:06 ` Dmitry Gutov
2021-09-09 13:09 ` Christophe via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-09 23:30 ` Dmitry Gutov
2021-09-10 5:11 ` Christophe via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-12-05 22:06 ` Dmitry Gutov
2021-12-10 10:50 ` jakanakaevangeli
2021-12-10 13:10 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-12-13 2:45 ` Dmitry Gutov
2021-12-13 3:14 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-01-23 3:23 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-01-24 1:50 ` Dmitry Gutov
2022-01-25 23:05 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-04 22:29 ` Dmitry Gutov
2022-06-05 0:17 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-05 0:36 ` Dmitry Gutov
2022-06-05 0:53 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-05 23:45 ` Dmitry Gutov
2022-06-06 1:34 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-06 9:07 ` Dmitry Gutov
2022-06-07 15:52 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-07 22:39 ` Dmitry Gutov
2023-03-17 6:26 ` Jim Porter
2023-03-18 1:01 ` Dmitry Gutov
2023-03-18 6:36 ` Jim Porter
2023-03-19 18:39 ` Jim Porter
2023-03-20 0:30 ` Jim Porter
2023-03-20 1:34 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-21 2:30 ` Jim Porter
2023-03-28 0:41 ` Dmitry Gutov
2023-03-28 4:06 ` Jim Porter
2023-03-28 6:10 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-28 17:43 ` Drew Adams
2023-03-28 19:35 ` Jim Porter
2023-03-28 21:21 ` Dmitry Gutov
2022-06-05 23:52 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-07 22:10 ` Dmitry Gutov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvk0ercrp5.fsf-monnier+emacs@gnu.org \
--to=bug-gnu-emacs@gnu.org \
--cc=50470@debbugs.gnu.org \
--cc=ch.bollard@laposte.net \
--cc=dgutov@yandex.ru \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.