Michael Albinus <[email protected]> writes:

> Morgan Smith <[email protected]> writes:
>
> Hi Morgan,
>
>> Micheal I have a question about how Guix should package Emacs.
>>
>> Should Guix hard-code the shell path to `tramp-encoding-shell'?  I think the
>> answer is yes but since I have you here I thought I'd ask.
>
> tramp-encoding-shell is intended for the local shell, yes. Guix might
> hard code it. Keeep in mind that it is customizable; users can change
> it.
>

Thank you very much for the confirmation!  I will add this to my TODO list.

>> -(defcustom org-babel-remote-temporary-directory "/tmp/"
>> +(defcustom org-babel-remote-temporary-directory nil
>>    "Directory to hold temporary files on remote hosts."
>>    :group 'org-babel
>>    :type 'string)
>
> Just a minor nit: the initial value, nil, does not fit the :type
> `string'. Likely, Emacs sanity checks will blame it.
>

Fixed this issue and added a news entry!

Ihor: At this point I think it would be ok if I pushed these two patches
to main myself but I don't want to overstep.  I'm still figuring out how
I should use my new powers.  Let me know how we're finishing this and if
it would have been ok if I had finished it myself here and now.


>> Thank you very much!
>>
>> Morgan

>From 167fb51c9810b1bec702cd467df6d550ead8455a Mon Sep 17 00:00:00 2001
From: Morgan Smith <[email protected]>
Date: Wed, 22 Apr 2026 15:29:06 -0400
Subject: [PATCH 1/2] Testing: TRAMP integration: Use local PATH and tmpdir

* testing/org-test.el (org-test-with-tramp-remote-dir--worker): Set
`tramp-remote-path' and `tramp-tmpdir' to use the local values as this
is a mock TRAMP connection that is actually just the local system.
---
 testing/org-test.el | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/testing/org-test.el b/testing/org-test.el
index fc1b2342d..2928fa08c 100644
--- a/testing/org-test.el
+++ b/testing/org-test.el
@@ -291,8 +291,13 @@ org-test-with-tramp-remote-dir--worker
      (t (require 'tramp)
         (defvar tramp-methods)
         (defvar tramp-default-host-alist)
-        (let ((tramp-methods
-               (cons '("mock"
+        (defvar tramp-remote-path)
+        (let (;; "Remote" PATH is same as local PATH
+              (tramp-remote-path (cons 'tramp-own-remote-path
+                                       tramp-remote-path))
+              (tramp-methods
+               (cons `("mock"
+                       (tramp-tmpdir ,temporary-file-directory)
                        (tramp-login-program        "sh")
                        (tramp-login-args           (("-i")))
                        (tramp-remote-shell         "/bin/sh")
-- 
2.54.0

>From 7d17eea48b0be410ea21c11db5b2bf2b2ee3f4c5 Mon Sep 17 00:00:00 2001
From: Morgan Smith <[email protected]>
Date: Tue, 19 May 2026 12:35:44 -0400
Subject: [PATCH 2/2] ob-core: Obsolete `org-babel-remote-temporary-directory'

TRAMP is able to determine the remote tmpdir dynamically when the
function `temporary-file-directory' is run.  Lets use that instead of
re-inventing the system ourselves.

* etc/ORG-NEWS (Removed or renamed functions and variables): Announce
deprecation.
* lisp/ob-core.el (org-babel-remote-temporary-directory): Change
':type' to allow a nil value.  Change default value to nil.  Mark as
obsolete.
(org-babel-temp-directory): If `org-babel-remote-temporary-directory'
is not set, run "(temporary-file-directory)".
---
 etc/ORG-NEWS    |  7 +++++++
 lisp/ob-core.el | 16 ++++++++++++----
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index a8c68de7f..7ebfca558 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -219,6 +219,13 @@ cookie =[N%]=.
 
 ** Removed or renamed functions and variables
 
+*** ~org-babel-remote-temporary-directory~ is now obsolete
+
+Org babel now allows TRAMP to determine the best temporary directory.
+To customize the directory try setting the =tmpdir= property in
+~tramp-connection-properties~.  See [[info:tramp#Predefined connection
+information]] for more information.
+
 ** Miscellaneous
 
 *** Some internal function names in =org-colview= library have been changed
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 823b27b72..c564cee43 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -3580,10 +3580,15 @@ org-babel-temporary-stable-directory
 Used by `org-babel-temp-file'.  This directory will be removed on
 Emacs shutdown.")
 
-(defcustom org-babel-remote-temporary-directory "/tmp/"
+(defcustom org-babel-remote-temporary-directory nil
   "Directory to hold temporary files on remote hosts."
   :group 'org-babel
-  :type 'string)
+  :type '(choice (const :tag "Defer to TRAMP" nil)
+                 string))
+(make-obsolete-variable
+ 'org-babel-remote-temporary-directory
+ "Customize `tramp-connection-properties' to set the \"tmpdir\" property instead."
+ "10.0")
 
 (defmacro org-babel-result-cond (result-params scalar-form &rest table-forms)
   "Call the code to parse raw string results according to RESULT-PARAMS.
@@ -3610,8 +3615,11 @@ org-babel-result-cond
 (defmacro org-babel-temp-directory ()
   "Return temporary directory suitable for `default-directory'."
   `(if (file-remote-p default-directory)
-       (concat (file-remote-p default-directory)
-	       org-babel-remote-temporary-directory)
+       (with-suppressed-warnings ((obsolete org-babel-remote-temporary-directory))
+         (if org-babel-remote-temporary-directory
+             (concat (file-remote-p default-directory)
+	             org-babel-remote-temporary-directory)
+           (temporary-file-directory)))
      (or (and org-babel-temporary-directory
 	      (file-exists-p org-babel-temporary-directory)
 	      org-babel-temporary-directory)
-- 
2.54.0

Reply via email to