[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX-diffs] Changes to auctex/latex.el
From: |
Ralf Angeli |
Subject: |
[AUCTeX-diffs] Changes to auctex/latex.el |
Date: |
Sun, 02 Oct 2005 07:53:06 -0400 |
Index: auctex/latex.el
diff -u auctex/latex.el:5.382 auctex/latex.el:5.383
--- auctex/latex.el:5.382 Fri Aug 26 16:26:26 2005
+++ auctex/latex.el Sun Oct 2 11:53:06 2005
@@ -598,58 +598,73 @@
(defun LaTeX-insert-environment (environment &optional extra)
"Insert LaTeX ENVIRONMENT with optional argument EXTRA."
- (let ((active-mark (and (TeX-active-mark)
- (not (eq (mark) (point)))))
- comment-flag prefix)
- (when active-mark
- (if (< (mark) (point))
- (exchange-point-and-mark)))
- (unless (TeX-looking-at-backward
- (if (and LaTeX-insert-into-comments
- (TeX-in-commented-line)
- (not (bolp)))
- (concat "^[ \t]*" TeX-comment-start-regexp "+[ \t]*")
- "^[ \t]*"))
- (LaTeX-newline))
- ;; Insert a linebreak at the end of the marked region if necessary.
- ;; Do this before we insert anything which might alter the prefix.
+ (let ((active-mark (and (TeX-active-mark) (not (eq (mark) (point)))))
+ (macrocode-p (and (eq major-mode 'doctex-mode)
+ (string-match "\\`macrocode\\*?\\'" environment)))
+ prefix content-start)
+ (when (and active-mark (< (mark) (point))) (exchange-point-and-mark))
+ ;; Compute the prefix.
+ (when (and LaTeX-insert-into-comments (TeX-in-commented-line))
+ (save-excursion
+ (beginning-of-line)
+ (looking-at
+ (concat "^\\([ \t]*" TeX-comment-start-regexp "+\\)+[ \t]*"))
+ (setq prefix (match-string 0))))
+ ;; What to do with the line containing point.
+ (cond ((save-excursion (beginning-of-line)
+ (looking-at (concat prefix "[ \t]*$")))
+ (kill-region (match-beginning 0) (match-end 0)))
+ ((TeX-looking-at-backward (concat "^" prefix "[ \t]*")
+ (line-beginning-position))
+ (beginning-of-line)
+ (newline)
+ (beginning-of-line 0))
+ ((bolp)
+ (delete-horizontal-space)
+ (newline)
+ (beginning-of-line 0))
+ (t
+ (delete-horizontal-space)
+ (newline 2)
+ (when prefix (insert prefix))
+ (beginning-of-line 0)))
+ ;; What to do with the line containing mark.
(when active-mark
(save-excursion
(goto-char (mark))
- (unless (progn (skip-chars-forward " \t") (eolp))
- ;; Use `(insert "\n")' instead of `(newline)' because in contrast
- ;; to Emacs, XEmacs moves the mark if `newline' is used.
- (if (bolp) (insert "\n") (LaTeX-newline))
- (indent-according-to-mode))))
- (when (and LaTeX-insert-into-comments
- (looking-at
- (concat "[ \t]*\\(" TeX-comment-start-regexp "+\\)")))
- (setq comment-flag t)
- (insert (setq prefix (match-string 1)) (TeX-comment-padding-string)))
+ (cond ((save-excursion (beginning-of-line)
+ (or (looking-at (concat prefix "[ \t]*$"))
+ (looking-at "[ \t]*$")))
+ (kill-region (match-beginning 0) (match-end 0)))
+ ((TeX-looking-at-backward (concat "^" prefix "[ \t]*")
+ (line-beginning-position))
+ (beginning-of-line)
+ (newline)
+ (beginning-of-line 0))
+ (t
+ (delete-horizontal-space)
+ (insert-before-markers "\n")
+ (newline)
+ (when prefix (insert prefix))))))
+ ;; Now insert the environment.
+ (if macrocode-p (insert "%") (when prefix (insert prefix)))
(insert TeX-esc "begin" TeX-grop environment TeX-grcl)
(indent-according-to-mode)
- (if extra (insert extra))
- (LaTeX-newline)
- (if active-mark
- (progn
- (goto-char (mark))
- (unless (TeX-looking-at-backward
- (if (and LaTeX-insert-into-comments
- (TeX-in-commented-line)
- (not (bolp)))
- (concat "^" comment-start-skip "[ \t]*")
- "^[ \t]*"))
- (LaTeX-newline)))
- (LaTeX-newline))
- (when comment-flag
- (insert prefix (TeX-comment-padding-string)))
+ (when extra (insert extra))
+ (setq content-start (line-beginning-position 2))
+ (unless active-mark
+ (newline)
+ (when prefix (insert prefix))
+ (newline))
+ (when active-mark (goto-char (mark)))
+ (if macrocode-p (insert "%") (when prefix (insert prefix)))
(insert TeX-esc "end" TeX-grop environment TeX-grcl)
- (indent-according-to-mode)
(end-of-line 0)
(if active-mark
(or (assoc environment LaTeX-indent-environment-list)
- (LaTeX-fill-environment nil))
- (indent-according-to-mode)))
+ (LaTeX-fill-region content-start (line-beginning-position 2)))
+ (indent-according-to-mode))
+ (save-excursion (beginning-of-line 2) (indent-according-to-mode)))
(TeX-math-input-method-off))
(defun LaTeX-modify-environment (environment)
- [AUCTeX-diffs] Changes to auctex/latex.el,
Ralf Angeli <=
- [AUCTeX-diffs] Changes to auctex/latex.el, Ralf Angeli, 2005/10/02
- [AUCTeX-diffs] Changes to auctex/latex.el, Masayuki Ataka, 2005/10/06
- [AUCTeX-diffs] Changes to auctex/latex.el, Arne Jørgensen, 2005/10/10
- [AUCTeX-diffs] Changes to auctex/latex.el, Arne Jørgensen, 2005/10/12
- [AUCTeX-diffs] Changes to auctex/latex.el, Arne Jørgensen, 2005/10/19
- [AUCTeX-diffs] Changes to auctex/latex.el, Masayuki Ataka, 2005/10/31