From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Glenn Morris Newsgroups: gmane.emacs.help Subject: Re: What's wrong with this elisp code? Date: Fri, 04 Aug 2006 13:51:11 -0700 Organization: None Message-ID: References: <44D233E1.6060900@speakeasy.net> <44D24F39.5080607@speakeasy.net> <52A05EBB-9A5D-48C9-8A2A-553908FD097E@Web.DE> <44D25BD4.7040006@speakeasy.net> <44D327DF.6090500@speakeasy.net> <1FC085D0-7196-4146-ABAE-1C4815191D9D@Web.DE> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1154727646 3345 80.91.229.2 (4 Aug 2006 21:40:46 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 4 Aug 2006 21:40:46 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Aug 04 23:40:45 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1G97P6-0005dj-3J for geh-help-gnu-emacs@m.gmane.org; Fri, 04 Aug 2006 23:40:24 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G97P5-0007zT-IR for geh-help-gnu-emacs@m.gmane.org; Fri, 04 Aug 2006 17:40:23 -0400 Original-Path: shelby.stanford.edu!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 43 Original-NNTP-Posting-Host: xoc5.stanford.edu Original-X-Trace: news.Stanford.EDU 1154724671 14041 171.64.56.172 (4 Aug 2006 20:51:11 GMT) Original-X-Complaints-To: news@news.stanford.edu X-Spook: Rule Psix sulfur supercomputer Nellis Range Chukaku-Ha X-Ran: .zb(5[f![;X&su{=g-&cxuq>/0mWgSStN7|bqdcN~ 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:36499 Archived-At: ken wrote: > Is there some other way that this variable could be defined other than > with defvar? Yes, the way that Jeff Miller already said: inside a let binding so that it only exists for the duration of the calling function: bar -> Symbol's value as variable is void: bar (defun foo () (let ((bar "BAR")) (message "the value of bar is %s" bar))) (foo) -> "the value of bar is BAR" bar -> Symbol's value as variable is void: bar Making your own definition of the variable `bar' outside of the function `foo' will be no help at all, since this global binding is hidden inside the let statement. The Emacs calendar does a few things in this way, which can make it difficult to follow. To achieve what you want, use the already posted solution, or adapt the definition of the function `diary-mail-entries' (see documentation of that function for example cron usage), eg to: (require 'diary-lib) (defun diary-to-file (file &optional ndays) "Write the diary entries for the next NDAYS (default 1) to FILE." (interactive (list (read-file-name "Write diary to file: ") (prefix-numeric-value current-prefix-arg))) (let ((diary-display-hook 'fancy-diary-display)) (list-diary-entries (calendar-current-date) (or ndays 1)) (with-temp-buffer (insert (if (get-buffer fancy-diary-buffer) (with-current-buffer fancy-diary-buffer (buffer-string)) "No diary entries found")) (write-region (point-min) (point-max) file nil nil nil t))))