Function: majutsu-thingatpt--jj-revision
majutsu-thingatpt--jj-revision is a natively compiled function defined
in majutsu-jj.el.
Signature
(majutsu-thingatpt--jj-revision &optional DISALLOW)
Documentation
Return the JJ revision at point, or nil if none is found.
Optional DISALLOW is a string of characters that should not appear in the revision identifier (used for recursive refinement).
Source Code
;; Defined in /nix/store/jagqw3nms546pad0gxi5f3wsckk6pji7-emacs-packages-deps/share/emacs/site-lisp/majutsu-jj.el
(defun majutsu-thingatpt--jj-revision (&optional disallow)
"Return the JJ revision at point, or nil if none is found.
Optional DISALLOW is a string of characters that should not appear
in the revision identifier (used for recursive refinement)."
(and-let* ((bounds
(let ((c (majutsu--regexp-char-class
(concat " \n\t~^:?*[\\|()<>" disallow))))
(cl-letf
(((get 'jj-revision 'beginning-op)
(lambda ()
(if (re-search-backward (format "[%s]" c) nil t)
(forward-char)
(goto-char (point-min)))))
((get 'jj-revision 'end-op)
(lambda ()
(re-search-forward (format "\\=[^%s]*" c) nil t))))
(bounds-of-thing-at-point 'jj-revision))))
(string (buffer-substring-no-properties (car bounds) (cdr bounds)))
(string (thread-first string
(string-trim-left "[][()</\"']+")
(string-trim-right "[])>\"'.,;:!]+"))))
(let* ((structured-revision
(memq (majutsu-text-property-near-point 'majutsu-row-field)
'(change-id commit-id bookmarks tags)))
(explicit-syntax (majutsu--explicit-jj-revision-syntax-p string)))
(when (or (string-match-p "\\.\\." string)
(string-match-p "/\\." string))
(setq disallow (concat disallow ".")))
(when (> (cl-count ?@ string) 1)
(setq disallow (concat disallow "@")))
(when (and (string-match-p "/[0-9]" string)
(> (cl-count ?/ string) 1))
(setq disallow (concat disallow "/")))
(if disallow
(majutsu-thingatpt--jj-revision disallow)
(and (not (string-blank-p string))
(or
(and (string-match-p "^[k-z]+$" string)
(>= (length string) (if structured-revision 1 4))
(majutsu-jj-revision-p string))
(and (>= (length string) 4)
(string-match-p "^[0-9a-fA-F]+$" string)
(majutsu-jj-revision-p string))
(string-equal string "@")
(and explicit-syntax
(majutsu-jj-revision-p string))
(and structured-revision
(majutsu-jj-revision-p string)))
string)))))