Skip to content

Replace the grep/ack run-with-timer hack with helm-run-after-exit - #218

Merged
bbatsov merged 1 commit into
masterfrom
replace-grep-timer-hack
Jul 8, 2026
Merged

Replace the grep/ack run-with-timer hack with helm-run-after-exit#218
bbatsov merged 1 commit into
masterfrom
replace-grep-timer-hack

Conversation

@bbatsov

@bbatsov bbatsov commented Jul 8, 2026

Copy link
Copy Markdown
Owner

#3 on the list. helm-projectile-grep (and the now-deprecated helm-projectile-ack) deferred the actual search through (run-with-timer 0.01 nil ...) - a fixed 10ms guess, present since the initial commit. The reason: when the command is invoked as an action from a Helm session (the C-s grep action in the project/directory sources), a new Helm session must not start until the current one has torn down.

That's exactly what helm-run-after-exit is for - and the codebase already uses it (the C-c p f etags binding). This routes both commands through a small helm-projectile--run-grep-or-ack helper that:

  • defers via helm-run-after-exit when helm-alive-p (invoked from a live session), and
  • runs the search directly otherwise (standalone M-x / keybinding).

So no more arbitrary 10ms latency on the standalone commands, no racy timer, and the deferral is explicit and self-documenting. Two tests cover both dispatch branches (68 specs).

Note: the interactive "grep from the project list" flow can't be exercised in batch, but in the real action paths Helm has already exited by the time the command runs (helm-exit-and-execute-action / action dispatch), so the direct-call branch handles them, with helm-run-after-exit as the guard for any still-live case.

  • The commits are consistent with our contribution guidelines
  • The new code is not generating bytecode or M-x checkdoc warnings
  • You've updated the changelog
  • You've updated the readme (no user-facing change)

`helm-projectile-grep' (and `helm-projectile-ack') deferred the actual
search through `(run-with-timer 0.01 ...)' - a fixed 10ms guess so that,
when the command was invoked as an action from a Helm session, the new
session wouldn't start before the current one finished tearing down.
This dated back to the initial commit.

Route both through `helm-projectile--run-grep-or-ack', which defers via
`helm-run-after-exit' when a Helm session is live (the codebase's own
idiom for this, already used for the etags binding) and runs the search
directly otherwise.  No more arbitrary latency on the standalone
commands, and the reason for the deferral is now explicit.
@codecov-commenter

codecov-commenter commented Jul 8, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 46.60%. Comparing base (56f81f1) to head (c0ba857).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
helm-projectile.el 80.00% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #218      +/-   ##
==========================================
+ Coverage   46.33%   46.60%   +0.27%     
==========================================
  Files           1        1              
  Lines         559      560       +1     
==========================================
+ Hits          259      261       +2     
+ Misses        300      299       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bbatsov
bbatsov merged commit 68d357c into master Jul 8, 2026
10 checks passed
@bbatsov
bbatsov deleted the replace-grep-timer-hack branch July 8, 2026 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants