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


From: Stefan Monnier
Subject: [Emacs-diffs] Changes to emacs/lisp/newcomment.el
Date: Sat, 10 May 2003 18:54:36 -0400

Index: emacs/lisp/newcomment.el
diff -c emacs/lisp/newcomment.el:1.64 emacs/lisp/newcomment.el:1.65
*** emacs/lisp/newcomment.el:1.64       Fri May  9 16:09:04 2003
--- emacs/lisp/newcomment.el    Sat May 10 18:54:35 2003
***************
*** 1,6 ****
  ;;; newcomment.el --- (un)comment regions of buffers
  
! ;; Copyright (C) 1999, 2000  Free Software Foundation Inc.
  
  ;; Author: code extracted from Emacs-20's simple.el
  ;; Maintainer: Stefan Monnier <address@hidden>
--- 1,6 ----
  ;;; newcomment.el --- (un)comment regions of buffers
  
! ;; Copyright (C) 1999,2000,2003  Free Software Foundation Inc.
  
  ;; Author: code extracted from Emacs-20's simple.el
  ;; Maintainer: Stefan Monnier <address@hidden>
***************
*** 493,507 ****
        ;; Compute desired indent.
        (setq indent (save-excursion (funcall comment-indent-function)))
        (if (not indent)
!         ;; comment-indent-function refuses: delegate to indent.
          (indent-according-to-mode)
        ;; Avoid moving comments past the fill-column.
        (unless (save-excursion (skip-chars-backward " \t") (bolp))
!         (setq indent
!               (min indent
!                    (+ (current-column)
                        (- (or comment-fill-column fill-column)
!                          (save-excursion (end-of-line) (current-column)))))))
        (unless (= (current-column) indent)
          ;; If that's different from current, change it.
          (delete-region (point) (progn (skip-chars-backward " \t") (point)))
--- 493,528 ----
        ;; 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))))))
!           (if (<= max indent)
!               (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.
!                 (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))))))))
        (unless (= (current-column) indent)
          ;; If that's different from current, change it.
          (delete-region (point) (progn (skip-chars-backward " \t") (point)))
***************
*** 764,772 ****
  indentation to be kept as it was before narrowing."
    (declare (debug t) (indent 2))
    (let ((bindent (make-symbol "bindent")))
!     `(let ((,bindent (save-excursion (goto-char beg) (current-column))))
         (save-restriction
!        (narrow-to-region beg end)
         (goto-char (point-min))
         (insert (make-string ,bindent ? ))
         (prog1
--- 785,793 ----
  indentation to be kept as it was before narrowing."
    (declare (debug t) (indent 2))
    (let ((bindent (make-symbol "bindent")))
!     `(let ((,bindent (save-excursion (goto-char ,beg) (current-column))))
         (save-restriction
!        (narrow-to-region ,beg ,end)
         (goto-char (point-min))
         (insert (make-string ,bindent ? ))
         (prog1
***************
*** 988,1000 ****
  This has no effect in modes that do not define a comment syntax."
    :type 'boolean)
  
! (defun comment-valid-prefix (prefix compos)
    (or
     ;; Accept any prefix if the current comment is not EOL-terminated.
     (save-excursion (goto-char compos) (comment-forward) (not (bolp)))
     ;; Accept any prefix that starts with a comment-start marker.
     (string-match (concat "\\`[ \t]*\\(?:" comment-start-skip "\\)")
!                fill-prefix)))
  
  ;;;###autoload
  (defun comment-indent-new-line (&optional soft)
--- 1009,1021 ----
  This has no effect in modes that do not define a comment syntax."
    :type 'boolean)
  
! (defun comment-valid-prefix-p (prefix compos)
    (or
     ;; Accept any prefix if the current comment is not EOL-terminated.
     (save-excursion (goto-char compos) (comment-forward) (not (bolp)))
     ;; Accept any prefix that starts with a comment-start marker.
     (string-match (concat "\\`[ \t]*\\(?:" comment-start-skip "\\)")
!                prefix)))
  
  ;;;###autoload
  (defun comment-indent-new-line (&optional soft)
***************
*** 1048,1054 ****
         ;; a comment and the prefix is not a comment starter.
         ((and fill-prefix
               (or (not compos)
!                  (comment-valid-prefix fill-prefix compos)))
          (indent-to-left-margin)
          (insert-and-inherit fill-prefix))
         ;; If we're not inside a comment, just try to indent.
--- 1069,1075 ----
         ;; a comment and the prefix is not a comment starter.
         ((and fill-prefix
               (or (not compos)
!                  (comment-valid-prefix-p fill-prefix compos)))
          (indent-to-left-margin)
          (insert-and-inherit fill-prefix))
         ;; If we're not inside a comment, just try to indent.




reply via email to

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