summaryrefslogtreecommitdiff
path: root/pancake.el
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2017-12-21 09:23:21 +0300
committerdefanor <defanor@uberspace.net>2017-12-21 09:23:21 +0300
commitb32900a7d426f06ee1bd2f69d8cf7899034f5470 (patch)
tree33496f0d50e87b286da038973cb294079da3dafc /pancake.el
parentdbd5740dea0ad6119cbef2b3b1cccf1e865beaca (diff)
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.
Diffstat (limited to 'pancake.el')
-rw-r--r--pancake.el26
1 files changed, 19 insertions, 7 deletions
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."