comparison lisp/progmodes/vhdl-mode.el @ 62917:e66c3159d2a4

(vhdl-fill-region): Test ARG, not INTERACTIVE. (vhdl-emacs-21): Doc fix. (vhdl-mode): Unconditionally set comment-padding. (vhdl-fixup-whitespace-region): Insert spaces only where there are none. (vhdl-statistics-buffer): Make the Emacs 21 behavior universal.
author Richard M. Stallman <rms@gnu.org>
date Tue, 31 May 2005 04:23:10 +0000
parents f2892faa87d4
children 252224857a7b 6aee1e9b0bd7 01137c1fdbe9
comparison
equal deleted inserted replaced
62916:f093607aa05a 62917:e66c3159d2a4
125 ;; XEmacs handling 125 ;; XEmacs handling
126 (defconst vhdl-xemacs (string-match "XEmacs" emacs-version) 126 (defconst vhdl-xemacs (string-match "XEmacs" emacs-version)
127 "Non-nil if XEmacs is used.") 127 "Non-nil if XEmacs is used.")
128 ;; Emacs 21 handling 128 ;; Emacs 21 handling
129 (defconst vhdl-emacs-21 (and (= emacs-major-version 21) (not vhdl-xemacs)) 129 (defconst vhdl-emacs-21 (and (= emacs-major-version 21) (not vhdl-xemacs))
130 "Non-nil if GNU Emacs 21 is used.") 130 "Non-nil if Emacs 21 is used.")
131 131
132 132
133 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 133 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
134 ;;; Variables 134 ;;; Variables
135 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 135 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4566 mode-require-final-newline) 4566 mode-require-final-newline)
4567 (set (make-local-variable 'parse-sexp-ignore-comments) t) 4567 (set (make-local-variable 'parse-sexp-ignore-comments) t)
4568 (set (make-local-variable 'indent-line-function) 'vhdl-indent-line) 4568 (set (make-local-variable 'indent-line-function) 'vhdl-indent-line)
4569 (set (make-local-variable 'comment-start) "--") 4569 (set (make-local-variable 'comment-start) "--")
4570 (set (make-local-variable 'comment-end) "") 4570 (set (make-local-variable 'comment-end) "")
4571 (when vhdl-emacs-21 4571 (set (make-local-variable 'comment-padding) "")
4572 (set (make-local-variable 'comment-padding) ""))
4573 (set (make-local-variable 'comment-column) vhdl-inline-comment-column) 4572 (set (make-local-variable 'comment-column) vhdl-inline-comment-column)
4574 (set (make-local-variable 'end-comment-column) vhdl-end-comment-column) 4573 (set (make-local-variable 'end-comment-column) vhdl-end-comment-column)
4575 (set (make-local-variable 'comment-start-skip) "--+\\s-*") 4574 (set (make-local-variable 'comment-start-skip) "--+\\s-*")
4576 (set (make-local-variable 'comment-multi-line) nil) 4575 (set (make-local-variable 'comment-multi-line) nil)
4577 (set (make-local-variable 'indent-tabs-mode) vhdl-indent-tabs-mode) 4576 (set (make-local-variable 'indent-tabs-mode) vhdl-indent-tabs-mode)
7482 ;; surround operator symbols by one space 7481 ;; surround operator symbols by one space
7483 (goto-char beg) 7482 (goto-char beg)
7484 (while (re-search-forward "\\(--.*\n\\|\"[^\"\n]*[\"\n]\\)\\|\\(\\([^/:<>=]\\)\\(:\\|=\\|<\\|>\\|:=\\|<=\\|>=\\|=>\\|/=\\)\\([^=>]\\|$\\)\\)" end t) 7483 (while (re-search-forward "\\(--.*\n\\|\"[^\"\n]*[\"\n]\\)\\|\\(\\([^/:<>=]\\)\\(:\\|=\\|<\\|>\\|:=\\|<=\\|>=\\|=>\\|/=\\)\\([^=>]\\|$\\)\\)" end t)
7485 (if (match-string 1) 7484 (if (match-string 1)
7486 (goto-char (match-end 1)) 7485 (goto-char (match-end 1))
7487 (replace-match "\\3 \\4 \\5") 7486 (save-excursion
7487 (goto-char (match-beginning 4))
7488 (unless (eq (preceding-char) ?\ )
7489 (insert " "))
7490 (goto-char (match-end 4))
7491 (unless (eq (following-char) ?\ )
7492 (insert " ")))
7488 (goto-char (match-end 4)))) 7493 (goto-char (match-end 4))))
7489 ;; eliminate multiple spaces and spaces at end of line 7494 ;; eliminate multiple spaces and spaces at end of line
7490 (goto-char beg) 7495 (goto-char beg)
7491 (while (or (and (looking-at "--.*\n") (re-search-forward "--.*\n" end t)) 7496 (while (or (and (looking-at "--.*\n") (re-search-forward "--.*\n" end t))
7492 (and (looking-at "\"") (re-search-forward "\"[^\"\n]*[\"\n]" end t)) 7497 (and (looking-at "\"") (re-search-forward "\"[^\"\n]*[\"\n]" end t))
7538 (defun vhdl-fill-region (beg end &optional arg) 7543 (defun vhdl-fill-region (beg end &optional arg)
7539 "Fill lines for a region of code." 7544 "Fill lines for a region of code."
7540 (interactive "r\np") 7545 (interactive "r\np")
7541 (save-excursion 7546 (save-excursion
7542 (goto-char beg) 7547 (goto-char beg)
7543 (let ((margin (if interactive (current-indentation) (current-column)))) 7548 (let ((margin (if arg (current-indentation) (current-column))))
7544 (goto-char end) 7549 (goto-char end)
7545 (setq end (point-marker)) 7550 (setq end (point-marker))
7546 ;; remove inline comments, newlines and whitespace 7551 ;; remove inline comments, newlines and whitespace
7547 (vhdl-comment-kill-region beg end) 7552 (vhdl-comment-kill-region beg end)
7548 (vhdl-comment-kill-inline-region beg end) 7553 (vhdl-comment-kill-inline-region beg end)
12053 File statistics: \"%s\"\n\ 12058 File statistics: \"%s\"\n\
12054 ---------------------\n\ 12059 ---------------------\n\
12055 # statements : %5d\n\ 12060 # statements : %5d\n\
12056 # code lines : %5d\n\ 12061 # code lines : %5d\n\
12057 # total lines : %5d\n\ " 12062 # total lines : %5d\n\ "
12058 (buffer-file-name) no-stats no-code-lines no-lines) 12063 (buffer-file-name) no-stats no-code-lines no-lines)))
12059 (unless vhdl-emacs-21 (vhdl-show-messages))))
12060 12064
12061 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 12065 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12062 ;; Help functions 12066 ;; Help functions
12063 12067
12064 (defun vhdl-re-search-forward (regexp &optional bound noerror count) 12068 (defun vhdl-re-search-forward (regexp &optional bound noerror count)