]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/vhdl-mode.el
Merge changes from emacs-23 branch.
[gnu-emacs] / lisp / progmodes / vhdl-mode.el
index a7f033c7045dc4895532a1dc4cdfc4080189122e..4ff9cf92b8d3252a823888e02ed839604f9b7997 100644 (file)
@@ -1,7 +1,7 @@
 ;;; 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
+;;   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Authors:     Reto Zimmermann <reto@gnu.org>
@@ -199,21 +199,6 @@ Examples:
   "Customizations for modes."
   :group 'vhdl)
 
-(defcustom vhdl-electric-mode t
-  "*Non-nil enables electrification (automatic template generation).
-If nil, template generators can still be invoked through key bindings and
-menu.  Is indicated in the modeline by \"/e\" after the mode name and can be
-toggled by `\\[vhdl-electric-mode]'."
-  :type 'boolean
-  :group 'vhdl-mode)
-
-(defcustom vhdl-stutter-mode t
-  "*Non-nil enables stuttering.
-Is indicated in the modeline by \"/s\" after the mode name and can be toggled
-by `\\[vhdl-stutter-mode]'."
-  :type 'boolean
-  :group 'vhdl-mode)
-
 (defcustom vhdl-indent-tabs-mode nil
   "*Non-nil means indentation can insert tabs.
 Overrides local variable `indent-tabs-mode'."
@@ -3466,13 +3451,11 @@ STRING are replaced by `-' and substrings are converted to lower case."
      ("Mode"
       ["Electric Mode"
        (progn (customize-set-variable 'vhdl-electric-mode
-                                     (not vhdl-electric-mode))
-             (vhdl-mode-line-update))
+                                     (not vhdl-electric-mode)))
        :style toggle :selected vhdl-electric-mode :keys "C-c C-m C-e"]
       ["Stutter Mode"
        (progn (customize-set-variable 'vhdl-stutter-mode
-                                     (not vhdl-stutter-mode))
-             (vhdl-mode-line-update))
+                                     (not vhdl-stutter-mode)))
        :style toggle :selected vhdl-stutter-mode :keys "C-c C-m C-s"]
       ["Indent Tabs Mode"
        (progn (customize-set-variable 'vhdl-indent-tabs-mode
@@ -4670,7 +4653,10 @@ Key bindings:
   (interactive)
   (kill-all-local-variables)
   (setq major-mode 'vhdl-mode)
-  (setq mode-name "VHDL")
+  (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)
@@ -4737,7 +4723,6 @@ Key bindings:
   ;; miscellaneous
   (vhdl-ps-print-init)
   (vhdl-write-file-hooks-init)
-  (vhdl-mode-line-update)
   (message "VHDL Mode %s.%s" vhdl-version
           (if noninteractive "" "  See menu for documentation and release notes."))
 
@@ -4757,8 +4742,7 @@ Key bindings:
   (vhdl-write-file-hooks-init)
   (vhdl-update-mode-menu)
   (vhdl-hideshow-init)
-  (run-hooks 'menu-bar-update-hook)
-  (vhdl-mode-line-update))
+  (run-hooks 'menu-bar-update-hook))
 
 (defun vhdl-write-file-hooks-init ()
   "Add/remove hooks when buffer is saved."
@@ -8010,7 +7994,7 @@ buffer."
                       (condition-case () (forward-sexp)
                         (error (goto-char (point-max))))
                       (< (point) end))
-          (delete-backward-char 1))
+          (delete-char -1))
         ;; add closing parenthesis
         (when (> (point) end)
           (goto-char end)
@@ -8055,31 +8039,15 @@ project is defined."
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;  Enabling/disabling
 
-(defun vhdl-mode-line-update ()
-  "Update the modeline string for VHDL major mode."
-  (setq mode-name (concat "VHDL"
-                         (and (or vhdl-electric-mode vhdl-stutter-mode) "/")
-                         (and vhdl-electric-mode "e")
-                         (and vhdl-stutter-mode "s")))
-  (force-mode-line-update t))
-
-(defun vhdl-electric-mode (arg)
+(define-minor-mode vhdl-electric-mode
   "Toggle VHDL electric mode.
 Turn on if ARG positive, turn off if ARG negative, toggle if ARG zero or nil."
-  (interactive "P")
-  (setq vhdl-electric-mode
-       (cond ((or (not arg) (zerop arg)) (not vhdl-electric-mode))
-             ((> arg 0) t) (t nil)))
-  (vhdl-mode-line-update))
+  :global t)
 
-(defun vhdl-stutter-mode (arg)
+(define-minor-mode vhdl-stutter-mode
   "Toggle VHDL stuttering mode.
 Turn on if ARG positive, turn off if ARG negative, toggle if ARG zero or nil."
-  (interactive "P")
-  (setq vhdl-stutter-mode
-       (cond ((or (not arg) (zerop arg)) (not vhdl-stutter-mode))
-             ((> arg 0) t) (t nil)))
-  (vhdl-mode-line-update))
+  :global t)
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Stuttering
@@ -8137,7 +8105,7 @@ Turn on if ARG positive, turn off if ARG negative, toggle if ARG zero or nil."
   (interactive "p")
   (if (and vhdl-stutter-mode (= count 1) (not (vhdl-in-literal)))
       (if (= (preceding-char) last-input-event)
-         (progn (delete-backward-char 1) (insert-char ?\" 1))
+         (progn (delete-char -1) (insert-char ?\" 1))
        (insert-char ?\' 1))
     (self-insert-command count)))
 
@@ -8204,7 +8172,7 @@ Turn on if ARG positive, turn off if ARG negative, toggle if ARG zero or nil."
       (unless (vhdl-template-field
               (concat "[type" (and (vhdl-standard-p 'ams) " or nature") "]")
               nil t)
-       (delete-backward-char 3))
+       (delete-char -3))
       (vhdl-insert-keyword " IS ")
       (vhdl-template-field "name" ";")
       (vhdl-comment-insert-inline))))
@@ -8568,7 +8536,7 @@ a configuration declaration if not within a design unit."
               (vhdl-template-field "library name" "." nil nil nil nil
                                    (vhdl-work-library))
               (vhdl-template-field "configuration name" ";"))
-             (t (delete-backward-char 1) (insert ";") t))))))
+             (t (delete-char -1) (insert ";") t))))))
 
 
 (defun vhdl-template-configuration-decl ()
@@ -8735,7 +8703,7 @@ a configuration declaration if not within a design unit."
        (vhdl-insert-keyword " OPEN ")
        (unless (vhdl-template-field "[READ_MODE | WRITE_MODE | APPEND_MODE]"
                                     nil t)
-         (delete-backward-char 6)))
+         (delete-char -6)))
       (vhdl-insert-keyword " IS ")
       (when (vhdl-standard-p '87)
        (vhdl-template-field "[IN | OUT]" " " t))
@@ -9063,7 +9031,7 @@ otherwise."
              (insert "\n")
              (indent-to margin))
            (delete-region end-pos (point))
