emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ken Mankoff <mankoff@gmail.com>
To: Kyle Meyer <kyle@kyleam.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] 3 improvements to ob-screen
Date: Wed, 15 Jul 2020 08:48:15 -0700	[thread overview]
Message-ID: <87365s3hkw.fsf@gmail.com> (raw)
In-Reply-To: <87pn8x4grt.fsf@kyleam.com>

[-- Attachment #1: Type: text/plain, Size: 223 bytes --]


On 2020-07-14 at 20:08 -07, Kyle Meyer <kyle@kyleam.com> wrote...
> Could you add a changelog entry to the body of this commit message and
> the others?

I made the changes you requested. Updated patches attached.

  -k.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-screen-Execute-last-line-in-block-send-newline.patch --]
[-- Type: text/x-diff, Size: 825 bytes --]

From d7b7555969ce0e58653c5b5a78d9a4a0bebbacdf Mon Sep 17 00:00:00 2001
From: "Kenneth D. Mankoff" <mankoff@gmail.com>
Date: Tue, 14 Jul 2020 13:29:36 -0700
Subject: [PATCH 1/3] ob-screen: Execute last line in block (send newline)

* lisp/ob-screen.el (org-babel-screen-session-write-temp-file): insert
newline after body.
---
 lisp/ob-screen.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/ob-screen.el b/lisp/ob-screen.el
