Function: semantic-tag-copy

semantic-tag-copy is a byte-compiled function defined in tag.el.gz.

Signature

(semantic-tag-copy TAG &optional NAME KEEP-FILE)

Documentation

Return a copy of TAG unlinked from the originating buffer.

If optional argument NAME is non-nil it specifies a new name for the copied tag. If optional argument KEEP-FILE is non-nil, and TAG was linked to a buffer, the originating buffer file name is kept in the :filename property of the copied tag. If KEEP-FILE is a string, and the originating buffer is NOT available, then KEEP-FILE is stored on the :filename property. This runs the tag hook unlink-copy-hook.

Source Code

;; Defined in /usr/src/emacs/lisp/cedet/semantic/tag.el.gz
(defun semantic-tag-copy (tag &optional name keep-file)
  "Return a copy of TAG unlinked from the originating buffer.
If optional argument NAME is non-nil it specifies a new name for the
copied tag.
If optional argument KEEP-FILE is non-nil, and TAG was linked to a
buffer, the originating buffer file name is kept in the `:filename'
property of the copied tag.
If KEEP-FILE is a string, and the originating buffer is NOT available,
then KEEP-FILE is stored on the `:filename' property.
This runs the tag hook `unlink-copy-hook'."
  ;; Right now, TAG is a list.
  (let ((copy (semantic-tag-clone tag name)))

    ;; Keep the filename if needed.
    (when keep-file
      (semantic--tag-put-property
       copy :filename (or (semantic-tag-file-name copy)
			  (and (stringp keep-file)
			       keep-file)
			  )))

    (when (semantic-tag-with-position-p tag)
      ;; Convert the overlay to a vector, effectively 'unlinking' the tag.
      (semantic--tag-set-overlay
       copy (vector (semantic-tag-start copy) (semantic-tag-end copy)))

      ;; Force the children to be copied also.
      ;;(let ((chil (semantic--tag-copy-list
      ;;	     (semantic-tag-components-with-overlays tag)
      ;;	     keep-file)))
      ;;;; Put the list into TAG.
      ;;)

      ;; Call the unlink-copy hook.  This should tell tools that
      ;; this tag is not part of any buffer.
      (when (overlayp (semantic-tag-overlay tag))
	(semantic--tag-run-hooks copy 'unlink-copy-hook))
      )
    copy))