Archived
1
0
Fork 0

re-enable flyspell with helm integration

This commit is contained in:
KemoNine 2022-08-25 20:05:52 -04:00
parent dfa675b014
commit dbfc184f0b

View file

@ -395,40 +395,53 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; flyspell
;(require 'flyspell)
;(setenv "LANG" "en_US")
;(setenv "DICPATH" "~/.emacs.d.profiles/common/dictionaries") ; https://github.com/wooorm/dictionaries
;(setq ispell-program-name "hunspell")
;(setq ispell-dictionary "en_US")
;
;(global-set-key (kbd "C-c y") 'flyspell-toggle )
;
;(defun flyspell-on-for-buffer-type ()
; "Enable Flyspell appropriately for the major mode of the current buffer. Uses `flyspell-prog-mode' for modes derived from `prog-mode', so only strings and comments get checked. All other buffers get `flyspell-mode' to check all text. If flyspell is already enabled, does nothing."
; (interactive)
; (if (not (symbol-value flyspell-mode)) ; if not already on
; (progn
; (if (derived-mode-p 'prog-mode)
; (progn
; (message "Flyspell on (code)")
; (flyspell-prog-mode))
; ;; else
; (progn
; (message "Flyspell on (text)")
; (flyspell-mode 1)))
; ;; I tried putting (flyspell-buffer) here but it didn't seem to work
; )))
;
; (defun flyspell-toggle ()
; "Turn Flyspell on if it is off, or off if it is on. When turning on, it uses `flyspell-on-for-buffer-type' so code-vs-text is handled appropriately."
; (interactive)
; (if (symbol-value flyspell-mode)
; (progn ; flyspell is on, turn it off
; (message "Flyspell off")
; (flyspell-mode -1))
; ; else - flyspell is off, turn it on
; (flyspell-on-for-buffer-type)))
;
;(add-hook 'find-file-hook 'flyspell-on-for-buffer-type)
;(add-hook 'text-mode-hook 'flyspell-on-for-buffer-type)
;(add-hook 'after-change-major-mode-hook 'flyspell-on-for-buffer-type)
(require 'flyspell)
(setenv "LANG" "en_US")
(setq ispell-program-name "hunspell")
(setq ispell-dictionary "en_US")
(use-package flyspell :demand t
:config
(use-package
flyspell-correct-helm)
(defun flyspellCompletion()
(flyspell-mode 1)
(set (make-local-variable 'company-backends)
(copy-tree company-backends))
(add-to-list 'company-backends 'company-ispell))
(defun flyspell-most-modes()
(add-hook 'text-mode-hook 'flyspellCompletion)
(add-hook 'prog-mode-hook 'flyspellCompletion)
(dolist (hook '(change-log-mode-hook log-edit-mode-hook))
(add-hook hook (lambda ()
(flyspell-mode -1)))))
(flyspell-most-modes)
)
(defun flyspell-on-for-buffer-type ()
"Enable Flyspell appropriately for the major mode of the current buffer. Uses `flyspell-prog-mode' for modes derived from `prog-mode', so only strings and comments get checked. All other buffers get `flyspell-mode' to check all text. If flyspell is already enabled, does nothing."
(interactive)
(if (not (symbol-value flyspell-mode)) ; if not already on
(progn
(if (derived-mode-p 'prog-mode)
(progn
(message "Flyspell on (code)")
(flyspell-prog-mode))
;; else
(progn
(message "Flyspell on (text)")
(flyspell-mode 1)))
;; I tried putting (flyspell-buffer) here but it didn't seem to work
)))
(defun flyspell-toggle ()
"Turn Flyspell on if it is off, or off if it is on. When turning on, it uses `flyspell-on-for-buffer-type' so code-vs-text is handled appropriately."
(interactive)
(if (symbol-value flyspell-mode)
(progn ; flyspell is on, t it off
(message "Flyspell off")
(flyspell-mode -1))
; else - flyspell is off, turn it on
(flyspell-on-for-buffer-type)))
; flyspell keyboard shortcuts
(global-set-key (kbd "C-x y") 'flyspell-toggle)
(global-set-key (kbd "C-x w") 'flyspell-correct-wrapper)