fix: sync 9P operations with actual filesystem interface
- Session creation: write KV pairs to s/new instead of root ctl;
always inject cwd (required) from default-directory if not provided
- Session kill: use delete-directory on s/{id} instead of root ctl
- Remove ollie--write-root-ctl and ollie--ctl-path (no root ctl exists)
- Diff colorizer: match +/− (U+FF0B/U+2212) emitted by file_edit/file_write
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
30b11c3a6a
commit
fa13794468
32
ollie.el
32
ollie.el
|
|
@ -88,12 +88,12 @@ An alist of (KEY . VALUE) string pairs; valid keys are
|
||||||
|
|
||||||
;;;; ──────────────── Paths ────────────────
|
;;;; ──────────────── Paths ────────────────
|
||||||
|
|
||||||
(defun ollie--ctl-path ()
|
|
||||||
(expand-file-name "ctl" ollie-mount-directory))
|
|
||||||
|
|
||||||
(defun ollie--sessions-dir ()
|
(defun ollie--sessions-dir ()
|
||||||
(expand-file-name "s" ollie-mount-directory))
|
(expand-file-name "s" ollie-mount-directory))
|
||||||
|
|
||||||
|
(defun ollie--sessions-new-path ()
|
||||||
|
(expand-file-name "new" (ollie--sessions-dir)))
|
||||||
|
|
||||||
(defun ollie--session-file (name)
|
(defun ollie--session-file (name)
|
||||||
"Return the full path to file NAME inside the current session directory.
|
"Return the full path to file NAME inside the current session directory.
|
||||||
Signals `user-error' if no session is active."
|
Signals `user-error' if no session is active."
|
||||||
|
|
@ -118,9 +118,6 @@ Signals `user-error' if no session is active."
|
||||||
(insert-file-contents path)
|
(insert-file-contents path)
|
||||||
(buffer-string))))
|
(buffer-string))))
|
||||||
|
|
||||||
(defun ollie--write-root-ctl (cmd)
|
|
||||||
"Write CMD (without trailing newline) to the root ctl file."
|
|
||||||
(ollie--fwrite (ollie--ctl-path) (concat cmd "\n")))
|
|
||||||
|
|
||||||
;;;; ──────────────── Session enumeration ────────────────
|
;;;; ──────────────── Session enumeration ────────────────
|
||||||
|
|
||||||
|
|
@ -161,14 +158,17 @@ Returns the new session ID."
|
||||||
(user-error "ollie-9p not mounted at %s (customize `ollie-mount-directory')"
|
(user-error "ollie-9p not mounted at %s (customize `ollie-mount-directory')"
|
||||||
ollie-mount-directory))
|
ollie-mount-directory))
|
||||||
(let* ((effective-opts (or opts ollie-default-session-opts))
|
(let* ((effective-opts (or opts ollie-default-session-opts))
|
||||||
|
;; cwd is required; inject it if not already present.
|
||||||
|
(effective-opts (if (assoc "cwd" effective-opts)
|
||||||
|
effective-opts
|
||||||
|
(cons (cons "cwd" default-directory) effective-opts)))
|
||||||
(before (ollie--session-ids))
|
(before (ollie--session-ids))
|
||||||
(seen (make-hash-table :test 'equal))
|
(seen (make-hash-table :test 'equal))
|
||||||
(cmd (concat "new"
|
(cmd (mapconcat (lambda (kv)
|
||||||
(mapconcat (lambda (kv)
|
(format "%s=%s" (car kv) (cdr kv)))
|
||||||
(format " %s=%s" (car kv) (cdr kv)))
|
effective-opts " ")))
|
||||||
effective-opts ""))))
|
|
||||||
(dolist (id before) (puthash id t seen))
|
(dolist (id before) (puthash id t seen))
|
||||||
(ollie--write-root-ctl cmd)
|
(ollie--fwrite (ollie--sessions-new-path) (concat cmd "\n"))
|
||||||
(let ((deadline (+ (float-time) 5.0))
|
(let ((deadline (+ (float-time) 5.0))
|
||||||
result)
|
result)
|
||||||
(while (and (not result) (< (float-time) deadline))
|
(while (and (not result) (< (float-time) deadline))
|
||||||
|
|
@ -199,7 +199,7 @@ Returns the new session ID."
|
||||||
(interactive)
|
(interactive)
|
||||||
(unless ollie--session-id (user-error "No active session"))
|
(unless ollie--session-id (user-error "No active session"))
|
||||||
(when (yes-or-no-p (format "Kill ollie session %s? " ollie--session-id))
|
(when (yes-or-no-p (format "Kill ollie session %s? " ollie--session-id))
|
||||||
(ollie--write-root-ctl (concat "kill " ollie--session-id))
|
(delete-directory (expand-file-name ollie--session-id (ollie--sessions-dir)) t)
|
||||||
(ollie--stop-watching)
|
(ollie--stop-watching)
|
||||||
(setq ollie--session-id nil
|
(setq ollie--session-id nil
|
||||||
ollie--chat-size -1)
|
ollie--chat-size -1)
|
||||||
|
|
@ -320,10 +320,10 @@ Must be called after `ansi-color-apply-on-region'."
|
||||||
;; Inside a result block: colorize diff lines.
|
;; Inside a result block: colorize diff lines.
|
||||||
(in-result
|
(in-result
|
||||||
(let ((face (cond
|
(let ((face (cond
|
||||||
((or (string-prefix-p "+++" line)
|
((or (string-prefix-p "+++" line)
|
||||||
(string-prefix-p "---" line)) 'shadow)
|
(string-prefix-p "−--" line)) 'shadow)
|
||||||
((string-prefix-p "+" line) 'ollie-diff-added)
|
((string-prefix-p "+" line) 'ollie-diff-added)
|
||||||
((string-prefix-p "-" line) 'ollie-diff-removed)
|
((string-prefix-p "−" line) 'ollie-diff-removed)
|
||||||
((string-prefix-p "@@" line) 'ollie-diff-hunk-header))))
|
((string-prefix-p "@@" line) 'ollie-diff-hunk-header))))
|
||||||
(when face
|
(when face
|
||||||
(put-text-property bol eol 'face face)))))
|
(put-text-property bol eol 'face face)))))
|
||||||
|
|
|
||||||
Reference in New Issue