unofficial mirror of emacs-devel@gnu.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

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