/usr/share/emacs/site-lisp/cflow-mode.el is in cflow 1:1.4+dfsg1-2ubuntu1.
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 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | ;;; cflow.el --- major mode for viewing cflow output files.
;; Authors: 1994, 1995, 2005, 2007 Sergey Poznyakoff
;; Version: 0.2.1
;; Keywords: cflow
;; $Id$
;; This file is part of GNU cflow
;; Copyright (C) 1994, 1995, 2005, 2007, 2010 Sergey Poznyakoff
;; GNU cflow 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 3 of the License, or
;; (at your option) any later version.
;; GNU cflow 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 cflow; if not, write to the Free Software Foundation,
;; Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
;; Installation:
;; You may wish to use precompiled version of the module. To create it
;; run:
;; emacs -batch -f batch-byte-compile cflow-mode.el
;; Install the file cflow-mode.elc (and, optionally, cflow-mode.el) to
;; any directory in your Emacs load-path.
;; Customization:
;; To your .emacs or site-start.el add:
;; (autoload 'cflow-mode "cflow-mode")
;; (setq auto-mode-alist (append auto-mode-alist
;; '(("\\.cflow$" . cflow-mode))))
(eval-when-compile
;; We use functions from these modules
(mapcar 'require '(font-lock)))
(defvar cflow-mode-syntax-table nil
"Syntax table used in cflow-mode buffers.")
(unless cflow-mode-syntax-table
(setq cflow-mode-syntax-table (make-syntax-table))
(modify-syntax-entry ?\# "<" cflow-mode-syntax-table)
(modify-syntax-entry ?\n ">" cflow-mode-syntax-table))
(defvar cflow-mode-map (make-sparse-keymap)
"Keymap used in Cflow mode.")
(define-key cflow-mode-map "s" 'cflow-find-function)
(define-key cflow-mode-map "r" 'cflow-recursion-root)
(define-key cflow-mode-map "R" 'cflow-recursion-next)
(define-key cflow-mode-map "x" 'cflow-goto-expand)
(define-key cflow-mode-map "E" 'cflow-edit-out-full)
(define-key cflow-mode-map [menu-bar] (make-sparse-keymap))
(define-key cflow-mode-map [menu-bar cflow]
(cons "Cflow" (make-sparse-keymap "Cflow")))
(define-key cflow-mode-map [menu-bar cflow cflow-recursion-next]
'("Recursion next" . cflow-recursion-next))
(define-key cflow-mode-map [menu-bar cflow cflow-recursion-root]
'("Recursion root" . cflow-recursion-root))
(define-key cflow-mode-map [menu-bar cflow cflow-goto-expand]
'("Find expansion" . cflow-goto-expand))
(define-key cflow-mode-map [menu-bar cflow cflow-find-function]
'("Find function" . cflow-find-function))
;; Find the function under cursor.
;; Switch to the proper buffer and go to the function header
(defun cflow-find-function ()
(interactive)
(let ((lst (cflow-find-default-function)))
(cond
(lst
(switch-to-buffer (find-file-noselect (car lst)))
(goto-line (car (cdr lst))))
(t
(error "No source/line information for this function.")))))
;; Parse a cflow listing line
;; Return (list SOURCE-NAME LINE-NUMBER)
(defun cflow-find-default-function ()
(save-excursion
(beginning-of-line)
(cond
((re-search-forward "\\([^ \t:]+\\):\\([0-9]+\\)"
(save-excursion (end-of-line) (point))
t)
(list
(buffer-substring (match-beginning 1) (match-end 1))
(string-to-number
(buffer-substring (match-beginning 2) (match-end 2)))))
(t
nil))))
;; If the cursor stays on a recursive call, then go to the root of
;; this call
(defun cflow-recursion-root ()
(interactive)
(let ((num (cond
((save-excursion
(beginning-of-line)
(re-search-forward "(recursive: see \\([0-9]+\\))"
(save-excursion (end-of-line) (point))
t))
(string-to-number
(buffer-substring (match-beginning 1) (match-end 1))))
(t
0))))
(cond
((> num 0)
(push-mark)
(goto-line num))
(t
(error "Not a recursive call")))))
(defun cflow-recursion-next ()
"Go to next recursive call"
(interactive)
(save-excursion
(beginning-of-line)
(cond
((re-search-forward "(R)"
(save-excursion (end-of-line) (point)) t)
(setq cflow-recursion-root-line (count-lines 1 (point))))))
(cond
((null cflow-recursion-root-line)
(error "No recursive functions"))
(t
(let ((pos (save-excursion
(next-line 1)
(re-search-forward
(concat "(recursive: see "
(number-to-string cflow-recursion-root-line)
")")
(point-max)
t))))
(cond
((null pos)
(goto-line cflow-recursion-root-line)
(error "no more calls."))
(t
(push-mark)
(goto-char pos)
(beginning-of-line)))))))
(defun cflow-goto-expand ()
(interactive)
(let ((num (cond
((save-excursion
(beginning-of-line)
(re-search-forward "\\[see \\([0-9]+\\)\\]"
(save-excursion (end-of-line) (point))
t))
(string-to-number
(buffer-substring (match-beginning 1) (match-end 1))))
(t
0))))
(cond
((> num 0)
(push-mark)
(goto-line num))
(t
(error "not expandable")))))
(defvar cflow-read-only)
(defun cflow-edit-out-full ()
"Get out of Cflow mode, leaving Cflow file buffer in fundamental mode."
(interactive)
(if (yes-or-no-p "Should I let you edit the whole Cflow file? ")
(progn
(setq buffer-read-only cflow-read-only)
(fundamental-mode)
(message "Type 'M-x cflow-mode RET' once done"))))
;; Font-lock stuff
(defconst cflow-font-lock-keywords
(eval-when-compile
(list
(cons "^\\s *[0-9]+" font-lock-constant-face)
(list "\\(\\S +\\)()\\s +\\(<[^>]*>\\)"
'(1 font-lock-function-name-face)
'(2 font-lock-type-face))
(list "\\(\\S +\\)\\s +\\(<[^>]*>\\)"
'(1 font-lock-variable-name-face)
'(2 font-lock-type-face))
(cons "\\S +()$" font-lock-builtin-face)
(cons "(R):?$" font-lock-comment-face)
(cons "(recursive: see [0-9]+)" font-lock-comment-face)
(cons "^[ \\t+-|\\]+" font-lock-keyword-face))))
;;;###autoload
(defun cflow-mode ()
"Major mode for viewing cflow output files
Key bindings are:
\\{cflow-mode-map}
"
(interactive)
(kill-all-local-variables)
(use-local-map cflow-mode-map)
(setq major-mode 'cflow-mode
mode-name "Cflow")
(make-variable-buffer-local 'cflow-recursion-root-line)
(set (make-local-variable 'cflow-read-only) buffer-read-only)
(setq buffer-read-only t)
(set-default 'cflow-recursion-root-line nil)
(set-syntax-table cflow-mode-syntax-table)
(make-local-variable 'font-lock-defaults)
(setq font-lock-defaults
'((cflow-font-lock-keywords) nil t
(("+-*/.<>=!?$%_&~^:" . "w"))
beginning-of-line)))
(provide 'cflow-mode)
;;; cflow-mode ends
|