(progn
(declare-buffer-specific comment-continuation)
(declare-buffer-specific comment-begin)
(declare-buffer-specific comment-start)
(declare-buffer-specific comment-end)
(declare-buffer-specific dont-wrap-comments)
(setq-default comment-begin "# ")
(setq-default comment-start "#")
(setq-default comment-end "")
(setq-default comment-continuation "")
(setq-default dont-wrap-comments 0)
(defun
(global-comment
(if prefix-argument-provided
(edit-global-comment)
(begin-global-comment))))
(defun
(begin-global-comment &comment-prefix& &comment-continuation&
&comment-continuation-fill& &comment-continuation-size&
(save-excursion
(set-mark)
(beginning-of-line)
(setq &comment-prefix& (region-to-string))
(&create-comment-continuation &comment-prefix&))
(insert-string comment-begin)
(if (! (looking-at "$"))
(save-excursion (insert-string "\n")))
(global-comment-recurse)
(if (save-excursion
(set-mark)
(beginning-of-line)
(if (= (region-to-string)
(concat &comment-prefix& comment-begin))
(progn
(delete-to-killbuffer)
0)
(= (region-to-string) &comment-continuation-fill&)
(progn
(exchange-dot-and-mark)
(provide-prefix-argument &comment-continuation-size&
(delete-previous-character))
1)
1))
(insert-string comment-end))
(novalue)))
(defun
(edit-global-comment &comment-continuation& &comment-continuation-fill&
&comment-continuation-size&
(save-excursion
(search-reverse comment-start)
(set-mark)
(beginning-of-line)
(&create-comment-continuation (region-to-string)))
(global-comment-recurse)))
(defun
(global-comment-recurse old-return old-lf old-c-o old-right-margin
old-mode old-auto-fill old-m-j
(setq old-return (local-binding-of '^M'))
(setq old-lf (local-binding-of '^J'))
(setq old-c-o (local-binding-of '^O'))
(setq old-right-margin right-margin)
(setq old-m-j (local-binding-of "\ej"))
(setq old-mode mode-string)
(setq old-auto-fill "")
(error-occured
(setq mode-string (concat mode-string " Global Comment"))
(setq right-margin 72)
(local-bind-to-key "comment-return" '^M')
(local-bind-to-key "comment-lf" '^J')
(local-bind-to-key "comment-c-o" '^O')
(local-bind-to-key "fill-global-comment-paragraph" "\ej")
(setq old-auto-fill (set-auto-fill-hook "comment-auto-fill"))
(recursive-edit))
(local-bind-to-key old-return "\^M")
(local-bind-to-key old-lf "\^J")
(local-bind-to-key old-c-o "\^O")
(local-bind-to-key old-m-j "\ej")
(if (!= old-auto-fill "")
(set-auto-fill-hook old-auto-fill))
(setq mode-string old-mode)
(setq right-margin old-right-margin)))
(defun
(&create-comment-continuation middle cont
(if (= comment-continuation "")
(setq comment-continuation
(concat comment-end "\^J" comment-begin)))
(setq middle (arg 1 "fill "))
(setq cont comment-continuation)
(temp-use-buffer "Scratch")
(erase-buffer)
(insert-string cont)
(beginning-of-file)
(if (error-occured (search-forward "\^J"))
(insert-character '^j'))
(setq &comment-continuation-size& (+ 1 (- (buffer-size) (dot))))
(set-mark)
(insert-string middle)
(end-of-file)
(setq &comment-continuation-fill& (region-to-string))
(set-mark)
(beginning-of-file)
(setq &comment-continuation& (region-to-string))))
(defun
(comment-return
(prefix-argument-loop
(insert-string &comment-continuation&)))
(comment-lf
(comment-return)
(tab-to-tab-stop))
(comment-c-o
(save-excursion
(if (bolp)
(backward-character))
(prefix-argument-loop
(insert-string &comment-continuation&))))
(comment-auto-fill
(save-restriction
(save-excursion
(set-mark)
(beginning-of-line)
(narrow-region))
(save-excursion
(while (& (>= (current-column) right-margin)
(! (error-occured (re-search-reverse "[ \t]"))))
(novalue))
(delete-white-space)
(insert-string &comment-continuation&)
(insert-string prefix-string)))))
(defun
(fill-global-comment-paragraph old-right old-left cont col
(if (!= (local-binding-of '^M') "comment-return")
(error-message "Must be in global comment edit to run"
" fill-global-comment-paragraph"))
(save-excursion
(setq cont &comment-continuation-fill&)
(temp-use-buffer "Scratch")
(erase-buffer)
(insert-string (quote cont))
(end-of-file)
(setq col (current-column))
(delete-white-space)
(insert-string "[ \t]*")
(set-mark)
(beginning-of-file)
(setq cont (region-to-string)))
(save-excursion
(beginning-of-line)
(while (& (looking-at cont)
(! (looking-at (concat cont "$")))
(! (bobp)))
(previous-line))
(next-line)
(set-mark)
(while (& (looking-at cont)
(! (looking-at (concat cont "$")))
(| (= comment-end "")
(! (looking-at (concat "[ \t]*" (quote comment-end)))))
(! (eobp)))
(next-line))
(backward-character)
(save-restriction
(narrow-region)
(beginning-of-file)
(insert-character '.')
(error-occured (replace-string &comment-continuation& " "))
(setq old-left left-margin)
(setq left-margin 1)
(justify-paragraph)
(beginning-of-file)
(delete-next-character)
(setq left-margin old-left)))))
(defun
(load-comment)))
(defun
(comment i
(setq i prefix-argument)
(while i
(end-of-line)
(if (save-excursion eoldot
(setq eoldot (dot))
(beginning-of-line)
(if (error-occured (search-forward comment-start))
0
(< (dot) eoldot)))
(progn
(beginning-of-line)
(search-forward comment-start)
(save-excursion diff
(search-reverse comment-start)
(if (!= (current-column) comment-column)
(progn
(delete-white-space)
(if (>= (current-column) comment-column)
(insert-string "\t")
(to-col comment-column))))
(if (& dont-wrap-comments
(save-excursion
(end-of-line)
(> (setq diff(- (current-column) 79)) 0)))
(progn was-col
(setq was-col (current-column))
(delete-white-space)
(if (>= (current-column)
(- was-col diff))
(insert-string " ")
(to-col (- was-col diff))))))
(if (= (following-char) ' ')
(forward-character)))
(progn
(if (>= (current-column) comment-column)
(insert-string "\t")
(to-col comment-column))
(insert-string comment-begin)
(save-excursion (insert-string comment-end))))
(if (> i 0)
(progn
(setq i (- i 1))
(if (> i 0)
(progn
(delete-empty-comment)
(next-line))))
(< i 0)
(progn
(setq i (+ i 1))
(if (< i 0)
(progn
(delete-empty-comment)
(previous-line)))))))
(delete-comment
(save-excursion
(end-of-line)
(set-mark)
(beginning-of-line)
(narrow-region)
(if (! (error-occured (search-forward comment-start)))
(progn
(search-reverse comment-start)
(delete-white-space)
(set-mark)
(if (= comment-end "")
(end-of-line)
(search-forward comment-end))
(delete-to-killbuffer)))
(widen-region)))
(indent-new-comment
(end-of-line)
(newline)
(comment)
(indent-under comment-start))
(next-comment
(delete-empty-comment)
(next-line)
(comment))
(previous-comment
(delete-empty-comment)
(previous-line)
(comment))
(delete-empty-comment
(comment)
(search-reverse comment-start)
(if (looking-at (concat "\\(" (quote comment-start) "[ \t]*"
(if (= comment-end "")
"$"
(quote comment-end))
"\\)"))
(save-excursion
(region-around-match 1)
(delete-to-killbuffer)
(delete-white-space)))))
(error-occured (_comment-hook)))
