emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Matt <matt@excalamus.com>
To: "Ihor Radchenko" <yantar92@posteo.net>
Cc: "osher jacob" <osherz5@gmail.com>,
	"emacs-orgmode" <emacs-orgmode@gnu.org>
Subject: Re: [BUG] ob-shell doesn't evaluate last line on Windows (cmd/cmdproxy) [9.6.1 ( @ c:/Users/Osher/AppData/Roaming/.emacs.d/elpa/org-9.6.1/)]
Date: Mon, 30 Jan 2023 01:00:37 -0500	[thread overview]
Message-ID: <18601435e3d.ff39cc9a634254.5523257640909678550@excalamus.com> (raw)
In-Reply-To: <87fsbxwrmw.fsf@localhost>


 ---- On Thu, 26 Jan 2023 04:51:19 -0500  Ihor Radchenko  wrote --- 

 > This will add a newline to "cmdproxy.exe" command -> "cmdproxy.exe\n".
 > You should instead look into `org-babel--write-temp-buffer-input-file'.

I made the change in `org-babel--shell-command-on-region' based on your recommendation in https://list.orgmode.org/orgmode/87bkmttv2h.fsf@localhost/

I'd be happy to put it in `org-babel--write-temp-buffer-input-file'.  Unfortunately, I don't understand why you suggest the change be made there.  Wouldn't it make more sense to insert the newline into the temp buffer that `org-babel--write-temp-buffer-input-file' writes from? 

I'm confused because I don't see a good way write a newline from `org-babel--write-temp-buffer-input-file'.  All the file writing functions[fn:1], with the exception of `with-temp-file', require a region's start and end and `with-temp-file' appears to overwrite the file.

;; 99.999% sure this isn't what you meant
 (defun org-babel--write-temp-buffer-input-file (input-file)
   "Write the contents of the current temp buffer into INPUT-FILE."
   (let ((start (point-min))
         (end (point-max)))
     (goto-char start)
     (push-mark (point) 'nomsg)
     (write-region start end input-file)
+    (with-temp-buffer
+      (insert "\n")
+      (write-region (point-min) (point-max) input-file))
     (delete-region start end)
     (exchange-point-and-mark)))

AFAICT, `org-babel--write-temp-buffer-input-file' is only called by `org-babel--shell-command-on-region' and that's only ever called by `org-babel-eval'.  That's where the query (the block source) is inserted into a temp buffer.  Maybe something like this?

modified   lisp/ob-eval.el
@@ -64,7 +64,7 @@ Writes QUERY into a temp-buffer that is processed with
   (let ((error-buffer (get-buffer-create " *Org-Babel Error*")) exit-code)
     (with-current-buffer error-buffer (erase-buffer))
     (with-temp-buffer
-      (insert query "\n")
+      (insert (concat query "\n"))
       (setq exit-code
             (org-babel--shell-command-on-region
              command error-buffer))

 [fn:1] https://www.gnu.org/software/emacs/manual/html_node/elisp/Writing-to-Files.html#Writing-to-Files





  reply	other threads:[~2023-01-30  6:01 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-16 16:27 [BUG] ob-shell doesn't evaluate last line on Windows (cmd/cmdproxy) [9.6.1 ( @ c:/Users/Osher/AppData/Roaming/.emacs.d/elpa/org-9.6.1/)] Osher Jacob
2023-01-16 21:40 ` Matt
2023-01-17  1:07   ` Matt
2023-01-17 19:53     ` Osher Jacob
2023-01-18  5:09       ` Matt
2023-01-18  9:05         ` Ihor Radchenko
2023-01-19 16:28           ` Osher Jacob
2023-01-20  4:29             ` Matt
2023-01-20  9:27               ` Ihor Radchenko
2023-01-23  3:12                 ` Matt
2023-01-23 11:42                   ` Ihor Radchenko
2023-01-26  4:04                   ` Matt
2023-01-26  9:51                     ` Ihor Radchenko
2023-01-30  6:00                       ` Matt [this message]
2023-01-30 14:00                         ` Ihor Radchenko
2023-01-30 17:08                           ` Matt
2023-02-01 12:05                             ` Ihor Radchenko
2023-02-01 20:21                               ` Matt
2023-01-20  9:24             ` Ihor Radchenko

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.orgmode.org/

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

  git send-email \
    --in-reply-to=18601435e3d.ff39cc9a634254.5523257640909678550@excalamus.com \
    --to=matt@excalamus.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=osherz5@gmail.com \
    --cc=yantar92@posteo.net \
    /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/org-mode.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).