Function: jinx--check-region

jinx--check-region is a natively compiled function defined in jinx.el.

Signature

(jinx--check-region START END &optional RETRY)

Documentation

Check region between START and END.

Optionally RETRY word at given position. Return updated END position.

Source Code

;; Defined in /nix/store/b5jnxgwmlp7hh60wfrx7amhrmrpfcqqi-emacs-packages-deps/share/emacs/site-lisp/elpa/jinx-20260926.912/jinx.el
(defun jinx--check-region (start end &optional retry)
  "Check region between START and END.
Optionally RETRY word at given position.  Return updated END
position."
  (let (parse-sexp-lookup-properties case-fold-search retry-start retry-end)
    (with-silent-modifications
      (save-excursion
        (save-match-data
          (with-syntax-table jinx--syntax-table
            ;; Ensure that region starts and ends at word boundaries
            (goto-char start)
            (unless (looking-at-p "\\<")
              (re-search-backward "\\<\\|^")
              (setq start (match-beginning 0)))
            (goto-char end)
            (unless (looking-at-p "\\>")
              (re-search-forward "\\>\\|$")
              (setq end (match-beginning 0)))
            (remove-overlays start end 'category 'jinx-overlay)
            (goto-char start)
            (while (re-search-forward "\\<\\w+\\>" end t)
              (let ((word-start (match-beginning 0))
                    (word-end (match-end 0)))
                ;; No quote or apostrophe at start or end
                (while (and (< word-start word-end)
                            (let ((c (char-after word-start)))
                              (or (= c ?') (= c ?’))))
                  (incf word-start))
                (while (and (< word-start word-end)
                            (let ((c (char-before word-end)))
                              (or (= c ?') (= c ?’))))
                  (decf word-end))
                (while (< word-start word-end)
                  (let ((subword-end word-end))
                    (when jinx--camel
                      (goto-char word-start)
                      (when (looking-at "\\([[:upper:]]?[[:lower:]]+\\)\\(?:[[:upper:]][[:lower:]]+\\)+\\>")
                        (setq subword-end (match-end 1))))
                    (goto-char subword-end)
                    (pcase (run-hook-with-args-until-success 'jinx--predicates word-start)
                      ((and (pred integerp) skip)
                       (goto-char (max subword-end (min end skip))))
                      ('nil
                       (if (and retry (<= word-start retry subword-end))
                           (setq retry-start word-start retry-end subword-end retry nil)
                         (overlay-put (make-overlay word-start subword-end) 'category 'jinx-overlay))))
                    (setq word-start subword-end)))))
            (remove-list-of-text-properties start end '(jinx--pending))
            (when retry-start
              (put-text-property retry-start retry-end 'jinx--pending t))))))))