Hello again,

Here is a patch which re-implements the function
ada-goto-previous-reference and the reference ring from ada-mode 4.0.
One of our users was addicted to hitting C-c C-s after C-c C-d :)

--
Ludovic Brenta.
--- ada-mode.el Tue Apr 15 12:57:24 2014
+++ ada-mode.el Wed Apr 16 12:49:56 2014
@@ -357,6 +357,7 @@
     (define-key map "\C-c\C-q"          'ada-xref-refresh)
     (define-key map "\C-c\C-r"          'ada-show-references)
     (define-key map "\C-c\M-r"          'ada-build-run)
+    (define-key map "\C-c\C-s"   'ada-goto-previous-reference)
     (define-key map "\C-c\C-v"   'ada-build-check)
     (define-key map "\C-c\C-w"          'ada-case-adjust-at-point)
     (define-key map "\C-c\C-x"   'ada-show-overriding)
@@ -1933,11 +1934,35 @@
       (error "No identifier around"))
      )))
 
+
+(defvar ada-xref-pos-ring '()
+  "List of positions selected by the cross-references functions.
+Used to go back to these positions.")
+
+(defconst ada-xref-pos-ring-max 16
+  "Number of positions kept in the list `ada-xref-pos-ring'.")
+
+(defun ada-xref-push-pos (filename position)
+  "Push (FILENAME, POSITION) on the position ring for cross-references."
+  (setq ada-xref-pos-ring (cons (list position filename) ada-xref-pos-ring))
+  (if (> (length ada-xref-pos-ring) ada-xref-pos-ring-max)
+      (setcdr (nthcdr (1- ada-xref-pos-ring-max) ada-xref-pos-ring) nil)))
+
+(defun ada-goto-previous-reference ()
+  "Go to the previous cross-reference we were on."
+  (interactive)
+  (if ada-xref-pos-ring
+      (let ((pos (car ada-xref-pos-ring)))
+       (setq ada-xref-pos-ring (cdr ada-xref-pos-ring))
+       (find-file (car (cdr pos)))
+       (goto-char (car pos)))))
+
 (defun ada-goto-source (file line column other-window)
   "Find and select FILE, at LINE and COLUMN.
 FILE may be absolute, or on `compilation-search-path'.
 
 If OTHER-WINDOW is non-nil, show the buffer in another window."
+  (ada-xref-push-pos (buffer-file-name) (point))
   (or (file-name-absolute-p file)
       (setq file (ff-get-file-name compilation-search-path file)))
   (let ((buffer (get-file-buffer file)))
_______________________________________________
Emacs-ada-mode mailing list
[email protected]
http://host114.hostmonster.com/mailman/listinfo/emacs-ada-mode_stephe-leake.org

Reply via email to