all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Turn on longlines in text modes [patch]
@ 2005-07-18 21:44 David Reitter
  2005-07-19  5:39 ` Chong Yidong
  2005-07-20  8:34 ` Richard M. Stallman
  0 siblings, 2 replies; 7+ messages in thread
From: David Reitter @ 2005-07-18 21:44 UTC (permalink / raw)



[-- Attachment #1.1.1: Type: text/plain, Size: 805 bytes --]

With the advent of longlines-mode it seems highly useful to have this  
mode directly available from the Options menu, and at least have a  
simple way to turn it on automatically in all text modes, just like  
auto fill. This could be done as in the enclosed patch. Of course  
there would be more generic ways, integrating the auto fill and  
longlines toggle functions, etc. - but probably not worth the hassle.

Also, can I suggest to turn on longlines-wrap-follows-window-size by  
default? Longlines is very much a matter of altering the way text is  
displayed (rather than actually modifying the buffer as saved to  
disk). Therefore I think it would be very sensible to link it to the  
window size by default rather than to a fixed line length. (This  
change is not included in the patch.)


  

[-- Attachment #1.1.2: soft-wrap.patch --]
[-- Type: application/octet-stream, Size: 3411 bytes --]

Index: menu-bar.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/menu-bar.el,v
retrieving revision 1.261
diff -c -r1.261 menu-bar.el
*** menu-bar.el	4 Jul 2005 23:08:56 -0000	1.261
--- menu-bar.el	18 Jul 2005 21:41:44 -0000
***************
*** 1031,1036 ****
--- 1031,1052 ----
                :button (:toggle . (if (listp text-mode-hook)
  				     (member 'turn-on-auto-fill text-mode-hook)
  				   (eq 'turn-on-auto-fill text-mode-hook)))))
+ 
+ (defun menu-bar-text-mode-longlines ()
+   (interactive)
+   (toggle-text-mode-longlines)
+   ;; This is somewhat questionable, as `text-mode-hook'
+   ;; might have changed outside customize.
+   ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2002-02-11.
+   (customize-mark-as-set 'text-mode-hook))
+ 
+ (define-key menu-bar-options-menu [longlines-mode]
+   '(menu-item "Soft Word Wrap in Text Modes"
+               menu-bar-text-mode-longlines
+ 	      :help "Automatically wrap words at line margins without creating new lines. (Longlines)"
+               :button (:toggle . (if (listp text-mode-hook)
+ 				     (member 'turn-on-longlines text-mode-hook)
+ 				   (eq 'turn-on-longlines text-mode-hook)))))
  (define-key menu-bar-options-menu [truncate-lines]
    '(menu-item "Truncate Long Lines in this Buffer"
  	      toggle-truncate-lines
Index: textmodes/text-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/textmodes/text-mode.el,v
retrieving revision 1.46
diff -c -r1.46 text-mode.el
*** textmodes/text-mode.el	4 Jul 2005 16:45:00 -0000	1.46
--- textmodes/text-mode.el	18 Jul 2005 21:41:44 -0000
***************
*** 32,38 ****
  (defcustom text-mode-hook nil
    "Normal hook run when entering Text mode and many related modes."
    :type 'hook
!   :options '(turn-on-auto-fill flyspell-mode)
    :group 'data)
  
  (defvar text-mode-variant nil
--- 32,38 ----
  (defcustom text-mode-hook nil
    "Normal hook run when entering Text mode and many related modes."
    :type 'hook
!   :options '(turn-on-auto-fill turn-on-longlines flyspell-mode)
    :group 'data)
  
  (defvar text-mode-variant nil
***************
*** 122,127 ****
--- 122,147 ----
  	(if (or (derived-mode-p 'text-mode) text-mode-variant)
  	    (auto-fill-mode (if enable-mode 1 0)))))
      (message "Auto Fill %s in Text modes"
+ 	     (if enable-mode "enabled" "disabled"))))
+ 
+ (defun turn-on-longlines ()
+    "Unconditionally turn on Longlines mode."
+    (longlines-mode 1))
+  
+ (defun toggle-text-mode-longlines ()
+   "Toggle whether to use `longlines-mode' in Text mode and related modes.
+  This command affects all buffers that use modes related to Text mode,
+  both existing buffers and buffers that you subsequently create."
+   (interactive)
+   (let ((enable-mode (not (memq 'turn-on-longlines text-mode-hook))))
+     (if enable-mode
+ 	(add-hook 'text-mode-hook 'turn-on-longlines)
+       (remove-hook 'text-mode-hook 'turn-on-longlines))
+     (dolist (buffer (buffer-list))
+       (with-current-buffer buffer
+ 	(if (or (derived-mode-p 'text-mode) text-mode-variant)
+ 	    (longlines-mode (if enable-mode 1 0)))))
+     (message "Longlines Mode %s in Text modes"
  	     (if enable-mode "enabled" "disabled"))))
  \f
  (defun center-paragraph ()

[-- Attachment #1.2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 2400 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: Turn on longlines in text modes [patch]
  2005-07-18 21:44 Turn on longlines in text modes [patch] David Reitter
@ 2005-07-19  5:39 ` Chong Yidong
  2005-07-19  6:31   ` David Kastrup
  2005-07-19 11:12   ` David Reitter
  2005-07-20  8:34 ` Richard M. Stallman
  1 sibling, 2 replies; 7+ messages in thread
From: Chong Yidong @ 2005-07-19  5:39 UTC (permalink / raw)
  Cc: emacs-devel '

> With the advent of longlines-mode it seems highly useful to have this
> mode directly available from the Options menu, and at least have a
> simple way to turn it on automatically in all text modes, just like
> auto fill. This could be done as in the enclosed patch. Of course
> there would be more generic ways, integrating the auto fill and
> longlines toggle functions, etc. - but probably not worth the hassle.

Just a note: longlines mode should not be used with auto-fill-mode on. In
fact, longlines-mode explicitly turns off auto-fill-mode.

> Also, can I suggest to turn on longlines-wrap-follows-window-size by
> default? Longlines is very much a matter of altering the way text is
> displayed (rather than actually modifying the buffer as saved to
> disk). Therefore I think it would be very sensible to link it to the
> window size by default rather than to a fixed line length. (This
> change is not included in the patch.)

The reason longlines-wrap-follows-window-size is nil by default is that it
can produce unexpected behavior when the buffer is simultaneously
displayed in two windows with different widths. Longlines will wrap using
the width of one of the windows, and the results will look strange in the
other window. There doesn't seem to be an easy way out of this, as far as
I know. At least, using fill-column, at least the results will be
consistent (provided no windows are narrower than the value of
fill-column.) Of course, if you don't encounter such situations,
longlines-wrap-follows-window-size should work perfectly fine.

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

* Re: Turn on longlines in text modes [patch]
  2005-07-19  5:39 ` Chong Yidong
@ 2005-07-19  6:31   ` David Kastrup
  2005-07-19 12:48     ` Chong Yidong
  2005-07-19 11:12   ` David Reitter
  1 sibling, 1 reply; 7+ messages in thread
From: David Kastrup @ 2005-07-19  6:31 UTC (permalink / raw)
  Cc: David Reitter, emacs-devel '

"Chong Yidong" <cyd@stupidchicken.com> writes:

> The reason longlines-wrap-follows-window-size is nil by default is
> that it can produce unexpected behavior when the buffer is
> simultaneously displayed in two windows with different widths.

There are several ways out of that one, I guess.  One is to allow
settings of 'min and 'current (with the obvious implications), another
would be to use window-local display properties for letting spaces
display as newlines (and newlines as spaces) when some window has a
different width.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: Turn on longlines in text modes [patch]
  2005-07-19  5:39 ` Chong Yidong
  2005-07-19  6:31   ` David Kastrup
@ 2005-07-19 11:12   ` David Reitter
  1 sibling, 0 replies; 7+ messages in thread
From: David Reitter @ 2005-07-19 11:12 UTC (permalink / raw)



[-- Attachment #1.1: Type: text/plain, Size: 1345 bytes --]

On 19 Jul 2005, at 06:39, Chong Yidong wrote:

> Just a note: longlines mode should not be used with auto-fill-mode  
> on. In
> fact, longlines-mode explicitly turns off auto-fill-mode.

Seems logical. But if it does so, shouldn't it turn it back on then  
(i.e. to the previous value) when it's deactivated?
At least when text-mode-auto-fill is on...

> The reason longlines-wrap-follows-window-size is nil by default is  
> that it
> can produce unexpected behavior when the buffer is simultaneously
> displayed in two windows with different widths. Longlines will wrap  
> using
> the width of one of the windows, and the results will look strange  
> in the
> other window. There doesn't seem to be an easy way out of this, as  
> far as
> I know.

In addition to what David K suggested, it might be possible to just  
wrap the text to the smallest of all window widths. That's not the  
ideal solution, but still better than just wrapping all text to some  
arbitrarily predefined line length by default.

By the way: longlines-mode (with longlines-wrap-follows-window-size)  
seems to wrap to early when using a variable-width font. Since  
variable-width fonts are predominantly used in text (as opposed to  
code) writing contexts, and that's where longlines-mode plays an  
important role, it might be a good idea to think about a fix.

[-- Attachment #1.2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 2400 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: Turn on longlines in text modes [patch]
  2005-07-19  6:31   ` David Kastrup
@ 2005-07-19 12:48     ` Chong Yidong
  2005-07-19 14:29       ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Chong Yidong @ 2005-07-19 12:48 UTC (permalink / raw)
  Cc: David Reitter, emacs-devel '

>> The reason longlines-wrap-follows-window-size is nil by default is
>> that it can produce unexpected behavior when the buffer is
>> simultaneously displayed in two windows with different widths.
>
> There are several ways out of that one, I guess.  One is to allow
> settings of 'min and 'current (with the obvious implications).

Good idea.  I'll see what I can do.

> another would be to use window-local display properties for letting
> spaces display as newlines (and newlines as spaces) when some window
> has a different width.

I've actually tried implementing something like this before.  It works,
but there are more side effects than in the current longlines
implementation.  The C-a and C-e commands go to the beginning and end of
the long lines instead of screen lines, which is correct but not useful,
so they would have to be modified before this mode can work properly. 
Since there's interest, I'll see if I can iron out the problems, and post
a longlines-2-mode for people to try out.

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

* Re: Turn on longlines in text modes [patch]
  2005-07-19 12:48     ` Chong Yidong
@ 2005-07-19 14:29       ` Stefan Monnier
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2005-07-19 14:29 UTC (permalink / raw)
  Cc: David Reitter, emacs-devel '

> I've actually tried implementing something like this before.  It works,
> but there are more side effects than in the current longlines
> implementation.  The C-a and C-e commands go to the beginning and end of
> the long lines instead of screen lines, which is correct but not useful,
> so they would have to be modified before this mode can work properly.
> Since there's interest, I'll see if I can iron out the problems, and post
> a longlines-2-mode for people to try out.

You may want to see if it can be integrated with screen-lines.el (which is
supposed to cause things like C-n, C-p, C-e, C-a to go work on
display-lines rather than on text-lines).
I expect screen-lines.el to not work well in the above settings, so I guess
the only thing I'm saying is that the screen-line.el part of the behavior
should be provided separately from longlines-2-mode since it's useful in its
own right.


        Stefan

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

* Re: Turn on longlines in text modes [patch]
  2005-07-18 21:44 Turn on longlines in text modes [patch] David Reitter
  2005-07-19  5:39 ` Chong Yidong
@ 2005-07-20  8:34 ` Richard M. Stallman
  1 sibling, 0 replies; 7+ messages in thread
From: Richard M. Stallman @ 2005-07-20  8:34 UTC (permalink / raw)
  Cc: emacs-devel

    Also, can I suggest to turn on longlines-wrap-follows-window-size by  
    default?

It sounds like a good idea to me.
But maybe there should be a user-settable maximum.

    There are several ways out of that one, I guess.  One is to allow
    settings of 'min and 'current (with the obvious implications), another
    would be to use window-local display properties for letting spaces
    display as newlines (and newlines as spaces) when some window has a
    different width.

`min' would certainly give consistent results.  To use the selected
window, it should be `selected', not `current'; this could work
presuming the code runs at the right time not to get confused
about which window that will be.

    By the way: longlines-mode (with longlines-wrap-follows-window-size)  
    seems to wrap to early when using a variable-width font. Since  
    variable-width fonts are predominantly used in text (as opposed to  
    code) writing contexts, and that's where longlines-mode plays an  
    important role, it might be a good idea to think about a fix.

This is an entry in etc/TODO--to make the indentation and filling
commands handle variable-width fonts.  I'd really be glad if someone
would work on this.

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

end of thread, other threads:[~2005-07-20  8:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-18 21:44 Turn on longlines in text modes [patch] David Reitter
2005-07-19  5:39 ` Chong Yidong
2005-07-19  6:31   ` David Kastrup
2005-07-19 12:48     ` Chong Yidong
2005-07-19 14:29       ` Stefan Monnier
2005-07-19 11:12   ` David Reitter
2005-07-20  8:34 ` Richard M. Stallman

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.