bug#2481: 23.0.91; javascript-mode indentation weirdness

Pat Maddox <[email protected]>
Newsgroups gmane.emacs.bugs,gmane.emacs.pretest.bugs
Message-ID <[email protected]>
If I'm on the last line of a file in javascript-mode and press tab to
indent, it beeps and says "End of buffer".  This doesn't happen in any
other modes as far as I can tell.

There's another problem with indentation or parsing, I'm not sure if
it's related or not...I've written some code to automatically format
braces:

(add-hook 'javascript-mode-hook
          (lambda ()
            (textmate-mode)
            (local-set-key "\r"
                           (lambda () (interactive)
                             (insert-line-before-closing-braces)
                             (newline-and-indent)))))

(defun insert-line-before-closing-braces ()
  (interactive)
  (save-excursion
    (let ((content (buffer-substring (point) (line-end-position))))
      (if (and (> (length content) 0)
               (string= (replace-regexp-in-string ")\\\|}" "" content)  ""))
          (newline-and-indent)))))

If I'm on the first line of a file and type (), and move between the
parens and press return, I get an error.  It works fine in every other
mode I've tried, or on any line other than #1.  Here's the error

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
  =(nil 41)
  (if (= (char-before) 41) (progn (backward-list)))
  (when (= (char-before) 41) (backward-list))
  (progn (skip-syntax-backward " ") (when (= ... 41) (backward-list))
(back-to-indentation) (cond (same-indent-p ...) (continued-expr-p ...)
(t ...)))
  (if (looking-at "[({[][ 	]*\\(/[/*]\\|$\\)") (progn
(skip-syntax-backward " ") (when ... ...) (back-to-indentation) (cond
... ... ...)) (unless same-indent-p (forward-char) (skip-chars-forward
" 	")) (current-column))
  (cond (ctrl-stmt-indent) ((js-continued-var-decl-list-p)
(js-re-search-backward "\\<var\\>" nil t) (+ ...
javascript-indent-level)) ((nth 1 parse-status) (goto-char ...) (if
... ... ... ...)) (continued-expr-p javascript-indent-level) (t (let
... ... ind)))
  (let ((ctrl-stmt-indent ...) (same-indent-p ...) (continued-expr-p
...)) (cond (ctrl-stmt-indent) (... ... ...) (... ... ...)
(continued-expr-p javascript-indent-level) (t ...)))
  (save-excursion (back-to-indentation) (let (... ... ...) (cond ...
... ... ... ...)))
  js-proper-indentation((1 1 nil nil nil nil 0 nil nil (1)))
  (indent-line-to (js-proper-indentation parse-status))
  (progn (indent-line-to (js-proper-indentation parse-status)) (when
(> offset 0) (forward-char offset)))
  (if (not (nth 8 parse-status)) (progn (indent-line-to ...) (when ... ...)))
  (when (not (nth 8 parse-status)) (indent-line-to
(js-proper-indentation parse-status)) (when (> offset 0) (forward-char
offset)))
  (let ((parse-status ...) (offset ...)) (when (not ...)
(indent-line-to ...) (when ... ...)))
  javascript-indent-line()
  indent-according-to-mode()
  newline-and-indent()
  (if (and (> ... 0) (string= ... "")) (newline-and-indent))
  (let ((content ...)) (if (and ... ...) (newline-and-indent)))
  (save-excursion (let (...) (if ... ...)))
  insert-line-before-closing-braces()
  (lambda nil (interactive) (insert-line-before-closing-braces)
(newline-and-indent))()
  call-interactively((lambda nil (interactive)
(insert-line-before-closing-braces) (newline-and-indent)) nil nil)


In GNU Emacs 23.0.91.1 (i386-apple-darwin9.6.0, NS apple-appkit-949.43)
 of 2009-02-26 on booyah.local
Windowing system distributor `Apple', version 10.3.949
configured using `configure  '--with-ns''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default-enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
  shell-dirtrack-mode: t
  diff-auto-refine-mode: t
  nxhtml-global-minor-mode: t
  global-auto-revert-mode: t
  show-paren-mode: t
  yas/minor-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
C-x b b l a <return> y M-x j a v a s c <tab> <return>
( <return> q C-x h C-w / / <return> ( <return> C-x
h C-w C-x C-f j a v a <return> <down> <down> C-SPC
<C-down> <down> <down> C-w <backspace> C-x C-s M-x
s u b m i <tab> <backspace> <backspace> <backspace>
<backspace> <backspace> b u g <tab> <tab> <M-backspace>
<M-backspace> r e p o <tab> r t <tab> <return>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
No buffer matching `bla', create one? (y or n)
Entering debugger...
Back to top level.
Mark set [4 times]
Loading tramp...done
Mark set
Saving file /Users/padillac/code/emacs/javascript.el...
Wrote /Users/padillac/code/emacs/javascript.el
Making completion list... [2 times]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.