unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Ivan Kanis <ivan@kanis.fr>
To: Emacs Development List <emacs-devel@gnu.org>
Subject: fill length of visual line mode
Date: Thu, 02 Oct 2014 09:48:12 +0200	[thread overview]
Message-ID: <87oatu6hfn.fsf@kanis.fr> (raw)

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))))))



             reply	other threads:[~2014-10-02  7:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-02  7:48 Ivan Kanis [this message]
2014-10-02 15:16 ` fill length of visual line mode 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87oatu6hfn.fsf@kanis.fr \
    --to=ivan@kanis.fr \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).