diff options
Diffstat (limited to '')
-rw-r--r-- | emacs | 94 |
1 files changed, 45 insertions, 49 deletions
@@ -127,55 +127,51 @@ (doxymacs-font-lock))))) ;; flyspell (with aspell for Unicode) -(setq ispell-program-name "aspell") -(setq ispell-extra-args '("--sug-mode=ultra")) - -(add-hook 'c-mode-hook 'flyspell-prog-mode) -(add-hook 'sh-mode-hook 'flyspell-prog-mode) -(add-hook 'c++-mode-hook 'flyspell-prog-mode) -(add-hook 'ruby-mode-hook 'flyspell-prog-mode) -(add-hook 'cperl-mode-hook 'flyspell-prog-mode) -(add-hook 'python-mode-hook 'flyspell-prog-mode) -(add-hook 'autoconf-mode-hook 'flyspell-prog-mode) -(add-hook 'autotest-mode-hook 'flyspell-prog-mode) -(add-hook 'makefile-mode-hook 'flyspell-prog-mode) -(add-hook 'emacs-lisp-mode-hook 'flyspell-prog-mode) - -(add-hook 'tex-mode-hook (function (lambda () (setq ispell-parser 'tex)))) -(add-hook 'texinfo-mode - '(lambda () (setq flyspell-generic-check-word-p - 'texinfo-mode-flyspell-verify))) - -(add-hook 'text-mode-hook (lambda () (flyspell-mode 1))) -(add-hook 'change-log-mode-hook (lambda () (flyspell-mode 1))) - -(add-hook 'flyspell-mode-hook 'flyspell-buffer) - -; ignore all #include stings -(add-hook 'flyspell-incorrect-hook - (lambda (left right undef) - (save-excursion - (goto-char left) - (beginning-of-line) - (if (looking-at "#include") - 't - 'nil) - ))) - -; change dictionary -(defun switch-dictionary() - (interactive) - (let* ((dic ispell-current-dictionary) - (change (if (string= dic "german") "english" "german"))) - (ispell-change-dictionary change) - (message "Dictionary switched from %s to %s" dic change) - (if flyspell-mode (save-excursion (flyspell-buffer))))) -(global-set-key (kbd "<f8>") 'switch-dictionary) - -; update flyspell after changing dictionary -(defadvice ispell-pdict-save (after advice) - (save-excursion (flyspell-buffer))) -(ad-activate 'ispell-pdict-save t) +(setq ispell-program-name "aspell" + ispell-extra-args '("--sug-mode=ultra")) + +;; define variable to store default dictionary for automatic flyspell enabling +(defvar flyspell-dict nil "Dictionary name, that should be set during find-file for flyspell-mode. +If this is set during find-file, flyspell mode gets enabled automaticaly.") +(make-variable-buffer-local 'flyspell-dict) + +(when (require 'ispell nil 'noerror) + ;; change dictionary + (defun switch-dictionary() + (interactive) + (let* ((dic ispell-current-dictionary) + (change (if (string= dic "german") "english" "german"))) + (ispell-change-dictionary change) + (message "Dictionary switched from %s to %s" dic change) + (if flyspell-mode (save-excursion (flyspell-buffer))))) + (global-set-key (kbd "<f8>") 'switch-dictionary) + + (when (require 'flyspell nil 'noerror) + ;; check buffer if enable flyspell + (add-hook 'flyspell-mode-hook + (lambda () + (when flyspell-mode (flyspell-buffer)))) + + ;; ignore all #include stings + (add-hook 'flyspell-incorrect-hook + (lambda (left right undef) + (save-excursion + (goto-char left) + (beginning-of-line) + (if (looking-at "#include") t nil)))) + + ;; activate flyspell mode during find-file if flyspell-dict is set + (add-hook 'find-file-hook + (lambda () + (when flyspell-dict + (ispell-change-dictionary flyspell-dict) + (flyspell-mode t)))) + + ;; update flyspell after changing personal dictionary + (defadvice ispell-pdict-save (after advice) + (save-excursion (flyspell-buffer))) + (ad-activate 'ispell-pdict-save t))) + ;; auto compile files (require 'self-compile-mode) |