12

Q: can I put divider lines in my org agenda view?

My agenda buffer can get a little busy when I have a lot of things due. This busyness has the counterproductive effect of making me avoid looking at my agenda because it freaks me out. I'm looking for a way to make it visually less daunting.

One thing I'd like is to be able to put divider lines (eg, just a line of dashes) in between agenda items that:

  • have a deadline today,
  • are past their deadline (overdue X days), and
  • have an upcoming deadline (due in X days).

Is it possible to put divider lines in the agenda view? If yes, how would I do that?

  • In a semi-related question entitled How to get the raw data for an org-mode agenda without an agenda view?, I posted an answer demonstrating how to obtain the raw data: emacs.stackexchange.com/a/12563/2287 You can modify that data to suit your needs, including, but not limited to: replace-regexp-in-string (add divider lines and/or newlines as you desire); you can have a string-equals or matches certain criteria or any other criteria you seek. Examine the existing text-properties with values to familiarize yourself with what is included out-of-the-box, and then use them. – lawlist Aug 19 '15 at 15:53
  • With a fresh cup of coffee in hand, I thought of an easier method using the org-mode raw data that doesn't even involve manipulating the data with replacing any portions of the string. I.e, just examine the text properties and if they match your criteria, insert something like a line before or after as the buffer is being populated by the mapcar in the example of the link above. This project could conceivable entail some time to implement to create a custom org-agenda buffer, and the example does not contemplate org-search-view or org-tags-view -- i.e., only org-agenda-list. – lawlist Aug 20 '15 at 16:29
2

org-agenda-block-separator

The separator between blocks in the agenda. If this is a string, it will be used as the separator, with a newline added. If it is a character, it will be repeated to fill the window width. If nil the separator is disabled. In org-agenda-custom-commands this addresses the separator between the current and the previous block.


org-agenda-compact-blocks

Non-nil means make the block agenda more compact. This is done globally by leaving out lines like the agenda span name and week number or the separator lines.

  • 1
    Thanks, but can you give an example of how one would use this in an agenda view? – Dan Aug 19 '15 at 21:10
1

You can have multiple blocks in an agenda view, each with its own search by just concatenating several custom commands:

(setq org-agenda-custom-commands
      '(("D" "Deadlines"
         ((tags-todo "DEADLINE=\"<today>\""
                     ((org-agenda-overriding-header "Due Today"))
                     )
          (tags-todo "DEADLINE<\"<today>\""
                     ((org-agenda-overriding-header "You're Late")))
          (tags-todo "+DEADLINE<\"<+5d>\"+DEADLINE>\"<today>\""
                     ((org-agenda-overriding-header "Better get on it")))
         ))))

You can also place a list of options at the end that will apply to all the blocks.

This disadvantage is that each block is computed separately so this takes 3 times as long to generate as a single agenda

1

The following is an example of how to examine the text-properties of the items being generated by org-agenda-list, and modify the string based on certain criteria. In this example, the value of the text property ts-date is obtained and compared against the current date -- if it is overdue, we add OLD:; if it is current, we add CURRENT:, if its future, we add FUTURE:. The original poster can customize this example add a new line and/or a divider line at select locations. The customization may vary depending upon the sorting criteria chosen by the original poster in the org-agenda-sorting-strategy, etc.

In this example, the function org-agenda-finalize-entries has been modified near the bottom between the sections labeled ;; BEGIN modification and ;; END modification.

(require 'org-agenda)

(defun org-agenda-finalize-entries (list &optional type)
  "Sort, limit and concatenate the LIST of agenda items.
The optional argument TYPE tells the agenda type."
  (let ((max-effort (cond ((listp org-agenda-max-effort)
         (cdr (assoc type org-agenda-max-effort)))
        (t org-agenda-max-effort)))
  (max-todo (cond ((listp org-agenda-max-todos)
       (cdr (assoc type org-agenda-max-todos)))
      (t org-agenda-max-todos)))
  (max-tags (cond ((listp org-agenda-max-tags)
       (cdr (assoc type org-agenda-max-tags)))
      (t org-agenda-max-tags)))
  (max-entries (cond ((listp org-agenda-max-entries)
          (cdr (assoc type org-agenda-max-entries)))
         (t org-agenda-max-entries))) l)
    (when org-agenda-before-sorting-filter-function
      (setq list
      (delq nil
      (mapcar
       org-agenda-before-sorting-filter-function list))))
    (setq list (mapcar 'org-agenda-highlight-todo list)
    list (mapcar 'identity (sort list 'org-entries-lessp)))
    (when max-effort
      (setq list (org-agenda-limit-entries
      list 'effort-minutes max-effort 'identity)))
    (when max-todo
      (setq list (org-agenda-limit-entries list 'todo-state max-todo)))
    (when max-tags
      (setq list (org-agenda-limit-entries list 'tags max-tags)))
    (when max-entries
      (setq list (org-agenda-limit-entries list 'org-hd-marker max-entries)))
    ;; BEGIN modification
    (setq list
      (mapcar
        (lambda (string)
          (let* (
              (current-date (time-to-days (current-time)))
              (ts-date (get-text-property 0 'ts-date string)) )
            (if ts-date
              (cond
                ((< ts-date current-date)
                  (message "The task dated %s is overdue." ts-date)
                  ;; The new value of `string' is returned/thrown as a result.
                  (replace-regexp-in-string "^" "OLD:  " string))
                ((= ts-date current-date)
                  (message "The task dated %s is due today." ts-date)
                  ;; The new value of `string' is returned/thrown as a result.
                  (replace-regexp-in-string "^" "CURRENT:  " string))
                ((> ts-date current-date)
                  (message "The task dated %s is not due yet." ts-date)
                  ;; The new value of `string' is returned/thrown as a result.
                  (replace-regexp-in-string "^" "FUTURE:  " string)))
              string)))
        list))
    ;; END modification
    (mapconcat 'identity list "\n")))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.