rougier / svg-lib

Emacs SVG libraries for creatings tags, icons and bars
GNU General Public License v3.0
343 stars 31 forks source link

`svg-lib-button--mouse-press` is incompatible with Emacs 27.X and lower #49

Open DavidCodingLounge opened 2 months ago

DavidCodingLounge commented 2 months ago

Just a small note about an incompatibility with Emacs 27.X and lower versions with the method svg-lib-button--mouse-press. It will throw an error when invoked due to a method parameter count mismatch.

It uses methods don't exist until Emacs 28.X (e.g. minibufferp with the additional live parameter and abort-minibuffers). I patched the method when in a lower Emacs version to only execute the hook callback when not in a minibuffer using the minibufferp method available. There is likely a better solution I am sure, but just wanted to surface this issue in case anyone else runs across it.

NOTE: - A dirtier solution for lower Emacs version that would technically accomplish the same thing, more or less (i.e. it doesn't work for minibuffers from multiple recursive edits ... though that edge case is probably non-existent for the use case of the library):

(if (minibufferp)
    (unwind-protect
        (throw 'exit (lambda () (signal 'minibuffer-quit nil)))
        (funcall hook)
    )
    (funcall hook)
)

Though I do wonder if this block could be simplified:

(unwind-protect
    (when (minibufferp)
        (throw 'exit (lambda () (signal 'minibuffer-quit nil))) ; Or `abort-minibuffers` for higher Emacs versions
    )
    (funcall hook)
)

Any who, I digress.

I hope this bug report helps.

Fantastic work, as always, and great library @rougier ! Thank you so much :)

rougier commented 1 month ago

Thanks and sorry for late answer. Thanks for your patch. Will it work on both 27 and upper? If so, can you make a PR?