From c13c07a5408742d3b07770cbc3d8ee34571f41a2 Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Sun, 16 Jul 2017 03:58:00 +0200 Subject: [PATCH] added autoscratch-pre-trigger-hook + autoscratch-post-trigger-hook --- autoscratch.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/autoscratch.el b/autoscratch.el index edf48e1..4224ec9 100644 --- a/autoscratch.el +++ b/autoscratch.el @@ -62,6 +62,10 @@ ;; `autoscratch-buffer' in the background. In order to enable this ;; feature, set `autoscratch-fork-after-trigger' to t. +;; To further tune the trigger bahavior you can tune +;; `autoscratch-pre-trigger-hook' which will be called before +;; executing the form of the matching trigger and +;; `autoscratch-post-trigger-hook' afterwards. ;;; Code: ;;;; Customizables @@ -101,6 +105,16 @@ This list triggers after the first character entered." (defcustom autoscratch-trigger-after 5 "Max chars to be entered to force trigger the default form.") +;;;; Public Vars + +(defvar autoscratch-pre-trigger-hook () + "Hooks called before executing a matching trigger form") + +(defvar autoscratch-post-trigger-hook () + "Hooks called after executing a matching trigger form") + +;; FIXME: add hooks for fork stuff + ;;;; Public Functions (defun autoscratch-buffer-rename () @@ -132,7 +146,9 @@ and create a new autoscratch buffer." ;;;; Internal Functions (defun autoscratch--eval-trigger-and-rename (form) + (run-hooks 'autoscratch-pre-trigger-hook) (eval form) + (run-hooks 'autoscratch-post-trigger-hook) (message (format "autoscratch switched to %s" major-mode)) (autoscratch-fork-and-rename-current))