predictive-f90.el 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. ;;; predictive-setup-f90.el --- predictive mode Fortran 90 setup function
  2. ;; Copyright (C) 2005 Toby Cubitt
  3. ;; Author: Toby Cubitt <toby-predictive@dr-qubit.org>
  4. ;; Version: 0.2
  5. ;; Keywords: predictive, setup function, fortran, f90
  6. ;; URL: http://www.dr-qubit.org/emacs.php
  7. ;; This file is part of the Emacs Predictive Completion package.
  8. ;;
  9. ;; This program is free software; you can redistribute it and/or
  10. ;; modify it under the terms of the GNU General Public License
  11. ;; as published by the Free Software Foundation; either version 2
  12. ;; of the License, or (at your option) any later version.
  13. ;;
  14. ;; This program is distributed in the hope that it will be useful,
  15. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. ;; GNU General Public License for more details.
  18. ;;
  19. ;; You should have received a copy of the GNU General Public License
  20. ;; along with this program; if not, write to the Free Software
  21. ;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  22. ;; MA 02110-1301, USA.
  23. ;;; Change Log:
  24. ;;
  25. ;; Version 0.2
  26. ;; * modified to use new auto-overlays package
  27. ;;
  28. ;; Version 0.1
  29. ;; * initial release
  30. ;;; Code:
  31. (require 'predictive)
  32. (provide 'predictive-f90)
  33. ;; variable to store identifier from call to `auto-overlay-init'
  34. (defvar predictive-f90-regexps nil)
  35. (make-local-variable 'predictive-f90-regexps)
  36. (defun predictive-setup-f90 ()
  37. "Sets up predictive mode for use with Fortran 90 mode."
  38. (interactive)
  39. ;; load the dictionaries
  40. (predictive-load-dict 'dict-english)
  41. (predictive-load-dict 'dict-f90)
  42. (predictive-load-dict 'dict-f90-attributes)
  43. (predictive-load-dict 'dict-f90-intent)
  44. (predictive-load-dict 'dict-f90-open)
  45. (predictive-load-dict 'dict-f90-close)
  46. (predictive-load-dict 'dict-f90-read)
  47. (predictive-load-dict 'dict-f90-write)
  48. (predictive-load-dict 'dict-f90-rewind-backspace)
  49. ;; clear overlays when predictive mode is disabled
  50. (add-hook 'predictive-mode-disable-hook
  51. (lambda () (auto-overlay-clear predictive-f90-regexps)))
  52. ;; use Fortran 90 dictionary
  53. (set (make-local-variable 'predictive-main-dict) 'dict-f90)
  54. ;; user-defined procedure and variable names are added to buffer dictionary
  55. (set (make-local-variable 'predictive-auto-add-to-dict) 'buffer)
  56. (set (make-local-variable 'predictive-add-to-dict-ask) nil)
  57. ;; setup regexps defining switch-dict regions
  58. (setq predictive-f90-regexps
  59. (auto-overlay-init
  60. '(
  61. ;; ! starts a comment, which lasts till end of line
  62. (line "!" (dict . dict-english) '(priority . 3))
  63. ;; 's and "s delimit the start and end of character constants
  64. ;; (don't care that "" is escaped, since behaves correctly like
  65. ;; this anyway)
  66. (self "\"" (dict . dict-english) '(priority . 2))
  67. (self "'" (dict . dict-english) '(priority . 2))
  68. ;; attributes come after type declarations but before "::"
  69. (stack
  70. (start "character" (dict . dict-f90-attributes))
  71. (start "complex" (dict . dict-f90-attributes))
  72. (start "double precision" (dict . dict-f90-attributes))
  73. (start "integer" (dict . dict-f90-attributes))
  74. (start "logical" (dict . dict-f90-attributes))
  75. (start "real" (dict . dict-f90-attributes))
  76. (end "::" (dict . il)))
  77. ;; keywords and named arguments
  78. (stack
  79. ;; keywords inside Intent
  80. (start "intent\\s *?(" (dict . dict-f90-intent))
  81. ;; named arguments inside Open
  82. (start "open\\s *?(" (dict . dict-f90-open))
  83. ;; named arguments inside Close
  84. (start "close\\s *?(" (dict . dict-f90-close))
  85. ;; named arguments inside Read
  86. (start "read\\s *?(" (dict . dict-f90-read))
  87. ;; named arguments inside Write
  88. (start "write\\s *?(" (dict . dict-f90-write))
  89. ;; named arguments inside Rewind
  90. (start "rewind\\s *?(" (dict . dict-f90-rewind-backspace))
  91. ;; named arguments inside Backspace
  92. (start "backspace\\s *?(" (dict . dict-f90-rewind-backspace))
  93. ;; make sure all ('s are accounted for
  94. (start "(")
  95. (end ")"))
  96. )))
  97. t ; indicate succesful setup
  98. )
  99. ;;; predictive-f90.el ends here