unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* What's wrong with this elisp code?
@ 2006-08-03 17:35 ken
  2006-08-03 19:16 ` Peter Dyballa
  0 siblings, 1 reply; 10+ messages in thread
From: ken @ 2006-08-03 17:35 UTC (permalink / raw)



This line below is in a script:

emacs --batch emacs-diary-day >& /home/xxx/tmp/emacs-diary-log

In /usr/share/emacs/21.3/site-lisp/ (confirmed in load-path) is a file
entitled emacs-diary-day.el; this file contains:

;show today's entries only
(diary 1)
(find-file "/home/xxx/tmp/emacs-diary-day")
;erase everything that might be in the buffer
(erase-buffer)

;see below for the arg to insert
;(apply 'insert diary-entries-list)
;tried both the above and below. Same error either way
(insert diary-entries-list)
(save-buffer)



I found this documentation earlier today:

the variable `diary-entries-list' is a list, in order by date, of all
relevant diary entries in the form of ((MONTH DAY YEAR) STRING), where
string is the diary entry for the given date.  This can be used, for
example, a different buffer for display (perhaps combined with
holidays), or produce hard copy output.

But I'm getting the error:

Loading rng-auto.el (source)...
Loading /usr/lib/emacs/21.3/i586-suse-linux/fns-21.3.1.el (source)...
Preparing diary...
Preparing diary...done
Symbol's value as variable is void: diary-entries-list

If I (setq diary-entries-list "Some string of chars")
there's no error, but of course this isn't what I'm after.

Any happy tips?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: What's wrong with this elisp code?
  2006-08-03 17:35 What's wrong with this elisp code? ken
@ 2006-08-03 19:16 ` Peter Dyballa
       [not found]   ` <44D24F39.5080607@speakeasy.net>
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Dyballa @ 2006-08-03 19:16 UTC (permalink / raw)
  Cc: GNU Emacs List


Am 03.08.2006 um 19:35 schrieb ken:

> the variable `diary-entries-list' is a list, in order by date, of all
> relevant diary entries in the form of ((MONTH DAY YEAR) STRING), where
> string is the diary entry for the given date.

I don't have this variable in my Emacsen. Once you type 'C-h v' on  
this variable name string a *Help* buffer should open that will show  
where this variable comes from. Now you can load that Elisp file  
before you make use of the variable ...

--
Greetings

   Pete

The light at the end of the tunnel has been turned off due to budget  
cuts.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: What's wrong with this elisp code?
       [not found] <mailman.4811.1154626598.9609.help-gnu-emacs@gnu.org>
@ 2006-08-04  3:31 ` Jeff Miller
       [not found]   ` <44D32639.80305@speakeasy.net>
  0 siblings, 1 reply; 10+ messages in thread
From: Jeff Miller @ 2006-08-04  3:31 UTC (permalink / raw)


ken <gebser@speakeasy.net> writes:

> But I'm getting the error:
> 
> Loading rng-auto.el (source)...
> Loading /usr/lib/emacs/21.3/i586-suse-linux/fns-21.3.1.el (source)...
> Preparing diary...
> Preparing diary...done
> Symbol's value as variable is void: diary-entries-list

I think this variable is only used inside of some let statements and
not available for general use.

If you use this in your emacs-diary-day.el, does it get you closer to
what you want?

(let* ((diary-display-hook 'fancy-diary-display)
       (diary-list-include-blanks t)
       (text (progn (list-diary-entries (calendar-current-date) 1)
		    (set-buffer fancy-diary-buffer)
		    (buffer-substring (point-min) (point-max)))))
  (find-file "emacs-diary-day")
  (erase-buffer)
  (insert text))
(save-buffer)

-- 
Jeff Miller
jmiller@cablespeed.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: What's wrong with this elisp code?
       [not found]           ` <44D327DF.6090500@speakeasy.net>
@ 2006-08-04 11:27             ` Peter Dyballa
  2006-08-04 19:39               ` ken
       [not found]               ` <mailman.4866.1154720372.9609.help-gnu-emacs@gnu.org>
       [not found]             ` <mailman.4842.1154691137.9609.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 10+ messages in thread
From: Peter Dyballa @ 2006-08-04 11:27 UTC (permalink / raw)



Am 04.08.2006 um 12:56 schrieb ken:

> This is the only instance of "(defvar diary-entries-list)" in the  
> entire
> subdirectory.  Could this variable be declared some other way, other
> than an explicit "defvar"?

No, there is without any clause a defvar instance in diary-lib.el.

>
> Another person who responded said he's thinking that this variable is
> only declared within functions, so not available for my use.

I can't tell. I do not programme so much in Elisp. Could be the  
author or the maintainer of calendar can help more. Have you read the  
*info* node on Calendar?

>
> In an earlier email you mentioned emacs find.  If that would help in
> this situation, could you point me to documentation of it.  I'd be  
> more
> than willing to give that a try.

