aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love2000-01-05 17:23:27 +0000
committerDave Love2000-01-05 17:23:27 +0000
commit7a7db8e56991acf5e6051faf64f6b7c2ec99fc0f (patch)
tree5e8293ab566f955dbbc8f7badaeecb9d82d099d5
parentfae2ac05e1e916397cb46f0ce7e37ccb1e2be2b7 (diff)
downloademacs-7a7db8e56991acf5e6051faf64f6b7c2ec99fc0f.tar.gz
emacs-7a7db8e56991acf5e6051faf64f6b7c2ec99fc0f.zip
(fortran-mode-map): Don't bind M-C-a,
M-C-e, M-C-h, C-j, C-xnd, TAB. (fortran-mode): Set beginning-of-defun, end-of-defun. (fortran-column-ruler): Simplify. (fortran-mark-subprogram, fortran-narrow-to-subprogram): Deleted. (fortran-with-subprogram-narrowing): Likewise. (fortran-indent-subprogram): Call mark-defun. (fortran-check-for-matching-do): Change narrowing.
-rw-r--r--lisp/progmodes/fortran.el210
1 files changed, 89 insertions, 121 deletions
diff --git a/lisp/progmodes/fortran.el b/lisp/progmodes/fortran.el
index d438e89ff93..183b1a00e17 100644
--- a/lisp/progmodes/fortran.el
+++ b/lisp/progmodes/fortran.el
@@ -1,6 +1,6 @@
1;;; fortran.el --- Fortran mode for GNU Emacs 1;;; fortran.el --- Fortran mode for GNU Emacs
2 2
3;; Copyright (c) 1986, 93, 94, 95, 97, 98, 1999 Free Software Foundation, Inc. 3;; Copyright (c) 1986, 93, 94, 95, 97-99, 2000 Free Software Foundation, Inc.
4 4
5;; Author: Michael D. Prange <prange@erl.mit.edu> 5;; Author: Michael D. Prange <prange@erl.mit.edu>
6;; Maintainer: Dave Love <fx@gnu.org> 6;; Maintainer: Dave Love <fx@gnu.org>
@@ -393,90 +393,81 @@ These get fixed-format comments fontified.")
393 (list nil "^\\s-+\\(block\\s-*data\\)\\s-*$" 1)) 393 (list nil "^\\s-+\\(block\\s-*data\\)\\s-*$" 1))
394 "Imenu generic expression for `imenu-default-create-index-function'.") 394 "Imenu generic expression for `imenu-default-create-index-function'.")
395 395
396(defvar fortran-mode-map () 396(defvar fortran-mode-map
397 (let ((fortran-mode-map (make-sparse-keymap)))
398 (define-key fortran-mode-map ";" 'fortran-abbrev-start)
399 (define-key fortran-mode-map "\C-c;" 'fortran-comment-region)
400 (define-key fortran-mode-map "\M-;" 'fortran-indent-comment)
401 (define-key fortran-mode-map "\M-\n" 'fortran-split-line)
402 (define-key fortran-mode-map "\M-\C-q" 'fortran-indent-subprogram)
403 (define-key fortran-mode-map "\C-c\C-w" 'fortran-window-create-momentarily)
404 (define-key fortran-mode-map "\C-c\C-r" 'fortran-column-ruler)
405 (define-key fortran-mode-map "\C-c\C-p" 'fortran-previous-statement)
406 (define-key fortran-mode-map "\C-c\C-n" 'fortran-next-statement)
407 (define-key fortran-mode-map "\C-c\C-d" 'fortran-join-line) ; like f90
408 (define-key fortran-mode-map "\M-^" 'fortran-join-line) ; subvert delete-indentation
409 (define-key fortran-mode-map "0" 'fortran-electric-line-number)
410 (define-key fortran-mode-map "1" 'fortran-electric-line-number)
411 (define-key fortran-mode-map "2" 'fortran-electric-line-number)
412 (define-key fortran-mode-map "3" 'fortran-electric-line-number)
413 (define-key fortran-mode-map "4" 'fortran-electric-line-number)
414 (define-key fortran-mode-map "5" 'fortran-electric-line-number)
415 (define-key fortran-mode-map "6" 'fortran-electric-line-number)
416 (define-key fortran-mode-map "7" 'fortran-electric-line-number)
417 (define-key fortran-mode-map "8" 'fortran-electric-line-number)
418 (define-key fortran-mode-map "9" 'fortran-electric-line-number)
419
420 ;; Menu
421 (unless (boundp 'fortran-mode-menu)
422 (easy-menu-define
423 fortran-mode-menu fortran-mode-map ""
424 `("Fortran"
425 ["Manual" (info "(emacs)Fortran")]
426 ,(customize-menu-create 'fortran)
427 ["Set" Custom-set t]
428 ["Save" Custom-save t]
429 ["Reset to Current" Custom-reset-current t]
430 ["Reset to Saved" Custom-reset-saved t]
431 ["Reset to Standard Settings" Custom-reset-standard t]
432 "----"
433 ["Toggle Auto-fill" fortran-auto-fill-mode :style toggle
434 :selected (eq auto-fill-function 'fortran-do-auto-fill)]
435 ["Toggle abbrev-mode" abbrev-mode :style toggle :selected abbrev-mode]
436 "----"
437 ["Comment-out Region" fortran-comment-region mark-active]
438 ["Uncomment-out region"
439 (fortran-comment-region (region-beginning) (region-end) 1)
440 mark-active]
441 ["Indent Region" indent-region mark-active]
442 ["Indent Subprogram" fortran-indent-subprogram t]
443 "----"
444 ["Beginning of Subprogram" fortran-beginning-of-subprogram t]
445 ["End of Subprogram" fortran-end-of-subprogram t]
446 ("Mark"
447 ["Subprogram" mark-defun t]
448 ["IF Block" fortran-mark-if t]
449 ["DO Block" fortran-mark-do t])
450 ["Narrow to Subprogram" narrow-to-defun t]
451 ["Widen" widen t]
452 "----"
453 ["Temporary column ruler" fortran-column-ruler t]
454 ["72-column window" fortran-window-create t]
455 ["Full Width Window"
456 (enlarge-window-horizontally (- (frame-width) (window-width)))
457 (< (window-width) (frame-width))]
458 ["Momentary 72-column window" fortran-window-create-momentarily t]
459 "----"
460 ["Break Line at Point" fortran-split-line t]
461 ["Join Line" fortran-join-line t]
462 ["Fill Statement/Comment" fill-paragraph t]
463 "----"
464 ["Add imenu menu"
465 imenu-add-menubar-index (not (and (boundp 'imenu--index-alist)
466 imenu--index-alist))])))
467 fortran-mode-map)
397 "Keymap used in Fortran mode.") 468 "Keymap used in Fortran mode.")
398(if fortran-mode-map
399 ()
400 (setq fortran-mode-map (make-sparse-keymap))
401 (define-key fortran-mode-map ";" 'fortran-abbrev-start)
402 (define-key fortran-mode-map "\C-c;" 'fortran-comment-region)
403 (define-key fortran-mode-map "\M-\C-a" 'fortran-beginning-of-subprogram)
404 (define-key fortran-mode-map "\M-\C-e" 'fortran-end-of-subprogram)
405 (define-key fortran-mode-map "\M-;" 'fortran-indent-comment)
406 (define-key fortran-mode-map "\M-\C-h" 'fortran-mark-subprogram)
407 (define-key fortran-mode-map "\M-\n" 'fortran-split-line)
408 (define-key fortran-mode-map "\n" 'fortran-indent-new-line)
409 (define-key fortran-mode-map "\M-\C-q" 'fortran-indent-subprogram)
410 (define-key fortran-mode-map "\C-c\C-w" 'fortran-window-create-momentarily)
411 (define-key fortran-mode-map "\C-c\C-r" 'fortran-column-ruler)
412 (define-key fortran-mode-map "\C-c\C-p" 'fortran-previous-statement)
413 (define-key fortran-mode-map "\C-c\C-n" 'fortran-next-statement)
414 (define-key fortran-mode-map "\C-c\C-d" 'fortran-join-line) ; like f90
415 (define-key fortran-mode-map "\M-^" 'fortran-join-line) ; subvert delete-indentation
416 (define-key fortran-mode-map "\C-xnd" 'fortran-narrow-to-subprogram)
417 ;(define-key fortran-mode-map "\t" 'fortran-indent-line)
418 (define-key fortran-mode-map "0" 'fortran-electric-line-number)
419 (define-key fortran-mode-map "1" 'fortran-electric-line-number)
420 (define-key fortran-mode-map "2" 'fortran-electric-line-number)
421 (define-key fortran-mode-map "3" 'fortran-electric-line-number)
422 (define-key fortran-mode-map "4" 'fortran-electric-line-number)
423 (define-key fortran-mode-map "5" 'fortran-electric-line-number)
424 (define-key fortran-mode-map "6" 'fortran-electric-line-number)
425 (define-key fortran-mode-map "7" 'fortran-electric-line-number)
426 (define-key fortran-mode-map "8" 'fortran-electric-line-number)
427 (define-key fortran-mode-map "9" 'fortran-electric-line-number)
428
429 ;; Menu
430 (unless (boundp 'fortran-mode-menu)
431 (easy-menu-define
432 fortran-mode-menu fortran-mode-map ""
433 `("Fortran"
434 ["Manual" (info "(emacs)Fortran")]
435 ,(customize-menu-create 'fortran)
436 ["Set" Custom-set t]
437 ["Save" Custom-save t]
438 ["Reset to Current" Custom-reset-current t]
439 ["Reset to Saved" Custom-reset-saved t]
440 ["Reset to Standard Settings" Custom-reset-standard t]
441 "----"
442 ["Toggle Auto-fill" fortran-auto-fill-mode :style toggle
443 :selected (eq auto-fill-function 'fortran-do-auto-fill)]
444 ["Toggle abbrev-mode" abbrev-mode :style toggle :selected abbrev-mode]
445 "----"
446 ["Comment-out Region" fortran-comment-region mark-active]
447 ["Uncomment-out region"
448 (fortran-comment-region (region-beginning) (region-end) 1)
449 mark-active]
450 ["Indent Region" indent-region mark-active]
451 ["Indent Subprogram" fortran-indent-subprogram t]
452 "----"
453 ["Beginning of Subprogram" fortran-beginning-of-subprogram t]
454 ["End of Subprogram" fortran-end-of-subprogram t]
455 ("Mark"
456 ["Subprogram" fortran-mark-subprogram t]
457 ["IF Block" fortran-mark-if t]
458 ["DO Block" fortran-mark-do t])
459 ["Narrow to Subprogram" fortran-narrow-to-subprogram t]
460 ["Widen" widen t]
461 "----"
462 ["Temporary column ruler" fortran-column-ruler t]
463 ["72-column window" fortran-window-create t]
464 ["Full Width Window"
465 (enlarge-window-horizontally (- (frame-width) (window-width)))
466 (< (window-width) (frame-width))]
467 ["Momentary 72-column window" fortran-window-create-momentarily t]
468 "----"
469 ["Break Line at Point" fortran-split-line t]
470 ["Join Line" fortran-join-line t]
471 ["Fill Statement/Comment" fill-paragraph t]
472 "----"
473 ["Add imenu menu"
474 imenu-add-menubar-index (not (and (boundp 'imenu--index-alist)
475 imenu--index-alist))]))))
476 469
477(defvar fortran-mode-abbrev-table nil) 470(defvar fortran-mode-abbrev-table
478(if fortran-mode-abbrev-table
479 ()
480 (let ((ac abbrevs-changed)) 471 (let ((ac abbrevs-changed))
481 (define-abbrev-table 'fortran-mode-abbrev-table ()) 472 (define-abbrev-table 'fortran-mode-abbrev-table ())
482 (define-abbrev fortran-mode-abbrev-table ";au" "automatic" nil) 473 (define-abbrev fortran-mode-abbrev-table ";au" "automatic" nil)
@@ -537,7 +528,8 @@ These get fixed-format comments fontified.")
537 (define-abbrev fortran-mode-abbrev-table ";vo" "volatile" nil) 528 (define-abbrev fortran-mode-abbrev-table ";vo" "volatile" nil)
538 (define-abbrev fortran-mode-abbrev-table ";w" "write" nil) 529 (define-abbrev fortran-mode-abbrev-table ";w" "write" nil)
539 (define-abbrev fortran-mode-abbrev-table ";wh" "where" nil) 530 (define-abbrev fortran-mode-abbrev-table ";wh" "where" nil)
540 (setq abbrevs-changed ac))) 531 (setq abbrevs-changed ac)
532 fortran-mode-abbrev-table))
541 533
542(eval-when-compile ; silence compiler 534(eval-when-compile ; silence compiler
543 (defvar imenu-case-fold-search) 535 (defvar imenu-case-fold-search)
@@ -676,6 +668,8 @@ with no args, if that value is non-nil."
676 (let (fortran-blink-matching-if ; avoid blinking delay 668 (let (fortran-blink-matching-if ; avoid blinking delay
677 indent-region-function) 669 indent-region-function)
678 (indent-region start end nil)))) 670 (indent-region start end nil))))
671 (setq beginning-of-defun #'fortran-beginning-of-subprogram)
672 (setq end-of-defun #'fortran-end-of-subprogram)
679 (run-hooks 'fortran-mode-hook)) 673 (run-hooks 'fortran-mode-hook))
680 674
681(defun fortran-comment-indent-function () 675(defun fortran-comment-indent-function ()
@@ -793,7 +787,7 @@ The key typed is executed unless it is SPC."
793 (beginning-of-line) 787 (beginning-of-line)
794 (if (eq (window-start (selected-window)) 788 (if (eq (window-start (selected-window))
795 (window-point (selected-window))) 789 (window-point (selected-window)))
796 (progn (forward-line) (point)) 790 (line-beginning-position 2)
797 (point))) 791 (point)))
798 nil "Type SPC or any command to erase ruler.")) 792 nil "Type SPC or any command to erase ruler."))
799 793
@@ -960,14 +954,6 @@ Auto-indent does not happen if a numeric ARG is used."
960 (goto-char (match-beginning 0)) 954 (goto-char (match-beginning 0))
961 (forward-line))))) 955 (forward-line)))))
962 956
963(defun fortran-mark-subprogram ()
964 "Put mark at end of Fortran subprogram, point at beginning.
965The marks are pushed."
966 (interactive)
967 (fortran-end-of-subprogram)
968 (push-mark (point) nil t)
969 (fortran-beginning-of-subprogram))
970
971(defun fortran-previous-statement () 957(defun fortran-previous-statement ()
972 "Moves point to beginning of the previous Fortran statement. 958 "Moves point to beginning of the previous Fortran statement.
973Returns `first-statement' if that statement is the first 959Returns `first-statement' if that statement is the first
@@ -1008,27 +994,6 @@ non-comment Fortran statement in the file, and nil otherwise."
1008 (looking-at (concat "[ \t]*" comment-start-skip))))) 994 (looking-at (concat "[ \t]*" comment-start-skip)))))
1009 (if (not not-last-statement) 995 (if (not not-last-statement)
1010 'last-statement))) 996 'last-statement)))
1011
1012(defun fortran-narrow-to-subprogram ()
1013 "Make text outside the current subprogram invisible.
1014The subprogram visible is the one that contains or follows point."
1015 (interactive)
1016 (save-excursion
1017 (fortran-mark-subprogram)
1018 (narrow-to-region (point) (mark))))
1019
1020(defmacro fortran-with-subprogram-narrowing (&rest forms)
1021 "Execute FORMS with buffer temporarily narrowed to current subprogram.
1022Doesn't push a mark."
1023 `(save-restriction
1024 (save-excursion
1025 (narrow-to-region (progn
1026 (fortran-beginning-of-subprogram)
1027 (point))
1028 (progn
1029 (fortran-end-of-subprogram)
1030 (point))))
1031 ,@forms))
1032 997
1033(defun fortran-blink-match (regex keyword find-begin) 998(defun fortran-blink-match (regex keyword find-begin)
1034 "From a line matching REGEX, blink matching KEYWORD statement line. 999 "From a line matching REGEX, blink matching KEYWORD statement line.
@@ -1286,7 +1251,7 @@ Return point or nil."
1286 "Properly indent the Fortran subprogram which contains point." 1251 "Properly indent the Fortran subprogram which contains point."
1287 (interactive) 1252 (interactive)
1288 (save-excursion 1253 (save-excursion
1289 (fortran-mark-subprogram) 1254 (mark-defun)
1290 (message "Indenting subprogram...") 1255 (message "Indenting subprogram...")
1291 (indent-region (point) (mark) nil)) 1256 (indent-region (point) (mark) nil))
1292 (message "Indenting subprogram...done.")) 1257 (message "Indenting subprogram...done."))
@@ -1506,12 +1471,15 @@ Otherwise return nil."
1506 (skip-chars-forward "0-9") 1471 (skip-chars-forward "0-9")
1507 (point)))) 1472 (point))))
1508 (beginning-of-line) 1473 (beginning-of-line)
1509 (fortran-with-subprogram-narrowing 1474 (save-restriction
1510 (and (re-search-backward 1475 (save-excursion
1511 (concat "\\(^[ \t0-9]*do[ \t]*0*" charnum "\\b\\)\\|" 1476 (narrow-to-defun)
1512 "\\(^[ \t]*0*" charnum "\\b\\)") 1477 (and (re-search-backward
1513 nil t) 1478 (concat "\\(^[ \t0-9]*do[ \t]*0*" charnum "\\b\\)\\|"
1514 (looking-at (concat "^[ \t0-9]*do[ \t]*0*" charnum))))))))) 1479 "\\(^[ \t]*0*" charnum "\\b\\)")
1480 nil t)
1481 (looking-at (concat "^[ \t0-9]*do[ \t]*0*"
1482 charnum))))))))))
1515 1483
1516(defun fortran-find-comment-start-skip () 1484(defun fortran-find-comment-start-skip ()
1517 "Move to past `comment-start-skip' found on current line. 1485 "Move to past `comment-start-skip' found on current line.