GNU logs - #25270, boring messages


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#25270: eshell -- programmatically send input -- feature request
Resent-From: Keith David Bershatsky <esq@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sun, 25 Dec 2016 19:02:01 +0000
Resent-Message-ID: <handler.25270.B.148269248714713 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 25270
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 25270 <at> debbugs.gnu.org
X-Debbugs-Original-To: bug-gnu-emacs@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.148269248714713
          (code B ref -1); Sun, 25 Dec 2016 19:02:01 +0000
Received: (at submit) by debbugs.gnu.org; 25 Dec 2016 19:01:27 +0000
Received: from localhost ([127.0.0.1]:54943 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1cLE2w-0003pE-Mm
	for submit <at> debbugs.gnu.org; Sun, 25 Dec 2016 14:01:27 -0500
Received: from eggs.gnu.org ([208.118.235.92]:55662)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <esq@HIDDEN>) id 1cLE2u-0003oz-59
 for submit <at> debbugs.gnu.org; Sun, 25 Dec 2016 14:01:24 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <esq@HIDDEN>) id 1cLE2n-0005cz-JA
 for submit <at> debbugs.gnu.org; Sun, 25 Dec 2016 14:01:19 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled
 version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:34491)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <esq@HIDDEN>) id 1cLE2n-0005cv-G6
 for submit <at> debbugs.gnu.org; Sun, 25 Dec 2016 14:01:17 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:46632)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <esq@HIDDEN>) id 1cLE2l-0003w5-Ne
 for bug-gnu-emacs@HIDDEN; Sun, 25 Dec 2016 14:01:17 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <esq@HIDDEN>) id 1cLE2i-0005c3-Kb
 for bug-gnu-emacs@HIDDEN; Sun, 25 Dec 2016 14:01:15 -0500
Received: from nov-007-i609.relay.mailchannels.net ([46.232.183.163]:53924)
 by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <esq@HIDDEN>) id 1cLE2h-0005V0-EY
 for bug-gnu-emacs@HIDDEN; Sun, 25 Dec 2016 14:01:12 -0500
X-Sender-Id: techassets|x-authuser|lawlist@HIDDEN
Received: from relay.mailchannels.net (localhost [127.0.0.1])
 by relay.mailchannels.net (Postfix) with ESMTP id 421061005BB
 for <bug-gnu-emacs@HIDDEN>; Sun, 25 Dec 2016 19:00:21 +0000 (UTC)
Received: from cp31.deluxehosting.com
 (ip-10-27-139-41.us-west-2.compute.internal [10.27.139.41])
 by relay.mailchannels.net (Postfix) with ESMTPA id DED3A100C6F
 for <bug-gnu-emacs@HIDDEN>; Sun, 25 Dec 2016 19:00:18 +0000 (UTC)
X-Sender-Id: techassets|x-authuser|lawlist@HIDDEN
Received: from cp31.deluxehosting.com (cp31.deluxehosting.com [10.107.128.240])
 (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384)
 by 0.0.0.0:2500 (trex/5.7.8); Sun, 25 Dec 2016 19:00:19 +0000
X-MC-Relay: Neutral
X-MailChannels-SenderId: techassets|x-authuser|lawlist@HIDDEN
X-MailChannels-Auth-Id: techassets
X-MC-Loop-Signature: 1482692419136:4194995530
X-MC-Ingress-Time: 1482692419136
Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:50339
 helo=server.local)
 by cp31.deluxehosting.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256)
 (Exim 4.87) (envelope-from <esq@HIDDEN>) id 1cLE1p-0002Sf-Kw
 for bug-gnu-emacs@HIDDEN; Sun, 25 Dec 2016 14:00:17 -0500
Date: Sun, 25 Dec 2016 11:00:16 -0800
Message-ID: <m28tr3omv3.wl%esq@HIDDEN>
From: Keith David Bershatsky <esq@HIDDEN>
MIME-Version: 1.0 (generated by   - "")
Content-Type: text/plain; charset=US-ASCII
X-AuthUser: lawlist@HIDDEN
X-Originating-IP: 45.48.239.195
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
 [fuzzy]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.4 (----)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.4 (----)

As far as I am aware, users of eshell have been limited to sending input programmatically by inserting the command into the eshell buffer (at the command prompt) and then executing `eshell-send-input`.  Some users (like myself) may feel that such a solution is lo-tech -- i.e., not very eloquent.  Perhaps this is because I, and perhaps others, am/are spoiled by functions available when running shell such as:

    (let ((buf (shell)))
      (comint-send-string buf "ls -la")
      (comint-send-input))

