diff options
| author | Artur Malabarba | 2015-02-08 19:03:17 -0200 |
|---|---|---|
| committer | Artur Malabarba | 2015-02-08 19:03:17 -0200 |
| commit | 97cb255360172980e7b79ed6a8cb35abbc58f897 (patch) | |
| tree | b3067683f9ab3ff500584c2d40c4ccb40f740aa0 | |
| parent | 61320cc95ca14ec282bb73307e9006fb1d6e7e80 (diff) | |
| download | emacs-97cb255360172980e7b79ed6a8cb35abbc58f897.tar.gz emacs-97cb255360172980e7b79ed6a8cb35abbc58f897.zip | |
newcomment.el (comment-line): New command on C-x C-;.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/bindings.el | 1 | ||||
| -rw-r--r-- | lisp/newcomment.el | 32 |
3 files changed, 39 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b862d42b961..64424b74c95 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2015-02-08 Artur Malabarba <bruce.connor.am@gmail.com> | ||
| 2 | |||
| 3 | * newcomment.el (comment-line): New command. | ||
| 4 | |||
| 5 | * bindings.el (ctl-x-map): Bind to `C-x C-;'. | ||
| 6 | |||
| 1 | 2015-02-08 Oleh Krehel <ohwoeowho@gmail.com> | 7 | 2015-02-08 Oleh Krehel <ohwoeowho@gmail.com> |
| 2 | 8 | ||
| 3 | * outline.el (outline-show-entry): Fix one invisible char for the | 9 | * outline.el (outline-show-entry): Fix one invisible char for the |
diff --git a/lisp/bindings.el b/lisp/bindings.el index 883914ecdc2..4cc9f6ad368 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el | |||
| @@ -1130,6 +1130,7 @@ if `inhibit-field-text-motion' is non-nil." | |||
| 1130 | (define-key esc-map "j" 'indent-new-comment-line) | 1130 | (define-key esc-map "j" 'indent-new-comment-line) |
| 1131 | (define-key esc-map "\C-j" 'indent-new-comment-line) | 1131 | (define-key esc-map "\C-j" 'indent-new-comment-line) |
| 1132 | (define-key ctl-x-map ";" 'comment-set-column) | 1132 | (define-key ctl-x-map ";" 'comment-set-column) |
| 1133 | (define-key ctl-x-map "C-;" 'comment-line) | ||
| 1133 | (define-key ctl-x-map "f" 'set-fill-column) | 1134 | (define-key ctl-x-map "f" 'set-fill-column) |
| 1134 | (define-key ctl-x-map "$" 'set-selective-display) | 1135 | (define-key ctl-x-map "$" 'set-selective-display) |
| 1135 | 1136 | ||
diff --git a/lisp/newcomment.el b/lisp/newcomment.el index e307eac94eb..aabafc76b9a 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 |