]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/vera-mode.el
Fix for 2011-10-21T02:23:59Z!cyd@gnu.org.
[gnu-emacs] / lisp / progmodes / vera-mode.el
index 0b50ee103b5f9592d96648de7da74cc6ec7ff4a1..b02324871ff46f96b5745a6c95d80fd255295546 100644 (file)
@@ -1,7 +1,6 @@
-;;; vera-mode.el --- major mode for editing Vera files.
+;;; vera-mode.el --- major mode for editing Vera files
 
-;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-;;   2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2011 Free Software Foundation, Inc.
 
 ;; Author:      Reto Zimmermann <reto@gnu.org>
 ;; Maintainer:  Reto Zimmermann <reto@gnu.org>
 
 ;; 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 3, 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
@@ -33,9 +32,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:
@@ -252,10 +249,10 @@ If nil, TAB always indents current line."
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Mode definition
 
-;;;###autoload (add-to-list 'auto-mode-alist '("\\.vr[hi]?\\'" . vera-mode))
+;;;###autoload (add-to-list 'auto-mode-alist (cons (purecopy "\\.vr[hi]?\\'")  'vera-mode))
 
 ;;;###autoload
-(defun vera-mode ()
+(define-derived-mode vera-mode prog-mode "Vera"
   "Major mode for editing Vera code.
 
 Usage:
@@ -293,7 +290,7 @@ Add a description of the problem and include a reproducible test case.
 Feel free to send questions and enhancement requests to <reto@gnu.org>.
 
 Official distribution is at
-<http://www.iis.ee.ethz.ch/~zimmi/emacs/vera-mode.html>.
+URL `http://www.iis.ee.ethz.ch/~zimmi/emacs/vera-mode.html'
 
 
                                                   The Vera Mode Maintainer
@@ -303,13 +300,6 @@ Key bindings:
 -------------
 
 \\{vera-mode-map}"
-  (interactive)
-  (kill-all-local-variables)
-  (setq major-mode 'vera-mode)
-  (setq mode-name "Vera")
-  ;; set maps and tables
-  (use-local-map vera-mode-map)
-  (set-syntax-table vera-mode-syntax-table)
   ;; set local variables
   (require 'cc-cmds)
   (set (make-local-variable 'comment-start) "//")
@@ -320,7 +310,6 @@ Key bindings:
   (set (make-local-variable 'comment-indent-function) 'c-comment-indent)
   (set (make-local-variable 'paragraph-start) "^$")
   (set (make-local-variable 'paragraph-separate) paragraph-start)
-  (set (make-local-variable 'require-final-newline) t)
   (set (make-local-variable 'indent-tabs-mode) nil)
   (set (make-local-variable 'indent-line-function) 'vera-indent-line)
   (set (make-local-variable 'parse-sexp-ignore-comments) t)
@@ -330,9 +319,7 @@ Key bindings:
   ;; add menu (XEmacs)
   (easy-menu-add vera-mode-menu)
   ;; miscellaneous
-  (message "Vera Mode %s.  Type C-c C-h for documentation." vera-version)
-  ;; run hooks
-  (run-hooks 'vera-mode-hook))
+  (message "Vera Mode %s.  Type C-c C-h for documentation." vera-version))
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -772,7 +759,7 @@ the offset is simply returned."
              relpos 0)
       (setq offset (vera-evaluate-offset offset langelem symbol)))
     (+ (if (and relpos
-               (< relpos (save-excursion (beginning-of-line) (point))))
+               (< relpos (line-beginning-position)))
           (save-excursion
             (goto-char relpos)
             (current-column))
@@ -1089,7 +1076,7 @@ try to increase performance by using this macro."
   (save-excursion
     (beginning-of-line)
     (let ((indent-point (point))
-         syntax state placeholder pos)
+         syntax state placeholder)
       ;; determine syntax state
       (setq state (parse-partial-sexp (point-min) (point)))
       (cond
@@ -1252,7 +1239,7 @@ Calls `indent-region' for whole buffer."
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; electrifications
 
-(defun vera-electric-tab (&optional prefix-arg)
+(defun vera-electric-tab (&optional prefix)
   "Do what I mean (indent, expand, tab, change indent, etc..).
 If preceding character is part of a word or a paren then `hippie-expand',
 else if right of non whitespace on line then `tab-to-tab-stop',
@@ -1263,14 +1250,16 @@ If `vera-intelligent-tab' is nil, always indent line."
   (interactive "*P")
   (if vera-intelligent-tab
       (progn
-       (cond ((memq (char-syntax (preceding-char)) '(?w ?_))
+       (cond ((and (not (featurep 'xemacs)) (use-region-p))
+              (vera-indent-region (region-beginning) (region-end) nil))
+             ((memq (char-syntax (preceding-char)) '(?w ?_))
               (let ((case-fold-search t)
                     (case-replace nil)
                     (hippie-expand-only-buffers
                      (or (and (boundp 'hippie-expand-only-buffers)
                               hippie-expand-only-buffers)
                          '(vera-mode))))
-                (vera-expand-abbrev prefix-arg)))
+                (vera-expand-abbrev prefix)))
              ((> (current-column) (current-indentation))
               (tab-to-tab-stop))
              ((and (or (eq last-command 'vera-electric-tab)
@@ -1340,7 +1329,7 @@ If `vera-intelligent-tab' is nil, always indent line."
   (interactive "*P")
   (let* ((ch (char-before))
         (indentp (and (not arg)
-                      (eq last-command-char ?/)
+                      (eq last-command-event ?/)
                       (or (and (eq ch ?/)
                                (not (vera-in-literal)))
                           (and (eq ch ?*)
@@ -1412,7 +1401,7 @@ If `vera-intelligent-tab' is nil, always indent line."
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Comments
 
-(defun vera-comment-uncomment-region (beg end &optional arg)
+(defun vera-comment-uncomment-region (beg end &optional _arg)
   "Comment region if not commented, uncomment region if already commented."
   (interactive "r\nP")
   (goto-char beg)
@@ -1482,5 +1471,4 @@ If `vera-intelligent-tab' is nil, always indent line."
 
 (provide 'vera-mode)
 
-;; arch-tag: 22eae722-7ac5-47ac-a713-c4db1cf623a9
 ;;; vera-mode.el ends here