From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: RE: turning on minor modes from hooks Date: Sat, 29 Aug 2009 17:14:53 -0700 Message-ID: <9CA8B839B73049A6A7B1AD1C4D92BFC3@us.oracle.com> References: <200908292125.n7TLPCdp005058@godzilla.ics.uci.edu> <87eiqui4yx.fsf@catnip.gol.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1251591359 8679 80.91.229.12 (30 Aug 2009 00:15:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 30 Aug 2009 00:15:59 +0000 (UTC) Cc: emacs-devel@gnu.org To: "'Miles Bader'" , "'Dan Nicolaescu'" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Aug 30 02:15:51 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MhY5G-0000vk-Gp for ged-emacs-devel@m.gmane.org; Sun, 30 Aug 2009 02:15:50 +0200 Original-Received: from localhost ([127.0.0.1]:34686 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MhY5F-0007hW-F9 for ged-emacs-devel@m.gmane.org; Sat, 29 Aug 2009 20:15:49 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MhY4b-0007Xn-Rh for emacs-devel@gnu.org; Sat, 29 Aug 2009 20:15:09 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MhY4V-0007VJ-1O for emacs-devel@gnu.org; Sat, 29 Aug 2009 20:15:08 -0400 Original-Received: from [199.232.76.173] (port=48471 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MhY4U-0007V8-NA for emacs-devel@gnu.org; Sat, 29 Aug 2009 20:15:02 -0400 Original-Received: from acsinet12.oracle.com ([141.146.126.234]:37754) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MhY4R-00059Z-O4; Sat, 29 Aug 2009 20:15:00 -0400 Original-Received: from acsinet15.oracle.com (acsinet15.oracle.com [141.146.126.227]) by acsinet12.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id n7U0EJF5027554 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 30 Aug 2009 00:14:21 GMT Original-Received: from abhmt003.oracle.com (abhmt003.oracle.com [141.146.116.12]) by acsinet15.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id n7U0EsoY006042; Sun, 30 Aug 2009 00:14:54 GMT Original-Received: from dradamslap1 (/141.144.88.200) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 29 Aug 2009 17:14:53 -0700 X-Mailer: Microsoft Office Outlook 11 Thread-Index: Acoo/3ZMZDeNsK06TWq3s6wBDUtyLwAAKQYw In-Reply-To: <87eiqui4yx.fsf@catnip.gol.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-Source-IP: abhmt003.oracle.com [141.146.116.12] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090208.4A99C47E.011F:SCFSTAT5015188,ss=1,fgs=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 1) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:114862 Archived-At: > > (add-hook 'text-mode-hook 'auto-fill-mode) > > > > This avoids defining extra functions just for the purpose > > of being able to call them from hooks. There's never been a need to define an "extra function" for use on a hook. (add-hook 'text-mode-hook (lambda () (auto-fill-mode 1))) > > Not sure how feasible is to have a clean implementation of > > such a feature... > > Stephen has long advocated that non-interactive invocation of mode > commands should always turn on the mode instead of toggling. So interactively a nil arg will toggle, but in Lisp a nil arg will turn it on? And just why is that a great idea? > I agree with that: I think the vast majority of uses in code > do not use the toggling anyway, and while there probably are > a few uses which would be broken by such a change, I think > there would be far _more_ currently-incorrect uses In libraries or in user init files? The latter, maybe, at least until they discover that it doesn't do what they thought. That doesn't take long... > that would be _fixed_ by such a change (where someone uses > (add-hook 'foo-hook 'ack-mode) not realizing that it really > toggles instead of turning on). "Not realizing" is the key phrase. This is not about being unable to understand, I think. It's about ordinary ignorance. It's about things not being the way some newbies expect, without reading the doc. There are lots of such Emacs-Lisp gotchas that new users learn about soon enough. What's so special about this one? This one they learn about as soon as they try it the first time. Or, barring simple trial and error, they can actually read the doc (quelle horreur !) to find out that a nil arg toggles. It's the same thing for learning about quoting or list structure or hooks or anything else: things might not be what you expect if you don't read a little. Emacs puts the info at your fingertips with doc strings and such - really not a biggee. It's not as if this is something complex and difficult for users to understand - some people just don't bother to check a doc string or Info. You seem to contrast ignorance about the arg, on the one hand, with the entire body of existing Lisp code that uses mode functions, on the other. Granted, most mode-function calls do not toggle the mode, but I don't think toggling is that rare. Not to mention code that might specifically test the arg, treating nil differently from a positive integer - oops, guess what, starting with Emacs 23.2 they act the same... I'd rather not expect library authors to have to adjust their existing code that toggles the mode, to make it call (foo-mode (not foo-mode)) instead of (foo-mode). I'd rather they not need to adjust code that examines the arg and acts accordingly, changing the logic for Emacs post-23.1. I'd rather that new users just read the doc and learn this FAQ, like so many other FAQs. Not a biggee, and neither is using `lambda' in a hook. This is a YAGNI feature, at best, and a bug-producer and code complexifier, at worst. No, I don't feel very strongly about this, but I do not think it's a great idea.