* 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
* Re: fill length of visual line mode
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-02 15:50 ` Glenn Morris
1 sibling, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2014-10-02 15:16 UTC (permalink / raw)
To: Ivan Kanis; +Cc: emacs-devel
> From: Ivan Kanis <ivan@kanis.fr>
> Date: Thu, 02 Oct 2014 09:48:12 +0200
>
> 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.
That's not how word-wrap was designed and implemented. It works more
like Web browsers, i.e. it wraps at the window edge.
> 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?
Not sure what you mean by your question. Are you asking whether
patches to implement the wrap at fill-column will be accepted? If so,
I'm quite sure the answer is YES.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: fill length of visual line mode
2014-10-02 7:48 fill length of visual line mode Ivan Kanis
2014-10-02 15:16 ` Eli Zaretskii
@ 2014-10-02 15:50 ` Glenn Morris
2014-10-03 20:39 ` Ivan Kanis
1 sibling, 1 reply; 13+ messages in thread
From: Glenn Morris @ 2014-10-02 15:50 UTC (permalink / raw)
To: Ivan Kanis; +Cc: Emacs Development List
Ivan Kanis wrote:
> 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.
This is http://debbugs.gnu.org/cgi/bugreport.cgi?bug=18589 .
(Presumably wrote a blog post or something and this is now flavour of
the week.)
> There is a hack [1] by James Wright to make it work by expanding the
> right margin of the buffer's window.
See comments at
http://lists.gnu.org/archive/html/emacs-devel/2013-12/msg00495.html .
The code you quote seems mostly OK, but I don't know who wrote it, so
I can't just install it, for copyright reasons.
If someone can rewrite it and submit a patch, or if the original author
can submit the patch, I'd be happy to install the feature.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: fill length of visual line mode
2014-10-02 15:50 ` Glenn Morris
@ 2014-10-03 20:39 ` Ivan Kanis
2014-10-03 21:20 ` Stefan Monnier
0 siblings, 1 reply; 13+ messages in thread
From: Ivan Kanis @ 2014-10-03 20:39 UTC (permalink / raw)
To: Glenn Morris; +Cc: Eli Zaretskii, Emacs Development List
October, 02 at 18:16 Eli wrote:
>> From: Ivan Kanis <ivan@kanis.fr>
>> Date: Thu, 02 Oct 2014 09:48:12 +0200
>>
>> 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.
>
> That's not how word-wrap was designed and implemented. It works more
> like Web browsers, i.e. it wraps at the window edge.
It's too long for me at work where I use a tiling window manager and
wide screen.
>> 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?
>
> Not sure what you mean by your question. Are you asking whether
> patches to implement the wrap at fill-column will be accepted? If so,
> I'm quite sure the answer is YES.
It is what I meant.
October, 02 at 11:50 Glenn wrote:
> The code you quote seems mostly OK, but I don't know who wrote it, so
> I can't just install it, for copyright reasons.
>
> If someone can rewrite it and submit a patch, or if the original author
> can submit the patch, I'd be happy to install the feature.
It just boils down to setting the right margin. I have to hide the right
fringe or it looks wrong. FWIW here is how I cobbled for gnus article.
(defun ivan-gnus-hack-visual-line-length ()
"Set visual line length by expanding the right margin of the
buffer’s window."
(let ((window (selected-window)))
(select-window (car (get-buffer-window-list gnus-article-buffer)))
(set-window-margins nil 0 (- (window-width) 80))
(set-window-fringes (selected-window) 8 0)
(visual-line-mode)
(select-window window)))
(add-hook 'gnus-article-prepare-hook 'ivan-gnus-hack-visual-line-length)
It just feels hackish and wrong. The right thing I feel is to use
fill-column.
Ivan
--
You must've hit the wrong any key.
-- BOFH excuse #52
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: fill length of visual line mode
2014-10-02 15:16 ` Eli Zaretskii
@ 2014-10-03 21:19 ` Johan Bockgård
2014-10-04 7:07 ` Eli Zaretskii
0 siblings, 1 reply; 13+ messages in thread
From: Johan Bockgård @ 2014-10-03 21:19 UTC (permalink / raw)
To: emacs-devel
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Ivan Kanis <ivan@kanis.fr>
>> Date: Thu, 02 Oct 2014 09:48:12 +0200
>>
>> 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.
>
> That's not how word-wrap was designed and implemented. It works more
> like Web browsers, i.e. it wraps at the window edge.
The original word wrap patch by Kim did support wrapping at a specified
column, but this feature was removed when the code was integrated into
Emacs.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: fill length of visual line mode
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 14:23 ` Ivan Kanis
0 siblings, 2 replies; 13+ messages in thread
From: Stefan Monnier @ 2014-10-03 21:20 UTC (permalink / raw)
To: Ivan Kanis; +Cc: Eli Zaretskii, Emacs Development List
> It just boils down to setting the right margin. I have to hide the right
> fringe or it looks wrong.
Better to swap the margin and the fringe with fringes-outside-margins.
> (defun ivan-gnus-hack-visual-line-length ()
> "Set visual line length by expanding the right margin of the
> buffer’s window."
> (let ((window (selected-window)))
> (select-window (car (get-buffer-window-list gnus-article-buffer)))
> (set-window-margins nil 0 (- (window-width) 80))
> (set-window-fringes (selected-window) 8 0)
> (visual-line-mode)
> (select-window window)))
You want to use `with-selection-window' above.
Additionally, the above will lose its effect if you hide the window and
show it again: you'd need to do it via window-configuration-change-hook.
Other problem: if window-width is smaller than 80 (which I gather is
your target fill-column in the above code), you end up setting
a negative margin.
> It just feels hackish and wrong. The right thing I feel is to use
> fill-column.
I'm not opposed to a patch that would let it obey fill-column
(optionally). But it does beg the question: what if the window is
smaller than fill-column? Should it then fill at the window's edge or
should it continue as if truncate-lines is set?
Stefan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: fill length of visual line mode
2014-10-03 21:19 ` Johan Bockgård
@ 2014-10-04 7:07 ` Eli Zaretskii
2014-10-04 17:16 ` Johan Bockgård
0 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2014-10-04 7:07 UTC (permalink / raw)
To: Johan Bockgård; +Cc: emacs-devel
> From: Johan Bockgård <bojohan@gnu.org>
> Date: Fri, 03 Oct 2014 23:19:39 +0200
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
> >> From: Ivan Kanis <ivan@kanis.fr>
> >> Date: Thu, 02 Oct 2014 09:48:12 +0200
> >>
> >> 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.
> >
> > That's not how word-wrap was designed and implemented. It works more
> > like Web browsers, i.e. it wraps at the window edge.
>
> The original word wrap patch by Kim did support wrapping at a specified
> column, but this feature was removed when the code was integrated into
> Emacs.
If so, bringing that back should be easier, as the code to do that is
probably archived somewhere.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: fill length of visual line mode
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
1 sibling, 1 reply; 13+ messages in thread
From: Harald Hanche-Olsen @ 2014-10-04 9:58 UTC (permalink / raw)
To: emacs-devel
[Stefan Monnier <monnier@iro.umontreal.ca> (2014-10-03 21:20:07 UTC)]
> I'm not opposed to a patch that would let it obey fill-column
> (optionally). But it does beg the question: what if the window is
> smaller than fill-column? Should it then fill at the window's edge or
> should it continue as if truncate-lines is set?
Filling at the window's edge is the only reasonable option, IMO.
The behaviour of web browsers was mentioned earlier. But you have the
CSS property max-width to modify that. I have – and frequently use – a
bookmarklet that lets me set the max-width property on the body
element in order to improve readability. It beats adjusting the
browser window itself.
Perhaps emacs could have a variable max-fill-column which, when set,
could govern visual line mode in this way? If set to t, it would mean
use the value of fill-column. Or if set to a number, ignore
fill-column and use the number itself. It shouldn't be allowed to
override fill-column in the other use cases, though. Perhaps
visual-line-max-fill-column would be a better name, if perhaps a bit
unwieldy.
– Harald
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: fill length of visual line mode
2014-10-03 21:20 ` Stefan Monnier
2014-10-04 9:58 ` Harald Hanche-Olsen
@ 2014-10-04 14:23 ` Ivan Kanis
2014-10-04 22:25 ` Stefan Monnier
1 sibling, 1 reply; 13+ messages in thread
From: Ivan Kanis @ 2014-10-04 14:23 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Eli Zaretskii, Emacs Development List
October, 03 at 17:20 Stefan wrote:
Hi Stefan,
Let's forget about the code I posted. It's a stupid hack that works for
me.
>> It just feels hackish and wrong. The right thing I feel is to use
>> fill-column.
>
> But it does beg the question: what if the window is smaller than
> fill-column? Should it then fill at the window's edge or should it
> continue as if truncate-lines is set?
I didn't think of that. I bet users will want either. So a variable
will say what to do.
--
Program load too heavy for processor to lift.
-- BOFH excuse #30
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: fill length of visual line mode
2014-10-04 9:58 ` Harald Hanche-Olsen
@ 2014-10-04 15:45 ` Drew Adams
0 siblings, 0 replies; 13+ messages in thread
From: Drew Adams @ 2014-10-04 15:45 UTC (permalink / raw)
To: Harald Hanche-Olsen, emacs-devel
> Perhaps emacs could have a variable max-fill-column which, when set,
> could govern visual line mode in this way? If set to t, it would
> mean use the value of fill-column. Or if set to a number, ignore
> fill-column and use the number itself. It shouldn't be allowed to
> override fill-column in the other use cases, though. Perhaps
> visual-line-max-fill-column would be a better name, if perhaps a bit
> unwieldy.
If it is specific to visual lines then yes of course, "visual-line"
(or similar) should be in the name. Users should not be able to
get the impression, by looking only at the name, that this has
something to do with `fill-column' generally.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: fill length of visual line mode
2014-10-04 7:07 ` Eli Zaretskii
@ 2014-10-04 17:16 ` Johan Bockgård
0 siblings, 0 replies; 13+ messages in thread
From: Johan Bockgård @ 2014-10-04 17:16 UTC (permalink / raw)
To: emacs-devel
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Johan Bockgård <bojohan@gnu.org>
>> Date: Fri, 03 Oct 2014 23:19:39 +0200
>>
>> The original word wrap patch by Kim did support wrapping at a specified
>> column, but this feature was removed when the code was integrated into
>> Emacs.
>
> If so, bringing that back should be easier, as the code to do that is
> probably archived somewhere.
http://lists.gnu.org/archive/html/emacs-devel/2005-07/msg01112.html
http://lists.gnu.org/archive/html/emacs-devel/2008-06/msg01544.html
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: fill length of visual line mode
2014-10-04 14:23 ` Ivan Kanis
@ 2014-10-04 22:25 ` Stefan Monnier
2014-10-05 7:59 ` Ivan Kanis
0 siblings, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2014-10-04 22:25 UTC (permalink / raw)
To: Ivan Kanis; +Cc: Eli Zaretskii, Emacs Development List
> Let's forget about the code I posted. It's a stupid hack that works for me.
>>> It just feels hackish and wrong. The right thing I feel is to use
>>> fill-column.
>> But it does beg the question: what if the window is smaller than
>> fill-column? Should it then fill at the window's edge or should it
>> continue as if truncate-lines is set?
> I didn't think of that. I bet users will want either. So a variable
> will say what to do.
I think pursuing the window-configuration-change-hook path is actually
a good idea: if we can get the desired behavior via Elisp code, it's
generally preferable (the C code is hairy enough as it is). It also
makes it easier to offer configurability (e.g. to choose whether to
center the visible text in the window, or not).
Stefan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: fill length of visual line mode
2014-10-04 22:25 ` Stefan Monnier
@ 2014-10-05 7:59 ` Ivan Kanis
0 siblings, 0 replies; 13+ messages in thread
From: Ivan Kanis @ 2014-10-05 7:59 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Eli Zaretskii, Emacs Development List
October, 04 at 18:25 Stefan wrote:
>> Let's forget about the code I posted. It's a stupid hack that works for me.
>>>> It just feels hackish and wrong. The right thing I feel is to use
>>>> fill-column.
>>> But it does beg the question: what if the window is smaller than
>>> fill-column? Should it then fill at the window's edge or should it
>>> continue as if truncate-lines is set?
>> I didn't think of that. I bet users will want either. So a variable
>> will say what to do.
>
> I think pursuing the window-configuration-change-hook path is actually
> a good idea: if we can get the desired behavior via Elisp code, it's
> generally preferable (the C code is hairy enough as it is). It also
> makes it easier to offer configurability (e.g. to choose whether to
> center the visible text in the window, or not).
OK. I won't do it straight away as the gnus hack is sufficient for me
for now. I am planning to use visual line mode for org in the future. If
I do it I will revisit your suggestions to write some elisp that can be
added to Emacs proper.
Ivan
--
Only two things are infinite, the universe and human stupidity, and
I'm not sure about the former.
-- Albert Einstein
^ 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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.