The "grep-find" command (sorry that I did not give the right name  
before!) in GNU Emacs is a young feature. It it in CVS versions of  
GNU Emacs, could be in 21.4 also, but I do not have it. It does a  
"find . -type f" with a grep for some argument(s) in the found files,  
output is put into a buffer with hypertext features, i.e. clicking on  
the file names opens them in another buffer. I ran this command  
yesterday and found diary-entries-list in diary-lib.el. And this  
seems to be the origin.

--
Greetings

   Pete

Ce qui été compris n'existe plus.    (Paul Eluard)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: What's wrong with this elisp code?
  2006-08-04 11:27             ` Peter Dyballa
@ 2006-08-04 19:39               ` ken
  2006-08-04 20:04                 ` Peter Dyballa
       [not found]               ` <mailman.4866.1154720372.9609.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 10+ messages in thread
From: ken @ 2006-08-04 19:39 UTC (permalink / raw)


Peter Dyballa wrote:
> 
> Am 04.08.2006 um 12:56 schrieb ken:
> 
>> This is the only instance of "(defvar diary-entries-list)" in the entire
>> subdirectory.  Could this variable be declared some other way, other
>> than an explicit "defvar"?
> 
> No, there is without any clause a defvar instance in diary-lib.el.

I'm glad computers can do text searches.  Otherwise I'd be thinking
myself crazy.  After reading through diary-lib.el several times, I just
searched for "defvar diary-entries-list" and this computer agrees with
my eyes and brain-- it's not there.  I'm using emacs version 2.3.1.

Is there some other way that this variable could be defined other than
with defvar?


>> Another person who responded said he's thinking that this variable is
>> only declared within functions, so not available for my use.
> 
> I can't tell. I do not programme so much in Elisp. Could be the author
> or the maintainer of calendar can help more. Have you read the *info*
> node on Calendar?

Yes, though-- at least in the emacs section of info-- it's not at all
helpful here, focussing on *using* the diary/calendar functions already
available.


>> In an earlier email you mentioned emacs find.  If that would help in
>> this situation, could you point me to documentation of it.  I'd be more
>> than willing to give that a try.
> 
> The "grep-find" command (sorry that I did not give the right name
> before!) in GNU Emacs is a young feature. It it in CVS versions of GNU
> Emacs, could be in 21.4 also, but I do not have it. It does a "find .
> -type f" with a grep for some argument(s) in the found files, output is
> put into a buffer with hypertext features, i.e. clicking on the file
> names opens them in another buffer. I ran this command yesterday and
> found diary-entries-list in diary-lib.el. And this seems to be the origin.

Thanks for the clarification.  I'm already quite conversant with grep
and find and other tools available on Linux; plus, I already do so much
in emacs, typically having three or more frames and dozens of files open
simultaneously, that I'd rather perform those functions from the command
line rather than from within emacs.  So if there's no additional benefit
to using grep-find in emacs, it would be more efficient and comfortable
for me to work as I currently do.


Thanks much for your kindness,
ken


> 
> -- 
> Greetings
> 
>   Pete
> 
> Ce qui été compris n'existe plus.    (Paul Eluard)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: What's wrong with this elisp code?
       [not found]   ` <44D32639.80305@speakeasy.net>
@ 2006-08-04 19:53     ` Jeff Miller
  0 siblings, 0 replies; 10+ messages in thread
From: Jeff Miller @ 2006-08-04 19:53 UTC (permalink / raw)


ken writes:

 > > I think this variable is only used inside of some let statements and
 > > not available for general use.
 > 
 > My elisp skills are limited, but I'm tending to agree with you.  I
 > haven't found a specific "(defvar diary-entries-list)" in any of the
 > files related to the calendaring or diary functions.

