GNU bug report logs - #8730
23.2; unload-feature leaves hook

Previous Next

Package: emacs;

Reported by: Andreas Röhler <andreas.roehler <at> easy-emacs.de>

Date: Wed, 25 May 2011 05:54:01 UTC

Severity: minor

Found in version 23.2

Done: Juanma Barranquero <lekktu <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #29 received at 8730 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juanma Barranquero <lekktu <at> gmail.com>
Cc: 8781 <at> debbugs.gnu.org, 8730 <at> debbugs.gnu.org
Subject: Re: 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
> 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




This bug report was last modified 14 years and 25 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.