# HG changeset patch # User Stefan Monnier # Date 991276003 0 # Node ID 4192225498c70a5f3a2b07b07c3aab78e35a3d02 # Parent 07263f7795e23c1f2fc017014bfd1dc78ffaaa36 (latex-find-indent): Handle the BOBP case. diff -r 07263f7795e2 -r 4192225498c7 lisp/textmodes/tex-mode.el --- a/lisp/textmodes/tex-mode.el Thu May 31 01:44:47 2001 +0000 +++ b/lisp/textmodes/tex-mode.el Thu May 31 02:26:43 2001 +0000 @@ -1881,41 +1881,43 @@ (latex-backward-sexp-1))) (scan-error (setq up-list-pos (nth 2 err)))) - (if (integerp up-list-pos) - ;; Have to indent relative to the open-paren. - (progn - (goto-char up-list-pos) - (if (and (not tex-indent-allhanging) - (> pos (progn (latex-down-list) - (forward-comment (point-max)) - (point)))) - ;; Align with the first element after the open-paren. - (current-column) - ;; We're the first element after a hanging brace. - (goto-char up-list-pos) - (+ indent tex-indent-basic (latex-find-indent 'virtual)))) - ;; We're now at the beginning of a line. - (if (not (and (not virtual) (eq (char-after) ?\\))) - ;; Nothing particular here: just keep the same indentation. - (+ indent (current-column)) - ;; We're now looking at a macro call. - (if (looking-at tex-indent-item-re) - ;; Indenting relative to an item, have to re-add the outdenting. - (+ indent (current-column) tex-indent-item) - (let ((col (current-column))) - (if (not (eq (char-syntax char) ?\()) - ;; If the first char was not an open-paren, there's - ;; a risk that this is really not an argument to the - ;; macro at all. - (+ indent col) - (forward-sexp 1) - (if (< (line-end-position) - (save-excursion (forward-comment (point-max)) - (point))) - ;; we're indenting the first argument. - (min (current-column) (+ tex-indent-arg col)) - (skip-syntax-forward " ") - (current-column))))))))))) + (cond + ((= (point-min) pos) 0) ; We're really just indenting the first line. + ((integerp up-list-pos) + ;; Have to indent relative to the open-paren. + (goto-char up-list-pos) + (if (and (not tex-indent-allhanging) + (> pos (progn (latex-down-list) + (forward-comment (point-max)) + (point)))) + ;; Align with the first element after the open-paren. + (current-column) + ;; We're the first element after a hanging brace. + (goto-char up-list-pos) + (+ indent tex-indent-basic (latex-find-indent 'virtual)))) + ;; We're now at the "beginning" of a line. + ((not (and (not virtual) (eq (char-after) ?\\))) + ;; Nothing particular here: just keep the same indentation. + (+ indent (current-column))) + ;; We're now looking at a macro call. + ((looking-at tex-indent-item-re) + ;; Indenting relative to an item, have to re-add the outdenting. + (+ indent (current-column) tex-indent-item)) + (t + (let ((col (current-column))) + (if (not (eq (char-syntax char) ?\()) + ;; If the first char was not an open-paren, there's + ;; a risk that this is really not an argument to the + ;; macro at all. + (+ indent col) + (forward-sexp 1) + (if (< (line-end-position) + (save-excursion (forward-comment (point-max)) + (point))) + ;; we're indenting the first argument. + (min (current-column) (+ tex-indent-arg col)) + (skip-syntax-forward " ") + (current-column)))))))))) (run-hooks 'tex-mode-load-hook)