emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/newcomment.el [lexbind]


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/lisp/newcomment.el [lexbind]
Date: Thu, 20 Nov 2003 19:36:39 -0500

Index: emacs/lisp/newcomment.el
diff -c emacs/lisp/newcomment.el:1.48.2.2 emacs/lisp/newcomment.el:1.48.2.3
*** emacs/lisp/newcomment.el:1.48.2.2   Tue Oct 14 19:51:20 2003
--- emacs/lisp/newcomment.el    Thu Nov 20 19:36:06 2003
***************
*** 501,511 ****
        (goto-char begpos)
        ;; Compute desired indent.
        (setq indent (save-excursion (funcall comment-indent-function)))
        (if (not indent)
          ;; comment-indent-function refuses: delegate to line-indent.
          (indent-according-to-mode)
!       ;; Avoid moving comments past the fill-column.
        (unless (save-excursion (skip-chars-backward " \t") (bolp))
          (let ((max (+ (current-column)
                        (- (or comment-fill-column fill-column)
                           (save-excursion (end-of-line) (current-column))))))
--- 501,516 ----
        (goto-char begpos)
        ;; Compute desired indent.
        (setq indent (save-excursion (funcall comment-indent-function)))
+       ;; If `indent' is nil and there's code before the comment, we can't
+       ;; use `indent-according-to-mode', so we default to comment-column.
+       (unless (or indent (save-excursion (skip-chars-backward " \t") (bolp)))
+       (setq indent comment-column))
        (if (not indent)
          ;; comment-indent-function refuses: delegate to line-indent.
          (indent-according-to-mode)
!       ;; If the comment is at the left of code, adjust the indentation.
        (unless (save-excursion (skip-chars-backward " \t") (bolp))
+         ;; Avoid moving comments past the fill-column.
          (let ((max (+ (current-column)
                        (- (or comment-fill-column fill-column)
                           (save-excursion (end-of-line) (current-column))))))
***************
*** 513,525 ****
                (setq indent max)       ;Don't move past the fill column.
              ;; We can choose anywhere between indent..max.
              ;; Let's try to align to a comment on the previous line.
!             (let ((other nil))
                (save-excursion
                  (when (and (zerop (forward-line -1))
                             (setq other (comment-search-forward
                                         (line-end-position) t)))
                    (goto-char other) (setq other (current-column))))
!               (if (and other (<= other max) (> other indent))
                    ;; There is a comment and it's in the range: bingo.
                    (setq indent other)
                  ;; Let's try to align to a comment on the next line, then.
--- 518,533 ----
                (setq indent max)       ;Don't move past the fill column.
              ;; We can choose anywhere between indent..max.
              ;; Let's try to align to a comment on the previous line.
!             (let ((other nil)
!                   (min (max indent
!                             (save-excursion (skip-chars-backward " \t")
!                                             (1+ (current-column))))))
                (save-excursion
                  (when (and (zerop (forward-line -1))
                             (setq other (comment-search-forward
                                         (line-end-position) t)))
                    (goto-char other) (setq other (current-column))))
!               (if (and other (<= other max) (>= other min))
                    ;; There is a comment and it's in the range: bingo.
                    (setq indent other)
                  ;; Let's try to align to a comment on the next line, then.
***************
*** 529,535 ****
                                 (setq other (comment-search-forward
                                             (line-end-position) t)))
                        (goto-char other) (setq other (current-column))))
!                   (if (and other (<= other max) (> other indent))
                        ;; There is a comment and it's in the range: bingo.
                        (setq indent other))))))))
        (unless (= (current-column) indent)
--- 537,543 ----
                                 (setq other (comment-search-forward
                                             (line-end-position) t)))
                        (goto-char other) (setq other (current-column))))
!                   (if (and other (<= other max) (> other min))
                        ;; There is a comment and it's in the range: bingo.
                        (setq indent other))))))))
        (unless (= (current-column) indent)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]