emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Word wrapping and long lines


From: Lennart Borgman (gmail)
Subject: Re: Word wrapping and long lines
Date: Fri, 19 Sep 2008 03:29:23 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071031 Thunderbird/2.0.0.9 Mnenhy/0.7.5.666

Chong Yidong wrote:
> "Lennart Borgman (gmail)" <address@hidden> writes:
> 
>>> Longlines mode will hopefully be phased out as its functionality is
>>> replaced by visual-line-mode.
>> But what about wrapping at some specific width (like longlines-mode
>> does), is that not implemented yet?
> 
> No.

Maybe something like this can be used:

(defun set-wrap-to-fill-values ()
  "Center `fill-column' display columns in buffer windows."
  (let ((buf-windows (get-buffer-window-list (current-buffer))))
    (dolist (win buf-windows)
      (let* ((edges (window-edges win))
             (win-width (- (nth 2 edges) (nth 0 edges)))
             (extra-width (- win-width fill-column))
             (left-marg (- (/ extra-width 2) 1))
             (right-marg (- win-width fill-column left-marg))
             (old-left left-margin-width)
             (old-right right-margin-width)
             )
        (unless (> left-marg 0) (setq left-marg 0))
        (unless (> right-marg 0) (setq right-marg 0))
        (unless (and (= old-left left-marg)
                     (= old-right right-marg))
          (set-window-margins win left-marg right-marg))))))

(define-minor-mode wrap-to-fill-mode
  "Center `fill-column' display columns in buffer windows."
  :group 'emacs
  (if wrap-to-fill-mode
      (add-hook 'window-configuration-change-hook
'set-wrap-to-fill-values nil t)
    (remove-hook 'window-configuration-change-hook
'set-wrap-to-fill-values t)))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]