Gentoo Archives: gentoo-dev

From: Andreas Voegele <voegelas@×××××××××××××××××.net>
To: gentoo-dev@××××××××××.org
Subject: [gentoo-dev] Re: Emacs settings for ebuild scripts
Date: Sat, 10 Nov 2001 07:17:41
Message-Id: m27ksysodu.fsf@columbus.localdomain
In Reply to: Re: [gentoo-dev] Emacs settings for ebuild scripts by Mikael Hallendal
1 Mikael Hallendal writes:
2
3 > In Emacs21 I get an error when hitting TAB telling me I'm not in
4 > shell-script-mode. You know what's causing that?
5
6 I don't know if this is a feature or a bug in Emacs 21. The function
7 sh-must-be-shell-mode in sh-script.el looks like this:
8
9 (defun sh-must-be-shell-mode ()
10 "Signal an error if not in Shell-script mode."
11 (unless (eq major-mode 'sh-mode)
12 (error "This buffer is not in Shell-script mode")))
13
14 IMHO the expression (eq major-mode 'sh-mode) should be replaced with
15 (derived-mode-p 'sh-mode).
16
17 I'll ask the Emacs developers.
18
19 In the meanwhile the following code, which includes an advice for
20 sh-must-be-shell-mode, can be used:
21
22 (define-derived-mode ebuild-script-mode
23 sh-mode "Ebuild-script" nil
24 (setq tab-width 4))
25
26 (setq auto-mode-alist
27 (append
28 '(("\\.ebuild$" . ebuild-script-mode))
29 auto-mode-alist))
30
31 (defadvice sh-must-be-shell-mode
32 (around sh-must-be-shell-mode-around activate)
33 "Accept modes derived from sh-mode."
34 (unless (derived-mode-p 'sh-mode)
35 ad-do-it))
36
37 --
38 Andreas