From db3ec3b67d617a650c3a7479d018564c354c5d6a Mon Sep 17 00:00:00 2001 From: Hugo Thunnissen Date: Mon, 7 Aug 2023 20:55:34 +0200 Subject: [PATCH] Add custom variables for worker and pipeline pause time --- phpinspect-pipeline.el | 15 +++++++++++++-- phpinspect-worker.el | 10 +++++++++- phpinspect.el | 2 ++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/phpinspect-pipeline.el b/phpinspect-pipeline.el index 021a730..3c3069d 100644 --- a/phpinspect-pipeline.el +++ b/phpinspect-pipeline.el @@ -28,9 +28,20 @@ (define-error 'phpinspect-pipeline-incoming "Signal for incoming pipeline data") (define-error 'phpinspect-pipeline-error "Signal for pipeline errors") -(defvar phpinspect-pipeline-pause-time 0.5 +(defcustom phpinspect-pipeline-pause-time 0.5 "Number of seconds to pause a pipeline thread when emacs receives -user input.") +user input. This is similar to `phpinspect-worker-pause-time', +but pipelines are meant to run in bursts. For that reason, the +default pause time for pipelines is lower to be a little more +aggressive in hogging cpu time. + +Set this variable to a higher value if you experience a lot of +jitter when editing during pipeline operations. At the time of +writing, pipelines are used to refresh the project +index/autoloader and for the indexation of \"include\" +directories." + :type 'number + :group 'phpinspect) (cl-defstruct (phpinspect-pipeline-end (:constructor phpinspect-make-pipeline-end)) (value nil diff --git a/phpinspect-worker.el b/phpinspect-worker.el index 70ec5c2..a7cc7f0 100644 --- a/phpinspect-worker.el +++ b/phpinspect-worker.el @@ -31,6 +31,14 @@ (require 'phpinspect-queue) (require 'phpinspect-pipeline) +(defcustom phpinspect-worker-pause-time 1 + "Number of seconds that `phpinspect-worker' should pause when +user input is detected. A higher value means better +responsiveness, at the cost of slower code indexation. On modern +hardware this probably doesn't need to be tweaked." + :type 'number + :group 'phpinspect) + (defvar phpinspect-worker nil "Contains the phpinspect worker that is used by all projects.") @@ -142,7 +150,7 @@ already present in the queue." ;; interrupt the thread. (unless (or (not (input-pending-p)) (phpinspect-worker-skip-next-pause worker)) - (phpinspect-thread-pause 1 mx continue)) + (phpinspect-thread-pause phpinspect-worker-pauseo-time mx continue)) (setf (phpinspect-worker-skip-next-pause worker) nil))) (t (message "Phpinspect worker thread errored :%s" err)))) (phpinspect--log "Worker thread exiting") diff --git a/phpinspect.el b/phpinspect.el index 349c7c8..e42f92c 100644 --- a/phpinspect.el +++ b/phpinspect.el @@ -142,6 +142,8 @@ Reparses the entire buffer without token reuse." "A minor mode for intelligent completion for and interaction with PHP files. +See also: \\[customize-group] RET phpinspect RET . + To initially index a project, use M-x `phpinspect-index-current-project' in a buffer of one of the project files. Project root is detected with `phpinspect-project-root-file-list'.