Convert consecutive FSF copyright years to ranges.
[bpt/emacs.git] / lisp / progmodes / vhdl-mode.el
index 24768d9..a69265a 100644 (file)
@@ -1,7 +1,6 @@
 ;;; vhdl-mode.el --- major mode for editing VHDL code
 
-;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-;;   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+;; Copyright (C) 1992-2011
 ;;   Free Software Foundation, Inc.
 
 ;; Authors:     Reto Zimmermann <reto@gnu.org>
@@ -4117,7 +4116,10 @@ The directory of the current source file is scanned."
 ;; performs all buffer local initializations
 
 ;;;###autoload
-(defun vhdl-mode ()
+(define-derived-mode vhdl-mode prog-mode
+  '("VHDL" (vhdl-electric-mode "/" (vhdl-stutter-mode "/"))
+           (vhdl-electric-mode "e")
+           (vhdl-stutter-mode "s"))
   "Major mode for editing VHDL code.
 
 Usage:
@@ -4650,26 +4652,13 @@ Key bindings:
 -------------
 
 \\{vhdl-mode-map}"
-  (interactive)
-  (kill-all-local-variables)
-  (setq major-mode 'vhdl-mode)
-  (setq mode-name '("VHDL"
-                    (vhdl-electric-mode "/" (vhdl-stutter-mode "/"))
-                    (vhdl-electric-mode "e")
-                    (vhdl-stutter-mode "s")))
-
-  ;; set maps and tables
-  (use-local-map vhdl-mode-map)
-  (set-syntax-table vhdl-mode-syntax-table)
-  (setq local-abbrev-table vhdl-mode-abbrev-table)
+  :abbrev-table vhdl-mode-abbrev-table
 
   ;; set local variables
   (set (make-local-variable 'paragraph-start)
        "\\s-*\\(--+\\s-*$\\|[^ -]\\|$\\)")
   (set (make-local-variable 'paragraph-separate) paragraph-start)
   (set (make-local-variable 'paragraph-ignore-fill-prefix) t)
-  (set (make-local-variable 'require-final-newline)
-       (if vhdl-emacs-22 mode-require-final-newline t))
   (set (make-local-variable 'parse-sexp-ignore-comments) t)
   (set (make-local-variable 'indent-line-function) 'vhdl-indent-line)
   (set (make-local-variable 'comment-start) "--")
@@ -4686,8 +4675,7 @@ Key bindings:
   ;; setup the comment indent variable in a Emacs version portable way
   ;; ignore any byte compiler warnings you might get here
   (when (boundp 'comment-indent-function)
-    (make-local-variable 'comment-indent-function)
-    (setq comment-indent-function 'vhdl-comment-indent))
+    (set (make-local-variable 'comment-indent-function) 'vhdl-comment-indent))
 
   ;; initialize font locking
   (set (make-local-variable 'font-lock-defaults)
@@ -4731,12 +4719,7 @@ Key bindings:
   (vhdl-ps-print-init)
   (vhdl-write-file-hooks-init)
   (message "VHDL Mode %s.%s" vhdl-version
-          (if noninteractive "" "  See menu for documentation and release notes."))
-
-  ;; run hooks
-  (if vhdl-emacs-22
-      (run-mode-hooks 'vhdl-mode-hook)
-    (run-hooks 'vhdl-mode-hook)))
+          (if noninteractive "" "  See menu for documentation and release notes.")))
 
 (defun vhdl-activate-customizations ()
   "Activate all customizations on local variables."
@@ -4754,10 +4737,10 @@ Key bindings:
 (defun vhdl-write-file-hooks-init ()
   "Add/remove hooks when buffer is saved."
   (if vhdl-modify-date-on-saving
-      (add-hook 'local-write-file-hooks 'vhdl-template-modify-noerror)
-    (remove-hook 'local-write-file-hooks 'vhdl-template-modify-noerror))
-  (make-local-variable 'after-save-hook)
-  (add-hook 'after-save-hook 'vhdl-add-modified-file))
+      (add-hook 'local-write-file-hooks 'vhdl-template-modify-noerror nil t)
+    (remove-hook 'local-write-file-hooks 'vhdl-template-modify-noerror t))
+  (if (featurep 'xemacs) (make-local-hook 'after-save-hook))
+  (add-hook 'after-save-hook 'vhdl-add-modified-file nil t))
 
 (defun vhdl-process-command-line-option (option)
   "Process command line options for VHDL Mode."
@@ -5271,13 +5254,12 @@ argument.  The styles are chosen from the `vhdl-style-alist' variable."
       (lambda (varentry)
        (let ((var (car varentry))
              (val (cdr varentry)))
-         (and local
-              (make-local-variable var))
          ;; special case for vhdl-offsets-alist
          (if (not (eq var 'vhdl-offsets-alist))
-             (set var val)
+             (set (if local (make-local-variable var) var) val)
            ;; reset vhdl-offsets-alist to the default value first
-           (setq vhdl-offsets-alist (copy-alist vhdl-offsets-alist-default))
+           (set (if local (make-local-variable var) var)
+                 (copy-alist vhdl-offsets-alist-default))
            ;; now set the langelems that are different
            (mapcar
             (function
@@ -7269,7 +7251,7 @@ indentation is done before aligning."
        (save-excursion
         (goto-char begin)
         (let (element
-              (eol (save-excursion (progn (end-of-line) (point)))))
+              (eol (point-at-eol)))
           (setq element (nth 0 copy))
           (when (and (or (and (listp (car element))
                               (memq major-mode (car element)))
@@ -7295,7 +7277,7 @@ the token in MATCH."
       ;; Determine the greatest whitespace distance to the alignment
       ;; character
       (goto-char begin)
-      (setq eol (progn (end-of-line) (point))
+      (setq eol (point-at-eol)
            bol (setq begin (progn (beginning-of-line) (point))))
       (while (< bol end)
        (save-excursion
@@ -7306,13 +7288,13 @@ the token in MATCH."
              (setq max distance))))
        (forward-line)
        (setq bol (point)
-             eol (save-excursion (end-of-line) (point)))
+             eol (point-at-eol))
        (setq lines (1+ lines)))
       ;; Now insert enough maxs to push each assignment operator to
       ;; the same column.  We need to use 'lines' as a counter, since
       ;; the location of the mark may change
       (goto-char (setq bol begin))
-      (setq eol (save-excursion (end-of-line) (point)))
+      (setq eol (point-at-eol))
       (while (> lines 0)
        (when (and (re-search-forward match eol t)
                   (not (vhdl-in-literal)))
@@ -7324,7 +7306,7 @@ the token in MATCH."
        (beginning-of-line)
        (forward-line)
        (setq bol (point)
-             eol (save-excursion (end-of-line) (point)))
+             eol (point-at-eol))
        (setq lines (1- lines))))))
 
 (defun vhdl-align-region-groups (beg end &optional spacing
@@ -7988,7 +7970,7 @@ buffer."
           (forward-char)
           (vhdl-forward-syntactic-ws))
         (goto-char end)
-        (when (> pos (save-excursion (end-of-line) (point)))
+        (when (> pos (point-at-eol))
           (error "ERROR:  Not within a generic/port clause"))
         ;; delete closing parenthesis on separate line (not supported style)
         (when (save-excursion (beginning-of-line) (looking-at "^\\s-*);"))
@@ -12115,9 +12097,7 @@ options vhdl-upper-case-{keywords,types,attributes,enum-values}."
   "Return the line number of the line containing point."
   (save-restriction
     (widen)
-    (save-excursion
-      (beginning-of-line)
-      (1+ (count-lines (point-min) (point))))))
+    (1+ (count-lines (point-min) (point-at-bol)))))
 
 (defun vhdl-line-kill-entire (&optional arg)
   "Delete entire line."
@@ -12134,8 +12114,7 @@ options vhdl-upper-case-{keywords,types,attributes,enum-values}."
   "Copy current line."
   (interactive "p")
   (save-excursion
-    (beginning-of-line)
-    (let ((position (point)))
+    (let ((position (point-at-bol)))
       (forward-line (or arg 1))
       (copy-region-as-kill position (point)))))
 
@@ -12503,10 +12482,10 @@ File statistics: \"%s\"\n\
            (cons (list 'vhdl-mode vhdl-hs-start-regexp nil "--\\( \\|$\\)"
                        'vhdl-hs-forward-sexp-func nil)
                  hs-special-modes-alist)))
-    (make-local-variable 'hs-minor-mode-hook)
+    (if (featurep 'xemacs) (make-local-hook 'hs-minor-mode-hook))
     (if vhdl-hide-all-init
-       (add-hook 'hs-minor-mode-hook 'hs-hide-all)
-      (remove-hook 'hs-minor-mode-hook 'hs-hide-all))
+       (add-hook 'hs-minor-mode-hook 'hs-hide-all nil t)
+      (remove-hook 'hs-minor-mode-hook 'hs-hide-all t))
     (hs-minor-mode arg)
     (force-mode-line-update)))         ; hack to update menu bar
 
@@ -12973,8 +12952,8 @@ This does background highlighting of translate-off regions.")
   (if (featurep 'xemacs)
       (when (boundp 'ps-print-color-p)
        (vhdl-ps-print-settings))
-    (make-local-variable 'ps-print-hook)
-    (add-hook 'ps-print-hook 'vhdl-ps-print-settings)))
+    (if (featurep 'xemacs) (make-local-hook 'ps-print-hook))
+    (add-hook 'ps-print-hook 'vhdl-ps-print-settings nil t)))
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -15916,7 +15895,7 @@ current project/directory."
                                                         &optional insert-conf)
   "Generate block configuration for architecture."
   (let ((margin (current-indentation))
-       (beg (save-excursion (beginning-of-line) (point)))
+       (beg (point-at-bol))
        ent-entry inst-entry inst-path inst-prev-path cons-key tmp-alist)
     ;; insert block configuration (for architecture)
     (vhdl-insert-keyword "FOR ") (insert arch-name "\n")
@@ -16977,5 +16956,4 @@ to visually support naming conventions.")
 
 (provide 'vhdl-mode)
 
-;; arch-tag: 780d7073-9b5d-4c6c-b0d8-26b28783aba3
 ;;; vhdl-mode.el ends here