diff options
| author | Glenn Morris | 2008-03-13 03:29:35 +0000 |
|---|---|---|
| committer | Glenn Morris | 2008-03-13 03:29:35 +0000 |
| commit | 599aeab922040ecf94b829fae73fa66a3a04fbea (patch) | |
| tree | 270532a5616a1faeb0e8661ab3e7193b1dc1dc1d | |
| parent | 34d11b923ee5609e37bbcd56999e7f3638b62a12 (diff) | |
| download | emacs-599aeab922040ecf94b829fae73fa66a3a04fbea.tar.gz emacs-599aeab922040ecf94b829fae73fa66a3a04fbea.zip | |
(f90-font-lock-n): New function.
(f90-font-lock-1, f90-font-lock-2, f90-font-lock-3, f90-font-lock-4):
Use f90-font-lock-n.
(f90-mode-abbrev-table): Use newer form of define-abbrev, where
supported. No need to bind abbrevs-changed for system abbrevs.
(f90-indent-region, f90-indent-subprogram, f90-match-end): Use cadr.
| -rw-r--r-- | lisp/progmodes/f90.el | 181 |
1 files changed, 87 insertions, 94 deletions
diff --git a/lisp/progmodes/f90.el b/lisp/progmodes/f90.el index 2c152d91512..7b2d78ca2ff 100644 --- a/lisp/progmodes/f90.el +++ b/lisp/progmodes/f90.el | |||
| @@ -604,8 +604,7 @@ logical\\|double[ \t]*precision\\|type[ \t]*(\\sw+)\\|none\\)[ \t]*" | |||
| 604 | (list f90-procedures-re '(1 font-lock-keyword-face keep)) | 604 | (list f90-procedures-re '(1 font-lock-keyword-face keep)) |
| 605 | "\\<real\\>" ; avoid overwriting real defs | 605 | "\\<real\\>" ; avoid overwriting real defs |
| 606 | ;; As an attribute, but not as an optional argument. | 606 | ;; As an attribute, but not as an optional argument. |
| 607 | '("\\<\\(asynchronous\\)[ \t]*[^=]" . 1) | 607 | '("\\<\\(asynchronous\\)[ \t]*[^=]" . 1))) |
| 608 | )) | ||
| 609 | "Highlights all F90 keywords and intrinsic procedures.") | 608 | "Highlights all F90 keywords and intrinsic procedures.") |
| 610 | 609 | ||
| 611 | (defvar f90-font-lock-keywords-4 | 610 | (defvar f90-font-lock-keywords-4 |
| @@ -726,34 +725,32 @@ Can be overridden by the value of `font-lock-maximum-decoration'.") | |||
| 726 | "Keymap used in F90 mode.") | 725 | "Keymap used in F90 mode.") |
| 727 | 726 | ||
| 728 | 727 | ||
| 728 | (defun f90-font-lock-n (n) | ||
| 729 | "Set `font-lock-keywords' to F90 level N keywords." | ||
| 730 | (font-lock-mode 1) | ||
| 731 | (setq font-lock-keywords | ||
| 732 | (symbol-value (intern-soft (format "f90-font-lock-keywords-%d" n)))) | ||
| 733 | (font-lock-fontify-buffer)) | ||
| 734 | |||
| 729 | (defun f90-font-lock-1 () | 735 | (defun f90-font-lock-1 () |
| 730 | "Set `font-lock-keywords' to `f90-font-lock-keywords-1'." | 736 | "Set `font-lock-keywords' to `f90-font-lock-keywords-1'." |
| 731 | (interactive) | 737 | (interactive) |
| 732 | (font-lock-mode 1) | 738 | (f90-font-lock-n 1)) |
| 733 | (setq font-lock-keywords f90-font-lock-keywords-1) | ||
| 734 | (font-lock-fontify-buffer)) | ||
| 735 | 739 | ||
| 736 | (defun f90-font-lock-2 () | 740 | (defun f90-font-lock-2 () |
| 737 | "Set `font-lock-keywords' to `f90-font-lock-keywords-2'." | 741 | "Set `font-lock-keywords' to `f90-font-lock-keywords-2'." |
| 738 | (interactive) | 742 | (interactive) |
| 739 | (font-lock-mode 1) | 743 | (f90-font-lock-n 2)) |
| 740 | (setq font-lock-keywords f90-font-lock-keywords-2) | ||
| 741 | (font-lock-fontify-buffer)) | ||
| 742 | 744 | ||
| 743 | (defun f90-font-lock-3 () | 745 | (defun f90-font-lock-3 () |
| 744 | "Set `font-lock-keywords' to `f90-font-lock-keywords-3'." | 746 | "Set `font-lock-keywords' to `f90-font-lock-keywords-3'." |
| 745 | (interactive) | 747 | (interactive) |
| 746 | (font-lock-mode 1) | 748 | (f90-font-lock-n 3)) |
| 747 | (setq font-lock-keywords f90-font-lock-keywords-3) | ||
| 748 | (font-lock-fontify-buffer)) | ||
| 749 | 749 | ||
| 750 | (defun f90-font-lock-4 () | 750 | (defun f90-font-lock-4 () |
| 751 | "Set `font-lock-keywords' to `f90-font-lock-keywords-4'." | 751 | "Set `font-lock-keywords' to `f90-font-lock-keywords-4'." |
| 752 | (interactive) | 752 | (interactive) |
| 753 | (font-lock-mode 1) | 753 | (f90-font-lock-n 4)) |
| 754 | (setq font-lock-keywords f90-font-lock-keywords-4) | ||
| 755 | (font-lock-fontify-buffer)) | ||
| 756 | |||
| 757 | 754 | ||
| 758 | ;; Regexps for finding program structures. | 755 | ;; Regexps for finding program structures. |
| 759 | (defconst f90-blocks-re | 756 | (defconst f90-blocks-re |
| @@ -931,77 +928,74 @@ Set subexpression 1 in the match-data to the name of the type." | |||
| 931 | f90-mode-abbrev-table) | 928 | f90-mode-abbrev-table) |
| 932 | "Abbrev table for F90 mode.") | 929 | "Abbrev table for F90 mode.") |
| 933 | 930 | ||
| 934 | (let (abbrevs-changed) | 931 | ;; Not in defvar because user abbrevs may be restored before this file loads. |
| 935 | ;; Use the 6th arg (SYSTEM-FLAG) of define-abbrev if possible. | 932 | (mapc |
| 936 | ;; A little baroque to quieten the byte-compiler. | 933 | (lambda (e) |
| 937 | (mapc | 934 | (condition-case nil |
| 938 | (function (lambda (element) | 935 | (define-abbrev f90-mode-abbrev-table (car e) (cdr e) nil :count 0 |
| 939 | (condition-case nil | 936 | :system t) |
| 940 | (apply 'define-abbrev f90-mode-abbrev-table | 937 | (wrong-number-of-arguments ; Emacs 22 |
| 941 | (append element '(nil 0 t))) | 938 | (define-abbrev f90-mode-abbrev-table (car e) (cdr e) nil 0 t)))) |
| 942 | (wrong-number-of-arguments | 939 | '(("`al" . "allocate" ) |
| 943 | (apply 'define-abbrev f90-mode-abbrev-table | 940 | ("`ab" . "allocatable" ) |
| 944 | (append element '(nil 0))))))) | 941 | ("`ai" . "abstract interface") |
| 945 | '(("`al" "allocate" ) | 942 | ("`as" . "assignment" ) |
| 946 | ("`ab" "allocatable" ) | 943 | ("`asy" . "asynchronous" ) |
| 947 | ("`ai" "abstract interface") | 944 | ("`ba" . "backspace" ) |
| 948 | ("`as" "assignment" ) | 945 | ("`bd" . "block data" ) |
| 949 | ("`asy" "asynchronous" ) | 946 | ("`c" . "character" ) |
| 950 | ("`ba" "backspace" ) | 947 | ("`cl" . "close" ) |
| 951 | ("`bd" "block data" ) | 948 | ("`cm" . "common" ) |
| 952 | ("`c" "character" ) | 949 | ("`cx" . "complex" ) |
| 953 | ("`cl" "close" ) | 950 | ("`cn" . "contains" ) |
| 954 | ("`cm" "common" ) | 951 | ("`cy" . "cycle" ) |
| 955 | ("`cx" "complex" ) | 952 | ("`de" . "deallocate" ) |
| 956 | ("`cn" "contains" ) | 953 | ("`df" . "define" ) |
| 957 | ("`cy" "cycle" ) | 954 | ("`di" . "dimension" ) |
| 958 | ("`de" "deallocate" ) | 955 | ("`dp" . "double precision") |
| 959 | ("`df" "define" ) | 956 | ("`dw" . "do while" ) |
| 960 | ("`di" "dimension" ) | 957 | ("`el" . "else" ) |
| 961 | ("`dp" "double precision") | 958 | ("`eli" . "else if" ) |
| 962 | ("`dw" "do while" ) | 959 | ("`elw" . "elsewhere" ) |
| 963 | ("`el" "else" ) | 960 | ("`em" . "elemental" ) |
| 964 | ("`eli" "else if" ) | 961 | ("`e" . "enumerator" ) |
| 965 | ("`elw" "elsewhere" ) | 962 | ("`eq" . "equivalence" ) |
| 966 | ("`em" "elemental" ) | 963 | ("`ex" . "external" ) |
| 967 | ("`e" "enumerator" ) | 964 | ("`ey" . "entry" ) |
| 968 | ("`eq" "equivalence" ) | 965 | ("`fl" . "forall" ) |
| 969 | ("`ex" "external" ) | 966 | ("`fo" . "format" ) |
| 970 | ("`ey" "entry" ) | 967 | ("`fu" . "function" ) |
| 971 | ("`fl" "forall" ) | 968 | ("`fa" . ".false." ) |
| 972 | ("`fo" "format" ) | 969 | ("`im" . "implicit none") |
| 973 | ("`fu" "function" ) | 970 | ("`in" . "include" ) |
| 974 | ("`fa" ".false." ) | 971 | ("`i" . "integer" ) |
| 975 | ("`im" "implicit none") | 972 | ("`it" . "intent" ) |
| 976 | ("`in" "include" ) | 973 | ("`if" . "interface" ) |
| 977 | ("`i" "integer" ) | 974 | ("`lo" . "logical" ) |
| 978 | ("`it" "intent" ) | 975 | ("`mo" . "module" ) |
| 979 | ("`if" "interface" ) | 976 | ("`na" . "namelist" ) |
| 980 | ("`lo" "logical" ) | 977 | ("`nu" . "nullify" ) |
| 981 | ("`mo" "module" ) | 978 | ("`op" . "optional" ) |
| 982 | ("`na" "namelist" ) | 979 | ("`pa" . "parameter" ) |
| 983 | ("`nu" "nullify" ) | 980 | ("`po" . "pointer" ) |
| 984 | ("`op" "optional" ) | 981 | ("`pr" . "print" ) |
| 985 | ("`pa" "parameter" ) | 982 | ("`pi" . "private" ) |
| 986 | ("`po" "pointer" ) | 983 | ("`pm" . "program" ) |
| 987 | ("`pr" "print" ) | 984 | ("`pr" . "protected" ) |
| 988 | ("`pi" "private" ) | 985 | ("`pu" . "public" ) |
| 989 | ("`pm" "program" ) | 986 | ("`r" . "real" ) |
| 990 | ("`pr" "protected" ) | 987 | ("`rc" . "recursive" ) |
| 991 | ("`pu" "public" ) | 988 | ("`rt" . "return" ) |
| 992 | ("`r" "real" ) | 989 | ("`rw" . "rewind" ) |
| 993 | ("`rc" "recursive" ) | 990 | ("`se" . "select" ) |
| 994 | ("`rt" "return" ) | 991 | ("`sq" . "sequence" ) |
| 995 | ("`rw" "rewind" ) | 992 | ("`su" . "subroutine" ) |
| 996 | ("`se" "select" ) | 993 | ("`ta" . "target" ) |
| 997 | ("`sq" "sequence" ) | 994 | ("`tr" . ".true." ) |
| 998 | ("`su" "subroutine" ) | 995 | ("`t" . "type" ) |
| 999 | ("`ta" "target" ) | 996 | ("`vo" . "volatile" ) |
| 1000 | ("`tr" ".true." ) | 997 | ("`wh" . "where" ) |
| 1001 | ("`t" "type" ) | 998 | ("`wr" . "write" ))) |
| 1002 | ("`vo" "volatile" ) | ||
| 1003 | ("`wh" "where" ) | ||
| 1004 | ("`wr" "write" )))) | ||
| 1005 | 999 | ||
| 1006 | 1000 | ||
| 1007 | ;;;###autoload | 1001 | ;;;###autoload |
| @@ -1452,8 +1446,7 @@ Does not check type and subprogram indentation." | |||
| 1452 | (setq icol (- icol f90-associate-indent))) | 1446 | (setq icol (- icol f90-associate-indent))) |
| 1453 | ((or (looking-at "contains[ \t]*\\(!\\|$\\)") | 1447 | ((or (looking-at "contains[ \t]*\\(!\\|$\\)") |
| 1454 | (f90-looking-at-program-block-end)) | 1448 | (f90-looking-at-program-block-end)) |
| 1455 | (setq icol (- icol f90-program-indent)))))) | 1449 | (setq icol (- icol f90-program-indent)))))))))) |
| 1456 | )))) | ||
| 1457 | icol)) | 1450 | icol)) |
| 1458 | 1451 | ||
| 1459 | (defun f90-previous-statement () | 1452 | (defun f90-previous-statement () |
| @@ -1837,8 +1830,8 @@ If run in the middle of a line, the line is not broken." | |||
| 1837 | block-list (cdr block-list)) | 1830 | block-list (cdr block-list)) |
| 1838 | (if f90-smart-end | 1831 | (if f90-smart-end |
| 1839 | (save-excursion | 1832 | (save-excursion |
| 1840 | (f90-block-match (car beg-struct) (car (cdr beg-struct)) | 1833 | (f90-block-match (car beg-struct) (cadr beg-struct) |
| 1841 | (car end-struct) (car (cdr end-struct))))) | 1834 | (car end-struct) (cadr end-struct)))) |
| 1842 | (setq ind-b | 1835 | (setq ind-b |
| 1843 | (cond ((looking-at f90-end-if-re) f90-if-indent) | 1836 | (cond ((looking-at f90-end-if-re) f90-if-indent) |
| 1844 | ((looking-at "end[ \t]*do\\>") f90-do-indent) | 1837 | ((looking-at "end[ \t]*do\\>") f90-do-indent) |
| @@ -1878,10 +1871,10 @@ If run in the middle of a line, the line is not broken." | |||
| 1878 | (if program | 1871 | (if program |
| 1879 | (progn | 1872 | (progn |
| 1880 | (message "Indenting %s %s..." | 1873 | (message "Indenting %s %s..." |
| 1881 | (car program) (car (cdr program))) | 1874 | (car program) (cadr program)) |
| 1882 | (indent-region (point) (mark) nil) | 1875 | (indent-region (point) (mark) nil) |
| 1883 | (message "Indenting %s %s...done" | 1876 | (message "Indenting %s %s...done" |
| 1884 | (car program) (car (cdr program)))) | 1877 | (car program) (cadr program))) |
| 1885 | (message "Indenting the whole file...") | 1878 | (message "Indenting the whole file...") |
| 1886 | (indent-region (point) (mark) nil) | 1879 | (indent-region (point) (mark) nil) |
| 1887 | (message "Indenting the whole file...done"))))) | 1880 | (message "Indenting the whole file...done"))))) |
| @@ -2028,7 +2021,7 @@ Leave point at the end of line." | |||
| 2028 | (when (save-excursion (beginning-of-line) (skip-chars-forward " \t0-9") | 2021 | (when (save-excursion (beginning-of-line) (skip-chars-forward " \t0-9") |
| 2029 | (setq end-struct (f90-looking-at-program-block-end))) | 2022 | (setq end-struct (f90-looking-at-program-block-end))) |
| 2030 | (setq end-block (car end-struct) | 2023 | (setq end-block (car end-struct) |
| 2031 | end-name (car (cdr end-struct))) | 2024 | end-name (cadr end-struct)) |
| 2032 | (save-excursion | 2025 | (save-excursion |
| 2033 | (beginning-of-line) | 2026 | (beginning-of-line) |
| 2034 | (while (and (> count 0) | 2027 | (while (and (> count 0) |
| @@ -2069,7 +2062,7 @@ Leave point at the end of line." | |||
| 2069 | (line-end-position))) | 2062 | (line-end-position))) |
| 2070 | (sit-for blink-matching-delay))) | 2063 | (sit-for blink-matching-delay))) |
| 2071 | (setq beg-block (car matching-beg) | 2064 | (setq beg-block (car matching-beg) |
| 2072 | beg-name (car (cdr matching-beg))) | 2065 | beg-name (cadr matching-beg)) |
| 2073 | (goto-char end-point) | 2066 | (goto-char end-point) |
| 2074 | (beginning-of-line) | 2067 | (beginning-of-line) |
| 2075 | (f90-block-match beg-block beg-name end-block end-name)))))) | 2068 | (f90-block-match beg-block beg-name end-block end-name)))))) |