GNU bug report logs -
#32795
26.1; provided-mode-derived-p does not support parent modes set with defalias
Previous Next
Full log
View this message in rfc822 format
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 <at> 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 <at> gnu.org
>
> If you wish to submit further information on this problem, please
> send it to 32795 <at> debbugs.gnu.org.
>
> Please do not send mail to help-debbugs <at> gnu.org unless you wish
> to report a problem with the Bug-tracking system.
This bug report was last modified 6 years and 296 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.