GNU bug report logs -
#8730
23.2; unload-feature leaves hook
Previous Next
Full log
Message #29 received at 8730 <at> debbugs.gnu.org (full text, mbox):
> 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.