While trying out `org-mouse', I noticed two semi-related issues with checkboxes. First, intermediate-state checkboxes (like [-]) aren't clickable. Second, if the checkboxes are inside a block and the theme gives the block a background color, the block's background is removed behind the checkbox. To see both of these in action:

  $ cat file.org
  * Regular
  - [X] Checked.
  - [-] Half-checked.
  - [ ] Not checked.
  * In block
  #+begin_src org
  - [X] Checked.
  - [-] Half-checked.
  - [ ] Not checked.
  #+end_src

$ emacs -Q --eval '(progn (setq org-modules '"'"'(org-mouse)) (custom-set-faces '"'"'(org-block ((t :background "green")))))' file.org

The attached patch fixes both of these issues. For the first problem, maybe it would be useful to put the regexp for checkboxes in a variable somewhere so it doesn't get out of sync. I wasn't sure though, so I went with the simpler solution for now.

My FSF copyright assignment should be on file, but let me know if there are any issues there.
From b2bd5115a89b9b26107aca4b59e516dc7d64f0cc Mon Sep 17 00:00:00 2001
From: Jim Porter <itsjimpor...@gmail.com>
Date: Sat, 18 Sep 2021 12:22:41 -0700
Subject: [PATCH] org-mouse: Support intermediate-state checkboxes

* lisp/org-mouse.el (org-mode-hook): Use regexp from
`org-set-font-lock-defaults' and set font-lock keywords more robustly.
---
 lisp/org-mouse.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/org-mouse.el b/lisp/org-mouse.el
index 4471d8e8d..eae6cd98f 100644
--- a/lisp/org-mouse.el
+++ b/lisp/org-mouse.el
@@ -890,8 +890,8 @@ This means, between the beginning of line and the point."
             (when (memq 'activate-checkboxes org-mouse-features)
               (font-lock-add-keywords
                nil
-               `(("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[ X]\\]\\)"
-                  (2 `(face org-checkbox keymap ,org-mouse-map mouse-face 
highlight) t)))
+               `(("^[ \t]*\\(?:[-+*]\\|[0-9]+[.)]\\)[ 
\t]+\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?\\(\\[[- X]\\]\\)"
+                  (1 `(face nil keymap ,org-mouse-map mouse-face highlight) 
prepend)))
                t))
 
             (defadvice org-open-at-point (around org-mouse-open-at-point 
activate)
-- 
2.25.1

Reply via email to