Function: jinx--load-module
jinx--load-module is a natively compiled function defined in jinx.el.
Signature
(jinx--load-module)
Documentation
Compile and load dynamic module.
Source Code
;; Defined in /nix/store/b5jnxgwmlp7hh60wfrx7amhrmrpfcqqi-emacs-packages-deps/share/emacs/site-lisp/elpa/jinx-20260926.912/jinx.el
(defun jinx--load-module ()
"Compile and load dynamic module."
(unless (fboundp #'jinx--mod-dict)
(unless module-file-suffix
(error "Jinx: Dynamic modules are not supported"))
(let* ((mod-name (file-name-with-extension "jinx-mod" module-file-suffix))
(mod-file (locate-library mod-name t)))
(unless mod-file
(let* ((cc (or (getenv "CC")
(seq-find #'executable-find '("gcc" "clang" "cc"))
(error "Jinx: No C compiler found")))
(c-name (file-name-with-extension mod-name ".c"))
(default-directory (file-name-directory
(or (locate-library c-name t)
(error "Jinx: %s not found" c-name))))
(command nil)
(inhibit-read-only t))
(with-current-buffer (get-buffer-create "*jinx module compilation*")
(erase-buffer)
(compilation-mode)
(insert (format "Jinx: Compiling %s\n" mod-name))
(setq command
`(,cc ,@jinx--compile-flags "-o" ,mod-name ,c-name
,@(split-string-and-unquote
(condition-case nil
(car (process-lines "pkg-config" "--cflags" "--libs" "enchant-2"))
(error
(insert "Jinx: pkgconf or pkg-config not found\n")
"-I/usr/include/enchant-2 -I/usr/local/include/enchant-2 -L/usr/local/lib -lenchant-2")))))
(insert (string-join command " ") "\n")
(if (equal 0 (apply #'call-process (car command) nil (current-buffer) t (cdr command)))
(insert (message "Jinx: %s compiled successfully" mod-name))
(let ((msg (format "Jinx: Compilation of %s failed" mod-name)))
(insert msg)
(pop-to-buffer (current-buffer))
(error msg))))
(setq mod-file (expand-file-name mod-name))))
;; Initialize Mac spell checker to avoid dead lock (gh:minad/jinx#91).
(when (and (eq window-system 'mac) (fboundp 'mac-do-applescript))
(mac-do-applescript
"use framework \"AppKit\"
set spellChecker to current application's NSSpellChecker's sharedSpellChecker()"))
(module-load mod-file))))