summaryrefslogtreecommitdiff
path: root/lisp/newcomment.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2011-01-14 13:10:15 -0500
committerStefan Monnier <monnier@iro.umontreal.ca>2011-01-14 13:10:15 -0500
commit6d3d61134327fe63fe33f16cf75d160686fd57b6 (patch)
treeeccbb474b4f9fc08ce0c2443e4340054c8d93d11 /lisp/newcomment.el
parentf80aa5bfa90dff5cd75d1f40e4ababa3c86af7fb (diff)
downloademacs-6d3d61134327fe63fe33f16cf75d160686fd57b6.tar.gz
* lisp/vc/smerge-mode.el: Resolve comment conflicts more aggressively.
(smerge-resolve--normalize-re): New var. (smerge-resolve--extract-comment, smerge-resolve--normalize): New funs. (smerge-resolve): Use them. * lisp/newcomment.el (comment-only-p): New function. (comment-or-uncomment-region): Use it.
Diffstat (limited to 'lisp/newcomment.el')
-rw-r--r--lisp/newcomment.el11
1 files changed, 7 insertions, 4 deletions
diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index 0f739513227..6e2955c6607 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -1185,6 +1185,12 @@ end- comment markers additionally to what `comment-add' already specifies."
'box-multi 'box)))
(comment-region beg end (+ comment-add arg))))
+(defun comment-only-p (beg end)
+ "Return non-nil if the text between BEG and END is all comments."
+ (save-excursion
+ (goto-char beg)
+ (comment-forward (point-max))
+ (<= end (point))))
;;;###autoload
(defun comment-or-uncomment-region (beg end &optional arg)
@@ -1193,10 +1199,7 @@ in which case call `uncomment-region'. If a prefix arg is given, it
is passed on to the respective function."
(interactive "*r\nP")
(comment-normalize-vars)
- (funcall (if (save-excursion ;; check for already commented region
- (goto-char beg)
- (comment-forward (point-max))
- (<= end (point)))
+ (funcall (if (comment-only-p beg end)
'uncomment-region 'comment-region)
beg end arg))