diff options
| author | Eli Zaretskii | 2004-09-04 12:31:09 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2004-09-04 12:31:09 +0000 |
| commit | cbdad6e2d1958e2bea1873594e6dd8458c07d9b5 (patch) | |
| tree | 09e6be46ee60545c7fe7cbd5e776455d5cbd92a8 | |
| parent | 0a4dd4e4915a9b3ac787f800f92e2d225e504f92 (diff) | |
| download | emacs-cbdad6e2d1958e2bea1873594e6dd8458c07d9b5.tar.gz emacs-cbdad6e2d1958e2bea1873594e6dd8458c07d9b5.zip | |
(uncomment-region): Bind comment-use-global-state to nil.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/newcomment.el | 105 |
2 files changed, 60 insertions, 50 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 96fa1656f0a..e4f15722f95 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2004-09-04 Dan Nicolaescu <dann@ics.uci.edu> | ||
| 2 | |||
| 3 | * newcomment.el (uncomment-region): Bind comment-use-global-state | ||
| 4 | to nil. | ||
| 5 | |||
| 1 | 2004-09-03 Luc Teirlinck <teirllm@auburn.edu> | 6 | 2004-09-03 Luc Teirlinck <teirllm@auburn.edu> |
| 2 | 7 | ||
| 3 | * autorevert.el (auto-revert-handler): Bind `buffer-read-only' | 8 | * autorevert.el (auto-revert-handler): Bind `buffer-read-only' |
diff --git a/lisp/newcomment.el b/lisp/newcomment.el index 22713f87a96..f4d4dc860d5 100644 --- a/lisp/newcomment.el +++ b/lisp/newcomment.el | |||
| @@ -710,54 +710,59 @@ comment markers." | |||
| 710 | (interactive "*r\nP") | 710 | (interactive "*r\nP") |
| 711 | (comment-normalize-vars) | 711 | (comment-normalize-vars) |
| 712 | (when (> beg end) (setq beg (prog1 end (setq end beg)))) | 712 | (when (> beg end) (setq beg (prog1 end (setq end beg)))) |
| 713 | (save-excursion | 713 | |
| 714 | (if uncomment-region-function | 714 | ;; Bind `comment-use-global-state' to nil. While uncommenting a |
| 715 | (funcall uncomment-region-function beg end arg) | 715 | ;; (which works a line at a time) region a comment can appear to be |
| 716 | (goto-char beg) | 716 | ;; included in a mult-line string, but it is actually not. |
| 717 | (setq end (copy-marker end)) | 717 | (let ((comment-use-global-state nil)) |
| 718 | (let* ((numarg (prefix-numeric-value arg)) | 718 | (save-excursion |
| 719 | (ccs comment-continue) | 719 | (if uncomment-region-function |
| 720 | (srei (comment-padright ccs 're)) | 720 | (funcall uncomment-region-function beg end arg) |
| 721 | (csre (comment-padright comment-start 're)) | 721 | (goto-char beg) |
| 722 | (sre (and srei (concat "^\\s-*?\\(" srei "\\)"))) | 722 | (setq end (copy-marker end)) |
| 723 | spt) | 723 | (let* ((numarg (prefix-numeric-value arg)) |
| 724 | (while (and (< (point) end) | 724 | (ccs comment-continue) |
| 725 | (setq spt (comment-search-forward end t))) | 725 | (srei (comment-padright ccs 're)) |
| 726 | (let ((ipt (point)) | 726 | (csre (comment-padright comment-start 're)) |
| 727 | ;; Find the end of the comment. | 727 | (sre (and srei (concat "^\\s-*?\\(" srei "\\)"))) |
| 728 | (ept (progn | 728 | spt) |
| 729 | (goto-char spt) | 729 | (while (and (< (point) end) |
| 730 | (unless (or (comment-forward) | 730 | (setq spt (comment-search-forward end t))) |
| 731 | ;; Allow non-terminated comments. | 731 | (let ((ipt (point)) |
| 732 | (eobp)) | 732 | ;; Find the end of the comment. |
| 733 | (error "Can't find the comment end")) | 733 | (ept (progn |
| 734 | (point))) | 734 | (goto-char spt) |
| 735 | (box nil) | 735 | (unless (or (comment-forward) |
| 736 | (box-equal nil)) ;Whether we might be using `=' for boxes. | 736 | ;; Allow non-terminated comments. |
| 737 | (save-restriction | 737 | (eobp)) |
| 738 | (narrow-to-region spt ept) | 738 | (error "Can't find the comment end")) |
| 739 | 739 | (point))) | |
| 740 | ;; Remove the comment-start. | 740 | (box nil) |
| 741 | (goto-char ipt) | 741 | (box-equal nil)) ;Whether we might be using `=' for boxes. |
| 742 | (skip-syntax-backward " ") | 742 | (save-restriction |
| 743 | ;; A box-comment starts with a looong comment-start marker. | 743 | (narrow-to-region spt ept) |
| 744 | (when (and (or (and (= (- (point) (point-min)) 1) | 744 | |
| 745 | (setq box-equal t) | 745 | ;; Remove the comment-start. |
| 746 | (looking-at "=\\{7\\}") | 746 | (goto-char ipt) |
| 747 | (not (eq (char-before (point-max)) ?\n)) | 747 | (skip-syntax-backward " ") |
| 748 | (skip-chars-forward "=")) | 748 | ;; A box-comment starts with a looong comment-start marker. |
| 749 | (> (- (point) (point-min) (length comment-start)) 7)) | 749 | (when (and (or (and (= (- (point) (point-min)) 1) |
| 750 | (> (count-lines (point-min) (point-max)) 2)) | 750 | (setq box-equal t) |
| 751 | (setq box t)) | 751 | (looking-at "=\\{7\\}") |
| 752 | ;; Skip the padding. Padding can come from comment-padding and/or | 752 | (not (eq (char-before (point-max)) ?\n)) |
| 753 | ;; from comment-start, so we first check comment-start. | 753 | (skip-chars-forward "=")) |
| 754 | (if (or (save-excursion (goto-char (point-min)) (looking-at csre)) | 754 | (> (- (point) (point-min) (length comment-start)) 7)) |
| 755 | (looking-at (regexp-quote comment-padding))) | 755 | (> (count-lines (point-min) (point-max)) 2)) |
| 756 | (goto-char (match-end 0))) | 756 | (setq box t)) |
| 757 | (when (and sre (looking-at (concat "\\s-*\n\\s-*" srei))) | 757 | ;; Skip the padding. Padding can come from comment-padding and/or |
| 758 | (goto-char (match-end 0))) | 758 | ;; from comment-start, so we first check comment-start. |
| 759 | (if (null arg) (delete-region (point-min) (point)) | 759 | (if (or (save-excursion (goto-char (point-min)) (looking-at csre)) |
| 760 | (skip-syntax-backward " ") | 760 | (looking-at (regexp-quote comment-padding))) |
| 761 | (goto-char (match-end 0))) | ||
| 762 | (when (and sre (looking-at (concat "\\s-*\n\\s-*" srei))) | ||
| 763 | (goto-char (match-end 0))) | ||
| 764 | (if (null arg) (delete-region (point-min) (point)) | ||
| 765 | (skip-syntax-backward " ") | ||
| 761 | (delete-char (- numarg)) | 766 | (delete-char (- numarg)) |
| 762 | (unless (or (bobp) | 767 | (unless (or (bobp) |
| 763 | (save-excursion (goto-char (point-min)) | 768 | (save-excursion (goto-char (point-min)) |
| @@ -765,7 +770,7 @@ comment markers." | |||
| 765 | ;; If there's something left but it doesn't look like | 770 | ;; If there's something left but it doesn't look like |
| 766 | ;; a comment-start any more, just remove it. | 771 | ;; a comment-start any more, just remove it. |
| 767 | (delete-region (point-min) (point)))) | 772 | (delete-region (point-min) (point)))) |
| 768 | 773 | ||
| 769 | ;; Remove the end-comment (and leading padding and such). | 774 | ;; Remove the end-comment (and leading padding and such). |
| 770 | (goto-char (point-max)) (comment-enter-backward) | 775 | (goto-char (point-max)) (comment-enter-backward) |
| 771 | ;; Check for special `=' used sometimes in comment-box. | 776 | ;; Check for special `=' used sometimes in comment-box. |
| @@ -803,7 +808,7 @@ comment markers." | |||
| 803 | (replace-match "" t t nil (if (match-end 2) 2 1))))) | 808 | (replace-match "" t t nil (if (match-end 2) 2 1))))) |
| 804 | ;; Go to the end for the next comment. | 809 | ;; Go to the end for the next comment. |
| 805 | (goto-char (point-max))))))) | 810 | (goto-char (point-max))))))) |
| 806 | (set-marker end nil))) | 811 | (set-marker end nil)))) |
| 807 | 812 | ||
| 808 | (defun comment-make-extra-lines (cs ce ccs cce min-indent max-indent &optional block) | 813 | (defun comment-make-extra-lines (cs ce ccs cce min-indent max-indent &optional block) |
| 809 | "Make the leading and trailing extra lines. | 814 | "Make the leading and trailing extra lines. |