annotate lisp/cedet/semantic/mru-bookmark.el @ 104507:51e316109fba

lisp/cedet/semantic/mru-bookmark.el: New file.
author Chong Yidong <cyd@stupidchicken.com>
date Mon, 21 Sep 2009 02:26:07 +0000
parents
children 32af6b5a433d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 ;;
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
43 ;; In the above, the history is pre-filled with the tags you recenetly
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
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
48 (require 'semantic)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49 (require 'eieio-base)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50 (require 'ring)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
51
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52 (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
53 (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
54 (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
55
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
56 ;;; TRACKING CORE
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
57 ;;
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
58 ;; Data structure for tracking MRU tag locations
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
59
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
60 (defclass semantic-bookmark (eieio-named)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
61 ((tag :initarg :tag
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62 :type semantic-tag
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 :documentation "The TAG this bookmark belongs to.")
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64 (parent :type (or semantic-tag null)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
65 :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
66 (offset :type number
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67 :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
68 somehow interesting.")
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
69 (filename :type string
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70 :documentation "String the tag belongs to.
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
71 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
72 (frequency :type number
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
73 :initform 0
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
74 :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
75 (reason :type symbol
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
76 :initform t
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
77 :documentation
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
78 "The reason this tag is interesting.
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
79 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
80 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
81 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
82 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
83 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
84 )
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
85 "A single bookmark.")
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
86
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
87 (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
88 "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
89 (condition-case nil
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
90 (save-excursion
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
91 (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
92 (semantic-go-to-tag (oref sbm tag))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
93 (oset sbm parent (semantic-current-tag-parent)))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
94 (error (message "Error bookmarking tag.")))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
95 )
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 (defmethod semantic-mrub-visit ((sbm semantic-bookmark))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
98 "Visit the semantic tag bookmark SBM.
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
99 Uses `semantic-go-to-tag' and highlighting."
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
100 (require 'semantic/decorate)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
101 (with-slots (tag filename) sbm
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
102 ;; Go to the tag
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
103 (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
104 (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
105 filename)))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
106 (set-buffer (find-file-noselect fn))))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
107 (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
108 ;; Go back to the offset.
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
109 (condition-case nil
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
110 (let ((o (oref sbm offset)))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
111 (forward-char o))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
112 (error nil))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
113 ;; make it visible
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
114 (switch-to-buffer (current-buffer))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
115 (semantic-momentary-highlight-tag tag)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
116 ))
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 (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
119 "Update the existing bookmark SBM.
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
120 POINT is some important location.
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
121 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
122 (condition-case nil
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
123 (progn
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
124 (with-slots (tag offset frequency) sbm
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
125 (setq offset (- point (semantic-tag-start tag)))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
126 (setq frequency (1+ frequency))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
127 )
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
128 (oset sbm reason reason))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
129 ;; This can fail on XEmacs at miscelaneous times.
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
130 (error nil))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
131 )
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 (defmethod semantic-mrub-preflush ((sbm semantic-bookmark))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
134 "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
135 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
136 (let ((tag (oref sbm tag))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
137 (parent (when (slot-boundp sbm 'parent)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
138 (oref sbm parent))))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
139 (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
140 (when (and b (eq b (current-buffer)))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
141 (semantic--tag-unlink-from-buffer tag)))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
142
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
143 (when parent
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
144 (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
145 (when (and b (eq b (current-buffer)))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
146 (semantic--tag-unlink-from-buffer parent))))))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
147
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
148 (defclass semantic-bookmark-ring ()
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
149 ((ring :initarg :ring
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
150 :type ring
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
151 :documentation
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
152 "List of `semantic-bookmark' objects.
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
153 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
154 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
155 items that were recently visited.")
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
156 (current-index :initform 0
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
157 :type number
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
158 :documentation
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
159 "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
160 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
161 )
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
162 "Track the current MRU stack of bookmarks.
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
163 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
164 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
165
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
166 (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
167 "Ring"
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
168 :ring (make-ring 20))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
169 "The MRU bookmark ring.
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
170 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
171
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
172 (defun semantic-mrub-find-nearby-tag (point)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
173 "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
174 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
175 ;; 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
176 ;;(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
177 (let ((tag (semantic-current-tag)))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
178 (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
179 (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
180 (semantic-find-tag-by-overlay-prev point))))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
181 (when nearby (setq tag nearby))))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
182 tag))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
183
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
184 (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
185 &optional reason)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
186 "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
187 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
188 for possible reasons.
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
189 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
190 (let* ((ring (oref sbr ring))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
191 (tag (semantic-mrub-find-nearby-tag (point)))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
192 (idx 0))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
193 (when tag
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
194 (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
195 (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
196 tag)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
197 (ring-remove ring idx))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
198 (setq idx (1+ idx)))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
199 ;; Create a new mark
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
200 (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
201 :tag tag)))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
202 ;; 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
203 (ring-insert ring sbm)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
204 (semantic-mrub-update sbm point reason))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
205 )))
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 (defun semantic-mrub-cache-flush-fcn ()
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
208 "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
209 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
210 (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
211 (len (ring-length ring))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
212 (idx 0)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
213 )
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
214 (while (< idx len)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
215 (semantic-mrub-preflush (ring-ref ring idx))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
216 (setq idx (1+ idx)))))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
217
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
218 (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
219 'semantic-mrub-cache-flush-fcn)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
220
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
221 ;;; EDIT tracker
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
222 ;;
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
223 (defvar semantic-mrub-last-overlay nil
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
224 "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
225
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
226 (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
227 "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
228 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
229 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
230 ;; Dup?
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
231 (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
232 (setq semantic-mrub-last-overlay overlay)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
233 (semantic-mrub-push semantic-mru-bookmark-ring
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
234 (point)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
235 'edit)))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
236
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
237 ;;; MINOR MODE
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
238 ;;
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
239 ;; Tracking minor mode.
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
240
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
241 (defcustom global-semantic-mru-bookmark-mode nil
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
242 "*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
243 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
244 until the buffer is reparsed."
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
245 :group 'semantic
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
246 :group 'semantic-modes
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
247 :type 'boolean
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
248 :require 'semantic-util-modes
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
249 :initialize 'custom-initialize-default
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
250 :set (lambda (sym val)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
251 (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
252
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
253 ;;;###autoload
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
254 (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
255 "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
256 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
257 If ARG is nil, then toggle."
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
258 (interactive "P")
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
259 (setq global-semantic-mru-bookmark-mode
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
260 (semantic-toggle-minor-mode-globally
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
261 'semantic-mru-bookmark-mode arg)))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
262
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
263 (defcustom semantic-mru-bookmark-mode-hook nil
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
264 "*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
265 :group 'semantic
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
266 :type 'hook)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
267
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
268 (defvar semantic-mru-bookmark-mode-map
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
269 (let ((km (make-sparse-keymap)))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
270 (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
271 km)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
272 "Keymap for mru-bookmark minor mode.")
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
273
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
274 (defvar semantic-mru-bookmark-mode nil
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
275 "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
276 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
277 (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
278
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
279 (defun semantic-mru-bookmark-mode-setup ()
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
280 "Setup option `semantic-mru-bookmark-mode'.
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
281 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
282 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
283 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
284 minor mode is enabled."
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
285 (if semantic-mru-bookmark-mode
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
286 (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
287 (progn
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
288 ;; 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
289 (setq semantic-mru-bookmark-mode nil)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
290 (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
291 (buffer-name)))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
292 (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
293 (add-hook 'semantic-edits-new-change-hooks
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
294 '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
295 (add-hook 'semantic-edits-move-change-hooks
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
296 '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
297 )
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
298 ;; Remove hooks
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
299 (remove-hook 'semantic-edits-new-change-hooks
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
300 'semantic-mru-bookmark-change-hook-fcn t)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
301 (remove-hook 'semantic-edits-move-change-hooks
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
302 'semantic-mru-bookmark-change-hook-fcn t)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
303 )
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
304 semantic-mru-bookmark-mode)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
305
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
306 (defun semantic-mru-bookmark-mode (&optional arg)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
307 "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
308 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
309 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
310
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
311 \\{semantic-mru-bookmark-mode-map}
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
312
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
313 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
314 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
315 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
316 minor mode is enabled."
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
317 (interactive
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
318 (list (or current-prefix-arg
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
319 (if semantic-mru-bookmark-mode 0 1))))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
320 (setq semantic-mru-bookmark-mode
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
321 (if arg
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
322 (>
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
323 (prefix-numeric-value arg)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
324 0)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
325 (not semantic-mru-bookmark-mode)))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
326 (semantic-mru-bookmark-mode-setup)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
327 (run-hooks 'semantic-mru-bookmark-mode-hook)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
328 (if (interactive-p)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
329 (message "mru-bookmark minor mode %sabled"
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
330 (if semantic-mru-bookmark-mode "en" "dis")))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
331 (semantic-mode-line-update)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
332 semantic-mru-bookmark-mode)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
333
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
334 (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
335 "k"
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
336 semantic-mru-bookmark-mode-map)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
337
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
338 ;;; COMPLETING READ
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
339 ;;
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
340 ;; 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
341 (defun semantic-mrub-read-history nil
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
342 "History of `semantic-mrub-completing-read'.")
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
343
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
344 (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
345 "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
346 (let ((idx 0)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
347 (len (ring-length ring))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
348 (al nil))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
349 (while (< idx len)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
350 (let ((r (ring-ref ring idx)))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
351 (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
352 al)))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
353 (setq idx (1+ idx)))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
354 (nreverse al)))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
355
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
356 (defun semantic-mrub-completing-read (prompt)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
357 "Do a `completing-read' on elements from the mru bookmark ring.
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
358 Argument PROMPT is the promot to use when reading."
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
359 (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
360 (error "Semantic Bookmark ring is currently empty"))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
361 (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
362 (ans nil)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
363 (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
364 (first (cdr (car alist)))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
365 (semantic-mrub-read-history nil)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
366 )
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
367 ;; 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
368 (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
369 (semantic-current-tag))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
370 (setq first (cdr (car (cdr alist)))))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
371 ;; 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
372 ;; 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
373 (let ((elts (reverse alist)))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
374 (while elts
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
375 (setq semantic-mrub-read-history
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
376 (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
377 (setq elts (cdr elts))))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
378 (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
379
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
380 ;; Do the read/prompt
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
381 (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
382 (semantic-format-tag-name
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
383 (oref first tag) t)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
384 )
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
385 (concat prompt ": ")))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
386 )
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
387 (setq ans
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
388 (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
389 ;; Calculate the return tag.
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
390 (if (string= ans "")
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
391 (setq ans first)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
392 ;; Return the bookmark object.
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
393 (setq ans (assoc ans alist))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
394 (if ans
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
395 (cdr ans)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
396 ;; 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
397 nil)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
398 )))
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 (defun semantic-mrub-switch-tags (tagmark)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
401 "Switch tags to TAGMARK.
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
402 Selects a new tag via promt through the mru tag ring.
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
403 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
404 (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
405 (if (not (semantic-bookmark-p tagmark))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
406 (signal 'wrong-type-argument tagmark))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
407
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
408 (semantic-mrub-push semantic-mru-bookmark-ring
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
409 (point)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
410 'jump)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
411 (semantic-mrub-visit tagmark)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
412 )
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 ;;; ADVICE
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
415 ;;
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
416 ;; Advise some commands to help set tag marks.
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
417 ;; (defadvice push-mark (around semantic-mru-bookmark activate)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
418 ;; "Push a mark at LOCATION with NOMSG and ACTIVATE passed to `push-mark'.
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
419 ;; If `semantic-mru-bookmark-mode' is active, also push a tag onto
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
420 ;; the mru bookmark stack."
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
421 ;; (semantic-mrub-push semantic-mru-bookmark-ring
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
422 ;; (point)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
423 ;; 'mark)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
424 ;; ad-do-it)
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 ;(defadvice set-mark-command (around semantic-mru-bookmark activate)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
427 ; "Set this buffer's mark to POS.
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
428 ;If `semantic-mru-bookmark-mode' is active, also push a tag onto
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
429 ;the mru bookmark stack."
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
430 ; (when (and semantic-mru-bookmark-mode (interactive-p))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
431 ; (semantic-mrub-push semantic-mru-bookmark-ring
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
432 ; (point)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
433 ; 'mark))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
434 ; ad-do-it)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
435
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
436
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
437 ;;; Debugging
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
438 ;;
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
439 (defun semantic-adebug-mrub ()
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
440 "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
441 Useful for debugging mrub problems."
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
442 (interactive)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
443 (require 'eieio-datadebug)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
444 (let* ((out semantic-mru-bookmark-ring))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
445 (data-debug-new-buffer "*TAG RING ADEBUG*")
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
446 (data-debug-insert-object-slots out "]")
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
447 ))
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
448
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
449
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
450 (provide 'semantic/mru-bookmark)
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
451
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
452 ;; Local variables:
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
453 ;; generated-autoload-file: "loaddefs.el"
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
454 ;; generated-autoload-feature: semantic/loaddefs
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
455 ;; generated-autoload-load-name: "semantic/mru-bookmark"
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
456 ;; End:
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
457
51e316109fba lisp/cedet/semantic/mru-bookmark.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
458 ;;; semantic/mru-bookmark.el ends here