From: Andrew Schwartzmeyer <andrew@schwartzmeyer.com>
To: 32795@debbugs.gnu.org
Subject: bug#32795: Acknowledgement (26.1; provided-mode-derived-p does not support parent modes set with defalias)
Date: Mon, 24 Sep 2018 19:36:11 -0700 [thread overview]
Message-ID: <2ee9d7be53e24d69a1fce4efb6333e71@posteo.net> (raw)
In-Reply-To: <handler.32795.B.153754328012273.ack@debbugs.gnu.org>
Hi all,
I actually just found _another_ scenario that breaks due to this. I was
editing a Jenkinsfile (groovy-mode) and expecting dtrt-indent to
automatically adjust the indent, but it was not. Turns out it's the same
reason again!
https://github.com/jscheid/dtrt-indent/blob/e860db7235147ed5ac1fd8f12b51dbb7cf2e75f1/dtrt-indent.el#L207
(define-globalized-minor-mode dtrt-indent-global-mode
dtrt-indent-mode
(lambda ()
(when (derived-mode-p 'prog-mode 'text-mode)
(dtrt-indent-mode))))
The check `(derived-mode-p 'prog-mode 'text-mode)` returns nil, because
the mode that groovy-mode derived from is set up like this:
(defalias 'groovy-parent-mode
(if (fboundp 'prog-mode) 'prog-mode 'fundamental-mode))
Using this for `provided-mode-derived-p` fixes it:
(defun provided-mode-derived-p (mode &rest modes)
"Non-nil if MODE is derived from one of MODES.
Uses the `derived-mode-parent' property of the symbol to trace
backwards.
If you just want to check `major-mode', use `derived-mode-p'."
(while
(and
(not (memq mode modes))
(let* ((parent (get mode 'derived-mode-parent))
(parentfn (symbol-function parent)))
(setq mode (if (and parentfn (symbolp parentfn)) parentfn
parent)))))
mode)
Thanks Robert Pluim for the `let*` trick, I was wondering how you do
that without nesting `let` expressions.
Does anyone have other suggestions before I send a patch file?
Thanks,
Andy
On 09/21/2018 8:22 am, help-debbugs@gnu.org wrote:
> Thank you for filing a new bug report with debbugs.gnu.org.
>
> This is an automatically generated reply to let you know your message
> has been received.
>
> Your message is being forwarded to the package maintainers and other
> interested parties for their attention; they will reply in due course.
>
> Your message has been sent to the package maintainer(s):
> bug-gnu-emacs@gnu.org
>
> If you wish to submit further information on this problem, please
> send it to 32795@debbugs.gnu.org.
>
> Please do not send mail to help-debbugs@gnu.org unless you wish
> to report a problem with the Bug-tracking system.
next prev parent reply other threads:[~2018-09-25 2:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-21 7:20 bug#32795: 26.1; provided-mode-derived-p does not support parent modes set with defalias Andrew Schwartzmeyer
[not found] ` <handler.32795.B.153754328012273.ack@debbugs.gnu.org>
2018-09-25 2:36 ` Andrew Schwartzmeyer [this message]
2018-09-25 4:15 ` bug#32795: Acknowledgement (26.1; provided-mode-derived-p does not support parent modes set with defalias) Andrew Schwartzmeyer
2018-09-25 5:22 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2ee9d7be53e24d69a1fce4efb6333e71@posteo.net \
--to=andrew@schwartzmeyer.com \
--cc=32795@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.