1

I set part settings of my EMACS with cusomize, and part with manually editing .emacs-file in my home directory. Not all settings from my .emacs applyed at EMACS startup.

For example, not working web-beautify before save, not enable js2-highlight-unused-variables on js2-mode and more. But if I select these lines and call command eval-region, she begin works!

Also someone settings from .emacs works on startup.

What I do wrong?

EMACS version: 24.5.1, builded from source

EMACS repos: ELPA, GNU, ORG

OS version: Ubuntu 14.04 x64

Link to my .emacs: http://pastebin.com/NJup9cDP

3
  • Doesn't Emacs report any errors on start-up? You could also log the .emacs evaluation progress in the *Messages* buffer by using (message "this and this stage reached") for example. Similarly, you could log hook execution by placing message calls in relevant functions.
    – wvxvw
    Commented Jun 11, 2015 at 12:01
  • Can the desktop mode disable my settings? Commented Jun 11, 2015 at 12:09
  • Do you mean desktop-save-mode? If so, it's very unlikely, but you can try to figure it out by either starting Emacs with --no-desktop option or by removing everything that was saved in the desktop file by calling M-x desktop-clear and restarting Emacs.
    – wvxvw
    Commented Jun 11, 2015 at 12:21

1 Answer 1

2

The function js2-highlight-unused-variables is a function used by js2-highlight-unused-variables-mode, which is a minor mode: https://github.com/mooz/js2-mode/blob/master/js2-mode.el

In general, minor modes are turned on as follows:

(js2-highlight-unused-variables-mode 1)

And, they are turned off as follows:

(js2-highlight-unused-variables-mode -1)

The original poster has created a function that looks like this:

(defun turn-on-highlight-unused-vars-on-js2-mode()(js2-highlight-unused-variables))

Instead, the original poster could try the following:

(defun turn-on-highlight-unused-vars-on-js2-mode ()
  (js2-highlight-unused-variables-mode 1))

With respect to web-beautify, the original poster will need to carefully compare his/her own code to the instructions on the homepage for the github repository -- https://github.com/yasuyk/web-beautify. If those instructions do not appear to work, then the original poster may wish to reduce his/her .emacs file to the absolute minimal installation needed for web-beautify and see if it works as expected. If web-beautify works as expected with a minimal .emacs installation, then the original poster can start enabling the other settings little by little until the culprit is located.

The instructions state in relevant part:

If you want to automatically format before saving a file, add the following hook to your emacs configuration:

(eval-after-load 'js2-mode
  '(add-hook 'js2-mode-hook
             (lambda ()
               (add-hook 'before-save-hook 'web-beautify-js-buffer t t))))

;; Or if you're using 'js-mode' (a.k.a 'javascript-mode')
(eval-after-load 'js
  '(add-hook 'js-mode-hook
             (lambda ()
               (add-hook 'before-save-hook 'web-beautify-js-buffer t t))))

(eval-after-load 'json-mode
  '(add-hook 'json-mode-hook
             (lambda ()
               (add-hook 'before-save-hook 'web-beautify-js-buffer t t))))

(eval-after-load 'sgml-mode
  '(add-hook 'html-mode-hook
             (lambda ()
               (add-hook 'before-save-hook 'web-beautify-html-buffer t t))))

(eval-after-load 'css-mode
  '(add-hook 'css-mode-hook
             (lambda ()
               (add-hook 'before-save-hook 'web-beautify-css-buffer t t))))
1
  • Thank you for detailed response! Disabling line with `(ergoemacs-mode 1) resolve my problem. Commented Jun 13, 2015 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.