Skip to content

Port counsel-kmacro to OClosures #3067

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2025
Merged

Port counsel-kmacro to OClosures #3067

merged 1 commit into from
Mar 4, 2025

Conversation

basil-conto
Copy link
Collaborator

Also fix action functions to support being ivy-called without exiting the completion session.

  • counsel-kmacro-kill: Try to prevent being called outside of counsel-kmacro minibuffer completion.
  • counsel-kmacro: Fix docstring. Ensure kmacro.el is loaded before evaluating any variables it defines. Remove kmacro-counter from prompt; it is already listed per-kmacro in ring. Do not default to kmacro-initial-counter-value; defer to kmacro-specific counter. Reword docs and action labels to avoid confusion between kmacro-initial-counter-value and kmacro-counter.
  • counsel--kmacro-format-function: Simplify.
  • counsel--with-kmacro: New macro for destructuring a kmacro object.
  • counsel--format-kmacro: New function.
  • counsel--kmacro-candidates: Use it and counsel--with-kmacro to format kmacro ring objects. Use kmacro-ring-head. Fix stale edmacro-fix-menu-commands warning message. Clarify docstring.
  • counsel--kmacro-exec: New compatibility shim for kmacro-exec-ring-item.
  • counsel-kmacro-action-run: Improve docstring. Fix current-prefix-arg usage and let ivy-current-prefix-arg override it. Use counsel--kmacro-exec. Update ivy-last for non-exiting ivy-call.
  • counsel-kmacro-action-delete-kmacro: Check whether candidate is in kmacro-ring before deleting, instead of comparing to last-kbd-macro. Use kmacro-delete-ring-head. Update ivy-last state for ivy-call.
  • counsel-kmacro-action-copy-initial-counter-value, counsel-kmacro-action-copy-counter-format-for-new-macro: Use counsel--with-kmacro for slot access. Clarify docstrings.
  • counsel--kmacro-cycle-until: New function.
  • counsel-kmacro-action-cycle-ring-to-macro: Use it for bounded ring cycling. Update ivy-last for non-exiting ivy-call.
  • counsel-kmacro-action-set-saved-starting-counter: Clarify docstring. Avoid having to construct a kmacro object directly by cycling ring, reading new counter, and cycling back. Use read-number. Update ivy-last state for ivy-call.
  • counsel-kmacro-action-execute-after-prompt: Improve docstring. Fix current-prefix-arg usage and let ivy-current-prefix-arg override it. Use read-number, read-string, and format-prompt. Avoid kmacro destructuring via counsel--kmacro-exec.

Fixes: #3066
Cc: @okamsn

@basil-conto basil-conto added bug Existing behavior is incorrect enhancement Suggestion to improve or extend existing behavior compat Issues relating to backward/forward compatibility labels Mar 3, 2025
@basil-conto basil-conto self-assigned this Mar 3, 2025
Also fix action functions to support being ivy-called without
exiting the completion session.

* counsel.el (counsel-kmacro-kill): Try to prevent being called
outside of counsel-kmacro minibuffer completion.
(counsel-kmacro): Fix docstring.  Ensure kmacro.el is loaded before
evaluating any variables it defines.  Remove kmacro-counter from
prompt; it is already listed per-kmacro in ring.  Do not default to
kmacro-initial-counter-value; defer to kmacro-specific counter.
Reword docs and action labels to avoid confusion between
kmacro-initial-counter-value and kmacro-counter.
(counsel--kmacro-format-function): Simplify.
(counsel--with-kmacro): New macro for destructuring a kmacro object.
(counsel--format-kmacro): New function.
(counsel--kmacro-candidates): Use it and counsel--with-kmacro to
format kmacro ring objects.  Use kmacro-ring-head.  Fix stale
edmacro-fix-menu-commands warning message.  Clarify docstring.
(counsel--kmacro-exec): New compatibility shim for
kmacro-exec-ring-item.
(counsel-kmacro-action-run): Improve docstring.  Fix
current-prefix-arg usage and let ivy-current-prefix-arg override it.
Use counsel--kmacro-exec.  Update ivy-last for non-exiting ivy-call.
(counsel-kmacro-action-delete-kmacro): Check whether candidate is in
kmacro-ring before deleting, instead of comparing to last-kbd-macro.
Use kmacro-delete-ring-head.  Update ivy-last state for ivy-call.
(counsel-kmacro-action-copy-initial-counter-value)
(counsel-kmacro-action-copy-counter-format-for-new-macro): Use
counsel--with-kmacro for slot access.  Clarify docstrings.
(counsel--kmacro-cycle-until): New function.
(counsel-kmacro-action-cycle-ring-to-macro): Use it for bounded ring
cycling.  Update ivy-last for non-exiting ivy-call.
(counsel-kmacro-action-set-saved-starting-counter): Clarify
docstring.  Avoid having to construct a kmacro object directly by
cycling ring, reading new counter, and cycling back.  Use
read-number.  Update ivy-last state for ivy-call.
(counsel-kmacro-action-execute-after-prompt): Improve docstring.
Fix current-prefix-arg usage and let ivy-current-prefix-arg override
it.  Use read-number, read-string, and format-prompt.  Avoid kmacro
destructuring via counsel--kmacro-exec.

Fixes #3066.
@basil-conto basil-conto merged commit db61f55 into master Mar 4, 2025
36 checks passed
@basil-conto basil-conto deleted the blc/kmacro branch March 4, 2025 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Existing behavior is incorrect compat Issues relating to backward/forward compatibility enhancement Suggestion to improve or extend existing behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kbd macros are stored as oclosure, resulting in counsel-kmacro error: Wrong type argument: listp
1 participant