From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: leoboiko@gmail.com Newsgroups: gmane.emacs.help Subject: Re: How to apply a minor mode to all buffers Date: Fri, 02 Feb 2007 17:27:24 -0200 Message-ID: <87lkjgs6lf.wl%leonardo.boiko@corp.orolix.com> References: <877ivkjb66.fsf@trick.ulm.malte.spiess> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1170444645 30373 80.91.229.12 (2 Feb 2007 19:30:45 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 2 Feb 2007 19:30:45 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Feb 02 20:30:29 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HD477-0001a3-GI for geh-help-gnu-emacs@m.gmane.org; Fri, 02 Feb 2007 20:30:25 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HD477-0001T8-2z for geh-help-gnu-emacs@m.gmane.org; Fri, 02 Feb 2007 14:30:25 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HD46v-0001Pn-0B for help-gnu-emacs@gnu.org; Fri, 02 Feb 2007 14:30:13 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HD46s-0001MG-Dj for help-gnu-emacs@gnu.org; Fri, 02 Feb 2007 14:30:11 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HD46s-0001MD-BC for help-gnu-emacs@gnu.org; Fri, 02 Feb 2007 14:30:10 -0500 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1HD46r-0005l0-V2 for help-gnu-emacs@gnu.org; Fri, 02 Feb 2007 14:30:10 -0500 Original-Received: from root by ciao.gmane.org with local (Exim 4.43) id 1HD46k-0000mj-8O for help-gnu-emacs@gnu.org; Fri, 02 Feb 2007 20:30:02 +0100 Original-Received: from 201.44.96.130 ([201.44.96.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 02 Feb 2007 20:30:02 +0100 Original-Received: from leoboiko by 201.44.96.130 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 02 Feb 2007 20:30:02 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 56 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 201.44.96.130 In-Reply-To: Mail-Followup-To: leonardo.boiko@corp.orolix.com User-Agent: Wanderlust/2.15.5 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (=?ISO-8859-4?Q?Shij=F2?=) APEL/10.6 Emacs/22.0.93 (i486-pc-linux-gnu) MULE/5.0 (SAKAKI) X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:40856 Archived-At: At Mon, 22 Jan 2007 11:57:35 -0500, Stefan Monnier wrote: > You could start with find-file-hook. find-file-hook won=E2=80=99t apply to buffers unrelated to files, though. after-change-major-mode-hook almost does the trick, but it still doesn=E2=80=99t get fundamental-mode. What I=E2=80=99d like is fundamental-mode-hook. =E2=80=9CDamn vim users=E2=80=9D, I said. =E2=80=9CKeep leaving those trai= ling whitespaces all over the place. It disrupts my mental concentration, for I have show-trailing-whitespace globally as t, and I have to stop whatever I=E2=80=99m doing to delete-trailing-whitespace.=E2=80=9D =E2=80=9CYou could put it in a hook, you know=E2=80=9D, said my friend. =E2=80=9CYes, of course=E2=80=9D, I replied, with my best =E2=80=9Cwhy I di= dn=E2=80=99t think of this before=E2=80=9D voice. =E2=80=9CBut I need to test whether the buffer is r= ead-only, else we=E2=80=99d generate lots of beeps=E2=80=9D: (setq-default show-trailing-whitespace nil) (defun leoboiko/delete-and-show-trailing-whitespace () "If the buffer is not readonly, delete trailing whitespace and turn on `show-trailing-whitespace'." (interactive) (if (not buffer-read-only) (progn (delete-trailing-whitespace) (setq show-trailing-whitespace t)))) (add-hook 'hook-for-all-buffers ;; what to put here? 'leoboiko/delete-and-show-trailing-whitespace) My first attempt was find-file-hook, but I want it to apply to non-file buffers too (like email drafts, etc). My second attempt was fundamental-mode-hook, but there is no such thing. My third attempt (after reading fundamental-mode=E2=80=99s source) was after-change-major-mode-hook, but this still doesn=E2=80=99t work for fundamental buffers (say, if I simply create a scratch buffer). The rationale I saw about why there is no fundamental-mode-hook is that variable customizations on fundamental mode are really global customizations. That=E2=80=99s nice, but I don=E2=80=99t want to change va= riables, I want to be able to run arbitrary functions every time a buffer is created. -- Leonardo Boiko http://namakajiri.net