diff options
| author | Richard M. Stallman | 2007-09-17 16:40:58 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2007-09-17 16:40:58 +0000 |
| commit | 5266b06b4f2410197210d9d9aa6929b8150fa4e4 (patch) | |
| tree | d782bd5983b7e25ff46a32633021141d2a3e1278 | |
| parent | 6eddc3bb42efc56044ed3abb5b24b40810b0b99c (diff) | |
| download | emacs-5266b06b4f2410197210d9d9aa6929b8150fa4e4.tar.gz emacs-5266b06b4f2410197210d9d9aa6929b8150fa4e4.zip | |
(comment-add): New arg EXTRA.
(comment-region-default): Pass EXTRA if not indenting lines.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/newcomment.el | 22 |
2 files changed, 21 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 428920aca19..45975a4d8ab 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2007-09-17 Richard Stallman <rms@gnu.org> | ||
| 2 | |||
| 3 | * newcomment.el (comment-add): New arg EXTRA. | ||
| 4 | (comment-region-default): Pass EXTRA if not indenting lines. | ||
| 5 | |||
| 1 | 2007-09-17 Micha,Ak(Bl Cadilhac <michael@cadilhac.name> | 6 | 2007-09-17 Micha,Ak(Bl Cadilhac <michael@cadilhac.name> |
| 2 | 7 | ||
| 3 | * net/browse-url.el (browse-url-url-encode-chars): New function. | 8 | * net/browse-url.el (browse-url-url-encode-chars): New function. |
diff --git a/lisp/newcomment.el b/lisp/newcomment.el index 71522cd1285..abe97c9efbe 100644 --- a/lisp/newcomment.el +++ b/lisp/newcomment.el | |||
| @@ -194,7 +194,7 @@ two semi-colons.") | |||
| 194 | (extra-line . (t nil t t)) | 194 | (extra-line . (t nil t t)) |
| 195 | (box . (nil t t t)) | 195 | (box . (nil t t t)) |
| 196 | (box-multi . (t t t t))) | 196 | (box-multi . (t t t t))) |
| 197 | "Possible comment styles of the form (STYLE . (MULTI ALIGN EXTRA INDENT)). | 197 | "Comment region styles of the form (STYLE . (MULTI ALIGN EXTRA INDENT)). |
| 198 | STYLE should be a mnemonic symbol. | 198 | STYLE should be a mnemonic symbol. |
| 199 | MULTI specifies that comments are allowed to span multiple lines. | 199 | MULTI specifies that comments are allowed to span multiple lines. |
| 200 | ALIGN specifies that the `comment-end' markers should be aligned. | 200 | ALIGN specifies that the `comment-end' markers should be aligned. |
| @@ -208,7 +208,8 @@ INDENT specifies that the `comment-start' markers should not be put at the | |||
| 208 | "Style to be used for `comment-region'. | 208 | "Style to be used for `comment-region'. |
| 209 | See `comment-styles' for a list of available styles." | 209 | See `comment-styles' for a list of available styles." |
| 210 | :type (if (boundp 'comment-styles) | 210 | :type (if (boundp 'comment-styles) |
| 211 | `(choice ,@(mapcar (lambda (s) `(const ,(car s))) comment-styles)) | 211 | `(choice ,@(mapcar (lambda (s) `(const ,(car s))) |
| 212 | comment-styles)) | ||
| 212 | 'symbol) | 213 | 'symbol) |
| 213 | :group 'comment) | 214 | :group 'comment) |
| 214 | 215 | ||
| @@ -938,9 +939,14 @@ indentation to be kept as it was before narrowing." | |||
| 938 | (delete-char n) | 939 | (delete-char n) |
| 939 | (setq ,bindent (- ,bindent n))))))))))) | 940 | (setq ,bindent (- ,bindent n))))))))))) |
| 940 | 941 | ||
| 941 | (defun comment-add (arg) | 942 | ;; Compute the number of extra semicolons to add to the comment starter |
| 943 | ;; in Lisp mode, extra stars in C mode, etc. | ||
| 944 | ;; If ARG is non-nil, just follow ARG. | ||
| 945 | ;; If the comment-starter is mult-char, just follow ARG. | ||
| 946 | ;; Otherwise obey comment-add, and add one more if EXTRA is non-nil. | ||
| 947 | (defun comment-add (arg &optional extra) | ||
| 942 | (if (and (null arg) (= (string-match "[ \t]*\\'" comment-start) 1)) | 948 | (if (and (null arg) (= (string-match "[ \t]*\\'" comment-start) 1)) |
| 943 | comment-add | 949 | (+ comment-add (if extra 1 0)) |
| 944 | (1- (prefix-numeric-value arg)))) | 950 | (1- (prefix-numeric-value arg)))) |
| 945 | 951 | ||
| 946 | (defun comment-region-internal (beg end cs ce | 952 | (defun comment-region-internal (beg end cs ce |
| @@ -1051,7 +1057,8 @@ The strings used as comment starts are built from | |||
| 1051 | (lines (nth 2 style)) | 1057 | (lines (nth 2 style)) |
| 1052 | (block (nth 1 style)) | 1058 | (block (nth 1 style)) |
| 1053 | (multi (nth 0 style))) | 1059 | (multi (nth 0 style))) |
| 1054 | ;; we use `chars' instead of `syntax' because `\n' might be | 1060 | |
| 1061 | ;; We use `chars' instead of `syntax' because `\n' might be | ||
| 1055 | ;; of end-comment syntax rather than of whitespace syntax. | 1062 | ;; of end-comment syntax rather than of whitespace syntax. |
| 1056 | ;; sanitize BEG and END | 1063 | ;; sanitize BEG and END |
| 1057 | (goto-char beg) (skip-chars-forward " \t\n\r") (beginning-of-line) | 1064 | (goto-char beg) (skip-chars-forward " \t\n\r") (beginning-of-line) |
| @@ -1079,7 +1086,10 @@ The strings used as comment starts are built from | |||
| 1079 | ((consp arg) (uncomment-region beg end)) | 1086 | ((consp arg) (uncomment-region beg end)) |
| 1080 | ((< numarg 0) (uncomment-region beg end (- numarg))) | 1087 | ((< numarg 0) (uncomment-region beg end (- numarg))) |
| 1081 | (t | 1088 | (t |
| 1082 | (setq numarg (comment-add arg)) | 1089 | ;; Add an extra semicolon in Lisp and similar modes. |
| 1090 | ;; If STYLE doesn't specify indenting the comments, | ||
| 1091 | ;; then add yet one more semicolon. | ||
| 1092 | (setq numarg (comment-add arg (null (nth 3 style)))) | ||
| 1083 | (comment-region-internal | 1093 | (comment-region-internal |
| 1084 | beg end | 1094 | beg end |
| 1085 | (let ((s (comment-padright comment-start numarg))) | 1095 | (let ((s (comment-padright comment-start numarg))) |