Giter VIP home page Giter VIP logo

Comments (14)

alphapapa avatar alphapapa commented on May 29, 2024

Hi Sebastian,

Thanks for your kind words. If you have time, I'd love if you could share an example config and/or a screenshot that I could add to the examples page. :)

I think the problem is that you're setting org-super-agenda-groups in a let, and the value of the variable isn't being preserved for the redo command. I'm not sure if there's a way to fix that, because I don't think Org is designed to do that.

Have you tried using it as a custom agenda command? I think that if you set the variable as a setting in a custom agenda command (see help for org-agenda-custom-commands), it will persist for the redo.

Other than that, if you set the variable globally, it will definitely persist across redos.

So I guess I should ask, can you show me an example of the code you're using, how you're setting the variable and running the command?

Thanks.

from org-super-agenda.

bascht avatar bascht commented on May 29, 2024

Hi @alphapapa. Thanks for your quick reply. I'm not that firm in Elisp – so it was indeed some kind of scoping issue with the (let) command. I've since added it as a custom command and this works (small snippet from my org-init.el, taken from https://github.com/bascht/dotfiles-public/tree/master/home/.emacs.d/personal):

(use-package org-super-agenda
  :config (org-super-agenda-mode))

(setq org-agenda-custom-commands
      '(("c" "Super Agenda" agenda
         (org-super-agenda-mode)
         ((org-super-agenda-groups
           '(
             (:name "Next Items"
                    :time-grid t
                    :tag ("NEXT" "outbox"))
             (:name "Important"
                    :priority "A")
             (:name "Today"
                    :time-grid t
                    :scheduled today)
             (:name "Quick Picks"
                    :effort < 00:30 ; ← that one doesn't seem to work, no?
                    )
             (:priority<= "B"
                          :order 1)
             )))
         (org-agenda nil "a"))))

If I censor away my own data a bit, I'd be happy to supply a screenshot with my example. πŸ˜„

from org-super-agenda.

alphapapa avatar alphapapa commented on May 29, 2024

Great, I'm glad you got it working! Here are a couple of FYIs:

  1. Since you used :time-grid t in the "Next Items" group, it will group everything that matches it, so none of those items will make it down to the "Today" group. Maybe that's what you want, in which case the one in "Today" is redundant. :)
  2. No, I haven't added an :effort selector, because I've never used efforts before! :) But I think it should be easy to add, so I'll put that on my list.

If I censor away my own data a bit, I'd be happy to supply a screenshot with my example.

That would be great! In fact, instead of having to use GIMP on a screenshot, you can use this function I happen to have handy, which just replaces the visible heading of the current item in the agenda view, without changing the heading of the actual item:

(defun org-agenda-sharpie ()
  "Censor the text of items in the agenda."
  (interactive)
  (let (regexp old-heading new-heading properties)
    ;; Save face properties of line in agenda to reapply to changed text
    (setq properties (text-properties-at (point)))

    ;; Go to source buffer
    (org-with-point-at (org-find-text-property-in-string 'org-marker
                                                         (buffer-substring (line-beginning-position)
                                                                           (line-end-position)))
      ;; Save old heading text and ask for new text
      (line-beginning-position)
      (unless (org-at-heading-p)
        ;; Not sure if necessary...IT IS NECESSARY
        (org-back-to-heading))
      (setq old-heading (when (looking-at org-complex-heading-regexp)
                          (match-string 4))))
    (setq new-heading (read-from-minibuffer "Overwrite visible heading with: "))
    (add-text-properties 0 (length new-heading) properties new-heading)
    ;; Back to agenda buffer
    (save-excursion
      (when (and old-heading new-heading)
        ;; Replace agenda text
        (let ((inhibit-read-only t))
          (goto-char (line-beginning-position))
          (when (search-forward old-heading (line-end-position))
            (replace-match new-heading 'fixedcase 'literal)))))))

from org-super-agenda.

alphapapa avatar alphapapa commented on May 29, 2024

I just added effort selectors. They seem to be working, but please let me know if they work right for you. Thanks.

from org-super-agenda.

bascht avatar bascht commented on May 29, 2024

@alphapapa Thanks for the :effort selector! Just updated to the latest version & it works! πŸ˜„
I cannot get (org-agenda-sharpie) to work, though. I'm in Agenda mode, cursor on the agenda item, run the function with M-x, can enter the new title in the Mini Buffer, but the actual item won't change. The *messages* buffer is empty. Any hints? πŸ˜„

from org-super-agenda.

alphapapa avatar alphapapa commented on May 29, 2024

Great, glad it's working.

So sorry about the function not working. That code that I commented out, that I wasn't sure if it was necessary...well apparently it is. Oops. :) This should work, I just tested it:

(defun org-agenda-sharpie ()
  "Censor the text of items in the agenda."
  (interactive)
  (let (regexp old-heading new-heading properties)
    ;; Save face properties of line in agenda to reapply to changed text
    (setq properties (text-properties-at (point)))

    ;; Go to source buffer
    (org-with-point-at (org-find-text-property-in-string 'org-marker
                                                         (buffer-substring (line-beginning-position)
                                                                           (line-end-position)))
      ;; Save old heading text and ask for new text
      (line-beginning-position)
      (unless (org-at-heading-p)
        ;; Not sure if necessary...IT IS!
        (org-back-to-heading))
      (setq old-heading (when (looking-at org-complex-heading-regexp)
                          (match-string 4))))
    (setq new-heading (read-from-minibuffer "Overwrite visible heading with: "))
    (add-text-properties 0 (length new-heading) properties new-heading)
    ;; Back to agenda buffer
    (save-excursion
      (when (and old-heading new-heading)
        ;; Replace agenda text
        (let ((inhibit-read-only t))
          (goto-char (line-beginning-position))
          (when (search-forward old-heading (line-end-position))
            (replace-match new-heading 'fixedcase 'literal)))))))

