[Emacs] Kommentieren
Von: Andreas Röhler (andreas.roehler@online.de) [Profil]
Datum: 31.03.2008 13:10
Message-ID: <fsqgoo$v9i$1@online.de>
Newsgroup: de.comp.editoren
Datum: 31.03.2008 13:10
Message-ID: <fsqgoo$v9i$1@online.de>
Newsgroup: de.comp.editoren
--nextPart16786214.iDD7qbR76t
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8Bit
Hallo allerseits,
anbei ein Versuch, die Kommentierung in Emacs etwas
geradliniger zu schreiben, so daß sich Fehler schneller
beheben lassen.
Auch ist der Funktionsumfang erweitert, die Bedienung
vereinfacht.
Sollte auf allen Emacsen laufen.
Wär' schön, wenn das mal jemand testen könnte.
Gruß und Dank
Andreas Röhler
--nextPart16786214.iDD7qbR76t
Content-Type: text/plain; name="comment.el"
Content-Transfer-Encoding: 8Bit
Content-Disposition: attachment; filename="comment.el"
;;; comment.el --- comment/uncomment line or region
;; Copyright (C) 2008 Andreas Röhler
;; Author: Andreas Röhler <andreas.roehler@online.de>
;; Keywords: wp, lisp
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; Set out to fix a bug occuring in all Emacsen, reported at
;; http://tracker.xemacs.org/XEmacs/its/issue232
;; it ended up with an alternative comment.el
;; The bug of `indent-new-comment-line' should be gone
;; with the following key:
;; (global-set-key [(meta j)] 'comment-indent-new-line-lor)
;; Comment.el should not disturb newcomment.el; it's
;; suffix `-lor' means `line-or-region', designing a
;; new feature: If no active region exists, all
;; commands operate from current line.
;; Other main diffs to newcomment.el are:
;; Styles will not be chosen by customization, but
;; called with respective functions. Thus you may
;; insert indented, plain, boxed or multiline comments
;; without hesitation.
;; If a style offers more than one comment
;; end-start-set, as "//" or "/* */" in C, it's up to
;; the mode to deliver the callers, which have to set
;; starts and ends. (That remains to do.)
;; No use of syntax, which was conceived as unnecessary.
;; Deliberate limited use of regexps.
;; Check if a comment-char is found inside a string no
;; longer relies on fontifying.
;;; Code:
(defcustom comment-fontify-lor t
"If t, comment-functions call font-lock-fontify-buffer . "
:type '(choice (const :tag "No" nil)
(const :tag "Yes" t)
:group 'comment))
(defcustom comment-empty-lines-lor nil
"If nil, `comment-region' does not comment out empty lines. "
:type '(choice (const :tag "No" nil)
(const :tag "Yes" t)
:group 'comment))
(defalias 'comment-function-lor 'comment-indent-lor)
(defalias 'comment-lor 'comment-indent-lor)
(defalias 'uncomment-function-lor 'uncomment-lor)
(defvar comment-pad-boxes-lor nil
"If comment-start and end in headers and footers are padded")
;;; Code:
;; Group as is from newcomment.el
(defgroup comment nil
"Indenting and filling of comments."
:prefix "comment-"
:group 'fill)
;; (setq uncomment-all-lor t)
(defcustom uncomment-all-lor t
"If uncomment-line should remove all comments on line. "
:type 'boolean
:group 'comment)
(defun comment-plain-lor (&optional beg end)
"Comment line or region at beginning of line. "
(interactive "*")
(comment-base-lor nil nil nil nil beg end))
(defun comment-plain-multi-or (&optional beg end)
"Comment line or region, at beginning of lines. "
(interactive "*")
(comment-base-lor nil nil t nil beg end))
(defun comment-indent-lor (&optional beg end)
"Comment line or region, indent comments. "
(interactive "*")
(comment-base-lor t nil nil nil beg end))
(defun comment-indent-multi-lor (&optional beg end)
"Comment line or region, indent comments. "
(interactive "*")
(comment-base-lor t nil t nil beg end))
(defun comment-box-lor (&optional beg end)
"Comment out line or region, putting it inside a box. "
(interactive "*")
(comment-base-lor t t nil nil beg end))
;;;###autoload
(defun comment-base-lor (indented box multi use-comment-column &optional beg end)
(let* ((beg (cond ((and beg end) beg)
((region-active-p)
(region-beginning))
(t (line-beginning-position))))
(end (cond ((and beg end) (copy-marker end))
((region-active-p)
(copy-marker (region-end)))
(t (copy-marker (line-end-position)))))
(comment-column (when use-comment-column
(search-backward comment-end)
(skip-chars-backward "[^ \t]")
(point)))
(multi multi)
(line (count-lines (point-min) (point)))
(comment-end-string (< 0 (length comment-end)))
(maxline 0)
(comment-fill-char
(substring (string-strip comment-start) -1))
;; comment-add should be set by progmodes exclusively
(add (if comment-end-string 0 comment-add))
first)
(when (and multi (not comment-end-string))
(error "%s" "No valid command in this context:
Comments spanning multiple lines need comment-end string"))
(comment-intern-lor beg end indented box multi comment-column first add)
(when box
(comment-box-intern-lor beg end comment-end-string comment-fill-char add))
(unless (< line (count-lines (point-min) (point))))
(forward-line 1))
(when comment-fontify-lor (font-lock-fontify-buffer)))
(defun comment-intern-lor (beg end indented box multi comment-column first add)
(when (or (and (empty-line-p) comment-empty-lines-lor)
(not (empty-line-p)))
(goto-char beg)
(when indented
(beginning-of-line)
(indent-according-to-mode))
(unless (and multi first)
(insert comment-start)
(let ((add add))
(while
(< 0 add)
(insert comment-start)
(setq add (1- add))))
(setq first t)
(skip-chars-backward " \t")
(fixup-whitespace)
(unless (looking-at comment-padding)
(insert comment-padding)))
(when (< 0 (length comment-end))
(if (<= end (line-end-position))
(goto-char end)
(goto-char (line-end-position)))
(let ((pos (point)))
(unless multi
(unless (looking-at comment-padding)
(insert comment-padding))
(insert comment-end)
(save-excursion
(goto-char pos)
(fixup-whitespace)
(unless (looking-at comment-padding)
(when (looking-at " ")
(replace-match ""))
(insert comment-padding))))))
(if (< (line-end-position) (1- end))
(progn
(forward-line 1)
(comment-intern-lor (line-beginning-position) end indented box multi comment-column first
add))
(when multi
(unless (looking-at comment-padding)
(insert comment-padding))
(let ((pos (point)))
(insert comment-end)
(save-excursion
(goto-char pos)
(fixup-whitespace)))))))
(defun comment-box-intern-lor (beg end comment-end-string comment-fill-char add)
(let* ((comment-end-string comment-end-string)
(maxline (comment-set-line-max-lor beg end comment-end-string))
(comment-fill-column
(if comment-end-string
(- maxline (length comment-end))
(+ maxline add))))
(if comment-end-string
(comment-indent-boxes-lor beg end comment-fill-column)
(comment-set-boxes-lor beg end comment-end-string maxline comment-fill-column
comment-fill-char add))
(comment-set-head-foot-lor beg end comment-end-string maxline comment-fill-column
comment-fill-char))
(forward-line 1))
(defun comment-set-head-foot-lor (beg end comment-end-string maxline comment-fill-column
comment-fill-char)
(let ((start-col 0))
(goto-char beg)
(newline)
(forward-line -1)
(indent-according-to-mode)
(insert comment-start)
(fixup-whitespace)
(setq start-col (progn (save-excursion (back-to-indentation) (current-column))))
(comment-fill-form-lor comment-end-string comment-fill-column comment-fill-char)
(goto-char end)
(if (bolp)
(progn
(newline)
(forward-line -1)
(indent-to start-col))
(progn
(end-of-line)
(newline)
(indent-to start-col))))
(insert comment-start)
(fixup-whitespace)
(comment-fill-form-lor comment-end-string comment-fill-column comment-fill-char))
(defun comment-set-line-max-lor (beg end comment-end-string &optional line-length)
(let ((line-length (or line-length 0)))
(goto-char beg)
(if comment-end-string
(search-forward comment-end (line-end-position) t 1)
(end-of-line)
(skip-chars-backward " \t"))
(untabify (line-beginning-position) (point))
(setq line-length (- (point) (line-beginning-position)))
(when (< maxline line-length)
(setq maxline line-length))
(forward-line 1))
(when (<= (line-end-position) end)
(comment-set-line-max-lor (line-beginning-position) end comment-end-string line-length))
(message "%s" maxline)
maxline)
(defun comment-indent-boxes-lor (beg end comment-fill-column)
(goto-char beg)
(while (<= (line-end-position) end)
(search-forward comment-end)
(goto-char (match-beginning 0))
(while (< (current-column) comment-fill-column)
(insert " "))
(forward-line 1)
(comment-indent-boxes-lor (line-beginning-position) end comment-fill-column)))
(defun comment-set-boxes-lor (beg end comment-end-string maxline comment-fill-column
comment-fill-char add)
(goto-char beg)
(while (<= (line-end-position) end)
(end-of-line)
(skip-chars-backward " \t")
(unless (looking-at comment-padding)
(insert comment-padding))
(while (< (current-column) comment-fill-column)
(insert " "))
(if comment-end-string
(insert comment-end)
(insert comment-start)
(while (and (empty-stringp comment-end) (< 0 add))
(insert comment-start)
(setq add (1- add))))
(forward-line 1)
(comment-set-boxes-lor (line-beginning-position) end comment-end-string maxline
comment-fill-column comment-fill-char add)))
(defun comment-fill-form-lor (comment-end-string comment-fill-column comment-fill-char)
(when comment-pad-boxes-lor
(if (looking-at comment-padding)
(forward-char 1)
(insert comment-padding)))
(while (< (current-column) comment-fill-column)
(cond ((looking-at "[\n\r\f]")
(insert comment-fill-char))
((looking-at "[ \t]")
(replace-match comment-fill-char))))
(save-excursion
(when comment-end-string
(insert comment-end)))
(unless comment-pad-boxes-lor
(when (looking-at comment-padding)
(replace-match comment-fill-char)))
(unless comment-end-string (insert (concat comment-fill-char comment-start))))
(defun comment-right-margin-lor (&optional multi)
"Insert a comment after code on current line or region. "
(interactive "*")
(let ((add comment-add))
(end-of-line)
(skip-chars-backward " \t")
(insert " ")
(insert comment-start)
(while (and (empty-stringp comment-end) (< 0 add))
(insert comment-start)
(setq add (1- add))))
(comment-inl-endform-lor))
(defun comment-indent-new-line-lor (&optional multi)
"Break line at point and indent, continuing comment if within one. "
(interactive "*")
(let ((pos (condition-case nil (search-backward (string-strip comment-start)
(line-beginning-position) nil)
(error "Can't see a comment in this line!")))
(col (current-column))
(add comment-add)
npos)
(while (eq (char-before) (char-after))
(forward-char -1))
(setq col (current-column))
(setq npos (point))
(end-of-line)
(newline)
(indent-to-column col)
(insert comment-start)
(while (and (empty-stringp comment-end) (< 0 add))
(insert comment-start)
(setq add (1- add)))
(comment-inl-endform-lor)))
(defun comment-inl-endform-lor ()
(save-excursion
(when (and (comment-end-stringp) (not multi))
(insert comment-end)))
(unless (or (looking-at comment-padding)
(looking-back comment-padding))
(insert comment-padding)))
;; (defun uncomment-lor (&optional beg end not-all)
;; "Uncomment line or region. With ARG not-all. "
;; (interactive "*r\nP")
;; (uncomment-base-lor beg end not-all)
;; (when comment-fontify-lor (font-lock-fontify-buffer)))
(defun uncomment-lor (&optional not-all beg end)
(interactive "*P")
(let ((beg (cond ((and beg end) beg)
((region-active-p)
(region-beginning))
(t (line-beginning-position))))
(end (cond ((and beg end) (copy-marker end) end)
((region-active-p)
(copy-marker end))
(t (copy-marker (line-end-position)))))
(all (not not-all))
(start-replace (make-string (length comment-start) ? ))
(end-replace (when (comment-end-stringp)
(make-string (length comment-end) ? )))
first (maxline 0))
(uncomment-intern-lor beg end all start-replace end-replace)
;; (goto-char end)
(end-of-line)
(forward-line 1)
(when comment-fontify-lor (font-lock-fontify-buffer))))
(defun uncomment-intern-lor (beg end all start-replace end-replace)
(goto-char beg)
(cond ((looking-at (regexp-quote comment-start))
(goto-char (match-beginning 0))
(comment-startreplace-intern-lor))
((and (re-search-forward (regexp-quote comment-start) end t 1) (save-match-data (not
(in-string-p (point)))))
(goto-char (match-beginning 0))
(comment-startreplace-intern-lor))
((and (< beg (point)) (in-string-p (point)))
(uncomment-intern-lor (point) end all start-replace end-replace)))
(when (and (< beg (point)) all)
(uncomment-intern-lor (line-beginning-position) end all start-replace end-replace))
(indent-according-to-mode)
(let ((indent (save-excursion (back-to-indentation) (current-column))))
(when (and (< (point) end) (comment-end-stringp) (search-forward comment-end nil t 1))
(replace-match end-replace)
(when (< end (point)) (setq end (point))
(indent-region beg end indent))))
(when (< (line-end-position) end)
(forward-line 1)
(uncomment-intern-lor (line-beginning-position) end all start-replace end-replace)))
(defun comment-dwim-lor ()
"As `comment-or-uncomment-lor' except as `uncomment'
is called with arg `not-all'.
Thus if a region contains lines with one or more comments,
only lines with one comment are uncommented completly.
Value of comment-add is honoured. "
(interactive "*")
(comment-or-uncomment-lor t))
(defun comment-or-uncomment-lor (&optional not-all beg end)
"Comment line or region, unless it's already commented:
uncomment then.
Uncommenting: with arg NOT-ALL only first comment is removed.
With region: Only first line is checked for decision.
Thus if first line is not commented, but some lines below are,
region is commented alltogether. "
(interactive "*P")
(let ((not-all not-all)
(beg (cond ((and beg end) beg)
((region-active-p)
(region-beginning))
(t (line-beginning-position))))
(end (cond ((and beg end) (copy-marker end) end)
((region-active-p)
(copy-marker (region-end)))
(t (copy-marker (line-end-position))))))
(if (save-excursion ;; check for already commented region
(goto-char beg)
(narrow-to-region beg (line-end-position))
(search-forward comment-start nil t 1)
(widen)
(< beg (point)))
(funcall 'uncomment-function-lor not-all beg end)
(funcall 'comment-function-lor))))
;;; helpers
(defun in-string-p (&optional pos)
(let ((orig (or pos (point))))
(save-excursion
(beginning-of-defun)
(nth 3 (parse-partial-sexp (point) orig)))))
(defun empty-stringp (string)
(string= "" string))
(defun comment-end-stringp (&optional ispec)
"Returns t if comment-end in comment-style is a non-empty string. "
(interactive "*p")
(let ((erg (and (not (empty-stringp comment-end))
(stringp comment-end))))
(when ispec
(message "%s" erg))
erg))
(defun search-comment-start-n-in-stringp (&optional beg end)
"Search comment start,
make sure, it's not part of a string. "
(interactive "r")
(let ((beg (or (and (when (and (interactive-p) (region-active-p)) beg) beg)(point)))
(end (or (when (and (interactive-p) (region-active-p)) end) (line-end-position)))
(pos (point)))
(goto-char beg)
(while
(and (search-forward comment-start end t 1) (in-string-p))
(search-comment-start-n-in-stringp))
(< pos (point))))
;; from GNU Emacs subr.el
(when (featurep 'xemacs)
(defun looking-back (regexp &optional limit greedy)
"Return non-nil if text before point matches regular expression REGEXP.
Like `looking-at' except matches before point, and is slower.
LIMIT if non-nil speeds up the search by specifying a minimum
starting position, to avoid checking matches that would start
before LIMIT.
If GREEDY is non-nil, extend the match backwards as far as possible,
stopping when a single additional previous character cannot be part
of a match for REGEXP."
(let ((start (point))
(pos
(save-excursion
(and (re-search-backward (concat "\\(?:" regexp "\\)\\=") limit t)
(point)))))
(if (and greedy pos)
(save-restriction
(narrow-to-region (point-min) start)
(while (and (> pos (point-min))
(save-excursion
(goto-char pos)
(backward-char 1)
(looking-at (concat "\\(?:" regexp "\\)\\'"))))
(setq pos (1- pos)))
(save-excursion
(goto-char pos)
(looking-at (concat "\\(?:" regexp "\\)\\'")))))
(not (null pos)))))
(defun indent-with-spaces (column)
"Indent with spaces to column "
(interactive "*")
(while (< (current-column) column)
(insert " "))
(forward-char 1))
(defun comment-startreplace-intern-lor ()
(let ((add comment-add))
(while (< 0 (1+ add))
(setq add (1- add))
(skip-chars-forward " \t")
(when (looking-at (regexp-quote comment-start))
(replace-match start-replace)))))
(provide 'comment)
;;; comment.el ends here
--nextPart16786214.iDD7qbR76t
Content-Type: text/plain; name="comment-test.el"
Content-Transfer-Encoding: 8Bit
Content-Disposition: attachment; filename="comment-test.el"
;;; comment-test.el --- tests for comment.el
;; Copyright (C) 2008 Andreas Roehler
;; Author: Andreas Roehler <andreas.roehler@online.de>
;; Keywords: wp, lisp
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; Call the test-functions inserting comments at some
;; dummy-texts.
;;; Code:
;; Delay in seconds
(setq comment-test-delay-lor 1)
(defun comment-all-test-lor (ins)
"Try all available comment-styles and modes in current-buffer.
Without second arg `ins', use dummy texts delivered.
After commenting `plain' or `indented', `comment-or-uncomment-lor' is called, which should
remove comments.
Boxed and right-margin comments are left. "
(interactive "*P")
(condition-case nil (comment-test-intern-lor 'comment-html-test-lor ins) (error nil))
(condition-case nil (comment-test-intern-lor 'comment-c-test-lor ins) (error nil))
(condition-case nil (comment-test-intern-lor 'comment-lisp-test-lor ins) (error nil))
(condition-case nil (comment-test-intern-lor 'comment-perl-test-lor ins) (error nil))
(condition-case nil (comment-test-intern-lor 'comment-sh-test-lor ins) (error nil)))
(defun comment-c-test-lor (ins)
"Try available comment-styles in current-buffer.
Without second arg `ins', use a dummy text delivered in new buffer.
After commenting plain or indented, `comment-or-uncomment-lor' is called, which should
remove comments.
Boxed and right-margin comments are left. "
(interactive "*P")
(comment-test-intern-lor 'comment-c-test-lor ins))
(defun comment-lisp-test-lor (ins)
"Try available comment-styles in current-buffer.
Without second arg `ins', use a dummy text delivered in new buffer.
After commenting plain or indented, `comment-or-uncomment-lor' is called, which should
remove comments.
Boxed and right-margin comments are left. "
(interactive "*P")
(comment-test-intern-lor 'comment-lisp-test-lor ins))
(defun comment-perl-test-lor (ins)
"Try available comment-styles in current-buffer.
Without second arg `ins', use a dummy text delivered in new buffer.
After commenting plain or indented, `comment-or-uncomment-lor' is called, which should
remove comments.
Boxed and right-margin comments are left. "
(interactive "*P")
(comment-test-intern-lor 'comment-perl-test-lor ins))
(defun comment-html-test-lor (ins)
"Try available comment-styles in current-buffer.
Without second arg `ins', use a dummy text delivered in new buffer.
After commenting plain or indented, `comment-or-uncomment-lor' is called, which should
remove comments.
Boxed and right-margin comments are left. "
(interactive "*P")
(comment-test-intern-lor 'comment-html-test-lor ins))
(defun comment-sh-test-lor (ins)
"Try available comment-styles in current-buffer.
Without second arg `ins', use a dummy text delivered in new buffer.
After commenting plain or indented, `comment-or-uncomment-lor' is called, which should
remove comments.
Boxed and right-margin comments are left. "
(interactive "*P")
(comment-test-intern-lor 'comment-sh-test-lor ins))
(defun comment-test-intern-lor (arg &optional ins)
(unless ins
(set-buffer (get-buffer-create "comment-test"))
(fundamental-mode)
(erase-buffer)
(switch-to-buffer (current-buffer)))
(let ((pos (point)))
(cond ((eq arg 'comment-c-test)
(unless ins (insert comment-c-test.txt))
(condition-case nil (c-mode) (error nil))
(setq comment-fill-char (substring (string-strip comment-start) -1)))
((eq arg 'comment-html-test)
(unless ins (insert comment-html-test.txt))
(condition-case nil (html-mode) (error nil))
(setq comment-add 0))
((eq arg 'comment-lisp-test)
(unless ins (insert comment-lisp-test.txt))
(condition-case nil (emacs-lisp-mode) (error nil)))
((eq arg 'comment-perl-test)
(unless ins (insert comment-perl-test.txt))
(condition-case nil (perl-mode) (error nil))
(setq comment-add 0))
((eq arg 'comment-sh-test)
(unless ins (insert comment-sh-test.txt))
(setq comment-add 0)
(condition-case nil (sh-mode) (error nil))))
(goto-char (point-min))
;; ajust indentation
(let ((pos (point)))
(while (< pos (progn (forward-line 1) (point)))
(setq pos (point))
(indent-according-to-mode)))
;; start
(goto-char (point-min))
(font-lock-fontify-buffer)
(forward-line 3)
(newline) (forward-line -1)
(insert "comment-plain-lor")
(sit-for comment-test-delay-lor)
(comment-plain-lor)
(comment-plain-lor)
(font-lock-fontify-buffer)
(sit-for comment-test-delay-lor)
(forward-line 1)
(end-of-line) (newline)
(insert "if comment-empty-lines-lor is t")
(comment-plain-lor)
(comment-plain-lor)
(sit-for comment-test-delay-lor)
(forward-line 2)
(end-of-line)(newline)
(insert "comment-indent-lor")
(comment-indent-lor)
(comment-indent-lor)
(sit-for comment-test-delay-lor)
(forward-line 2)
(end-of-line)(newline)
(insert "comment-dwim")
(comment-dwim-lor)
(comment-dwim-lor)
(sit-for comment-test-delay-lor)
(forward-line 1)
(push-mark)
(forward-line 1)
(end-of-line) (newline)
(insert "comment-box-lor")
(beginning-of-line)
(indent-according-to-mode)
(comment-indent-lor)
(comment-box-lor)
(font-lock-fontify-buffer)
(sit-for comment-test-delay-lor)
(forward-line 1)
(end-of-line) (newline)
(insert "comment-right-margin-lor")
(comment-indent-lor)
(comment-right-margin-lor)
(insert "foo bar")
(sit-for comment-test-delay-lor)
(comment-indent-new-line-lor)
(insert "foo baz")
(sit-for comment-test-delay-lor)
(comment-indent-new-line-lor)
(insert "foo foo ...")
(when (comment-end-stringp)
(forward-line 1)
(end-of-line) (newline)
(insert "comment-plain-multi-or")
(comment-plain-lor)
(setq pos (point))
(forward-line 2)
(end-of-line)
(comment-plain-multi-or pos (copy-marker (point)))
(font-lock-fontify-buffer)
(sit-for comment-test-delay-lor)
(forward-line 1)
(newline) (forward-line -1)
(insert "comment-indent-multi-or")
(comment-indent-lor)
(setq pos (point))
(forward-line 2)
(end-of-line)
(comment-indent-multi-lor pos (copy-marker (point)))
(font-lock-fontify-buffer)
(sit-for comment-test-delay-lor)
(sit-for comment-test-delay-lor))))
(setq comment-c-test.txt "
#include <stdio.h>
int main(void)
{
printf(\"Hello, world!\\n\");
printf(\"Hello, world!\\n\");
printf(\"Hello, world!\\n\");
printf(\"Hello, world!\\n\");
printf(\"Hello, world!\\n\");
printf(\"Hello, world!\\n\");
printf(\"Hello, world!\\n\");
printf(\"Hello, world!\\n\");
printf(\"Hello, world!\\n\");
printf(\"Hello, world!\\n\");
printf(\"Hello, world!\\n\");
printf(\"Hello, world!\\n\");
printf(\"Hello, world!\\n\");
printf(\"Hello, world!\\n\");
printf(\"Hello, world!\\n\");
printf(\"Hello, world!\\n\");
printf(\"Hello, world!\\n\");
printf(\"Hello, world!\\n\");
printf(\"Hello, world!\\n\");
printf(\"Hello, world!\\n\");
printf(\"Hello, world!\\n\");
printf(\"Hello, world!\\n\");
printf(\"Hello, world!\\n\");
printf(\"Hello, world!\\n\");
printf(\"Hello, world!\\n\");
printf(\"Hello, world!\\n\");
printf(\"Hello, world!\\n\");
printf(\"Hello, world!\\n\");
return 0;
}
")
(setq comment-html-test.txt"
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
\"http://www.w3c.org/TR/html4/loose.dtd\">
<html>
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html\">
</head>
<body>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
<p>Hello World!</p>
</body>
</html>
")
(setq comment-lisp-test.txt "
(defun ihw ()
\" \"
(interactive \"\*\")
(insert \"Hello World!\")
(insert \"Hello World!\")
(insert \"Hello World!\")
(insert \"Hello World!\")
(insert \"Hello World!\")
(insert \"Hello World!\")
(insert \"Hello World!\")
(insert \"Hello World!\")
(insert \"Hello World!\")
(insert \"Hello World!\")
(insert \"Hello World!\")
(insert \"Hello World!\")
(insert \"Hello World!\")
(insert \"Hello World!\")
(insert \"Hello World!\")
(insert \"Hello World!\")
(insert \"Hello World!\")
)
")
(setq comment-sh-test.txt "
#!/bin/bash
if true; then
echo 'Hallo Welt!'
echo 'Hallo Welt!'
else
echo 'Hallo Welt!'
echo 'Hallo Welt!'
echo 'Hallo Welt!'
echo 'Hallo Welt!'
echo 'Hallo Welt!'
echo 'Hallo Welt!'
echo 'Hallo Welt!'
echo 'Hallo Welt!'
echo 'Hallo Welt!'
echo 'Hallo Welt!'
echo 'Hallo Welt!'
echo 'Hallo Welt!'
echo 'Hallo Welt!'
echo 'Hallo Welt!'
echo 'Hallo Welt!'
echo 'Hallo Welt!'
echo 'Hallo Welt!'
echo 'Hallo Welt!'
echo 'Hallo Welt!'
echo 'Hallo Welt!'
echo 'Hallo Welt!'
echo 'Hallo Welt!'
echo 'Hallo Welt!'
echo 'Hallo Welt!'
fi
")
(setq comment-perl-test.txt "\@eingang = glob\('1.html'\);
print \"\@eingang \\n\";
foreach \$i \(@eingang\) \{
open(D_E, \$i) or die \"Datei nicht gefunden: \$i\";
while \(<D_E>\)\{
chomp;
if \( /^http/ \) \{
print \"\$_ \\n\";
print \"Hello, world!\\n\";
print \"Hello, world!\\n\";
print \"Hello, world!\\n\";
print \"Hello, world!\\n\";
print \"Hello, world!\\n\";
print \"Hello, world!\\n\";
print \"Hello, world!\\n\";
print \"Hello, world!\\n\";
print \"Hello, world!\\n\";
print \"Hello, world!\\n\";
print \"Hello, world!\\n\";
print \"Hello, world!\\n\";
print \"Hello, world!\\n\";
print \"Hello, world!\\n\";
print \"Hello, world!\\n\";
}\
elsif \( /<a href=http:\\/\\/multi.org/g \) \{
@eingabe = split(/<a href=http:\\/\\/multi.org/);
foreach \(@eingabe\) \{
print \$_;
\}\}\}\}
")
(provide 'comment-test)
;;; comment-test.el ends here
--nextPart16786214.iDD7qbR76t--
[ Auf dieses Posting antworten ]Antworten
- Andreas Röhler (31.03.2008 18:58)
- Sven Joachim (31.03.2008 19:24)
- Andreas Röhler (31.03.2008 20:36)
- Sven Joachim (31.03.2008 20:51)
- Andreas Röhler (31.03.2008 21:23)
- Andreas Röhler (01.04.2008 08:53)
