;;; array.el --- array editing commands for GNU Emacs
-;; Copyright (C) 1987, 2000, 2001, 2002, 2003, 2004,
-;; 2005, 2006 Free Software Foundation, Inc.
+;; Copyright (C) 1987, 2000-2014 Free Software Foundation, Inc.
-;; Author David M. Brown
-;; Maintainer: FSF
+;; Author: David M. Brown
+;; Maintainer: emacs-devel@gnu.org
;; Keywords: extensions
;; 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
;; 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:
(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.
;;; 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
\\[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)
(+ (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