From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sebastian Wiesner Newsgroups: gmane.emacs.devel Subject: Re: Derived modes and mode hooks Date: Sat, 9 Mar 2013 15:43:47 +0100 Message-ID: References: <20130309223153.65701f80892c4ad001cc5ab2@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1362840251 31556 80.91.229.3 (9 Mar 2013 14:44:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 9 Mar 2013 14:44:11 +0000 (UTC) Cc: emacs-devel To: Xue Fuqiao Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Mar 09 15:44:35 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UEL0l-0005Kc-GL for ged-emacs-devel@m.gmane.org; Sat, 09 Mar 2013 15:44:35 +0100 Original-Received: from localhost ([::1]:44604 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UEL0P-0007sG-IP for ged-emacs-devel@m.gmane.org; Sat, 09 Mar 2013 09:44:13 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:46385) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UEL05-0007SF-AQ for emacs-devel@gnu.org; Sat, 09 Mar 2013 09:43:57 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UEL00-00036l-Do for emacs-devel@gnu.org; Sat, 09 Mar 2013 09:43:53 -0500 Original-Received: from mail-qa0-f44.google.com ([209.85.216.44]:40610) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UEL00-00036f-9n for emacs-devel@gnu.org; Sat, 09 Mar 2013 09:43:48 -0500 Original-Received: by mail-qa0-f44.google.com with SMTP id bv4so284814qab.10 for ; Sat, 09 Mar 2013 06:43:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=wDcX5fX8GzsIBhoAaGhx8+h85zPzGCOWng8QZ3oMzFQ=; b=Aqwees22nWfKvsPPx1Fox4NtZL1Pk9boRo4Sy9EMMQn6T94siqhIKI6+1JtkqWcZo0 dTg3RD5iqCMxlkrtGBr3ETWLWmOAmxPM7biWOudEWWWFHvYZvR6RIru7esW6f0K47TZG FkGJeL5udkFdq1wlSaeVparoJVwCZK+UPTmCjBEfusJfxQxtWVcui6ph41OYr4Bjrg32 g044Gvbod497C5eoKsyaFTsX2GipJ1MLtUKydypipIgSD4SJAjfMmqLiTnUsj6lBh1oc S+1+KpMRhQDFvNKCtIZzaapW5MrFcfYdGcdw5SMihp/MCtvMdF6MrCI2JtH601T40+dm mSpQ== X-Received: by 10.224.176.70 with SMTP id bd6mr9116350qab.26.1362840227747; Sat, 09 Mar 2013 06:43:47 -0800 (PST) Original-Received: by 10.224.111.147 with HTTP; Sat, 9 Mar 2013 06:43:47 -0800 (PST) In-Reply-To: <20130309223153.65701f80892c4ad001cc5ab2@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.216.44 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:157663 Archived-At: 2013/3/9 Xue Fuqiao : > On Sat, 9 Mar 2013 15:06:00 +0100 > Sebastian Wiesner wrote: > >> For instance, given "foo-mode" defined as: >> >> (define-derived-mode foo-mode text-mode "Foo" >> "A useless mode for demonstration purposes" >> (body-of-foo-mode)) > >> Then "M-x foo-mode" will > >> 1. Perform some standard setup stuff (e.g. killing local variables, >> setting the key map, etc.) >> 2. Execute "body-of-foo-mode" >> 3. Execute all hooks in "text-mode-hook" >> 4. Execute all hooks in "foo-mode-hook" > >> Is this right? If so, how can `body-of-foo-mode` forcibly overrule >> settings made in `text-mode-hook`? > > See the function `run-mode-hooks'. What am I supposed to see there? I read the documentation of this function, even looked at its source code, and now I feel confirmed in my analysis of things. But I can't see anything that would help me to solve the actual problem, that is forcibly disabling `auto-fill-mode`. I can't even control when and how this function is invoked, as `define-derived-mode` does that implicitly. > I'm no expert on this, but IIRC `after-change-major-mode-hook' helps. Call me stupid, but I fail to see how it could. It's executed even earlier than `body-of-foo-mode`, and thus suffers from the same problem: The later execution of `text-mode-hook` will bring back `auto-fill-mode`, given `(add-hook 'text-mode-hook 'auto-fill-mode)` in the user's init file. I need something that runs *after* `text-mode-hook`, but *before* `foo-mode-hook`.