From: Juri Linkov <juri@jurta.org>
To: emacs-devel@gnu.org
Subject: Re: C-n and C-a
Date: Fri, 06 Feb 2009 02:45:17 +0200 [thread overview]
Message-ID: <8763jotmim.fsf@jurta.org> (raw)
In-Reply-To: <E1LSXwC-0001K2-VZ@fencepost.gnu.org> (Richard M. Stallman's message of "Thu, 29 Jan 2009 09:32:12 -0500")
Below is a patch that addresses part of problems raised on
this thread. (I'll send a separate patch for another part later).
First, it adds a new prefix map bound to `C-x l' for line-oriented
commands, and rebinds `count-lines-page' to `C-x l p'.
There was an old commented-out line for the `narrow-to-page' command
bound to `C-x p' that was later rebound to `C-x n p'. Now we will have
a symmetrical key `C-x l p' for another page-related command. Also it
binds more line-oriented commands to `C-x l': `toggle-truncate-lines'
to `C-x l t', `toggle-word-wrap' to `C-x l w' and `visual-line-mode'
to `C-x l v'.
`toggle-word-wrap' is a new command. Actually it's just a copy of
`toggle-truncate-lines' that operates on the variable `word-wrap'
instead of `truncate-lines'. By analogy with `default-truncate-lines'
it also adds a new variable `default-word-wrap'.
The default value of `word-wrap' is changed to t that is the most
expected default value nowadays as most editors do. This eliminates
the need to enforce enabling word-mode in `visual-line-mode'.
The essential point of `visual-line-mode' is only to turn off
`truncate-lines' since otherwise it makes no sense. The doc string
now says so.
Index: lisp/bindings.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/bindings.el,v
retrieving revision 1.218
diff -c -r1.218 bindings.el
*** lisp/bindings.el 29 Jan 2009 08:53:39 -0000 1.218
--- lisp/bindings.el 6 Feb 2009 00:41:24 -0000
***************
*** 718,723 ****
--- 718,727 ----
(define-key narrow-map "n" 'narrow-to-region)
(define-key narrow-map "w" 'widen)
+ (defvar line-map (make-sparse-keymap)
+ "Keymap for line-oriented commands.")
+ (define-key ctl-x-map "l" line-map)
+
;; Quitting
(define-key global-map "\e\e\e" 'keyboard-escape-quit)
(define-key global-map "\C-g" 'keyboard-quit)
***************
*** 1092,1098 ****
(define-key esc-map "\C-a" 'beginning-of-defun)
(define-key esc-map "\C-e" 'end-of-defun)
(define-key esc-map "\C-h" 'mark-defun)
! (define-key ctl-x-map "nd" 'narrow-to-defun)
(define-key esc-map "(" 'insert-parentheses)
(define-key esc-map ")" 'move-past-close-and-reindent)
--- 1098,1104 ----
(define-key esc-map "\C-a" 'beginning-of-defun)
(define-key esc-map "\C-e" 'end-of-defun)
(define-key esc-map "\C-h" 'mark-defun)
! (define-key narrow-map "d" 'narrow-to-defun)
(define-key esc-map "(" 'insert-parentheses)
(define-key esc-map ")" 'move-past-close-and-reindent)
***************
*** 1121,1129 ****
(define-key ctl-x-map "[" 'backward-page)
(define-key ctl-x-map "]" 'forward-page)
(define-key ctl-x-map "\C-p" 'mark-page)
! (define-key ctl-x-map "l" 'count-lines-page)
! (define-key ctl-x-map "np" 'narrow-to-page)
! ;; (define-key ctl-x-map "p" 'narrow-to-page)
\f
(defvar abbrev-map (make-sparse-keymap)
"Keymap for abbrev commands.")
--- 1127,1138 ----
(define-key ctl-x-map "[" 'backward-page)
(define-key ctl-x-map "]" 'forward-page)
(define-key ctl-x-map "\C-p" 'mark-page)
! (define-key narrow-map "p" 'narrow-to-page)
! (define-key line-map "p" 'count-lines-page)
! \f
! (define-key line-map "t" 'toggle-truncate-lines)
! (define-key line-map "w" 'toggle-word-wrap)
! (define-key line-map "v" 'visual-line-mode)
\f
(defvar abbrev-map (make-sparse-keymap)
"Keymap for abbrev commands.")
Index: lisp/simple.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/simple.el,v
retrieving revision 1.968
diff -c -r1.968 simple.el
*** lisp/simple.el 27 Jan 2009 20:09:38 -0000 1.968
--- lisp/simple.el 6 Feb 2009 00:42:16 -0000
***************
*** 4550,4556 ****
(define-minor-mode visual-line-mode
"Redefine simple editing commands to act on visual lines, not logical lines.
! This also turns on `word-wrap' in the buffer."
:keymap visual-line-mode-map
:group 'visual-line
:lighter " wrap"
--- 4560,4566 ----
(define-minor-mode visual-line-mode
"Redefine simple editing commands to act on visual lines, not logical lines.
! This also turns off `truncate-lines' in the buffer."
:keymap visual-line-mode-map
:group 'visual-line
:lighter " wrap"
***************
*** 4562,4580 ****
;; visual-line-mode is turned off.
(dolist (var '(line-move-visual truncate-lines
truncate-partial-width-windows
! word-wrap fringe-indicator-alist))
(if (local-variable-p var)
(push (cons var (symbol-value var))
visual-line--saved-state)))
(set (make-local-variable 'line-move-visual) t)
(set (make-local-variable 'truncate-partial-width-windows) nil)
(setq truncate-lines nil
- word-wrap t
fringe-indicator-alist
(cons (cons 'continuation visual-line-fringe-indicators)
fringe-indicator-alist)))
(kill-local-variable 'line-move-visual)
- (kill-local-variable 'word-wrap)
(kill-local-variable 'truncate-lines)
(kill-local-variable 'truncate-partial-width-windows)
(kill-local-variable 'fringe-indicator-alist)
--- 4572,4588 ----
;; visual-line-mode is turned off.
(dolist (var '(line-move-visual truncate-lines
truncate-partial-width-windows
! fringe-indicator-alist))
(if (local-variable-p var)
(push (cons var (symbol-value var))
visual-line--saved-state)))
(set (make-local-variable 'line-move-visual) t)
(set (make-local-variable 'truncate-partial-width-windows) nil)
(setq truncate-lines nil
fringe-indicator-alist
(cons (cons 'continuation visual-line-fringe-indicators)
fringe-indicator-alist)))
(kill-local-variable 'line-move-visual)
(kill-local-variable 'truncate-lines)
(kill-local-variable 'truncate-partial-width-windows)
(kill-local-variable 'fringe-indicator-alist)
***************
*** 5075,5080 ****
--- 5083,5103 ----
(message "Truncate long lines %s"
(if truncate-lines "enabled" "disabled")))
+ (defun toggle-word-wrap (&optional arg)
+ "Toggle whether to use word-wrapping for continuation lines.
+ With prefix argument ARG, wrap continuation lines at word boundaries
+ if ARG is positive, otherwise wrap them at the right screen edge.
+ This command toggles the value of `word-wrap'. It has no effect
+ if long lines are truncated."
+ (interactive "P")
+ (setq word-wrap
+ (if (null arg)
+ (not word-wrap)
+ (> (prefix-numeric-value arg) 0)))
+ (force-mode-line-update)
+ (message "Word wrapping %s"
+ (if word-wrap "enabled" "disabled")))
+
(defvar overwrite-mode-textual " Ovwrt"
"The string displayed in the mode line when in overwrite mode.")
(defvar overwrite-mode-binary " Bin Ovwrt"
Index: src/buffer.c
===================================================================
RCS file: /sources/emacs/emacs/src/buffer.c,v
retrieving revision 1.579
diff -c -r1.579 buffer.c
*** src/buffer.c 8 Jan 2009 03:15:25 -0000 1.579
--- src/buffer.c 6 Feb 2009 00:44:28 -0000
***************
*** 5175,5181 ****
XSETFASTINT (buffer_defaults.tab_width, 8);
buffer_defaults.truncate_lines = Qnil;
! buffer_defaults.word_wrap = Qnil;
buffer_defaults.ctl_arrow = Qt;
buffer_defaults.direction_reversed = Qnil;
buffer_defaults.cursor_type = Qt;
--- 5175,5181 ----
XSETFASTINT (buffer_defaults.tab_width, 8);
buffer_defaults.truncate_lines = Qnil;
! buffer_defaults.word_wrap = Qt;
buffer_defaults.ctl_arrow = Qt;
buffer_defaults.direction_reversed = Qnil;
buffer_defaults.cursor_type = Qt;
***************
*** 5540,5545 ****
--- 5540,5550 ----
doc: /* Default value of `truncate-lines' for buffers that do not override it.
This is the same as (default-value 'truncate-lines). */);
+ DEFVAR_LISP_NOPRO ("default-word-wrap",
+ &buffer_defaults.word_wrap,
+ doc: /* Default value of `word-wrap' for buffers that do not override it.
+ This is the same as (default-value 'word-wrap). */);
+
DEFVAR_LISP_NOPRO ("default-fill-column",
&buffer_defaults.fill_column,
doc: /* Default value of `fill-column' for buffers that do not override it.
--
Juri Linkov
http://www.jurta.org/emacs/
next prev parent reply other threads:[~2009-02-06 0:45 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-29 14:32 C-n and C-a Richard M Stallman
2009-01-29 15:10 ` Tassilo Horn
2009-01-29 16:09 ` Harald Hanche-Olsen
2009-01-29 17:15 ` Tassilo Horn
2009-01-29 19:40 ` Adrian Robert
2009-01-30 0:32 ` Juri Linkov
2009-01-30 1:20 ` Stefan Monnier
2009-01-30 9:45 ` Eli Zaretskii
2009-01-31 17:45 ` Juri Linkov
2009-01-31 19:47 ` Stefan Monnier
2009-02-02 1:45 ` Juri Linkov
2009-01-31 20:33 ` Chong Yidong
2009-02-02 1:47 ` Juri Linkov
2009-01-30 7:25 ` Richard M Stallman
2009-01-29 18:24 ` Karl Fogel
2009-01-29 18:48 ` Harald Hanche-Olsen
2009-01-29 21:41 ` Stefan Monnier
2009-01-30 16:07 ` Sascha Wilde
2009-01-31 20:34 ` Chong Yidong
2009-01-30 0:29 ` Juri Linkov
2009-01-30 6:12 ` mail
2009-01-31 17:45 ` Juri Linkov
2009-01-31 22:35 ` Drew Adams
2009-02-01 20:11 ` Leo
2009-02-03 15:11 ` Carsten Dominik
2009-02-02 1:54 ` Juri Linkov
2009-02-02 2:25 ` Drew Adams
2009-02-02 9:45 ` Juri Linkov
2009-02-06 0:45 ` Juri Linkov [this message]
2009-02-06 16:04 ` Chong Yidong
2009-02-08 0:48 ` Juri Linkov
2009-02-08 20:08 ` Stefan Monnier
2009-02-09 21:22 ` Christian Schlauer
2009-02-09 22:02 ` Drew Adams
2009-02-10 2:05 ` Stefan Monnier
2009-02-10 3:11 ` Drew Adams
2009-02-11 22:45 ` Juri Linkov
2009-02-12 2:01 ` Miles Bader
2009-02-12 10:05 ` Juri Linkov
2009-02-12 11:04 ` Miles Bader
2009-02-13 6:33 ` Richard M Stallman
2009-02-07 1:52 ` Stefan Monnier
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8763jotmim.fsf@jurta.org \
--to=juri@jurta.org \
--cc=emacs-devel@gnu.org \
/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 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.