diff options
| author | Glenn Morris | 2002-08-21 21:26:07 +0000 |
|---|---|---|
| committer | Glenn Morris | 2002-08-21 21:26:07 +0000 |
| commit | 0ee7f06810f439b4f00a04d7826aced662956999 (patch) | |
| tree | 4d457c3df9161eaaa98991033870f8628620b41c | |
| parent | 3cdaec13e757965a1d67bb054737e3f0c1ff0e94 (diff) | |
| download | emacs-0ee7f06810f439b4f00a04d7826aced662956999.tar.gz emacs-0ee7f06810f439b4f00a04d7826aced662956999.zip | |
eval-when-compile a few defvars to quieten the byte-compiler.
(f90-xemacs-flag): Wrap in eval-and-compile.
(f90-font-lock-keywords): Doc fix.
(f90-mode-abbrev-table): Use the 6th (system-flag) argument of
define-abbrev if available, but work without it as well.
(f90-mark-subprogram-overlay): Variable deleted.
(f90-mark-subprogram): No need to be silent about push-mark.
Get rid of the silly overlay bit.
(f90-abbrev-start): unread-command-event is obsolete in XEmacs too.
| -rw-r--r-- | lisp/progmodes/f90.el | 192 |
1 files changed, 97 insertions, 95 deletions
diff --git a/lisp/progmodes/f90.el b/lisp/progmodes/f90.el index 14386b065fb..7e898b50fd1 100644 --- a/lisp/progmodes/f90.el +++ b/lisp/progmodes/f90.el | |||
| @@ -156,6 +156,19 @@ | |||
| 156 | 156 | ||
| 157 | ;;; Code: | 157 | ;;; Code: |
| 158 | 158 | ||
| 159 | (eval-and-compile | ||
| 160 | (defconst f90-xemacs-flag (string-match "XEmacs\\|Lucid" emacs-version) | ||
| 161 | "Non-nil means F90 mode thinks it is running under XEmacs.")) | ||
| 162 | |||
| 163 | ;; Most of these are just to quieten the byte-compiler. | ||
| 164 | (eval-when-compile | ||
| 165 | (defvar comment-auto-fill-only-comments) | ||
| 166 | (defvar font-lock-keywords) | ||
| 167 | (unless f90-xemacs-flag | ||
| 168 | ;; If you have GNU Emacs 19.22 or earlier, comment this out, or get imenu. | ||
| 169 | (require 'imenu) | ||
| 170 | (defvar current-menubar))) | ||
| 171 | |||
| 159 | ;; User options | 172 | ;; User options |
| 160 | 173 | ||
| 161 | (defgroup f90 nil | 174 | (defgroup f90 nil |
| @@ -242,8 +255,13 @@ The options are 'downcase-word, 'upcase-word, 'capitalize-word and nil." | |||
| 242 | :type 'boolean | 255 | :type 'boolean |
| 243 | :group 'f90) | 256 | :group 'f90) |
| 244 | 257 | ||
| 245 | (defconst f90-xemacs-flag (string-match "XEmacs\\|Lucid" emacs-version) | 258 | (defcustom f90-mode-hook nil |
| 246 | "Non-nil means F90 mode thinks it is running under XEmacs.") | 259 | "Hook run when entering F90 mode." |
| 260 | :type 'hook | ||
| 261 | :options '(f90-add-imenu-menu) | ||
| 262 | :group 'f90) | ||
| 263 | |||
| 264 | ;; User options end here. | ||
| 247 | 265 | ||
| 248 | (defconst f90-keywords-re | 266 | (defconst f90-keywords-re |
| 249 | (regexp-opt '("allocatable" "allocate" "assign" "assignment" "backspace" | 267 | (regexp-opt '("allocatable" "allocate" "assign" "assignment" "backspace" |
| @@ -398,7 +416,8 @@ do\\([ \t]*while\\)?\\|select[ \t]*case\\|where\\|forall\\)\\)\\>" | |||
| 398 | 416 | ||
| 399 | (defvar f90-font-lock-keywords | 417 | (defvar f90-font-lock-keywords |
| 400 | f90-font-lock-keywords-2 | 418 | f90-font-lock-keywords-2 |
| 401 | "*Default expressions to highlight in F90 mode.") | 419 | "*Default expressions to highlight in F90 mode. |
| 420 | Can be overridden by the value of `font-lock-maximum-decoration'.") | ||
| 402 | 421 | ||
| 403 | 422 | ||
| 404 | (defvar f90-mode-syntax-table | 423 | (defvar f90-mode-syntax-table |
| @@ -686,77 +705,77 @@ do\\([ \t]*while\\)?\\|select[ \t]*case\\|where\\|forall\\)\\)\\>" | |||
| 686 | 705 | ||
| 687 | (put 'f90-add-imenu-menu 'menu-enable '(not f90-imenu-flag)) | 706 | (put 'f90-add-imenu-menu 'menu-enable '(not f90-imenu-flag)) |
| 688 | 707 | ||
| 689 | |||
| 690 | ;; When compiling under GNU Emacs, load imenu during compilation. | ||
| 691 | ;; If you have 19.22 or earlier, comment this out, or get imenu. | ||
| 692 | (or f90-xemacs-flag (eval-when-compile (require 'imenu))) | ||
| 693 | |||
| 694 | 708 | ||
| 695 | ;; Abbrevs have generally two letters, except standard types `c, `i, `r, `t. | 709 | ;; Abbrevs have generally two letters, except standard types `c, `i, `r, `t. |
| 696 | (defvar f90-mode-abbrev-table | 710 | (defvar f90-mode-abbrev-table |
| 697 | (let (abbrevs-changed) | 711 | (let (abbrevs-changed) |
| 698 | (define-abbrev-table 'f90-mode-abbrev-table | 712 | (define-abbrev-table 'f90-mode-abbrev-table nil) |
| 699 | '(("`al" "allocate" nil 0 t) | 713 | ;; Use the 6th arg (SYSTEM-FLAG) of define-abbrev if possible. |
| 700 | ("`ab" "allocatable" nil 0 t) | 714 | ;; A little baroque to quieten the byte-compiler. |
| 701 | ("`as" "assignment" nil 0 t) | 715 | (mapcar |
| 702 | ("`ba" "backspace" nil 0 t) | 716 | (function (lambda (element) |
| 703 | ("`bd" "block data" nil 0 t) | 717 | (condition-case nil |
| 704 | ("`c" "character" nil 0 t) | 718 | (apply 'define-abbrev f90-mode-abbrev-table |
| 705 | ("`cl" "close" nil 0 t) | 719 | (append element '(nil 0 t))) |
| 706 | ("`cm" "common" nil 0 t) | 720 | (wrong-number-of-arguments |
| 707 | ("`cx" "complex" nil 0 t) | 721 | (apply 'define-abbrev f90-mode-abbrev-table |
| 708 | ("`cn" "contains" nil 0 t) | 722 | (append element '(nil 0))))))) |
| 709 | ("`cy" "cycle" nil 0 t) | 723 | '(("`al" "allocate" ) |
| 710 | ("`de" "deallocate" nil 0 t) | 724 | ("`ab" "allocatable" ) |
| 711 | ("`df" "define" nil 0 t) | 725 | ("`as" "assignment" ) |
| 712 | ("`di" "dimension" nil 0 t) | 726 | ("`ba" "backspace" ) |
| 713 | ("`dw" "do while" nil 0 t) | 727 | ("`bd" "block data" ) |
| 714 | ("`el" "else" nil 0 t) | 728 | ("`c" "character" ) |
| 715 | ("`eli" "else if" nil 0 t) | 729 | ("`cl" "close" ) |
| 716 | ("`elw" "elsewhere" nil 0 t) | 730 | ("`cm" "common" ) |
| 717 | ("`eq" "equivalence" nil 0 t) | 731 | ("`cx" "complex" ) |
| 718 | ("`ex" "external" nil 0 t) | 732 | ("`cn" "contains" ) |
| 719 | ("`ey" "entry" nil 0 t) | 733 | ("`cy" "cycle" ) |
| 720 | ("`fl" "forall" nil 0 t) | 734 | ("`de" "deallocate" ) |
| 721 | ("`fo" "format" nil 0 t) | 735 | ("`df" "define" ) |
| 722 | ("`fu" "function" nil 0 t) | 736 | ("`di" "dimension" ) |
| 723 | ("`fa" ".false." nil 0 t) | 737 | ("`dw" "do while" ) |
| 724 | ("`im" "implicit none" nil 0 t) | 738 | ("`el" "else" ) |
| 725 | ("`in " "include" nil 0 t) | 739 | ("`eli" "else if" ) |
| 726 | ("`i" "integer" nil 0 t) | 740 | ("`elw" "elsewhere" ) |
| 727 | ("`it" "intent" nil 0 t) | 741 | ("`eq" "equivalence" ) |
| 728 | ("`if" "interface" nil 0 t) | 742 | ("`ex" "external" ) |
| 729 | ("`lo" "logical" nil 0 t) | 743 | ("`ey" "entry" ) |
| 730 | ("`mo" "module" nil 0 t) | 744 | ("`fl" "forall" ) |
| 731 | ("`na" "namelist" nil 0 t) | 745 | ("`fo" "format" ) |
| 732 | ("`nu" "nullify" nil 0 t) | 746 | ("`fu" "function" ) |
| 733 | ("`op" "optional" nil 0 t) | 747 | ("`fa" ".false." ) |
| 734 | ("`pa" "parameter" nil 0 t) | 748 | ("`im" "implicit none") |
| 735 | ("`po" "pointer" nil 0 t) | 749 | ("`in" "include" ) |
| 736 | ("`pr" "print" nil 0 t) | 750 | ("`i" "integer" ) |
| 737 | ("`pi" "private" nil 0 t) | 751 | ("`it" "intent" ) |
| 738 | ("`pm" "program" nil 0 t) | 752 | ("`if" "interface" ) |
| 739 | ("`pu" "public" nil 0 t) | 753 | ("`lo" "logical" ) |
| 740 | ("`r" "real" nil 0 t) | 754 | ("`mo" "module" ) |
| 741 | ("`rc" "recursive" nil 0 t) | 755 | ("`na" "namelist" ) |
| 742 | ("`rt" "return" nil 0 t) | 756 | ("`nu" "nullify" ) |
| 743 | ("`rw" "rewind" nil 0 t) | 757 | ("`op" "optional" ) |
| 744 | ("`se" "select" nil 0 t) | 758 | ("`pa" "parameter" ) |
| 745 | ("`sq" "sequence" nil 0 t) | 759 | ("`po" "pointer" ) |
| 746 | ("`su" "subroutine" nil 0 t) | 760 | ("`pr" "print" ) |
| 747 | ("`ta" "target" nil 0 t) | 761 | ("`pi" "private" ) |
| 748 | ("`tr" ".true." nil 0 t) | 762 | ("`pm" "program" ) |
| 749 | ("`t" "type" nil 0 t) | 763 | ("`pu" "public" ) |
| 750 | ("`wh" "where" nil 0 t) | 764 | ("`r" "real" ) |
| 751 | ("`wr" "write" nil 0 t))) | 765 | ("`rc" "recursive" ) |
| 766 | ("`rt" "return" ) | ||
| 767 | ("`rw" "rewind" ) | ||
| 768 | ("`se" "select" ) | ||
| 769 | ("`sq" "sequence" ) | ||
| 770 | ("`su" "subroutine" ) | ||
| 771 | ("`ta" "target" ) | ||
| 772 | ("`tr" ".true." ) | ||
| 773 | ("`t" "type" ) | ||
| 774 | ("`wh" "where" ) | ||
| 775 | ("`wr" "write" ))) | ||
| 752 | f90-mode-abbrev-table) | 776 | f90-mode-abbrev-table) |
| 753 | "Abbrev table for F90 mode.") | 777 | "Abbrev table for F90 mode.") |
| 754 | 778 | ||
| 755 | (defcustom f90-mode-hook nil | ||
| 756 | "Hook run when entering F90 mode." | ||
| 757 | :type 'hook | ||
| 758 | :options '(f90-add-imenu-menu) | ||
| 759 | :group 'f90) | ||
| 760 | 779 | ||
| 761 | ;;;###autoload | 780 | ;;;###autoload |
| 762 | (defun f90-mode () | 781 | (defun f90-mode () |
| @@ -1369,32 +1388,18 @@ A block is a subroutine, if-endif, etc." | |||
| 1369 | (f90-next-block (- (or num 1)))) | 1388 | (f90-next-block (- (or num 1)))) |
| 1370 | 1389 | ||
| 1371 | 1390 | ||
| 1372 | (defvar f90-mark-subprogram-overlay nil | ||
| 1373 | "Used internally by `f90-mark-subprogram' to highlight the subprogram.") | ||
| 1374 | (make-variable-buffer-local 'f90-mark-subprogram-overlay) | ||
| 1375 | |||
| 1376 | (defun f90-mark-subprogram () | 1391 | (defun f90-mark-subprogram () |
| 1377 | "Put mark at end of F90 subprogram, point at beginning, push marks. | 1392 | "Put mark at end of F90 subprogram, point at beginning, push marks." |
| 1378 | If called interactively, highlight the subprogram with the face `highlight'. | ||
| 1379 | Call again to remove the highlighting." | ||
| 1380 | (interactive) | 1393 | (interactive) |
| 1381 | (let ((pos (point)) program) | 1394 | (let ((pos (point)) program) |
| 1382 | (f90-end-of-subprogram) | 1395 | (f90-end-of-subprogram) |
| 1383 | (push-mark (point) t) | 1396 | (push-mark) |
| 1384 | (goto-char pos) | 1397 | (goto-char pos) |
| 1385 | (setq program (f90-beginning-of-subprogram)) | 1398 | (setq program (f90-beginning-of-subprogram)) |
| 1386 | ;; The keywords in the preceding lists assume case-insensitivity. | ||
| 1387 | (if f90-xemacs-flag | 1399 | (if f90-xemacs-flag |
| 1388 | (zmacs-activate-region) | 1400 | (zmacs-activate-region) |
| 1389 | (setq mark-active t | 1401 | (setq mark-active t |
| 1390 | deactivate-mark nil) | 1402 | deactivate-mark nil)) |
| 1391 | (if (interactive-p) | ||
| 1392 | (if (overlayp f90-mark-subprogram-overlay) | ||
| 1393 | (if (overlay-buffer f90-mark-subprogram-overlay) | ||
| 1394 | (delete-overlay f90-mark-subprogram-overlay) | ||
| 1395 | (move-overlay f90-mark-subprogram-overlay (point) (mark))) | ||
| 1396 | (setq f90-mark-subprogram-overlay (make-overlay (point) (mark))) | ||
| 1397 | (overlay-put f90-mark-subprogram-overlay 'face 'highlight)))) | ||
| 1398 | program)) | 1403 | program)) |
| 1399 | 1404 | ||
| 1400 | (defun f90-comment-region (beg-region end-region) | 1405 | (defun f90-comment-region (beg-region end-region) |
| @@ -1570,7 +1575,7 @@ If run in the middle of a line, the line is not broken." | |||
| 1570 | (set-marker end-region-mark nil) | 1575 | (set-marker end-region-mark nil) |
| 1571 | (set-marker save-point nil) | 1576 | (set-marker save-point nil) |
| 1572 | (if f90-xemacs-flag | 1577 | (if f90-xemacs-flag |
| 1573 | (zmacs-deactivate-region) | 1578 | (zmacs-deactivate-region) |
| 1574 | (deactivate-mark)))) | 1579 | (deactivate-mark)))) |
| 1575 | 1580 | ||
| 1576 | (defun f90-indent-subprogram () | 1581 | (defun f90-indent-subprogram () |
| @@ -1681,7 +1686,7 @@ Update keyword case first." | |||
| 1681 | f90-cache-position (point))) | 1686 | f90-cache-position (point))) |
| 1682 | (setq f90-cache-position nil) | 1687 | (setq f90-cache-position nil) |
| 1683 | (if f90-xemacs-flag | 1688 | (if f90-xemacs-flag |
| 1684 | (zmacs-deactivate-region) | 1689 | (zmacs-deactivate-region) |
| 1685 | (deactivate-mark)))) | 1690 | (deactivate-mark)))) |
| 1686 | 1691 | ||
| 1687 | (defun f90-block-match (beg-block beg-name end-block end-name) | 1692 | (defun f90-block-match (beg-block beg-name end-block end-name) |
| @@ -1774,18 +1779,15 @@ Leave point at the end of line." | |||
| 1774 | "Typing `\\[help-command] or `? lists all the F90 abbrevs. | 1779 | "Typing `\\[help-command] or `? lists all the F90 abbrevs. |
| 1775 | Any other key combination is executed normally." | 1780 | Any other key combination is executed normally." |
| 1776 | (interactive) | 1781 | (interactive) |
| 1777 | (let (e c) | 1782 | (let (c) |
| 1778 | (insert last-command-char) | 1783 | (insert last-command-char) |
| 1779 | (if (not f90-xemacs-flag) | 1784 | (if f90-xemacs-flag |
| 1780 | (setq c (read-event)) | 1785 | (setq c (event-to-character (next-command-event))) |
| 1781 | (setq e (next-command-event) | 1786 | (setq c (read-event))) |
| 1782 | c (event-to-character e))) | ||
| 1783 | ;; Insert char if not equal to `?'. | 1787 | ;; Insert char if not equal to `?'. |
| 1784 | (if (or (eq c ??) (eq c help-char)) | 1788 | (if (or (eq c ??) (eq c help-char)) |
| 1785 | (f90-abbrev-help) | 1789 | (f90-abbrev-help) |
| 1786 | (if f90-xemacs-flag | 1790 | (setq unread-command-events (list c))))) |
| 1787 | (setq unread-command-event e) | ||
| 1788 | (setq unread-command-events (list c)))))) | ||
| 1789 | 1791 | ||
| 1790 | (defun f90-abbrev-help () | 1792 | (defun f90-abbrev-help () |
| 1791 | "List the currently defined abbrevs in F90 mode." | 1793 | "List the currently defined abbrevs in F90 mode." |