From b32900a7d426f06ee1bd2f69d8cf7899034f5470 Mon Sep 17 00:00:00 2001 From: defanor Date: Thu, 21 Dec 2017 09:23:21 +0300 Subject: Retain position on redisplay, reload, etc Based on line numbers that are attached to document blocks, not dependent on window/terminal width. Some bits can still be refined/refactored, but here's the initial support. --- pancake.el | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'pancake.el') diff --git a/pancake.el b/pancake.el index f28b4c2..85fcd94 100644 --- a/pancake.el +++ b/pancake.el @@ -372,16 +372,28 @@ property. Returns a list of collected values." "Sets the width (in columns) that the pancake process should use. Current window width is used if none is provided." (interactive) - ;; Not using `pancake-process-send' here, since it itself would call - ;; this function. - (process-send-string pancake-process - (format "set width %d\n" - (or width (1- (window-width)))))) + (pancake-process-send-raw + (format "set width %d\n" (or width (1- (window-width)))))) + +(defun pancake-position-adjust (&optional line) + "Sets the position (LINE) that the pancake process should use. +Current line is used if none is provided." + (interactive) + (pancake-process-send-raw + (format "set position %d\n" (or line (line-number-at-pos (point)))))) + +(defun pancake-process-send-raw (line) + "Send LINE to the pancake process, without adjusting any +parameters." + (process-send-string pancake-process (concat line "\n"))) (defun pancake-process-send (line) - "Send LINE to the pancake process." + "Send LINE to the pancake process, adjusting width and setting +the current position at once. See `pancake-process-send-raw' for +a version that doesn't do that." (pancake-width-adjust) - (process-send-string pancake-process (concat line "\n"))) + (pancake-position-adjust) + (pancake-process-send-raw line)) (defun pancake-go-backward () "Go backward in history." -- cgit v1.2.3