diff options
| author | Chong Yidong | 2007-10-17 02:47:39 +0000 |
|---|---|---|
| committer | Chong Yidong | 2007-10-17 02:47:39 +0000 |
| commit | 71fdf0898e86112a57064b13852bd5d48677a9a2 (patch) | |
| tree | 569809e6528f97a1d1980858b8768ad3e5d27ff0 | |
| parent | a457f2b8c411e796f7d73871bd68110369808c3b (diff) | |
| download | emacs-71fdf0898e86112a57064b13852bd5d48677a9a2.tar.gz emacs-71fdf0898e86112a57064b13852bd5d48677a9a2.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.
| -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." | |||
| 55 | "Non-nil means wrapping and filling happen at the edge of the window. | 55 | "Non-nil means wrapping and filling happen at the edge of the window. |
| 56 | Otherwise, `fill-column' is used, regardless of the window size. This | 56 | Otherwise, `fill-column' is used, regardless of the window size. This |
| 57 | does not work well when the buffer is displayed in multiple windows | 57 | does not work well when the buffer is displayed in multiple windows |
| 58 | with differing widths." | 58 | with differing widths. |
| 59 | |||
| 60 | If the value is an integer, that specifies the distance from the | ||
| 61 | right edge of the window at which wrapping occurs. For any other | ||
| 62 | non-nil value, wrapping occurs 2 characters from the right edge." | ||
| 59 | :group 'longlines | 63 | :group 'longlines |
| 60 | :type 'boolean) | 64 | :type 'boolean) |
| 61 | 65 | ||
| @@ -117,8 +121,14 @@ are indicated with a symbol." | |||
| 117 | 'longlines-search-function) | 121 | 'longlines-search-function) |
| 118 | (add-to-list 'buffer-substring-filters 'longlines-encode-string) | 122 | (add-to-list 'buffer-substring-filters 'longlines-encode-string) |
| 119 | (when longlines-wrap-follows-window-size | 123 | (when longlines-wrap-follows-window-size |
| 120 | (set (make-local-variable 'fill-column) | 124 | (let ((dw (if (and (integerp longlines-wrap-follows-window-size) |
| 121 | (- (window-width) window-min-width)) | 125 | (>= longlines-wrap-follows-window-size 0) |
| 126 | (< longlines-wrap-follows-window-size | ||
| 127 | (window-width))) | ||
| 128 | longlines-wrap-follows-window-size | ||
| 129 | 2))) | ||
| 130 | (set (make-local-variable 'fill-column) | ||
| 131 | (- (window-width) dw))) | ||
| 122 | (add-hook 'window-configuration-change-hook | 132 | (add-hook 'window-configuration-change-hook |
| 123 | 'longlines-window-change-function nil t)) | 133 | 'longlines-window-change-function nil t)) |
| 124 | (let ((buffer-undo-list t) | 134 | (let ((buffer-undo-list t) |
| @@ -415,9 +425,14 @@ This is called by `post-command-hook' after each command." | |||
| 415 | (defun longlines-window-change-function () | 425 | (defun longlines-window-change-function () |
| 416 | "Re-wrap the buffer if the window width has changed. | 426 | "Re-wrap the buffer if the window width has changed. |
| 417 | This is called by `window-configuration-change-hook'." | 427 | This is called by `window-configuration-change-hook'." |
| 418 | (when (/= fill-column (- (window-width) window-min-width)) | 428 | (let ((dw (if (and (integerp longlines-wrap-follows-window-size) |
| 419 | (setq fill-column (- (window-width) window-min-width)) | 429 | (>= longlines-wrap-follows-window-size 0) |
| 420 | (longlines-wrap-region (point-min) (point-max)))) | 430 | (< longlines-wrap-follows-window-size (window-width))) |
| 431 | longlines-wrap-follows-window-size | ||
| 432 | 2))) | ||
| 433 | (when (/= fill-column (- (window-width) dw)) | ||
| 434 | (setq fill-column (- (window-width) dw)) | ||
| 435 | (longlines-wrap-region (point-min) (point-max))))) | ||
| 421 | 436 | ||
| 422 | ;; Isearch | 437 | ;; Isearch |
| 423 | 438 | ||