diff options
| author | Glenn Morris | 2007-08-01 06:18:16 +0000 |
|---|---|---|
| committer | Glenn Morris | 2007-08-01 06:18:16 +0000 |
| commit | 694cf05e5b5b503af94b63dfe51c44859d76d7b7 (patch) | |
| tree | 753c5110a21a8e9dfb8be3e52980555863d71c8c | |
| parent | f3e82d6997144e6925c86dedd0f2f828d8a3cd29 (diff) | |
| download | emacs-694cf05e5b5b503af94b63dfe51c44859d76d7b7.tar.gz emacs-694cf05e5b5b503af94b63dfe51c44859d76d7b7.zip | |
Remove leading `*' from all defcustom doc strings.
(fortran-tab-mode-default): Remove needless autoload.
(fortran-tab-mode-string): Add help-echo and mouse properties, and
mark as risky.
(fortran-line-length): New buffer-local variable, safe if integer.
(fortran-if-start-re, fortran-end-prog-re1, fortran-end-prog-re):
Change from variables to constants.
(fortran-font-lock-syntactic-keywords): Delete as a variable,
replace with a new function definition.
(fortran-mode): Use fortran-line-length, and
fortran-font-lock-syntactic-keywords as a function. Add a
hack-local-variables-hook function.
(fortran-line-length, fortran-hack-local-variables): New functions.
(fortran-window-create, fortran-strip-sequence-nos): Doc fix. Use
fortran-line-length rather than 72.
(fortran-window-create-momentarily): Doc fix.
| -rw-r--r-- | lisp/progmodes/fortran.el | 164 |
1 files changed, 117 insertions, 47 deletions
diff --git a/lisp/progmodes/fortran.el b/lisp/progmodes/fortran.el index b9865613765..37db236c99f 100644 --- a/lisp/progmodes/fortran.el +++ b/lisp/progmodes/fortran.el | |||
| @@ -1,7 +1,8 @@ | |||
| 1 | ;;; fortran.el --- Fortran mode for GNU Emacs | 1 | ;;; fortran.el --- Fortran mode for GNU Emacs |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1986, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001, | 3 | ;; Copyright (C) 1986, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001, |
| 4 | ;; 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. | 4 | ;; 2002, 2003, 2004, 2005, 2006, 2007 |
| 5 | ;; Free Software Foundation, Inc. | ||
| 5 | 6 | ||
| 6 | ;; Author: Michael D. Prange <prange@erl.mit.edu> | 7 | ;; Author: Michael D. Prange <prange@erl.mit.edu> |
| 7 | ;; Maintainer: Glenn Morris <rgm@gnu.org> | 8 | ;; Maintainer: Glenn Morris <rgm@gnu.org> |
| @@ -78,42 +79,52 @@ | |||
| 78 | :group 'fortran) | 79 | :group 'fortran) |
| 79 | 80 | ||
| 80 | 81 | ||
| 81 | ;;;###autoload | ||
| 82 | (defcustom fortran-tab-mode-default nil | 82 | (defcustom fortran-tab-mode-default nil |
| 83 | "*Default tabbing/carriage control style for empty files in Fortran mode. | 83 | "Default tabbing/carriage control style for empty files in Fortran mode. |
| 84 | A non-nil value specifies tab-digit style of continuation control. | 84 | A non-nil value specifies tab-digit style of continuation control. |
| 85 | A value of nil specifies that continuation lines are marked | 85 | A value of nil specifies that continuation lines are marked |
| 86 | with a character in column 6." | 86 | with a character in column 6." |
| 87 | :type 'boolean | 87 | :type 'boolean |
| 88 | :group 'fortran-indent) | 88 | :group 'fortran-indent) |
| 89 | 89 | ||
| 90 | (defcustom fortran-tab-mode-string "/t" | 90 | ;; TODO add more detail of what tab mode is to doc string. |
| 91 | "*String to appear in mode line in TAB format buffers." | 91 | (defcustom fortran-tab-mode-string |
| 92 | (propertize "/t" 'help-echo "This buffer is in Fortran TAB mode" | ||
| 93 | 'mouse-face 'mode-line-highlight | ||
| 94 | 'local-map | ||
| 95 | (make-mode-line-mouse-map 'mouse-1 | ||
| 96 | (lambda () | ||
| 97 | (interactive) | ||
| 98 | (describe-variable | ||
| 99 | 'fortran-tab-mode-string)))) | ||
| 100 | "String to appear in mode line in TAB format buffers." | ||
| 92 | :type 'string | 101 | :type 'string |
| 93 | :group 'fortran-indent) | 102 | :group 'fortran-indent) |
| 94 | 103 | ||
| 104 | (put 'fortran-tab-mode-string 'risky-local-variable t) | ||
| 105 | |||
| 95 | (defcustom fortran-do-indent 3 | 106 | (defcustom fortran-do-indent 3 |
| 96 | "*Extra indentation applied to DO blocks." | 107 | "Extra indentation applied to DO blocks." |
| 97 | :type 'integer | 108 | :type 'integer |
| 98 | :group 'fortran-indent) | 109 | :group 'fortran-indent) |
| 99 | 110 | ||
| 100 | (defcustom fortran-if-indent 3 | 111 | (defcustom fortran-if-indent 3 |
| 101 | "*Extra indentation applied to IF, SELECT CASE and WHERE blocks." | 112 | "Extra indentation applied to IF, SELECT CASE and WHERE blocks." |
| 102 | :type 'integer | 113 | :type 'integer |
| 103 | :group 'fortran-indent) | 114 | :group 'fortran-indent) |
| 104 | 115 | ||
| 105 | (defcustom fortran-structure-indent 3 | 116 | (defcustom fortran-structure-indent 3 |
| 106 | "*Extra indentation applied to STRUCTURE, UNION, MAP and INTERFACE blocks." | 117 | "Extra indentation applied to STRUCTURE, UNION, MAP and INTERFACE blocks." |
| 107 | :type 'integer | 118 | :type 'integer |
| 108 | :group 'fortran-indent) | 119 | :group 'fortran-indent) |
| 109 | 120 | ||
| 110 | (defcustom fortran-continuation-indent 5 | 121 | (defcustom fortran-continuation-indent 5 |
| 111 | "*Extra indentation applied to continuation lines." | 122 | "Extra indentation applied to continuation lines." |
| 112 | :type 'integer | 123 | :type 'integer |
| 113 | :group 'fortran-indent) | 124 | :group 'fortran-indent) |
| 114 | 125 | ||
| 115 | (defcustom fortran-comment-indent-style 'fixed | 126 | (defcustom fortran-comment-indent-style 'fixed |
| 116 | "*How to indent comments. | 127 | "How to indent comments. |
| 117 | nil forces comment lines not to be touched; | 128 | nil forces comment lines not to be touched; |
| 118 | `fixed' indents to `fortran-comment-line-extra-indent' columns beyond | 129 | `fixed' indents to `fortran-comment-line-extra-indent' columns beyond |
| 119 | `fortran-minimum-statement-indent-fixed' (if `indent-tabs-mode' nil), or | 130 | `fortran-minimum-statement-indent-fixed' (if `indent-tabs-mode' nil), or |
| @@ -124,13 +135,13 @@ nil forces comment lines not to be touched; | |||
| 124 | :group 'fortran-indent) | 135 | :group 'fortran-indent) |
| 125 | 136 | ||
| 126 | (defcustom fortran-comment-line-extra-indent 0 | 137 | (defcustom fortran-comment-line-extra-indent 0 |
| 127 | "*Amount of extra indentation for text within full-line comments." | 138 | "Amount of extra indentation for text within full-line comments." |
| 128 | :type 'integer | 139 | :type 'integer |
| 129 | :group 'fortran-indent | 140 | :group 'fortran-indent |
| 130 | :group 'fortran-comment) | 141 | :group 'fortran-comment) |
| 131 | 142 | ||
| 132 | (defcustom fortran-comment-line-start "C" | 143 | (defcustom fortran-comment-line-start "C" |
| 133 | "*Delimiter inserted to start new full-line comment. | 144 | "Delimiter inserted to start new full-line comment. |
| 134 | You might want to change this to \"*\", for instance." | 145 | You might want to change this to \"*\", for instance." |
| 135 | :version "21.1" | 146 | :version "21.1" |
| 136 | :type 'string | 147 | :type 'string |
| @@ -147,7 +158,7 @@ You might want to change this to \"*\", for instance." | |||
| 147 | 158 | ||
| 148 | (defcustom fortran-directive-re | 159 | (defcustom fortran-directive-re |
| 149 | "^[ \t]*#.*" | 160 | "^[ \t]*#.*" |
| 150 | "*Regexp to match a directive line. | 161 | "Regexp to match a directive line. |
| 151 | The matching text will be fontified with `font-lock-keyword-face'. | 162 | The matching text will be fontified with `font-lock-keyword-face'. |
| 152 | The matching line will be given zero indentation." | 163 | The matching line will be given zero indentation." |
| 153 | :version "22.1" | 164 | :version "22.1" |
| @@ -155,12 +166,12 @@ The matching line will be given zero indentation." | |||
| 155 | :group 'fortran-indent) | 166 | :group 'fortran-indent) |
| 156 | 167 | ||
| 157 | (defcustom fortran-minimum-statement-indent-fixed 6 | 168 | (defcustom fortran-minimum-statement-indent-fixed 6 |
| 158 | "*Minimum statement indentation for fixed format continuation style." | 169 | "Minimum statement indentation for fixed format continuation style." |
| 159 | :type 'integer | 170 | :type 'integer |
| 160 | :group 'fortran-indent) | 171 | :group 'fortran-indent) |
| 161 | 172 | ||
| 162 | (defcustom fortran-minimum-statement-indent-tab (max tab-width 6) | 173 | (defcustom fortran-minimum-statement-indent-tab (max tab-width 6) |
| 163 | "*Minimum statement indentation for TAB format continuation style." | 174 | "Minimum statement indentation for TAB format continuation style." |
| 164 | :type 'integer | 175 | :type 'integer |
| 165 | :group 'fortran-indent) | 176 | :group 'fortran-indent) |
| 166 | 177 | ||
| @@ -168,30 +179,30 @@ The matching line will be given zero indentation." | |||
| 168 | ;; of length one rather than a single character. | 179 | ;; of length one rather than a single character. |
| 169 | ;; The code in this file accepts either format for compatibility. | 180 | ;; The code in this file accepts either format for compatibility. |
| 170 | (defcustom fortran-comment-indent-char " " | 181 | (defcustom fortran-comment-indent-char " " |
| 171 | "*Single-character string inserted for Fortran comment indentation. | 182 | "Single-character string inserted for Fortran comment indentation. |
| 172 | Normally a space." | 183 | Normally a space." |
| 173 | :type 'string | 184 | :type 'string |
| 174 | :group 'fortran-comment) | 185 | :group 'fortran-comment) |
| 175 | 186 | ||
| 176 | (defcustom fortran-line-number-indent 1 | 187 | (defcustom fortran-line-number-indent 1 |
| 177 | "*Maximum indentation for Fortran line numbers. | 188 | "Maximum indentation for Fortran line numbers. |
| 178 | 5 means right-justify them within their five-column field." | 189 | 5 means right-justify them within their five-column field." |
| 179 | :type 'integer | 190 | :type 'integer |
| 180 | :group 'fortran-indent) | 191 | :group 'fortran-indent) |
| 181 | 192 | ||
| 182 | (defcustom fortran-check-all-num-for-matching-do nil | 193 | (defcustom fortran-check-all-num-for-matching-do nil |
| 183 | "*Non-nil causes all numbered lines to be treated as possible DO loop ends." | 194 | "Non-nil causes all numbered lines to be treated as possible DO loop ends." |
| 184 | :type 'boolean | 195 | :type 'boolean |
| 185 | :group 'fortran) | 196 | :group 'fortran) |
| 186 | 197 | ||
| 187 | (defcustom fortran-blink-matching-if nil | 198 | (defcustom fortran-blink-matching-if nil |
| 188 | "*Non-nil causes \\[fortran-indent-line] on ENDIF to blink on matching IF. | 199 | "Non-nil causes \\[fortran-indent-line] on ENDIF to blink on matching IF. |
| 189 | Also, from an ENDDO statement blink on matching DO [WHILE] statement." | 200 | Also, from an ENDDO statement blink on matching DO [WHILE] statement." |
| 190 | :type 'boolean | 201 | :type 'boolean |
| 191 | :group 'fortran) | 202 | :group 'fortran) |
| 192 | 203 | ||
| 193 | (defcustom fortran-continuation-string "$" | 204 | (defcustom fortran-continuation-string "$" |
| 194 | "*Single-character string used for Fortran continuation lines. | 205 | "Single-character string used for Fortran continuation lines. |
| 195 | In fixed format continuation style, this character is inserted in | 206 | In fixed format continuation style, this character is inserted in |
| 196 | column 6 by \\[fortran-split-line] to begin a continuation line. | 207 | column 6 by \\[fortran-split-line] to begin a continuation line. |
| 197 | Also, if \\[fortran-indent-line] finds this at the beginning of a | 208 | Also, if \\[fortran-indent-line] finds this at the beginning of a |
| @@ -201,16 +212,17 @@ appropriate style. Normally $." | |||
| 201 | :group 'fortran) | 212 | :group 'fortran) |
| 202 | 213 | ||
| 203 | (defcustom fortran-comment-region "c$$$" | 214 | (defcustom fortran-comment-region "c$$$" |
| 204 | "*String inserted by \\[fortran-comment-region] at start of each \ | 215 | "String inserted by \\[fortran-comment-region] at start of each \ |
| 205 | line in region." | 216 | line in region." |
| 206 | :type 'string | 217 | :type 'string |
| 207 | :group 'fortran-comment) | 218 | :group 'fortran-comment) |
| 208 | 219 | ||
| 209 | (defcustom fortran-electric-line-number t | 220 | (defcustom fortran-electric-line-number t |
| 210 | "*Non-nil causes line numbers to be moved to the correct column as typed." | 221 | "Non-nil causes line numbers to be moved to the correct column as typed." |
| 211 | :type 'boolean | 222 | :type 'boolean |
| 212 | :group 'fortran) | 223 | :group 'fortran) |
| 213 | 224 | ||
| 225 | ;; TODO use fortran-line-length, somehow. | ||
| 214 | (defcustom fortran-column-ruler-fixed | 226 | (defcustom fortran-column-ruler-fixed |
| 215 | "0 4 6 10 20 30 40 5\ | 227 | "0 4 6 10 20 30 40 5\ |
| 216 | 0 60 70\n\ | 228 | 0 60 70\n\ |
| @@ -222,6 +234,7 @@ See the variable `fortran-column-ruler-tab' for TAB format mode." | |||
| 222 | :type 'string | 234 | :type 'string |
| 223 | :group 'fortran) | 235 | :group 'fortran) |
| 224 | 236 | ||
| 237 | ;; TODO use fortran-line-length, somehow. | ||
| 225 | (defcustom fortran-column-ruler-tab | 238 | (defcustom fortran-column-ruler-tab |
| 226 | "0 810 20 30 40 5\ | 239 | "0 810 20 30 40 5\ |
| 227 | 0 60 70\n\ | 240 | 0 60 70\n\ |
| @@ -239,11 +252,38 @@ See the variable `fortran-column-ruler-fixed' for fixed format mode." | |||
| 239 | :group 'fortran) | 252 | :group 'fortran) |
| 240 | 253 | ||
| 241 | (defcustom fortran-break-before-delimiters t | 254 | (defcustom fortran-break-before-delimiters t |
| 242 | "*Non-nil causes filling to break lines before delimiters. | 255 | "Non-nil causes filling to break lines before delimiters. |
| 243 | Delimiters are characters matching the regexp `fortran-break-delimiters-re'." | 256 | Delimiters are characters matching the regexp `fortran-break-delimiters-re'." |
| 244 | :type 'boolean | 257 | :type 'boolean |
| 245 | :group 'fortran) | 258 | :group 'fortran) |
| 246 | 259 | ||
| 260 | ;; TODO 0 as no-limit, as per g77. | ||
| 261 | (defcustom fortran-line-length 72 | ||
| 262 | "Maximum number of characters in a line of fixed-form Fortran code. | ||
| 263 | Characters beyond this point are treated as comments. Setting | ||
| 264 | this variable directly (after fortran mode is loaded) does not | ||
| 265 | take effect. Use either \\[customize] (which affects all Fortran | ||
| 266 | buffers and the default) or the function | ||
| 267 | `fortran-line-length' (which can also operate on just the current | ||
| 268 | buffer). This corresponds to the g77 compiler option | ||
| 269 | `-ffixed-line-length-N'." | ||
| 270 | :type 'integer | ||
| 271 | :initialize 'custom-initialize-default | ||
| 272 | :set (lambda (symbol value) | ||
| 273 | ;; Do all fortran buffers, and the default. | ||
| 274 | (fortran-line-length value t)) | ||
| 275 | :version "23.1" | ||
| 276 | :group 'fortran) | ||
| 277 | |||
| 278 | (put 'fortran-line-length 'safe-local-variable 'integerp) | ||
| 279 | (make-variable-buffer-local 'fortran-line-length) | ||
| 280 | |||
| 281 | (defcustom fortran-mode-hook nil | ||
| 282 | "Hook run when entering Fortran mode." | ||
| 283 | :type 'hook | ||
| 284 | :group 'fortran) | ||
| 285 | |||
| 286 | |||
| 247 | (defconst fortran-break-delimiters-re "[-+*/><=, \t]" | 287 | (defconst fortran-break-delimiters-re "[-+*/><=, \t]" |
| 248 | "Regexp matching delimiter characters at which lines may be broken. | 288 | "Regexp matching delimiter characters at which lines may be broken. |
| 249 | There are certain tokens comprised entirely of characters | 289 | There are certain tokens comprised entirely of characters |
| @@ -259,22 +299,16 @@ characters matching the regexp `fortran-break-delimiters-re' that should | |||
| 259 | not be split by filling. Each element is assumed to be two | 299 | not be split by filling. Each element is assumed to be two |
| 260 | characters long.") | 300 | characters long.") |
| 261 | 301 | ||
| 262 | (defcustom fortran-mode-hook nil | 302 | (defconst fortran-if-start-re "\\(\\(\\sw\\|\\s_\\)+:[ \t]*\\)?if[ \t]*(" |
| 263 | "Hook run when entering Fortran mode." | ||
| 264 | :type 'hook | ||
| 265 | :group 'fortran) | ||
| 266 | |||
| 267 | |||
| 268 | (defvar fortran-if-start-re "\\(\\(\\sw\\|\\s_\\)+:[ \t]*\\)?if[ \t]*(" | ||
| 269 | "Regexp matching the start of an IF statement.") | 303 | "Regexp matching the start of an IF statement.") |
| 270 | 304 | ||
| 271 | (defvar fortran-end-prog-re1 | 305 | (defconst fortran-end-prog-re1 |
| 272 | "end\ | 306 | "end\ |
| 273 | \\([ \t]*\\(program\\|subroutine\\|function\\|block[ \t]*data\\)\\>\ | 307 | \\([ \t]*\\(program\\|subroutine\\|function\\|block[ \t]*data\\)\\>\ |
| 274 | \\([ \t]*\\(\\sw\\|\\s_\\)+\\)?\\)?" | 308 | \\([ \t]*\\(\\sw\\|\\s_\\)+\\)?\\)?" |
| 275 | "Regexp possibly matching the end of a subprogram.") | 309 | "Regexp possibly matching the end of a subprogram.") |
| 276 | 310 | ||
| 277 | (defvar fortran-end-prog-re | 311 | (defconst fortran-end-prog-re |
| 278 | (concat "^[ \t0-9]*" fortran-end-prog-re1) | 312 | (concat "^[ \t0-9]*" fortran-end-prog-re1) |
| 279 | "Regexp possibly matching the end of a subprogram, from the line start. | 313 | "Regexp possibly matching the end of a subprogram, from the line start. |
| 280 | See also `fortran-end-prog-re1'.") | 314 | See also `fortran-end-prog-re1'.") |
| @@ -402,11 +436,13 @@ Consists of level 3 plus all other intrinsics not already highlighted.") | |||
| 402 | ;; (We can do so for F90-style). Therefore an unmatched quote in a | 436 | ;; (We can do so for F90-style). Therefore an unmatched quote in a |
| 403 | ;; standard comment will throw fontification off on the wrong track. | 437 | ;; standard comment will throw fontification off on the wrong track. |
| 404 | ;; So we do syntactic fontification with regexps. | 438 | ;; So we do syntactic fontification with regexps. |
| 405 | (defvar fortran-font-lock-syntactic-keywords | 439 | (defun fortran-font-lock-syntactic-keywords () |
| 406 | '(("^[cd\\*]" 0 (11)) | 440 | "Return a value for `font-lock-syntactic-keywords' in Fortran mode. |
| 407 | ("^[^cd\\*\t\n].\\{71\\}\\([^\n]+\\)" 1 (11))) | 441 | This varies according to the value of `fortran-line-length'. |
| 408 | "`font-lock-syntactic-keywords' for Fortran. | 442 | This is used to fontify fixed-format Fortran comments." |
| 409 | These get fixed-format comments fontified.") | 443 | `(("^[cd\\*]" 0 (11)) |
| 444 | (,(format "^[^cd\\*\t\n].\\{%d\\}\\([^\n]+\\)" fortran-line-length) | ||
| 445 | 1 (11)))) | ||
| 410 | 446 | ||
| 411 | (defvar fortran-font-lock-keywords fortran-font-lock-keywords-1 | 447 | (defvar fortran-font-lock-keywords fortran-font-lock-keywords-1 |
| 412 | "Default expressions to highlight in Fortran mode.") | 448 | "Default expressions to highlight in Fortran mode.") |
| @@ -582,6 +618,8 @@ Used in the Fortran entry in `hs-special-modes-alist'.") | |||
| 582 | ["Widen" widen t] | 618 | ["Widen" widen t] |
| 583 | "--" | 619 | "--" |
| 584 | ["Temporary column ruler" fortran-column-ruler t] | 620 | ["Temporary column ruler" fortran-column-ruler t] |
| 621 | ;; May not be '72', depending on fortran-line-length, but this | ||
| 622 | ;; seems ok for a menu item. | ||
| 585 | ["72-column window" fortran-window-create t] | 623 | ["72-column window" fortran-window-create t] |
| 586 | ["Full Width Window" | 624 | ["Full Width Window" |
| 587 | (enlarge-window-horizontally (- (frame-width) (window-width))) | 625 | (enlarge-window-horizontally (- (frame-width) (window-width))) |
| @@ -780,7 +818,7 @@ with no args, if that value is non-nil." | |||
| 780 | (set (make-local-variable 'normal-auto-fill-function) 'fortran-auto-fill) | 818 | (set (make-local-variable 'normal-auto-fill-function) 'fortran-auto-fill) |
| 781 | (set (make-local-variable 'indent-tabs-mode) (fortran-analyze-file-format)) | 819 | (set (make-local-variable 'indent-tabs-mode) (fortran-analyze-file-format)) |
| 782 | (setq mode-line-process '(indent-tabs-mode fortran-tab-mode-string)) | 820 | (setq mode-line-process '(indent-tabs-mode fortran-tab-mode-string)) |
| 783 | (set (make-local-variable 'fill-column) 72) | 821 | (set (make-local-variable 'fill-column) fortran-line-length) |
| 784 | (set (make-local-variable 'fill-paragraph-function) 'fortran-fill-paragraph) | 822 | (set (make-local-variable 'fill-paragraph-function) 'fortran-fill-paragraph) |
| 785 | (set (make-local-variable 'font-lock-defaults) | 823 | (set (make-local-variable 'font-lock-defaults) |
| 786 | '((fortran-font-lock-keywords | 824 | '((fortran-font-lock-keywords |
| @@ -791,7 +829,7 @@ with no args, if that value is non-nil." | |||
| 791 | nil t ((?/ . "$/") ("_$" . "w")) | 829 | nil t ((?/ . "$/") ("_$" . "w")) |
| 792 | fortran-beginning-of-subprogram)) | 830 | fortran-beginning-of-subprogram)) |
| 793 | (set (make-local-variable 'font-lock-syntactic-keywords) | 831 | (set (make-local-variable 'font-lock-syntactic-keywords) |
| 794 | fortran-font-lock-syntactic-keywords) | 832 | (fortran-font-lock-syntactic-keywords)) |
| 795 | (set (make-local-variable 'imenu-case-fold-search) t) | 833 | (set (make-local-variable 'imenu-case-fold-search) t) |
| 796 | (set (make-local-variable 'imenu-generic-expression) | 834 | (set (make-local-variable 'imenu-generic-expression) |
| 797 | fortran-imenu-generic-expression) | 835 | fortran-imenu-generic-expression) |
| @@ -804,9 +842,38 @@ with no args, if that value is non-nil." | |||
| 804 | #'fortran-current-defun) | 842 | #'fortran-current-defun) |
| 805 | (set (make-local-variable 'dabbrev-case-fold-search) 'case-fold-search) | 843 | (set (make-local-variable 'dabbrev-case-fold-search) 'case-fold-search) |
| 806 | (set (make-local-variable 'gud-find-expr-function) 'fortran-gud-find-expr) | 844 | (set (make-local-variable 'gud-find-expr-function) 'fortran-gud-find-expr) |
| 845 | (add-hook 'hack-local-variables-hook 'fortran-hack-local-variables nil t) | ||
| 807 | (run-mode-hooks 'fortran-mode-hook)) | 846 | (run-mode-hooks 'fortran-mode-hook)) |
| 808 | 847 | ||
| 809 | 848 | ||
| 849 | (defun fortran-line-length (nchars &optional global) | ||
| 850 | "Set the length of fixed-form Fortran lines to NCHARS. | ||
| 851 | This normally only affects the current buffer, which must be in | ||
| 852 | Fortran mode. If the optional argument GLOBAL is non-nil, it | ||
| 853 | affects all Fortran buffers, and also the default." | ||
| 854 | (interactive "p") | ||
| 855 | (let (new) | ||
| 856 | (mapcar (lambda (buff) | ||
| 857 | (with-current-buffer buff | ||
| 858 | (when (eq major-mode 'fortran-mode) | ||
| 859 | (setq fortran-line-length nchars | ||
| 860 | fill-column fortran-line-length | ||
| 861 | new (fortran-font-lock-syntactic-keywords)) | ||
| 862 | ;; Refontify only if necessary. | ||
| 863 | (unless (equal new font-lock-syntactic-keywords) | ||
| 864 | (setq font-lock-syntactic-keywords | ||
| 865 | (fortran-font-lock-syntactic-keywords)) | ||
| 866 | (if font-lock-mode (font-lock-mode 1)))))) | ||
| 867 | (if global | ||
| 868 | (buffer-list) | ||
| 869 | (list (current-buffer)))) | ||
| 870 | (if global | ||
| 871 | (setq-default fortran-line-length nchars)))) | ||
| 872 | |||
| 873 | (defun fortran-hack-local-variables () | ||
| 874 | "Fortran mode adds this to `hack-local-variables-hook'." | ||
| 875 | (fortran-line-length fortran-line-length)) | ||
| 876 | |||
| 810 | (defun fortran-gud-find-expr () | 877 | (defun fortran-gud-find-expr () |
| 811 | ;; Consider \n as punctuation (end of expression). | 878 | ;; Consider \n as punctuation (end of expression). |
| 812 | (with-syntax-table fortran-gud-syntax-table | 879 | (with-syntax-table fortran-gud-syntax-table |
| @@ -940,7 +1007,7 @@ The next key typed is executed unless it is SPC." | |||
| 940 | nil "Type SPC or any command to erase ruler.")) | 1007 | nil "Type SPC or any command to erase ruler.")) |
| 941 | 1008 | ||
| 942 | (defun fortran-window-create () | 1009 | (defun fortran-window-create () |
| 943 | "Make the window 72 columns wide. | 1010 | "Make the window `fortran-line-length' (default 72) columns wide. |
| 944 | See also `fortran-window-create-momentarily'." | 1011 | See also `fortran-window-create-momentarily'." |
| 945 | (interactive) | 1012 | (interactive) |
| 946 | (let ((window-min-width 2)) | 1013 | (let ((window-min-width 2)) |
| @@ -951,13 +1018,13 @@ See also `fortran-window-create-momentarily'." | |||
| 951 | (scroll-bar-width (- (nth 2 window-edges) | 1018 | (scroll-bar-width (- (nth 2 window-edges) |
| 952 | (car window-edges) | 1019 | (car window-edges) |
| 953 | (window-width)))) | 1020 | (window-width)))) |
| 954 | (split-window-horizontally (+ 72 scroll-bar-width))) | 1021 | (split-window-horizontally (+ fortran-line-length scroll-bar-width))) |
| 955 | (other-window 1) | 1022 | (other-window 1) |
| 956 | (switch-to-buffer " fortran-window-extra" t) | 1023 | (switch-to-buffer " fortran-window-extra" t) |
| 957 | (select-window (previous-window)))) | 1024 | (select-window (previous-window)))) |
| 958 | 1025 | ||
| 959 | (defun fortran-window-create-momentarily (&optional arg) | 1026 | (defun fortran-window-create-momentarily (&optional arg) |
| 960 | "Momentarily make the window 72 columns wide. | 1027 | "Momentarily make the window `fortran-line-length' (default 72) columns wide. |
| 961 | Optional ARG non-nil and non-unity disables the momentary feature. | 1028 | Optional ARG non-nil and non-unity disables the momentary feature. |
| 962 | See also `fortran-window-create'." | 1029 | See also `fortran-window-create'." |
| 963 | (interactive "p") | 1030 | (interactive "p") |
| @@ -1065,7 +1132,8 @@ Auto-indent does not happen if a numeric ARG is used." | |||
| 1065 | (string-match "^\\s-*\\(\\'\\|\\s<\\)" | 1132 | (string-match "^\\s-*\\(\\'\\|\\s<\\)" |
| 1066 | (buffer-substring (match-end 0) | 1133 | (buffer-substring (match-end 0) |
| 1067 | (min (line-end-position) | 1134 | (min (line-end-position) |
| 1068 | (+ 72 (line-beginning-position))))))) | 1135 | (+ fortran-line-length |
| 1136 | (line-beginning-position))))))) | ||
| 1069 | 1137 | ||
| 1070 | ;; Note that you can't just check backwards for `subroutine' &c in | 1138 | ;; Note that you can't just check backwards for `subroutine' &c in |
| 1071 | ;; case of un-marked main programs not at the start of the file. | 1139 | ;; case of un-marked main programs not at the start of the file. |
| @@ -1996,13 +2064,15 @@ Always returns non-nil (to prevent `fill-paragraph' being called)." | |||
| 1996 | (fortran-indent-line))) | 2064 | (fortran-indent-line))) |
| 1997 | 2065 | ||
| 1998 | (defun fortran-strip-sequence-nos (&optional do-space) | 2066 | (defun fortran-strip-sequence-nos (&optional do-space) |
| 1999 | "Delete all text in column 72 and up (assumed to be sequence numbers). | 2067 | "Delete all text in column `fortran-line-length' (default 72) and up. |
| 2000 | Normally also deletes trailing whitespace after stripping such text. | 2068 | This is assumed to be sequence numbers. Normally also deletes |
| 2001 | Supplying prefix arg DO-SPACE prevents stripping the whitespace." | 2069 | trailing whitespace after stripping such text. Supplying prefix |
| 2070 | arg DO-SPACE prevents stripping the whitespace." | ||
| 2002 | (interactive "*p") | 2071 | (interactive "*p") |
| 2003 | (save-excursion | 2072 | (save-excursion |
| 2004 | (goto-char (point-min)) | 2073 | (goto-char (point-min)) |
| 2005 | (while (re-search-forward "^.\\{72\\}\\(.*\\)" nil t) | 2074 | (while (re-search-forward (format "^.\\{%d\\}\\(.*\\)" fortran-line-length) |
| 2075 | nil t) | ||
| 2006 | (replace-match "" nil nil nil 1) | 2076 | (replace-match "" nil nil nil 1) |
| 2007 | (unless do-space (delete-horizontal-space))))) | 2077 | (unless do-space (delete-horizontal-space))))) |
| 2008 | 2078 | ||