aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2000-05-25 19:13:41 +0000
committerStefan Monnier2000-05-25 19:13:41 +0000
commit64e5710226b77f312ab8567cc32f2d49df1c606d (patch)
tree65314fb64a86bf4a4fd7691f80d3e853a03c3870
parent5589b330a0abf7243a8aec08a4a785b4691c6b44 (diff)
downloademacs-64e5710226b77f312ab8567cc32f2d49df1c606d.tar.gz
emacs-64e5710226b77f312ab8567cc32f2d49df1c606d.zip
(fill-comment, comment-column, comment-start)
(comment-start-skip, comment-end, comment-indent-function) (block-comment-start, block-comment-end, indent-for-comment) (set-comment-column, kill-comment, comment-padding, comment-region) (comment-multi-line, indent-new-comment-line): Remove.
-rw-r--r--lisp/simple.el350
1 files changed, 0 insertions, 350 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index 69eab7d5bcb..9105231ad4f 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -35,11 +35,6 @@
35 "Killing and yanking commands" 35 "Killing and yanking commands"
36 :group 'editing) 36 :group 'editing)
37 37
38(defgroup fill-comments nil
39 "Indenting and filling of comments."
40 :prefix "comment-"
41 :group 'fill)
42
43(defgroup paren-matching nil 38(defgroup paren-matching nil
44 "Highlight (un)matching of parens and expressions." 39 "Highlight (un)matching of parens and expressions."
45 :group 'matching) 40 :group 'matching)
@@ -2617,266 +2612,10 @@ With argument 0, interchanges line point is in with line mark is in."
2617 (delete-region (point) (+ (point) len1)) 2612 (delete-region (point) (+ (point) len1))
2618 (insert word2))) 2613 (insert word2)))
2619 2614
2620(defcustom comment-column 32
2621 "*Column to indent right-margin comments to.
2622Setting this variable automatically makes it local to the current buffer.
2623Each mode establishes a different default value for this variable; you
2624can set the value for a particular mode using that mode's hook."
2625 :type 'integer
2626 :group 'fill-comments)
2627(make-variable-buffer-local 'comment-column)
2628
2629(defcustom comment-start nil
2630 "*String to insert to start a new comment, or nil if no comment syntax."
2631 :type '(choice (const :tag "None" nil)
2632 string)
2633 :group 'fill-comments)
2634
2635(defcustom comment-start-skip nil
2636 "*Regexp to match the start of a comment plus everything up to its body.
2637If there are any \\(...\\) pairs, the comment delimiter text is held to begin
2638at the place matched by the close of the first pair."
2639 :type '(choice (const :tag "None" nil)
2640 regexp)
2641 :group 'fill-comments)
2642
2643(defcustom comment-end ""
2644 "*String to insert to end a new comment.
2645Should be an empty string if comments are terminated by end-of-line."
2646 :type 'string
2647 :group 'fill-comments)
2648
2649(defvar comment-indent-hook nil 2615(defvar comment-indent-hook nil
2650 "Obsolete variable for function to compute desired indentation for a comment. 2616 "Obsolete variable for function to compute desired indentation for a comment.
2651This function is called with no args with point at the beginning of 2617This function is called with no args with point at the beginning of
2652the comment's starting delimiter.") 2618the comment's starting delimiter.")
2653
2654(defvar comment-indent-function
2655 (lambda () comment-column)
2656 "Function to compute desired indentation for a comment.
2657This function is called with no args with point at the beginning of
2658the comment's starting delimiter.")
2659
2660(defcustom block-comment-start nil
2661 "*String to insert to start a new comment on a line by itself.
2662If nil, use `comment-start' instead.
2663Note that the regular expression `comment-start-skip' should skip this string
2664as well as the `comment-start' string."
2665 :type '(choice (const :tag "Use comment-start" nil)
2666 string)
2667 :group 'fill-comments)
2668
2669(defcustom block-comment-end nil
2670 "*String to insert to end a new comment on a line by itself.
2671Should be an empty string if comments are terminated by end-of-line.
2672If nil, use `comment-end' instead."
2673 :type '(choice (const :tag "Use comment-end" nil)
2674 string)
2675 :group 'fill-comments)
2676
2677(defun indent-for-comment ()
2678 "Indent this line's comment to comment column, or insert an empty comment."
2679 (interactive "*")
2680 (let* ((empty (save-excursion (beginning-of-line)
2681 (looking-at "[ \t]*$")))
2682 (starter (or (and empty block-comment-start) comment-start))
2683 (ender (or (and empty block-comment-end) comment-end)))
2684 (cond
2685 ((null starter)
2686 (error "No comment syntax defined"))
2687 ((null comment-start-skip)
2688 (error "This mode doesn't define `comment-start-skip'"))
2689 (t (let* ((eolpos (save-excursion (end-of-line) (point)))
2690 cpos indent begpos)
2691 (beginning-of-line)
2692 (if (re-search-forward comment-start-skip eolpos 'move)
2693 (progn (setq cpos (point-marker))
2694 ;; Find the start of the comment delimiter.
2695 ;; If there were paren-pairs in comment-start-skip,
2696 ;; position at the end of the first pair.
2697 (if (match-end 1)
2698 (goto-char (match-end 1))
2699 ;; If comment-start-skip matched a string with
2700 ;; internal whitespace (not final whitespace) then
2701 ;; the delimiter start at the end of that
2702 ;; whitespace. Otherwise, it starts at the
2703 ;; beginning of what was matched.
2704 (skip-syntax-backward " " (match-beginning 0))
2705 (skip-syntax-backward "^ " (match-beginning 0)))))
2706 (setq begpos (point))
2707 ;; Compute desired indent.
2708 (if (= (current-column)
2709 (setq indent (if comment-indent-hook
2710 (funcall comment-indent-hook)
2711 (funcall comment-indent-function))))
2712 (goto-char begpos)
2713 ;; If that's different from current, change it.
2714 (skip-chars-backward " \t")
2715 (delete-region (point) begpos)
2716 (indent-to indent))
2717 ;; An existing comment?
2718 (if cpos
2719 (progn (goto-char cpos)
2720 (set-marker cpos nil))
2721 ;; No, insert one.
2722 (insert starter)
2723 (save-excursion
2724 (insert ender))))))))
2725
2726(defun set-comment-column (arg)
2727 "Set the comment column based on point.
2728With no arg, set the comment column to the current column.
2729With just minus as arg, kill any comment on this line.
2730With any other arg, set comment column to indentation of the previous comment
2731 and then align or create a comment on this line at that column."
2732 (interactive "P")
2733 (if (eq arg '-)
2734 (kill-comment nil)
2735 (if arg
2736 (progn
2737 (save-excursion
2738 (beginning-of-line)
2739 (re-search-backward comment-start-skip)
2740 (beginning-of-line)
2741 (re-search-forward comment-start-skip)
2742 (goto-char (match-beginning 0))
2743 (setq comment-column (current-column))
2744 (message "Comment column set to %d" comment-column))
2745 (indent-for-comment))
2746 (setq comment-column (current-column))
2747 (message "Comment column set to %d" comment-column))))
2748
2749(defun kill-comment (arg)
2750 "Kill the comment on this line, if any.
2751With argument, kill comments on that many lines starting with this one."
2752 ;; this function loses in a lot of situations. it incorrectly recognises
2753 ;; comment delimiters sometimes (ergo, inside a string), doesn't work
2754 ;; with multi-line comments, can kill extra whitespace if comment wasn't
2755 ;; through end-of-line, et cetera.
2756 (interactive "P")
2757 (or comment-start-skip (error "No comment syntax defined"))
2758 (let ((count (prefix-numeric-value arg)) endc)
2759 (while (> count 0)
2760 (save-excursion
2761 (end-of-line)
2762 (setq endc (point))
2763 (beginning-of-line)
2764 (and (string< "" comment-end)
2765 (setq endc
2766 (progn
2767 (re-search-forward (regexp-quote comment-end) endc 'move)
2768 (skip-chars-forward " \t")
2769 (point))))
2770 (beginning-of-line)
2771 (if (re-search-forward comment-start-skip endc t)
2772 (progn
2773 (goto-char (match-beginning 0))
2774 (skip-chars-backward " \t")
2775 (kill-region (point) endc)
2776 ;; to catch comments a line beginnings
2777 (indent-according-to-mode))))
2778 (if arg (forward-line 1))
2779 (setq count (1- count)))))
2780
2781(defvar comment-padding 1
2782 "Number of spaces `comment-region' puts between comment chars and text.
2783
2784Extra spacing between the comment characters and the comment text
2785makes the comment easier to read. Default is 1. Nil means 0 and is
2786more efficient.")
2787
2788(defun comment-region (beg end &optional arg)
2789 "Comment or uncomment each line in the region.
2790With just C-u prefix arg, uncomment each line in region.
2791Numeric prefix arg ARG means use ARG comment characters.
2792If ARG is negative, delete that many comment characters instead.
2793Comments are terminated on each line, even for syntax in which newline does
2794not end the comment. Blank lines do not get comments.
2795
2796The strings used as comment starts are build from
2797`comment-start' without trailing spaces and `comment-padding'."
2798 ;; if someone wants it to only put a comment-start at the beginning and
2799 ;; comment-end at the end then typing it, C-x C-x, closing it, C-x C-x
2800 ;; is easy enough. No option is made here for other than commenting
2801 ;; every line.
2802 (interactive "*r\nP")
2803 (or comment-start (error "No comment syntax is defined"))
2804 (if (> beg end) (let (mid) (setq mid beg beg end end mid)))
2805 (save-excursion
2806 (save-restriction
2807 (let* ((comment-start
2808 (substring comment-start 0
2809 (string-match "[ \t]*$" comment-start)))
2810 (cs comment-start) (ce comment-end)
2811 (cp (when comment-padding
2812 (make-string comment-padding ? )))
2813 numarg)
2814 (if (consp arg) (setq numarg t)
2815 (setq numarg (prefix-numeric-value arg))
2816 ;; For positive arg > 1, replicate the comment delims now,
2817 ;; then insert the replicated strings just once.
2818 (while (> numarg 1)
2819 (setq cs (concat cs comment-start)
2820 ce (concat ce comment-end))
2821 (setq numarg (1- numarg))))
2822 ;; Loop over all lines from BEG to END.
2823 (narrow-to-region beg end)
2824 (goto-char beg)
2825 (if (or (eq numarg t) (< numarg 0))
2826 (while (not (eobp))
2827 (let (found-comment)
2828 ;; Delete comment start from beginning of line.
2829 (if (eq numarg t)
2830 (while (looking-at (regexp-quote cs))
2831 (setq found-comment t)
2832 (delete-char (length cs)))
2833 (let ((count numarg))
2834 (while (and (> 1 (setq count (1+ count)))
2835 (looking-at (regexp-quote cs)))
2836 (setq found-comment t)
2837 (delete-char (length cs)))))
2838 ;; Delete comment padding from beginning of line
2839 (when (and found-comment comment-padding
2840 (looking-at (regexp-quote cp)))
2841 (delete-char comment-padding))
2842 ;; Delete comment end from end of line.
2843 (if (string= "" ce)
2844 nil
2845 (if (eq numarg t)
2846 (progn
2847 (end-of-line)
2848 ;; This is questionable if comment-end ends in
2849 ;; whitespace. That is pretty brain-damaged,
2850 ;; though.
2851 (while (progn (skip-chars-backward " \t")
2852 (and (>= (- (point) (point-min)) (length ce))
2853 (save-excursion
2854 (backward-char (length ce))
2855 (looking-at (regexp-quote ce)))))
2856 (delete-char (- (length ce)))))
2857 (let ((count numarg))
2858 (while (> 1 (setq count (1+ count)))
2859 (end-of-line)
2860 ;; this is questionable if comment-end ends in whitespace
2861 ;; that is pretty brain-damaged though
2862 (skip-chars-backward " \t")
2863 (if (>= (- (point) (point-min)) (length ce))
2864 (save-excursion
2865 (backward-char (length ce))
2866 (if (looking-at (regexp-quote ce))
2867 (delete-char (length ce)))))))))
2868 (forward-line 1)))
2869
2870 (when comment-padding
2871 (setq cs (concat cs cp)))
2872 (while (not (eobp))
2873 ;; Insert at beginning and at end.
2874 (if (looking-at "[ \t]*$") ()
2875 (insert cs)
2876 (if (string= "" ce) ()
2877 (end-of-line)
2878 (insert ce)))
2879 (search-forward "\n" nil 'move)))))))
2880 2619
2881(defun backward-word (arg) 2620(defun backward-word (arg)
2882 "Move backward until encountering the end of a word. 2621 "Move backward until encountering the end of a word.
@@ -3146,95 +2885,6 @@ Just \\[universal-argument] as argument means to use the current column."
3146 (message "Fill column set to %d (was %d)" arg fill-column) 2885 (message "Fill column set to %d (was %d)" arg fill-column)
3147 (setq fill-column arg))) 2886 (setq fill-column arg)))
3148 2887
3149(defcustom comment-multi-line nil
3150 "*Non-nil means \\[indent-new-comment-line] should continue same comment
3151on new line, with no new terminator or starter.
3152This is obsolete because you might as well use \\[newline-and-indent]."
3153 :type 'boolean
3154 :group 'fill-comments)
3155
3156(defun indent-new-comment-line (&optional soft)
3157 "Break line at point and indent, continuing comment if within one.
3158This indents the body of the continued comment
3159under the previous comment line.
3160
3161This command is intended for styles where you write a comment per line,
3162starting a new comment (and terminating it if necessary) on each line.
3163If you want to continue one comment across several lines, use \\[newline-and-indent].
3164
3165If a fill column is specified, it overrides the use of the comment column
3166or comment indentation.
3167
3168The inserted newline is marked hard if `use-hard-newlines' is true,
3169unless optional argument SOFT is non-nil."
3170 (interactive)
3171 (let (comcol comstart)
3172 (skip-chars-backward " \t")
3173 (delete-region (point)
3174 (progn (skip-chars-forward " \t")
3175 (point)))
3176 (if soft (insert-and-inherit ?\n) (newline 1))
3177 (if fill-prefix
3178 (progn
3179 (indent-to-left-margin)
3180 (insert-and-inherit fill-prefix))
3181 (if (not comment-multi-line)
3182 (save-excursion
3183 (if (and comment-start-skip
3184 (let ((opoint (1- (point)))
3185 inside)
3186 (forward-line -1)
3187 ;; Determine (more or less) whether
3188 ;; target position is inside a comment.
3189 (while (and (re-search-forward comment-start-skip opoint t)
3190 (not (setq inside (or (equal comment-end "")
3191 (not (search-forward comment-end opoint t)))))))
3192 inside))
3193 ;; The old line has a comment and point was inside the comment.
3194 ;; Set WIN to the pos of the comment-start.
3195 ;; But if the comment is empty, look at preceding lines
3196 ;; to find one that has a nonempty comment.
3197
3198 ;; If comment-start-skip contains a \(...\) pair,
3199 ;; the real comment delimiter starts at the end of that pair.
3200 (let ((win (or (match-end 1) (match-beginning 0))))
3201 (while (and (eolp) (not (bobp))
3202 (let (opoint)
3203 (beginning-of-line)
3204 (setq opoint (point))
3205 (forward-line -1)
3206 (re-search-forward comment-start-skip opoint t)))
3207 (setq win (or (match-end 1) (match-beginning 0))))
3208 ;; Indent this line like what we found.
3209 (goto-char win)
3210 (setq comcol (current-column))
3211 (setq comstart
3212 (buffer-substring (point) (match-end 0)))))))
3213 (if comcol
3214 (let ((comment-column comcol)
3215 (comment-start comstart)
3216 (comment-end comment-end))
3217 (and comment-end (not (equal comment-end ""))
3218 ; (if (not comment-multi-line)
3219 (progn
3220 (forward-char -1)
3221 (insert comment-end)
3222 (forward-char 1))
3223 ; (setq comment-column (+ comment-column (length comment-start))
3224 ; comment-start "")
3225 ; )
3226 )
3227 (if (not (eolp))
3228 (setq comment-end ""))
3229 (insert-and-inherit ?\n)
3230 (forward-char -1)
3231 (indent-for-comment)
3232 (save-excursion
3233 ;; Make sure we delete the newline inserted above.
3234 (end-of-line)
3235 (delete-char 1)))
3236 (indent-according-to-mode)))))
3237
3238(defun set-selective-display (arg) 2888(defun set-selective-display (arg)
3239 "Set `selective-display' to ARG; clear it if no arg. 2889 "Set `selective-display' to ARG; clear it if no arg.
3240When the value of `selective-display' is a number > 0, 2890When the value of `selective-display' is a number > 0,