Mercurial > emacs
comparison lisp/newcomment.el @ 54276:0c512d4c08e1
(uncomment-region): Allow non-terminated comment.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Thu, 04 Mar 2004 19:20:35 +0000 |
parents | 043054d4d662 |
children | 41d93a97701d |
comparison
equal
deleted
inserted
replaced
54275:f4b54db9c8ae | 54276:0c512d4c08e1 |
---|---|
1 ;;; newcomment.el --- (un)comment regions of buffers | 1 ;;; newcomment.el --- (un)comment regions of buffers |
2 | 2 |
3 ;; Copyright (C) 1999,2000,2003 Free Software Foundation Inc. | 3 ;; Copyright (C) 1999,2000,2003,2004 Free Software Foundation Inc. |
4 | 4 |
5 ;; Author: code extracted from Emacs-20's simple.el | 5 ;; Author: code extracted from Emacs-20's simple.el |
6 ;; Maintainer: Stefan Monnier <monnier@cs.yale.edu> | 6 ;; Maintainer: Stefan Monnier <monnier@cs.yale.edu> |
7 ;; Keywords: comment uncomment | 7 ;; Keywords: comment uncomment |
8 | 8 |
714 (setq spt (comment-search-forward end t))) | 714 (setq spt (comment-search-forward end t))) |
715 (let ((ipt (point)) | 715 (let ((ipt (point)) |
716 ;; Find the end of the comment. | 716 ;; Find the end of the comment. |
717 (ept (progn | 717 (ept (progn |
718 (goto-char spt) | 718 (goto-char spt) |
719 (unless | 719 (unless (or (comment-forward) |
720 (or | 720 ;; Allow non-terminated comments. |
721 (comment-forward) | 721 (eobp)) |
722 ;; Allow eob as comment-end instead of \n. | |
723 (and | |
724 (eobp) | |
725 (let ((s1 (aref (syntax-table) (char-after spt))) | |
726 (s2 (aref (syntax-table) | |
727 (or (char-after (1+ spt)) 0))) | |
728 (sn (aref (syntax-table) ?\n)) | |
729 (flag->b (car (string-to-syntax "> b"))) | |
730 (flag-1b (car (string-to-syntax " 1b"))) | |
731 (flag-2b (car (string-to-syntax " 2b")))) | |
732 (cond | |
733 ;; One-character comment-start terminated by | |
734 ;; \n. | |
735 ((and | |
736 (equal sn (string-to-syntax ">")) | |
737 (equal s1 (string-to-syntax "<"))) | |
738 (insert-char ?\n 1) | |
739 t) | |
740 ;; Two-character type b comment-start | |
741 ;; terminated by \n. | |
742 ((and | |
743 (= (logand (car sn) flag->b) flag->b) | |
744 (= (logand (car s1) flag-1b) flag-1b) | |
745 (= (logand (car s2) flag-2b) flag-2b)) | |
746 (insert-char ?\n 1) | |
747 t))))) | |
748 (error "Can't find the comment end")) | 722 (error "Can't find the comment end")) |
749 (point))) | 723 (point))) |
750 (box nil) | 724 (box nil) |
751 (box-equal nil)) ;Whether we might be using `=' for boxes. | 725 (box-equal nil)) ;Whether we might be using `=' for boxes. |
752 (save-restriction | 726 (save-restriction |