index 75a2dc691..3edc2c265 100644
--- a/lisp/ob-screen.el
+++ b/lisp/ob-screen.el
@@ -108,6 +108,7 @@ In case you want to use a different screen than one selected by your $PATH")
   (let ((tmpfile (org-babel-temp-file "screen-")))
     (with-temp-file tmpfile
       (insert body)
+      (insert "\n")
 
       ;; org-babel has superfluous spaces
       (goto-char (point-min))
-- 
2.25.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-ob-screen-Respect-session-name.-Don-t-prepend-org-ba.patch --]
[-- Type: text/x-diff, Size: 2486 bytes --]

From 05dcb2a9f9acb6d15c88ac67d9268243b620cf5e Mon Sep 17 00:00:00 2001
From: "Kenneth D. Mankoff" <mankoff@gmail.com>
Date: Tue, 14 Jul 2020 13:41:35 -0700
Subject: [PATCH 2/3] ob-screen: Respect :session name. Don't prepend
 'org-babel-session-'

* lisp/ob-screen.el (org-babel-prep-session:screen): Remove concat of
"org-babel-session-" string onto session name when creating session.

* lisp/ob-screen.el (org-babel-screen-session-socketname): Remove
concat of "org-babel-session-" string onto session name searching for
existing screen session.
---
 etc/ORG-NEWS      | 7 +++++++
 lisp/ob-screen.el | 6 ++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index c366f61e0..623fa9dc3 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -380,6 +380,13 @@ From ~org-enable-priority-commands~ to ~org-priority-enable-commands~.
 From ~org-show-priority~ to ~org-priority-show~.
 
 ** Miscellaneous
+*** =ob-screen.el=: Respect screen =:session= name
+
+Screen babel session are now named based on the =:session= header 
+argument (defaults to ~default~). 
+
+Previously all session names had  ~org-babel-session-~ prepended.
+
 *** Forward/backward paragraph functions in line with the rest of Emacs
 ~org-forward-paragraph~ and ~org-backward-paragraph~, bound to
 ~<C-UP>~ and ~<C-DOWN>~ functions mimic more closely behaviour of
diff --git a/lisp/ob-screen.el b/lisp/ob-screen.el
index 3edc2c265..fe4698203 100644
--- a/lisp/ob-screen.el
+++ b/lisp/ob-screen.el
@@ -62,8 +62,7 @@ In case you want to use a different screen than one selected by your $PATH")
          (process-name (concat "org-babel: terminal (" session ")")))
     (apply 'start-process process-name "*Messages*"
            terminal `("-T" ,(concat "org-babel: " session) "-e" ,org-babel-screen-location
-		      "-c" "/dev/null" "-mS" ,(concat "org-babel-session-" session)
-		      ,cmd))
+		      "-c" "/dev/null" "-mS" ,session ,cmd))
     ;; XXX: Is there a better way than the following?
     (while (not (org-babel-screen-session-socketname session))
       ;; wait until screen session is available before returning
@@ -97,8 +96,7 @@ In case you want to use a different screen than one selected by your $PATH")
 			 nil
 			 (mapcar
 			  (lambda (x)
-			    (when (string-match
-				   (concat "org-babel-session-" session) x)
+			    (when (string-match x)
 			      x))
 			  sockets)))))
     (when match-socket (car (split-string match-socket)))))
-- 
2.25.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-ob-screen-accept-screenrc-header-argument.patch --]
[-- Type: text/x-diff, Size: 2647 bytes --]

From d99c637f1cade54ab2f66b72ec32026a15aa03de Mon Sep 17 00:00:00 2001
From: "Kenneth D. Mankoff" <mankoff@gmail.com>
Date: Tue, 14 Jul 2020 13:48:52 -0700
Subject: [PATCH 3/3] ob-screen: accept :screenrc header argument

* lisp/ob-screen.el (org-babel-default-header-args:screen): Add
default header argument `:screenrc' and value "/dev/null".

* lisp/ob-screen.el (org-babel-prep-session:screen): Use header
argument in variable `screenrc' and not hard-coded value.
---
 etc/ORG-NEWS      | 6 ++++++
 lisp/ob-screen.el | 6 ++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 623fa9dc3..5fb2af22e 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -229,6 +229,12 @@ directory configured for ClojureScript will /not/ work.
 Babel Java blocks recognize header argument =:cmdargs= and pass its
 value in call to =java=.
 
+*** =ob-screen.el=: Screen now accepts =:screenrc= header argument
+
+Screen blocks now recognize the =:screenrc= header argument and pass
+its value to the screen command via the "-c" option. The default
+remains =/dev/null= (i.e. a clean screen session)
+
 *** =RET= and =C-j= now obey ~electric-indent-mode~
 
 Since Emacs 24.4, ~electric-indent-mode~ is enabled by default.  In
diff --git a/lisp/ob-screen.el b/lisp/ob-screen.el
index fe4698203..021fef60d 100644
--- a/lisp/ob-screen.el
+++ b/lisp/ob-screen.el
@@ -40,7 +40,8 @@
 In case you want to use a different screen than one selected by your $PATH")
 
 (defvar org-babel-default-header-args:screen
-  '((:results . "silent") (:session . "default") (:cmd . "sh") (:terminal . "xterm"))
+  '((:results . "silent") (:session . "default") (:cmd . "sh")
+    (:terminal . "xterm") (:screenrc . "/dev/null"))
   "Default arguments to use when running screen source blocks.")
 
 (defun org-babel-execute:screen (body params)
@@ -59,10 +60,11 @@ In case you want to use a different screen than one selected by your $PATH")
   (let* ((session (cdr (assq :session params)))
          (cmd (cdr (assq :cmd params)))
          (terminal (cdr (assq :terminal params)))
+         (screenrc (cdr (assq :screenrc params)))
          (process-name (concat "org-babel: terminal (" session ")")))
     (apply 'start-process process-name "*Messages*"
            terminal `("-T" ,(concat "org-babel: " session) "-e" ,org-babel-screen-location
-		      "-c" "/dev/null" "-mS" ,session ,cmd))
+		      "-c" ,screenrc "-mS" ,session ,cmd))
     ;; XXX: Is there a better way than the following?
     (while (not (org-babel-screen-session-socketname session))
       ;; wait until screen session is available before returning
-- 
2.25.1


  reply	other threads:[~2020-07-15 15:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-09 16:05 Patch: send 'return' after babel blocks sent to ob-screen [9.3.7 (9.3.7-12-g5d6868-elpaplus @ /home/kdm/.emacs.d/elpa/org-plus-contrib-20200706/)] Ken Mankoff
2020-07-14  4:55 ` Kyle Meyer
2020-07-14 21:00   ` [PATCH] 3 improvements to ob-screen Ken Mankoff
2020-07-15  3:08     ` Kyle Meyer
2020-07-15 15:48       ` Ken Mankoff [this message]
2020-07-16  3:01         ` Kyle Meyer
2020-07-16  3:12           ` Kyle Meyer
2020-07-16  4:46             ` Ken Mankoff

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=87365s3hkw.fsf@gmail.com \
    --to=mankoff@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=kyle@kyleam.com \
    /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).