unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* fill length of visual line mode
@ 2014-10-02  7:48 Ivan Kanis
  2014-10-02 15:16 ` Eli Zaretskii
  2014-10-02 15:50 ` Glenn Morris
  0 siblings, 2 replies; 13+ messages in thread
From: Ivan Kanis @ 2014-10-02  7:48 UTC (permalink / raw)
  To: Emacs Development List

Hello,

I just enabled visual line mode today. I have started using it to
display gnus article. I noticed that the fill happens at the width of
the Emacs window. I set fill-column to 70 and I was expecting it to wrap
there.

There is a hack [1] by James Wright to make it work by expanding the
right margin of the buffer's window.

I don't feel it should be so complicated to customize this behavior.

Would it be OK to code wrap at fill-column?

Ivan

[1] The code on Emacs wiki:

(defvar visual-wrap-column nil)

(defun set-visual-wrap-column (new-wrap-column &optional buffer)
  "Force visual line wrap at NEW-WRAP-COLUMN in BUFFER (defaults
to current buffer) by setting the right-hand margin on every
window that displays BUFFER.  A value of NIL or 0 for
NEW-WRAP-COLUMN disables this behavior."
  (interactive (list (read-number "New visual wrap column, 0 to disable: "
                                  (or visual-wrap-column fill-column 0))))
  (if (and (numberp new-wrap-column)
           (zerop new-wrap-column))
    (setq new-wrap-column nil))
  (with-current-buffer (or buffer (current-buffer))
    (visual-line-mode t)
    (set (make-local-variable 'visual-wrap-column) new-wrap-column)
    (add-hook 'window-configuration-change-hook
              'update-visual-wrap-column nil t)
    (let ((windows (get-buffer-window-list)))
      (while windows
        (when (window-live-p (car windows))
          (with-selected-window (car windows)
            (update-visual-wrap-column)))
        (setq windows (cdr windows))))))

(defun update-visual-wrap-column ()
  (if (not visual-wrap-column)
    (set-window-margins nil nil)
    (let* ((current-margins (window-margins))
           (right-margin (or (cdr current-margins) 0))
           (current-width (window-width))
           (current-available (+ current-width right-margin)))
      (if (<= current-available visual-wrap-column)
        (set-window-margins nil (car current-margins))
        (set-window-margins nil (car current-margins)
                            (- current-available
  visual-wrap-column))))))



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2014-10-05  7:59 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-02  7:48 fill length of visual line mode Ivan Kanis
2014-10-02 15:16 ` Eli Zaretskii
2014-10-03 21:19   ` Johan Bockgård
2014-10-04  7:07     ` Eli Zaretskii
2014-10-04 17:16       ` Johan Bockgård
2014-10-02 15:50 ` Glenn Morris
2014-10-03 20:39   ` Ivan Kanis
2014-10-03 21:20     ` Stefan Monnier
2014-10-04  9:58       ` Harald Hanche-Olsen
2014-10-04 15:45         ` Drew Adams
2014-10-04 14:23       ` Ivan Kanis
2014-10-04 22:25         ` Stefan Monnier
2014-10-05  7:59           ` Ivan Kanis

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).