Function: var:add-and-run-hook

var:add-and-run-hook is an autoloaded and byte-compiled function defined in hvar.el.

Signature

(var:add-and-run-hook HOOK HOOK-FUNCTION)

Documentation

Add to mode HOOK the HOOK-FUNCTION; call it in matching major-mode buffers.

HOOK is a symbol whose name begins with a major-mode name and ends with
"-hook".

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hvar.el
;;; ************************************************************************
;;; Public functions
;;; ************************************************************************

;;;###autoload
(defun var:add-and-run-hook (hook hook-function)
  "Add to mode HOOK the HOOK-FUNCTION; call it in matching major-mode buffers.
HOOK is a symbol whose name begins with a major-mode name and ends with
\"-hook\"."
  (add-hook hook hook-function)
  (let* ((hook-name (symbol-name hook))
	 (mode (when (string-match "-hooks?\\'" hook-name)
		 (intern (substring hook-name 0 (match-beginning 0))))))
    (when mode (var:run-hook-in-matching-buffers mode hook-function))))