Currently, my emacs's flycheck is enabled for js as default. I'm using global-flycheck-mode but not sure if I have set its value as a list. I wonder how to enable flycheck for other modes like json-mode, web-mode, c++mode. Here is my settings for flycheck.
;; ===================flycheck settings start====================
;; use web-mode for .jsx files
(add-to-list 'auto-mode-alist '("\\.jsx$" . web-mode))
;; http://www.flycheck.org/manual/latest/index.html
(require 'flycheck)
;; turn on flychecking globally
(add-hook 'after-init-hook #'global-flycheck-mode)
;; disable jshint since we prefer eslint checking
(setq-default flycheck-disabled-checkers
(append flycheck-disabled-checkers
'(javascript-jshint)))
;; use eslint with web-mode for jsx files
(flycheck-add-mode 'javascript-eslint 'web-mode)
;; customize flycheck temp file prefix
(setq-default flycheck-temp-prefix ".flycheck")
;; disable json-jsonlist checking for json files
(setq-default flycheck-disabled-checkers
(append flycheck-disabled-checkers
'(json-jsonlist)))
;; https://github.com/purcell/exec-path-from-shell
;; only need exec-path-from-shell on OSX
;; this hopefully sets up path and other vars better
(when (memq window-system '(mac ns))
(exec-path-from-shell-initialize))
;; for better jsx syntax-highlighting in web-mode
;; - courtesy of Patrick #halbtuerke
(defadvice web-mode-highlight-part (around tweak-jsx activate)
(if (equal web-mode-content-type "jsx")
(let ((web-mode-enable-part-face nil))
ad-do-it)
ad-do-it))
;; c++
(add-hook 'c++-mode-hook (lambda () (setq flycheck-gcc-language-standard "c++11")))
;; ===================flycheck settings end======================
Im currently using this one. Works fine.
;; Enable for other modes
(add-hook 'c++-mode-hook 'flycheck-mode)
(add-hook 'web-mode-hook 'flycheck-mode)
(add-hook 'json-mode-hook 'flycheck-mode)
But I still don't understand why it only enables for js2-mode before.
Related
When using `org-export-as-html' in batch mode the html produced from code blocks has no syntax coloring.
How do I enable the syntax coloring in batch mode?
EDIT:
From the terminal I run emacs --script make.el.
In make.el I include org and org-html and eventually call (org-export-as-html 3)
The following will bold/underline keywords but still no color:
(add-to-list 'load-path "~/elisp/org/contrib/lisp")
(require 'htmlize)
(setq c-standard-font-lock-fontify-region-function 'font-lock-default-fontify-region) ;; fixes bug
(org-export-as-html 3)
EDIT 2:
A couple more things I've tried - they make no difference:
(setq org-src-fontify-natively t)
(org-babel-do-load-languages 'org-babel-load-languages '((java .t)))
I've also tried loaded my entire .emacs
I'm using GNU Emacs 24.3.1 and Org 7.9.2
Apparently, if you use the color-theme library, then (for occult reasons about which I have no clue yet) you can have colored outputs through htmlize when exporting in batch mode.
For example, evaluating the following code in an org buffer to export makes htmlize use colors defined by means of a theme, and that works when exporting both in batch mode and interactively (by creating a temporary frame and setting the appropriate color theme to avoid messing up the frame containing the org buffer to export):
(require 'cl) ;for `lexical-let'
(add-hook
;; This is for org 8.x (use `org-export-first-hook' for earlier versions).
(make-local-variable 'org-export-before-processing-hook)
(lambda (backend)
(add-to-list (make-local-variable 'load-path) (expand-file-name "./etc"))
(require 'color-theme)
(color-theme-initialize)
(when (display-graphic-p) ;Are we running in interactive mode?
;; If so, create a temporary frame to install the color theme used by
;; htmlize:
(lexical-let ((buff (switch-to-buffer-other-frame (current-buffer)))
(frame (selected-frame)))
(setq color-theme-is-global nil)
(make-frame-invisible frame)
;; Schedule deletion of temporary frame:
(add-to-list
;; The following is for org 8.x (earlier versions use other hooks like
;; `org-latex-final-hook').
(make-local-variable 'org-export-filter-final-output-functions)
(lambda (string backend info) (delete-frame frame)))))
;; Install color theme.
(color-theme-blippblopp)))
I had installed org-mode version 8.2.1 from emacs list-packages.
I downloaded the latest version 8.2.4 and placed it in .emacs.d and added the following to my .emacs,
(add-to-list 'load-path "~/.emacs.d/org-8.2.4/lisp")
Emacs still reports org-mode version to be 8.2.1
Try removing old installation(s) of org-mode from the load-path first:
(require 'cl)
;; Org-mode that was shipped with Emacs
(setq load-path (remove-if (lambda (x) (string-match-p "org$" x)) load-path))
;; ELPA
(setq load-path (remove-if (lambda (x) (string-match-p "org-20" x)) load-path))
(setq custom-org-path "~/.emacs.d/org-8.2.4/lisp")
(add-to-list 'load-path custom-org-path)
Also make sure to do it as early as possible in your init.el - especially if you use org-mode-based system for your emacs configuration files.
Add the following to your init.el file.
(require 'package)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
From the org compact guide here.
I use Emacs only for \LaTeX and python programming. Is there a way to automatically turn on flyspell-mode when I work on a .tex file, and turn on flyspell-prog-mode when I work on a .py file? How can I do this in my .emacs file?
Add those functions to hooks of python-mode and latex-mode
(require 'python)
;; If you use tex-mode
(require 'tex-mode)`
(add-hook 'latex-mode-hook 'flyspell-mode)
;; If you use AUCTeX
(load "auctex.el" nil t t)`
(add-hook 'LaTeX-mode-hook 'flyspell-mode)
(add-hook 'python-mode-hook 'flyspell-prog-mode)
Something like this should work.
(setq auto-mode-alist (cons '("\\.tex\\'" . flyspell-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.py\\'" . flyspell-prog-mode) auto-mode-alist))
I want to develop java in emacs. I install ecb, jde and auto-complete extensions. Each one works well without starting others. But when i want to use them together, some problem happened.
auto-complete-mode doesn't auto start with jde, I need to start it by M-x auto-complete-mode. If without jde, auto-complete-mode will auto start
When I manually start the auto-complete-mode in jde, the auto complete is not work well. It just auto complete the word that is appeared.
Here is my .emacs content:
(global-linum-mode 1)
(setq linum-format "%2d| ")
(setq default-tab-width 4)
(setq debug-on-error t)
;;no backup file
(setq make-backup-files nil)
(setq debug-on-error t)
;;auto complete config
(add-to-list 'load-path "D:/emacs-24.1/custom_el/auto-complete-1.3.1")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "D:/emacs-24.1/custom_el/auto-complete-1.3.1/dict")
(ac-config-default)
(setq stack-trace-on-error t)
(add-to-list 'load-path (expand-file-name "D:/emacs-24.1/custom_el/jdee-2.4.0.1/lisp"))
(add-to-list 'load-path (expand-file-name "D:/emacs-24.1/custom_el/cedet-1.1/common"))
(add-to-list 'load-path (expand-file-name "D:/emacs-24.1/custom_el/elib-1.0"))
(add-to-list 'load-path' "d:/emacs-24.1/custom_el/ecb-2.40")
;; Initialize CEDET.
(load-file (expand-file-name "D:/emacs-24.1/custom_el/cedet-1.1/common/cedet.el"))
(load-file (expand-file-name "D:/emacs-24.1/custom_el/ecb-2.40/ecb.el"))
(require 'ecb)
(ecb-activate)
(ecb-byte-compile)
;; If you want Emacs to defer loading the JDE until you open a
;; Java file, edit the following line
(setq defer-loading-jde nil)
;; to read:
;;
;; (setq defer-loading-jde t)
;;
(if defer-loading-jde
(progn
(autoload 'jde-mode "jde" "JDE mode." t)
(setq auto-mode-alist
(append
'(("\\.java\\'" . jde-mode))
auto-mode-alist)))
(require 'jde))
;; Sets the basic indentation for Java source files
;; to two spaces.
(defun my-jde-mode-hook ()
(setq c-basic-offset 2))
(add-hook 'jde-mode-hook 'my-jde-mode-hook)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(ecb-options-version "2.40")
'(ecb-primary-secondary-mouse-buttons (quote mouse-1--C-mouse-1)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
The version info is :
emacs : 24.1
auto complete : 1.3.1
ecb : 2.40
cedet : 1.1
elib : 1.0
jdee : 2.4.0.1
To auto-start auto-complete-mode with jde-mode, you need to add jde-mode to ac-modes:
(push 'jde-mode ac-modes)
Then you need to add a JDEE-specific source to ac-sources. I'm not sure of the extent of JDEE integration with Semantic, you may be able to use the pre-defined source for it:
(add-hook 'jde-mode-hook (lambda () (push 'ac-source-semantic ac-sources)))
If not, you may need to define a specialized source with ac-define-source. See auto-complete-config.el for examples.
I just install auto-complete-mode, however everytime I start emacs I have to M-x auto-complete-mode. Is there anyway to have it loaded automatically ?
My .emacs is as follows:
;; auto-complete
(add-to-list 'load-path "~/.emacs.d/")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d//ac-dict")
(ac-config-default)
Thanks
I think you can do it in various ways. To enable it globally you should use
(global-auto-complete-mode t)
But it uses auto-complete-mode-maybe, which turn AC on only those listed in ac-modes. You can add them manually just like this
(add-to-list 'ac-modes 'sql-mode)
You can make your own list if you wish AC be active only for few modes
(setq ac-modes '(c++-mode sql-mode))
Or rewrite it to have AC everywhere.
(defun auto-complete-mode-maybe ()
"No maybe for you. Only AC!"
(auto-complete-mode 1))
edited:
Autocomplete in minibuffer is bad. I think this will be better.
(defun auto-complete-mode-maybe ()
"No maybe for you. Only AC!"
(unless (minibufferp (current-buffer))
(auto-complete-mode 1)))
I just needed this:
(require 'auto-complete)
(global-auto-complete-mode t)
added to my .emacs.d/init.el file.
I installed auto-complete with the package manager. I'm using Emacs 24.