From b58e342bf414e869bf772fb3a38691fa4a604978 Mon Sep 17 00:00:00 2001 From: defanor Date: Thu, 14 Dec 2017 19:21:27 +0300 Subject: 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. --- pancake.el | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'pancake.el') 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 () -- cgit v1.2.3