emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org google weather
@ 2011-03-03 21:37 Simon Brown
  2011-03-04  8:40 ` Ian Barton
  0 siblings, 1 reply; 30+ messages in thread
From: Simon Brown @ 2011-03-03 21:37 UTC (permalink / raw)
  To: Emacs Org Mode List

Evening all,

Has anybody tried adding the functionality of %%(diary-sunrise-sunset)
(sunrise, sunset time and daylight hours) to the google weather code?

Simon

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

* Re: org google weather
  2011-03-03 21:37 org google weather Simon Brown
@ 2011-03-04  8:40 ` Ian Barton
  2011-03-04  9:08   ` Sébastien Vauban
  2011-03-04 21:28   ` Simon Brown
  0 siblings, 2 replies; 30+ messages in thread
From: Ian Barton @ 2011-03-04  8:40 UTC (permalink / raw)
  To: emacs-orgmode

On 03/03/11 21:37, Simon Brown wrote:
> Evening all,
>
> Has anybody tried adding the functionality of %%(diary-sunrise-sunset)
> (sunrise, sunset time and daylight hours) to the google weather code?
>
> Simon
>
I just have something like:

#+CATEGORY: Day/Year
&%%(diary-day-of-year)
#+CATEGORY: Sunrise
&%%(diary-sunrise-sunset)

in one of my Agenda files. Sunrise then appears at sunrise time in my 
Agenda like:

   Sunrise:     6:53...... Sunrise (GMT), sunset 5:52pm (GMT) at 
Wilkesley (10:58 hours daylight)

You need to have some magic fu like:

#+BEGIN_SRC emacs-lisp
   (setq calendar-latitude 53)
   (setq calendar-longitude -2.6)
   (setq calendar-location-name "Wilkesley")
#+END_SRC

in your .emacs so Emacs knows where you are.

Ian.

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

* Re: org google weather
  2011-03-04  8:40 ` Ian Barton
@ 2011-03-04  9:08   ` Sébastien Vauban
  2011-03-04 11:27     ` Ian Barton
  2011-03-04 21:28   ` Simon Brown
  1 sibling, 1 reply; 30+ messages in thread
From: Sébastien Vauban @ 2011-03-04  9:08 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Ian,

Ian Barton wrote:
>> Has anybody tried adding the functionality of %%(diary-sunrise-sunset)
>> (sunrise, sunset time and daylight hours) to the google weather code?
>
> I just have something like:
>
> #+CATEGORY: Day/Year
> &%%(diary-day-of-year)
> #+CATEGORY: Sunrise
> &%%(diary-sunrise-sunset)
>
> in one of my Agenda files. Sunrise then appears at sunrise time in my Agenda
> like:
>
>    Sunrise:     6:53...... Sunrise (GMT), sunset 5:52pm (GMT) at 
> Wilkesley (10:58 hours daylight)

Do you have a way to get the sunset located on a line on its own (different
line from the sunrise one)?  That'd be even much nicer...

Best regards,
  Seb

-- 
Sébastien Vauban

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

* Re: org google weather
  2011-03-04  9:08   ` Sébastien Vauban
@ 2011-03-04 11:27     ` Ian Barton
  2011-03-04 15:29       ` brian powell
  2011-03-04 16:38       ` Nick Dokos
  0 siblings, 2 replies; 30+ messages in thread
From: Ian Barton @ 2011-03-04 11:27 UTC (permalink / raw)
  To: emacs-orgmode


> Hi Ian,
>
> Ian Barton wrote:
>>> Has anybody tried adding the functionality of %%(diary-sunrise-sunset)
>>> (sunrise, sunset time and daylight hours) to the google weather code?
>>
>> I just have something like:
>>
>> #+CATEGORY: Day/Year
>> &%%(diary-day-of-year)
>> #+CATEGORY: Sunrise
>> &%%(diary-sunrise-sunset)
>>
>> in one of my Agenda files. Sunrise then appears at sunrise time in my Agenda
>> like:
>>
>>     Sunrise:     6:53...... Sunrise (GMT), sunset 5:52pm (GMT) at
>> Wilkesley (10:58 hours daylight)
>
> Do you have a way to get the sunset located on a line on its own (different
> line from the sunrise one)?  That'd be even much nicer...
>
No, but I would like one:) If there were separate diary functions for 
sunrise and sunset it would be easy. Maybe I need to look at the diary 
elisp and write my own separate functions.

Ian.

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

