Discussion:
"wrap after last space" mode?
(too old to reply)
iaw4
2012-09-12 03:13:20 UTC
Permalink
I often have to edit files that others are editing in MS Word (yuck!) and saving as ASCII. I am probably not the only one, so this has probably been fixed somewhere already.

my problem are line ends. I cannot fill the paragraph, or my line ends will make the display for my MS Word really ugly. the paragraph won't be refilled when they edit. so I need to edit paragraphs without inserting line ends everywhere. I can do this in the current standard settings, and the novel way to go up and down a line works great. it would be even better if, just as in MS Word, the visual wrap would occur at the last space before the text hits the column end, rather than in the middle of a word.

does such a mode exist for text files?

regards,

/iaw
Julian Bradfield
2012-09-12 07:21:24 UTC
Permalink
Post by iaw4
my problem are line ends. I cannot fill the paragraph, or my line ends will make the display for my MS Word really ugly. the paragraph won't be refilled when they edit. so I need to edit paragraphs without inserting line ends everywhere. I can do this in the current standard settings, and the novel way to go up and down a line works great. it would be even better if, just as in MS Word, the visual wrap would occur at the last space before the text hits the column end, rather than in the middle of a word.
Doesn't visual-line-mode do this anyway?

You don't say what emacs you're using...
Remco van 't Veer
2012-09-12 08:04:02 UTC
Permalink
Post by iaw4
my problem are line ends. I cannot fill the paragraph, or my line
ends will make the display for my MS Word really ugly. the paragraph
won't be refilled when they edit. so I need to edit paragraphs
without inserting line ends everywhere. I can do this in the current
standard settings, and the novel way to go up and down a line works
great. it would be even better if, just as in MS Word, the visual
wrap would occur at the last space before the text hits the column
end, rather than in the middle of a word.
does such a mode exist for text files?
I use longlines-mode when I don't want newlines in my paragraphs;

When Long Lines mode is enabled, long lines are wrapped if they
extend beyond `fill-column'. The soft newlines used for line
wrapping will not show up when the text is yanked or saved to
disk.

Regards,
Remco
iaw4
2012-09-12 15:33:17 UTC
Permalink
longlines-mode looks exactly what I would like.

is there a way to show the hard returns so that they are more obvious?

regards,

/iaw
Post by Remco van 't Veer
Post by iaw4
my problem are line ends. I cannot fill the paragraph, or my line
ends will make the display for my MS Word really ugly. the paragraph
won't be refilled when they edit. so I need to edit paragraphs
without inserting line ends everywhere. I can do this in the current
standard settings, and the novel way to go up and down a line works
great. it would be even better if, just as in MS Word, the visual
wrap would occur at the last space before the text hits the column
end, rather than in the middle of a word.
does such a mode exist for text files?
I use longlines-mode when I don't want newlines in my paragraphs;
When Long Lines mode is enabled, long lines are wrapped if they
extend beyond `fill-column'. The soft newlines used for line
wrapping will not show up when the text is yanked or saved to
disk.
Regards,
Remco
Remco van 't Veer
2012-09-13 07:20:59 UTC
Permalink
Post by iaw4
longlines-mode looks exactly what I would like.
is there a way to show the hard returns so that they are more obvious?
From longlines-mode documentation:

If the variable `longlines-show-hard-newlines' is non-nil, hard
newlines are indicated with a symbol.
iaw4
2012-09-29 20:05:15 UTC
Permalink
this is really useful. if any emacs developers are reading this group, may I suggest that this mode should be the text default mode when a file is loaded that has lines that are really long? It could trigger if there are more than 3 lines that are more than 180 characters long, for example. or it could even be the default text-mode.
Post by Remco van 't Veer
Post by iaw4
longlines-mode looks exactly what I would like.
is there a way to show the hard returns so that they are more obvious?
If the variable `longlines-show-hard-newlines' is non-nil, hard
newlines are indicated with a symbol.
Remco van 't Veer
2012-10-01 13:09:42 UTC
Permalink
Post by iaw4
this is really useful. if any emacs developers are reading this
group, may I suggest that this mode should be the text default mode
when a file is loaded that has lines that are really long? It could
trigger if there are more than 3 lines that are more than 180
characters long, for example. or it could even be the default
text-mode.
The best thing about emacs is that everybody is an emacs developer! ;)

(defconst auto-longline-mode-length-threshold 180)
(defconst auto-longline-mode-lines-threshold 3)
(defconst auto-longline-mode-examination-depth 10)

(defun need-longlines-mode-p ()
(save-excursion
(let ((longline-count 0)
(tested-lines 0))
(goto-char (point-min))
(catch 'aha
(while t
(when (> (- (point-at-eol) (point-at-bol))
auto-longline-mode-length-threshold)
(incf longline-count))
(when (or (>= longline-count auto-longline-mode-lines-threshold)
(>= tested-lines auto-longline-mode-examination-depth)
(equal (forward-line 1) 1))
(throw 'aha t))
(incf tested-lines)))
(>= longline-count auto-longline-mode-lines-threshold))))

(add-hook 'text-mode-hook
(lambda () (when (need-longlines-mode-p) (longlines-mode 1))))

Kind regards,
Remco
iaw4
2012-10-02 04:05:01 UTC
Permalink
Post by Remco van 't Veer
The best thing about emacs is that everybody is an emacs developer! ;)
you and both others! ;-).

more seriously, 99% of emacs users probably do not know how to program emacs. I am one of them. occasionally, I pick up a little here and there, but it's not enough. so the experience out-of-the-box matters. your quick function would make for a better out-of-the-box experience for 90% of users if it were standard. (though it would have to be toggle-able for pure users, too.)

actually, as for me, I will hook it in regardless of line length, just as long as I am in text-mode. the minimum line lengths would be a conservative way to handle this. a more aggressive, but user-friendly way would be to make this text-mode default.

regards,

/iaw
Joost Kremers
2013-08-23 08:12:32 UTC
Permalink
this is really useful. if any emacs developers are reading this group,
may I suggest that this mode should be the text default mode when a
file is loaded that has lines that are really long? It could trigger
if there are more than 3 lines that are more than 180 characters long,
for example. or it could even be the default text-mode.
note that longline-mode was deprecated a while ago in favour of
visual-line-mode and has actually been removed from the latest Emacs
release, or will be removed in the next. It's still available in
lisp/obsolete, but you'd have to load it explicitly.
--
Joost Kremers ***@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)
Teemu Likonen
2012-09-12 16:25:30 UTC
Permalink
Post by iaw4
does such a mode exist for text files?
You can use visual-line-mode which is a minor mode. I have my own
flowing-text-mode based on text-mode and visual-line-mode:


(define-derived-mode flowing-text-mode text-mode "Text[flow]"
"Major mode for editing text with long flowing lines."
(visual-line-mode 1)
(whitespace-newline-mode 1)
(set (make-local-variable 'tab-stop-list)
(number-sequence 4 100 4))
(setq indent-tabs-mode nil
fill-column 99999))
Loading...