/usr/share/gerris/gfs-mode.el is in gerris-mpi 20110329-dfsg.2-1build2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | ;;; gfs-mode.el
;;; Copyright: (C) 2010 Stephane Popinet
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2 of
;; the License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; if not, write to the Free Software
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
;; 02110-1301 USA
;;
;; To use this package, you can save this file somewhere in your
;; load-path and put the following in your .emacs at a minimum:
;;
;; (require 'gfs-mode)
(define-derived-mode gfs-mode shell-script-mode "Gerris"
"Major mode for editing Gerris simulation files."
(require 'gfs-keywords)
(defvar gfs-browse-base "http://gfs.sourceforge.net/wiki/index.php/"
"First part of URL used to display documentation on the Gerris website.")
(defvar gfs-ref-regexp
(eval-when-compile
(concat "\\<" (regexp-opt gfs-abbrevs t) "\\>"))
"Regular expression compiled Gerris keywords.")
(defvar gfs-modules-regexp
(eval-when-compile
(concat "\\<" (regexp-opt gfs-modules t) "\\>"))
"Regular expression compiled Gerris modules.")
(define-key gfs-mode-map [mouse-2] 'gfs-mode-mouse-2)
(define-key gfs-mode-map [follow-link] 'mouse-face)
(defun gfs-clickable-refs (limit)
"Font-lock function which finds Gerris keywords and makes them clickable."
(if (re-search-forward (eval gfs-ref-regexp) limit t)
(progn
(add-text-properties (match-beginning 0) (match-end 0)
(list 'mouse-face 'highlight
'gfs-keyword (match-string 0)
'help-echo "mouse-2: documentation"
'rear-nonsticky '(mouse-face gfs-keyword help-echo)))
t)))
(defun gfs-clickable-modules (limit)
"Font-lock function which finds Gerris modules and makes them clickable."
(if (re-search-forward (eval gfs-modules-regexp) limit t)
(progn
(add-text-properties (match-beginning 0) (match-end 0)
(list 'mouse-face 'highlight
'gfs-module (match-string 0)
'help-echo "mouse-2: documentation"
'rear-nonsticky '(mouse-face gfs-module help-echo)))
t)))
(defun gfs-comments (limit)
"Font-lock function which finds Gerris comments."
(re-search-forward "#.*$" limit t))
(defconst gfs-font-lock-keywords
(list
'(gfs-clickable-refs (0 'font-lock-function-name-face t))
'(gfs-clickable-modules (0 'font-lock-type-face t))
'(gfs-comments (0 'font-lock-comment-face t)))
"Font-lock-keywords to be added when gfs-mode is active.")
(defun gfs-url-create (ref-string module)
"Returns REF-STRING without carriage returns and with spaces converted
to + signs, useful when creating a URL to lookup on the Gerris website."
(with-temp-buffer
(insert gfs-browse-base)
(if module
(progn
(insert "Object_hierarchy#")
(insert (capitalize ref-string)))
(progn
(unless (string= (substring ref-string 0 3) "Gfs")
(insert "Gfs"))
(insert ref-string)))
(buffer-string)))
(defun gfs-browse-reference (reference &optional module)
"Wrapper function to call standard Emacs browser function for REFERENCE."
(message "Linking to Gerris website for %s..." reference)
(browse-url (gfs-url-create reference module)))
(defun gfs-mode-mouse-2 (event arg)
"Fetch documentation for keyword under the mouse click."
(interactive "e\nP")
(let (my-keyword)
(save-excursion
(set-buffer (window-buffer (posn-window (event-end event))))
(goto-char (posn-point (event-end event)))
(setq my-keyword (get-text-property (point) 'gfs-keyword)))
(if my-keyword
(progn
(select-window (posn-window (event-end event)))
(gfs-browse-reference my-keyword))
(progn
(setq my-keyword (get-text-property (point) 'gfs-module))
(if my-keyword
(progn
(select-window (posn-window (event-end event)))
(gfs-browse-reference my-keyword t))
(mouse-yank-at-click event arg)
)))))
(font-lock-add-keywords nil gfs-font-lock-keywords)
;; load keywords for autocompletion with dabbrev
(find-file-noselect (locate-file "gfs-keywords.el" load-path) t)
(setq case-fold-search nil)
(column-number-mode 1)
)
(add-to-list 'auto-mode-alist '("\\.gfs\\'" . gfs-mode))
(provide 'gfs-mode)
|