* Re: org google weather
  2011-03-04 11:27     ` Ian Barton
@ 2011-03-04 15:29       ` brian powell
  2011-03-04 16:38       ` Nick Dokos
  1 sibling, 0 replies; 30+ messages in thread
From: brian powell @ 2011-03-04 15:29 UTC (permalink / raw)
  To: lists; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 2239 bytes --]

FWIW/YMMV I use RUBY: I like the "twilight" info too--not sure emacs does
twilight info too--maybe you can reuse some of the code and put into
OrgMode: I do:

emacs -l .bja-sunrise-sunset-twilight.el

--where .bja-sunrise-sunset-twilight.el is:

(defun bja-sunrise ()
  "Display sunrise, sunset & twilight information."
  (interactive)
  (shell-command "~/sunrise_http_post.rb"))

--excerption of sunrise_http_post.rb (available somewhere on the web)
...
require 'net/http'

YOUR_ID = 'BGPOWELL' # A unique ID per comment above
YOUR_CITY = 'Fairfax' # The name of your city
YOUR_STATE = 'VA' # Two letter state abbreviation

now = Time.now
month = now.month
day = now.day + 1 # Tomorrow
year = now.year

Net::HTTP.start('aa.usno.navy.mil') do |query|
  response = query.post('/cgi-bin/aa_pap.pl',
"FFX=1&ID=#{YOUR_ID}&xxy=#{year}&xxm=#{month}&xxd=#{day}&st=#{YOUR_STATE}&place=#{YOUR_CITY}&ZZZ=END")
  if response.body =~ /Begin civil twilight[^0-9]*(\d+:\d{2}
[ap].m.).*Sunrise[^0-9]*(\d+:\d{2} [ap].m.).*Sunset[^0-9]*(\d+:\d{2}
[ap].m.).*End civil twilight[^0-9]*(\d+:\d{2} [ap].m.)/m
    puts "#{month}/#{day}/#{year}"
    puts "Begin Twilight: #{$1}"
    puts "Sunrise : #{$2}"
    puts "Sunset : #{$3}"
    puts "End Twilight : #{$4}"
  end
end



On Fri, Mar 4, 2011 at 6:27 AM, Ian Barton <lists@manor-farm.org> wrote:

>
>  Hi Ian,
>>
>> Ian Barton wrote:
>>
>>> Has anybody tried adding the functionality of %%(diary-sunrise-sunset)
>>>> (sunrise, sunset time and daylight hours) to the google weather code?
>>>>
>>>
>>> I just have something like:
>>>
>>> #+CATEGORY: Day/Year
>>> &%%(diary-day-of-year)
>>> #+CATEGORY: Sunrise
>>> &%%(diary-sunrise-sunset)
>>>
>>> in one of my Agenda files. Sunrise then appears at sunrise time in my
>>> Agenda
>>> like:
>>>
>>>    Sunrise:     6:53...... Sunrise (GMT), sunset 5:52pm (GMT) at
>>> Wilkesley (10:58 hours daylight)
>>>
>>
>> Do you have a way to get the sunset located on a line on its own
>> (different
>> line from the sunrise one)?  That'd be even much nicer...
>>
>>  No, but I would like one:) If there were separate diary functions for
> sunrise and sunset it would be easy. Maybe I need to look at the diary elisp
> and write my own separate functions.
>
> Ian.
>
>

[-- Attachment #2: Type: text/html, Size: 3601 bytes --]

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

* Re: org google weather
  2011-03-04 11:27     ` Ian Barton
  2011-03-04 15:29       ` brian powell
@ 2011-03-04 16:38       ` Nick Dokos
  2011-03-04 19:28         ` Bastien
                           ` (2 more replies)
  1 sibling, 3 replies; 30+ messages in thread
From: Nick Dokos @ 2011-03-04 16:38 UTC (permalink / raw)
  To: lists; +Cc: nicholas.dokos, emacs-orgmode

Ian Barton <lists@manor-farm.org> wrote:

> 
> > Hi Ian,
> >
> > Ian Barton wrote:
> >>> Has anybody tried adding the functionality of %%(diary-sunrise-sunset)
> >>> (sunrise, sunset time and daylight hours) to the google weather code?
> >>
> >> I just have something like:
> >>
> >> #+CATEGORY: Day/Year
> >> &%%(diary-day-of-year)
> >> #+CATEGORY: Sunrise
> >> &%%(diary-sunrise-sunset)
> >>
> >> in one of my Agenda files. Sunrise then appears at sunrise time in my Agenda
> >> like:
> >>
> >>     Sunrise:     6:53...... Sunrise (GMT), sunset 5:52pm (GMT) at
> >> Wilkesley (10:58 hours daylight)
> >
> > Do you have a way to get the sunset located on a line on its own (different
> > line from the sunrise one)?  That'd be even much nicer...
> >
> No, but I would like one:) If there were separate diary functions for
> sunrise and sunset it would be easy. Maybe I need to look at the diary
> elisp and write my own separate functions.
> 

Quick hack just parsing the output of diary-sunrise-sunset.

I added this early in my org-config file (which is sourced by .emacs)
- modify latitude, longitude to taste:

--8<---------------cut here---------------start------------->8---
;;; diary supplement - rich in Ca
(setq calendar-latitude 42.3)
(setq calendar-longitude -71.0)
(defun diary-sunrise ()
  (let ((dss (diary-sunrise-sunset)))
    (with-temp-buffer
      (insert dss)
      (goto-char (point-min))
      (search-forward ",")
      (buffer-substring (point-min) (match-beginning 0)))))

(defun diary-sunset ()
  (let ((dss (diary-sunrise-sunset))
        start end)
    (with-temp-buffer
      (insert dss)
      (goto-char (point-min))
      (search-forward ", ")
      (setq start (match-end 0))
      (search-forward " at")
      (setq end (match-beginning 0))
      (goto-char start)
      (capitalize-word 1)
      (buffer-substring start end))))
--8<---------------cut here---------------end--------------->8---

and this to one of my agenda files:

--8<---------------cut here---------------start------------->8---
#+CATEGORY: Weather
%%(diary-sunrise)
%%(diary-sunset)
--8<---------------cut here---------------end--------------->8---

and I get:

,----
| Friday      4 March 2011
|   Weather:     6:16...... Sunrise (EST)
|                8:00...... ----------------
|               10:00...... ----------------
|               12:00...... ----------------
|               14:00...... ----------------
|               16:00...... ----------------
|   Weather:    17:36...... Sunset (EST)
|               18:00...... ----------------
|               20:00...... ----------------
`----

Nick

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

* Re: org google weather
  2011-03-04 16:38       ` Nick Dokos
