Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

More hacking; jump to the location of the current tag.

  • Loading branch information...
commit bcb3eb326118f0e6f4327d914823772bc76df9fa 1 parent 9cf92b4
Mark Hepburn authored September 10, 2009

Showing 1 changed file with 29 additions and 12 deletions. Show diff stats Hide diff stats

  1. 41  tags-view.el
41  tags-view.el
@@ -35,6 +35,11 @@
35 35
 ;;; like the practice of writing something to completion for emacs for
36 36
 ;;; once!
37 37
 
  38
+;;; TODO:
  39
+;;; * support for gtags as well as etags
  40
+;;; * manipulation of the tags list (deletion, etc)
  41
+;;; * autodetection of etags/gtags etc
  42
+
38 43
 ;;; Code:
39 44
 
40 45
 ;;; etags.el.  Locations are in global variable `tags-location-ring',
@@ -72,20 +77,19 @@
72 77
     (set-buffer (marker-buffer marker))
73 78
     (line-number-at-pos (marker-position marker))))
74 79
 
75  
-(defun tv-insert-items (items)
  80
+(defun tv-insert-items (items &optional count)
76 81
   "Insert the formatted list of tags with context"
  82
+  (unless count (setq count 0))
77 83
   (if items
78 84
       (progn
79  
-        (tv-insert-single-item (car items))
  85
+        (tv-insert-single-item (car items) count)
80 86
         (if (cdr items)
81 87
             (progn
82 88
               (if tv-separator-string
83  
-                  (progn
84  
-                    (insert tv-separator-string)
85  
-                    (insert "\n")))
86  
-              (tv-insert-items (cdr items)))))))
  89
+                  (insert tv-separator-string "\n"))
  90
+              (tv-insert-items (cdr items) (1+ count)))))))
87 91
 
88  
-(defun tv-insert-single-item (marker)
  92
+(defun tv-insert-single-item (marker posn)
89 93
   "Insert a single formatted item, including overlays etc.
90 94
 Argument is a marker that will be displayed, along with
91 95
 `tv-context-lines' of context, if non-zero."
@@ -94,10 +98,11 @@ Argument is a marker that will be displayed, along with
94 98
                                 (buffer-name (marker-buffer marker))
95 99
                                 (tv-what-line marker))
96 100
                         'face 'tv-header-face))
97  
-    (insert (tv-get-lines-with-context marker tv-context-lines))
98  
-    (insert "\n")
99  
-    (let* ((o (make-overlay beg (point))))
100  
-      (overlay-put o 'mouse-face 'highlight))))
  101
+    (insert (tv-get-lines-with-context marker tv-context-lines) "\n")
  102
+    (let ((o (make-overlay beg (point))))
  103
+      (overlay-put o 'mouse-face 'highlight)
  104
+      (overlay-put o 'tv-ring-posn posn)
  105
+      (overlay-put o 'tv-marker marker))))
101 106
 
102 107
 (defun tv-get-lines-with-context (marker &optional num-context)
103 108
   "Grabs the line at the specified marker; if optional
@@ -123,7 +128,16 @@ Argument is a marker that will be displayed, along with
123 128
 
124 129
 ;;; to implement; different methods of operating on the current selection:
125 130
 (defun tv-display-tag-other-window ())
126  
-(defun tv-jump-to-tag-and-quit ())
  131
+(defun tv-jump-to-tag-and-quit (location)
  132
+  (interactive "d")
  133
+  (let* ((o (or (car-safe (overlays-at location))
  134
+                (car (overlays-at (next-overlay-change location)))))
  135
+         (marker (overlay-get o 'tv-marker))
  136
+         (buf    (marker-buffer marker))
  137
+         (posn   (marker-position marker)))
  138
+    (switch-to-buffer buf)
  139
+    (goto-char posn)
  140
+    (delete-other-windows)))
127 141
 (defun tv-clear-tag-at-point ())
128 142
 
129 143
 ;;; Navigation:
@@ -180,6 +194,9 @@ Argument is a marker that will be displayed, along with
180 194
     (define-key km "\C-p" 'tv-previous-tag)
181 195
     (define-key km "k"    'tv-previous-tag)
182 196
 
  197
+    ;; operation:
  198
+    (define-key km "\C-m"  'tv-jump-to-tag-and-quit)
  199
+
183 200
     ;; cleanup:
184 201
     (define-key km "q"    'delete-window)))
185 202
 

0 notes on commit bcb3eb3

Please sign in to comment.
Something went wrong with that request. Please try again.