]> code.delx.au - gnu-emacs/blobdiff - lisp/cedet/semantic/senator.el
Update copyright year to 2015
[gnu-emacs] / lisp / cedet / semantic / senator.el
index 522b655c2084587f465e410e98409bd41c174fe1..c58def60585e9080ba447b5ad29bd5605af94a46 100644 (file)
@@ -1,10 +1,9 @@
 ;;; semantic/senator.el --- SEmantic NAvigaTOR
 
-;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
-;;   2009  Free Software Foundation, Inc.
+;; Copyright (C) 2000-2015 Free Software Foundation, Inc.
 
 ;; Author: David Ponce <david@dponce.com>
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
 ;; Created: 10 Nov 2000
 ;; Keywords: syntax
 
@@ -42,8 +41,6 @@
 
 ;; (eval-when-compile (require 'hippie-exp))
 
-(declare-function semanticdb-fast-strip-find-results "semantic/db-find")
-(declare-function semanticdb-deep-find-tags-for-completion "semantic/db-find")
 (declare-function semantic-analyze-tag-references "semantic/analyze/refs")
 (declare-function semantic-analyze-refs-impl "semantic/analyze/refs")
 (declare-function semantic-analyze-find-tag "semantic/analyze")
@@ -182,8 +179,8 @@ source."
     (goto-char (semantic-tag-start tag))
     (when (re-search-forward (concat
                               ;; The tag name is expected to be
-                              ;; between word delimiters, whitespaces,
-                              ;; or punctuations.
+                              ;; between word delimiters, whitespace,
+                              ;; or punctuation.
                               "\\(\\<\\|\\s-+\\|\\s.\\)"
                               (regexp-quote name)
                               "\\(\\>\\|\\s-+\\|\\s.\\)")
@@ -258,6 +255,7 @@ TEXT, BOUND, NOERROR, and COUNT arguments are interpreted."
   "Navigate to the next Semantic tag.
 Return the tag or nil if at end of buffer."
   (interactive)
+  (semantic-error-if-unparsed)
   (let ((pos (point))
         (tag (semantic-current-tag))
         where)
@@ -297,6 +295,7 @@ Return the tag or nil if at end of buffer."
   "Navigate to the previous Semantic tag.
 Return the tag or nil if at beginning of buffer."
   (interactive)
+  (semantic-error-if-unparsed)
   (let ((pos (point))
         (tag (semantic-current-tag))
         where)
@@ -522,6 +521,7 @@ If that parent which is only a reference in the function tag
 is found, we can jump to it.
 Some tags such as includes have other reference features."
   (interactive)
+  (semantic-error-if-unparsed)
   (let ((result (semantic-up-reference (or tag (semantic-current-tag)))))
     (if (not result)
         (error "No up reference found")
@@ -686,9 +686,9 @@ Use semantic tags to navigate."
     (when ft
       (ring-insert senator-tag-ring ft)
       (kill-ring-save (semantic-tag-start ft) (semantic-tag-end ft))
-      (when (interactive-p)
-        (message "Use C-y to yank text.  Use `senator-yank-tag' for prototype insert."))
-      )
+      (when (called-interactively-p 'interactive)
+        (message "Use C-y to yank text.  \
+Use `senator-yank-tag' for prototype insert.")))
     ft))
 
 ;;;###autoload
@@ -700,9 +700,9 @@ the kill ring.  Retrieve that text with \\[yank]."
   (let ((ct (senator-copy-tag))) ;; this handles the reparse for us.
     (kill-region (semantic-tag-start ct)
                  (semantic-tag-end ct))
-    (when (interactive-p)
-      (message "Use C-y to yank text.  Use `senator-yank-tag' for prototype insert."))
-    ))
+    (when (called-interactively-p 'interactive)
+      (message "Use C-y to yank text.  \
+Use `senator-yank-tag' for prototype insert."))))
 
 ;;;###autoload
 (defun senator-yank-tag ()
@@ -714,21 +714,32 @@ yanked to."
       (let ((ft (ring-ref senator-tag-ring 0)))
           (semantic-foreign-tag-check ft)
           (semantic-insert-foreign-tag ft)
-          (when (interactive-p)
+          (when (called-interactively-p 'interactive)
             (message "Use C-y to recover the yank the text of %s."
-                     (semantic-tag-name ft)))
-          )))
+                     (semantic-tag-name ft))))))
 
 ;;;###autoload
 (defun senator-copy-tag-to-register (register &optional kill-flag)
   "Copy the current tag into REGISTER.
 Optional argument KILL-FLAG will delete the text of the tag to the
-kill ring."
-  (interactive "cTag to register: \nP")
+kill ring.
+
+Interactively, reads the register using `register-read-with-preview',
+if available."
+  (interactive (list (if (fboundp 'register-read-with-preview)
+                        (register-read-with-preview "Tag to register: ")
+                      (read-char "Tag to register: "))
+                    current-prefix-arg))
   (semantic-fetch-tags)
   (let ((ft (semantic-obtain-foreign-tag)))
     (when ft
-      (set-register register ft)
+      (set-register
+       register (registerv-make
+                 ft
+                 :insert-func #'semantic-insert-foreign-tag
+                 :jump-func (lambda (v)
+                              (switch-to-buffer (semantic-tag-buffer v))
+                              (goto-char (semantic-tag-start v)))))
       (if kill-flag
           (kill-region (semantic-tag-start ft)
                        (semantic-tag-end ft))))))
@@ -857,26 +868,6 @@ Use a senator search function when semantic isearch mode is enabled."
 ;;   [(control ?,)]
 ;;   'senator-isearch-toggle-semantic-mode)
 
-;; (defadvice insert-register (around senator activate)
-;;   "Insert contents of register REGISTER as a tag.
-;; If senator is not active, use the original mechanism."
-;;   (let ((val (get-register (ad-get-arg 0))))
-;;     (if (and senator-minor-mode (interactive-p)
-;;              (semantic-foreign-tag-p val))
-;;         (semantic-insert-foreign-tag val)
-;;       ad-do-it)))
-
-;; (defadvice jump-to-register (around senator activate)
-;;   "Insert contents of register REGISTER as a tag.
-;; If senator is not active, use the original mechanism."
-;;   (let ((val (get-register (ad-get-arg 0))))
-;;     (if (and senator-minor-mode (interactive-p)
-;;              (semantic-foreign-tag-p val))
-;;         (progn
-;;           (switch-to-buffer (semantic-tag-buffer val))
-;;           (goto-char (semantic-tag-start val)))
-;;       ad-do-it)))
-
 (provide 'semantic/senator)
 
 ;; Local variables:
@@ -884,5 +875,4 @@ Use a senator search function when semantic isearch mode is enabled."
 ;; generated-autoload-load-name: "semantic/senator"
 ;; End:
 
-;; arch-tag: 397100d0-e2db-467e-8c19-d8d4d99d51f1
 ;;; semantic/senator.el ends here