summaryrefslogtreecommitdiff
path: root/pancake.el
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2017-12-14 19:21:27 +0300
committerdefanor <defanor@uberspace.net>2017-12-14 19:21:27 +0300
commitb58e342bf414e869bf772fb3a38691fa4a604978 (patch)
treed6b057c6f6252a60a882f5f4703d5b20cfbd0fa0 /pancake.el
parente1151532a46a7ce2c59a8bc86088063cb03c4438 (diff)
Add the "set width" command
This is mostly needed for embedding, since there doesn't seem to be any practical (let alone portable) standard way to notify pancake of emacs window size changes. In pancake.el, width adjustment is now getting done automatically whenever any other command gets issued.
Diffstat (limited to 'pancake.el')
-rw-r--r--pancake.el13
1 files changed, 11 insertions, 2 deletions
diff --git a/pancake.el b/pancake.el
index 98aab6d..6429f67 100644
--- a/pancake.el
+++ b/pancake.el
@@ -174,8 +174,7 @@ if no URL is provided."
(current-buffer)
(car pancake-buffers))))
(with-current-buffer buffer
- (when url
- (process-send-string pancake-process (concat url "\n")))
+ (when url (pancake-process-send url))
(display-buffer (current-buffer)))))
(defun pancake-translate-color (name attr)
@@ -356,8 +355,18 @@ property. Returns a list of collected values."
(interactive)
(funcall (pancake-input (gui-get-primary-selection))))
+(defun pancake-width-adjust (&optional width)
+ "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 (window-width)))))
+
(defun pancake-process-send (line)
"Send LINE to the pancake process."
+ (pancake-width-adjust)
(process-send-string pancake-process (concat line "\n")))
(defun pancake-go-backward ()