Function: hywiki-word-store-around-point

hywiki-word-store-around-point is a byte-compiled function defined in hywiki.el.

Signature

(hywiki-word-store-around-point)

Documentation

Store any HyWikiWord before or after point for post-command comparison.

Markers are stored into hywiki--buttonize-start and hywiki--buttonize-end. HyWikiWords are stored only outside of hywiki-non-hook-context-p contexts. This is triggered by pre-command-hook for non-character commands, including deletion commands and those in hywiki-non-character-commands.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hywiki.el
(defun hywiki-word-store-around-point ()
  "Store any HyWikiWord before or after point for post-command comparison.
Markers are stored into `hywiki--buttonize-start' and `hywiki--buttonize-end'.
HyWikiWords are stored only outside of `hywiki-non-hook-context-p' contexts.
This is triggered by `pre-command-hook' for non-character commands,
including deletion commands and those in `hywiki-non-character-commands'."
  (unless (hywiki-ignore-command-hooks-p)
    ;; (when ert--running-tests
    ;;  (message "Running pre-command-hook..."))
    (setq hywiki--buffer-modified-tick (buffer-modified-tick)
	  hywiki--word-pre-command nil)

    (unless (bound-and-true-p edebug-active)
      (set-marker hywiki--buttonize-start nil)
      (set-marker hywiki--buttonize-end nil)
      (setq hywiki--buttonize-range nil))

    (when (and (current-idle-time) (hywiki-non-hook-context-p) (hywiki-word-at))
      ;; Dehighlight any previously highlighted WikiWord at point if
      ;; it is outside of a valid context.
      (save-restriction
	(narrow-to-region (line-beginning-position) (line-end-position 2))
	(hywiki-maybe-dehighlight-reference)))

    (if (and (symbolp this-command)
	     (string-match-p "\\(^\\|-?\\)\\(insert\\|undo\\)\\(-\\|$\\)\\|eval-last-sexp\\|eval-expression\\|read--expression-try-read" (symbol-name this-command)))
	;; prior to an insertion command
	(progn
	  (setq hywiki--start (point)
		hywiki--end nil)
	  ;; Use these to store any range of a delimited HyWikiWord#section
	  (set-marker hywiki--buttonize-start nil)
	  (set-marker hywiki--buttonize-end nil)
	  hywiki--start)
      (unless (hywiki-non-hook-context-p)
	;; Record the WikiWord from any WikiWord ref that point is on
	(setq hywiki--word-pre-command (hywiki-get-singular-wikiword
					(hywiki-word-at)))
	(when (or (memq this-command hywiki-non-character-commands)
		  (and (symbolp this-command)
		       (string-match-p "^\\(org-\\)?\\(delete-\\|kill-\\)\\|\\(-delete\\|-kill\\)\\(-\\|$\\)" (symbol-name this-command))))
	  ;; Test if at delimiters surrounding a single WikiWord reference
	  ;; and if so, record those for use by post hooks.
	  (cl-destructuring-bind (start end)
	      ;; Get delimited region only if before or after delimiters,
	      ;; else return (nil nil).
	      (setq hywiki--buttonize-range
		    (hywiki-at-range-delimiter)) ;; includes delimiters
	    (setq hywiki--start (point))
	    ;; Use these to store any range of a delimited HyWikiWord#section
	    (set-marker hywiki--buttonize-start start)
	    (set-marker hywiki--buttonize-end end)
	    start))))
    (setq hywiki--command-executed-flag t)))