diff options
Diffstat (limited to 'lisp/newcomment.el')
| -rw-r--r-- | lisp/newcomment.el | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lisp/newcomment.el b/lisp/newcomment.el index e307eac94eb..172a5634a57 100644 --- a/lisp/newcomment.el +++ b/lisp/newcomment.el | |||
| @@ -1451,6 +1451,38 @@ unless optional argument SOFT is non-nil." | |||
| 1451 | (end-of-line 0) | 1451 | (end-of-line 0) |
| 1452 | (insert comend)))))))))))) | 1452 | (insert comend)))))))))))) |
| 1453 | 1453 | ||
| 1454 | ;;;###autoload | ||
| 1455 | (defun comment-line (n) | ||
| 1456 | "Comment or uncomment current line and leave point after it. | ||
| 1457 | With positive prefix, apply to N lines including current one. | ||
| 1458 | With negative prefix, apply to -N lines above. Also, further | ||
| 1459 | consecutive invocations of this command will inherit the negative | ||
| 1460 | argument. | ||
| 1461 | |||
| 1462 | If region is active, comment lines in active region instead. | ||
| 1463 | Unlike `comment-dwim', this always comments whole lines." | ||
| 1464 | (interactive "p") | ||
| 1465 | (if (use-region-p) | ||
| 1466 | (comment-or-uncomment-region | ||
| 1467 | (save-excursion | ||
| 1468 | (goto-char (region-beginning)) | ||
| 1469 | (line-beginning-position)) | ||
| 1470 | (save-excursion | ||
| 1471 | (goto-char (region-end)) | ||
| 1472 | (line-end-position))) | ||
| 1473 | (when (and (eq last-command 'comment-line-backward) | ||
| 1474 | (natnump n)) | ||
| 1475 | (setq n (- n))) | ||
| 1476 | (let ((range | ||
| 1477 | (list (line-beginning-position) | ||
| 1478 | (goto-char (line-end-position n))))) | ||
| 1479 | (comment-or-uncomment-region | ||
| 1480 | (apply #'min range) | ||
| 1481 | (apply #'max range))) | ||
| 1482 | (forward-line 1) | ||
| 1483 | (back-to-indentation) | ||
| 1484 | (unless (natnump n) (setq this-command 'comment-line-backward)))) | ||
| 1485 | |||
| 1454 | (provide 'newcomment) | 1486 | (provide 'newcomment) |
| 1455 | 1487 | ||
| 1456 | ;;; newcomment.el ends here | 1488 | ;;; newcomment.el ends here |