Mercurial > emacs
annotate lisp/cedet/semantic/mru-bookmark.el @ 106196:2721ecb2b07c
* cedet/semantic/ia.el (semantic-ia-completion-format-tag-function):
Use semantic-format-tag-prototype.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sun, 22 Nov 2009 23:09:17 +0000 |
parents | 83dde921cc1b |
children | 019d906c8f48 |
rev | line source |
---|---|
104507
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1 ;;; semantic/mru-bookmark.el --- Automatic bookmark tracking |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3 ;; Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
4 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com> |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
6 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
7 ;; This file is part of GNU Emacs. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
8 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
9 ;; GNU Emacs is free software: you can redistribute it and/or modify |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
10 ;; it under the terms of the GNU General Public License as published by |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
11 ;; the Free Software Foundation, either version 3 of the License, or |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
12 ;; (at your option) any later version. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
13 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
14 ;; GNU Emacs is distributed in the hope that it will be useful, |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
17 ;; GNU General Public License for more details. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
18 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
19 ;; You should have received a copy of the GNU General Public License |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
21 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
22 ;;; Commentary: |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
23 ;; |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
24 ;; Using editing hooks, track the most recently visited or poked tags, |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
25 ;; and keep a list of them, with the current point in from, and sorted |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
26 ;; by most recently used. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
27 ;; |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
28 ;; I envision this would be used in place of switch-buffers once |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
29 ;; someone got the hang of it. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
30 ;; |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
31 ;; I'd also like to see this used to provide some nice defaults for |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
32 ;; other programs where logical destinations or targets are the tags |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
33 ;; that have been recently edited. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
34 ;; |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
35 ;; Quick Start: |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
36 ;; |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
37 ;; M-x global-semantic-mru-bookmark-mode RET |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
38 ;; |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
39 ;; < edit some code > |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
40 ;; |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
41 ;; C-x B <select a tag name> RET |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
42 ;; |
105308 | 43 ;; In the above, the history is pre-filled with the tags you recently |
104507
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
44 ;; edited in the order you edited them. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
45 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
46 ;;; Code: |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
47 |
105652
51bc239bdc37
* cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
105377
diff
changeset
|
48 (eval-when-compile (require 'cl)) |
104507
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
49 (require 'semantic) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
50 (require 'eieio-base) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
51 (require 'ring) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
52 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
53 (declare-function data-debug-new-buffer "data-debug") |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
54 (declare-function data-debug-insert-object-slots "eieio-datadebug") |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
55 (declare-function semantic-momentary-highlight-tag "semantic/decorate") |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
56 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
57 ;;; TRACKING CORE |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
58 ;; |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
59 ;; Data structure for tracking MRU tag locations |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
60 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
61 (defclass semantic-bookmark (eieio-named) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
62 ((tag :initarg :tag |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
63 :type semantic-tag |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
64 :documentation "The TAG this bookmark belongs to.") |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
65 (parent :type (or semantic-tag null) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
66 :documentation "The tag that is the parent of :tag.") |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
67 (offset :type number |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
68 :documentation "The offset from `tag' start that is |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
69 somehow interesting.") |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
70 (filename :type string |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
71 :documentation "String the tag belongs to. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
72 Set this when the tag gets unlinked from the buffer it belongs to.") |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
73 (frequency :type number |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
74 :initform 0 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
75 :documentation "Track the frequency this tag is visited.") |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
76 (reason :type symbol |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
77 :initform t |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
78 :documentation |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
79 "The reason this tag is interesting. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
80 Nice values are 'edit, 'read, 'jump, and 'mark. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
81 edit - created because the tag text was edited. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
82 read - created because point lingered in tag text. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
83 jump - jumped to another tag from this tag. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
84 mark - created a regular mark in this tag.") |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
85 ) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
86 "A single bookmark.") |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
87 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
88 (defmethod initialize-instance :AFTER ((sbm semantic-bookmark) &rest fields) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
89 "Initialize the bookmark SBM with details about :tag." |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
90 (condition-case nil |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
91 (save-excursion |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
92 (oset sbm filename (semantic-tag-file-name (oref sbm tag))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
93 (semantic-go-to-tag (oref sbm tag)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
94 (oset sbm parent (semantic-current-tag-parent))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
95 (error (message "Error bookmarking tag."))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
96 ) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
97 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
98 (defmethod semantic-mrub-visit ((sbm semantic-bookmark)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
99 "Visit the semantic tag bookmark SBM. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
100 Uses `semantic-go-to-tag' and highlighting." |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
101 (require 'semantic/decorate) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
102 (with-slots (tag filename) sbm |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
103 ;; Go to the tag |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
104 (when (not (semantic-tag-in-buffer-p tag)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
105 (let ((fn (or (semantic-tag-file-name tag) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
106 filename))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
107 (set-buffer (find-file-noselect fn)))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
108 (semantic-go-to-tag (oref sbm tag) (oref sbm parent)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
109 ;; Go back to the offset. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
110 (condition-case nil |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
111 (let ((o (oref sbm offset))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
112 (forward-char o)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
113 (error nil)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
114 ;; make it visible |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
115 (switch-to-buffer (current-buffer)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
116 (semantic-momentary-highlight-tag tag) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
117 )) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
118 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
119 (defmethod semantic-mrub-update ((sbm semantic-bookmark) point reason) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
120 "Update the existing bookmark SBM. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
121 POINT is some important location. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
122 REASON is a symbol. See slot `reason' on `semantic-bookmark'." |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
123 (condition-case nil |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
124 (progn |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
125 (with-slots (tag offset frequency) sbm |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
126 (setq offset (- point (semantic-tag-start tag))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
127 (setq frequency (1+ frequency)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
128 ) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
129 (oset sbm reason reason)) |
105308 | 130 ;; This can fail on XEmacs at miscellaneous times. |
104507
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
131 (error nil)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
132 ) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
133 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
134 (defmethod semantic-mrub-preflush ((sbm semantic-bookmark)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
135 "Method called on a tag before the current buffer list of tags is flushed. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
136 If there is a buffer match, unlink the tag." |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
137 (let ((tag (oref sbm tag)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
138 (parent (when (slot-boundp sbm 'parent) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
139 (oref sbm parent)))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
140 (let ((b (semantic-tag-in-buffer-p tag))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
141 (when (and b (eq b (current-buffer))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
142 (semantic--tag-unlink-from-buffer tag))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
143 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
144 (when parent |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
145 (let ((b (semantic-tag-in-buffer-p parent))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
146 (when (and b (eq b (current-buffer))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
147 (semantic--tag-unlink-from-buffer parent)))))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
148 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
149 (defclass semantic-bookmark-ring () |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
150 ((ring :initarg :ring |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
151 :type ring |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
152 :documentation |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
153 "List of `semantic-bookmark' objects. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
154 This list is maintained as a list with the first item |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
155 being the current location, and the rest being a list of |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
156 items that were recently visited.") |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
157 (current-index :initform 0 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
158 :type number |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
159 :documentation |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
160 "The current index into RING for some operation. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
161 User commands use this to move through the ring, or reset.") |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
162 ) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
163 "Track the current MRU stack of bookmarks. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
164 We can't use the built-in ring data structure because we need |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
165 to delete some items from the ring when we don't have the data.") |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
166 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
167 (defvar semantic-mru-bookmark-ring (semantic-bookmark-ring |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
168 "Ring" |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
169 :ring (make-ring 20)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
170 "The MRU bookmark ring. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
171 This ring tracks the most recent active tags of interest.") |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
172 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
173 (defun semantic-mrub-find-nearby-tag (point) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
174 "Find a nearby tag to be pushed for this current location. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
175 Argument POINT is where to find the tag near." |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
176 ;; I thought this was a good idea, but it is not! |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
177 ;;(semantic-fetch-tags) ;; Make sure everything is up-to-date. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
178 (let ((tag (semantic-current-tag))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
179 (when (or (not tag) (semantic-tag-of-class-p tag 'type)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
180 (let ((nearby (or (semantic-find-tag-by-overlay-next point) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
181 (semantic-find-tag-by-overlay-prev point)))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
182 (when nearby (setq tag nearby)))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
183 tag)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
184 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
185 (defmethod semantic-mrub-push ((sbr semantic-bookmark-ring) point |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
186 &optional reason) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
187 "Add a bookmark to the ring SBR from POINT. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
188 REASON is why it is being pushed. See doc for `semantic-bookmark' |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
189 for possible reasons. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
190 The resulting bookmark is then sorted within the ring." |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
191 (let* ((ring (oref sbr ring)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
192 (tag (semantic-mrub-find-nearby-tag (point))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
193 (idx 0)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
194 (when tag |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
195 (while (and (not (ring-empty-p ring)) (< idx (ring-size ring))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
196 (if (semantic-tag-similar-p (oref (ring-ref ring idx) tag) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
197 tag) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
198 (ring-remove ring idx)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
199 (setq idx (1+ idx))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
200 ;; Create a new mark |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
201 (let ((sbm (semantic-bookmark (semantic-tag-name tag) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
202 :tag tag))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
203 ;; Take the mark, and update it for the current state. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
204 (ring-insert ring sbm) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
205 (semantic-mrub-update sbm point reason)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
206 ))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
207 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
208 (defun semantic-mrub-cache-flush-fcn () |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
209 "Function called in the `semantic-before-toplevel-cache-flush-hook`. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
210 Cause tags in the ring to become unlinked." |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
211 (let* ((ring (oref semantic-mru-bookmark-ring ring)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
212 (len (ring-length ring)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
213 (idx 0) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
214 ) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
215 (while (< idx len) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
216 (semantic-mrub-preflush (ring-ref ring idx)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
217 (setq idx (1+ idx))))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
218 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
219 (add-hook 'semantic-before-toplevel-cache-flush-hook |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
220 'semantic-mrub-cache-flush-fcn) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
221 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
222 ;;; EDIT tracker |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
223 ;; |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
224 (defvar semantic-mrub-last-overlay nil |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
225 "The last overlay bumped by `semantic-mru-bookmark-change-hook-fcn'.") |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
226 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
227 (defun semantic-mru-bookmark-change-hook-fcn (overlay) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
228 "Function set into `semantic-edits-new/move-change-hook's. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
229 Argument OVERLAY is the overlay created to mark the change. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
230 This function pushes tags onto the tag ring." |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
231 ;; Dup? |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
232 (when (not (eq overlay semantic-mrub-last-overlay)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
233 (setq semantic-mrub-last-overlay overlay) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
234 (semantic-mrub-push semantic-mru-bookmark-ring |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
235 (point) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
236 'edit))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
237 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
238 ;;; MINOR MODE |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
239 ;; |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
240 ;; Tracking minor mode. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
241 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
242 (defcustom global-semantic-mru-bookmark-mode nil |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
243 "*If non-nil enable global use of variable `semantic-mru-bookmark-mode'. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
244 When this mode is enabled, changes made to a buffer are highlighted |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
245 until the buffer is reparsed." |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
246 :group 'semantic |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
247 :group 'semantic-modes |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
248 :type 'boolean |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
249 :require 'semantic-util-modes |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
250 :initialize 'custom-initialize-default |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
251 :set (lambda (sym val) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
252 (global-semantic-mru-bookmark-mode (if val 1 -1)))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
253 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
254 ;;;###autoload |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
255 (defun global-semantic-mru-bookmark-mode (&optional arg) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
256 "Toggle global use of option `semantic-mru-bookmark-mode'. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
257 If ARG is positive, enable, if it is negative, disable. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
258 If ARG is nil, then toggle." |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
259 (interactive "P") |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
260 (setq global-semantic-mru-bookmark-mode |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
261 (semantic-toggle-minor-mode-globally |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
262 'semantic-mru-bookmark-mode arg))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
263 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
264 (defcustom semantic-mru-bookmark-mode-hook nil |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
265 "*Hook run at the end of function `semantic-mru-bookmark-mode'." |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
266 :group 'semantic |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
267 :type 'hook) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
268 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
269 (defvar semantic-mru-bookmark-mode-map |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
270 (let ((km (make-sparse-keymap))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
271 (define-key km "\C-xB" 'semantic-mrub-switch-tags) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
272 km) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
273 "Keymap for mru-bookmark minor mode.") |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
274 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
275 (defvar semantic-mru-bookmark-mode nil |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
276 "Non-nil if mru-bookmark minor mode is enabled. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
277 Use the command `semantic-mru-bookmark-mode' to change this variable.") |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
278 (make-variable-buffer-local 'semantic-mru-bookmark-mode) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
279 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
280 (defun semantic-mru-bookmark-mode-setup () |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
281 "Setup option `semantic-mru-bookmark-mode'. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
282 The minor mode can be turned on only if semantic feature is available |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
283 and the current buffer was set up for parsing. When minor mode is |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
284 enabled parse the current buffer if needed. Return non-nil if the |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
285 minor mode is enabled." |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
286 (if semantic-mru-bookmark-mode |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
287 (if (not (and (featurep 'semantic) (semantic-active-p))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
288 (progn |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
289 ;; Disable minor mode if semantic stuff not available |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
290 (setq semantic-mru-bookmark-mode nil) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
291 (error "Buffer %s was not set up for parsing" |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
292 (buffer-name))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
293 (semantic-make-local-hook 'semantic-edits-new-change-hooks) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
294 (add-hook 'semantic-edits-new-change-hooks |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
295 'semantic-mru-bookmark-change-hook-fcn nil t) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
296 (add-hook 'semantic-edits-move-change-hooks |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
297 'semantic-mru-bookmark-change-hook-fcn nil t) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
298 ) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
299 ;; Remove hooks |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
300 (remove-hook 'semantic-edits-new-change-hooks |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
301 'semantic-mru-bookmark-change-hook-fcn t) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
302 (remove-hook 'semantic-edits-move-change-hooks |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
303 'semantic-mru-bookmark-change-hook-fcn t) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
304 ) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
305 semantic-mru-bookmark-mode) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
306 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
307 (defun semantic-mru-bookmark-mode (&optional arg) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
308 "Minor mode for tracking tag-based bookmarks automatically. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
309 Tag based bookmarks a tracked based on editing and viewing habits |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
310 and can then be navigated via the MRU bookmark keymap. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
311 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
312 \\{semantic-mru-bookmark-mode-map} |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
313 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
314 With prefix argument ARG, turn on if positive, otherwise off. The |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
315 minor mode can be turned on only if semantic feature is available and |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
316 the current buffer was set up for parsing. Return non-nil if the |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
317 minor mode is enabled." |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
318 (interactive |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
319 (list (or current-prefix-arg |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
320 (if semantic-mru-bookmark-mode 0 1)))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
321 (setq semantic-mru-bookmark-mode |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
322 (if arg |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
323 (> |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
324 (prefix-numeric-value arg) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
325 0) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
326 (not semantic-mru-bookmark-mode))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
327 (semantic-mru-bookmark-mode-setup) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
328 (run-hooks 'semantic-mru-bookmark-mode-hook) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
329 (if (interactive-p) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
330 (message "mru-bookmark minor mode %sabled" |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
331 (if semantic-mru-bookmark-mode "en" "dis"))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
332 (semantic-mode-line-update) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
333 semantic-mru-bookmark-mode) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
334 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
335 (semantic-add-minor-mode 'semantic-mru-bookmark-mode |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
336 "k" |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
337 semantic-mru-bookmark-mode-map) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
338 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
339 ;;; COMPLETING READ |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
340 ;; |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
341 ;; Ask the user for a tag in MRU order. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
342 (defun semantic-mrub-read-history nil |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
343 "History of `semantic-mrub-completing-read'.") |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
344 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
345 (defun semantic-mrub-ring-to-assoc-list (ring) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
346 "Convert RING into an association list for completion." |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
347 (let ((idx 0) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
348 (len (ring-length ring)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
349 (al nil)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
350 (while (< idx len) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
351 (let ((r (ring-ref ring idx))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
352 (setq al (cons (cons (oref r :object-name) r) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
353 al))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
354 (setq idx (1+ idx))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
355 (nreverse al))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
356 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
357 (defun semantic-mrub-completing-read (prompt) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
358 "Do a `completing-read' on elements from the mru bookmark ring. |
105308 | 359 Argument PROMPT is the prompt to use when reading." |
104507
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
360 (if (ring-empty-p (oref semantic-mru-bookmark-ring ring)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
361 (error "Semantic Bookmark ring is currently empty")) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
362 (let* ((ring (oref semantic-mru-bookmark-ring ring)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
363 (ans nil) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
364 (alist (semantic-mrub-ring-to-assoc-list ring)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
365 (first (cdr (car alist))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
366 (semantic-mrub-read-history nil) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
367 ) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
368 ;; Don't include the current tag.. only those that come after. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
369 (if (semantic-equivalent-tag-p (oref first tag) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
370 (semantic-current-tag)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
371 (setq first (cdr (car (cdr alist))))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
372 ;; Create a fake history list so we don't have to bind |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
373 ;; M-p and M-n to our special cause. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
374 (let ((elts (reverse alist))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
375 (while elts |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
376 (setq semantic-mrub-read-history |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
377 (cons (car (car elts)) semantic-mrub-read-history)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
378 (setq elts (cdr elts)))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
379 (setq semantic-mrub-read-history (nreverse semantic-mrub-read-history)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
380 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
381 ;; Do the read/prompt |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
382 (let ((prompt (if first (format "%s (%s): " prompt |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
383 (semantic-format-tag-name |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
384 (oref first tag) t) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
385 ) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
386 (concat prompt ": "))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
387 ) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
388 (setq ans |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
389 (completing-read prompt alist nil nil nil 'semantic-mrub-read-history))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
390 ;; Calculate the return tag. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
391 (if (string= ans "") |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
392 (setq ans first) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
393 ;; Return the bookmark object. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
394 (setq ans (assoc ans alist)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
395 (if ans |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
396 (cdr ans) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
397 ;; no match. Custom word. Look it up somwhere? |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
398 nil) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
399 ))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
400 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
401 (defun semantic-mrub-switch-tags (tagmark) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
402 "Switch tags to TAGMARK. |
105308 | 403 Selects a new tag via prompt through the mru tag ring. |
104507
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
404 Jumps to the tag and highlights it briefly." |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
405 (interactive (list (semantic-mrub-completing-read "Switch to tag"))) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
406 (if (not (semantic-bookmark-p tagmark)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
407 (signal 'wrong-type-argument tagmark)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
408 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
409 (semantic-mrub-push semantic-mru-bookmark-ring |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
410 (point) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
411 'jump) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
412 (semantic-mrub-visit tagmark) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
413 ) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
414 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
415 ;;; Debugging |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
416 ;; |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
417 (defun semantic-adebug-mrub () |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
418 "Display a list of items in the MRU bookmarks list. |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
419 Useful for debugging mrub problems." |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
420 (interactive) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
421 (require 'eieio-datadebug) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
422 (let* ((out semantic-mru-bookmark-ring)) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
423 (data-debug-new-buffer "*TAG RING ADEBUG*") |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
424 (data-debug-insert-object-slots out "]") |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
425 )) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
426 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
427 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
428 (provide 'semantic/mru-bookmark) |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
429 |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
430 ;; Local variables: |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
431 ;; generated-autoload-file: "loaddefs.el" |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
432 ;; generated-autoload-load-name: "semantic/mru-bookmark" |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
433 ;; End: |
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
434 |
105377 | 435 ;; arch-tag: 297fa190-2942-460b-941d-f117db4e1fbf |
104507
51e316109fba
lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
436 ;;; semantic/mru-bookmark.el ends here |