86 |
to understand comments or not in the given buffer. |
to understand comments or not in the given buffer. |
87 |
Major modes should set this variable.") |
Major modes should set this variable.") |
88 |
|
|
89 |
|
(defcustom comment-fill-column nil |
90 |
|
"Column to use for `comment-indent'. If nil, use `fill-column' instead." |
91 |
|
:type '(choice nil integer)) |
92 |
|
|
93 |
;;;###autoload |
;;;###autoload |
94 |
(defcustom comment-column 32 |
(defcustom comment-column 32 |
95 |
"*Column to indent right-margin comments to. |
"*Column to indent right-margin comments to. |
96 |
Each mode establishes a different default value for this variable; you |
Each mode establishes a different default value for this variable; you |
97 |
can set the value for a particular mode using that mode's hook. |
can set the value for a particular mode using that mode's hook. |
98 |
Comments might be indented to a value smaller than this in order |
Comments might be indented to a value smaller than this in order |
99 |
not to go beyond `fill-column'." |
not to go beyond `comment-fill-column'." |
100 |
:type 'integer) |
:type 'integer) |
101 |
(make-variable-buffer-local 'comment-column) |
(make-variable-buffer-local 'comment-column) |
102 |
|
|
483 |
(setq indent |
(setq indent |
484 |
(min indent |
(min indent |
485 |
(+ (current-column) |
(+ (current-column) |
486 |
(- fill-column |
(- (or comment-fill-column fill-column) |
487 |
(save-excursion (end-of-line) (current-column))))))) |
(save-excursion (end-of-line) (current-column))))))) |
488 |
(unless (= (current-column) indent) |
(unless (= (current-column) indent) |
489 |
;; If that's different from current, change it. |
;; If that's different from current, change it. |
897 |
'box-multi 'box))) |
'box-multi 'box))) |
898 |
(comment-region beg end (+ comment-add arg)))) |
(comment-region beg end (+ comment-add arg)))) |
899 |
|
|
900 |
|
|
901 |
|
;;;###autoload |
902 |
|
(defun comment-or-uncomment-region (beg end &optional arg) |
903 |
|
"Call `comment-region', unless the region only consists of comments, |
904 |
|
in which case call `uncomment-region'. If a prefix arg is given, it |
905 |
|
is passed on to the respective function." |
906 |
|
(interactive "*r\nP") |
907 |
|
(funcall (if (save-excursion ;; check for already commented region |
908 |
|
(goto-char beg) |
909 |
|
(comment-forward (point-max)) |
910 |
|
(<= end (point))) |
911 |
|
'uncomment-region 'comment-region) |
912 |
|
beg end arg)) |
913 |
|
|
914 |
;;;###autoload |
;;;###autoload |
915 |
(defun comment-dwim (arg) |
(defun comment-dwim (arg) |
916 |
"Call the comment command you want (Do What I Mean). |
"Call the comment command you want (Do What I Mean). |
923 |
(interactive "*P") |
(interactive "*P") |
924 |
(comment-normalize-vars) |
(comment-normalize-vars) |
925 |
(if (and mark-active transient-mark-mode) |
(if (and mark-active transient-mark-mode) |
926 |
(let ((beg (min (point) (mark))) |
(comment-or-uncomment-region (region-beginning) (region-end) arg) |
|
(end (max (point) (mark)))) |
|
|
(if (save-excursion ;; check for already commented region |
|
|
(goto-char beg) |
|
|
(comment-forward (point-max)) |
|
|
(<= end (point))) |
|
|
(uncomment-region beg end arg) |
|
|
(comment-region beg end arg))) |
|
927 |
(if (save-excursion (beginning-of-line) (not (looking-at "\\s-*$"))) |
(if (save-excursion (beginning-of-line) (not (looking-at "\\s-*$"))) |
928 |
;; FIXME: If there's no comment to kill on this line and ARG is |
;; FIXME: If there's no comment to kill on this line and ARG is |
929 |
;; specified, calling comment-kill is not very clever. |
;; specified, calling comment-kill is not very clever. |
980 |
(setq comin (point)))))) |
(setq comin (point)))))) |
981 |
|
|
982 |
;; Now we know we should auto-fill. |
;; Now we know we should auto-fill. |
983 |
(delete-horizontal-space) |
;; Insert the newline before removing empty space so that markers |
984 |
|
;; get preserved better. |
985 |
(if soft (insert-and-inherit ?\n) (newline 1)) |
(if soft (insert-and-inherit ?\n) (newline 1)) |
986 |
|
(save-excursion (forward-char -1) (delete-horizontal-space)) |
987 |
|
(delete-horizontal-space) |
988 |
|
|
989 |
(if (and fill-prefix (not adaptive-fill-mode)) |
(if (and fill-prefix (not adaptive-fill-mode)) |
990 |
;; Blindly trust a non-adaptive fill-prefix. |
;; Blindly trust a non-adaptive fill-prefix. |
991 |
(progn |
(progn |
992 |
(indent-to-left-margin) |
(indent-to-left-margin) |
993 |
(insert-and-inherit fill-prefix)) |
(insert-before-markers-and-inherit fill-prefix)) |
994 |
|
|
995 |
;; If necessary check whether we're inside a comment. |
;; If necessary check whether we're inside a comment. |
996 |
(unless (or compos (null comment-start)) |
(unless (or compos (null comment-start)) |