-           (delete-backward-char 1)
+           (delete-char -1)
            (insert ")")
            (when vhdl-auto-align (vhdl-align-region-groups start (point) 1))
            t)
@@ -9437,7 +9405,7 @@ otherwise."
     (vhdl-insert-keyword "REPORT ")
     (if (equal "\"\"" (vhdl-template-field
                       "string expression" nil t start (point) t))
-       (delete-backward-char 2)
+       (delete-char -2)
       (setq start (point))
       (vhdl-insert-keyword " SEVERITY ")
       (unless (vhdl-template-field "[NOTE | WARNING | ERROR | FAILURE]" nil t)
@@ -9585,7 +9553,7 @@ otherwise."
                    "[scalar type | ARRAY | RECORD | ACCESS | FILE]" nil t)
                   ""))))
        (cond ((equal definition "")
-              (delete-backward-char 4)
+              (delete-char -4)
               (insert ";"))
              ((equal definition "ARRAY")
               (delete-region (point) (progn (forward-word -1) (point)))
@@ -10085,13 +10053,13 @@ If starting after end-comment-column, start a new line."
       (if (not (or (and string (progn (insert string) t))
                   (vhdl-template-field "[comment]" nil t)))
          (delete-region position (point))
-       (while (= (preceding-char) ? ) (delete-backward-char 1))
-;      (when (> (current-column) end-comment-column)
-;        (setq position (point-marker))
-;        (re-search-backward "-- ")
-;        (insert "\n")
-;        (indent-to comment-column)
-;        (goto-char position))
+       (while (= (preceding-char) ?\ ) (delete-char -1))
+       ;; (when (> (current-column) end-comment-column)
+       ;;   (setq position (point-marker))
+       ;;   (re-search-backward "-- ")
+       ;;   (insert "\n")
+       ;;   (indent-to comment-column)
+       ;;   (goto-char position))
        ))))
 
 (defun vhdl-comment-block ()
@@ -10224,7 +10192,7 @@ Point is left between them."
     (when semicolon-pos (goto-char semicolon-pos))
     (if not-empty
        (progn (delete-char 1) (insert ")"))
-      (delete-backward-char 2))))
+      (delete-char -2))))
 
 (defun vhdl-template-generic-list (optional &optional no-value)
   "Read from user a generic spec argument list."
@@ -12533,7 +12501,7 @@ File statistics: \"%s\"\n\
        (add-hook 'hs-minor-mode-hook 'hs-hide-all)
       (remove-hook 'hs-minor-mode-hook 'hs-hide-all))
     (hs-minor-mode arg)
-    (vhdl-mode-line-update)))          ; hack to update menu bar
+    (force-mode-line-update)))         ; hack to update menu bar
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -15152,7 +15120,8 @@ is already shown in a buffer."
     (let ((buffer (get-file-buffer (car token))))
       (speedbar-find-file-in-frame (car token))
       (when (or vhdl-speedbar-jump-to-unit buffer)
-       (goto-line (cdr token))
+       (goto-char (point-min))
+       (forward-line (1- (cdr token)))
        (recenter))
       (vhdl-speedbar-update-current-unit t t)
       (speedbar-set-timer dframe-update-speed)
@@ -15170,7 +15139,8 @@ is already shown in a buffer."
              (let ((token (get-text-property
                            (match-beginning 3) 'speedbar-token)))
                (vhdl-visit-file (car token) t
-                                (progn (goto-line (cdr token))
+                                (progn (goto-char (point-min))
+                                       (forward-line (1- (cdr token)))
                                        (end-of-line)
                                        (if is-entity
                                            (vhdl-port-copy)
@@ -15919,7 +15889,8 @@ current project/directory."
     ;; insert component declarations
     (while ent-alist
       (vhdl-visit-file (nth 2 (car ent-alist)) nil
-                      (progn (goto-line (nth 3 (car ent-alist)))
+                      (progn (goto-char (point-min))
+                             (forward-line (1- (nth 3 (car ent-alist))))
                              (end-of-line)
                              (vhdl-port-copy)))
       (goto-char component-pos)