]> code.delx.au - gnu-emacs/blobdiff - lisp/array.el
Do not prompt twice to save a buffer
[gnu-emacs] / lisp / array.el
index d68aaa5cf621c8df2f7cc5f81d06688527ebeb0a..f0960fae01d11b1fc0aaac312264ff0dc30a70a3 100644 (file)
@@ -1,10 +1,9 @@
 ;;; array.el --- array editing commands for GNU Emacs
 
-;; Copyright (C) 1987, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-;;   2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1987, 2000-2016 Free Software Foundation, Inc.
 
 ;; Author: David M. Brown
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
 ;; Keywords: extensions
 
 ;; This file is part of GNU Emacs.
@@ -748,9 +747,7 @@ of `array-rows-numbered'."
 
 (defun current-line ()
   "Return the current buffer line at point.  The first line is 0."
-  (save-excursion
-    (beginning-of-line)
-    (count-lines (point-min) (point))))
+  (count-lines (point-min) (line-beginning-position)))
 
 (defun move-to-column-untabify (column)
   "Move to COLUMN on the current line, untabifying if necessary.
@@ -775,37 +772,35 @@ Return COLUMN."
 
 ;;; Array mode.
 
-(defvar array-mode-map nil
+(defvar array-mode-map
+  (let ((map (make-keymap)))
+    (define-key map "\M-ad"   'array-display-local-variables)
+    (define-key map "\M-am"   'array-make-template)
+    (define-key map "\M-ae"   'array-expand-rows)
+    (define-key map "\M-ar"   'array-reconfigure-rows)
+    (define-key map "\M-a="   'array-what-position)
+    (define-key map "\M-ag"   'array-goto-cell)
+    (define-key map "\M-af"   'array-fill-rectangle)
+    (define-key map "\C-n"    'array-next-row)
+    (define-key map "\C-p"    'array-previous-row)
+    (define-key map "\C-f"    'array-forward-column)
+    (define-key map "\C-b"    'array-backward-column)
+    (define-key map "\M-n"    'array-copy-down)
+    (define-key map "\M-p"    'array-copy-up)
+    (define-key map "\M-f"    'array-copy-forward)
+    (define-key map "\M-b"    'array-copy-backward)
+    (define-key map "\M-\C-n" 'array-copy-row-down)
+    (define-key map "\M-\C-p" 'array-copy-row-up)
+    (define-key map "\M-\C-f" 'array-copy-column-forward)
+    (define-key map "\M-\C-b" 'array-copy-column-backward)
+    map)
   "Keymap used in array mode.")
 
-(if array-mode-map
-    ()
-  (setq array-mode-map (make-keymap))
-  ;; Bind keys.
-  (define-key array-mode-map "\M-ad"   'array-display-local-variables)
-  (define-key array-mode-map "\M-am"   'array-make-template)
-  (define-key array-mode-map "\M-ae"   'array-expand-rows)
-  (define-key array-mode-map "\M-ar"   'array-reconfigure-rows)
-  (define-key array-mode-map "\M-a="   'array-what-position)
-  (define-key array-mode-map "\M-ag"   'array-goto-cell)
-  (define-key array-mode-map "\M-af"   'array-fill-rectangle)
-  (define-key array-mode-map "\C-n"    'array-next-row)
-  (define-key array-mode-map "\C-p"    'array-previous-row)
-  (define-key array-mode-map "\C-f"    'array-forward-column)
-  (define-key array-mode-map "\C-b"    'array-backward-column)
-  (define-key array-mode-map "\M-n"    'array-copy-down)
-  (define-key array-mode-map "\M-p"    'array-copy-up)
-  (define-key array-mode-map "\M-f"    'array-copy-forward)
-  (define-key array-mode-map "\M-b"    'array-copy-backward)
-  (define-key array-mode-map "\M-\C-n" 'array-copy-row-down)
-  (define-key array-mode-map "\M-\C-p" 'array-copy-row-up)
-  (define-key array-mode-map "\M-\C-f" 'array-copy-column-forward)
-  (define-key array-mode-map "\M-\C-b" 'array-copy-column-backward))
 
 (put 'array-mode 'mode-class 'special)
 
 ;;;###autoload
-(defun array-mode ()
+(define-derived-mode array-mode fundamental-mode "Array"
   "Major mode for editing arrays.
 
   Array mode is a specialized mode for editing arrays.  An array is
@@ -868,9 +863,6 @@ take a numeric prefix argument):
         \\[array-display-local-variables]   Display the current values of local variables.
 
 Entering array mode calls the function `array-mode-hook'."
-
-  (interactive)
-  (kill-all-local-variables)
   (make-local-variable 'array-buffer-line)
   (make-local-variable 'array-buffer-column)
   (make-local-variable 'array-row)
@@ -893,17 +885,12 @@ Entering array mode calls the function `array-mode-hook'."
        (+ (floor (1- array-max-column) array-columns-per-line)
           (if array-rows-numbered 2 1)))
   (message "")
-  (setq major-mode 'array-mode)
-  (setq mode-name "Array")
   (force-mode-line-update)
   (set (make-local-variable 'truncate-lines) t)
-  (setq overwrite-mode 'overwrite-mode-textual)
-  (use-local-map array-mode-map)
-  (run-mode-hooks 'array-mode-hook))
+  (setq overwrite-mode 'overwrite-mode-textual))
 
 \f
 
 (provide 'array)
 
-;; arch-tag: 0086605d-79fe-4a1a-992a-456417261f80
 ;;; array.el ends here