@ 2011-03-04 19:28         ` Bastien
  2011-03-04 19:42         ` Konrad Hinsen
  2011-03-04 23:03         ` Sébastien Vauban
  2 siblings, 0 replies; 30+ messages in thread
From: Bastien @ 2011-03-04 19:28 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: emacs-orgmode

Hi Nick,

Nick Dokos <nicholas.dokos@hp.com> writes:

> Quick hack just parsing the output of diary-sunrise-sunset.

Nice one -- a good candidate for Worg/org-hacks.org ;)

-- 
 Bastien

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

* Re: org google weather
  2011-03-04 16:38       ` Nick Dokos
  2011-03-04 19:28         ` Bastien
@ 2011-03-04 19:42         ` Konrad Hinsen
  2011-03-04 20:26           ` Nick Dokos
  2011-03-04 23:03         ` Sébastien Vauban
  2 siblings, 1 reply; 30+ messages in thread
From: Konrad Hinsen @ 2011-03-04 19:42 UTC (permalink / raw)
  To: nicholas.dokos, Org Mode Mailing List

On 4 Mar 2011, at 17:38, Nick Dokos wrote:

> Quick hack just parsing the output of diary-sunrise-sunset.
...

Nice!

Is there a way to get this inserted only into the day view, but not  
into the week view? In fact, I would like to have that choice for  
agenda items in general. It makes sense (to me at least) to have more  
information in the day view than in the week view.

Konrad.

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

* Re: org google weather
  2011-03-04 19:42         ` Konrad Hinsen
@ 2011-03-04 20:26           ` Nick Dokos
  2011-03-05 10:19             ` Bastien
  0 siblings, 1 reply; 30+ messages in thread
From: Nick Dokos @ 2011-03-04 20:26 UTC (permalink / raw)
  To: Konrad Hinsen; +Cc: nicholas.dokos, Org Mode Mailing List

Konrad Hinsen <konrad.hinsen@fastmail.net> wrote:


> Is there a way to get this inserted only into the day view, but not
> into the week view? In fact, I would like to have that choice for
> agenda items in general. It makes sense (to me at least) to have more
> information in the day view than in the week view.
> 

Not that I know of, which means one of two things: it's there but I
don't know about it (something that has happened many times in the past
with org) or it's not there and Carsten will have it implemented by
tomorrow morning :-)

Nick

PS. FWIW, I'd like that feature too...

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

* Re: org google weather
  2011-03-04  8:40 ` Ian Barton
  2011-03-04  9:08   ` Sébastien Vauban
@ 2011-03-04 21:28   ` Simon Brown
  2011-03-04 22:05     ` Nick Dokos
  1 sibling, 1 reply; 30+ messages in thread
From: Simon Brown @ 2011-03-04 21:28 UTC (permalink / raw)
  To: lists; +Cc: emacs-orgmode

At Fri, 04 Mar 2011 08:40:23 +0000,
Ian Barton wrote:
> On 03/03/11 21:37, Simon Brown wrote:
> > Has anybody tried adding the functionality of %%(diary-sunrise-sunset)
> > (sunrise, sunset time and daylight hours) to the google weather code?
> I just have something like:
> 
> #+CATEGORY: Day/Year
> &%%(diary-day-of-year)
> #+CATEGORY: Sunrise
> &%%(diary-sunrise-sunset)

That's where I am at the moment, with the weather forecast, sunrise
and sunset times on different lines. I was wondering if the two could
be integrated to make a one line weather forecast, sunrise and sunset
times. ?

eg.
Location: (icon) Chance of Rain, [-1,6] ℃, Sunrise 0658 Sunset 1759 1101 hrs of daylight

Simon

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

* Re: org google weather
  2011-03-04 21:28   ` Simon Brown
@ 2011-03-04 22:05     ` Nick Dokos
  2011-03-04 22:29       ` Nick Dokos
  2011-03-04 22:43       ` Simon Brown
  0 siblings, 2 replies; 30+ messages in thread
From: Nick Dokos @ 2011-03-04 22:05 UTC (permalink / raw)
  To: Simon Brown; +Cc: nicholas.dokos, emacs-orgmode

Simon Brown <lists@700c.org> wrote:

> At Fri, 04 Mar 2011 08:40:23 +0000,
> Ian Barton wrote:
> > On 03/03/11 21:37, Simon Brown wrote:
> > > Has anybody tried adding the functionality of %%(diary-sunrise-sunset)
> > > (sunrise, sunset time and daylight hours) to the google weather code?
> > I just have something like:
> > 
> > #+CATEGORY: Day/Year
> > &%%(diary-day-of-year)
> > #+CATEGORY: Sunrise
> > &%%(diary-sunrise-sunset)
> 
> That's where I am at the moment, with the weather forecast, sunrise
> and sunset times on different lines. I was wondering if the two could
> be integrated to make a one line weather forecast, sunrise and sunset
> times. ?
> 
> eg.
> Location: (icon) Chance of Rain, [-1,6] ℃, Sunrise 0658 Sunset 1759 1101 hrs of daylight
> 

Just write your own function to take the individual results and concatenate them, e.g.

--8<---------------cut here---------------start------------->8---
(defun full-catastrophe ()
  (format "%s :: %s" (org-google-weather) (diary-sunrise-sunset)))
--8<---------------cut here---------------end--------------->8---

and add 

--8<---------------cut here---------------start------------->8---
%%(full-catastrophe)
--8<---------------cut here---------------end--------------->8---

to some agenda file.

Nick

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

* Re: org google weather
  2011-03-04 22:05     ` Nick Dokos
