From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KTDa8-0000Z7-DG for mharc-grub-devel@gnu.org; Wed, 13 Aug 2008 06:27:56 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KTDa4-0000YR-J8 for grub-devel@gnu.org; Wed, 13 Aug 2008 06:27:53 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KTDa0-0000XU-U1 for grub-devel@gnu.org; Wed, 13 Aug 2008 06:27:51 -0400 Received: from [199.232.76.173] (port=50618 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KTDZy-0000Wb-S4 for grub-devel@gnu.org; Wed, 13 Aug 2008 06:27:47 -0400 Received: from smtp-vbr4.xs4all.nl ([194.109.24.24]:4052) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KTDZy-0007ER-8a for grub-devel@gnu.org; Wed, 13 Aug 2008 06:27:46 -0400 Received: from localhost.localdomain (249-174.surfsnel.dsl.internl.net [145.99.174.249]) by smtp-vbr4.xs4all.nl (8.13.8/8.13.8) with ESMTP id m7DARidt050318 for ; Wed, 13 Aug 2008 12:27:45 +0200 (CEST) (envelope-from mgerards@xs4all.nl) From: Marco Gerards To: The development of GRUB 2 References: Mail-Copies-To: mgerards@xs4all.nl Date: Wed, 13 Aug 2008 12:31:21 +0200 In-Reply-To: (bean123ch@gmail.com's message of "Tue, 12 Aug 2008 05:03:10 +0800") Message-ID: <87od3x8ava.fsf@xs4all.nl> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by XS4ALL Virus Scanner X-detected-kernel: by monty-python.gnu.org: FreeBSD 4.6-4.9 Subject: Re: Idea: use menu hook to implement the savedefault command X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Aug 2008 10:27:54 -0000 Bean writes: > Hi, > > Now it's possible to implement savedefault with load_env and save_env, > but the problem is we need to add it to every menuitem, it's tedious > process, and new item don't get it automatically. > > I'm thinking about using menu hook to solve this. I can think of two > implementation: > > 1. Function interface > > We can install hooks, which get called just before the menu is invoked. > > 2. Script interface > > We can use certain variable to specific the command to use, for example: > > set MENU_PRELOAD=save_env default Wouldn't this be a BOOT_PRELOAD? I thought about this before (see archives about scripting), making it possible for the user to add hooks. In C: ... menu code ... /* The `menu' hook has one argument. */ grub_hook_invoke ("menu", 1, arglist); In scripting: function menu_hook_handler() save_env; hook --register --hook=menu --script menu_hook_handler Or do you think I am crazy now? ;-) This will involve some scripting hacking, but might pay off. Do you think this is too complex for users?