From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: cc-mode adds newlines Date: Mon, 22 Nov 2004 15:06:20 -0500 Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1101154034 22628 80.91.229.6 (22 Nov 2004 20:07:14 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 22 Nov 2004 20:07:14 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Nov 22 21:06:59 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CWKSh-0007IN-00 for ; Mon, 22 Nov 2004 21:06:59 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CWKbl-0004es-0h for ged-emacs-devel@m.gmane.org; Mon, 22 Nov 2004 15:16:21 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CWKbd-0004em-2d for emacs-devel@gnu.org; Mon, 22 Nov 2004 15:16:13 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CWKbc-0004ea-ME for emacs-devel@gnu.org; Mon, 22 Nov 2004 15:16:12 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CWKbc-0004eX-HS for emacs-devel@gnu.org; Mon, 22 Nov 2004 15:16:12 -0500 Original-Received: from [132.204.24.67] (helo=mercure.iro.umontreal.ca) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CWKSI-0002kj-GL for emacs-devel@gnu.org; Mon, 22 Nov 2004 15:06:34 -0500 Original-Received: from hidalgo.iro.umontreal.ca (hidalgo.iro.umontreal.ca [132.204.27.50]) by mercure.iro.umontreal.ca (Postfix) with ESMTP id 3713A8282AF; Mon, 22 Nov 2004 15:06:34 -0500 (EST) Original-Received: from asado.iro.umontreal.ca (asado.iro.umontreal.ca [132.204.24.84]) by hidalgo.iro.umontreal.ca (Postfix) with ESMTP id AF0444AC50A; Mon, 22 Nov 2004 15:06:20 -0500 (EST) Original-Received: by asado.iro.umontreal.ca (Postfix, from userid 20848) id 4AC3C8CA69; Mon, 22 Nov 2004 15:06:20 -0500 (EST) Original-To: Kevin Rodgers In-Reply-To: (Kevin Rodgers's message of "Mon, 22 Nov 2004 12:16:07 -0700") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux) X-DIRO-MailScanner-Information: Please contact the ISP for more information X-DIRO-MailScanner: Found to be clean X-DIRO-MailScanner-SpamCheck: n'est pas un polluriel, SpamAssassin (score=0, requis 5) X-MailScanner-From: monnier@iro.umontreal.ca 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: main.gmane.org gmane.emacs.devel:30266 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:30266 > I agree, but I would like to see it implemented outside of customize. > Custom would of course provide an interface to it, but wouldn't be the > only way to specify a mode-specific value. I think `add-hook' is perfectly fine for non-custom uses. People have used it for years without any problems. > (put 'require-final-newline 'c-mode t) > would be equivalent to > (add-hook 'c-mode-hook > (lambda () > (set (make-local-variable 'require-final-newline) t)) I recommend (defun my-c-mode-hook () (set (make-local-variable 'require-final-newline) t)) (add-hook 'c-mode-hook 'my-c-mode-hook) It's better behaved when you reload your .emacs. If you think the above is too scary, we can provide functions/macros to make it less so. E.g. a macro `setq-local'. > Ah, we're talking about almost exactly the same thing. You've collected > all the mode-specific values into an association list keyed by the mode > symbol, and put that on the variable's custom-per-mode property; whereas > I put each value on a separate property. I actually dislike this property in my sample code because it duplicate some info. A better way would be to hard-code the result of `assq' inthe definition of the functions we put on the hooks, and then in custom-get-per-mode we'd rebuild the alist by looking at the hooks and extracting the value from the body of the function. But that's pretty ugly. The reason for doing that would be that if a user does (remove-hook 'foo-mode-hook 'custom-set-foo-some-var) it should properly update the corresponding value returned by custom-get-per-mode. Stefan