@ 2011-03-04 22:29       ` Nick Dokos
  2011-03-04 22:43       ` Simon Brown
  1 sibling, 0 replies; 30+ messages in thread
From: Nick Dokos @ 2011-03-04 22:29 UTC (permalink / raw)
  Cc: Simon Brown, nicholas.dokos, emacs-orgmode

Nick Dokos <nicholas.dokos@hp.com> wrote:

> 
> Just write your own function to take the individual results and concatenate=
>  them, e.g.
> 
> (defun full-catastrophe ()
>   (format "%s :: %s" (org-google-weather) (diary-sunrise-sunset)))
> 
> and add
> 
> %%(full-catastrophe)
> 
> to some agenda file.
> 

BTW, I noticed that semicolons followed by spaces cause trouble:

--8<---------------cut here---------------start------------->8---
(defun full-catastrophe ()
  (format "a; b"))
--8<---------------cut here---------------end--------------->8---

puts "a" on one agenda line and "b" in another. It does not happen
if there is no space after the semicolon. And in case you are wondering,
I saw it when trying Ian's (diary-day-of-year) example, which includes "; " in
its output.

Nick

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

* Re: org google weather
  2011-03-04 22:05     ` Nick Dokos
  2011-03-04 22:29       ` Nick Dokos
@ 2011-03-04 22:43       ` Simon Brown
  1 sibling, 0 replies; 30+ messages in thread
From: Simon Brown @ 2011-03-04 22:43 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: emacs-orgmode

At Fri, 04 Mar 2011 17:05:55 -0500,
Nick Dokos wrote:
> Simon Brown <lists@700c.org> wrote:
> > At Fri, 04 Mar 2011 08:40:23 +0000,
> > Ian Barton wrote:
> > > On 03/03/11 21:37, Simon Brown wrote:
> > > > Has anybody tried adding the functionality of %%(diary-sunrise-sunset)
> > > > (sunrise, sunset time and daylight hours) to the google weather code?
> > > I just have something like:
> > > 
> > > #+CATEGORY: Day/Year
> > > &%%(diary-day-of-year)
> > > #+CATEGORY: Sunrise
> > > &%%(diary-sunrise-sunset)
> > 
> > That's where I am at the moment, with the weather forecast, sunrise
> > and sunset times on different lines. I was wondering if the two could
> > be integrated to make a one line weather forecast, sunrise and sunset
> > times. ?
> > 
> > eg.
> > Location: (icon) Chance of Rain, [-1,6] ℃, Sunrise 0658 Sunset 1759 1101 hrs of daylight
> > 
> 
> Just write your own function to take the individual results and concatenate them, e.g.
> 
> --8<---------------cut here---------------start------------->8---
> (defun full-catastrophe ()
>   (format "%s :: %s" (org-google-weather) (diary-sunrise-sunset)))
> --8<---------------cut here---------------end--------------->8---
> 
> and add 
> 
> --8<---------------cut here---------------start------------->8---
> %%(full-catastrophe)
> --8<---------------cut here---------------end--------------->8---

Excellent, I like your style :-)

Simon

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

* Re: org google weather
  2011-03-04 16:38       ` Nick Dokos
  2011-03-04 19:28         ` Bastien
  2011-03-04 19:42         ` Konrad Hinsen
@ 2011-03-04 23:03         ` Sébastien Vauban
  2011-03-04 23:25           ` Nick Dokos
  2 siblings, 1 reply; 30+ messages in thread
From: Sébastien Vauban @ 2011-03-04 23:03 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Nick,

Nick Dokos wrote:
> Ian Barton <lists-Y4y6QUDF+ubzvewUbhsq6Q@public.gmane.org> wrote:
>> > Ian Barton wrote:
>> >>> Has anybody tried adding the functionality of %%(diary-sunrise-sunset)
>> >>> (sunrise, sunset time and daylight hours) to the google weather code?
>> >>
>> >> I just have something like:
>> >>
>> >> #+CATEGORY: Day/Year
>> >> &%%(diary-day-of-year)
>> >> #+CATEGORY: Sunrise
>> >> &%%(diary-sunrise-sunset)
>> >>
>> >> in one of my Agenda files. Sunrise then appears at sunrise time in my
>> >> Agenda like:
>> >>
>> >>     Sunrise:     6:53...... Sunrise (GMT), sunset 5:52pm (GMT) at
>> >> Wilkesley (10:58 hours daylight)
>> >
>> > Do you have a way to get the sunset located on a line on its own
>> > (different line from the sunrise one)? That'd be even much nicer...
>>
>> No, but I would like one:) If there were separate diary functions for
>> sunrise and sunset it would be easy. Maybe I need to look at the diary
>> elisp and write my own separate functions.
>
> Quick hack just parsing the output of diary-sunrise-sunset.

Excellent hack, for at least 2 reasons: the feature itself, and showing us the
way how to enhance the agenda... Thanks a lot.

> I added this early in my org-config file (which is sourced by .emacs)
> [...] and this to one of my agenda files:
>
> #+CATEGORY: Weather
> %%(diary-sunrise)
> %%(diary-sunset)
>
> and I get:
>
> ,----
> | Friday      4 March 2011
> |   Weather:     6:16...... Sunrise (EST)
> |                8:00...... ----------------
> |               10:00...... ----------------
> |               12:00...... ----------------
> |               14:00...... ----------------
> |               16:00...... ----------------
> |   Weather:    17:36...... Sunset (EST)
> |               18:00...... ----------------
> |               20:00...... ----------------
> `----

Because of this:

#+begin_src emacs-lisp
    (setq org-agenda-default-appointment-duration 60)
#+end_src

I get:

    ,----
    | 2011-03-05 Sat
    |                0:01-1:01  now ____
    |   Weather:     7:18-8:18  Sunrise (+0100)
    |                8:00-9:00  ________
    |               10:00-11:00 ________
    |               12:00-13:00 ________
    |               14:00-15:00 ________
    |               16:00-17:00 ________
    |               18:00-19:00 ________
    |   Weather:    18:24-19:24 Sunset (+0100)
    `----

