Giter VIP home page Giter VIP logo

Comments (7)

rjhorn-agfa avatar rjhorn-agfa commented on May 28, 2024

A little more poking reveals that by the point where org-super-agenda gets the timegrid, the lines from %%(diary commands do not have the "dotime" property at all. This is based on changing the test for time grid to include everything with the dotime property.

This is actually perhaps promising, since the %%(diary processing is fairly well isolated. I can experiment with modifying it to add a text property to part of the string.

from org-super-agenda.

rjhorn-agfa avatar rjhorn-agfa commented on May 28, 2024

Yes. I find that all diary types (and related types) are given a text-property 'type "sexp" during org-agenda processing after executing the sexp. This code works:

:test (let ((time (org-find-text-property-in-string 'dotime item))
(thetype (org-find-text-property-in-string 'type item)))
;; For this to match, the 'dotime property must be set, and
;; it must not be equal to 'time. If it is not set, or if
;; it is set and is equal to 'time, the item is not part of
;; the time-grid. Yes, this is confusing. :)
;; diary entries in the grid will have the 'type of "sexp"
(or (equal thetype "sexp") (and (not (equal time nil)) (not (equal time 'time)))))

You may find some better way that you prefer for this test. It turns out that org-agenda is already flagging the text for S-expressions, so this should be a stable bug fix for org-super-agenda.

from org-super-agenda.

alphapapa avatar alphapapa commented on May 28, 2024

Hi,

Thanks for reporting this and digging into it. I've hardly used diary-style sexps, so I'm not very familiar with them; I always have to refresh my memory about how they work.

I'm not sure that they should always be grouped with the time-grid entries. For sunrise/sunset, that makes sense, since they have a time associated. But entries without times associated probably shouldn't be in the time-grid.

I'm trying to test this now, but I don't see diary-sunrise and diary-sunset functions, only diary-sunrise-sunset, which creates a single line listing both sunrise and sunset.

Here are all of the text properties I see for the sunrise/sunset line:

There are text properties here:
  breadcrumbs          nil
  date                 (7 5 2017)
  day                  736515
  dotime               time
  duration             nil
  extra                ""
  face                 org-agenda-calendar-sexp
  format               [Show]
  help-echo            "mouse-2 or RET jump to org file ~/src/org-super-agenda/test.org"
  level                "   "
  mouse-face           highlight
  org-agenda-type      agenda
  org-category         "test"
  org-day-cnt          1
  org-heading          t
  org-highest-priority 65
  org-last-args        (nil nil day)
  org-lowest-priority  67
  org-marker           [Show]
  org-redo-cmd         (org-agenda-list 'nil nil 'day nil)
  org-series-cmd       nil
  tags                 nil
  time                 " 1:02......"
  time-of-day          102
  todo-state           nil
  txt                  [Show]
  type                 "sexp"
  warntime             nil

Maybe we could test for the time or time-of-day property, but I guess we'll have to investigate what other items have those properties too. Another possibility is to make a generic text-property matcher.

Of course, you could also add a :regexp matcher that matches on sunrise or sunset, and put that in the group with the :time-grid matcher, like:

:regexp (rx (or "sunrise" "sunset"))

I'm not sure what the best way to handle this is. What do you think?

Thanks.

from org-super-agenda.

alphapapa avatar alphapapa commented on May 28, 2024

Well, I did some more checking, and I think this might do it:

(org-super-agenda--defgroup time-grid
  "Group items that appear on a time grid.
This matches the `dotime' text-property, which, if NOT set to
`time' (I know, this gets confusing), means it WILL appear in the
agenda time-grid. "
  :section-name "Timed items"  ; Note: this does not mean the item has a "SCHEDULED:" line
  :test (or (--when-let (org-find-text-property-in-string 'time item)
              ;; This property is a string; if empty, it doesn't match
              (not (string-empty-p it)))
            ;; This property is nil if it doesn't match
            (org-find-text-property-in-string 'time-of-day item)
            (--when-let (org-find-text-property-in-string 'dotime item)
              ;; For this to match, the 'dotime property must be set, and
              ;; it must not be equal to 'time.  If it is not set, or if
              ;; it is set and is equal to 'time, the item is not part of
              ;; the time-grid.  Yes, this is confusing.  :)
              (not (eql it 'time)))))

If you'd like to test this, just evaluate this form, and then run your agenda. It seems to work for me, and the sunrise/sunset line is properly sorted among other time-grid lines. It doesn't seem to have any adverse effects on other grouping, but I'd like it to be tested a bit more thoroughly before releasing it as an update.

from org-super-agenda.

rjhorn-agfa avatar rjhorn-agfa commented on May 28, 2024

I'll try it and get back to you.

I realized that sunrise/set are local extensions that I added from somewhere:

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

I don't see anything there that would change properties.

from org-super-agenda.

rjhorn-agfa avatar rjhorn-agfa commented on May 28, 2024

That fix works, and I think it's the right one. Based on the principle of least astonishment, org-super-agenda should use the same rules as org-agenda. Looking through it's code I find:

  1. The %%(sexpr) must be at the beginning of the line, otherwise the (sexpr) is not evaluated,
  2. If the result does not contain something that looks like a date to org, it is not in the time grid
  3. If the date is not the right day, it is not in the time grid. The sexpr may do a lot of date calculations, repetitions, etc. By the time it reaches org-agenda it's resolved to a particular day.
  4. If there is nothing that looks like a time, the entry is not in the time grid. It might be elsewhere in the agenda results, but it's not in the grid.
  5. The first thing that looks like a time is used as the time in the time grid.

Step 4) corresponds to setting the properties time-of-day and time. The test for 'time-of-day is simpler, because that will either be nil or have a value. Nil means not in the grid.

from org-super-agenda.

alphapapa avatar alphapapa commented on May 28, 2024

Thanks, Robert. And thanks for the sunrise/sunset functions; I think I may use those in my agenda. Let me know if you find any other issues.

from org-super-agenda.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.