or

    (let ((buf (shell)))
      (comint-simple-send buf "ls -la"))

Here is a link to a thread entitled "How to programmatically execute a command in eshell?":

http://emacs.stackexchange.com/questions/7617/how-to-programmatically-execute-a-command-in-eshell

And the accepted answer is as follows:

    (with-current-buffer "*eshell*"
      (eshell-return-to-prompt)
      (insert "ls")
      (eshell-send-input))

The following is an example of how this new feature might be implemented:

SAMPLE USAGE:  (eshell-send-input nil nil nil "ls -la /")

(require 'eshell)

(defun eshell-send-input (&optional use-region queue-p no-newline input-string-a)
  "Send the input received to Eshell for parsing and processing.
After `eshell-last-output-end', sends all text from that marker to
point as input.  Before that marker, calls `eshell-get-old-input' to
retrieve old input, copies it to the end of the buffer, and sends it.
-  If USE-REGION is non-nil, the current region (between point and mark)
will be used as input.
-  If QUEUE-P is non-nil, input will be queued until the next prompt,
rather than sent to the currently active process.  If no process, the
input is processed immediately.
-  If NO-NEWLINE is non-nil, the input is sent without an implied final
newline."
  (interactive "P")
  ;; Note that the input string does not include its terminal newline.
  (let ((proc-running-p
          (and (eshell-interactive-process)
               (not queue-p)))
        (inhibit-point-motion-hooks t)
        after-change-functions)
    (unless (and proc-running-p
                 (not (eq (process-status (eshell-interactive-process)) 'run)))
      (if (or proc-running-p
              (>= (point) eshell-last-output-end))
        (goto-char (point-max))
        ;; This is for a situation when point is before `point-max'.
        (let ((copy (or input-string-a (eshell-get-old-input use-region))))
          (goto-char eshell-last-output-end)
          (insert-and-inherit copy)))
      (unless (or no-newline
                  (and eshell-send-direct-to-subprocesses
                       proc-running-p))
        (insert-before-markers-and-inherit ?\n))
      (if proc-running-p
        (progn
          (eshell-update-markers eshell-last-output-end)
          (if (or eshell-send-direct-to-subprocesses
                  (= eshell-last-input-start eshell-last-input-end))
            (unless no-newline
              (process-send-string (eshell-interactive-process) "\n"))
                (process-send-region (eshell-interactive-process)
                   eshell-last-input-start
                   eshell-last-input-end)))
        (if (and (null input-string-a) (= eshell-last-output-end (point)))
          ;; This next line is for a situation when nothing is there -- just make a new command prompt.
          (run-hooks 'eshell-post-command-hook)
          (let (input)
            (eshell-condition-case err
              (progn
                (setq input (or input-string-a
                                (buffer-substring-no-properties
                                   eshell-last-output-end (1- (point)))))
                (run-hook-with-args 'eshell-expand-input-functions
                        eshell-last-output-end (1- (point)))
                (let ((cmd (eshell-parse-command-input
                             eshell-last-output-end (1- (point)) nil input-string-a)))
                  (when cmd
                    (eshell-update-markers eshell-last-output-end)
                    (setq input (buffer-substring-no-properties
                                  eshell-last-input-start
                                  (1- eshell-last-input-end)))
                    (run-hooks 'eshell-input-filter-functions)
                    (and (catch 'eshell-terminal
                           (ignore
                             (if (eshell-invoke-directly cmd)
                               (eval cmd)
                               (eshell-eval-command cmd input))))
                         (eshell-life-is-too-much)))))
                  (quit
                    (eshell-reset t)
                    (run-hooks 'eshell-post-command-hook)
                    (signal 'quit nil))
                  (error
                    (eshell-reset t)
                    (eshell-interactive-print
                      (concat (error-message-string err) "\n"))
                    (run-hooks 'eshell-post-command-hook)
                    (insert-and-inherit input)))))))))

(defun eshell-parse-command-input (beg end &optional args input-string-b)
  "Parse the command input from BEG to END.
The difference is that `eshell-parse-command' expects a complete
command string (and will error if it doesn't get one), whereas this
function will inform the caller whether more input is required.
-  If nil is returned, more input is necessary (probably because a
multi-line input string wasn't terminated properly).  Otherwise, it
will return the parsed command."
  (let (delim command)
    (if (setq delim (catch 'eshell-incomplete
                      (ignore
                        (setq command (eshell-parse-command (cons beg end) args t input-string-b)))))
      (ignore
        (message "Expecting completion of delimiter %c ..."
          (if (listp delim)
              (car delim)
            delim)))
      command)))

(defun eshell-parse-command (command &optional args toplevel input-string-c)
  "Parse the COMMAND, adding ARGS if given.
COMMAND can either be a string, or a cons cell demarcating a buffer
region.  TOPLEVEL, if non-nil, means that the outermost command (the
user's input command) is being parsed, and that pre and post command
hooks should be run before and after the command."
  (let* (
      eshell--sep-terms
      (terms
        (if input-string-c
          (eshell-parse-arguments--temp-buffer input-string-c)
          (append
            (if (consp command)
              (eshell-parse-arguments (car command) (cdr command))
              (let ((here (point))
                    (inhibit-point-motion-hooks t))
                (with-silent-modifications
                  ;; FIXME: Why not use a temporary buffer and avoid this
                  ;; "insert&delete" business?  --Stef
                  (insert command)
                  (prog1
                      (eshell-parse-arguments here (point))
                    (delete-region here (point))))))
            args)))
      (commands
        (mapcar
          (function
            (lambda (cmd)
              (setq cmd (if (or (not (car eshell--sep-terms))
                                (string= (car eshell--sep-terms) ";"))
                          (eshell-parse-pipeline cmd)
                          `(eshell-do-subjob
                              (list ,(eshell-parse-pipeline cmd)))))
              (setq eshell--sep-terms (cdr eshell--sep-terms))
              (if eshell-in-pipeline-p
                cmd
                `(eshell-trap-errors ,cmd))))
          (eshell-separate-commands terms "[&;]" nil 'eshell--sep-terms))) )
    (let ((cmd commands))
      (while cmd
        (if (cdr cmd)
            (setcar cmd `(eshell-commands ,(car cmd))))
        (setq cmd (cdr cmd))))
    (if toplevel
      `(eshell-commands (progn
                                (run-hooks 'eshell-pre-command-hook)
                                (catch 'top-level (progn ,@commands))
                                (run-hooks 'eshell-post-command-hook)))
      (macroexp-progn commands))))

(defun eshell-parse-arguments--temp-buffer (input-string-d)
  "Parse all of the arguments at point from BEG to END.
Returns the list of arguments in their raw form.
Point is left at the end of the arguments."
  (with-temp-buffer
    (insert input-string-d)
    (let ((inhibit-point-motion-hooks t)
          (args (list t))
          delim)
      (with-silent-modifications
        (remove-text-properties (point-min) (point-max)
                                '(arg-begin nil arg-end nil))
        (goto-char (point-min))
        (if (setq
             delim
             (catch 'eshell-incomplete
               (while (not (eobp))
                 (let* ((here (point))
                        (arg (eshell-parse-argument)))
                   (if (= (point) here)
                       (error "Failed to parse argument '%s'"
                              (buffer-substring here (point-max))))
                   (and arg (nconc args (list arg)))))))
            (throw 'eshell-incomplete (if (listp delim)
                                          delim
                                        (list delim (point) (cdr args)))))
        (cdr args)))))




Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Keith David Bershatsky <esq@HIDDEN>
Subject: bug#25270: Acknowledgement (eshell -- programmatically send input
 -- feature request)
Message-ID: <handler.25270.B.148269248714713.ack <at> debbugs.gnu.org>
References: <m28tr3omv3.wl%esq@HIDDEN>
X-Gnu-PR-Message: ack 25270
X-Gnu-PR-Package: emacs
Reply-To: 25270 <at> debbugs.gnu.org
Date: Sun, 25 Dec 2016 19:02:02 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 bug-gnu-emacs@HIDDEN

If you wish to submit further information on this problem, please
send it to 25270 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
25270: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D25270
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#25270: eshell -- programmatically send input -- feature request
Resent-From: Lars Ingebrigtsen <larsi@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 13 May 2022 14:04:02 +0000
Resent-Message-ID: <handler.25270.B25270.165245058315619 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 25270
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Keith David Bershatsky <esq@HIDDEN>
Cc: Jim Porter <jporterbugs@HIDDEN>, 25270 <at> debbugs.gnu.org
Received: via spool by 25270-submit <at> debbugs.gnu.org id=B25270.165245058315619
          (code B ref 25270); Fri, 13 May 2022 14:04:02 +0000
Received: (at 25270) by debbugs.gnu.org; 13 May 2022 14:03:03 +0000
Received: from localhost ([127.0.0.1]:44427 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1npVsk-00043p-R9
	for submit <at> debbugs.gnu.org; Fri, 13 May 2022 10:03:03 -0400
Received: from quimby.gnus.org ([95.216.78.240]:37794)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1npVsj-00043M-Ng
 for 25270 <at> debbugs.gnu.org; Fri, 13 May 2022 10:03:02 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:
 References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=L9BliwpqGv57FXD0USP7C/QCml5ZxiBikikGNcjks9U=; b=se7xrcaNdiEpwU25hZcfgCYfbF
 7uXNdnXZewF1ClbY7ce00knmxectvBygkZdCe/isuc5z1NsYFqjIVN2UJna9z9PAunwDwROrPwOI7
 8FGs/mdta03VcC0nEuVbSnfQbcMgJ1Kloha6NbcQq322sSHkVMcF0KKyMHZl095+VlRo=;
Received: from [84.212.220.105] (helo=xo)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1npVsZ-0001LE-Qd; Fri, 13 May 2022 16:02:54 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
References: <m28tr3omv3.wl%esq@HIDDEN>
X-Now-Playing: Tom Tom Club's _Close To The Bone_: "On The Line Again"
Date: Fri, 13 May 2022 16:02:51 +0200
In-Reply-To: <m28tr3omv3.wl%esq@HIDDEN> (Keith David Bershatsky's message
 of "Sun, 25 Dec 2016 11:00:16 -0800")
Message-ID: <87tu9tsf78.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview:  Keith David Bershatsky <esq@HIDDEN> writes: > As far
 as I am aware,
 users of eshell have been limited to sending > input programmatically
 by inserting the command into the eshell buffer > (at the command prompt)
 and then executing `eshell-send- [...] 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Keith David Bershatsky <esq@HIDDEN> writes:

> As far as I am aware, users of eshell have been limited to sending
> input programmatically by inserting the command into the eshell buffer
> (at the command prompt) and then executing `eshell-send-input`.  Some
> users (like myself) may feel that such a solution is lo-tech -- i.e.,
> not very eloquent. 

[...]

> The following is an example of how this new feature might be implemented:
>
> SAMPLE USAGE:  (eshell-send-input nil nil nil "ls -la /")
>
> (require 'eshell)
>
> (defun eshell-send-input (&optional use-region queue-p no-newline input-string-a)

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

I think this makes sense, but I'm not very familiar with eshell
internals, so I've added Jim to the CCs; perhaps he has some comments.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#25270: eshell -- programmatically send input -- feature request
Resent-From: Jim Porter <jporterbugs@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Mon, 16 May 2022 05:47:01 +0000
Resent-Message-ID: <handler.25270.B25270.165268001520017 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 25270
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Lars Ingebrigtsen <larsi@HIDDEN>, Keith David Bershatsky <esq@HIDDEN>
Cc: 25270 <at> debbugs.gnu.org
Received: via spool by 25270-submit <at> debbugs.gnu.org id=B25270.165268001520017
          (code B ref 25270); Mon, 16 May 2022 05:47:01 +0000
Received: (at 25270) by debbugs.gnu.org; 16 May 2022 05:46:55 +0000
Received: from localhost ([127.0.0.1]:51426 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nqTZH-0005Cn-3Q
	for submit <at> debbugs.gnu.org; Mon, 16 May 2022 01:46:55 -0400
Received: from mail-pl1-f169.google.com ([209.85.214.169]:43874)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <jporterbugs@HIDDEN>) id 1nqTZF-0005Cb-Dz
 for 25270 <at> debbugs.gnu.org; Mon, 16 May 2022 01:46:53 -0400
Received: by mail-pl1-f169.google.com with SMTP id i17so13430631pla.10
 for <25270 <at> debbugs.gnu.org>; Sun, 15 May 2022 22:46:53 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=subject:to:cc:references:from:message-id:date:mime-version
 :in-reply-to:content-language:content-transfer-encoding;
 bh=zX3CRlfosN/ryxOWgxp2EvPNfvzEfYzxw+y+XmZzOZs=;
 b=SL8p/l7AtxBTx+X1ZS+kHxZrQQ6IJTFLmwIY+8C8JmCEmW63uasmNJARXp16z5Qehs
 87eT6Q11knWmfpXbLBkgjW+ekMNoah/ujuqcTRo+IEkSYxV1M6gMDXN1rcBNnF4Pq9gj
 fCrPWhO3Pi8RbISGo7qmAwjARW/IJIM+hILxxajAX5xxNwNjwu3TFUz1NIaK6i8HI9lR
 RQKSv2fVmSpNXAhOSNRyWyyfi3p257nNp1bm10lFE5j3PdAoWFTwE6hPMZCn30x/3BDC
 bXEf4oh/m4uBrYCpd3rcWYmdoUpXIVJ0CpJVRLO9fL8wDITamerhIUgjybJ/Xp8Vxep3
 Qs5A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:subject:to:cc:references:from:message-id:date
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=zX3CRlfosN/ryxOWgxp2EvPNfvzEfYzxw+y+XmZzOZs=;
 b=tir3jaiUzvBW8OUBz4FXL0dc4yUE7eAbBw/i3Uoyk/n96e6jrUZGYU9uWXTb2VaEq4
 ExCXRIg1gbAZOIMFf7Puv+ipIigdi9I93UpKhPr00hTuJQCJuvIe3A7VgVGCaLv/+Z0A
 dd3yssDxy2ldkh0thglgNtxXkgVGiTxUeMGtkYlAwxhz7L+e4aVUby+nLwP9aIT0mfgP
 2j6U+5aMQH1DovwDGanXETHdlOpNkpiUQgEN2mgeMoQ0JdSfp1FoJDfDLclGqffihZwA
 6/KXuipg5pJNbVg8BJ4olLLlzmgq3MwTqixRrBwl7IZ6MV+5M8VKC5uNnVi/IC5/eAPk
 9BSw==
X-Gm-Message-State: AOAM530nRCtKY79SxlbSpWgOHZ41h2Q+zO/D7sIU8p0pacCI+DCiBApX
 54GF9mNgHXJPaXBtvVifZXoWxOAzDR8=
X-Google-Smtp-Source: ABdhPJweEr5EV2dIzS0CG5Yo0qmL7DiOaEAtjBNdTKl0lGuiW79s920rwn/PCKtdArg6SXXKGvOv6A==
X-Received: by 2002:a17:902:6805:b0:161:8214:c170 with SMTP id
 h5-20020a170902680500b001618214c170mr2824379plk.11.1652680007475; 
 Sun, 15 May 2022 22:46:47 -0700 (PDT)
Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com.
 [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id
 f187-20020a62dbc4000000b0050dc762814bsm5893323pfg.37.2022.05.15.22.46.46
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Sun, 15 May 2022 22:46:47 -0700 (PDT)
References: <m28tr3omv3.wl%esq@HIDDEN> <87tu9tsf78.fsf@HIDDEN>
From: Jim Porter <jporterbugs@HIDDEN>
Message-ID: <9f52fe73-30ef-edf9-1d5b-2bf134e69dac@HIDDEN>
Date: Sun, 15 May 2022 22:46:47 -0700
MIME-Version: 1.0
In-Reply-To: <87tu9tsf78.fsf@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: -0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On 5/13/2022 7:02 AM, Lars Ingebrigtsen wrote:
> Keith David Bershatsky <esq@HIDDEN> writes:
> 
>> As far as I am aware, users of eshell have been limited to sending
>> input programmatically by inserting the command into the eshell buffer
>> (at the command prompt) and then executing `eshell-send-input`.  Some
>> users (like myself) may feel that such a solution is lo-tech -- i.e.,
>> not very eloquent.
> 
> [...]
> 
>> The following is an example of how this new feature might be implemented:
>>
>> SAMPLE USAGE:  (eshell-send-input nil nil nil "ls -la /")
>>
>> (require 'eshell)
>>
>> (defun eshell-send-input (&optional use-region queue-p no-newline input-string-a)
> 
> (I'm going through old bug reports that unfortunately weren't resolved
> at the time.)
> 
> I think this makes sense, but I'm not very familiar with eshell
> internals, so I've added Jim to the CCs; perhaps he has some comments.

Hm, I think it's reasonable to have something similar to 
`comint-send-string' for Eshell, but I'm not quite sure what the best 
way to do this would be. I think a separate function, like 
`eshell-send-string', would probably be a nicer API, since it could be 
called like `comint-send-string'.

Also, for the code posted in the original message, I'm not sure the 
changes to `eshell-parse-command' are needed. It should already let you 
pass a command string to it. Maybe this is because there's an issue with 
how `eshell-parse-command' temporarily inserts COMMAND into the buffer 
(see the FIXME comment in the code in the original message)? If there 
is, we'd probably have to think quite a bit more about how to resolve it.

Some background: I think it would be pretty risky to try to perform 
Eshell argument parsing anywhere *but* in the contents of the current 
Eshell buffer, as in `eshell-parse-arguments--temp-buffer' in the 
original message. See `eshell-with-temp-command' in Emacs 29 (which is 
what the FIXME comment morphed into), in particular this part:

          ;; Since parsing relies partly on buffer-local state
          ;; (e.g. that of `eshell-parse-argument-hook'), we need to
          ;; perform the parsing in the Eshell buffer.

Basically, Eshell is extremely flexible, and argument parsing is handled 
by `eshell-parse-argument-hook', which can do all sorts of things to 
change how arguments are parsed, and may even be buffer-local to a 
particular Eshell instance. Parsing Eshell arguments anywhere but the 
"target" Eshell buffer is asking for trouble.

I'll see if I can put together a patch along the above line in the next 
couple weeks.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#25270: eshell -- programmatically send input -- feature request
Resent-From: Lars Ingebrigtsen <larsi@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Mon, 16 May 2022 12:14:01 +0000
Resent-Message-ID: <handler.25270.B25270.165270320412337 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 25270
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Jim Porter <jporterbugs@HIDDEN>
Cc: Keith David Bershatsky <esq@HIDDEN>, 25270 <at> debbugs.gnu.org
Received: via spool by 25270-submit <at> debbugs.gnu.org id=B25270.165270320412337
          (code B ref 25270); Mon, 16 May 2022 12:14:01 +0000
Received: (at 25270) by debbugs.gnu.org; 16 May 2022 12:13:24 +0000
Received: from localhost ([127.0.0.1]:51971 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nqZbH-0003Cu-Qm
	for submit <at> debbugs.gnu.org; Mon, 16 May 2022 08:13:23 -0400
Received: from quimby.gnus.org ([95.216.78.240]:41984)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1nqZbG-0003Cf-Il
 for 25270 <at> debbugs.gnu.org; Mon, 16 May 2022 08:13:22 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:
 References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=Gx9dMr4fPhxzyWbWvuO/M8lo2lvXv0+OliBoLAFHswU=; b=rl+VaqaOntFXjTqKF0Rh1bST3x
 ADtlt9aC9lSRr4jxvb/UwyWltmsa88Z+Jn+X7b6F1BvAYJ/FfH3rAnHCeCAeArf4Smnwu4lKhki0I
 axp7ihBCkg4R1S9/HqaVkgsUbcLJUAUq+BiJqmbUQ6HPkSLBHDSBjwFmnf+J3BNkspLw=;
Received: from [84.212.220.105] (helo=xo)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1nqZb7-0004bK-4I; Mon, 16 May 2022 14:13:15 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
References: <m28tr3omv3.wl%esq@HIDDEN> <87tu9tsf78.fsf@HIDDEN>
 <9f52fe73-30ef-edf9-1d5b-2bf134e69dac@HIDDEN>
Date: Mon, 16 May 2022 14:13:11 +0200
In-Reply-To: <9f52fe73-30ef-edf9-1d5b-2bf134e69dac@HIDDEN> (Jim Porter's
 message of "Sun, 15 May 2022 22:46:47 -0700")
Message-ID: <87o7zxfzfs.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview:  Jim Porter <jporterbugs@HIDDEN> writes: > Also, for the
 code posted in the original message,
 I'm not sure the > changes to `eshell-parse-command'
 are needed. It should already let > you pass a command string to it. Maybe
 this is because the [...] 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Jim Porter <jporterbugs@HIDDEN> writes:

> Also, for the code posted in the original message, I'm not sure the
> changes to `eshell-parse-command' are needed. It should already let
> you pass a command string to it. Maybe this is because there's an
> issue with how `eshell-parse-command' temporarily inserts COMMAND into
> the buffer (see the FIXME comment in the code in the original
> message)? If there is, we'd probably have to think quite a bit more
> about how to resolve it.

Yes, if I understood correctly, that was the main problem -- inserting
things into the buffer to eval it sometimes leaves artefacts (or doesn't
work), so it'd be better to talk directly to the underlying shell to get
things evalled.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





Last modified: Mon, 16 May 2022 12:15:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.