Просмотр исходного кода

Clean up flyspell-prog-mode toggle

Josh Bicking 7 лет назад
Родитель
Сommit
a4dbe53ed4
1 измененных файлов с 10 добавлено и 7 удалено
  1. 10 7
      emacs

+ 10 - 7
emacs

@@ -417,15 +417,18 @@ scroll-step 1)
  "l" 'auto-fill-mode
  "s" '(lambda ()
 	(interactive)
-	(if (string= (buffer-local-value 'major-mode (current-buffer)) "text-mode")
-	    (if flyspell-mode
-		(funcall 'flyspell-mode '0)
-	      (flyspell-mode)
-	      (flyspell-buffer))
+	;; use flyspell-mode when in text buffers, otherwise use flyspell-prog-mode
+	(let ((current-mode
+	       (buffer-local-value 'major-mode (current-buffer)))
+	      (flyspell-mode-to-call
+	       (if (or (string= current-mode "text-mode") (string= current-mode "markdown-mode"))
+		   'flyspell-mode
+		 'flyspell-prog-mode)))
+	  ;; toggle the current flyspell mode, and eval the buffer if we turned it on
 	  (if flyspell-mode
 	      (funcall 'flyspell-mode '0)
-	    (flyspell-prog-mode)
-	    (flyspell-buffer))))
+	    (funcall flyspell-mode-to-call)
+	    (flyspell-buffer)))
  ;"a" 'auto-complete-mode
  "a" 'company-mode
  "g" 'magit-status