unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Jim Porter <jporterbugs@gmail.com>
To: Dmitry Gutov <dgutov@yandex.ru>,
	Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Christophe <ch.bollard@laposte.net>,
	50470@debbugs.gnu.org, John Wiegley <johnw@gnu.org>
Subject: bug#50470: 27.1; 'company-mode' 'eshell'
Date: Thu, 16 Mar 2023 23:26:44 -0700	[thread overview]
Message-ID: <00ad5c72-20c5-d27e-2bc8-6436858bbd8d@gmail.com> (raw)
In-Reply-To: <b9a01ada-9415-afe0-941e-3f22fb4bd99d@yandex.ru>

I've recently been digging through how Eshell and Pcomplete interact, so 
I think I understand what's happening here.

On 6/7/2022 3:39 PM, Dmitry Gutov wrote:
> pcomplete-completions-at-point somehow has pcomplete-stub pointing to 
> the necessary value (e.g. "/home/dgutov/Do") in the asterisk-less cases 
> (due to some other code path being taken), but not in this specific one.

I believe the problem is that when Eshell parses the command line to 
figure out what to give Pcomplete, it expands the globs itself, so 
things get messed up. So we want to prevent glob-expansion before 
passing to Pcomplete.

The below patch does this, but it's probably not the right way to do it. 
  However, it's a simple change, and before I go through the larger 
effort of a proper patch, I want to be sure I'm actually solving the 
right thing.

For some background/explanation of how I'm thinking we should solve 
this: in Emacs 30, while fixing some other completion issues, I added 
'eshell-complete--eval-argument-form' (Emacs 29 does a similar thing, 
but the code is in 'eshell-complete-parse-arguments'). We probably want 
to enhance this function so that it only evaluates Eshell arguments 
forms that we know are ok. For a fun example of why the current behavior 
is wrong, try pressing TAB at the end of this command: "cd ${sleep 5; 
echo Doc}". Yes, it actually *runs* that subcommand before passing it to 
Pcomplete. :/


--------------------------------------------------


diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el
index b65652019d4..7168f91d774 100644
--- a/lisp/eshell/em-cmpl.el
+++ b/lisp/eshell/em-cmpl.el
@@ -325,6 +325,10 @@ eshell-complete-parse-arguments
        (if (= begin end)
           (end-of-line))
        (setq end (point-marker)))
+    ;; Don't expand globs when parsing arguments; we want to pass any
+    ;; globs to Pcomplete unaltered.
+    (let ((eshell-parse-argument-hook (remq #'eshell-parse-glob-chars
+                                            eshell-parse-argument-hook)))
        (if (setq delim
                 (catch 'eshell-incomplete
                   (ignore
@@ -341,7 +345,7 @@ eshell-complete-parse-arguments
                  ((member (car delim) '("(" "$("))
                  (throw 'pcompleted (elisp-completion-at-point)))
                 (t
-              (eshell--pcomplete-insert-tab))))
+                (eshell--pcomplete-insert-tab)))))
      (when (get-text-property (1- end) 'comment)
        (eshell--pcomplete-insert-tab))
      (let ((pos (1- end)))






  reply	other threads:[~2023-03-17  6:26 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
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 [this message]
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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=00ad5c72-20c5-d27e-2bc8-6436858bbd8d@gmail.com \
    --to=jporterbugs@gmail.com \
    --cc=50470@debbugs.gnu.org \
    --cc=ch.bollard@laposte.net \
    --cc=dgutov@yandex.ru \
    --cc=johnw@gnu.org \
    --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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).