Indentation issues with Emacs (Espresso in this case)
There is certainly something I miss in Emacs configuration regarding indentation.
Here is some JavaScript code I'd like to indent:
$(function(){
$.superbox.settings = {
closeTxt: "",
loadTxt: "",
[...]
If I do a M-q
(i.e. paredit-reindent-defun
) here is what I get:
$(function(){
$.superbox.settings = {
closeTxt: "",
开发者_StackOverflow社区 loadTxt: "",
How can I configure Emacs to follow more conventional indentation? In this particular case I'd like to see closeTxt
one indentation (e.g. four spaces) further the $.superbox
declaration one line above...
P.S. I use the emacs-starter-kit (https://github.com/technomancy/emacs-starter-kit).
paredit
is poorly suited for anything other than Lisp editing. I would indent JavaScript code using it. You should try using the standard JavaScript indent defuns instead. Remove the following lines from starter-kit-js.el
, restart Emacs and try again:
(add-hook 'espresso-mode-hook 'esk-paredit-nonlisp)
(eval-after-load 'espresso
'(progn (define-key espresso-mode-map "{" 'paredit-open-curly)
(define-key espresso-mode-map "}" 'paredit-close-curly-and-newline)
;; fixes problem with pretty function font-lock
(define-key espresso-mode-map (kbd ",") 'self-insert-command)
(font-lock-add-keywords
'espresso-mode `(("\\(function *\\)("
(0 (progn (compose-region (match-beginning 1)
(match-end 1) "ƒ")
nil)))))))
精彩评论