Commit c61167f98756

Vincent Demeester <vincent@sbr.pm>
2026-02-26 11:25:29
emacs: added phscroll and improved pi-coding-agent config
Added phscroll (smooth horizontal scrolling) as a custom Nix package and configured it in emacs. Switched pi-coding-agent to use the 'pir' executable, removed ispell from completion in pi input buffers to fix corfu conflicts, and added a post-command hook to auto-resync status when OSC escape sequences in RPC output corrupt event parsing.
1 parent 378364e
Changed files (3)
dots
config
emacs
home
common
pkgs
dots/config/emacs/init.el
@@ -2924,6 +2924,9 @@ the appropriate file in ~/.local/share/imapfilter-rules/"
 	 "CLOUD_ML_REGION" "us-east5"
 	 "ANTHROPIC_VERTEX_PROJECT_ID" "itpc-gcp-pnd-pe-eng-claude")))
 
+(use-package phscroll
+  :defer t)
+
 (use-package pi-coding-agent
   :commands (pi-coding-agent)
   :init (defalias 'pi #'pi-coding-agent)
@@ -2932,8 +2935,32 @@ the appropriate file in ~/.local/share/imapfilter-rules/"
   (pi-coding-agent-input-window-height 10)
   (pi-coding-agent-tool-preview-lines 10)
   (pi-coding-agent-bash-preview-lines 5)
+  (pi-coding-agent-executable '("pir"))
   (pi-coding-agent-context-warning-threshold 70)
-  (pi-coding-agent-context-error-threshold 90))
+  (pi-coding-agent-context-error-threshold 90)
+  :config
+  ;; Remove ispell from completion in pi input buffer (conflicts with corfu)
+  (add-hook 'pi-coding-agent-input-mode-hook
+            (lambda ()
+              (remove-hook 'completion-at-point-functions #'ispell-completion-at-point t)))
+  ;; Auto-resync status when pi reports idle but Emacs thinks it's streaming
+  ;; Workaround for OSC escape sequences in RPC output breaking event parsing
+  (add-hook 'pi-coding-agent-input-mode-hook
+            (lambda ()
+              (add-hook 'post-command-hook
+                        (lambda ()
+                          (when-let ((chat-buf (pi-coding-agent--get-chat-buffer)))
+                            (with-current-buffer chat-buf
+                              (when (and (eq pi-coding-agent--status 'streaming)
+                                         (pi-coding-agent--state-needs-verification-p))
+                                (pi-coding-agent--rpc-async
+                                 pi-coding-agent--process
+                                 '(:type "get_state")
+                                 (lambda (r)
+                                   (when (buffer-live-p chat-buf)
+                                     (with-current-buffer chat-buf
+                                       (pi-coding-agent--update-state-from-response r)))))))))
+                        nil t))))
 
 (use-package devdocs
   :commands (devdocs-lookup devdocs-install vde/install-devdocs)
home/common/dev/emacs.nix
@@ -23,7 +23,6 @@ let
       age
       agent-shell
       aggressive-indent
-      pi-coding-agent
       aidermacs
       alert
       async
@@ -137,6 +136,8 @@ let
       ox-jira
       ox-tufte
       pandoc-mode
+      pi-coding-agent
+      pkgs.phscroll
       popon
       popper
       rg
pkgs/default.nix
@@ -75,4 +75,14 @@ in
     };
   };
 
+  phscroll = compileEmacsFiles {
+    name = "phscroll";
+    src = pkgs.fetchFromGitHub {
+      owner = "misohena";
+      repo = "phscroll";
+      rev = "582abedb4cf6aba216cdb5fe7217d612a1d68d5a";
+      hash = "sha256-LklBCgDYnC1SF2MD5LDI/CoQVSWlmrG83JGa155z4DI=";
+    };
+  };
+
 }