/[emacs]/emacs/lisp/progmodes/cc-cmds.el
ViewVC logotype

Diff of /emacs/lisp/progmodes/cc-cmds.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.28 by mast, Wed Apr 24 00:48:52 2002 UTC revision 1.29 by mast, Wed Apr 24 01:27:15 2002 UTC
# Line 2761  command to conveniently insert and align Line 2761  command to conveniently insert and align
2761                    '("" . 0))))))                    '("" . 0))))))
2762      ))      ))
2763    
2764  (defun c-mask-comment (fill-mode apply-outside-literal fun &rest args)  (defun c-mask-comment (fill-paragraph apply-outside-literal fun &rest args)
2765    ;; Calls FUN with ARGS ar arguments.  If point is inside a comment,    ;; Calls FUN with ARGS ar arguments.  If point is inside a comment,
2766    ;; the comment starter and ender are masked and the buffer is    ;; the comment starter and ender are masked and the buffer is
2767    ;; narrowed to make it look like a normal paragraph during the call.    ;; narrowed to make it look like a normal paragraph during the call.
2768      ;;
2769      ;; FILL-PARAGRAPH is non-nil if called for paragraph filling.  The
2770      ;; position of point is then less significant when doing masking and
2771      ;; narrowing.
2772    (let (fill    (let (fill
2773          ;; beg and end limits the region to narrow.  end is a marker.          ;; beg and end limits the region to narrow.  end is a marker.
2774          beg end          beg end
# Line 2790  command to conveniently insert and align Line 2794  command to conveniently insert and align
2794        ;; Widen to catch comment limits correctly.        ;; Widen to catch comment limits correctly.
2795        (widen)        (widen)
2796        (unless c-lit-limits        (unless c-lit-limits
2797          (setq c-lit-limits (c-literal-limits nil fill-mode)))          (setq c-lit-limits (c-literal-limits nil fill-paragraph)))
2798        (setq c-lit-limits (c-collect-line-comments c-lit-limits))        (setq c-lit-limits (c-collect-line-comments c-lit-limits))
2799        (unless c-lit-type        (unless c-lit-type
2800          (setq c-lit-type (c-literal-type c-lit-limits))))          (setq c-lit-type (c-literal-type c-lit-limits))))
# Line 2840  command to conveniently insert and align Line 2844  command to conveniently insert and align
2844                                                   "\\)\\*/"))                                                   "\\)\\*/"))
2845                               (eq (cdr c-lit-limits) (match-end 0))                               (eq (cdr c-lit-limits) (match-end 0))
2846                               ;; Leave the comment ender on its own line.                               ;; Leave the comment ender on its own line.
2847                               (set-marker end (max (point) here))))                               (set-marker end (point))))
2848                  (when fill-mode                  (when fill-paragraph
2849                    ;; The comment ender should hang.  Replace all cruft                    ;; The comment ender should hang.  Replace all cruft
2850                    ;; between it and the last word with one or two 'x'                    ;; between it and the last word with one or two 'x'
2851                    ;; and include it in the region.  We'll change them                    ;; and include it in the region.  We'll change them
# Line 2900  command to conveniently insert and align Line 2904  command to conveniently insert and align
2904                ;; The region includes the comment starter.                ;; The region includes the comment starter.
2905                (save-excursion                (save-excursion
2906                  (goto-char (car c-lit-limits))                  (goto-char (car c-lit-limits))
2907                  (when (and (looking-at comment-start-skip)                  (if (looking-at (concat "\\(" comment-start-skip "\\)$"))
2908                             (> here (match-end 0)))                      ;; Begin with the next line.
2909                    (if (eq (match-end 0) (c-point 'eol))                      (setq beg (c-point 'bonl))
2910                        ;; Begin with the next line.                    ;; Fake the fill prefix in the first line.
2911                        (setq beg (c-point 'bonl))                    (setq tmp-pre t)))))
                     ;; Fake the fill prefix in the first line.  
                     (setq tmp-pre t))))))  
2912             ((eq c-lit-type 'string)     ; String.             ((eq c-lit-type 'string)     ; String.
2913              (save-excursion              (save-excursion
2914                (when (>= end (cdr c-lit-limits))                (when (>= end (cdr c-lit-limits))
# Line 2984  Warning: Regexp from `c-comment-prefix-r Line 2986  Warning: Regexp from `c-comment-prefix-r
2986                                                ""))))                                                ""))))
2987                             (car (or fill (c-guess-fill-prefix                             (car (or fill (c-guess-fill-prefix
2988                                            c-lit-limits c-lit-type))))))                                            c-lit-limits c-lit-type))))))
2989                      ;; Don't remember why I added this, but it doesn't                      ;; Save the relative position of point if it's
2990                      ;; work correctly since `here' can point anywhere                      ;; outside the region we're going to narrow.  Want
2991                      ;; after the deletes and inserts above.                      ;; to restore it in that case, but otherwise it
2992                      ;(point-rel (cond ((< here beg) (- here beg))                      ;; should be moved according to the called
2993                      ;                  ((> here end) (- here end))))                      ;; function.
2994                      )                      (point-rel (cond ((< (point) beg) (- (point) beg))
2995                                         ((> (point) end) (- (point) end)))))
2996                  ;; Preparations finally done! Now we can call the                  ;; Preparations finally done! Now we can call the
2997                  ;; actual function.                  ;; actual function.
2998                  (prog1                  (prog1
2999                      (save-restriction                      (save-restriction
3000                        (narrow-to-region beg end)                        (narrow-to-region beg end)
3001                        (apply fun args))                        (apply fun args))
3002                    ;(if point-rel                    (if point-rel
3003                    ;    ;; Restore point if it was outside the region.                        ;; Restore point if it was outside the region.
3004                    ;    (if (< point-rel 0)                        (if (< point-rel 0)
3005                    ;       (goto-char (+ beg point-rel))                            (goto-char (+ beg point-rel))
3006                    ;     (goto-char (+ end point-rel))))                          (goto-char (+ end point-rel))))))
                   ))  
3007              (when apply-outside-literal              (when apply-outside-literal
3008                (apply fun args))))                (apply fun args))))
3009        (when (consp tmp-pre)        (when (consp tmp-pre)

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.29

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26