Skip to content
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

Issue with Meow and Git Timemachine Integration #462

Open
MArpogaus opened this issue May 23, 2023 · 0 comments
Open

Issue with Meow and Git Timemachine Integration #462

MArpogaus opened this issue May 23, 2023 · 0 comments
Labels
compatibility issue with meow integrating with a third-party package

Comments

@MArpogaus
Copy link

Problem Description

There is an issue when using Meow and Git Timemachine packages together.
When viewing a file in git-timemachine-mode meow, switches states using the meow--mode-get-state function which returns the meow mode based on the current major mode or overides in meow-mode-state-list.

Since git-timemachine-mode is a minor mode, it cant be used for automatic switching into motion using meow-mode-state-list.

Proposed Solution

A possible workaround is to modify the meow--mode-get-state function in Meow to disable mode inference and always return a specific state. By overriding this function, we can bypass the automatic mode switching behavior and consistently set the desired Meow state.

To implement this workaround, we can define a buffer-local variable called my-meow-desired-state, which will hold the desired Meow state for the current buffer. We can then use the advice-add function to apply advice to meow--mode-get-state, modifying its behavior based on the value of my-meow-desired-state. Additionally, a hook can be added to set the desired state specifically when entering Git Timemachine mode.

Implementation Steps

  1. Add the necessary definitions and modifications to your Emacs configuration:

    ;; Define buffer-local variable
    (defvar-local my-meow-desired-state 'motion
      "Buffer-local variable to specify the desired Meow state.")
    
    ;; Function to set the buffer-local value of my-meow-desired-state
    (defun my-meow-set-desired-state (state)
      "Set the buffer-local variable 'my-meow-desired-state' to the specified state."
      (setq-local my-meow-desired-state state))
    
    ;; Advice function to modify 'meow--mode-get-state' based on 'my-meow-desired-state'
    (defun my-meow-mode-get-state-advice (orig-func &rest args)
      "Advice function to modify 'meow--mode-get-state' based on 'my-meow-desired-state'."
      (if my-meow-desired-state
          my-meow-desired-state
        (apply orig-func args)))
    
    ;; Apply advice to 'meow--mode-get-state'
    (advice-add 'meow--mode-get-state :around #'my-meow-mode-get-state-advice)
    
    ;; Hook to set my-meow-desired-state to 'motion' when entering git-timemachine mode
    (defun my-meow-git-timemachine-hook ()
      "Hook to set my-meow-desired-state to 'motion' when entering git-timemachine mode."
      (my-meow-set-desired-state 'motion))
    
    ;; Check if git-timemachine is loaded and add the hook
    (when (featurep 'git-timemachine)
      (add-hook 'git-timemachine-mode-hook 'my-meow-git-timemachine-hook))
  2. Evaluate or reload your Emacs configuration to apply the changes.

Disclaimer

Please note that the workaround provided here is based on guidance from an AI language model (ChatGPT) and may not cover all possible edge cases or interactions with other packages. It is recommended to thoroughly test the solution and make any necessary adjustments based on your specific setup.


This issue can be considered as a possible enhancement for Meow to improve compatibility with minor modes like Git Timemachine. The workaround provided can serve as a temporary solution until an official enhancement is implemented.

@eshrh eshrh added the compatibility issue with meow integrating with a third-party package label Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility issue with meow integrating with a third-party package
Projects
None yet
Development

No branches or pull requests

2 participants