Function: srecode-document-insert-group-comments
srecode-document-insert-group-comments is an autoloaded, interactive
and byte-compiled function defined in document.el.gz.
Signature
(srecode-document-insert-group-comments BEG END)
Documentation
Insert group comments around the active between BEG and END.
If the region includes only parts of some tags, expand out to the beginning and end of the tags on the region. If there is only one tag in the region, complain.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/cedet/srecode/document.el.gz
;;;###autoload
(defun srecode-document-insert-group-comments (beg end)
"Insert group comments around the active between BEG and END.
If the region includes only parts of some tags, expand out
to the beginning and end of the tags on the region.
If there is only one tag in the region, complain."
(interactive "r")
(srecode-load-tables-for-mode major-mode)
(srecode-load-tables-for-mode major-mode 'document)
(if (not (srecode-table))
(error "No template table found for mode %s" major-mode))
(let* ((dict (srecode-create-dictionary))
(context "declaration")
(temp-start nil)
(temp-end nil)
(tag-start (save-excursion
(goto-char beg)
(or (semantic-current-tag)
(semantic-find-tag-by-overlay-next))))
(tag-end (save-excursion
(goto-char end)
(or (semantic-current-tag)
(semantic-find-tag-by-overlay-prev))))
(parent-tag nil)
(first-pos beg)
(second-pos end)
)
;; If beg/end wrapped nothing, then tag-start,end would actually
;; point at some odd stuff that is out of order.
(when (or (not tag-start) (not tag-end)
(> (semantic-tag-end tag-start)
(semantic-tag-start tag-end)))
(setq tag-start nil
tag-end nil))
(when tag-start
;; If tag-start and -end are the same, and it is a class or
;; struct, try to find child tags inside the classdecl.
(cond
((and (eq tag-start tag-end)
tag-start
(semantic-tag-of-class-p tag-start 'type))
(setq parent-tag tag-start)
(setq tag-start (semantic-find-tag-by-overlay-next beg)
tag-end (semantic-find-tag-by-overlay-prev end))
)
((eq (semantic-find-tag-parent-by-overlay tag-start) tag-end)
(setq parent-tag tag-end)
(setq tag-end (semantic-find-tag-by-overlay-prev end))
)
((eq tag-start (semantic-find-tag-parent-by-overlay tag-end))
(setq parent-tag tag-start)
(setq tag-start (semantic-find-tag-by-overlay-next beg))
)
)
(when parent-tag
;; We are probably in a classdecl
;; @todo -could I really use (srecode-calculate-context) ?
(setq context "classdecl")
)
;; Derive start and end locations based on the tags.
(setq first-pos (semantic-tag-start tag-start)
second-pos (semantic-tag-end tag-end))
)
;; Now load the templates
(setq temp-start (srecode-template-get-table (srecode-table)
"group-comment-start"
context
'document)
temp-end (srecode-template-get-table (srecode-table)
"group-comment-end"
context
'document))
(when (or (not temp-start) (not temp-end))
(error "No templates for inserting group comments"))
;; Setup the name of this group ahead of time.
;; @todo - guess at a name based on common strings
;; of the tags in the group.
(srecode-dictionary-set-value
dict "GROUPNAME"
(read-string "Name of group: "))
;; Perform the insertion
;; Do the end first so we don't need to recalculate anything.
;;
(goto-char second-pos)
(end-of-line)
(srecode-insert-fcn temp-end dict)
(goto-char first-pos)
(beginning-of-line)
(srecode-insert-fcn temp-start dict)
))