From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: C-n and C-a Date: Fri, 06 Feb 2009 02:45:17 +0200 Organization: JURTA Message-ID: <8763jotmim.fsf@jurta.org> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1233930169 28487 80.91.229.12 (6 Feb 2009 14:22:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 6 Feb 2009 14:22:49 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Feb 06 15:24:04 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LVRcW-00037n-0O for ged-emacs-devel@m.gmane.org; Fri, 06 Feb 2009 15:23:52 +0100 Original-Received: from localhost ([127.0.0.1]:54391 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LVRbC-00035M-RU for ged-emacs-devel@m.gmane.org; Fri, 06 Feb 2009 09:22:30 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LVFBs-0001iM-Cy for emacs-devel@gnu.org; Thu, 05 Feb 2009 20:07:32 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LVFBq-0001i4-P2 for emacs-devel@gnu.org; Thu, 05 Feb 2009 20:07:32 -0500 Original-Received: from [199.232.76.173] (port=37299 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LVFBq-0001hz-MD for emacs-devel@gnu.org; Thu, 05 Feb 2009 20:07:30 -0500 Original-Received: from relay01.kiev.sovam.com ([62.64.120.200]:1236) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LVFBp-0002Lz-Ur for emacs-devel@gnu.org; Thu, 05 Feb 2009 20:07:30 -0500 Original-Received: from [83.170.232.243] (helo=smtp.svitonline.com) by relay01.kiev.sovam.com with esmtp (Exim 4.69) (envelope-from ) id 1LVFBj-000JBn-6p for emacs-devel@gnu.org; Fri, 06 Feb 2009 03:07:23 +0200 In-Reply-To: (Richard M. Stallman's message of "Thu, 29 Jan 2009 09:32:12 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.90 (x86_64-pc-linux-gnu) X-Scanner-Signature: 26e083d2ce24d3f2b762b2848bba661f X-DrWeb-checked: yes X-detected-operating-system: by monty-python.gnu.org: FreeBSD 4.8-5.1 (or MacOS X 10.2-10.3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:108811 Archived-At: 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) (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) ! ! (define-key line-map "t" 'toggle-truncate-lines) ! (define-key line-map "w" 'toggle-word-wrap) ! (define-key line-map "v" 'visual-line-mode) (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/