Thank you!

from org-super-agenda.

bascht avatar bascht commented on May 29, 2024

@alphapapa We're one step further. The Sharpie will rewrite the very last tag (I've no idea why, though):

before

screenshot_20170803_180728

after

screenshot_20170803_180640

from org-super-agenda.

alphapapa avatar alphapapa commented on May 29, 2024

I'm stumped, I don't know how that could happen. You are using Org 9, right?

I modified the code a bit and tested it again on several headings, and it works every time for me:

(defun org-agenda-sharpie ()
  "Censor the text of items in the agenda."
  (interactive)
  (let (regexp old-heading new-heading properties)
    ;; Save face properties of line in agenda to reapply to changed text
    (setq properties (text-properties-at (point)))

    ;; Go to source buffer
    (org-with-point-at (org-find-text-property-in-string 'org-marker
                                                         (buffer-substring (line-beginning-position)
                                                                           (line-end-position)))
      ;; Save old heading text and ask for new text
      (line-beginning-position)
      (unless (org-at-heading-p)
        ;; Not sure if necessary
        (org-back-to-heading))
      (setq old-heading (when (looking-at org-complex-heading-regexp)
                          (match-string 4))))
    (unless old-heading
      (error "Can't find heading.  How can this be?"))
    ;; Back to agenda buffer
    (setq new-heading (read-from-minibuffer "Overwrite visible heading with: "))
    (add-text-properties 0 (length new-heading) properties new-heading)
    ;; Replace agenda text
    (save-excursion
      (let ((inhibit-read-only t))
        (goto-char (line-beginning-position))
        (when (search-forward old-heading (line-end-position))
          (replace-match new-heading 'fixedcase 'literal))))))

I hope we can get it working, I really like the look of that screenshot. Thanks for your patience.

from org-super-agenda.

bascht avatar bascht commented on May 29, 2024

Thanks again for debugging this & providing a new function. I'm on the latest org-mode, but I think there might be something off with my tags / the way they align. The function works in some cases and doesn't in some cases (the headlines tag shows a double colon like :something::).

Long story sort: I cleaned up my items a bit and you can use the uncensored version, as there are (hopefully) no confidential or embarrassing tasks left. 😬

Screenshot

screenshot_20170804_181001

My config (heavily inspired by yours ;))

(setq org-agenda-custom-commands
      '(("c" "Super Agenda" agenda
         (org-super-agenda-mode)
         ((org-super-agenda-groups
           '(
             (:name "Next Items"
                    :time-grid t
                    :tag ("NEXT" "outbox"))
             (:name "Important"
                    :priority "A")
             (:name "Quick Picks"
                    :effort< "0:30"
                    )
             (:priority<= "B"
                          :scheduled > "tomorrow"
                          :order 1)
             )))
         (org-agenda nil "a"))))

from org-super-agenda.

alphapapa avatar alphapapa commented on May 29, 2024

Thanks, Sebastian, that screenshot looks great, I will add it and the config to the examples page.

I'm perplexed by the problem with the function and the tags issue. I use code straight from Org to read the entry title, so I don't understand how it could be getting a tag instead. You might have actually found an obscure bug in Org itself, so you might look at some of the items it misbehaved on and see if the tag string is correct, and whether this code returns the title or a tag or something else (with point at the beginning of the heading line):

(when (looking-at org-complex-heading-regexp)
                          (match-string 4))

By the way, the (:scheduled > "tomorrow") selector won't work, it should be like (:scheduled future) for anything after today, or (:scheduled (after "2017-08-03")) for arbitrary dates.

Thanks for your help with this!

from org-super-agenda.

bascht avatar bascht commented on May 29, 2024

Thanks for the :scheduled future hint! I didn't even notice that no filter did match. 😬
The Org issue itself is really weird. I found one headline where (org-agenda-sharpie) would replace the first bit (the actual file) and after reloading the aganda everything was back to normal and it would replace the actual headline text.

Your search function did work for every headline, however. πŸ˜„

from org-super-agenda.

alphapapa avatar alphapapa commented on May 29, 2024

Hm, that is strange. Of course, this is my own little hack, and so it's not a big surprise that there are corner cases in the agenda's hidden text properties, haha.

Thanks for your help!

from org-super-agenda.

novoid avatar novoid commented on May 29, 2024

In case you're looking for an additional example configuration, I linked the relevant parts of my configuration.

The advantage of my approach is the central definition of my super-agenda which is used as my default agenda defined in org-agenda-custom-commands and in the function my-org-agenda() which brings you to your agenda right away:

  • my-super-agenda
    • defines a variable my-super-agenda-groups which holds my central definition of super-agenda
    • defines function my-super-agenda() which calls my super-agenda interactively or within other functions
      - org-agenda-custom-commands
      - includes my super-agenda as a small snippet which is using the my-super-agenda-groups from above
      - my-org-agenda
      - a function which switches to the already generated agenda (which is waiting in a background buffer) or re-generates my agenda

from org-super-agenda.

alphapapa avatar alphapapa commented on May 29, 2024

Thanks, Karl, that's awesome!

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.