Add 2010 to copyright years.
[bpt/emacs.git] / lisp / textmodes / picture.el
index 3ae3921..2673ee1 100644 (file)
@@ -1,6 +1,7 @@
 ;;; picture.el --- "Picture mode" -- editing using quarter-plane screen model
 
-;; Copyright (C) 1985, 1994, 2002, 2003 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+;;   2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: K. Shane Hartman
 ;; Maintainer: FSF
@@ -8,10 +9,10 @@
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -19,9 +20,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -560,7 +559,8 @@ Leaves the region surrounding the rectangle."
          (left   (min c1 c2))
          (top    (min r1 r2))
          (bottom (max r1 r2)))
-    (goto-line top)
+    (goto-char (point-min))
+    (forward-line (1- top))
     (move-to-column left t)
     (picture-update-desired-column t)
 
@@ -581,7 +581,8 @@ Leaves the region surrounding the rectangle."
     (picture-insert picture-rectangle-v (- (picture-current-line) top))
 
     (picture-set-motion pvs phs)
-    (goto-line sl)
+    (goto-char (point-min))
+    (forward-line (1- sl))
     (move-to-column sc t)))
 
 \f
@@ -660,60 +661,69 @@ Picture mode is invoked by the command \\[picture-mode]."
 ;;;###autoload
 (defun picture-mode ()
   "Switch to Picture mode, in which a quarter-plane screen model is used.
+\\<picture-mode-map>
 Printing characters replace instead of inserting themselves with motion
 afterwards settable by these commands:
-  C-c <          Move left after insertion.
-  C-c >          Move right after insertion.
-  C-c ^          Move up after insertion.
-  C-c .          Move down after insertion.
-  C-c `          Move northwest (nw) after insertion.
-  C-c '          Move northeast (ne) after insertion.
-  C-c /          Move southwest (sw) after insertion.
-  C-c \\   Move southeast (se) after insertion.
-  C-u C-c `  Move westnorthwest (wnw) after insertion.
-  C-u C-c '  Move eastnortheast (ene) after insertion.
-  C-u C-c /  Move westsouthwest (wsw) after insertion.
-  C-u C-c \\  Move eastsoutheast (ese) after insertion.
+
+ Move left after insertion:            \\[picture-movement-left]
+ Move right after insertion:           \\[picture-movement-right]
+ Move up after insertion:              \\[picture-movement-up]
+ Move down after insertion:            \\[picture-movement-down]
+
+ Move northwest (nw) after insertion:  \\[picture-movement-nw]
+ Move northeast (ne) after insertion:  \\[picture-movement-ne]
+ Move southwest (sw) after insertion:  \\[picture-movement-sw]
+ Move southeast (se) after insertion:  \\[picture-movement-se]
+
+ Move westnorthwest (wnw) after insertion:  C-u \\[picture-movement-nw]
+ Move eastnortheast (ene) after insertion:  C-u \\[picture-movement-ne]
+ Move westsouthwest (wsw) after insertion:  C-u \\[picture-movement-sw]
+ Move eastsoutheast (ese) after insertion:  C-u \\[picture-movement-se]
+
 The current direction is displayed in the mode line.  The initial
 direction is right.  Whitespace is inserted and tabs are changed to
 spaces when required by movement.  You can move around in the buffer
 with these commands:
-  \\[picture-move-down]          Move vertically to SAME column in previous line.
-  \\[picture-move-up]    Move vertically to SAME column in next line.
-  \\[picture-end-of-line]        Move to column following last non-whitespace character.
-  \\[picture-forward-column]     Move right inserting spaces if required.
-  \\[picture-backward-column]    Move left changing tabs to spaces if required.
-  C-c C-f Move in direction of current picture motion.
-  C-c C-b Move in opposite direction of current picture motion.
-  Return  Move to beginning of next line.
+
+ Move vertically to SAME column in previous line: \\[picture-move-down]
+ Move vertically to SAME column in next line:     \\[picture-move-up]
+ Move to column following last
+  non-whitespace character:                       \\[picture-end-of-line]
+ Move right, inserting spaces if required:        \\[picture-forward-column]
+ Move left changing tabs to spaces if required:   \\[picture-backward-column]
+ Move in direction of current picture motion:     \\[picture-motion]
+ Move opposite to current picture motion:         \\[picture-motion-reverse]
+ Move to beginning of next line:                  \\[next-line]
+
 You can edit tabular text with these commands:
-  M-Tab          Move to column beneath (or at) next interesting character.
-           `Indents' relative to a previous line.
-  Tab    Move to next stop in tab stop list.
-  C-c Tab Set tab stops according to context of this line.
-           With ARG resets tab stops to default (global) value.
-           See also documentation of variable  picture-tab-chars
-           which defines \"interesting character\".  You can manually
-           change the tab stop list with command \\[edit-tab-stops].
+
+ Move to column beneath (or at) next interesting
+  character (see variable `picture-tab-chars'):   \\[picture-tab-search]
+ Move to next stop in tab stop list:              \\[picture-tab]
+ Set tab stops according to context of this line: \\[picture-set-tab-stops]
+   (With ARG, resets tab stops to default value.)
+ Change the tab stop list:                        \\[edit-tab-stops]
+
 You can manipulate text with these commands:
-  C-d    Clear (replace) ARG columns after point without moving.
-  C-c C-d Delete char at point - the command normally assigned to C-d.
-  \\[picture-backward-clear-column]  Clear (replace) ARG columns before point, moving back over them.
-  \\[picture-clear-line]         Clear ARG lines, advancing over them.  The cleared
-           text is saved in the kill ring.
-  \\[picture-open-line]          Open blank line(s) beneath current line.
+ Clear ARG columns after point without moving:    \\[picture-clear-column]
+ Delete char at point:                            \\[delete-char]
+ Clear ARG columns backward:                      \\[picture-backward-clear-column]
+ Clear ARG lines, advancing over them:            \\[picture-clear-line]
+  (the cleared text is saved in the kill ring)
+ Open blank line(s) beneath current line:         \\[picture-open-line]
+
 You can manipulate rectangles with these commands:
-  C-c C-k Clear (or kill) a rectangle and save it.
-  C-c C-w Like C-c C-k except rectangle is saved in named register.
-  C-c C-y Overlay (or insert) currently saved rectangle at point.
-  C-c C-x Like C-c C-y except rectangle is taken from named register.
-  C-c C-r Draw a rectangular box around mark and point.
-  \\[copy-rectangle-to-register]   Copies a rectangle to a register.
-  \\[advertised-undo]   Can undo effects of rectangle overlay commands
-           if invoked soon enough.
-You can return to the previous mode with:
-  C-c C-c Which also strips trailing whitespace from every line.
-           Stripping is suppressed by supplying an argument.
+  Clear a rectangle and save it:                  \\[picture-clear-rectangle]
+  Clear a rectangle, saving in a named register:  \\[picture-clear-rectangle-to-register]
+  Insert currently saved rectangle at point:      \\[picture-yank-rectangle]
+  Insert rectangle from named register:           \\[picture-yank-rectangle-from-register]
+  Draw a rectangular box around mark and point:   \\[picture-draw-rectangle]
+  Copies a rectangle to a register:               \\[copy-rectangle-to-register]
+  Undo effects of rectangle overlay commands:     \\[undo]
+
+You can return to the previous mode with \\[picture-mode-exit], which
+also strips trailing whitespace from every line.  Stripping is suppressed
+by supplying an argument.
 
 Entry to this mode calls the value of `picture-mode-hook' if non-nil.
 
@@ -748,8 +758,9 @@ they are not defaultly assigned to keys."
 
 (defun picture-mode-exit (&optional nostrip)
   "Undo `picture-mode' and return to previous major mode.
-With no argument strips whitespace from end of every line in Picture buffer
-  otherwise just return to previous mode."
+With no argument, strip whitespace from end of every line in Picture buffer;
+  otherwise, just return to previous mode.
+Runs `picture-mode-exit-hook' at the end."
   (interactive "P")
   (if (not (eq major-mode 'picture-mode))
       (error "You aren't editing a Picture")
@@ -759,9 +770,10 @@ With no argument strips whitespace from end of every line in Picture buffer
     (setq major-mode picture-mode-old-major-mode)
     (kill-local-variable 'tab-stop-list)
     (setq truncate-lines picture-mode-old-truncate-lines)
-    (force-mode-line-update)))
+    (force-mode-line-update)
+    (run-hooks 'picture-mode-exit-hook)))
 
 (provide 'picture)
 
-;;; arch-tag: e452d08d-a470-4fbf-896e-ea276698d1ca
+;; arch-tag: e452d08d-a470-4fbf-896e-ea276698d1ca
 ;;; picture.el ends here