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

Support derived modes in zoom-ignored-major-modes #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jtamagnan
Copy link

Foreword

First of all thank you for this incredible tool, its been a few years
since I've been using it, and I've never looked back.

I ran into an issue that I lived with for a while but figured I could
try to improve it. Hopefully this PR finds you well.

Problem

Emacs has a concept of derived and parent modes. The relationship
between these modes is often used to share configuration or show a
shared purpose.

zoom-mode does not support the use of these "parent" modes in
zoom-ignored-major-modes, instead it checks whether the current mode
is in that list of modes. One example would be a user who wants to
ignore all gnus-mode child modes; currently they would need to add
gnus-summary-mode, gnus-group-mode, and some of the other 20 odd
^gnus-.*-mode$ modes. This is difficult to track and error prone.

Solution

Instead of checking if the major-mode is in the
zoom-ignored-major-modes list check if it is a child of one of those
modes.

Testing

I've tested with gnus-mode and found it to work as expected

@cyrus-and
Copy link
Owner

cyrus-and commented Aug 15, 2024

But does it really work though?

(setq modes (list major-mode))

;; (lisp-interaction-mode)

(derived-mode-p modes)

;; nil

(member major-mode modes)

;; (lisp-interaction-mode)

@jtamagnan
Copy link
Author

jtamagnan commented Aug 16, 2024

But does it really work though?

Oh wow... That's surprising 😅

I looked into it a little bit. It seems like the behavior is different in Emacs 30.1 and Emacs 29.1 This lines up with some news entry but I'm not positive what was changed.

Tests:

$ emacs -Q --batch --eval '(princ (format "version: %s\noutput: %s" emacs-version (derived-mode-p (list major-mode))))'
version: 31.0.50
output: lisp-interaction-mode
$ emacs -Q --batch --eval '(princ (format "version: %s\noutput: %s" emacs-version (derived-mode-p (list major-mode))))'
version: 29.1
output: nil

I'll go update this PR to handle both versions

@cyrus-and
Copy link
Owner

FYI Emacs 29.2 here, and yes:

(derived-mode-p 'c-mode major-mode)

;; lisp-interaction-mode

@jtamagnan
Copy link
Author

It seems like the most robust solution would be to include both the original check and the new check. I've pushed that code and lightly tested it. It seems consistent with what we'd expect

@cyrus-and
Copy link
Owner

cyrus-and commented Aug 17, 2024

Eh, but that still won't work in <30:

(progn
  (setq zoom-ignored-major-modes '(prog-mode))
  (member major-mode zoom-ignored-major-modes)
  (derived-mode-p zoom-ignored-major-modes))

;; nil

I propose the following:

(progn
  (setq zoom-ignored-major-modes '(prog-mode))
  (derived-mode-p zoom-ignored-major-modes)
  (apply 'derived-mode-p zoom-ignored-major-modes))

;; prog-mode

What do you think? (The above is run in *scratch*.)

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