From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Karl Chen Newsgroups: gmane.emacs.devel Subject: Re: cal-x.el/diary-lib.el diary-mode-hook Date: Thu, 15 May 2008 12:28:41 -0700 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1210879748 21931 80.91.229.12 (15 May 2008 19:29:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 15 May 2008 19:29:08 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu May 15 21:29:44 2008 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 1Jwj93-0003Jp-Vp for ged-emacs-devel@m.gmane.org; Thu, 15 May 2008 21:29:42 +0200 Original-Received: from localhost ([127.0.0.1]:46934 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jwj8K-0006d2-9D for ged-emacs-devel@m.gmane.org; Thu, 15 May 2008 15:28:56 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jwj8D-0006b8-Tt for emacs-devel@gnu.org; Thu, 15 May 2008 15:28:49 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jwj89-0006VW-At for emacs-devel@gnu.org; Thu, 15 May 2008 15:28:49 -0400 Original-Received: from [199.232.76.173] (port=41939 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jwj88-0006VI-UC for emacs-devel@gnu.org; Thu, 15 May 2008 15:28:45 -0400 Original-Received: from roar.cs.berkeley.edu ([128.32.36.242]:54280 helo=roar.quarl.org) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Jwj88-0004G5-FR for emacs-devel@gnu.org; Thu, 15 May 2008 15:28:44 -0400 Original-Received: by roar.quarl.org (Postfix, from userid 18378) id 1B0DF34365; Thu, 15 May 2008 12:28:41 -0700 (PDT) X-Quack-Archive: 1 In-Reply-To: (Stefan Monnier's message of "Thu\, 15 May 2008 10\:52\:15 -0400") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Linux 2.6? (barebone, rare!) 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:97226 Archived-At: >>>>> On 2008-05-15 07:52 PDT, Stefan Monnier writes: >> I realize the documentation for diary-display-hook says >> "list of functions", but a couple places in the code >> let-bind diary-display-hook to non-lists, and the >> documentation in 22.2 has sample code with non-lists. Stefan> Hooks accept either a function or a list of functions, Stefan> where the former is only accepted for historical Stefan> reasons. So all the code that sets hooks to a single Stefan> function should be reported as (minor) bugs, and all Stefan> the documentation that does that should be reported as Stefan> (non-minor) bugs. A quick grep in the EMACS_22_BASE Stefan> branch disn't show me the sample code you refer to, so Stefan> could you please tell us where you found it? Sure. Emacs 22.2 (Debian) sample code in docstring: calendar.el:769: (setq diary-display-hook 'fancy-diary-display) Let-binds: appt.el:346: (let* ((diary-display-hook 'appt-make-list) diary-lib.el:581: (let* ... (diary-display-hook 'ignore) diary-lib.el:915: (let ((diary-display-hook 'fancy-diary-display)) Stefan> This said, using `memq' on a hook is indeed an error. Memq on hook: cal-x.el:90: (if (not (memq 'fancy-diary-display diary-display-hook)) cal-x.el:148: (if (not (memq 'fancy-diary-display diary-display-hook)) Docstring could be tweaked slightly: diary-lib.el:670: (defun fancy-diary-display () diary-lib.el:671: "Prepare a diary buffer with relevant entries in a fancy, noneditable form. diary-lib.el:672: This function is provided for optional use as the `diary-display-hook'." Stefan> PS: You should "never" modify a hook with setq, always Stefan> use `add-hook'. I see. I think the whole confusion arises because diary-display-hook doesn't act like a regular hook, where a bunch of hooks are typically stacked and called sequentially. The various functions for diary display are really alternates to each other, not stackable extras. If diary-display-hook already contains fancy-diary-display, then when add-hook fancy-schedule-display-desk-calendar has no effect. An nil value for diary-display-hook also has different semantics than for regular hooks. Perhaps it should have been called "diary-display-function" to begin with, though there was probably a reason for converting it into a list-of-functions hook other than just its name.