GithubHelp home page GithubHelp logo

Suggestion about org-deadsync HOT 5 CLOSED

alphapapa avatar alphapapa commented on July 20, 2024
Suggestion

from org-deadsync.

Comments (5)

legalnonsense avatar legalnonsense commented on July 20, 2024

from org-deadsync.

legalnonsense avatar legalnonsense commented on July 20, 2024

I just saw all the other suggestions you made. For some reason your first one only came through my email. Thank you! I will work on these.

from org-deadsync.

legalnonsense avatar legalnonsense commented on July 20, 2024

With regard to the locked deadline, I had the idea that to ensure that the user does not change a locked deadline that I would make the deadline text itself read-only. If the user tries to change a locked deadline, it prompts to see if they want to unlock it.

The only function that uses the deadline-locked-p function is the toggle-lock function, both of which I think I put there for testing.

I am not sure why I used (end-of-visual-line), nor do I know why I used (org-deadline-get-time) instead of (org-entry-get).

But this gets to the point of something I have been wondering about. If I call (org-entry-get) from anywhere within the heading, it'll tell me there is a deadline, but I have no idea of where to find it. Hence my thought that one needed to ensure they knew where they were in the heading before calling re-search-forward (or backward). Otherwise, how would you know which direction to go?

You can't just re-search-backward to get to a heading, because you could very well be at the first point of the heading, and only the next heading would be picked up. Hence moving the point to the end of the line, then searching backward (in case I was actually at the first point of the heading.. This is the only way I could then to ensure the point was at the beginning of the heading, so I could then search for the DEADLINE: regular expression, knowing that I would find it with re-search-forward.

I know the re-searches are unbounded, but I am relying on knowing that I am in a heading and will therefore hit a "^*+ " backwards, and (if on the top line) I'll hit a DEADLINE forwards.

There's also an underlying issue that org doesn't seem to care what order DEADLINE and SCHEDULED appear in (whichever was set last appears first), so you can't assume where the deadline is on the second line.

I had no idea about the regexp variables. I figured I should be using my own, but was too lazy to fix it all when it occurred to me.

Thank you again for the help. Posting this because I am curious if I am doing something wrong-headed. I was screwing around today changing the appearance of the outline in a more fundamental way than with say, org bullets, and it relies on the method I described above for normalizing point positions in a heading. I realize now I write a function that will simply place the point at the beginning of the heading.

Beyond that, if there is a higher level obviousness that I am missing then that would be great!

from org-deadsync.

alphapapa avatar alphapapa commented on July 20, 2024

With regard to the locked deadline, I had the idea that to ensure that the user does not change a locked deadline that I would make the deadline text itself read-only. If the user tries to change a locked deadline, it prompts to see if they want to unlock it.

That's a neat idea.

But this gets to the point of something I have been wondering about. If I call (org-entry-get) from anywhere within the heading, it'll tell me there is a deadline, but I have no idea of where to find it. Hence my thought that one needed to ensure they knew where they were in the heading before calling re-search-forward (or backward). Otherwise, how would you know which direction to go?

You can't just re-search-backward to get to a heading, because you could very well be at the first point of the heading, and only the next heading would be picked up. Hence moving the point to the end of the line, then searching backward (in case I was actually at the first point of the heading.. This is the only way I could then to ensure the point was at the beginning of the heading, so I could then search for the DEADLINE: regular expression, knowing that I would find it with re-search-forward.

Use something like:

(save-excursion
  (outline-back-to-heading)
  (when (re-search-forward org-deadline-time-regexp (line-end-position 2) t)
    do-your-stuff)) 

Ideally your code would be running with point on the heading already, so you could omit the call to outline-back-to-heading. It also solves this issue:

There's also an underlying issue that org doesn't seem to care what order DEADLINE and SCHEDULED appear in (whichever was set last appears first), so you can't assume where the deadline is on the second line.

Because it will leave point after the deadline timestamp.

I realize now I write a function that will simply place the point at the beginning of the heading.

Most such functions you'll need already exist in outline.el and org.el. Helm makes these easy to find.

I was screwing around today changing the appearance of the outline in a more fundamental way than with say, org bullets, and it relies on the method I described above for normalizing point positions in a heading.

You might find this function interesting. It adds outline number overlays to headings. They aren't updated automatically, of course, but sometimes it can be useful. To be more correct, it should probably use a unique property for the overlays it makes, so it can only clear those overlays when it runs again. It almost seems like it should be written to use a recursive function, but on the other hand, while trees are recursive, it's parsing them as plain text, which isn't recursive. Of course, you could use org-narrow-to-subtree and write it recursively, but that would probably be slower. Anyway, it's messy, but it works.

(defun ap/org-outline-numbers ()
    (interactive)
    (save-excursion
      (let* ((positions-levels (progn
                                 (goto-char (point-min))
                                 (when (org-before-first-heading-p)
                                   (outline-next-heading))
                                 (cl-loop while (not (eobp))
                                          collect (cons (point) (org-current-level))
                                          do (outline-next-heading))))
             (tree (cl-loop with current-top-level = 0
                            with current-subtree-numbers
                            with results
                            with previous-level
                            for (position . level) in positions-levels
                            if (= 1 level)
                            do (progn
                                 (setq current-subtree-numbers nil)
                                 (setq previous-level level)
                                 (push (a-list 'heading (save-excursion
                                                          (goto-char position)
                                                          (substring-no-properties
                                                           (org-get-heading t t)))
                                               'position position
                                               'level level
                                               'number (concat (number-to-string (incf current-top-level)) "."))
                                       results))
                            else do (let* ((current-level-number (cond ((<= level previous-level)
                                                                        (incf (map-elt current-subtree-numbers level)))
                                                                       ((> level previous-level)
                                                                        1)))
                                           text-number)
                                      (setq previous-level level)
                                      (map-put current-subtree-numbers level current-level-number)
                                      (setq text-number (cl-loop for lookup from level downto 1
                                                                 for lookedup = (map-elt current-subtree-numbers lookup)
                                                                 if lookedup
                                                                 collect lookedup into result
                                                                 else collect current-top-level into result
                                                                 finally return (s-join "." (mapcar #'number-to-string (nreverse result)))))
                                      (push (a-list 'heading (save-excursion
                                                               (goto-char position)
                                                               (substring-no-properties
                                                                (org-get-heading t t)))
                                                    'position position
                                                    'level level
                                                    'number text-number)
                                            results))
                            finally return (nreverse results))))
        (ov-clear)
        (--each tree
          (let-alist it
            (ov (+ .position (1- .level)) (+ .position .level)
                'display .number))))))

I tried prism.el. My first reaction was that it seemed like a lot going on, and I generally don't like a lot of syntax highlighting. But the more I used it the more I liked it. It looks great on with my dark theme. I need to tinker with it more. I really like the colorized parenthesis. I also liked the sample I saw that tended to keep everything the same color, which I felt gave more of an indication of depth. Have some thoughts but don't want to share them until I play with it a bit.

Thanks, let me know what you think after you've used it some more.

Thanks again for the help on this and everything else. Work is ramping up for me so I'll likely not be writing much, and plan to spend some downtime learning about lisp interpreters in interpreters and such. Will check out some of those books you recommended and hope to come back ready to try something new.

Glad I can help a little.

from org-deadsync.

legalnonsense avatar legalnonsense commented on July 20, 2024

Changes implemented.

from org-deadsync.

Related Issues (3)

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.