/[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.68 by miles, Mon Sep 1 15:45:13 2003 UTC revision 1.69 by monnier, Fri Oct 24 20:26:26 2003 UTC
# Line 501  If CONTINUE is non-nil, use the `comment Line 501  If CONTINUE is non-nil, use the `comment
501        (goto-char begpos)        (goto-char begpos)
502        ;; Compute desired indent.        ;; Compute desired indent.
503        (setq indent (save-excursion (funcall comment-indent-function)))        (setq indent (save-excursion (funcall comment-indent-function)))
504          ;; If `indent' is nil and there's code before the comment, we can't
505          ;; use `indent-according-to-mode', so we default to comment-column.
506          (unless (or indent (save-excursion (skip-chars-backward " \t") (bolp)))
507            (setq indent comment-column))
508        (if (not indent)        (if (not indent)
509            ;; comment-indent-function refuses: delegate to line-indent.            ;; comment-indent-function refuses: delegate to line-indent.
510            (indent-according-to-mode)            (indent-according-to-mode)
511          ;; Avoid moving comments past the fill-column.          ;; If the comment is at the left of code, adjust the indentation.
512          (unless (save-excursion (skip-chars-backward " \t") (bolp))          (unless (save-excursion (skip-chars-backward " \t") (bolp))
513              ;; Avoid moving comments past the fill-column.
514            (let ((max (+ (current-column)            (let ((max (+ (current-column)
515                          (- (or comment-fill-column fill-column)                          (- (or comment-fill-column fill-column)
516                             (save-excursion (end-of-line) (current-column))))))                             (save-excursion (end-of-line) (current-column))))))
# Line 513  If CONTINUE is non-nil, use the `comment Line 518  If CONTINUE is non-nil, use the `comment
518                  (setq indent max)       ;Don't move past the fill column.                  (setq indent max)       ;Don't move past the fill column.
519                ;; We can choose anywhere between indent..max.                ;; We can choose anywhere between indent..max.
520                ;; Let's try to align to a comment on the previous line.                ;; Let's try to align to a comment on the previous line.
521                (let ((other nil))                (let ((other nil)
522                        (min (max indent
523                                  (save-excursion (skip-chars-backward " \t")
524                                                  (1+ (current-column))))))
525                  (save-excursion                  (save-excursion
526                    (when (and (zerop (forward-line -1))                    (when (and (zerop (forward-line -1))
527                               (setq other (comment-search-forward                               (setq other (comment-search-forward
528                                           (line-end-position) t)))                                           (line-end-position) t)))
529                      (goto-char other) (setq other (current-column))))                      (goto-char other) (setq other (current-column))))
530                  (if (and other (<= other max) (> other indent))                  (if (and other (<= other max) (>= other min))
531                      ;; There is a comment and it's in the range: bingo.                      ;; There is a comment and it's in the range: bingo.
532                      (setq indent other)                      (setq indent other)
533                    ;; Let's try to align to a comment on the next line, then.                    ;; Let's try to align to a comment on the next line, then.
# Line 529  If CONTINUE is non-nil, use the `comment Line 537  If CONTINUE is non-nil, use the `comment
537                                   (setq other (comment-search-forward                                   (setq other (comment-search-forward
538                                               (line-end-position) t)))                                               (line-end-position) t)))
539                          (goto-char other) (setq other (current-column))))                          (goto-char other) (setq other (current-column))))
540                      (if (and other (<= other max) (> other indent))                      (if (and other (<= other max) (> other min))
541                          ;; There is a comment and it's in the range: bingo.                          ;; There is a comment and it's in the range: bingo.
542                          (setq indent other))))))))                          (setq indent other))))))))
543          (unless (= (current-column) indent)          (unless (= (current-column) indent)

Legend:
Removed from v.1.68  
changed lines
  Added in v.1.69

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