emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/jinx 4fc9450062 1/4: Setup internal state after jinx-mo


From: ELPA Syncer
Subject: [elpa] externals/jinx 4fc9450062 1/4: Setup internal state after jinx-mode-hook
Date: Fri, 26 May 2023 05:58:50 -0400 (EDT)

branch: externals/jinx
commit 4fc94500623285c9b3bf4fdc6ac066f4ffddf2a1
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Setup internal state after jinx-mode-hook
---
 CHANGELOG.org |  2 ++
 jinx.el       | 40 +++++++++++++++++++---------------------
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/CHANGELOG.org b/CHANGELOG.org
index e3d7714551..d18a12e966 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -13,6 +13,8 @@
 - Rename category of Jinx overlays to =jinx-overlay=.
 - Rename =jinx-misspelled-map= to =jinx-overlay-map=.
 - Add many more language modes to =jinx-camel-modes=.
+- Run =jinx-mode-hook= before spell checker setup, such that local variables 
can
+  be updated in time.
 
 * Version 0.8 (2023-04-28)
 
diff --git a/jinx.el b/jinx.el
index 4bf4bdcb8a..a1775e0393 100644
--- a/jinx.el
+++ b/jinx.el
@@ -507,8 +507,8 @@ If CHECK is non-nil, always check first."
   (cl-loop for (mode . vals) in list
            if (or (eq mode t) (derived-mode-p mode)) append vals))
 
-(defun jinx--get-org-language ()
-  "Get language from Org #+language keyword."
+(defun jinx--use-org-language ()
+  "Use language from Org #+language keyword."
   (when (and (not (local-variable-p 'jinx-languages))
              (derived-mode-p #'org-mode))
     (save-excursion
@@ -516,6 +516,7 @@ If CHECK is non-nil, always check first."
         (goto-char (point-min))
         (when (re-search-forward "^ *#\\+language: +\\([a-z_]+\\) *$" nil t)
           (setq-local jinx-languages (match-string-no-properties 1)))))))
+(add-hook 'jinx-mode-hook #'jinx--use-org-language)
 
 (defun jinx--timer-handler ()
   "Global timer handler, checking the pending regions in all windows."
@@ -727,9 +728,18 @@ If CHECK is non-nil, always check first."
     (insert-before-markers word)
     (delete-region start end)))
 
-(defun jinx--load-dicts ()
-  "Load dictionaries and setup syntax table."
-  (setq jinx--dicts (delq nil (mapcar #'jinx--mod-dict
+(defun jinx--setup ()
+  "Setup internal state and load dictionaries."
+  (setq jinx--exclude-regexp
+        (when-let ((regexps (jinx--mode-list jinx-exclude-regexps)))
+          (mapconcat (lambda (r) (format "\\(?:%s\\)" r))
+                     regexps "\\|"))
+        jinx--include-faces (jinx--mode-list jinx-include-faces)
+        jinx--exclude-faces (jinx--mode-list jinx-exclude-faces)
+        jinx--camel (or (eq jinx-camel-modes t)
+                        (apply #'derived-mode-p jinx-camel-modes))
+        jinx--session-words (split-string jinx-local-words)
+        jinx--dicts (delq nil (mapcar #'jinx--mod-dict
                                       (split-string jinx-languages)))
         jinx--syntax-table (make-syntax-table jinx--base-syntax-table))
   (unless jinx--dicts
@@ -819,7 +829,7 @@ With prefix argument GLOBAL change the languages globally."
                    (y-or-n-p "Save `jinx-languages' as file-local variable? 
")))
       (add-file-local-variable 'jinx-languages jinx-languages)
       (setf (alist-get 'jinx-languages file-local-variables-alist) 
jinx-languages))))
-  (jinx--load-dicts)
+  (jinx--setup)
   (jinx--cleanup))
 
 ;;;###autoload
@@ -891,25 +901,13 @@ If prefix argument ALL non-nil correct all misspellings."
   :lighter (:eval (concat " Jinx[" jinx-languages "]"))
   :group 'jinx
   :keymap jinx-mode-map
+  :after-hook (when jinx-mode (jinx--setup))
   (cond
    ((buffer-base-buffer) ;; Do not enable in indirect buffers
-    (when jinx-mode
-      (jinx-mode -1)))
+    (when jinx-mode (jinx-mode -1)))
    (jinx-mode
     (jinx--load-module)
-    (let ((enable-local-variables :safe))
-      (hack-local-variables))
-    (jinx--get-org-language)
-    (setq jinx--exclude-regexp
-          (when-let ((regexps (jinx--mode-list jinx-exclude-regexps)))
-            (mapconcat (lambda (r) (format "\\(?:%s\\)" r))
-                       regexps "\\|"))
-          jinx--include-faces (jinx--mode-list jinx-include-faces)
-          jinx--exclude-faces (jinx--mode-list jinx-exclude-faces)
-          jinx--camel (or (eq jinx-camel-modes t)
-                          (apply #'derived-mode-p jinx-camel-modes))
-          jinx--session-words (split-string jinx-local-words))
-    (jinx--load-dicts)
+    (let ((enable-local-variables :safe)) (hack-local-variables))
     (add-hook 'window-state-change-hook #'jinx--reschedule nil t)
     (add-hook 'window-scroll-functions #'jinx--reschedule nil t)
     (add-hook 'post-command-hook #'jinx--reschedule nil t)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]