diff options
| author | Stefan Monnier <monnier@iro.umontreal.ca> | 2006-04-17 03:51:30 +0000 |
|---|---|---|
| committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2006-04-17 03:51:30 +0000 |
| commit | b433a5608e182fb6bf4014a1219ba202fb1358a9 (patch) | |
| tree | 05771c465537764b6c5ec692e762d716765746bb /lisp | |
| parent | f8c62b703717c25946587818342f60d07941f608 (diff) | |
| download | emacs-b433a5608e182fb6bf4014a1219ba202fb1358a9.tar.gz | |
(comment-add): New function.
(comment-region-default, comment-dwim): Use it.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/newcomment.el | 14 |
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 @@ +2006-04-16 Stefan Monnier <monnier@iro.umontreal.ca> + + * newcomment.el (comment-add): New function. + (comment-region-default, comment-dwim): Use it. + 2006-04-15 Michael Olson <mwolson@gnu.org> * emacs-lisp/tq.el: Improve comments. @@ -6,8 +11,8 @@ Update for modified queue structure. (tq-queue-add): Accept `question' argument. (tq-queue-pop): If a question is pending, send it. - (tq-enqueue): Accept new optional argument `delay-question'. If - this is non-nil, and at least one other question is pending a + (tq-enqueue): Accept new optional argument `delay-question'. + If this is non-nil, and at least one other question is pending a response, queue the question rather than sending it immediately. 2006-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." (delete-char n) (setq ,bindent (- ,bindent n))))))))))) +(defun comment-add (arg) + (if (and (null arg) (= (string-match "[ \t]*\\'" comment-start) 1)) + comment-add + (1- (prefix-numeric-value arg)))) + (defun comment-region-internal (beg end cs ce &optional ccs cce block lines indent) "Comment region BEG .. END. @@ -999,7 +1004,6 @@ The strings used as comment starts are built from (defun comment-region-default (beg end &optional arg) (let* ((numarg (prefix-numeric-value arg)) - (add comment-add) (style (cdr (assoc comment-style comment-styles))) (lines (nth 2 style)) (block (nth 1 style)) @@ -1032,8 +1036,7 @@ The strings used as comment starts are built from ((consp arg) (uncomment-region beg end)) ((< numarg 0) (uncomment-region beg end (- numarg))) (t - (setq numarg (if (and (null arg) (= (length comment-start) 1)) - add (1- numarg))) + (setq numarg (comment-add arg)) (comment-region-internal beg end (let ((s (comment-padright comment-start numarg))) @@ -1091,9 +1094,8 @@ You can configure `comment-style' to change the way regions are commented." ;; FIXME: If there's no comment to kill on this line and ARG is ;; specified, calling comment-kill is not very clever. (if arg (comment-kill (and (integerp arg) arg)) (comment-indent)) - (let ((add (if arg (prefix-numeric-value arg) - (if (= (length comment-start) 1) comment-add 0)))) - ;; Some modes insist on keeping column 0 comment in column 0 + (let ((add (comment-add arg))) + ;; Some modes insist on keeping column 0 comment in column 0 ;; so we need to move away from it before inserting the comment. (indent-according-to-mode) (insert (comment-padright comment-start add)) |
