annotate lisp/cedet/semantic/util-modes.el @ 108211:73a1ddc06d0e

Use a mode-line spec rather than a static string in Semantic. * cedet/semantic/util-modes.el: (semantic-minor-modes-format): New var to replace... (semantic-minor-modes-status): Remove. (semantic-mode-line-update): Construct a mode-line spec rather than a static string so that mouse buttons can be used on individual minor modes and so that semantic-mode-line-update only needs to be called when global settings are changed. (semantic-add-minor-mode, semantic-toggle-minor-mode-globally): Call semantic-mode-line-update. (semantic-toggle-minor-mode-globally): Don't assume mode is on minor-mode-alist, check semantic-minor-mode-alist as well. (semantic-stickyfunc-mode, semantic-show-parser-state-auto-marker) (semantic-show-parser-state-marker, semantic-show-parser-state-mode) (semantic-show-unmatched-syntax-mode, semantic-highlight-edits-mode): * cedet/semantic/mru-bookmark.el (semantic-mru-bookmark-mode): * cedet/semantic/idle.el (semantic-idle-scheduler-mode) (define-semantic-idle-service, semantic-idle-summary-mode): * cedet/semantic/decorate/mode.el (semantic-decoration-mode): Don't call semantic-mode-line-update any more.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sun, 02 May 2010 01:06:53 -0400
parents 5143700578d0
children b799d38f522a
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
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 106197
diff changeset
3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
105340
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:
108211
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
31
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
32 ;; FIXME: compiling util-modes.el seems to require loading util-modes.el,
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
33 ;; so if the previous compilation generated a file that fails to load,
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
34 ;; recompiling fails to fix the problem.
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
35 (require 'semantic)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
36
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
37 ;;; Group for all semantic enhancing modes
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
38 (defgroup semantic-modes nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
39 "Minor modes associated with the Semantic architecture."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
40 :group 'semantic)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
41
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
42 ;;;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
43 ;;;; Semantic minor modes stuff
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
44 ;;;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
45 (defcustom semantic-update-mode-line t
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104517
diff changeset
46 "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
47 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
48 line."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49 :group 'semantic
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50 :type 'boolean
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
51 :require 'semantic/util-modes
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52 :initialize 'custom-initialize-default
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
53 :set (lambda (sym val)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
54 (set-default sym val)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
55 ;; Update status of all Semantic enabled buffers
108211
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
56 (semantic-mode-line-update)))
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
57
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
58 (defcustom semantic-mode-line-prefix
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104517
diff changeset
59 (propertize "S" 'face 'bold)
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104517
diff changeset
60 "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
61 :group 'semantic
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62 :type 'string
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 :require 'semantic/util-modes
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64 :initialize 'custom-initialize-default)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
65
108211
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
66 (defvar semantic-minor-modes-format nil
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
67 "Mode line format showing Semantic minor modes which are locally enabled.
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
68 It is displayed in the mode line.")
108211
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
69 (put 'semantic-minor-modes-format 'risky-local-variable t)
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
71 (defvar semantic-minor-mode-alist nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
72 "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
73 Like variable `minor-mode-alist'.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
74
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
75 (defun semantic-mode-line-update ()
108211
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
76 "Update mode line format of Semantic minor modes.
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
77 Only minor modes that are locally enabled are shown in the mode line."
108211
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
78 (setq semantic-minor-modes-format nil)
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
79 (dolist (x semantic-minor-mode-alist)
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
80 (setq minor-mode-alist (delq (assq (car x) minor-mode-alist)
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
81 minor-mode-alist)))
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
82 (when semantic-update-mode-line
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
83 (let ((locals '()))
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
84 ;; Select the minor modes that aren't enabled globally and who
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
85 ;; have a non-empty "name".
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
86 (dolist (x semantic-minor-mode-alist)
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
87 (unless (or (memq (car x) semantic-init-hook)
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
88 (not (string-match "^[ ]*\\(.+\\)" (cadr x))))
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
89 (push (list (car x) (concat "/" (match-string 1 (cadr x)))) locals)))
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
90 ;; Then build the format spec.
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
91 (when locals
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
92 (let ((prefix (if (string-match "^[ ]*\\(.+\\)"
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
93 semantic-mode-line-prefix)
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
94 (match-string 1 semantic-mode-line-prefix)
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
95 "S")))
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
96 (setq semantic-minor-modes-format
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
97 `((:eval (if (or ,@(mapcar 'car locals))
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
98 ,(concat " " prefix)))))
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
99 ;; It would be easier to just put `locals' inside
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
100 ;; semantic-minor-modes-format, but then things like
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
101 ;; mode-line-minor-mode-help can't find the right major mode
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
102 ;; any more. So instead, we carefully put the minor modes
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
103 ;; in minor-mode-alist.
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
104 (let* ((elem (or (assq 'semantic-minor-modes-format
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
105 minor-mode-alist)
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
106 ;; FIXME: This entry is meaningless for
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
107 ;; mode-line-minor-mode-help.
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
108 '(semantic-minor-modes-format
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
109 semantic-minor-modes-format)))
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
110 (tail (or (memq elem minor-mode-alist)
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
111 (setq minor-mode-alist
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
112 (cons elem minor-mode-alist)))))
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
113 (setcdr tail (nconc locals (cdr tail)))))))))
104414
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-desktop-ignore-this-minor-mode (buffer)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
116 "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
117 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
118 nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
119
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
120 (defun semantic-add-minor-mode (toggle name)
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
121 "Register a new Semantic minor mode.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
122 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
123 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
124 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
125
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
126 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
127 is active. NAME should be either a string starting with a space, or a
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
128 symbol whose value is such a string."
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
129 ;; 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
130 (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
131 (if mm
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
132 (setcdr mm (list name))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
133 (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
134 semantic-minor-mode-alist))))
108211
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
135 (semantic-mode-line-update)
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
136
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
137 ;; 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
138 ;; 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
139 ;; by Desktop.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
140 (when (boundp 'desktop-minor-mode-handlers)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
141 (add-to-list 'desktop-minor-mode-handlers
108211
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
142 (cons toggle 'semantic-desktop-ignore-this-minor-mode))))
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
143
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
144 (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
145 "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
146 Return non-nil if MODE is turned on in every Semantic enabled buffer.
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
147 If ARG is positive, enable, if it is negative, disable.
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
148 MODE must be a valid minor mode defined in `minor-mode-alist' and must be
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
149 too an interactive function used to toggle the mode."
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
150 ;; FIXME: All callers should pass a -1 or +1 argument.
108211
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
151 (or (and (fboundp mode) (or (assq mode minor-mode-alist) ;Needed?
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
152 (assq mode semantic-minor-mode-alist)))
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
153 (error "Semantic minor mode %s not found" mode))
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
154 ;; Add or remove the MODE toggle function from `semantic-init-hook'.
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
155 (cond
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
156 ;; Turn off if ARG < 0
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
157 ((< arg 0) (remove-hook 'semantic-init-hook mode))
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
158 ;; Turn on if ARG > 0
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
159 ((> arg 0) (add-hook 'semantic-init-hook mode))
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
160 ;; Otherwise just check MODE state
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
161 (t
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
162 (error "semantic-toggle-minor-mode-globally: arg should be -1 or 1")))
108211
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
163 ;; Update the minor mode format.
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
164 (semantic-mode-line-update)
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
165 ;; Then turn MODE on or off in every Semantic enabled buffer.
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
166 (semantic-map-buffers #'(lambda () (funcall mode arg))))
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
167
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
168 ;;;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
169 ;;;; 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
170 ;;;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
171
104466
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
172 ;;;###autoload
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
173 (define-minor-mode global-semantic-highlight-edits-mode
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
174 "Toggle global use of option `semantic-highlight-edits-mode'.
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
175 If ARG is positive or nil, enable, if it is negative, disable."
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
176 :global t :group 'semantic :group 'semantic-modes
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
177 (semantic-toggle-minor-mode-globally
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
178 'semantic-highlight-edits-mode
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
179 (if global-semantic-highlight-edits-mode 1 -1)))
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
180
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
181 (defcustom semantic-highlight-edits-mode-hook nil
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104517
diff changeset
182 "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
183 :group 'semantic
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
184 :type 'hook)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
185
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
186 (defface semantic-highlight-edits-face
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
187 '((((class color) (background dark))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
188 ;; 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
189 (:background "gray20"))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
190 (((class color) (background light))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
191 (:background "gray90")))
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104517
diff changeset
192 "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
193 :group 'semantic-faces)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
194
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
195 (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
196 "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
197 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
198 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
199 (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
200
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
201 (defvar semantic-highlight-edits-mode-map
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
202 (let ((km (make-sparse-keymap)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
203 km)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
204 "Keymap for highlight-edits minor mode.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
205
104466
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
206 ;;;###autoload
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
207 (define-minor-mode semantic-highlight-edits-mode
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
208 "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
209 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
210 properly.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
211 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
212 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
213 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
214 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
215 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
216 minor mode is enabled."
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
217 :keymap semantic-highlight-edits-mode-map
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
218 (if semantic-highlight-edits-mode
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
219 (if (not (and (featurep 'semantic) (semantic-active-p)))
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
220 (progn
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
221 ;; Disable minor mode if semantic stuff not available
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
222 (setq semantic-highlight-edits-mode nil)
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
223 (error "Buffer %s was not set up for parsing"
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
224 (buffer-name)))
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
225 (semantic-make-local-hook 'semantic-edits-new-change-hooks)
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
226 (add-hook 'semantic-edits-new-change-hooks
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
227 'semantic-highlight-edits-new-change-hook-fcn nil t))
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
228 ;; Remove hooks
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
229 (remove-hook 'semantic-edits-new-change-hooks
108211
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
230 'semantic-highlight-edits-new-change-hook-fcn t)))
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
231
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
232 (semantic-add-minor-mode 'semantic-highlight-edits-mode
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
233 "e")
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
234
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 ;;;; Minor mode to show unmatched-syntax elements
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
237 ;;;;
104466
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
238
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
239 ;;;###autoload
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
240 (define-minor-mode global-semantic-show-unmatched-syntax-mode
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
241 "Toggle global use of option `semantic-show-unmatched-syntax-mode'.
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
242 If ARG is positive or nil, enable, if it is negative, disable."
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
243 :global t :group 'semantic :group 'semantic-modes
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
244 ;; Not needed because it's autoloaded instead.
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
245 ;; :require 'semantic/util-modes
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
246 (semantic-toggle-minor-mode-globally
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
247 'semantic-show-unmatched-syntax-mode
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
248 (if global-semantic-show-unmatched-syntax-mode 1 -1)))
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
249
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
250 (defcustom semantic-show-unmatched-syntax-mode-hook nil
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104517
diff changeset
251 "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
252 :group 'semantic
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
253 :type 'hook)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
254
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
255 (defface semantic-unmatched-syntax-face
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
256 '((((class color) (background dark))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
257 (:underline "red"))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
258 (((class color) (background light))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
259 (:underline "red")))
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104517
diff changeset
260 "Face used to show unmatched syntax in.
106895
181539c8b6a4 Fix typos in docstrings, error messages, etc.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
261 The face is used in `semantic-show-unmatched-syntax-mode'."
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
262 :group 'semantic-faces)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
263
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
264 (defsubst semantic-unmatched-syntax-overlay-p (overlay)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
265 "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
266 (eq (semantic-overlay-get overlay 'semantic) 'unmatched))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
267
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
268 (defun semantic-showing-unmatched-syntax-p ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
269 "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
270 (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
271 found)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
272 (while (and ol (not found))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
273 (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
274 ol (cdr ol)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
275 found))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
276
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
277 (defun semantic-show-unmatched-lex-tokens-fetch ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
278 "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
279 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
280 originally passed in."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
281 (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
282 (ustc nil))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
283 (while ol
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
284 (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
285 (setq ustc (cons (cons 'thing
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
286 (cons (semantic-overlay-start (car ol))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
287 (semantic-overlay-end (car ol))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
288 ustc)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
289 (setq ol (cdr ol)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
290 (nreverse ustc))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
291 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
292
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
293 (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
294 "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
295 (let ((ol (semantic-overlays-in beg end)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
296 (while ol
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
297 (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
298 (semantic-overlay-delete (car ol)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
299 (setq ol (cdr ol)))))
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 (defsubst semantic-clean-unmatched-syntax-in-buffer ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
302 "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
303 (semantic-clean-unmatched-syntax-in-region
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
304 (point-min) (point-max)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
305
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
306 (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
307 "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
308 (semantic-clean-unmatched-syntax-in-region
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
309 (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
310
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
311 (defun semantic-show-unmatched-syntax (syntax)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
312 "Function set into `semantic-unmatched-syntax-hook'.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
313 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
314 ;; 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
315 ;; 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
316 ;; 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
317 ;; 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
318 ;; buffer cleaning, and the like.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
319 (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
320 (if syntax
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
321 (let (o)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
322 (while syntax
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
323 (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
324 (semantic-lex-token-end (car syntax))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
325 (semantic-overlay-put o 'semantic 'unmatched)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
326 (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
327 (setq syntax (cdr syntax))))
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
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
330 (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
331 "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
332 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
333 (save-excursion
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
334 (goto-char point)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
335 (let ((os point) (ol nil))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
336 (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
337 (setq os (semantic-overlay-next-change os))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
338 (when os
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
339 ;; Get overlays at position
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
340 (setq ol (semantic-overlays-at os))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
341 ;; find the overlay that belongs to semantic
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
342 ;; and starts at the found position.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
343 (while (and ol (listp ol))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
344 (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
345 (setq ol (car ol)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
346 (if (listp ol)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
347 (setq ol (cdr ol))))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
348 ol)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
349
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
350 (defvar semantic-show-unmatched-syntax-mode-map
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
351 (let ((km (make-sparse-keymap)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
352 (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
353 km)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
354 "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
355
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
356 ;;;###autoload
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
357 (define-minor-mode semantic-show-unmatched-syntax-mode
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
358 "Minor mode to highlight unmatched lexical syntax tokens.
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
359 When a parser executes, some elements in the buffer may not match any
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
360 parser rules. These text characters are considered unmatched syntax.
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
361 Often time, the display of unmatched syntax can expose coding
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
362 problems before the compiler is run.
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
363
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
364 With prefix argument ARG, turn on if positive, otherwise off. The
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
365 minor mode can be turned on only if semantic feature is available and
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
366 the current buffer was set up for parsing. Return non-nil if the
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
367 minor mode is enabled.
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
368
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
369 \\{semantic-show-unmatched-syntax-mode-map}"
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
370 :keymap semantic-show-unmatched-syntax-mode-map
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
371 (if semantic-show-unmatched-syntax-mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
372 (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
373 (progn
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
374 ;; 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
375 (setq semantic-show-unmatched-syntax-mode nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
376 (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
377 (buffer-name)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
378 ;; Add hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
379 (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
380 (add-hook 'semantic-unmatched-syntax-hook
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
381 'semantic-show-unmatched-syntax nil t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
382 (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
383 (add-hook 'semantic-pre-clean-token-hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
384 '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
385 ;; Show unmatched syntax elements
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
386 (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
387 (semantic-show-unmatched-syntax
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
388 (semantic-unmatched-syntax-tokens))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
389 ;; Remove hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
390 (remove-hook 'semantic-unmatched-syntax-hook
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
391 'semantic-show-unmatched-syntax t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
392 (remove-hook 'semantic-pre-clean-token-hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
393 'semantic-clean-token-of-unmatched-syntax t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
394 ;; Cleanup unmatched-syntax highlighting
108211
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
395 (semantic-clean-unmatched-syntax-in-buffer)))
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
396
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
397 (semantic-add-minor-mode 'semantic-show-unmatched-syntax-mode
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
398 "u")
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
399
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
400 (defun semantic-show-unmatched-syntax-next ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
401 "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
402 (interactive)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
403 (let ((o (semantic-next-unmatched-syntax (point))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
404 (if o
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
405 (goto-char (semantic-overlay-start o)))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
406
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 ;;;; 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
410 ;;;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
411
104466
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
412 ;;;###autoload
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
413 (define-minor-mode global-semantic-show-parser-state-mode
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
414 "Toggle global use of option `semantic-show-parser-state-mode'.
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
415 If ARG is positive or nil, enable, if it is negative, disable."
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
416 :global t :group 'semantic
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
417 ;; Not needed because it's autoloaded instead.
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
418 ;; :require 'semantic/util-modes
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
419 (semantic-toggle-minor-mode-globally
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
420 'semantic-show-parser-state-mode
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
421 (if global-semantic-show-parser-state-mode 1 -1)))
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
422
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
423 (defcustom semantic-show-parser-state-mode-hook nil
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104517
diff changeset
424 "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
425 :group 'semantic
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
426 :type 'hook)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
427
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
428 (defvar semantic-show-parser-state-mode-map
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
429 (let ((km (make-sparse-keymap)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
430 km)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
431 "Keymap for show-parser-state minor mode.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
432
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
433 ;;;###autoload
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
434 (define-minor-mode semantic-show-parser-state-mode
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
435 "Minor mode for displaying parser cache state in the modeline.
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
436 The cache can be in one of three states. They are
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
437 Up to date, Partial reparse needed, and Full reparse needed.
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
438 The state is indicated in the modeline with the following characters:
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
439 `-' -> The cache is up to date.
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
440 `!' -> The cache requires a full update.
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
441 `~' -> The cache needs to be incrementally parsed.
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
442 `%' -> The cache is not currently parseable.
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
443 `@' -> Auto-parse in progress (not set here.)
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
444 With prefix argument ARG, turn on if positive, otherwise off. The
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
445 minor mode can be turned on only if semantic feature is available and
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
446 the current buffer was set up for parsing. Return non-nil if the
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
447 minor mode is enabled."
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
448 :keymap semantic-show-parser-state-mode-map
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
449 (if semantic-show-parser-state-mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
450 (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
451 (progn
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
452 ;; 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
453 (setq semantic-show-parser-state-mode nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
454 (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
455 (buffer-name)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
456 ;; Set up mode line
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
457
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
458 (when (not
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
459 (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
460 (setq mode-line-modified
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
461 (append mode-line-modified
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
462 '(semantic-show-parser-state-string))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
463 ;; Add hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
464 (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
465 (add-hook 'semantic-edits-new-change-hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
466 'semantic-show-parser-state-marker nil t)
104517
beb4db733a34 * cedet/semantic/edit.el
Chong Yidong <cyd@stupidchicken.com>
parents: 104516
diff changeset
467 (semantic-make-local-hook 'semantic-edits-incremental-reparse-failed-hook)
beb4db733a34 * cedet/semantic/edit.el
Chong Yidong <cyd@stupidchicken.com>
parents: 104516
diff changeset
468 (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
469 'semantic-show-parser-state-marker nil t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
470 (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
471 (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
472 'semantic-show-parser-state-marker nil t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
473 (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
474 (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
475 'semantic-show-parser-state-marker nil t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
476 (semantic-show-parser-state-marker)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
477
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
478 (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
479 (add-hook 'semantic-before-auto-parse-hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
480 '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
481 (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
482 (add-hook 'semantic-after-auto-parse-hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
483 'semantic-show-parser-state-marker nil t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
484
104516
cd549f5a486b * cedet/semantic/util-modes.el
Chong Yidong <cyd@stupidchicken.com>
parents: 104513
diff changeset
485 (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
486 (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
487 'semantic-show-parser-state-auto-marker nil t)
104516
cd549f5a486b * cedet/semantic/util-modes.el
Chong Yidong <cyd@stupidchicken.com>
parents: 104513
diff changeset
488 (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
489 (add-hook 'semantic-after-idle-scheduler-reparse-hook
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
490 'semantic-show-parser-state-marker nil t))
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
491 ;; Remove parts of mode line
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
492 (setq mode-line-modified
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
493 (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
494 ;; Remove hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
495 (remove-hook 'semantic-edits-new-change-hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
496 'semantic-show-parser-state-marker t)
104517
beb4db733a34 * cedet/semantic/edit.el
Chong Yidong <cyd@stupidchicken.com>
parents: 104516
diff changeset
497 (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
498 'semantic-show-parser-state-marker t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
499 (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
500 'semantic-show-parser-state-marker t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
501 (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
502 'semantic-show-parser-state-marker t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
503
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
504 (remove-hook 'semantic-before-auto-parse-hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
505 'semantic-show-parser-state-auto-marker t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
506 (remove-hook 'semantic-after-auto-parse-hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
507 'semantic-show-parser-state-marker t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
508
104516
cd549f5a486b * cedet/semantic/util-modes.el
Chong Yidong <cyd@stupidchicken.com>
parents: 104513
diff changeset
509 (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
510 'semantic-show-parser-state-auto-marker t)
104516
cd549f5a486b * cedet/semantic/util-modes.el
Chong Yidong <cyd@stupidchicken.com>
parents: 104513
diff changeset
511 (remove-hook 'semantic-after-idle-scheduler-reparse-hook
108211
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
512 'semantic-show-parser-state-marker t)))
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
513
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
514 (semantic-add-minor-mode 'semantic-show-parser-state-mode
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
515 "")
104414
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 (defvar semantic-show-parser-state-string nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
518 "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
519 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
520 (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
521
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
522 (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
523 "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
524 This marker is one of the following:
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
525 `-' -> The cache is up to date.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
526 `!' -> The cache requires a full update.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
527 `~' -> The cache needs to be incrementally parsed.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
528 `%' -> The cache is not currently parseable.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
529 `@' -> Auto-parse in progress (not set here.)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
530 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
531 in many situations."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
532 (setq semantic-show-parser-state-string
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
533 (cond ((semantic-parse-tree-needs-rebuild-p)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
534 "!")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
535 ((semantic-parse-tree-needs-update-p)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
536 "^")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
537 ((semantic-parse-tree-unparseable-p)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
538 "%")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
539 (t
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
540 "-")))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
541 ;;(message "Setup mode line indicator to [%s]" semantic-show-parser-state-string)
108211
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
542 )
104414
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 (defun semantic-show-parser-state-auto-marker ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
545 "Hook function run before an autoparse.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
546 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
547 to indicate a parse in progress."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
548 (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
549 (setq semantic-show-parser-state-string "@")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
550 ;; For testing.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
551 ;;(sit-for 1)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
552 ))
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
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
555 ;;;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
556 ;;;; Minor mode to make function decls sticky.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
557 ;;;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
558
104466
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
559 ;;;###autoload
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
560 (define-minor-mode global-semantic-stickyfunc-mode
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
561 "Toggle global use of option `semantic-stickyfunc-mode'.
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
562 If ARG is positive or nil, enable, if it is negative, disable."
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
563 :global t :group 'semantic :group 'semantic-modes
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
564 ;; Not needed because it's autoloaded instead.
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
565 ;; :require 'semantic/util-modes
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
566 (semantic-toggle-minor-mode-globally
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
567 'semantic-stickyfunc-mode (if global-semantic-stickyfunc-mode 1 -1)))
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
568
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
569 (defcustom semantic-stickyfunc-mode-hook nil
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104517
diff changeset
570 "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
571 :group 'semantic
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
572 :type 'hook)
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 (defvar semantic-stickyfunc-mode-map
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
575 (let ((km (make-sparse-keymap)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
576 (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
577 km)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
578 "Keymap for stickyfunc minor mode.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
579
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
580 (defvar semantic-stickyfunc-popup-menu nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
581 "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
582
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
583 (easy-menu-define
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
584 semantic-stickyfunc-popup-menu
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
585 semantic-stickyfunc-mode-map
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
586 "Stickyfunc Menu"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
587 '("Stickyfunc Mode" :visible (progn nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
588 [ "Copy Headerline Tag" senator-copy-tag
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
589 :active (semantic-current-tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
590 :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
591 [ "Kill Headerline Tag" senator-kill-tag
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
592 :active (semantic-current-tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
593 :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
594 ]
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
595 [ "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
596 :active (semantic-current-tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
597 :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
598 ]
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
599 [ "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
600 :active (semantic-current-tag)
106895
181539c8b6a4 Fix typos in docstrings, error messages, etc.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
601 :help "Narrow to the bounds of the current tag"]
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
602 [ "Fold Headerline Tag" senator-fold-tag-toggle
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
603 :active (semantic-current-tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
604 :style toggle
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
605 :selected (let ((tag (semantic-current-tag)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
606 (and tag (semantic-tag-folded-p tag)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
607 :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
608 ]
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
609 "---"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
610 [ "About This Header Line"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
611 (lambda () (interactive)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
612 (describe-function 'semantic-stickyfunc-mode)) t])
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
613 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
614
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
615 (defcustom semantic-stickyfunc-indent-string
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
616 (if (and window-system (not (featurep 'xemacs)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
617 (concat
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
618 (condition-case nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
619 ;; Test scroll bar location
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
620 (let ((charwidth (frame-char-width))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
621 (scrollpos (frame-parameter (selected-frame)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
622 'vertical-scroll-bars))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
623 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
624 (if (or (eq scrollpos 'left)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
625 ;; 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
626 ;; 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
627 ;; 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
628 ;; 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
629 ;; support a header line.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
630 (eq scrollpos t))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
631 (let ((w (when (boundp 'scroll-bar-width)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
632 (symbol-value 'scroll-bar-width))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
633
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
634 (if (not w)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
635 (setq w (frame-parameter (selected-frame)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
636 'scroll-bar-width)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
637
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
638 ;; 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
639 ;; 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
640 (if (not w)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
641 (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
642 ;; 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
643 ;; parameter is different from the frame
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
644 ;; parameter by only 1 pixel.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
645 1)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
646
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
647 (if (not w)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
648 " "
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
649 (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
650 ; the scrollbar.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
651 (make-string (/ w charwidth) ? )))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
652 ""))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
653 (error ""))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
654 (condition-case nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
655 ;; Test fringe size.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
656 (let* ((f (window-fringes))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
657 (fw (car f))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
658 (numspace (/ fw (frame-char-width)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
659 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
660 (make-string numspace ? ))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
661 (error
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
662 ;; 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
663 ;; tricks.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
664 (condition-case nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
665 ;; 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
666 ;; 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
667 (if (get 'fringe 'face)
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 "")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
670 (error ""))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
671 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
672 ;; 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
673 ;; 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
674 "")
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104517
diff changeset
675 "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
676 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
677 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
678 when it lands in the sticky line."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
679 :group 'semantic
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
680 :type 'string)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
681
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
682 (defvar semantic-stickyfunc-old-hlf nil
106895
181539c8b6a4 Fix typos in docstrings, error messages, etc.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
683 "Value of the header line when entering stickyfunc mode.")
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
684
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
685 (defconst semantic-stickyfunc-header-line-format
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
686 (cond ((featurep 'xemacs)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
687 nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
688 ((>= emacs-major-version 22)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
689 '(:eval (list
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
690 ;; Magic bit I found on emacswiki.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
691 (propertize " " 'display '((space :align-to 0)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
692 (semantic-stickyfunc-fetch-stickyline))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
693 ((= emacs-major-version 21)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
694 '(:eval (list semantic-stickyfunc-indent-string
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
695 (semantic-stickyfunc-fetch-stickyline))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
696 (t nil))
106895
181539c8b6a4 Fix typos in docstrings, error messages, etc.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
697 "The header line format used by stickyfunc mode.")
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
698
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
699 ;;;###autoload
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
700 (define-minor-mode semantic-stickyfunc-mode
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
701 "Minor mode to show the title of a tag in the header line.
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
702 Enables/disables making the header line of functions sticky.
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
703 A function (or other tag class specified by
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
704 `semantic-stickyfunc-sticky-classes') has a header line, meaning the
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
705 first line which describes the rest of the construct. This first
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
706 line is what is displayed in the header line.
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
707
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
708 With prefix argument ARG, turn on if positive, otherwise off. The
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
709 minor mode can be turned on only if semantic feature is available and
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
710 the current buffer was set up for parsing. Return non-nil if the
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
711 minor mode is enabled."
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
712 ;; Don't need indicator. It's quite visible
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
713 :keymap semantic-stickyfunc-mode-map
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
714 (if semantic-stickyfunc-mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
715 (progn
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
716 (unless (and (featurep 'semantic) (semantic-active-p))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
717 ;; 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
718 (setq semantic-stickyfunc-mode nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
719 (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
720 (unless (boundp 'default-header-line-format)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
721 ;; 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
722 (setq semantic-stickyfunc-mode nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
723 (error "Sticky Function mode requires Emacs 21"))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
724 ;; Enable the mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
725 ;; 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
726 (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
727 (not (eq header-line-format
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
728 semantic-stickyfunc-header-line-format)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
729 (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
730 header-line-format))
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
731 (setq header-line-format semantic-stickyfunc-header-line-format))
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
732 ;; Disable sticky func mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
733 ;; 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
734 ;; 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
735 (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
736 (kill-local-variable 'header-line-format)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
737 (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
738 (setq header-line-format semantic-stickyfunc-old-hlf)
108211
73a1ddc06d0e Use a mode-line spec rather than a static string in Semantic.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108210
diff changeset
739 (kill-local-variable 'semantic-stickyfunc-old-hlf)))))
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
740
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
741 (defvar semantic-stickyfunc-sticky-classes
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
742 '(function type)
106895
181539c8b6a4 Fix typos in docstrings, error messages, etc.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
743 "List of tag classes which stickyfunc will display in the header line.")
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
744 (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
745
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
746 (defun semantic-stickyfunc-tag-to-stick ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
747 "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
748 (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
749 ;; Get rid of non-matching tags.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
750 (while (and tags
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
751 (not (member
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
752 (semantic-tag-class (car tags))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
753 semantic-stickyfunc-sticky-classes))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
754 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
755 (setq tags (cdr tags)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
756 (car tags)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
757
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
758 (defun semantic-stickyfunc-fetch-stickyline ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
759 "Make the function at the top of the current window sticky.
106895
181539c8b6a4 Fix typos in docstrings, error messages, etc.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
760 Capture its function declaration, and place it in the header line.
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
761 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
762 (let ((str
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
763 (save-excursion
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
764 (goto-char (window-start (selected-window)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
765 (forward-line -1)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
766 (end-of-line)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
767 ;; Capture this function
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
768 (let* ((tag (semantic-stickyfunc-tag-to-stick)))
106895
181539c8b6a4 Fix typos in docstrings, error messages, etc.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
769 ;; TAG is nil if there was nothing of the appropriate type there.
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
770 (if (not tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
771 ;; 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
772 (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
773 ;; Get it
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
774 (goto-char (semantic-tag-start tag))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
775 ;; Klaus Berndl <klaus.berndl@sdm.de>:
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
776 ;; 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
777 ;; 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
778 ;; void
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
779 ;; ClassX::methodM(arg1...)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
780 ;; {
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
781 ;; ...
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 ;; 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
784 ;; 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
785 (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
786 (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
787 ))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
788 (start 0))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
789 (while (string-match "%" str start)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
790 (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
791 start (1+ (match-end 0)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
792 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
793 ;; 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
794 ;; We should replace them here.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
795 ;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
796 ;; 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
797 ;; 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
798 (while (string-match "\t" str start)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
799 (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
800 str))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
801
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
802 (defun semantic-stickyfunc-menu (event)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
803 "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
804 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
805 (interactive "e")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
806 (let* ((startwin (selected-window))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
807 (win (car (car (cdr event))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
808 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
809 (select-window win t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
810 (save-excursion
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
811 (goto-char (window-start win))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
812 (sit-for 0)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
813 (popup-menu semantic-stickyfunc-popup-menu event)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
814 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
815 (select-window startwin)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
816
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
817
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
818 (semantic-add-minor-mode 'semantic-stickyfunc-mode
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
819 "") ;; Don't need indicator. It's quite visible
104414
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
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 ;;;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
824 ;;;; 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
825 ;;;;
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 ;; 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
828 ;; 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
829
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
830 ;;;###autoload
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
831 (define-minor-mode global-semantic-highlight-func-mode
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
832 "Toggle global use of option `semantic-highlight-func-mode'.
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
833 If ARG is positive or nil, enable, if it is negative, disable."
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
834 :global t :group 'semantic :group 'semantic-modes
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
835 ;; Not needed because it's autoloaded instead.
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
836 ;; :require 'semantic/util-modes
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
837 (semantic-toggle-minor-mode-globally
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
838 'semantic-highlight-func-mode
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
839 (if global-semantic-highlight-func-mode 1 -1)))
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
840
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
841 (defcustom semantic-highlight-func-mode-hook nil
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104517
diff changeset
842 "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
843 :group 'semantic
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
844 :type 'hook)
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 (defvar semantic-highlight-func-mode-map
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
847 (let ((km (make-sparse-keymap))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
848 (m3 (if (featurep 'xemacs) [ button3 ] [ mouse-3 ]))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
849 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
850 (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
851 km)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
852 "Keymap for highlight-func minor mode.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
853
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
854 (defvar semantic-highlight-func-popup-menu nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
855 "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
856
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
857 (easy-menu-define
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
858 semantic-highlight-func-popup-menu
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
859 semantic-highlight-func-mode-map
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
860 "Highlight-Func Menu"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
861 '("Highlight-Func Mode" :visible (progn nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
862 [ "Copy Tag" senator-copy-tag
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
863 :active (semantic-current-tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
864 :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
865 [ "Kill Tag" senator-kill-tag
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
866 :active (semantic-current-tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
867 :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
868 ]
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
869 [ "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
870 :active (semantic-current-tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
871 :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
872 ]
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
873 [ "Narrow To Tag" senator-narrow-to-defun
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
874 :active (semantic-current-tag)
106895
181539c8b6a4 Fix typos in docstrings, error messages, etc.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
875 :help "Narrow to the bounds of the current tag"]
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
876 [ "Fold Tag" senator-fold-tag-toggle
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
877 :active (semantic-current-tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
878 :style toggle
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
879 :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
880 (and tag (semantic-tag-folded-p tag)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
881 :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
882 ]
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
883 "---"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
884 [ "About This Tag" semantic-describe-tag t])
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
885 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
886
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
887 (defun semantic-highlight-func-menu (event)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
888 "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
889 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
890 (interactive "e")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
891 (let* ((startwin (selected-window))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
892 (win (semantic-event-window event))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
893 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
894 (select-window win t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
895 (save-excursion
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
896 ;(goto-char (window-start win))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
897 (mouse-set-point event)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
898 (sit-for 0)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
899 (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
900 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
901 (select-window startwin)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
902
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
903 (defvar semantic-highlight-func-ct-overlay nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
904 "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
905 (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
906
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
907 (defface semantic-highlight-func-current-tag-face
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
908 '((((class color) (background dark))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
909 ;; 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
910 (:background "gray20"))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
911 (((class color) (background light))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
912 (:background "gray90")))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
913 "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
914 :group 'semantic-faces)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
915
104466
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
916 ;;;###autoload
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
917 (define-minor-mode semantic-highlight-func-mode
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
918 "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
919 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
920 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
921 `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
922 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
923
104512
aa2a07e5db2f * cedet/semantic.el (semantic-parser-working-message): Use a less
Chong Yidong <cyd@stupidchicken.com>
parents: 104466
diff changeset
924 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
925 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
926 classes list.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
927
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
928 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
929 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
930 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
931 minor mode is enabled."
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
932 :lighter nil ;; Don't need indicator. It's quite visible.
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
933 (if semantic-highlight-func-mode
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
934 (progn
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
935 (unless (and (featurep 'semantic) (semantic-active-p))
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
936 ;; Disable minor mode if semantic stuff not available
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
937 (setq semantic-highlight-func-mode nil)
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
938 (error "Buffer %s was not set up for parsing" (buffer-name)))
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
939 ;; Setup our hook
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
940 (add-hook 'post-command-hook
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
941 'semantic-highlight-func-highlight-current-tag nil t))
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
942 ;; Disable highlight func mode
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
943 (remove-hook 'post-command-hook
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
944 'semantic-highlight-func-highlight-current-tag t)
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
945 (semantic-highlight-func-highlight-current-tag t)))
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
946
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
947 (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
948 "Highlight the current tag under point.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
949 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
950 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
951 function was called, move the overlay."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
952 (when (and (not (minibufferp))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
953 (or (not semantic-highlight-func-ct-overlay)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
954 (eq (semantic-overlay-buffer
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
955 semantic-highlight-func-ct-overlay)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
956 (current-buffer))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
957 (let* ((tag (semantic-stickyfunc-tag-to-stick))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
958 (ol semantic-highlight-func-ct-overlay))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
959 (when (not ol)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
960 ;; No overlay in this buffer. Make one.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
961 (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
962 (current-buffer) t nil))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
963 (semantic-overlay-put ol 'highlight-func t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
964 (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
965 (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
966 (semantic-overlay-put ol 'help-echo
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
967 "Current Function : mouse-3 - Context menu")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
968 (setq semantic-highlight-func-ct-overlay ol)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
969 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
970
106895
181539c8b6a4 Fix typos in docstrings, error messages, etc.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
971 ;; TAG is nil if there was nothing of the appropriate type there.
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
972 (if (or (not tag) disable)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
973 ;; No tag, make the overlay go away.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
974 (progn
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
975 (semantic-overlay-put ol 'tag nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
976 (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
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 ;; 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
980 (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
981 (save-excursion
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
982 (goto-char (semantic-tag-start tag))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
983 (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
984 (semantic-overlay-put ol 'tag tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
985 (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
986 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
987 )
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 nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
990
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
991 (semantic-add-minor-mode 'semantic-highlight-func-mode
108210
5143700578d0 Use define-minor-mode in CEDET where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106895
diff changeset
992 "") ;; Don't need indicator. It's quite visible
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
993
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
994 (provide 'semantic/util-modes)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
995
104466
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
996 ;; Local variables:
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
997 ;; 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
998 ;; 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
999 ;; End:
22e5fec9a17e lisp/cedet/semantic/util-modes.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
1000
105377
7f4c7f5c0eba Add arch tagline
Miles Bader <miles@gnu.org>
parents: 105340
diff changeset
1001 ;; 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
1002 ;;; semantic/util-modes.el ends here