bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#32795: Acknowledgement (26.1; provided-mode-derived-p does not suppo


From: Andrew Schwartzmeyer
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
User-agent: Posteo Webmail

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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]