i.e, a not-that-clear indication of when the sunrise/sunset is supposed to
happen.

In this case, it's clearly a one-minute event. Is there, then, a way to avoid
the "+ 1 hour" range computation for it, while keeping the above variable for
other common tasks?

Best regards,
  Seb

-- 
Sébastien Vauban

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

* Re: org google weather
  2011-03-04 23:03         ` Sébastien Vauban
@ 2011-03-04 23:25           ` Nick Dokos
  0 siblings, 0 replies; 30+ messages in thread
From: Nick Dokos @ 2011-03-04 23:25 UTC (permalink / raw)
  To: =?utf-8?Q?S=C3=A9bastien_Vauban?=; +Cc: nicholas.dokos, emacs-orgmode

Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> wrote:


> Because of this:
> 
> #+begin_src emacs-lisp
>     (setq org-agenda-default-appointment-duration 60)
> #+end_src
> 
> I get:
> 
>     ,----
>     | 2011-03-05 Sat
>     |                0:01-1:01  now ____
>     |   Weather:     7:18-8:18  Sunrise (+0100)
>     |                8:00-9:00  ________
>     |               10:00-11:00 ________
>     |               12:00-13:00 ________
>     |               14:00-15:00 ________
>     |               16:00-17:00 ________
>     |               18:00-19:00 ________
>     |   Weather:    18:24-19:24 Sunset (+0100)
>     `----
> 
> i.e, a not-that-clear indication of when the sunrise/sunset is supposed to
> happen.
> 
> In this case, it's clearly a one-minute event. Is there, then, a way to avoid
> the "+ 1 hour" range computation for it, while keeping the above variable for
> other common tasks?
> 

Not that I know of, but maybe a generalization of the feature that
Konrad was looking for might be what's needed: give properties to agenda
entry generators, so e.g. they cause the agenda entry to be only
displayed today, or to be of a given duration (0 in this case, 10 mins
in some other case, 1 hour by default), etc.  The difficult thing is to
make it general enough, concise enough and undestandable enough for mere
mortals to have a chance.

Nick

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

* Re: org google weather
  2011-03-04 20:26           ` Nick Dokos
@ 2011-03-05 10:19             ` Bastien
  2011-03-05 11:44               ` Matthew Sauer
  2011-03-05 14:29               ` Konrad Hinsen
  0 siblings, 2 replies; 30+ messages in thread
From: Bastien @ 2011-03-05 10:19 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: Konrad Hinsen, Org Mode Mailing List

Hi Nick,

Nick Dokos <nicholas.dokos@hp.com> writes:

> Konrad Hinsen <konrad.hinsen@fastmail.net> wrote:
>
>> Is there a way to get this inserted only into the day view, but not
>> into the week view? In fact, I would like to have that choice for
>> agenda items in general. It makes sense (to me at least) to have more
>> information in the day view than in the week view.
>
> Not that I know of, which means one of two things: it's there but I
> don't know about it (something that has happened many times in the past
> with org) or it's not there and Carsten will have it implemented by
> tomorrow morning :-)

A clever combination of org-agenda-span and org-agenda-skip-function
(checking against this span) in a custom agenda command should do.

HTH,

-- 
 Bastien

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

* Re: org google weather
  2011-03-05 10:19             ` Bastien
@ 2011-03-05 11:44               ` Matthew Sauer
  2011-03-05 13:26                 ` Konrad Hinsen
  2011-03-05 14:29               ` Konrad Hinsen
  1 sibling, 1 reply; 30+ messages in thread
From: Matthew Sauer @ 2011-03-05 11:44 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 919 bytes --]

I put the diary-sunset and diary-sunrise functions in a file called
sunrisesunset.el in my elisp directory, it is part of my load path and put
'(require 'sunrisesunset)
in my .emacs
It only loads if I type
M-x load-library   RET   sunrisesunset RET
I am not sure why it isn't automatically loading like other files I have set
the same way, the same holds true for org-google-weather, I ran the git,
have it in my home directory and have it set up for require in my dotemacs
but i still have to
M-x load-library RET org-google-weather RET
to get it to work in my agenda.

I am running on cygwin with emacs 23.2 and with Org 7.4 (updated to make
sure), I ended up putting the diary-sunrise and diary-sunset functions in my
dot emacs and they work just fine but putting the contents of different .el
files in my dotemacs file isn't a good long term solution.  Any suggestions
as to what I might look at or for?

Matthew S

[-- Attachment #2: Type: text/html, Size: 1226 bytes --]

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

* Re: org google weather
  2011-03-05 11:44               ` Matthew Sauer
@ 2011-03-05 13:26                 ` Konrad Hinsen
  2011-03-05 14:57                   ` Matthew Sauer
  0 siblings, 1 reply; 30+ messages in thread
From: Konrad Hinsen @ 2011-03-05 13:26 UTC (permalink / raw)
  To: Matthew Sauer, Org Mode Mailing List

On 5 Mar 2011, at 12:44, Matthew Sauer wrote:

>
> I put the diary-sunset and diary-sunrise functions in a file called  
> sunrisesunset.el in my elisp directory, it is part of my load path  
> and put
> '(require 'sunrisesunset)
> in my .emacs

