0

Running Doom Emacs v2.0.9 on Emacs 27.1.

I can mark several entries in the agenda buffer and work on all of them together.

Is there a way to keep marked entries highlighted? This would give more comfort while we operate on them.

0

2 Answers 2

0

Your question should be more accurate. You can compose a function to do what you want. For instance to highlight saturday and monday using the color pink (you can have a try in interactive mode ):

(defun my-highlight-we-agenda ()
" your function description "
(highlight-regexp "saturday\\|sunday" 'hi-pink))

Next you active this function in any org-agenda-list buffer

(add-hook 'org-agenda-finalize-hook #'my-highlight-we-agenda)

To compose a regexp just as you need, you can use re-builder in a org-agenda buffer

2
  • Thanks. But that was not what I meant. In agenda buffer, one can mark an entry using org-agenda-bulk-toggle. This puts a small icon in the leftmost column. Can we have the line highlighted instead?
    – deshmukh
    Commented Jan 10, 2021 at 9:07
  • Could you post an example of your org-agenda buffer and what you want to be done ?
    – gigiair
    Commented Jan 10, 2021 at 15:07
0

Here's a function that will highlight all marked lines in yellow, and unhighlight unmarked lines. I add advice to run it after all commands that mark and unmark entries:

;; Highlight lines of marked Org-Agenda items
;; See https://emacs.stackexchange.com/a/70380/17182
(defun my-org-agenda-highlight-marked (oldfun &rest r)
  ;; ‘advice--cd*r’ finds the underlying advised function so that we can
  ;; properly compare functions.
  (let* ((oldfun-base (advice--cd*r oldfun))
         ;; Functions that examine the whole buffer and are not implemented
         ;; in terms of more primitive functions - currently just
         ;; ‘org-agenda-bulk-unmark-all'.
         (all-buffer-funcs
                   (mapcar (lambda (sym)
                             (advice--cd*r (symbol-function sym)))
                           '(org-agenda-bulk-unmark-all)))
         (begin
          (cond
           ((member oldfun all-buffer-funcs) (point-min))
           ((use-region-p) (region-beginning))
           (t (point-at-bol))))
         (end
          (cond
           ((member oldfun all-buffer-funcs) (point-max))
           ((use-region-p) (region-end))
           (t (point-at-eol)))))
    (apply oldfun r)
    (save-excursion
      (goto-char begin)
      (forward-line 0)
      (while (< (point) end)
        (let* ((ovs (overlays-at (point)))
               (marked-entry-overlay
                (nth 0
                     (cl-remove-if-not
                      (lambda (ov)
                        (eq (overlay-get ov 'type) 'org-marked-entry-overlay))
                      ovs)))
               (highlight-marked-overlay
                (nth 0
                     (cl-remove-if-not
                      (lambda (ov)
                        (eq (overlay-get ov 'type) 'my-org-agenda-highlight-marked))
                      ovs))))
          (cond
           ((and highlight-marked-overlay (not marked-entry-overlay))
            (delete-overlay highlight-marked-overlay))
           ((and marked-entry-overlay (not highlight-marked-overlay))
            (let ((ov (make-overlay (point-at-bol) (point-at-eol))))
              (overlay-put ov 'type 'my-org-agenda-highlight-marked)
              (overlay-put ov 'face '(:background "yellow"))))))
        (forward-line 1)))))
;; ‘org-agenda-bulk-mark-all’, ‘org-agenda-bulk-mark-regexp’, and
;; ‘org-agenda-bulk-toggle-all’ are all implemented using
;; ‘org-agenda-bulk-mark’, and ‘org-agend-bulk-toggle’, so
;; they don't need to be advised.
(dolist (cmd '(org-agenda-bulk-mark org-agenda-bulk-toggle
               org-agenda-bulk-unmark org-agenda-bulk-unmark-all))
  (advice-add cmd :around #'my-org-agenda-highlight-marked))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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