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

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

bug#8730: bug#8781: bug#8730: bug#8781: 24.0.50; unload-feature don't re


From: Stefan Monnier
Subject: bug#8730: bug#8781: bug#8730: bug#8781: 24.0.50; unload-feature don't restore default key
Date: Sat, 25 Jun 2011 09:30:19 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> If found, I follow back the chain of derivation until I find a major
> mode M' which is not defined in F.

Sounds good.

> If found, I use M'; if not, I switch the buffer to  "(or (default
> 'major-mode) 'fundamental-mode)".

I'd just use fundamental-mode which is treated by define-derived-mode as
the implicit parent when there's no parent.

> +
> +      ;; Change major mode in all buffers using one defined in the
> feature being unloaded.
> +      (save-current-buffer
> +        (dolist (buffer (buffer-list))
> +          (set-buffer buffer)
> +          (let ((proposed major-mode)
> +                (original major-mode))
> +            ;; Look for an antecessor mode not defined in the feature
> we're processing
> +            (while (and proposed (rassq proposed unload-function-defs-list))
> +              (setq proposed (get proposed 'derived-mode-parent)))
> +            (unless (eq proposed major-mode)
> +              ;; Two cases: either proposed is nil, and we want to
> switch to the default
> +              ;; major mode, or proposed is not nil and not
> major-mode, and so we use it.
> +              (funcall (or proposed default-mode))
> +              ;; This check protects agains the user having a weird
> default major-mode;
> +              ;; for example, one that calls set-auto-mode (been
> here, done that).
> +              (when (eq major-mode original) (funcall 'fundamental-mode))))))
> +

But please move it into its own function.


        Stefan





reply via email to

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