Function: srecode-document-insert-variable-one-line-comment
srecode-document-insert-variable-one-line-comment is an autoloaded,
interactive and byte-compiled function defined in document.el.gz.
Signature
(srecode-document-insert-variable-one-line-comment &optional VAR-IN)
Documentation
Insert or replace a variable comment.
VAR-IN is the Semantic tag of the function to add a comment too. If VAR-IN is not provided, the current tag is used instead. It is assumed that the comment occurs just after VAR-IN.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/cedet/srecode/document.el.gz
;;;###autoload
(defun srecode-document-insert-variable-one-line-comment (&optional var-in)
"Insert or replace a variable comment.
VAR-IN is the Semantic tag of the function to add a comment too.
If VAR-IN is not provided, the current tag is used instead.
It is assumed that the comment occurs just after VAR-IN."
(interactive)
(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))
(temp (srecode-template-get-table (srecode-table)
"variable-same-line-comment"
"declaration"
'document)))
(if (not temp)
(error "No templates for inserting variable comments"))
;; Try to figure out the tag we want to use.
(when (not var-in)
(semantic-fetch-tags)
(setq var-in (semantic-current-tag)))
(when (or (not var-in)
(not (semantic-tag-of-class-p var-in 'variable)))
(error "No tag of class `variable' to insert comment for"))
(if (not (eq (current-buffer) (semantic-tag-buffer var-in)))
(error "Only insert comments for tags in the current buffer"))
;; Find any existing doc strings.
(goto-char (semantic-tag-end var-in))
(skip-syntax-forward "-" (line-end-position))
(let ((lextok (semantic-doc-snarf-comment-for-tag 'lex))
)
(when lextok
(let ((s (semantic-lex-token-start lextok))
(e (semantic-lex-token-end lextok)))
(pulse-momentary-highlight-region s e)
(when (not (y-or-n-p "A comment already exists. Replace? "))
(error "Quit"))
;; Extract text from the existing comment.
(srecode-extract temp s e)
(delete-region s e)
(goto-char s) ;; To avoid adding a CR.
))
)
;; Clean up the end of the line and use handy comment-column.
(end-of-line)
(delete-horizontal-space)
(move-to-column comment-column t)
(when (< (point) (line-end-position)) (end-of-line))
;; Perform the insertion
(let ((srecode-semantic-selected-tag var-in)
(srecode-semantic-apply-tag-augment-hook
(lambda (tag dict)
(srecode-dictionary-set-value
dict "DOC" (srecode-document-parameter-comment
tag))))
)
(srecode-insert-fcn temp dict)
))
)