diff options
author | Chong Yidong <cyd@stupidchicken.com> | 2007-10-17 02:50:23 +0000 |
---|---|---|
committer | Chong Yidong <cyd@stupidchicken.com> | 2007-10-17 02:50:23 +0000 |
commit | c455889deb499b2f5fc5af9b766c39b17f3405f2 (patch) | |
tree | 23a84696b0d4c3bbaeba756d092238a3b001a487 /lisp/longlines.el | |
parent | cdbd4b4b1c62df28ee9003c49176919a5ef0cb24 (diff) | |
download | emacs-c455889deb499b2f5fc5af9b766c39b17f3405f2.tar.gz emacs-c455889deb499b2f5fc5af9b766c39b17f3405f2.tar.bz2 emacs-c455889deb499b2f5fc5af9b766c39b17f3405f2.zip |
(longlines-wrap-follows-window-size): Integer value
specifies wrapping margin.
(longlines-mode, longlines-window-change-function): Set
window-specific wrapping margin based on the above.
Diffstat (limited to 'lisp/longlines.el')
-rw-r--r-- | lisp/longlines.el | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/lisp/longlines.el b/lisp/longlines.el index 07977910a22..c820150c27a 100644 --- a/lisp/longlines.el +++ b/lisp/longlines.el @@ -55,7 +55,11 @@ when the file is saved to disk." "Non-nil means wrapping and filling happen at the edge of the window. Otherwise, `fill-column' is used, regardless of the window size. This does not work well when the buffer is displayed in multiple windows -with differing widths." +with differing widths. + +If the value is an integer, that specifies the distance from the +right edge of the window at which wrapping occurs. For any other +non-nil value, wrapping occurs 2 characters from the right edge." :group 'longlines :type 'boolean) @@ -117,8 +121,14 @@ are indicated with a symbol." 'longlines-search-function) (add-to-list 'buffer-substring-filters 'longlines-encode-string) (when longlines-wrap-follows-window-size - (set (make-local-variable 'fill-column) - (- (window-width) window-min-width)) + (let ((dw (if (and (integerp longlines-wrap-follows-window-size) + (>= longlines-wrap-follows-window-size 0) + (< longlines-wrap-follows-window-size + (window-width))) + longlines-wrap-follows-window-size + 2))) + (set (make-local-variable 'fill-column) + (- (window-width) dw))) (add-hook 'window-configuration-change-hook 'longlines-window-change-function nil t)) (let ((buffer-undo-list t) @@ -415,9 +425,14 @@ This is called by `post-command-hook' after each command." (defun longlines-window-change-function () "Re-wrap the buffer if the window width has changed. This is called by `window-configuration-change-hook'." - (when (/= fill-column (- (window-width) window-min-width)) - (setq fill-column (- (window-width) window-min-width)) - (longlines-wrap-region (point-min) (point-max)))) + (let ((dw (if (and (integerp longlines-wrap-follows-window-size) + (>= longlines-wrap-follows-window-size 0) + (< longlines-wrap-follows-window-size (window-width))) + longlines-wrap-follows-window-size + 2))) + (when (/= fill-column (- (window-width) dw)) + (setq fill-column (- (window-width) dw)) + (longlines-wrap-region (point-min) (point-max))))) ;; Isearch |