comparison lisp/newcomment.el @ 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 b2fbe05650de
children 0c512d4c08e1
comparison
equal deleted inserted replaced
53987:c76c40c6cb68 53988:043054d4d662
696 "Uncomment each line in the BEG .. END region. 696 "Uncomment each line in the BEG .. END region.
697 The numeric prefix ARG can specify a number of chars to remove from the 697 The numeric prefix ARG can specify a number of chars to remove from the
698 comment markers." 698 comment markers."
699 (interactive "*r\nP") 699 (interactive "*r\nP")
700 (comment-normalize-vars) 700 (comment-normalize-vars)
701 (if (> beg end) (let (mid) (setq mid beg beg end end mid))) 701 (when (> beg end) (setq beg (prog1 end (setq end beg))))
702 (save-excursion 702 (save-excursion
703 (if uncomment-region-function 703 (if uncomment-region-function
704 (funcall uncomment-region-function beg end arg) 704 (funcall uncomment-region-function beg end arg)
705 (goto-char beg) 705 (goto-char beg)
706 (setq end (copy-marker end)) 706 (setq end (copy-marker end))
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 (comment-forward) 719 (unless
720 (or
721 (comment-forward)
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)))))
720 (error "Can't find the comment end")) 748 (error "Can't find the comment end"))
721 (point))) 749 (point)))
722 (box nil) 750 (box nil)
723 (box-equal nil)) ;Whether we might be using `=' for boxes. 751 (box-equal nil)) ;Whether we might be using `=' for boxes.
724 (save-restriction 752 (save-restriction