annotate lisp/cedet/semantic/decorate.el @ 108116:8cf84fb217cc

merge trunk
author Kenichi Handa <handa@etlken>
date Mon, 26 Apr 2010 10:22:02 +0900
parents 1d1d5d9bd884
children a5ad4f188e19
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
104437
11587959f51d cedet/semantic/decorate.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
1 ;;; semantic/decorate.el --- Utilities for decorating/highlighting tokens.
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: 105377
diff changeset
3 ;;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2009, 2010
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
4 ;;; Free Software Foundation, Inc.
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 ;; Author: Eric M. Ludlam <zappo@gnu.org>
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
7 ;; Keywords: syntax
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
8
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
10
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
11 ;; 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
12 ;; 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
13 ;; 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
14 ;; (at your option) any later version.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
15
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
16 ;; 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
17 ;; 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
18 ;; 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
19 ;; GNU General Public License for more details.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
20
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
21 ;; 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
22 ;; 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
23
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
24 ;;; Commentary:
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
25 ;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
26 ;; Text representing a semantic tag is wrapped in an overlay.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
27 ;; This overlay can be used for highlighting, or setting other
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
28 ;; editing properties on a tag, such as "read only."
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
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
31 (require 'semantic)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
32 (require 'pulse)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
33
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
34 ;;; Code:
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
35
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
36 ;;; Highlighting Basics
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
37 (defun semantic-highlight-tag (tag &optional face)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
38 "Specify that TAG should be highlighted.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
39 Optional FACE specifies the face to use."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
40 (let ((o (semantic-tag-overlay tag)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
41 (semantic-overlay-put o 'old-face
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
42 (cons (semantic-overlay-get o 'face)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
43 (semantic-overlay-get o 'old-face)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
44 (semantic-overlay-put o 'face (or face 'semantic-tag-highlight-face))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
45 ))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
46
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
47 (defun semantic-unhighlight-tag (tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
48 "Unhighlight TAG, restoring it's previous face."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49 (let ((o (semantic-tag-overlay tag)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50 (semantic-overlay-put o 'face (car (semantic-overlay-get o 'old-face)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
51 (semantic-overlay-put o 'old-face (cdr (semantic-overlay-get o 'old-face)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52 ))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
53
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
54 ;;; Momentary Highlighting - One line
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
55 (defun semantic-momentary-highlight-one-tag-line (tag &optional face)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
56 "Highlight the first line of TAG, unhighlighting before next command.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
57 Optional argument FACE specifies the face to do the highlighting."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
58 (save-excursion
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
59 ;; Go to first line in tag
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
60 (semantic-go-to-tag tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
61 (pulse-momentary-highlight-one-line (point))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 ;;; Momentary Highlighting - Whole Tag
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64 (defun semantic-momentary-highlight-tag (tag &optional face)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
65 "Highlight TAG, removing highlighting when the user hits a key.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
66 Optional argument FACE is the face to use for highlighting.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67 If FACE is not specified, then `highlight' will be used."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
68 (when (semantic-tag-with-position-p tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
69 (if (not (semantic-overlay-p (semantic-tag-overlay tag)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70 ;; No overlay, but a position. Highlight the first line only.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
71 (semantic-momentary-highlight-one-tag-line tag face)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
72 ;; The tag has an overlay, highlight the whole thing
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
73 (pulse-momentary-highlight-overlay (semantic-tag-overlay tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
74 face)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
75 )))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
76
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
77 (defun semantic-set-tag-face (tag face)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
78 "Specify that TAG should use FACE for display."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
79 (semantic-overlay-put (semantic-tag-overlay tag) 'face face))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
80
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
81 (defun semantic-set-tag-invisible (tag &optional visible)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
82 "Enable the text in TAG to be made invisible.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
83 If VISIBLE is non-nil, make the text visible."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
84 (semantic-overlay-put (semantic-tag-overlay tag) 'invisible
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
85 (not visible)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
86
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
87 (defun semantic-tag-invisible-p (tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
88 "Return non-nil if TAG is invisible."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
89 (semantic-overlay-get (semantic-tag-overlay tag) 'invisible))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
90
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
91 (defun semantic-set-tag-intangible (tag &optional tangible)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
92 "Enable the text in TAG to be made intangible.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
93 If TANGIBLE is non-nil, make the text visible.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
94 This function does not have meaning in XEmacs because it seems that
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
95 the extent 'intangible' property does not exist."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
96 (semantic-overlay-put (semantic-tag-overlay tag) 'intangible
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
97 (not tangible)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
98
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
99 (defun semantic-tag-intangible-p (tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
100 "Return non-nil if TAG is intangible.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
101 This function does not have meaning in XEmacs because it seems that
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
102 the extent 'intangible' property does not exist."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
103 (semantic-overlay-get (semantic-tag-overlay tag) 'intangible))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
104
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
105 (defun semantic-overlay-signal-read-only
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
106 (overlay after start end &optional len)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
107 "Hook used in modification hooks to prevent modification.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
108 Allows deletion of the entire text.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
109 Argument OVERLAY, AFTER, START, END, and LEN are passed in by the system."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
110 ;; Stolen blithly from cpp.el in Emacs 21.1
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
111 (if (and (not after)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
112 (or (< (semantic-overlay-start overlay) start)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
113 (> (semantic-overlay-end overlay) end)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
114 (error "This text is read only")))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
115
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
116 (defun semantic-set-tag-read-only (tag &optional writable)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
117 "Enable the text in TAG to be made read-only.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
118 Optional argument WRITABLE should be non-nil to make the text writable
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
119 instead of read-only."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
120 (let ((o (semantic-tag-overlay tag))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
121 (hook (if writable nil '(semantic-overlay-signal-read-only))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
122 (if (featurep 'xemacs)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
123 ;; XEmacs extents have a 'read-only' property.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
124 (semantic-overlay-put o 'read-only (not writable))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
125 (semantic-overlay-put o 'modification-hooks hook)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
126 (semantic-overlay-put o 'insert-in-front-hooks hook)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
127 (semantic-overlay-put o 'insert-behind-hooks hook))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
128
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
129 (defun semantic-tag-read-only-p (tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
130 "Return non-nil if the current TAG is marked read only."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
131 (let ((o (semantic-tag-overlay tag)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
132 (if (featurep 'xemacs)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
133 ;; XEmacs extents have a 'read-only' property.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
134 (semantic-overlay-get o 'read-only)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
135 (member 'semantic-overlay-signal-read-only
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
136 (semantic-overlay-get o 'modification-hooks)))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
137
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
138 ;;; Secondary overlays
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
139 ;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
140 ;; Some types of decoration require a second overlay to be made.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
141 ;; It could be for images, arrows, or whatever.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
142 ;; We need a way to create such an overlay, and make sure it
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
143 ;; gets whacked, but doesn't show up in the master list
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
144 ;; of overlays used for searching.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
145 (defun semantic-tag-secondary-overlays (tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
146 "Return a list of secondary overlays active on TAG."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
147 (semantic--tag-get-property tag 'secondary-overlays))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
148
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
149 (defun semantic-tag-create-secondary-overlay (tag &optional link-hook)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
150 "Create a secondary overlay for TAG.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
151 Returns an overlay. The overlay is also saved in TAG.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
152 LINK-HOOK is a function called whenever TAG is to be linked into
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
153 a buffer. It should take TAG and OVERLAY as arguments.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
154 The LINK-HOOK should be used to position and set properties on the
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
155 generated secondary overlay."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
156 (if (not (semantic-tag-overlay tag))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
157 ;; do nothing if there is no overlay
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
158 nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
159 (let* ((os (semantic-tag-start tag))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
160 (oe (semantic-tag-end tag))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
161 (o (semantic-make-overlay os oe (semantic-tag-buffer tag) t))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
162 (attr (semantic-tag-secondary-overlays tag))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
163 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
164 (semantic--tag-put-property tag 'secondary-overlays (cons o attr))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
165 (semantic-overlay-put o 'semantic-secondary t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
166 (semantic-overlay-put o 'semantic-link-hook link-hook)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
167 (semantic-tag-add-hook tag 'link-hook 'semantic--tag-link-secondary-overlays)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
168 (semantic-tag-add-hook tag 'unlink-hook 'semantic--tag-unlink-secondary-overlays)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
169 (semantic-tag-add-hook tag 'unlink-copy-hook 'semantic--tag-unlink-copy-secondary-overlays)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
170 (run-hook-with-args link-hook tag o)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
171 o)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
172
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
173 (defun semantic-tag-get-secondary-overlay (tag property)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
174 "Return secondary overlays from TAG with PROPERTY.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
175 PROPERTY is a symbol and all overlays with that symbol are returned.."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
176 (let* ((olsearch (semantic-tag-secondary-overlays tag))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
177 (o nil))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
178 (while olsearch
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
179 (when (semantic-overlay-get (car olsearch) property)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
180 (setq o (cons (car olsearch) o)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
181 (setq olsearch (cdr olsearch)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
182 o))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
183
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
184 (defun semantic-tag-delete-secondary-overlay (tag overlay-or-property)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
185 "Delete from TAG the secondary overlay OVERLAY-OR-PROPERTY.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
186 If OVERLAY-OR-PROPERTY is an overlay, delete that overlay.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
187 If OVERLAY-OR-PROPERTY is a symbol, find the overlay with that property."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
188 (let* ((o overlay-or-property))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
189 (if (semantic-overlay-p o)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
190 (setq o (list o))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
191 (setq o (semantic-tag-get-secondary-overlay tag overlay-or-property)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
192 (while (semantic-overlay-p (car o))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
193 ;; We don't really need to worry about the hooks.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
194 ;; They will clean themselves up eventually ??
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
195 (semantic--tag-put-property
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
196 tag 'secondary-overlays
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
197 (delete (car o) (semantic-tag-secondary-overlays tag)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
198 (semantic-overlay-delete (car o))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
199 (setq o (cdr o)))))
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 (defun semantic--tag-unlink-copy-secondary-overlays (tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
202 "Unlink secondary overlays from TAG which is a copy.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
203 This means we don't destroy the overlays, only remove reference
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
204 from them in TAG."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
205 (let ((ol (semantic-tag-secondary-overlays tag)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
206 (while ol
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
207 ;; Else, remove all traces of ourself from the tag
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
208 ;; Note to self: Does this prevent multiple types of secondary
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
209 ;; overlays per tag?
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
210 (semantic-tag-remove-hook tag 'link-hook 'semantic--tag-link-secondary-overlays)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
211 (semantic-tag-remove-hook tag 'unlink-hook 'semantic--tag-unlink-secondary-overlays)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
212 (semantic-tag-remove-hook tag 'unlink-copy-hook 'semantic--tag-unlink-copy-secondary-overlays)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
213 ;; Next!
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
214 (setq ol (cdr ol)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
215 (semantic--tag-put-property tag 'secondary-overlays nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
216 ))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
217
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
218 (defun semantic--tag-unlink-secondary-overlays (tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
219 "Unlink secondary overlays from TAG."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
220 (let ((ol (semantic-tag-secondary-overlays tag))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
221 (nl nil))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
222 (while ol
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
223 (if (semantic-overlay-get (car ol) 'semantic-link-hook)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
224 ;; Only put in a proxy if there is a link-hook. If there is no link-hook
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
225 ;; the decorating mode must know when tags are unlinked on its own.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
226 (setq nl (cons (semantic-overlay-get (car ol) 'semantic-link-hook)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
227 nl))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
228 ;; Else, remove all traces of ourself from the tag
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
229 ;; Note to self: Does this prevent multiple types of secondary
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
230 ;; overlays per tag?
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
231 (semantic-tag-remove-hook tag 'link-hook 'semantic--tag-link-secondary-overlays)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
232 (semantic-tag-remove-hook tag 'unlink-hook 'semantic--tag-unlink-secondary-overlays)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
233 (semantic-tag-remove-hook tag 'unlink-copy-hook 'semantic--tag-unlink-copy-secondary-overlays)
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 (semantic-overlay-delete (car ol))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
236 (setq ol (cdr ol)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
237 (semantic--tag-put-property tag 'secondary-overlays (nreverse nl))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
238 ))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
239
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
240 (defun semantic--tag-link-secondary-overlays (tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
241 "Unlink secondary overlays from TAG."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
242 (let ((ol (semantic-tag-secondary-overlays tag)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
243 ;; Wipe out old values.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
244 (semantic--tag-put-property tag 'secondary-overlays nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
245 ;; Run all the link hooks.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
246 (while ol
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
247 (semantic-tag-create-secondary-overlay tag (car ol))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
248 (setq ol (cdr ol)))
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
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
251 ;;; Secondary Overlay Uses
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
252 ;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
253 ;; States to put on tags that depend on a secondary overlay.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
254 (defun semantic-set-tag-folded (tag &optional folded)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
255 "Fold TAG, such that only the first line of text is shown.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
256 Optional argument FOLDED should be non-nil to fold the tag.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
257 nil implies the tag should be fully shown."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
258 ;; If they are different, do the deed.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
259 (let ((o (semantic-tag-folded-p tag)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
260 (if (not folded)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
261 ;; We unfold.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
262 (when o
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
263 (semantic-tag-delete-secondary-overlay tag 'semantic-folded))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
264 (unless o
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
265 ;; Add the foldn
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
266 (setq o (semantic-tag-create-secondary-overlay tag))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
267 ;; mark as folded
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
268 (semantic-overlay-put o 'semantic-folded t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
269 ;; Move to cover end of tag
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
270 (save-excursion
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
271 (goto-char (semantic-tag-start tag))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
272 (end-of-line)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
273 (semantic-overlay-move o (point) (semantic-tag-end tag)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
274 ;; We need to modify the invisibility spec for this to
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
275 ;; work.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
276 (if (or (eq buffer-invisibility-spec t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
277 (not (assoc 'semantic-fold buffer-invisibility-spec)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
278 (add-to-invisibility-spec '(semantic-fold . t)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
279 (semantic-overlay-put o 'invisible 'semantic-fold)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
280 (overlay-put o 'isearch-open-invisible
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
281 'semantic-set-tag-folded-isearch)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
282 ))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
283
104442
b22b44e953cb cedet/semantic/chart.el: Don't require semantic/find.
Chong Yidong <cyd@stupidchicken.com>
parents: 104437
diff changeset
284 (declare-function semantic-current-tag "semantic/find")
b22b44e953cb cedet/semantic/chart.el: Don't require semantic/find.
Chong Yidong <cyd@stupidchicken.com>
parents: 104437
diff changeset
285
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
286 (defun semantic-set-tag-folded-isearch (overlay)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
287 "Called by isearch if it discovers text in the folded region.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
288 OVERLAY is passed in by isearch."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
289 (semantic-set-tag-folded (semantic-current-tag) nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
290 )
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 (defun semantic-tag-folded-p (tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
293 "Non-nil if TAG is currently folded."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
294 (semantic-tag-get-secondary-overlay tag 'semantic-folded)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
295 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
296
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
297 (provide 'semantic/decorate)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
298
105377
7f4c7f5c0eba Add arch tagline
Miles Bader <miles@gnu.org>
parents: 105260
diff changeset
299 ;; arch-tag: 30e5b6cb-dba0-41cd-920a-bc1dce267ad8
104437
11587959f51d cedet/semantic/decorate.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
300 ;;; semantic/decorate.el ends here