aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2006-04-17 03:51:30 +0000
committerStefan Monnier2006-04-17 03:51:30 +0000
commitb433a5608e182fb6bf4014a1219ba202fb1358a9 (patch)
tree05771c465537764b6c5ec692e762d716765746bb
parentf8c62b703717c25946587818342f60d07941f608 (diff)
downloademacs-b433a5608e182fb6bf4014a1219ba202fb1358a9.tar.gz
emacs-b433a5608e182fb6bf4014a1219ba202fb1358a9.zip
(comment-add): New function.
(comment-region-default, comment-dwim): Use it.
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/newcomment.el14
2 files changed, 15 insertions, 8 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index dfc0c79b1f5..76177538012 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12006-04-16 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * newcomment.el (comment-add): New function.
4 (comment-region-default, comment-dwim): Use it.
5
12006-04-15 Michael Olson <mwolson@gnu.org> 62006-04-15 Michael Olson <mwolson@gnu.org>
2 7
3 * emacs-lisp/tq.el: Improve comments. 8 * emacs-lisp/tq.el: Improve comments.
@@ -6,8 +11,8 @@
6 Update for modified queue structure. 11 Update for modified queue structure.
7 (tq-queue-add): Accept `question' argument. 12 (tq-queue-add): Accept `question' argument.
8 (tq-queue-pop): If a question is pending, send it. 13 (tq-queue-pop): If a question is pending, send it.
9 (tq-enqueue): Accept new optional argument `delay-question'. If 14 (tq-enqueue): Accept new optional argument `delay-question'.
10 this is non-nil, and at least one other question is pending a 15 If this is non-nil, and at least one other question is pending a
11 response, queue the question rather than sending it immediately. 16 response, queue the question rather than sending it immediately.
12 17
132006-04-15 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> 182006-04-15 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index 5fa9ac09b0b..877d5c9f399 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -895,6 +895,11 @@ indentation to be kept as it was before narrowing."
895 (delete-char n) 895 (delete-char n)
896 (setq ,bindent (- ,bindent n))))))))))) 896 (setq ,bindent (- ,bindent n)))))))))))
897 897
898(defun comment-add (arg)
899 (if (and (null arg) (= (string-match "[ \t]*\\'" comment-start) 1))
900 comment-add
901 (1- (prefix-numeric-value arg))))
902
898(defun comment-region-internal (beg end cs ce 903(defun comment-region-internal (beg end cs ce
899 &optional ccs cce block lines indent) 904 &optional ccs cce block lines indent)
900 "Comment region BEG .. END. 905 "Comment region BEG .. END.
@@ -999,7 +1004,6 @@ The strings used as comment starts are built from
999 1004
1000(defun comment-region-default (beg end &optional arg) 1005(defun comment-region-default (beg end &optional arg)
1001 (let* ((numarg (prefix-numeric-value arg)) 1006 (let* ((numarg (prefix-numeric-value arg))
1002 (add comment-add)
1003 (style (cdr (assoc comment-style comment-styles))) 1007 (style (cdr (assoc comment-style comment-styles)))
1004 (lines (nth 2 style)) 1008 (lines (nth 2 style))
1005 (block (nth 1 style)) 1009 (block (nth 1 style))
@@ -1032,8 +1036,7 @@ The strings used as comment starts are built from
1032 ((consp arg) (uncomment-region beg end)) 1036 ((consp arg) (uncomment-region beg end))
1033 ((< numarg 0) (uncomment-region beg end (- numarg))) 1037 ((< numarg 0) (uncomment-region beg end (- numarg)))
1034 (t 1038 (t
1035 (setq numarg (if (and (null arg) (= (length comment-start) 1)) 1039 (setq numarg (comment-add arg))
1036 add (1- numarg)))
1037 (comment-region-internal 1040 (comment-region-internal
1038 beg end 1041 beg end
1039 (let ((s (comment-padright comment-start numarg))) 1042 (let ((s (comment-padright comment-start numarg)))
@@ -1091,9 +1094,8 @@ You can configure `comment-style' to change the way regions are commented."
1091 ;; FIXME: If there's no comment to kill on this line and ARG is 1094 ;; FIXME: If there's no comment to kill on this line and ARG is
1092 ;; specified, calling comment-kill is not very clever. 1095 ;; specified, calling comment-kill is not very clever.
1093 (if arg (comment-kill (and (integerp arg) arg)) (comment-indent)) 1096 (if arg (comment-kill (and (integerp arg) arg)) (comment-indent))
1094 (let ((add (if arg (prefix-numeric-value arg) 1097 (let ((add (comment-add arg)))
1095 (if (= (length comment-start) 1) comment-add 0)))) 1098 ;; Some modes insist on keeping column 0 comment in column 0
1096 ;; Some modes insist on keeping column 0 comment in column 0
1097 ;; so we need to move away from it before inserting the comment. 1099 ;; so we need to move away from it before inserting the comment.
1098 (indent-according-to-mode) 1100 (indent-according-to-mode)
1099 (insert (comment-padright comment-start add)) 1101 (insert (comment-padright comment-start add))