开发者

Indentation issues with Emacs (Espresso in this case)

开发者 https://www.devze.com 2023-02-23 06:55 出处:网络
There is certainly something I miss in Emacs configuration regarding indentation. Here is some JavaScript code I\'d like to indent:

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)))))))
0

精彩评论

暂无评论...
验证码 换一张
取 消