Did you put a

	(provide 'sunrisesunset)

at the end of sunrisesunset.el? That's what tells Emacs that the  
requirement is now fulfilled.

Konrad.

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

* Re: org google weather
  2011-03-05 10:19             ` Bastien
  2011-03-05 11:44               ` Matthew Sauer
@ 2011-03-05 14:29               ` Konrad Hinsen
  2011-03-05 17:07                 ` Bastien
  1 sibling, 1 reply; 30+ messages in thread
From: Konrad Hinsen @ 2011-03-05 14:29 UTC (permalink / raw)
  To: Bastien; +Cc: nicholas.dokos, Org Mode Mailing List

On 5 Mar 2011, at 11:19, Bastien wrote:

>>> Is there a way to get this inserted only into the day view, but not
>>> into the week view? In fact, I would like to have that choice for
>>> agenda items in general. It makes sense (to me at least) to have  
>>> more
>>> information in the day view than in the week view.
>>
>> Not that I know of, which means one of two things: it's there but I
>> don't know about it (something that has happened many times in the  
>> past
>> with org) or it's not there and Carsten will have it implemented by
>> tomorrow morning :-)
>
> A clever combination of org-agenda-span and org-agenda-skip-function
> (checking against this span) in a custom agenda command should do.

That sounds like a good plan. A property could be used to limit  
visibility to day or week views, and the skip-function would check for  
that property.

Konrad.

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

* Re: org google weather
  2011-03-05 13:26                 ` Konrad Hinsen
@ 2011-03-05 14:57                   ` Matthew Sauer
  2011-03-05 15:15                     ` Michael Markert
  2011-03-05 15:23                     ` Nick Dokos
  0 siblings, 2 replies; 30+ messages in thread
From: Matthew Sauer @ 2011-03-05 14:57 UTC (permalink / raw)
  To: Konrad Hinsen, Bastien; +Cc: Org Mode Mailing List

[-- Attachment #1: Type: text/plain, Size: 1667 bytes --]

Konrad,

Being an elisp noob I had forgotten about the provide code in the .el file.
That fixed that problem, THANK YOU so much.   Now if I can figure out why I
have to
M-x load-library RET google-weather RET
M-x load-library RET org-google-weather RET
to get google weather to work with my agenda (though I am debating on
leaving it this way and having a function load these two files as I am not
always internet connected and it is annoying to wait for the network
connection attempt to timeout 4 times for each day it attempts to retrieve
the weather or maybe I should look and see if I can patch it to make it skip
the other attempts if the first fails? but then I need to figure out how to
get them to load automatically).  I should just need to use the code in my
dot emacs
'(require 'google-weather)
'(require 'org-google-weather)
for it to work but that doesn't seem to do the trick, maybe i need to look
in the code in those .el files.

Bastien,
to your question, I am trying to set some functions in other .el files so
that I can break up differnt parts of code for the different parts of my
.emacs file intsead of just adding more and more code.

Matthew

On Sat, Mar 5, 2011 at 7:26 AM, Konrad Hinsen <konrad.hinsen@fastmail.net>wrote:

> On 5 Mar 2011, at 12:44, Matthew Sauer wrote:
>
>
>> I put the diary-sunset and diary-sunrise functions in a file called
>> sunrisesunset.el in my elisp directory, it is part of my load path and put
>> '(require 'sunrisesunset)
>> in my .emacs
>>
>
> Did you put a
>
>        (provide 'sunrisesunset)
>
> at the end of sunrisesunset.el? That's what tells Emacs that the
> requirement is now fulfilled.
>
> Konrad.
>

[-- Attachment #2: Type: text/html, Size: 2326 bytes --]

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

* Re: org google weather
  2011-03-05 14:57                   ` Matthew Sauer
@ 2011-03-05 15:15                     ` Michael Markert
  2011-03-05 15:23                     ` Nick Dokos
  1 sibling, 0 replies; 30+ messages in thread
From: Michael Markert @ 2011-03-05 15:15 UTC (permalink / raw)
  To: Matthew Sauer; +Cc: emacs-orgmode

On 5 Mar 2011, Matthew Sauer wrote:
> I should just need to use the code in my dot emacs
> '(require 'google-weather)
> '(require 'org-google-weather)
> for it to work but that doesn't seem to do the trick, maybe i need to
> look in the code in those .el files.

You should omit the leading '. With it the lines are equivalent to

(list 'require 'google-weather)
(list 'require 'org-google-weather)

Michael

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

* Re: org google weather
  2011-03-05 14:57                   ` Matthew Sauer
  2011-03-05 15:15                     ` Michael Markert
@ 2011-03-05 15:23                     ` Nick Dokos
  2011-03-05 17:46                       ` Matthew Sauer
  1 sibling, 1 reply; 30+ messages in thread
From: Nick Dokos @ 2011-03-05 15:23 UTC (permalink / raw)
  To: Matthew Sauer
  Cc: Bastien, Konrad Hinsen, nicholas.dokos, Org Mode Mailing List

Matthew Sauer <improv.philosophy@gmail.com> wrote:

> '(require 'google-weather)
> '(require 'org-google-weather)

That should be

(require 'google-weather)
(require 'org-google-weather)

without a quote.

Nick

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

* Re: org google weather
  2011-03-05 14:29               ` Konrad Hinsen
@ 2011-03-05 17:07                 ` Bastien
  2011-03-05 20:35                   ` Konrad Hinsen
  0 siblings, 1 reply; 30+ messages in thread
From: Bastien @ 2011-03-05 17:07 UTC (permalink / raw)
  To: Konrad Hinsen; +Cc: nicholas.dokos, Org Mode Mailing List

Hi Konrad,

Konrad Hinsen <konrad.hinsen@fastmail.net> writes:

>> A clever combination of org-agenda-span and org-agenda-skip-function
>> (checking against this span) in a custom agenda command should do.
>
> That sounds like a good plan. A property could be used to limit visibility
> to day or week views, and the skip-function would check for that property.

Sorry, not sure I was clear enough: my point was that you can *already*
select tasks you want to appear on the dayly agenda view and not on the
weekly agenda view. 

It's just a matter of writing an org-agenda-skip-function that react
differently depending on org-agenda-span.

I leave the homework to someone else :)

-- 
 Bastien

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

* Re: org google weather
  2011-03-05 15:23                     ` Nick Dokos
@ 2011-03-05 17:46                       ` Matthew Sauer
  2011-03-05 19:57                         ` Nick Dokos
  0 siblings, 1 reply; 30+ messages in thread
From: Matthew Sauer @ 2011-03-05 17:46 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: Bastien, Konrad Hinsen, Org Mode Mailing List

[-- Attachment #1: Type: text/plain, Size: 550 bytes --]

Thanks that worked, as I said Noob, somethings get the quote and some
don't.  Now if I can just get org-contacts to load correctly, void variable
value, life will be great.  I think I am starting to get the hang of this
language.
Matthew

On Sat, Mar 5, 2011 at 9:23 AM, Nick Dokos <nicholas.dokos@hp.com> wrote:

> Matthew Sauer <improv.philosophy@gmail.com> wrote:
>
> > '(require 'google-weather)
> > '(require 'org-google-weather)
>
> That should be
>
> (require 'google-weather)
> (require 'org-google-weather)
>
> without a quote.
>
> Nick
>
>

[-- Attachment #2: Type: text/html, Size: 1009 bytes --]

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

* Re: org google weather
  2011-03-05 17:46                       ` Matthew Sauer
@ 2011-03-05 19:57                         ` Nick Dokos
  0 siblings, 0 replies; 30+ messages in thread
From: Nick Dokos @ 2011-03-05 19:57 UTC (permalink / raw)
  To: Matthew Sauer
  Cc: Bastien, Konrad Hinsen, nicholas.dokos, Org Mode Mailing List

Matthew Sauer <improv.philosophy@gmail.com> wrote:

> Thanks that worked, as I said Noob, somethings get the quote and some don't.  Now if I can just get
> org-contacts to load correctly, void variable value, life will be great.  I think I am starting to
> get the hang of this language.
> Matthew
> 

The main thing to remember is that quote inhibits evaluation: 'a gives
you the symbol a whereas a without the quote gives you the *value* of
a. Remember also that in lisp, you call a function func with arguments x
and y like this: (func x y) - this calls the function func on the
*values* of x and y and returns a function value (which of course
depends on how the function is defined). OTOH, '(func x y) is a list of
three elements: func, x and y. So

'(require 'google-weather)

does nothing whereas

(require 'google-weather) 

calls the function require with the symbol google-weather as its argument.

OTOH, the incorrect

(require google-weather)

would call the same function with the *value* of the symbol google-weather
as its argument. Since the symbol has no value, you'd get an error.
Hope this makes things a bit clearer, but there is nothing like getting an
elementary book on Lisp (or the Emacs Lisp introductory tutorial which
should be available in your emacs or online).

As for org-contacts, I just did a git pull (from
git://git.naquadah.org/org-contacts.git) and I was able to load it with
no problems. Also I don't see a variable named "value" in the file, so
either your report of the error is inaccurate or your version is
older. Try the latest version and if you still have problems, checkout
out section 1.4, "Feedback", of the Org manual to find out how to
produce a useful backtrace - then post that to the list.

Nick

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

* Re: org google weather
  2011-03-05 17:07                 ` Bastien
@ 2011-03-05 20:35                   ` Konrad Hinsen
  2011-03-05 21:19                     ` brian powell
  2011-03-05 23:51                     ` Nick Dokos
  0 siblings, 2 replies; 30+ messages in thread
From: Konrad Hinsen @ 2011-03-05 20:35 UTC (permalink / raw)
  To: Bastien; +Cc: nicholas.dokos, Org Mode Mailing List

Hi Bastien,

On 5 Mar 2011, at 18:07, Bastien wrote:

> Sorry, not sure I was clear enough: my point was that you can  
> *already*
> select tasks you want to appear on the dayly agenda view and not on  
> the
> weekly agenda view.
>
> It's just a matter of writing an org-agenda-skip-function that react
> differently depending on org-agenda-span.

Right, you "just" need to write a function ;-)

I guess I wasn't clear enough either, because that's what my proposal  
is about as well. My idea is

1) Use some property (or tag) to mark events in an org-file as "day  
view only".
2) Write an org-agenda-skip-function that checks for that property/tag  
AND checks the value of org-agenda-span.

What keeps me from writing that function right now is that I don't  
know the internals of org-mode well enough to know how to check for a  
propery or tag. I expect to spend an hour reading source code, and  
that's for another day :-)

Konrad.

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

* Re: org google weather
  2011-03-05 20:35                   ` Konrad Hinsen
@ 2011-03-05 21:19                     ` brian powell
  2011-03-05 23:51                     ` Nick Dokos
  1 sibling, 0 replies; 30+ messages in thread
From: brian powell @ 2011-03-05 21:19 UTC (permalink / raw)
  To: Org Mode Mailing List

The sunrise and sunset strings have been available in the diary
functions for EMACS for a long time; and, the new code above you've
made for inserting them into the weather strings in OrgMode agendas is
great too.  Thanks and I look forward to using it.

Now, is there any simple way, maybe with the (require 'google-weather)
that one can get the "twilight" times too--the 6 degrees of earth
rotation before sunrise and after sunset when there is still sunlight
outside but no sun to be seen? (I like to play soccer at that time
sometimes.)

(I think twilight depends on lat-lon location too though)

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

* Re: org google weather
  2011-03-05 20:35                   ` Konrad Hinsen
  2011-03-05 21:19                     ` brian powell
@ 2011-03-05 23:51                     ` Nick Dokos
  2011-03-06 10:33                       ` Konrad Hinsen
  1 sibling, 1 reply; 30+ messages in thread
From: Nick Dokos @ 2011-03-05 23:51 UTC (permalink / raw)
  To: Konrad Hinsen; +Cc: Bastien, nicholas.dokos, Org Mode Mailing List

Konrad Hinsen <konrad.hinsen@fastmail.net> wrote:


> What keeps me from writing that function right now is that I don't
> know the internals of org-mode well enough to know how to check for a
> propery or tag. I expect to spend an hour reading source code, and
> that's for another day :-)
> 

Before diving into the code, check out Appendix A, "Hacking", and in
particular section A.9, "Using the property API", in the Org manual.

Nick

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

* Re: org google weather
  2011-03-05 23:51                     ` Nick Dokos
@ 2011-03-06 10:33                       ` Konrad Hinsen
  2011-03-06 11:20                         ` Konrad Hinsen
  0 siblings, 1 reply; 30+ messages in thread
From: Konrad Hinsen @ 2011-03-06 10:33 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: Bastien, Org Mode Mailing List

On 6 Mar 2011, at 00:51, Nick Dokos wrote:

> Konrad Hinsen <konrad.hinsen@fastmail.net> wrote:
>
>> What keeps me from writing that function right now is that I don't
>> know the internals of org-mode well enough to know how to check for a
>> propery or tag. I expect to spend an hour reading source code, and
>> that's for another day :-)
>
> Before diving into the code, check out Appendix A, "Hacking", and in
> particular section A.9, "Using the property API", in the Org manual.

Thanks for the useful hint! I am not used to code that comes with a  
hacker's manual.

BTW, I found a very simple solution to my original problem of having  
sunrise and sunset only in the day view:

%%(when (eq span 'day) (diary-sunrise))
%%(when (eq span 'day) (diary-sunset))

Fortunately, because apparently org-agenda-skip-function is not called  
for diary-style entries. But I'll continue exploring that approach for  
other types of entries.

Konrad.

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

* Re: org google weather
  2011-03-06 10:33                       ` Konrad Hinsen
@ 2011-03-06 11:20                         ` Konrad Hinsen
  0 siblings, 0 replies; 30+ messages in thread
From: Konrad Hinsen @ 2011-03-06 11:20 UTC (permalink / raw)
  To: nicholas.dokos, Bastien, Org Mode Mailing List

On 6 Mar 2011, at 11:33, Konrad Hinsen wrote:

> Fortunately, because apparently org-agenda-skip-function is not  
> called for diary-style entries. But I'll continue exploring that  
> approach for other types of entries.

That was relatively easy as well:

(defun org-agenda-day-view-only-filter ()
   (let ((subtree-end   (save-excursion (org-end-of-subtree t)))
         (day-view-only (org-entry-get nil "day-view-only" t)))
     (if day-view-only
         (if (eq span 'day)
             nil
             subtree-end)
          nil)))

(setq org-agenda-skip-function-global 'org-agenda-day-view-only-filter)

The agenda items eliminated from the week views are marked with:

:PROPERTIES:
:day-view-only: t
:END:

I put the filter on the global skip function, but others may prefer to  
use a custom agenda view.

Konrad.

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

end of thread, other threads:[~2011-03-06 11:20 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-03 21:37 org google weather Simon Brown
2011-03-04  8:40 ` Ian Barton
2011-03-04  9:08   ` Sébastien Vauban
2011-03-04 11:27     ` Ian Barton
2011-03-04 15:29       ` brian powell
2011-03-04 16:38       ` Nick Dokos
2011-03-04 19:28         ` Bastien
2011-03-04 19:42         ` Konrad Hinsen
2011-03-04 20:26           ` Nick Dokos
2011-03-05 10:19             ` Bastien
2011-03-05 11:44               ` Matthew Sauer
2011-03-05 13:26                 ` Konrad Hinsen
2011-03-05 14:57                   ` Matthew Sauer
2011-03-05 15:15                     ` Michael Markert
2011-03-05 15:23                     ` Nick Dokos
2011-03-05 17:46                       ` Matthew Sauer
2011-03-05 19:57                         ` Nick Dokos
2011-03-05 14:29               ` Konrad Hinsen
2011-03-05 17:07                 ` Bastien
2011-03-05 20:35                   ` Konrad Hinsen
2011-03-05 21:19                     ` brian powell
2011-03-05 23:51                     ` Nick Dokos
2011-03-06 10:33                       ` Konrad Hinsen
2011-03-06 11:20                         ` Konrad Hinsen
2011-03-04 23:03         ` Sébastien Vauban
2011-03-04 23:25           ` Nick Dokos
2011-03-04 21:28   ` Simon Brown
2011-03-04 22:05     ` Nick Dokos
2011-03-04 22:29       ` Nick Dokos
2011-03-04 22:43       ` Simon Brown

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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