~ruther/guix-local

ref: f3d2705f64ac3ef2dcdcd0d48eed413fb1fdab40 guix-local/gnu/packages/patches/emacs-elisp-autofmt-fix-region-send.patch -rw-r--r-- 2.6 KiB
f3d2705f — Cayetano Santos gnu: ieee-p1076: Move to hdl. 30 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Author: Danny Milosavljevic <dannym@friendly-machines.com>
Date: 2025-10-14
Subject: Fix stdin-buffer handling in make-process path

On Windows, make-process hangs, so a workaround path uses call-process
with a temporary stderr file instead. This workaround path correctly
handles the stdin-buffer parameter: only sending input when stdin-buffer
is non-nil.

The make-process path (used on Unix-like systems) was missing this
logic.  It unconditionally sent data from whatever buffer was current at
function entry, completely ignoring the stdin-buffer parameter.

This caused two bugs in the make-process path:
1. When stdin-buffer is nil, it incorrectly sent data instead of closing
   stdin immediately.
2. When stdin-buffer is non-nil, it sent data from the wrong buffer.

The fix adds the same conditional logic as the workaround path.
  
diff -ru orig/emacs-elisp-autofmt/elisp-autofmt.el emacs-elisp-autofmt/elisp-autofmt.el
--- orig/emacs-elisp-autofmt/elisp-autofmt.el	2025-10-01 11:52:38.833698871 +0200
+++ emacs-elisp-autofmt/elisp-autofmt.el	2025-10-02 09:43:45.366455005 +0200
@@ -518,8 +518,12 @@
                 (setq sentinel-called-expect 2)
                 (set-process-sentinel proc-err (lambda (_proc _msg) (incf sentinel-called))))
 
-              (process-send-region proc-out (point-min) (point-max))
-              (process-send-eof proc-out)
+              (if stdin-buffer
+                  (with-current-buffer stdin-buffer
+                    (process-send-region proc-out (point-min) (point-max))
+                    (process-send-eof proc-out))
+                ;; If there is no input buffer, just close the process's stdin immediately.
+                (process-send-eof proc-out))
 
               (while (/= sentinel-called sentinel-called-expect)
                 (accept-process-output))
diff -ru orig/emacs-elisp-autofmt/tests/test_generate_defs.py emacs-elisp-autofmt/tests/test_generate_defs.py
--- orig/emacs-elisp-autofmt/tests/test_generate_defs.py	2025-10-01 11:52:38.834538726 +0200
+++ emacs-elisp-autofmt/tests/test_generate_defs.py	2025-10-02 09:55:24.504676023 +0200
@@ -101,7 +101,7 @@
     def test_check_simple(self) -> None:
         data = generate_defs_package_as_json("subr")
         self.assertEqual(data['functions']['with-syntax-table'], ['macro', 1, 'many', {'indent': 1}])
-        self.assertEqual(data['functions']['defvar-local'], ['macro', 1, 'many', {'doc-string': 3, 'indent': 'defun'}])
+        self.assertEqual(data['functions']['defvar-local'], ['macro', 2, 3, {'doc-string': 3, 'indent': 2}])
 
 
 class SimpleTestBuiltinPackage_Simple(unittest.TestCase):