]> git.eshelyaron.com Git - emacs.git/commitdiff
(uncomment-region): Allow eob as comment end.
authorEli Zaretskii <eliz@is.elta.co.il>
Mon, 16 Feb 2004 14:12:57 +0000 (14:12 +0000)
committerEli Zaretskii <eliz@is.elta.co.il>
Mon, 16 Feb 2004 14:12:57 +0000 (14:12 +0000)
lisp/ChangeLog
lisp/newcomment.el

index 88fa9377f46e5b7afeb02a76c25fbd0e1494cc6d..a6bc343eceda501804d7180d01dc28ee05c33c7c 100644 (file)
@@ -1,3 +1,7 @@
+2004-02-16  Jesper Harder  <harder@ifa.au.dk>
+
+       * newcomment.el (uncomment-region): Allow eob as comment end.
+
 2004-02-16  Jari Aalto  <jari.aalto@poboxes.com>  (tiny change)
 
        * filecache.el: All message and error commands now use prefix
index cf5a815fe95fb12915dbaf5522f5e68d8693e202..91943503f5e46a54650789d598c67ce659195404 100644 (file)
@@ -698,7 +698,7 @@ The numeric prefix ARG can specify a number of chars to remove from the
 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 @@ comment markers."
                ;; 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)