Function: org-ctags-get-filename-for-tag

org-ctags-get-filename-for-tag is an interactive and byte-compiled function defined in org-ctags.el.gz.

Signature

(org-ctags-get-filename-for-tag TAG)

Documentation

TAG is a string. Search the active TAGS file for a matching tag.

If the tag is found, return a list containing the filename, line number, and buffer position where the tag is found.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-ctags.el.gz
;;; General utility functions.  ===============================================
;; These work outside org-ctags mode.

(defun org-ctags-get-filename-for-tag (tag)
  "TAG is a string.  Search the active TAGS file for a matching tag.
If the tag is found, return a list containing the filename, line number, and
buffer position where the tag is found."
  (interactive "sTag: ")
  (unless tags-file-name
    (call-interactively #'visit-tags-table))
  (save-excursion
    (visit-tags-table-buffer 'same)
    (when tags-file-name
      (with-current-buffer (get-file-buffer tags-file-name)
        (goto-char (point-min))
        (cond
         ((re-search-forward (format "^.*\^?%s\^A\\([0-9]+\\),\\([0-9]+\\)$"
                                     (regexp-quote tag)) nil t)
          (let ((line (string-to-number (match-string 1)))
                (pos (string-to-number (match-string 2))))
            (cond
             ((re-search-backward "\n\\(.*\\),[0-9]+\n")
              (list (match-string 1) line pos))
             (t              ; can't find a file name preceding the matched
					; tag??
              (error "Malformed TAGS file: %s" (buffer-name))))))
         (t                               ; tag not found
          nil))))))