changeset 53988:043054d4d662

(uncomment-region): Allow eob as comment end.
author Eli Zaretskii <eliz@is.elta.co.il>
date Mon, 16 Feb 2004 14:10:41 +0000
parents c76c40c6cb68
children 8cb345f1e4e6
files lisp/newcomment.el
diffstat 1 files changed, 30 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/newcomment.el	Mon Feb 16 13:59:46 2004 +0000
+++ b/lisp/newcomment.el	Mon Feb 16 14:10:41 2004 +0000
@@ -698,7 +698,7 @@
 comment markers."
   (interactive "*r\nP")
   (comment-normalize-vars)
-  (if (> beg end) (let (mid) (setq mid beg beg end end mid)))
+  (when (> beg end) (setq beg (prog1 end (setq end beg))))
   (save-excursion
     (if uncomment-region-function
 	(funcall uncomment-region-function beg end arg)
@@ -716,7 +716,35 @@
 		;; Find the end of the comment.
 		(ept (progn
 		       (goto-char spt)
-		       (unless (comment-forward)
+		       (unless
+			   (or
+			    (comment-forward)
+			    ;; Allow eob as comment-end instead of \n.
+			    (and
+			     (eobp)
+			     (let ((s1 (aref (syntax-table) (char-after spt)))
+				   (s2 (aref (syntax-table)
+					     (or (char-after (1+ spt)) 0)))
+				   (sn (aref (syntax-table) ?\n))
+				   (flag->b (car (string-to-syntax "> b")))
+				   (flag-1b (car (string-to-syntax "  1b")))
+				   (flag-2b (car (string-to-syntax "  2b"))))
+			       (cond
+				;; One-character comment-start terminated by
+				;; \n.
+				((and
+				  (equal sn (string-to-syntax ">"))
+				  (equal s1 (string-to-syntax "<")))
+				 (insert-char ?\n 1)
+				 t)
+				;; Two-character type b comment-start
+				;; terminated by \n.
+				((and
+				  (= (logand (car sn) flag->b) flag->b)
+				  (= (logand (car s1) flag-1b) flag-1b)
+				  (= (logand (car s2) flag-2b) flag-2b))
+				 (insert-char ?\n 1)
+				 t)))))
 			 (error "Can't find the comment end"))
 		       (point)))
 		(box nil)