These are my first functions:
(defun cxxcomment (pos0 pos1)
"Alternative commenting function for c++ code"
(interactive "r")
(let ((line0 (line-number-at-pos pos0))
(line1 (line-number-at-pos pos1)))
(save-excursion
(while (<= line0 line1)
(goto-line line0)
(insert "//")
(setq line0 (+ line0 1 ))
)
)
)
)
(defun cxxuncomment (pos0 pos1)
"Alternative uncommenting function for c++ code"
(interactive "r")
(let ((line0 (line-number-at-pos pos0))
(line1 (line-number-at-pos pos1)))
(save-excursion
(while (<= line0 line1)
(goto-line line0)
(if (re-search-forward "^\\([ \t]*\\)//" (line-end-position) t)
(replace-match "\\1"))
(setq line0 (+ line0 1 ))
)
)
)
)
Very basic stuff, but I already like this one better than the one built into c++-mode ;-)
0 comments:
Post a Comment