/[emacs]/emacs/lisp/newcomment.el
ViewVC logotype

Diff of /emacs/lisp/newcomment.el

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

revision 1.38 by monnier, Tue Nov 13 20:17:26 2001 UTC revision 1.39 by monnier, Mon Nov 19 06:08:38 2001 UTC
# Line 464  If CONTINUE is non-nil, use the `comment Line 464  If CONTINUE is non-nil, use the `comment
464        ;; Compute desired indent.        ;; Compute desired indent.
465        (setq indent (save-excursion (funcall comment-indent-function)))        (setq indent (save-excursion (funcall comment-indent-function)))
466        (if (not indent)        (if (not indent)
467            ;; comment-indent-function refuses delegates to indent.            ;; comment-indent-function refuses: delegate to indent.
468            (indent-according-to-mode)            (indent-according-to-mode)
469          ;; Avoid moving comments past the fill-column.          ;; Avoid moving comments past the fill-column.
470          (setq indent          (unless (save-excursion (skip-chars-backward " \t") (bolp))
471                (min indent            (setq indent
472                     (+ (current-column)                  (min indent
473                        (- fill-column                       (+ (current-column)
474                           (save-excursion (end-of-line) (current-column))))))                          (- fill-column
475                               (save-excursion (end-of-line) (current-column)))))))
476          (unless (= (current-column) indent)          (unless (= (current-column) indent)
477            ;; If that's different from current, change it.            ;; If that's different from current, change it.
478            (delete-region (point) (progn (skip-chars-backward " \t") (point)))            (delete-region (point) (progn (skip-chars-backward " \t") (point)))
# Line 969  unless optional argument SOFT is non-nil Line 970  unless optional argument SOFT is non-nil
970              (insert-and-inherit fill-prefix))              (insert-and-inherit fill-prefix))
971    
972          ;; If necessary check whether we're inside a comment.          ;; If necessary check whether we're inside a comment.
973          (unless (or comment-multi-line compos (null comment-start))          (unless (or compos (null comment-start))
974            (save-excursion            (save-excursion
975              (backward-char)              (backward-char)
976              (setq compos (comment-beginning))              (setq compos (comment-beginning))
# Line 992  unless optional argument SOFT is non-nil Line 993  unless optional argument SOFT is non-nil
993                    ;; and the current comment's indentation, with a preference                    ;; and the current comment's indentation, with a preference
994                    ;; for comment-column.                    ;; for comment-column.
995                    (save-excursion                    (save-excursion
996                        ;; FIXME: use prev line's info rather than first line's.
997                      (goto-char compos)                      (goto-char compos)
998                      (min (current-column) (max comment-column                      (min (current-column) (max comment-column
999                                                 (+ 2 (current-indentation))))))                                                 (+ 2 (current-indentation))))))
# Line 1013  unless optional argument SOFT is non-nil Line 1015  unless optional argument SOFT is non-nil
1015                            (point))                            (point))
1016                           nil t)))))                           nil t)))))
1017                   (comment-start comstart)                   (comment-start comstart)
1018                     (continuep (or comment-multi-line
1019                                    (cadr (assoc comment-style comment-styles))))
1020                   ;; Force comment-continue to be recreated from comment-start.                   ;; Force comment-continue to be recreated from comment-start.
1021                   ;; FIXME: wrong if comment-continue was set explicitly!                   ;; FIXME: wrong if comment-continue was set explicitly!
1022                     ;; FIXME: use prev line's continuation if available.
1023                   (comment-continue nil))                   (comment-continue nil))
1024              (insert-and-inherit ?\n)              (if (and comment-multi-line (> (length comment-end) 0))
1025              (forward-char -1)                  (indent-according-to-mode)
1026              (comment-indent (cadr (assoc comment-style comment-styles)))                (insert-and-inherit ?\n)
1027              (save-excursion                (forward-char -1)
1028                (let ((pt (point)))                (comment-indent continuep)
1029                  (end-of-line)                (save-excursion
1030                  (let ((comend (buffer-substring pt (point))))                  (let ((pt (point)))
1031                    ;; The 1+ is to make sure we delete the \n inserted above.                    (end-of-line)
1032                    (delete-region pt (1+ (point)))                    (let ((comend (buffer-substring pt (point))))
1033                    (beginning-of-line)                      ;; The 1+ is to make sure we delete the \n inserted above.
1034                    (backward-char)                      (delete-region pt (1+ (point)))
1035                    (insert comend)                      (end-of-line 0)
1036                    (forward-char)))))))))))                      (insert comend))))))))))))
1037    
1038  (provide 'newcomment)  (provide 'newcomment)
1039    

Legend:
Removed from v.1.38  
changed lines
  Added in v.1.39

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