annotate lisp/cedet/semantic/util-modes.el @ 105424:098f8a47a308

Fix typos in comments.
author Juanma Barranquero <lekktu@gmail.com>
date Sun, 04 Oct 2009 02:11:57 +0000
parents 5b8c8cd21526
children 83dde921cc1b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
104466
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
1 ;;; semantic/util-modes.el --- Semantic minor modes
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
2
105340
118ad0cdd9a8 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 105260
diff changeset
3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
118ad0cdd9a8 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 105260
diff changeset
4 ;; Free Software Foundation, Inc.
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
5
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
6 ;; Authors: Eric M. Ludlam <zappo@gnu.org>
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
7 ;; David Ponce <david@dponce.com>
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
8 ;; Keywords: syntax
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
9
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
11
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
14 ;; the Free Software Foundation, either version 3 of the License, or
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
15 ;; (at your option) any later version.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
16
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
20 ;; GNU General Public License for more details.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
21
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
24
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
25 ;;; Commentary:
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
26 ;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
27 ;; Semantic utility minor modes.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
28 ;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
29
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
30 ;;; Code:
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
31 (require 'semantic)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
32
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
33 ;;; Group for all semantic enhancing modes
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
34 (defgroup semantic-modes nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
35 "Minor modes associated with the Semantic architecture."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
36 :group 'semantic)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
37
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
38 ;;;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
39 ;;;; Semantic minor modes stuff
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
40 ;;;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
41 (defcustom semantic-update-mode-line t
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104517
diff changeset
42 "If non-nil, show enabled minor modes in the mode line.
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
43 Only minor modes that are not turned on globally are shown in the mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
44 line."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
45 :group 'semantic
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
46 :type 'boolean
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
47 :require 'semantic/util-modes
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
48 :initialize 'custom-initialize-default
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49 :set (lambda (sym val)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50 (set-default sym val)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
51 ;; Update status of all Semantic enabled buffers
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52 (semantic-map-buffers
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
53 #'semantic-mode-line-update)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
54
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
55 (defcustom semantic-mode-line-prefix
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104517
diff changeset
56 (propertize "S" 'face 'bold)
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104517
diff changeset
57 "Prefix added to minor mode indicators in the mode line."
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
58 :group 'semantic
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
59 :type 'string
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
60 :require 'semantic/util-modes
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
61 :initialize 'custom-initialize-default)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 (defvar semantic-minor-modes-status nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64 "String showing Semantic minor modes which are locally enabled.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
65 It is displayed in the mode line.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
66 (make-variable-buffer-local 'semantic-minor-modes-status)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
68 (defvar semantic-minor-mode-alist nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
69 "Alist saying how to show Semantic minor modes in the mode line.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70 Like variable `minor-mode-alist'.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
71
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
72 (defun semantic-mode-line-update ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
73 "Update display of Semantic minor modes in the mode line.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
74 Only minor modes that are locally enabled are shown in the mode line."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
75 (setq semantic-minor-modes-status nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
76 (if semantic-update-mode-line
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
77 (let ((ml semantic-minor-mode-alist)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
78 mm ms see)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
79 (while ml
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
80 (setq mm (car ml)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
81 ms (cadr mm)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
82 mm (car mm)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
83 ml (cdr ml))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
84 (when (and (symbol-value mm)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
85 ;; Only show local minor mode status
104513
a6a812dd2d88 * cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 104512
diff changeset
86 (not (memq mm semantic-init-hook)))
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
87 (and ms
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
88 (symbolp ms)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
89 (setq ms (symbol-value ms)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
90 (and (stringp ms)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
91 (not (member ms see)) ;; Don't duplicate same status
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
92 (setq see (cons ms see)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
93 ms (if (string-match "^[ ]*\\(.+\\)" ms)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
94 (match-string 1 ms)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
95 (setq semantic-minor-modes-status
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
96 (if semantic-minor-modes-status
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
97 (concat semantic-minor-modes-status "/" ms)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
98 ms)))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
99 (if semantic-minor-modes-status
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
100 (setq semantic-minor-modes-status
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
101 (concat
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
102 " "
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
103 (if (string-match "^[ ]*\\(.+\\)"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
104 semantic-mode-line-prefix)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
105 (match-string 1 semantic-mode-line-prefix)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
106 "S")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
107 "/"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
108 semantic-minor-modes-status))))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
109
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
110 (defun semantic-desktop-ignore-this-minor-mode (buffer)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
111 "Installed as a minor-mode initializer for Desktop mode.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
112 BUFFER is the buffer to not initialize a Semantic minor mode in."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
113 nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
114
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
115 (defun semantic-add-minor-mode (toggle name &optional keymap)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
116 "Register a new Semantic minor mode.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
117 TOGGLE is a symbol which is the name of a buffer-local variable that
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
118 is toggled on or off to say whether the minor mode is active or not.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
119 It is also an interactive function to toggle the mode.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
120
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
121 NAME specifies what will appear in the mode line when the minor mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
122 is active. NAME should be either a string starting with a space, or a
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
123 symbol whose value is such a string.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
124
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
125 Optional KEYMAP is the keymap for the minor mode that will be added to
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
126 `minor-mode-map-alist'."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
127 ;; Add a dymmy semantic minor mode to display the status
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
128 (or (assq 'semantic-minor-modes-status minor-mode-alist)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
129 (setq minor-mode-alist (cons (list 'semantic-minor-modes-status
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
130 'semantic-minor-modes-status)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
131 minor-mode-alist)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
132 (if (fboundp 'add-minor-mode)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
133 ;; Emacs 21 & XEmacs
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
134 (add-minor-mode toggle "" keymap)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
135 ;; Emacs 20
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
136 (or (assq toggle minor-mode-alist)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
137 (setq minor-mode-alist (cons (list toggle "") minor-mode-alist)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
138 (or (not keymap)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
139 (assq toggle minor-mode-map-alist)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
140 (setq minor-mode-map-alist (cons (cons toggle keymap)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
141 minor-mode-map-alist))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
142 ;; Record how to display this minor mode in the mode line
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
143 (let ((mm (assq toggle semantic-minor-mode-alist)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
144 (if mm
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
145 (setcdr mm (list name))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
146 (setq semantic-minor-mode-alist (cons (list toggle name)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
147 semantic-minor-mode-alist))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
148
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
149 ;; Semantic minor modes don't work w/ Desktop restore.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
150 ;; This line will disable this minor mode from being restored
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
151 ;; by Desktop.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
152 (when (boundp 'desktop-minor-mode-handlers)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
153 (add-to-list 'desktop-minor-mode-handlers
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
154 (cons toggle 'semantic-desktop-ignore-this-minor-mode)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
155 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
156
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
157 (defun semantic-toggle-minor-mode-globally (mode &optional arg)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
158 "Toggle minor mode MODE in every Semantic enabled buffer.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
159 Return non-nil if MODE is turned on in every Semantic enabled buffer.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
160 If ARG is positive, enable, if it is negative, disable. If ARG is
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
161 nil, then toggle. Otherwise do nothing. MODE must be a valid minor
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
162 mode defined in `minor-mode-alist' and must be too an interactive
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
163 function used to toggle the mode."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
164 (or (and (fboundp mode) (assq mode minor-mode-alist))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
165 (error "Semantic minor mode %s not found" mode))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
166 (if (not arg)
104513
a6a812dd2d88 * cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 104512
diff changeset
167 (if (memq mode semantic-init-hook)
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
168 (setq arg -1)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
169 (setq arg 1)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
170 ;; Add or remove the MODE toggle function from
104513
a6a812dd2d88 * cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 104512
diff changeset
171 ;; `semantic-init-hook'. Then turn MODE on or off in every
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
172 ;; Semantic enabled buffer.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
173 (cond
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
174 ;; Turn off if ARG < 0
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
175 ((< arg 0)
104513
a6a812dd2d88 * cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 104512
diff changeset
176 (remove-hook 'semantic-init-hook mode)
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
177 (semantic-map-buffers #'(lambda () (funcall mode -1)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
178 nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
179 ;; Turn on if ARG > 0
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
180 ((> arg 0)
104513
a6a812dd2d88 * cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 104512
diff changeset
181 (add-hook 'semantic-init-hook mode)
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
182 (semantic-map-buffers #'(lambda () (funcall mode 1)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
183 t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
184 ;; Otherwise just check MODE state
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
185 (t
104513
a6a812dd2d88 * cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 104512
diff changeset
186 (memq mode semantic-init-hook))
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
187 ))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
188
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
189 ;;;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
190 ;;;; Minor mode to highlight areas that a user edits.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
191 ;;;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
192
104466
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
193 ;;;###autoload
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
194 (defun global-semantic-highlight-edits-mode (&optional arg)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
195 "Toggle global use of option `semantic-highlight-edits-mode'.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
196 If ARG is positive, enable, if it is negative, disable.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
197 If ARG is nil, then toggle."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
198 (interactive "P")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
199 (setq global-semantic-highlight-edits-mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
200 (semantic-toggle-minor-mode-globally
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
201 'semantic-highlight-edits-mode arg)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
202
104466
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
203 ;;;###autoload
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
204 (defcustom global-semantic-highlight-edits-mode nil
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104517
diff changeset
205 "If non-nil enable global use of variable `semantic-highlight-edits-mode'.
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
206 When this mode is enabled, changes made to a buffer are highlighted
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
207 until the buffer is reparsed."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
208 :group 'semantic
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
209 :group 'semantic-modes
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
210 :type 'boolean
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
211 :require 'semantic/util-modes
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
212 :initialize 'custom-initialize-default
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
213 :set (lambda (sym val)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
214 (global-semantic-highlight-edits-mode (if val 1 -1))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
215
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
216 (defcustom semantic-highlight-edits-mode-hook nil
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104517
diff changeset
217 "Hook run at the end of function `semantic-highlight-edits-mode'."
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
218 :group 'semantic
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
219 :type 'hook)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
220
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
221 (defface semantic-highlight-edits-face
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
222 '((((class color) (background dark))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
223 ;; Put this back to something closer to black later.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
224 (:background "gray20"))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
225 (((class color) (background light))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
226 (:background "gray90")))
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104517
diff changeset
227 "Face used to show dirty tokens in `semantic-highlight-edits-mode'."
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
228 :group 'semantic-faces)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
229
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
230 (defun semantic-highlight-edits-new-change-hook-fcn (overlay)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
231 "Function set into `semantic-edits-new-change-hook'.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
232 Argument OVERLAY is the overlay created to mark the change.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
233 This function will set the face property on this overlay."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
234 (semantic-overlay-put overlay 'face 'semantic-highlight-edits-face))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
235
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
236 (defvar semantic-highlight-edits-mode-map
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
237 (let ((km (make-sparse-keymap)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
238 km)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
239 "Keymap for highlight-edits minor mode.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
240
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
241 (defvar semantic-highlight-edits-mode nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
242 "Non-nil if highlight-edits minor mode is enabled.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
243 Use the command `semantic-highlight-edits-mode' to change this variable.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
244 (make-variable-buffer-local 'semantic-highlight-edits-mode)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
245
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
246 (defun semantic-highlight-edits-mode-setup ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
247 "Setup option `semantic-highlight-edits-mode'.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
248 The minor mode can be turned on only if semantic feature is available
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
249 and the current buffer was set up for parsing. When minor mode is
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
250 enabled parse the current buffer if needed. Return non-nil if the
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
251 minor mode is enabled."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
252 (if semantic-highlight-edits-mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
253 (if (not (and (featurep 'semantic) (semantic-active-p)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
254 (progn
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
255 ;; Disable minor mode if semantic stuff not available
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
256 (setq semantic-highlight-edits-mode nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
257 (error "Buffer %s was not set up for parsing"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
258 (buffer-name)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
259 (semantic-make-local-hook 'semantic-edits-new-change-hooks)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
260 (add-hook 'semantic-edits-new-change-hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
261 'semantic-highlight-edits-new-change-hook-fcn nil t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
262 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
263 ;; Remove hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
264 (remove-hook 'semantic-edits-new-change-hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
265 'semantic-highlight-edits-new-change-hook-fcn t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
266 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
267 semantic-highlight-edits-mode)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
268
104466
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
269 ;;;###autoload
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
270 (defun semantic-highlight-edits-mode (&optional arg)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
271 "Minor mode for highlighting changes made in a buffer.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
272 Changes are tracked by semantic so that the incremental parser can work
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
273 properly.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
274 This mode will highlight those changes as they are made, and clear them
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
275 when the incremental parser accounts for those edits.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
276 With prefix argument ARG, turn on if positive, otherwise off. The
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
277 minor mode can be turned on only if semantic feature is available and
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
278 the current buffer was set up for parsing. Return non-nil if the
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
279 minor mode is enabled."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
280 (interactive
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
281 (list (or current-prefix-arg
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
282 (if semantic-highlight-edits-mode 0 1))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
283 (setq semantic-highlight-edits-mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
284 (if arg
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
285 (>
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
286 (prefix-numeric-value arg)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
287 0)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
288 (not semantic-highlight-edits-mode)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
289 (semantic-highlight-edits-mode-setup)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
290 (run-hooks 'semantic-highlight-edits-mode-hook)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
291 (if (interactive-p)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
292 (message "highlight-edits minor mode %sabled"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
293 (if semantic-highlight-edits-mode "en" "dis")))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
294 (semantic-mode-line-update)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
295 semantic-highlight-edits-mode)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
296
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
297 (semantic-add-minor-mode 'semantic-highlight-edits-mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
298 "e"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
299 semantic-highlight-edits-mode-map)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
300
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
301
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
302 ;;;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
303 ;;;; Minor mode to show unmatched-syntax elements
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
304 ;;;;
104466
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
305
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
306 ;;;###autoload
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
307 (defun global-semantic-show-unmatched-syntax-mode (&optional arg)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
308 "Toggle global use of option `semantic-show-unmatched-syntax-mode'.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
309 If ARG is positive, enable, if it is negative, disable.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
310 If ARG is nil, then toggle."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
311 (interactive "P")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
312 (setq global-semantic-show-unmatched-syntax-mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
313 (semantic-toggle-minor-mode-globally
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
314 'semantic-show-unmatched-syntax-mode arg)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
315
104466
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
316 ;;;###autoload
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
317 (defcustom global-semantic-show-unmatched-syntax-mode nil
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104517
diff changeset
318 "If non-nil, enable global use of `semantic-show-unmatched-syntax-mode'.
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
319 When this mode is enabled, syntax in the current buffer which the
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
320 semantic parser cannot match is highlighted with a red underline."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
321 :group 'semantic
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
322 :group 'semantic-modes
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
323 :type 'boolean
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
324 :require 'semantic/util-modes
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
325 :initialize 'custom-initialize-default
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
326 :set (lambda (sym val)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
327 (global-semantic-show-unmatched-syntax-mode (if val 1 -1))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
328
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
329 (defcustom semantic-show-unmatched-syntax-mode-hook nil
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104517
diff changeset
330 "Hook run at the end of function `semantic-show-unmatched-syntax-mode'."
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
331 :group 'semantic
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
332 :type 'hook)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
333
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
334 (defface semantic-unmatched-syntax-face
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
335 '((((class color) (background dark))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
336 (:underline "red"))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
337 (((class color) (background light))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
338 (:underline "red")))
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104517
diff changeset
339 "Face used to show unmatched syntax in.
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
340 The face is used in `semantic-show-unmatched-syntax-mode'."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
341 :group 'semantic-faces)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
342
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
343 (defsubst semantic-unmatched-syntax-overlay-p (overlay)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
344 "Return non-nil if OVERLAY is an unmatched syntax one."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
345 (eq (semantic-overlay-get overlay 'semantic) 'unmatched))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
346
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
347 (defun semantic-showing-unmatched-syntax-p ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
348 "Return non-nil if an unmatched syntax overlay was found in buffer."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
349 (let ((ol (semantic-overlays-in (point-min) (point-max)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
350 found)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
351 (while (and ol (not found))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
352 (setq found (semantic-unmatched-syntax-overlay-p (car ol))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
353 ol (cdr ol)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
354 found))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
355
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
356 (defun semantic-show-unmatched-lex-tokens-fetch ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
357 "Fetch a list of unmatched lexical tokens from the current buffer.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
358 Uses the overlays which have accurate bounds, and rebuilds what was
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
359 originally passed in."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
360 (let ((ol (semantic-overlays-in (point-min) (point-max)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
361 (ustc nil))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
362 (while ol
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
363 (if (semantic-unmatched-syntax-overlay-p (car ol))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
364 (setq ustc (cons (cons 'thing
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
365 (cons (semantic-overlay-start (car ol))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
366 (semantic-overlay-end (car ol))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
367 ustc)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
368 (setq ol (cdr ol)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
369 (nreverse ustc))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
370 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
371
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
372 (defun semantic-clean-unmatched-syntax-in-region (beg end)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
373 "Remove all unmatched syntax overlays between BEG and END."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
374 (let ((ol (semantic-overlays-in beg end)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
375 (while ol
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
376 (if (semantic-unmatched-syntax-overlay-p (car ol))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
377 (semantic-overlay-delete (car ol)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
378 (setq ol (cdr ol)))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
379
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
380 (defsubst semantic-clean-unmatched-syntax-in-buffer ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
381 "Remove all unmatched syntax overlays found in current buffer."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
382 (semantic-clean-unmatched-syntax-in-region
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
383 (point-min) (point-max)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
384
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
385 (defsubst semantic-clean-token-of-unmatched-syntax (token)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
386 "Clean the area covered by TOKEN of unmatched syntax markers."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
387 (semantic-clean-unmatched-syntax-in-region
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
388 (semantic-tag-start token) (semantic-tag-end token)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
389
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
390 (defun semantic-show-unmatched-syntax (syntax)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
391 "Function set into `semantic-unmatched-syntax-hook'.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
392 This will highlight elements in SYNTAX as unmatched syntax."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
393 ;; This is called when `semantic-show-unmatched-syntax-mode' is
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
394 ;; enabled. Highlight the unmatched syntax, and then add a semantic
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
395 ;; property to that overlay so we can add it to the official list of
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
396 ;; semantic supported overlays. This gets it cleaned up for errors,
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
397 ;; buffer cleaning, and the like.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
398 (semantic-clean-unmatched-syntax-in-buffer) ;Clear previous highlighting
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
399 (if syntax
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
400 (let (o)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
401 (while syntax
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
402 (setq o (semantic-make-overlay (semantic-lex-token-start (car syntax))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
403 (semantic-lex-token-end (car syntax))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
404 (semantic-overlay-put o 'semantic 'unmatched)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
405 (semantic-overlay-put o 'face 'semantic-unmatched-syntax-face)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
406 (setq syntax (cdr syntax))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
407 ))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
408
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
409 (defun semantic-next-unmatched-syntax (point &optional bound)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
410 "Find the next overlay for unmatched syntax after POINT.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
411 Do not search past BOUND if non-nil."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
412 (save-excursion
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
413 (goto-char point)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
414 (let ((os point) (ol nil))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
415 (while (and os (< os (or bound (point-max))) (not ol))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
416 (setq os (semantic-overlay-next-change os))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
417 (when os
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
418 ;; Get overlays at position
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
419 (setq ol (semantic-overlays-at os))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
420 ;; find the overlay that belongs to semantic
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
421 ;; and starts at the found position.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
422 (while (and ol (listp ol))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
423 (and (semantic-unmatched-syntax-overlay-p (car ol))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
424 (setq ol (car ol)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
425 (if (listp ol)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
426 (setq ol (cdr ol))))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
427 ol)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
428
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
429 (defvar semantic-show-unmatched-syntax-mode-map
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
430 (let ((km (make-sparse-keymap)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
431 (define-key km "\C-c,`" 'semantic-show-unmatched-syntax-next)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
432 km)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
433 "Keymap for command `semantic-show-unmatched-syntax-mode'.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
434
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
435 (defvar semantic-show-unmatched-syntax-mode nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
436 "Non-nil if show-unmatched-syntax minor mode is enabled.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
437 Use the command `semantic-show-unmatched-syntax-mode' to change this
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
438 variable.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
439 (make-variable-buffer-local 'semantic-show-unmatched-syntax-mode)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
440
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
441 (defun semantic-show-unmatched-syntax-mode-setup ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
442 "Setup the `semantic-show-unmatched-syntax' minor mode.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
443 The minor mode can be turned on only if semantic feature is available
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
444 and the current buffer was set up for parsing. When minor mode is
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
445 enabled parse the current buffer if needed. Return non-nil if the
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
446 minor mode is enabled."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
447 (if semantic-show-unmatched-syntax-mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
448 (if (not (and (featurep 'semantic) (semantic-active-p)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
449 (progn
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
450 ;; Disable minor mode if semantic stuff not available
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
451 (setq semantic-show-unmatched-syntax-mode nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
452 (error "Buffer %s was not set up for parsing"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
453 (buffer-name)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
454 ;; Add hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
455 (semantic-make-local-hook 'semantic-unmatched-syntax-hook)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
456 (add-hook 'semantic-unmatched-syntax-hook
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
457 'semantic-show-unmatched-syntax nil t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
458 (semantic-make-local-hook 'semantic-pre-clean-token-hooks)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
459 (add-hook 'semantic-pre-clean-token-hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
460 'semantic-clean-token-of-unmatched-syntax nil t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
461 ;; Show unmatched syntax elements
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
462 (if (not (semantic--umatched-syntax-needs-refresh-p))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
463 (semantic-show-unmatched-syntax
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
464 (semantic-unmatched-syntax-tokens))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
465 ;; Remove hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
466 (remove-hook 'semantic-unmatched-syntax-hook
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
467 'semantic-show-unmatched-syntax t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
468 (remove-hook 'semantic-pre-clean-token-hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
469 'semantic-clean-token-of-unmatched-syntax t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
470 ;; Cleanup unmatched-syntax highlighting
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
471 (semantic-clean-unmatched-syntax-in-buffer))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
472 semantic-show-unmatched-syntax-mode)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
473
104466
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
474 ;;;###autoload
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
475 (defun semantic-show-unmatched-syntax-mode (&optional arg)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
476 "Minor mode to highlight unmatched lexical syntax tokens.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
477 When a parser executes, some elements in the buffer may not match any
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
478 parser rules. These text characters are considered unmatched syntax.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
479 Often time, the display of unmatched syntax can expose coding
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
480 problems before the compiler is run.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
481
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
482 With prefix argument ARG, turn on if positive, otherwise off. The
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
483 minor mode can be turned on only if semantic feature is available and
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
484 the current buffer was set up for parsing. Return non-nil if the
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
485 minor mode is enabled.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
486
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
487 \\{semantic-show-unmatched-syntax-mode-map}"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
488 (interactive
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
489 (list (or current-prefix-arg
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
490 (if semantic-show-unmatched-syntax-mode 0 1))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
491 (setq semantic-show-unmatched-syntax-mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
492 (if arg
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
493 (>
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
494 (prefix-numeric-value arg)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
495 0)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
496 (not semantic-show-unmatched-syntax-mode)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
497 (semantic-show-unmatched-syntax-mode-setup)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
498 (run-hooks 'semantic-show-unmatched-syntax-mode-hook)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
499 (if (interactive-p)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
500 (message "show-unmatched-syntax minor mode %sabled"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
501 (if semantic-show-unmatched-syntax-mode "en" "dis")))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
502 (semantic-mode-line-update)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
503 semantic-show-unmatched-syntax-mode)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
504
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
505 (semantic-add-minor-mode 'semantic-show-unmatched-syntax-mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
506 "u"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
507 semantic-show-unmatched-syntax-mode-map)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
508
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
509 (defun semantic-show-unmatched-syntax-next ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
510 "Move forward to the next occurrence of unmatched syntax."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
511 (interactive)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
512 (let ((o (semantic-next-unmatched-syntax (point))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
513 (if o
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
514 (goto-char (semantic-overlay-start o)))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
515
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
516
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
517 ;;;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
518 ;;;; Minor mode to display the parser state in the modeline.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
519 ;;;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
520
104466
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
521 ;;;###autoload
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
522 (defcustom global-semantic-show-parser-state-mode nil
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104517
diff changeset
523 "If non-nil enable global use of `semantic-show-parser-state-mode'.
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
524 When enabled, the current parse state of the current buffer is displayed
105340
118ad0cdd9a8 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 105260
diff changeset
525 in the mode line. See `semantic-show-parser-state-marker' for details
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
526 on what is displayed."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
527 :group 'semantic
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
528 :type 'boolean
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
529 :require 'semantic/util-modes
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
530 :initialize 'custom-initialize-default
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
531 :set (lambda (sym val)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
532 (global-semantic-show-parser-state-mode (if val 1 -1))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
533
104466
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
534 ;;;###autoload
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
535 (defun global-semantic-show-parser-state-mode (&optional arg)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
536 "Toggle global use of option `semantic-show-parser-state-mode'.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
537 If ARG is positive, enable, if it is negative, disable.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
538 If ARG is nil, then toggle."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
539 (interactive "P")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
540 (setq global-semantic-show-parser-state-mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
541 (semantic-toggle-minor-mode-globally
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
542 'semantic-show-parser-state-mode arg)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
543
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
544 (defcustom semantic-show-parser-state-mode-hook nil
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104517
diff changeset
545 "Hook run at the end of function `semantic-show-parser-state-mode'."
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
546 :group 'semantic
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
547 :type 'hook)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
548
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
549 (defvar semantic-show-parser-state-mode-map
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
550 (let ((km (make-sparse-keymap)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
551 km)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
552 "Keymap for show-parser-state minor mode.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
553
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
554 (defvar semantic-show-parser-state-mode nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
555 "Non-nil if show-parser-state minor mode is enabled.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
556 Use the command `semantic-show-parser-state-mode' to change this variable.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
557 (make-variable-buffer-local 'semantic-show-parser-state-mode)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
558
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
559 (defun semantic-show-parser-state-mode-setup ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
560 "Setup option `semantic-show-parser-state-mode'.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
561 The minor mode can be turned on only if semantic feature is available
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
562 and the current buffer was set up for parsing. When minor mode is
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
563 enabled parse the current buffer if needed. Return non-nil if the
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
564 minor mode is enabled."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
565 (if semantic-show-parser-state-mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
566 (if (not (and (featurep 'semantic) (semantic-active-p)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
567 (progn
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
568 ;; Disable minor mode if semantic stuff not available
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
569 (setq semantic-show-parser-state-mode nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
570 (error "Buffer %s was not set up for parsing"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
571 (buffer-name)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
572 ;; Set up mode line
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
573
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
574 (when (not
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
575 (memq 'semantic-show-parser-state-string mode-line-modified))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
576 (setq mode-line-modified
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
577 (append mode-line-modified
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
578 '(semantic-show-parser-state-string))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
579 ;; Add hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
580 (semantic-make-local-hook 'semantic-edits-new-change-hooks)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
581 (add-hook 'semantic-edits-new-change-hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
582 'semantic-show-parser-state-marker nil t)
104517
beb4db733a34 * cedet/semantic/edit.el
Chong Yidong <cyd@stupidchicken.com>
parents: 104516
diff changeset
583 (semantic-make-local-hook 'semantic-edits-incremental-reparse-failed-hook)
beb4db733a34 * cedet/semantic/edit.el
Chong Yidong <cyd@stupidchicken.com>
parents: 104516
diff changeset
584 (add-hook 'semantic-edits-incremental-reparse-failed-hook
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
585 'semantic-show-parser-state-marker nil t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
586 (semantic-make-local-hook 'semantic-after-partial-cache-change-hook)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
587 (add-hook 'semantic-after-partial-cache-change-hook
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
588 'semantic-show-parser-state-marker nil t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
589 (semantic-make-local-hook 'semantic-after-toplevel-cache-change-hook)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
590 (add-hook 'semantic-after-toplevel-cache-change-hook
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
591 'semantic-show-parser-state-marker nil t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
592 (semantic-show-parser-state-marker)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
593
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
594 (semantic-make-local-hook 'semantic-before-auto-parse-hooks)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
595 (add-hook 'semantic-before-auto-parse-hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
596 'semantic-show-parser-state-auto-marker nil t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
597 (semantic-make-local-hook 'semantic-after-auto-parse-hooks)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
598 (add-hook 'semantic-after-auto-parse-hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
599 'semantic-show-parser-state-marker nil t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
600
104516
cd549f5a486b * cedet/semantic/util-modes.el
Chong Yidong <cyd@stupidchicken.com>
parents: 104513
diff changeset
601 (semantic-make-local-hook 'semantic-before-idle-scheduler-reparse-hook)
cd549f5a486b * cedet/semantic/util-modes.el
Chong Yidong <cyd@stupidchicken.com>
parents: 104513
diff changeset
602 (add-hook 'semantic-before-idle-scheduler-reparse-hook
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
603 'semantic-show-parser-state-auto-marker nil t)
104516
cd549f5a486b * cedet/semantic/util-modes.el
Chong Yidong <cyd@stupidchicken.com>
parents: 104513
diff changeset
604 (semantic-make-local-hook 'semantic-after-idle-scheduler-reparse-hook)
cd549f5a486b * cedet/semantic/util-modes.el
Chong Yidong <cyd@stupidchicken.com>
parents: 104513
diff changeset
605 (add-hook 'semantic-after-idle-scheduler-reparse-hook
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
606 'semantic-show-parser-state-marker nil t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
607 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
608 ;; Remove parts of mode line
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
609 (setq mode-line-modified
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
610 (delq 'semantic-show-parser-state-string mode-line-modified))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
611 ;; Remove hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
612 (remove-hook 'semantic-edits-new-change-hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
613 'semantic-show-parser-state-marker t)
104517
beb4db733a34 * cedet/semantic/edit.el
Chong Yidong <cyd@stupidchicken.com>
parents: 104516
diff changeset
614 (remove-hook 'semantic-edits-incremental-reparse-failed-hook
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
615 'semantic-show-parser-state-marker t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
616 (remove-hook 'semantic-after-partial-cache-change-hook
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
617 'semantic-show-parser-state-marker t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
618 (remove-hook 'semantic-after-toplevel-cache-change-hook
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
619 'semantic-show-parser-state-marker t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
620
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
621 (remove-hook 'semantic-before-auto-parse-hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
622 'semantic-show-parser-state-auto-marker t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
623 (remove-hook 'semantic-after-auto-parse-hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
624 'semantic-show-parser-state-marker t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
625
104516
cd549f5a486b * cedet/semantic/util-modes.el
Chong Yidong <cyd@stupidchicken.com>
parents: 104513
diff changeset
626 (remove-hook 'semantic-before-idle-scheduler-reparse-hook
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
627 'semantic-show-parser-state-auto-marker t)
104516
cd549f5a486b * cedet/semantic/util-modes.el
Chong Yidong <cyd@stupidchicken.com>
parents: 104513
diff changeset
628 (remove-hook 'semantic-after-idle-scheduler-reparse-hook
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
629 'semantic-show-parser-state-marker t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
630 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
631 semantic-show-parser-state-mode)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
632
104466
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
633 ;;;###autoload
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
634 (defun semantic-show-parser-state-mode (&optional arg)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
635 "Minor mode for displaying parser cache state in the modeline.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
636 The cache can be in one of three states. They are
105340
118ad0cdd9a8 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 105260
diff changeset
637 Up to date, Partial reparse needed, and Full reparse needed.
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
638 The state is indicated in the modeline with the following characters:
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
639 `-' -> The cache is up to date.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
640 `!' -> The cache requires a full update.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
641 `~' -> The cache needs to be incrementally parsed.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
642 `%' -> The cache is not currently parseable.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
643 `@' -> Auto-parse in progress (not set here.)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
644 With prefix argument ARG, turn on if positive, otherwise off. The
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
645 minor mode can be turned on only if semantic feature is available and
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
646 the current buffer was set up for parsing. Return non-nil if the
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
647 minor mode is enabled."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
648 (interactive
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
649 (list (or current-prefix-arg
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
650 (if semantic-show-parser-state-mode 0 1))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
651 (setq semantic-show-parser-state-mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
652 (if arg
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
653 (>
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
654 (prefix-numeric-value arg)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
655 0)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
656 (not semantic-show-parser-state-mode)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
657 (semantic-show-parser-state-mode-setup)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
658 (run-hooks 'semantic-show-parser-state-mode-hook)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
659 (if (interactive-p)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
660 (message "show-parser-state minor mode %sabled"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
661 (if semantic-show-parser-state-mode "en" "dis")))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
662 (semantic-mode-line-update)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
663 semantic-show-parser-state-mode)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
664
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
665 (semantic-add-minor-mode 'semantic-show-parser-state-mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
666 ""
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
667 semantic-show-parser-state-mode-map)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
668
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
669 (defvar semantic-show-parser-state-string nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
670 "String showing the parser state for this buffer.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
671 See `semantic-show-parser-state-marker' for details.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
672 (make-variable-buffer-local 'semantic-show-parser-state-string)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
673
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
674 (defun semantic-show-parser-state-marker (&rest ignore)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
675 "Set `semantic-show-parser-state-string' to indicate parser state.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
676 This marker is one of the following:
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
677 `-' -> The cache is up to date.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
678 `!' -> The cache requires a full update.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
679 `~' -> The cache needs to be incrementally parsed.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
680 `%' -> The cache is not currently parseable.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
681 `@' -> Auto-parse in progress (not set here.)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
682 Arguments IGNORE are ignored, and accepted so this can be used as a hook
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
683 in many situations."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
684 (setq semantic-show-parser-state-string
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
685 (cond ((semantic-parse-tree-needs-rebuild-p)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
686 "!")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
687 ((semantic-parse-tree-needs-update-p)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
688 "^")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
689 ((semantic-parse-tree-unparseable-p)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
690 "%")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
691 (t
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
692 "-")))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
693 ;;(message "Setup mode line indicator to [%s]" semantic-show-parser-state-string)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
694 (semantic-mode-line-update))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
695
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
696 (defun semantic-show-parser-state-auto-marker ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
697 "Hook function run before an autoparse.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
698 Set up `semantic-show-parser-state-marker' to show `@'
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
699 to indicate a parse in progress."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
700 (unless (semantic-parse-tree-up-to-date-p)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
701 (setq semantic-show-parser-state-string "@")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
702 (semantic-mode-line-update)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
703 ;; For testing.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
704 ;;(sit-for 1)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
705 ))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
706
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
707
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
708 ;;;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
709 ;;;; Minor mode to make function decls sticky.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
710 ;;;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
711
104466
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
712 ;;;###autoload
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
713 (defun global-semantic-stickyfunc-mode (&optional arg)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
714 "Toggle global use of option `semantic-stickyfunc-mode'.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
715 If ARG is positive, enable, if it is negative, disable.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
716 If ARG is nil, then toggle."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
717 (interactive "P")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
718 (setq global-semantic-stickyfunc-mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
719 (semantic-toggle-minor-mode-globally
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
720 'semantic-stickyfunc-mode arg)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
721
104466
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
722 ;;;###autoload
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
723 (defcustom global-semantic-stickyfunc-mode nil
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104517
diff changeset
724 "If non-nil, enable global use of `semantic-stickyfunc-mode'.
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
725 This minor mode only works for Emacs 21 or later.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
726 When enabled, the header line is enabled, and the first line
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
727 of the current function or method is displayed in it.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
728 This makes it appear that the first line of that tag is
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
729 `sticky' to the top of the window."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
730 :group 'semantic
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
731 :group 'semantic-modes
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
732 :type 'boolean
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
733 :require 'semantic/util-modes
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
734 :initialize 'custom-initialize-default
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
735 :set (lambda (sym val)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
736 (global-semantic-stickyfunc-mode (if val 1 -1))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
737
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
738 (defcustom semantic-stickyfunc-mode-hook nil
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104517
diff changeset
739 "Hook run at the end of function `semantic-stickyfunc-mode'."
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
740 :group 'semantic
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
741 :type 'hook)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
742
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
743 (defvar semantic-stickyfunc-mode-map
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
744 (let ((km (make-sparse-keymap)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
745 (define-key km [ header-line down-mouse-1 ] 'semantic-stickyfunc-menu)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
746 km)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
747 "Keymap for stickyfunc minor mode.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
748
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
749 (defvar semantic-stickyfunc-popup-menu nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
750 "Menu used if the user clicks on the header line used by stickyfunc mode.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
751
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
752 (easy-menu-define
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
753 semantic-stickyfunc-popup-menu
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
754 semantic-stickyfunc-mode-map
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
755 "Stickyfunc Menu"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
756 '("Stickyfunc Mode" :visible (progn nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
757 [ "Copy Headerline Tag" senator-copy-tag
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
758 :active (semantic-current-tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
759 :help "Copy the current tag to the tag ring"]
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
760 [ "Kill Headerline Tag" senator-kill-tag
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
761 :active (semantic-current-tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
762 :help "Kill tag text to the kill ring, and copy the tag to the tag ring"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
763 ]
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
764 [ "Copy Headerline Tag to Register" senator-copy-tag-to-register
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
765 :active (semantic-current-tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
766 :help "Copy the current tag to a register"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
767 ]
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
768 [ "Narrow To Headerline Tag" senator-narrow-to-defun
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
769 :active (semantic-current-tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
770 :help "Narrow to the bounds of the current tag."]
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
771 [ "Fold Headerline Tag" senator-fold-tag-toggle
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
772 :active (semantic-current-tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
773 :style toggle
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
774 :selected (let ((tag (semantic-current-tag)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
775 (and tag (semantic-tag-folded-p tag)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
776 :help "Fold the current tag to one line"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
777 ]
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
778 "---"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
779 [ "About This Header Line"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
780 (lambda () (interactive)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
781 (describe-function 'semantic-stickyfunc-mode)) t])
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
782 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
783
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
784 (defvar semantic-stickyfunc-mode nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
785 "Non-nil if stickyfunc minor mode is enabled.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
786 Use the command `semantic-stickyfunc-mode' to change this variable.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
787 (make-variable-buffer-local 'semantic-stickyfunc-mode)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
788
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
789 (defcustom semantic-stickyfunc-indent-string
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
790 (if (and window-system (not (featurep 'xemacs)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
791 (concat
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
792 (condition-case nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
793 ;; Test scroll bar location
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
794 (let ((charwidth (frame-char-width))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
795 (scrollpos (frame-parameter (selected-frame)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
796 'vertical-scroll-bars))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
797 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
798 (if (or (eq scrollpos 'left)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
799 ;; Now wait a minute. If you turn scroll-bar-mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
800 ;; on, then off, the new value is t, not left.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
801 ;; Will this mess up older emacs where the default
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
802 ;; was on the right? I don't think so since they don't
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
803 ;; support a header line.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
804 (eq scrollpos t))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
805 (let ((w (when (boundp 'scroll-bar-width)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
806 (symbol-value 'scroll-bar-width))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
807
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
808 (if (not w)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
809 (setq w (frame-parameter (selected-frame)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
810 'scroll-bar-width)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
811
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
812 ;; in 21.2, the frame parameter is sometimes empty
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
813 ;; so we need to get the value here.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
814 (if (not w)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
815 (setq w (+ (get 'scroll-bar-width 'x-frame-parameter)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
816 ;; In 21.4, or perhaps 22.1 the x-frame
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
817 ;; parameter is different from the frame
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
818 ;; parameter by only 1 pixel.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
819 1)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
820
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
821 (if (not w)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
822 " "
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
823 (setq w (+ 2 w)) ; Some sort of border around
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
824 ; the scrollbar.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
825 (make-string (/ w charwidth) ? )))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
826 ""))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
827 (error ""))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
828 (condition-case nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
829 ;; Test fringe size.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
830 (let* ((f (window-fringes))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
831 (fw (car f))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
832 (numspace (/ fw (frame-char-width)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
833 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
834 (make-string numspace ? ))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
835 (error
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
836 ;; Well, the fancy new Emacs functions failed. Try older
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
837 ;; tricks.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
838 (condition-case nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
839 ;; I'm not so sure what's up with the 21.1-21.3 fringe.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
840 ;; It looks to be about 1 space wide.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
841 (if (get 'fringe 'face)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
842 " "
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
843 "")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
844 (error ""))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
845 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
846 ;; Not Emacs or a window system means no scrollbar or fringe,
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
847 ;; and perhaps not even a header line to worry about.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
848 "")
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104517
diff changeset
849 "String used to indent the stickyfunc header.
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
850 Customize this string to match the space used by scrollbars and
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
851 fringe so it does not appear that the code is moving left/right
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
852 when it lands in the sticky line."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
853 :group 'semantic
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
854 :type 'string)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
855
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
856 (defvar semantic-stickyfunc-old-hlf nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
857 "Value of the header line when entering sticky func mode.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
858
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
859 (defconst semantic-stickyfunc-header-line-format
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
860 (cond ((featurep 'xemacs)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
861 nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
862 ((>= emacs-major-version 22)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
863 '(:eval (list
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
864 ;; Magic bit I found on emacswiki.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
865 (propertize " " 'display '((space :align-to 0)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
866 (semantic-stickyfunc-fetch-stickyline))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
867 ((= emacs-major-version 21)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
868 '(:eval (list semantic-stickyfunc-indent-string
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
869 (semantic-stickyfunc-fetch-stickyline))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
870 (t nil))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
871 "The header line format used by sticky func mode.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
872
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
873 (defun semantic-stickyfunc-mode-setup ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
874 "Setup option `semantic-stickyfunc-mode'.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
875 For semantic enabled buffers, make the function declaration for the top most
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
876 function \"sticky\". This is accomplished by putting the first line of
105406
5b8c8cd21526 * cedet/srecode/srt-mode.el (srecode-template-mode): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
877 text for that function in the header line."
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
878 (if semantic-stickyfunc-mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
879 (progn
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
880 (unless (and (featurep 'semantic) (semantic-active-p))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
881 ;; Disable minor mode if semantic stuff not available
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
882 (setq semantic-stickyfunc-mode nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
883 (error "Buffer %s was not set up for parsing" (buffer-name)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
884 (unless (boundp 'default-header-line-format)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
885 ;; Disable if there are no header lines to use.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
886 (setq semantic-stickyfunc-mode nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
887 (error "Sticky Function mode requires Emacs 21"))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
888 ;; Enable the mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
889 ;; Save previous buffer local value of header line format.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
890 (when (and (local-variable-p 'header-line-format (current-buffer))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
891 (not (eq header-line-format
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
892 semantic-stickyfunc-header-line-format)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
893 (set (make-local-variable 'semantic-stickyfunc-old-hlf)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
894 header-line-format))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
895 (setq header-line-format semantic-stickyfunc-header-line-format)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
896 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
897 ;; Disable sticky func mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
898 ;; Restore previous buffer local value of header line format if
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
899 ;; the current one is the sticky func one.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
900 (when (eq header-line-format semantic-stickyfunc-header-line-format)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
901 (kill-local-variable 'header-line-format)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
902 (when (local-variable-p 'semantic-stickyfunc-old-hlf (current-buffer))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
903 (setq header-line-format semantic-stickyfunc-old-hlf)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
904 (kill-local-variable 'semantic-stickyfunc-old-hlf))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
905 semantic-stickyfunc-mode)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
906
104466
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
907 ;;;###autoload
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
908 (defun semantic-stickyfunc-mode (&optional arg)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
909 "Minor mode to show the title of a tag in the header line.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
910 Enables/disables making the header line of functions sticky.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
911 A function (or other tag class specified by
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
912 `semantic-stickyfunc-sticky-classes') has a header line, meaning the
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
913 first line which describes the rest of the construct. This first
105406
5b8c8cd21526 * cedet/srecode/srt-mode.el (srecode-template-mode): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
914 line is what is displayed in the header line.
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
915
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
916 With prefix argument ARG, turn on if positive, otherwise off. The
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
917 minor mode can be turned on only if semantic feature is available and
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
918 the current buffer was set up for parsing. Return non-nil if the
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
919 minor mode is enabled."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
920 (interactive
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
921 (list (or current-prefix-arg
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
922 (if semantic-stickyfunc-mode 0 1))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
923 (setq semantic-stickyfunc-mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
924 (if arg
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
925 (>
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
926 (prefix-numeric-value arg)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
927 0)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
928 (not semantic-stickyfunc-mode)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
929 (semantic-stickyfunc-mode-setup)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
930 (run-hooks 'semantic-stickyfunc-mode-hook)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
931 (if (interactive-p)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
932 (message "Stickyfunc minor mode %sabled"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
933 (if semantic-stickyfunc-mode "en" "dis")))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
934 (semantic-mode-line-update)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
935 semantic-stickyfunc-mode)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
936
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
937 (defvar semantic-stickyfunc-sticky-classes
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
938 '(function type)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
939 "List of tag classes which sticky func will display in the header line.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
940 (make-variable-buffer-local 'semantic-stickyfunc-sticky-classes)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
941
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
942 (defun semantic-stickyfunc-tag-to-stick ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
943 "Return the tag to stick at the current point."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
944 (let ((tags (nreverse (semantic-find-tag-by-overlay (point)))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
945 ;; Get rid of non-matching tags.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
946 (while (and tags
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
947 (not (member
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
948 (semantic-tag-class (car tags))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
949 semantic-stickyfunc-sticky-classes))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
950 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
951 (setq tags (cdr tags)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
952 (car tags)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
953
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
954 (defun semantic-stickyfunc-fetch-stickyline ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
955 "Make the function at the top of the current window sticky.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
956 Capture it's function declaration, and place it in the header line.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
957 If there is no function, disable the header line."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
958 (let ((str
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
959 (save-excursion
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
960 (goto-char (window-start (selected-window)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
961 (forward-line -1)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
962 (end-of-line)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
963 ;; Capture this function
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
964 (let* ((tag (semantic-stickyfunc-tag-to-stick)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
965 ;; TAG is nil if there was nothing of the apropriate type there.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
966 (if (not tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
967 ;; Set it to be the text under the header line
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
968 (buffer-substring (point-at-bol) (point-at-eol))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
969 ;; Get it
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
970 (goto-char (semantic-tag-start tag))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
971 ;; Klaus Berndl <klaus.berndl@sdm.de>:
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
972 ;; goto the tag name; this is especially needed for languages
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
973 ;; like c++ where a often used style is like:
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
974 ;; void
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
975 ;; ClassX::methodM(arg1...)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
976 ;; {
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
977 ;; ...
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
978 ;; }
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
979 ;; Without going to the tag-name we would get"void" in the
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
980 ;; header line which is IMHO not really useful
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
981 (search-forward (semantic-tag-name tag) nil t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
982 (buffer-substring (point-at-bol) (point-at-eol))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
983 ))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
984 (start 0))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
985 (while (string-match "%" str start)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
986 (setq str (replace-match "%%" t t str 0)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
987 start (1+ (match-end 0)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
988 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
989 ;; In 21.4 (or 22.1) the heder doesn't expand tabs. Hmmmm.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
990 ;; We should replace them here.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
991 ;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
992 ;; This hack assumes that tabs are kept smartly at tab boundaries
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
993 ;; instead of in a tab boundary where it might only represent 4 spaces.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
994 (while (string-match "\t" str start)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
995 (setq str (replace-match " " t t str 0)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
996 str))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
997
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
998 (defun semantic-stickyfunc-menu (event)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
999 "Popup a menu that can help a user understand stickyfunc-mode.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1000 Argument EVENT describes the event that caused this function to be called."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1001 (interactive "e")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1002 (let* ((startwin (selected-window))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1003 (win (car (car (cdr event))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1004 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1005 (select-window win t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1006 (save-excursion
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1007 (goto-char (window-start win))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1008 (sit-for 0)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1009 (popup-menu semantic-stickyfunc-popup-menu event)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1010 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1011 (select-window startwin)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1012
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1013
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1014 (semantic-add-minor-mode 'semantic-stickyfunc-mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1015 "" ;; Don't need indicator. It's quite visible
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1016 semantic-stickyfunc-mode-map)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1017
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1018
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1019
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1020 ;;;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1021 ;;;; Minor mode to make highlight the current function
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1022 ;;;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1023
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1024 ;; Highlight the first like of the function we are in if it is different
105424
098f8a47a308 Fix typos in comments.
Juanma Barranquero <lekktu@gmail.com>
parents: 105406
diff changeset
1025 ;; from the tag going off the top of the screen.
104466
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
1026
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
1027 ;;;###autoload
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1028 (defun global-semantic-highlight-func-mode (&optional arg)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1029 "Toggle global use of option `semantic-highlight-func-mode'.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1030 If ARG is positive, enable, if it is negative, disable.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1031 If ARG is nil, then toggle."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1032 (interactive "P")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1033 (setq global-semantic-highlight-func-mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1034 (semantic-toggle-minor-mode-globally
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1035 'semantic-highlight-func-mode arg)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1036
104466
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
1037 ;;;###autoload
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1038 (defcustom global-semantic-highlight-func-mode nil
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104517
diff changeset
1039 "If non-nil, enable global use of `semantic-highlight-func-mode'.
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1040 When enabled, the first line of the current tag is highlighted."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1041 :group 'semantic
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1042 :group 'semantic-modes
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1043 :type 'boolean
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1044 :require 'semantic/util-modes
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1045 :initialize 'custom-initialize-default
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1046 :set (lambda (sym val)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1047 (global-semantic-highlight-func-mode (if val 1 -1))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1048
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1049 (defcustom semantic-highlight-func-mode-hook nil
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104517
diff changeset
1050 "Hook run at the end of function `semantic-highlight-func-mode'."
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1051 :group 'semantic
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1052 :type 'hook)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1053
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1054 (defvar semantic-highlight-func-mode-map
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1055 (let ((km (make-sparse-keymap))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1056 (m3 (if (featurep 'xemacs) [ button3 ] [ mouse-3 ]))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1057 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1058 (define-key km m3 'semantic-highlight-func-menu)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1059 km)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1060 "Keymap for highlight-func minor mode.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1061
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1062 (defvar semantic-highlight-func-popup-menu nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1063 "Menu used if the user clicks on the header line used by `semantic-highlight-func-mode'.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1064
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1065 (easy-menu-define
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1066 semantic-highlight-func-popup-menu
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1067 semantic-highlight-func-mode-map
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1068 "Highlight-Func Menu"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1069 '("Highlight-Func Mode" :visible (progn nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1070 [ "Copy Tag" senator-copy-tag
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1071 :active (semantic-current-tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1072 :help "Copy the current tag to the tag ring"]
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1073 [ "Kill Tag" senator-kill-tag
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1074 :active (semantic-current-tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1075 :help "Kill tag text to the kill ring, and copy the tag to the tag ring"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1076 ]
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1077 [ "Copy Tag to Register" senator-copy-tag-to-register
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1078 :active (semantic-current-tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1079 :help "Copy the current tag to a register"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1080 ]
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1081 [ "Narrow To Tag" senator-narrow-to-defun
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1082 :active (semantic-current-tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1083 :help "Narrow to the bounds of the current tag."]
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1084 [ "Fold Tag" senator-fold-tag-toggle
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1085 :active (semantic-current-tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1086 :style toggle
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1087 :selected (let ((tag (semantic-stickyfunc-tag-to-stick)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1088 (and tag (semantic-tag-folded-p tag)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1089 :help "Fold the current tag to one line"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1090 ]
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1091 "---"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1092 [ "About This Tag" semantic-describe-tag t])
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1093 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1094
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1095 (defun semantic-highlight-func-menu (event)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1096 "Popup a menu that displays things to do to the current tag.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1097 Argument EVENT describes the event that caused this function to be called."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1098 (interactive "e")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1099 (let* ((startwin (selected-window))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1100 (win (semantic-event-window event))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1101 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1102 (select-window win t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1103 (save-excursion
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1104 ;(goto-char (window-start win))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1105 (mouse-set-point event)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1106 (sit-for 0)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1107 (semantic-popup-menu semantic-highlight-func-popup-menu)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1108 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1109 (select-window startwin)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1110
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1111 (defvar semantic-highlight-func-mode nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1112 "Non-nil if highlight-func minor mode is enabled.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1113 Use the command `semantic-highlight-func-mode' to change this variable.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1114 (make-variable-buffer-local 'semantic-highlight-func-mode)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1115
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1116 (defvar semantic-highlight-func-ct-overlay nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1117 "Overlay used to highlight the tag the cursor is in.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1118 (make-variable-buffer-local 'semantic-highlight-func-ct-overlay)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1119
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1120 (defface semantic-highlight-func-current-tag-face
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1121 '((((class color) (background dark))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1122 ;; Put this back to something closer to black later.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1123 (:background "gray20"))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1124 (((class color) (background light))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1125 (:background "gray90")))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1126 "Face used to show the top of current function."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1127 :group 'semantic-faces)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1128
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1129
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1130 (defun semantic-highlight-func-mode-setup ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1131 "Setup option `semantic-highlight-func-mode'.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1132 For semantic enabled buffers, highlight the first line of the
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1133 current tag declaration."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1134 (if semantic-highlight-func-mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1135 (progn
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1136 (unless (and (featurep 'semantic) (semantic-active-p))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1137 ;; Disable minor mode if semantic stuff not available
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1138 (setq semantic-highlight-func-mode nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1139 (error "Buffer %s was not set up for parsing" (buffer-name)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1140 ;; Setup our hook
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1141 (add-hook 'post-command-hook 'semantic-highlight-func-highlight-current-tag nil t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1142 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1143 ;; Disable highlight func mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1144 (remove-hook 'post-command-hook 'semantic-highlight-func-highlight-current-tag t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1145 (semantic-highlight-func-highlight-current-tag t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1146 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1147 semantic-highlight-func-mode)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1148
104466
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
1149 ;;;###autoload
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1150 (defun semantic-highlight-func-mode (&optional arg)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1151 "Minor mode to highlight the first line of the current tag.
105406
5b8c8cd21526 * cedet/srecode/srt-mode.el (srecode-template-mode): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
1152 Enables/disables making the current function's first line light up.
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1153 A function (or other tag class specified by
104512
aa2a07e5db2f * cedet/semantic.el (semantic-parser-working-message): Use a less
Chong Yidong <cyd@stupidchicken.com>
parents: 104466
diff changeset
1154 `semantic-stickyfunc-sticky-classes') is highlighted, meaning the
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1155 first line which describes the rest of the construct.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1156
104512
aa2a07e5db2f * cedet/semantic.el (semantic-parser-working-message): Use a less
Chong Yidong <cyd@stupidchicken.com>
parents: 104466
diff changeset
1157 See `semantic-stickyfunc-mode' for putting a function in the
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1158 header line. This mode recycles the stickyfunc configuration
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1159 classes list.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1160
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1161 With prefix argument ARG, turn on if positive, otherwise off. The
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1162 minor mode can be turned on only if semantic feature is available and
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1163 the current buffer was set up for parsing. Return non-nil if the
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1164 minor mode is enabled."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1165 (interactive
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1166 (list (or current-prefix-arg
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1167 (if semantic-highlight-func-mode 0 1))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1168 (setq semantic-highlight-func-mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1169 (if arg
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1170 (>
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1171 (prefix-numeric-value arg)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1172 0)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1173 (not semantic-highlight-func-mode)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1174 (semantic-highlight-func-mode-setup)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1175 (run-hooks 'semantic-highlight-func-mode-hook)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1176 (if (interactive-p)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1177 (message "Highlight-Func minor mode %sabled"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1178 (if semantic-highlight-func-mode "en" "dis")))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1179 semantic-highlight-func-mode)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1180
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1181 (defun semantic-highlight-func-highlight-current-tag (&optional disable)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1182 "Highlight the current tag under point.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1183 Optional argument DISABLE will turn off any active highlight.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1184 If the current tag for this buffer is different from the last time this
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1185 function was called, move the overlay."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1186 (when (and (not (minibufferp))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1187 (or (not semantic-highlight-func-ct-overlay)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1188 (eq (semantic-overlay-buffer
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1189 semantic-highlight-func-ct-overlay)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1190 (current-buffer))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1191 (let* ((tag (semantic-stickyfunc-tag-to-stick))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1192 (ol semantic-highlight-func-ct-overlay))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1193 (when (not ol)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1194 ;; No overlay in this buffer. Make one.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1195 (setq ol (semantic-make-overlay (point-min) (point-min)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1196 (current-buffer) t nil))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1197 (semantic-overlay-put ol 'highlight-func t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1198 (semantic-overlay-put ol 'face 'semantic-highlight-func-current-tag-face)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1199 (semantic-overlay-put ol 'keymap semantic-highlight-func-mode-map)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1200 (semantic-overlay-put ol 'help-echo
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1201 "Current Function : mouse-3 - Context menu")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1202 (setq semantic-highlight-func-ct-overlay ol)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1203 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1204
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1205 ;; TAG is nil if there was nothing of the apropriate type there.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1206 (if (or (not tag) disable)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1207 ;; No tag, make the overlay go away.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1208 (progn
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1209 (semantic-overlay-put ol 'tag nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1210 (semantic-overlay-move ol (point-min) (point-min) (current-buffer))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1211 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1212
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1213 ;; We have a tag, if it is the same, do nothing.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1214 (unless (eq (semantic-overlay-get ol 'tag) tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1215 (save-excursion
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1216 (goto-char (semantic-tag-start tag))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1217 (search-forward (semantic-tag-name tag) nil t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1218 (semantic-overlay-put ol 'tag tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1219 (semantic-overlay-move ol (point-at-bol) (point-at-eol))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1220 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1221 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1222 )))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1223 nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1224
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1225 (semantic-add-minor-mode 'semantic-highlight-func-mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1226 "" ;; Don't need indicator. It's quite visible
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1227 nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1228
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1229 (provide 'semantic/util-modes)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1230
104466
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
1231 ;; Local variables:
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
1232 ;; generated-autoload-file: "loaddefs.el"
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
1233 ;; generated-autoload-feature: semantic/loaddefs
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
1234 ;; generated-autoload-load-name: "semantic/util-modes"
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
1235 ;; End:
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
1236
105377
7f4c7f5c0eba Add arch tagline
Miles Bader <miles@gnu.org>
parents: 105340
diff changeset
1237 ;; arch-tag: 18f5a3d8-1fd7-4c17-b149-a313c126987d
104466
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
1238 ;;; semantic/util-modes.el ends here