flyspell doesn't load with LaTeX file in emacs - emacs

Following this web page, I have edited my ~/.emacs file and added the line:
(add-hook 'LaTeX-mode-hook 'flyspell-mode)
However, flyspell doesn't start with LaTeX files. Why is that so?

I could not make this work:
(add-hook 'LaTeX-mode-hook 'flyspell-mode) or
(add-hook 'latex-mode-hook 'flyspell-mode)
But then I found this:
(add-hook 'LaTeX-mode-hook 'turn-on-flyspell)
-and it is working.

Emacs is case-sensitive; the hook should be written as latex-mode-hook. Try this:
(add-hook 'latex-mode-hook 'flyspell-mode)

Related

Set Flycheck enable for other mode

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.

Having trouble getiting Tomorrow theme to work in Emacs

I have only recently started to use emacs. I have succesffully used a couple of different themes, but am having trouble getting Tomorrow to work.
Here's what I have done:
The .el files are in ~/.emacs.d/themes/
my-init.el:
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/")
(require 'color-theme-sanityinc-tomorrow)
(load-theme 'color-theme-sanityinc-tomorrow-night t)
I load this in .emacs by doing
(add-hook 'after-init-hook '(lambda ()
(load "~/.emacs.d/my-noexternals.el")
(load "~/.emacs.d/my-init.el") ))
When I reload emacs I see eval-buffer: Cannot open load file: no such file or directory, color-theme-sanityinc-tomorrow.
If color-theme-sanityinc-tomorrow.el is in ~/.emacs.d/themes/ you need to had:
(add-to-list 'load-path "~/.emacs.d/themes/")
before the require.
Regards

emacs can't turn on minor-mode automatically

I want irony-mode be turned on automatically in c-mode. But I have tried two ways, both fail. Can someone teach me? I don't like to type M-x irony-mode always.
1:
(require 'irony)
(defun my:irony-init ()
(irony-mode 1))
(add-hook 'c++-mode-hook 'my:irony-init)
(add-hook 'c-mode-hook 'my:irony-init)
OR 2:
(require 'irony)
(add-hook 'c++-mode-hook 'irony-mode)
(add-hook 'c-mode-hook 'irony-mode)
I find not only irony-mode, but also ggtags and flycheck can't load through add-hook. I have (add-hook 'c-mode-hook 'flycheck-mode), but it doesn't work. Can someone help me? My .emacs.d has uploaded to github:https://github.com/cfampc/emacs.d。 My irony-mode is configured in .emacs.d/custom/c-settings.el and flycheck ggtags is in .emacs.d//custom/edit-settings.el. Before I can have ggtags-mode auto-load in C. Now, If I add (add-hook 'c-mode-common-hook 'irony-mode) after (load ...) all of my config file, it does work. But if I add it in .emacs.d/custom/c-settings.el , It doesn't work. why?
That should work fine, so you should recursively bisect your config to find the source of the problem.

Emacs, how to auto turn on flyspell for LaTeX file

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

Emacs auto-complete-mode at startup

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.