emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ken Mankoff <mankoff@gmail.com>
To: Kyle Meyer <kyle@kyleam.com>, emacs-orgmode@gnu.org
Subject: [PATCH] 3 improvements to ob-screen
Date: Tue, 14 Jul 2020 14:00:20 -0700	[thread overview]
Message-ID: <87h7u93j8b.fsf@gmail.com> (raw)
In-Reply-To: <874kqa66hb.fsf@kyleam.com>

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

Hello,

The attached three patches implement a bug fix, a simplification, and a new feature to ob-screen.

bug fix: 001 Execute last line in block (send newline)
simplify: 002 Don't add extra characters to session name
feature: 003 Accept :screenrc header argument

I've signed the FSF docs but do not see my name here: https://orgmode.org/worg/org-contribute.html under "Current contributors".

  -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: 734 bytes --]

From cb014cd2da79b30967dd24fba37d7f75569ed92d 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 | 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: 2185 bytes --]

From e6ee8bff913da35a0183f8e2c1db7021342492d9 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-'

---
 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: 2394 bytes --]

From 866f3c4788e58bf26dcf9c90cb7638f48a6a4ecc 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

---
 etc/ORG-NEWS      | 6 ++++++
 lisp/ob-screen.el | 5 +++--
 2 files changed, 9 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..7115080f8 100644
--- a/lisp/ob-screen.el
+++ b/lisp/ob-screen.el
@@ -40,7 +40,7 @@
 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 +59,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-14 21:01 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   ` Ken Mankoff [this message]
2020-07-15  3:08     ` [PATCH] 3 improvements to ob-screen Kyle Meyer
2020-07-15 15:48       ` Ken Mankoff
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=87h7u93j8b.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).