From: David Reitter <david.reitter@gmail.com>
Subject: Turn on longlines in text modes [patch]
Date: Mon, 18 Jul 2005 22:44:59 +0100 [thread overview]
Message-ID: <993C95CD-DA31-4B96-A73F-94D0B46A4B65@gmail.com> (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
next reply other threads:[~2005-07-18 21:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-18 21:44 David Reitter [this message]
2005-07-19 5:39 ` Turn on longlines in text modes [patch] 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=993C95CD-DA31-4B96-A73F-94D0B46A4B65@gmail.com \
--to=david.reitter@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).