bug-gnu-emacs
[Top][All Lists]
Advanced

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

A potential bug of longlines-mode


From: brianjiang
Subject: A potential bug of longlines-mode
Date: Fri, 3 Aug 2007 12:49:22 +0800

A potential bug of longlines-mode
 
If for some reason executing (longlines-mode 1) twice for the same
buffer, the longlines will be cut with "hard newline" instead of the
"soft newline". Then when the buffer is saved, the long line will be
saved as multiple lines. And when the longlines-mode is disabled, the
longline cannot go back to a single lines.
 
This may break the format of the user's file unexpectedly (since no
modified flag wil be set when adding the newline.).
 
I met this issue recently because I put "(desktop-read)" in my .emacs
file (I followed some out-of-date tips) wrongly. then the
(desktop-read) is executing twice (one is during load eva the .emacs
file, the other time is when after-init-hook is running.). So the
(longlines-mode 1) is executing twice too.
 
I have a brief look at the longlines.el, and find the mechanism of
the mode is: When enabling the mode, it replaces all the newline with
"hard newline" and the fill the paragraph using "soft newline". When
disabling the mode, it removes all the "soft newline" so that the
buffer go back to its original content.
 
But if we executing (longlines-mode 1) when the longlines mode already
turned on, then all the "soft newline" added by longlines mode
previously will be replaced by "hard newline" and the when we disable
the mode or save the file, we cannot go back to the original text
since we cannot distinguish which newline is added by longlines and
which newline the file already has before.
 
All we need to do to fix this problem is that when enabling the
longlines mode, check whether the longlnes mode have already
enabled. If yes, then don't replace the "soft newline" with "hard
newline" (or don't do the turn on action again).
Regards,
Brian

reply via email to

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