aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2010-03-28 16:41:37 -0400
committerChong Yidong2010-03-28 16:41:37 -0400
commit2a793f7f35d279ed7304772718613e40edfa917d (patch)
treebab67f977b47f432026df2e6b6bf8e6f758c6c1c
parent727be7737986d9a58b326e8ada58859291436a07 (diff)
downloademacs-2a793f7f35d279ed7304772718613e40edfa917d.tar.gz
emacs-2a793f7f35d279ed7304772718613e40edfa917d.zip
Revert 2009-08-15 change, restoring electric punctuation (Bug#5586)
* progmodes/js.el (js-auto-indent-flag, js-mode-map) (js-insert-and-indent): Revert 2009-08-15 change, restoring electric punctuation for "{}();,:" (Bug#5586).
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/progmodes/js.el25
2 files changed, 29 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 4cba32fe52c..3294db39d52 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,9 @@
12010-03-28 Chong Yidong <cyd@stupidchicken.com> 12010-03-28 Chong Yidong <cyd@stupidchicken.com>
2 2
3 * progmodes/js.el (js-auto-indent-flag, js-mode-map)
4 (js-insert-and-indent): Revert 2009-08-15 change, restoring
5 electric punctuation for "{}();,:" (Bug#5586).
6
3 * mail/sendmail.el (mail-default-directory): Doc fix. 7 * mail/sendmail.el (mail-default-directory): Doc fix.
4 8
52010-03-27 Chong Yidong <cyd@stupidchicken.com> 92010-03-27 Chong Yidong <cyd@stupidchicken.com>
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 8c8d0553cfa..6bd22e4e6fa 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -436,6 +436,13 @@ The value must be no less than minus `js-indent-level'."
436 :type 'integer 436 :type 'integer
437 :group 'js) 437 :group 'js)
438 438
439(defcustom js-auto-indent-flag t
440 "Whether to automatically indent when typing punctuation characters.
441If non-nil, the characters {}();,: also indent the current line
442in Javascript mode."
443 :type 'boolean
444 :group 'js)
445
439(defcustom js-flat-functions nil 446(defcustom js-flat-functions nil
440 "Treat nested functions as top-level functions in `js-mode'. 447 "Treat nested functions as top-level functions in `js-mode'.
441This applies to function movement, marking, and so on." 448This applies to function movement, marking, and so on."
@@ -483,6 +490,9 @@ getting timeout messages."
483 490
484(defvar js-mode-map 491(defvar js-mode-map
485 (let ((keymap (make-sparse-keymap))) 492 (let ((keymap (make-sparse-keymap)))
493 (mapc (lambda (key)
494 (define-key keymap key #'js-insert-and-indent))
495 '("{" "}" "(" ")" ":" ";" ","))
486 (define-key keymap [(control ?c) (meta ?:)] #'js-eval) 496 (define-key keymap [(control ?c) (meta ?:)] #'js-eval)
487 (define-key keymap [(control ?c) (control ?j)] #'js-set-js-context) 497 (define-key keymap [(control ?c) (control ?j)] #'js-set-js-context)
488 (define-key keymap [(control meta ?x)] #'js-eval-defun) 498 (define-key keymap [(control meta ?x)] #'js-eval-defun)
@@ -498,6 +508,21 @@ getting timeout messages."
498 keymap) 508 keymap)
499 "Keymap for `js-mode'.") 509 "Keymap for `js-mode'.")
500 510
511(defun js-insert-and-indent (key)
512 "Run the command bound to KEY, and indent if necessary.
513Indentation does not take place if point is in a string or
514comment."
515 (interactive (list (this-command-keys)))
516 (call-interactively (lookup-key (current-global-map) key))
517 (let ((syntax (save-restriction (widen) (syntax-ppss))))
518 (when (or (and (not (nth 8 syntax))
519 js-auto-indent-flag)
520 (and (nth 4 syntax)
521 (eq (current-column)
522 (1+ (current-indentation)))))
523 (indent-according-to-mode))))
524
525
501;;; Syntax table and parsing 526;;; Syntax table and parsing
502 527
503(defvar js-mode-syntax-table 528(defvar js-mode-syntax-table