I know I managed to use it in a lisp function once before.  I think I
had to use diary-hook to run the function though.  I'll have to look
at it closer later on.   I'm heading out tonight and will be away all
week. 

 > > If you use this in your emacs-diary-day.el, does it get you closer to
 > > what you want?
 > > 
 > > (let* ((diary-display-hook 'fancy-diary-display)
 > >        (diary-list-include-blanks t)
 > >        (text (progn (list-diary-entries (calendar-current-date) 1)
 > > 		    (set-buffer fancy-diary-buffer)
 > > 		    (buffer-substring (point-min) (point-max)))))
 > >   (find-file "emacs-diary-day")
 > >   (erase-buffer)
 > >   (insert text))
 > > (save-buffer)
 > > 
 > 
 > The error I'm getting with this is a little different:
 > 
 > Loading rng-auto.el (source)...
 > Loading /usr/lib/emacs/21.3/i586-suse-linux/fns-21.3.1.el (source)...
 > Symbol's function definition is void: list-diary-entries
 > 

Ah, I think it's missing diary-lib, try invoking it like this:

emacs -batch -l diary-lib -l /home/jmiller/local/lisp/emacs-diary-day.el 

Or add (require 'diary-lib) at the beginning of emacs-diary-day.el.

 > Thanks for the effort though,
 > ken

Jeff 

-- 
Jeff Miller
jmiller@cablespeed.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: What's wrong with this elisp code?
  2006-08-04 19:39               ` ken
@ 2006-08-04 20:04                 ` Peter Dyballa
  0 siblings, 0 replies; 10+ messages in thread
From: Peter Dyballa @ 2006-08-04 20:04 UTC (permalink / raw)
  Cc: GNU Emacs List


Am 04.08.2006 um 21:39 schrieb ken:

> I'm glad computers can do text searches.  Otherwise I'd be thinking
> myself crazy.  After reading through diary-lib.el several times, I  
> just
> searched for "defvar diary-entries-list" and this computer agrees with
> my eyes and brain-- it's not there.  I'm using emacs version 2.3.1.

Upgrade to GNU Emacs 22.0.50 from CVS (you probably mean that you  
have an elderly version 21.3.1, 21.4 is the recent one) and learn a  
bit about CVS, configuring, getting missing software, and making and  
installing free software!

>
> Is there some other way that this variable could be defined other than
> with defvar?

Defvar it in site-start.el! It'll be empty, but it'll be at least  
there! To be prepared for the future you might like to check first  
whether the variable is already defined. If not, create it!

There is, hopefully, a node about Emacs Lisp in *info* (if not, you  
can get it from GNU/FSF). There might be some pointers to answer your  
question.

--
Greetings

   Pete

"I wouldn't recommend sex, drugs or insanity for everyone, but  
they've always worked for me."
                                           -- Hunter S. Thompson

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: What's wrong with this elisp code?
       [not found]               ` <mailman.4866.1154720372.9609.help-gnu-emacs@gnu.org>
@ 2006-08-04 20:51                 ` Glenn Morris
  0 siblings, 0 replies; 10+ messages in thread
From: Glenn Morris @ 2006-08-04 20:51 UTC (permalink / raw)


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))))

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: What's wrong with this elisp code?
       [not found]             ` <mailman.4842.1154691137.9609.help-gnu-emacs@gnu.org>
@ 2006-08-04 22:23               ` Glenn Morris
  2006-08-05  0:06                 ` ken
  0 siblings, 1 reply; 10+ messages in thread
From: Glenn Morris @ 2006-08-04 22:23 UTC (permalink / raw)


Peter Dyballa wrote:

> No, there is without any clause a defvar instance in diary-lib.el.

Just for the sake of clarity, this form (only present in diary-lib in
CVS):

(defvar diary-entries-list)

only has the effect of suppressing a byte-compiler warning. It doesn't
actually define a value for diary-entries-list.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: What's wrong with this elisp code?
  2006-08-04 22:23               ` Glenn Morris
@ 2006-08-05  0:06                 ` ken
  0 siblings, 0 replies; 10+ messages in thread
From: ken @ 2006-08-05  0:06 UTC (permalink / raw)


Glenn Morris wrote:
> Peter Dyballa wrote:
> 
>> No, there is without any clause a defvar instance in diary-lib.el.
> 
> Just for the sake of clarity, this form (only present in diary-lib in
> CVS):
> 
> (defvar diary-entries-list)
> 
> only has the effect of suppressing a byte-compiler warning. It doesn't
> actually define a value for diary-entries-list.

Thanks, Glenn and everyone else who lent a hand, even the mean guy.

I'm bagging this project.  Elisp is just too much for me I guess.  I
thought this would be a couple hours' project.  Instead I've spent the
better part of two days on it.  On the other hand, I recently learned
and wrote a handy app in Tk/Tcl in a couple hours.  And I didn't have to
upgrade anything.  (It seems like eight out of ten times I try to write
something in elisp, I need to upgrade.)

I have to admire those of you who can write stuff in elisp.  I've
learned and wrote tons of code in a lot of different languages.  I guess
I should spend my time where I'm productive.

Thanks again,
ken

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2006-08-05  0:06 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-03 17:35 What's wrong with this elisp code? ken
2006-08-03 19:16 ` Peter Dyballa
     [not found]   ` <44D24F39.5080607@speakeasy.net>
     [not found]     ` <52A05EBB-9A5D-48C9-8A2A-553908FD097E@Web.DE>
     [not found]       ` <44D25BD4.7040006@speakeasy.net>
     [not found]         ` <C1580EEC-6A6C-4FE3-8295-070AC6D482AD@Web.DE>
     [not found]           ` <44D327DF.6090500@speakeasy.net>
2006-08-04 11:27             ` Peter Dyballa
2006-08-04 19:39               ` ken
2006-08-04 20:04                 ` Peter Dyballa
     [not found]               ` <mailman.4866.1154720372.9609.help-gnu-emacs@gnu.org>
2006-08-04 20:51                 ` Glenn Morris
     [not found]             ` <mailman.4842.1154691137.9609.help-gnu-emacs@gnu.org>
2006-08-04 22:23               ` Glenn Morris
2006-08-05  0:06                 ` ken
     [not found] <mailman.4811.1154626598.9609.help-gnu-emacs@gnu.org>
2006-08-04  3:31 ` Jeff Miller
     [not found]   ` <44D32639.80305@speakeasy.net>
2006-08-04 19:53     ` Jeff Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).