1

my org-agenda todo list looks something like this:

  inbox:      TODO learn how to process the inbox
  inbox:      TODO learn how to create a useful org agenda
  foo:        TODO start the project

I want to use org-agenda-bulk-mark-regexp to mark all the items residing in my inbox. I'm invoking the function like (org-agenda-bulk-mark-regexp "inbox:"). However, this doesn't select the items in the inbox. It only works on items that contain inbox: in their header.

How can I select these items?

3
  • 1
  • 1
    How about limiting the agenda search results to only the inbox file, and then marking everything? Or, how about adding inbox tags to everything relating to your inbox, and searching only for those tags and then marking all search results?
    – lawlist
    Jul 16 '20 at 0:33
  • BTW, technically inbox is the category, not the file name (although in most cases, the two are the same - if you ignore the .org extension). So you could also do a property search (C-c a m if you 've set up the keybinding as recommended in the manual) +CATEGORY="inbox" and then mark everything as @lawlist suggests.
    – NickD
    Jul 16 '20 at 1:31
1

Was having the exact same problem.

Issue:

If you take a look at the source for org-agenda-bulk-mark-regexp:

(defun org-agenda-bulk-mark-regexp (regexp)
  "Mark entries matching REGEXP for future agenda bulk action."
  (interactive "sMark entries matching regexp: ")
  (let ((entries-marked 0) txt-at-point)
    (save-excursion
      (goto-char (point-min))
      (goto-char (next-single-property-change (point) 'org-hd-marker))
      (while (and (re-search-forward regexp nil t)
          (setq txt-at-point
            (get-text-property (match-beginning 0) 'txt)))
    (if (get-char-property (point) 'invisible)
        (beginning-of-line 2)
      (when (string-match-p regexp txt-at-point)
        (setq entries-marked (1+ entries-marked))
        (call-interactively 'org-agenda-bulk-mark)))))
    (unless entries-marked
      (message "No entry matching this regexp."))))

The issue comes when the txt text property is saved as txt-at-point and used for matching the regex with string-match-p later on. As the comments to your question stated, inbox is the category (which is usually the same as the filename) and doesn't appear with a colon (inbox:) in the txt property.

Solution:

I made an edited version of the same function which matches based on the category but not based on any of the text of the item:

  (defun custom/org-agenda-bulk-mark-regexp-category (regexp)
    "Mark entries whose category matches REGEXP for future agenda bulk action."
    (interactive "sMark entries with category matching regexp: ")
    (let ((entries-marked 0) txt-at-point)
      (save-excursion
        (goto-char (point-min))
        (goto-char (next-single-property-change (point) 'org-hd-marker))
        (while (and (re-search-forward regexp nil t)
                    (setq category-at-point
                          (get-text-property (match-beginning 0) 'org-category)))
          (if (get-char-property (point) 'invisible)
              (beginning-of-line 2)
            (when (string-match-p regexp category-at-point)
              (setq entries-marked (1+ entries-marked))
              (call-interactively 'org-agenda-bulk-mark)))))
      (unless entries-marked
        (message "No entry matching this regexp."))))

This can now be used as such:

(defun custom/org-process-inbox ()
  "Called in org-agenda-mode, processes all inbox items."
  (interactive)
  (custom/org-agenda-bulk-mark-regexp-category "inbox")
  (custom/bulk-process-entries))

While this still doesn't allow you to match the inbox: pattern directly as you still have to remove the colon, I think it likely accomplishes what you're looking for in trying to bulk mark based on the category (file name).

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.