From 683b454ff269600c59ffbbded415058971adde86 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Sat, 26 Nov 2022 01:20:54 +0000 Subject: Fix column preservation in text fields like ielm after prompt. Add a hacky one-off test to assemble buffer text with a field. --- paredit.el | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'paredit.el') diff --git a/paredit.el b/paredit.el index 449a75b..77f5a68 100644 --- a/paredit.el +++ b/paredit.el @@ -184,7 +184,7 @@ If point was on code, it moves with the code. If point was on indentation, it stays in indentation." (let ((column (make-symbol "column")) (indentation (make-symbol "indentation"))) - `(let ((,column (current-column)) + `(let ((,column (paredit-current-column)) (,indentation (paredit-current-indentation))) (let ((value (progn ,@body))) (paredit-restore-column ,column ,indentation) @@ -2953,10 +2953,16 @@ This is independent of context -- it doesn't check what state the t) nil))) +(defun paredit-current-column () + ;; Like current-column, but respects field boundaries in interactive + ;; modes like ielm. For use only with paredit-restore-column, which + ;; works relative to point-at-bol. + (- (point) (point-at-bol))) + (defun paredit-current-indentation () (save-excursion (back-to-indentation) - (current-column))) + (paredit-current-column))) (defun paredit-restore-column (column indentation) ;; Preserve the point's position either in the indentation or in the -- cgit v1.2.1