emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Improve org-mouse support for checkboxes
@ 2021-09-18 19:38 Jim Porter
  2021-09-18 20:54 ` Samuel Wales
  2021-09-26  5:58 ` Bastien
  0 siblings, 2 replies; 6+ messages in thread
From: Jim Porter @ 2021-09-18 19:38 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1027 bytes --]

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.

[-- Attachment #2: 0001-org-mouse-Support-intermediate-state-checkboxes.patch --]
[-- Type: text/plain, Size: 1249 bytes --]

From b2bd5115a89b9b26107aca4b59e516dc7d64f0cc Mon Sep 17 00:00:00 2001
From: Jim Porter <itsjimporter@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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Improve org-mouse support for checkboxes
  2021-09-18 19:38 [PATCH] Improve org-mouse support for checkboxes Jim Porter
@ 2021-09-18 20:54 ` Samuel Wales
  2021-09-18 22:47   ` Jim Porter
  2021-09-26  5:58 ` Bastien
  1 sibling, 1 reply; 6+ messages in thread
From: Samuel Wales @ 2021-09-18 20:54 UTC (permalink / raw)
  To: Jim Porter; +Cc: emacs-orgmode

thanks for this.  if tests are written, might be useful to include the
case where half-checked are parents.

On 9/18/21, Jim Porter <jporterbugs@gmail.com> wrote:
> 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.
>


-- 
The Kafka Pandemic

Please learn what misopathy is.
https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Improve org-mouse support for checkboxes
  2021-09-18 20:54 ` Samuel Wales
@ 2021-09-18 22:47   ` Jim Porter
  0 siblings, 0 replies; 6+ messages in thread
From: Jim Porter @ 2021-09-18 22:47 UTC (permalink / raw)
  To: Samuel Wales; +Cc: emacs-orgmode

On 9/18/2021 1:54 PM, Samuel Wales wrote:
> thanks for this.  if tests are written, might be useful to include the
> case where half-checked are parents.

I tested manually, and this behaves how I'd expect; not surprising, 
since it just calls `org-toggle-checkbox'. Maybe there's an argument 
that parent checkboxes shouldn't be clickable in the first place though. 
I don't think you can call `org-toggle-checkbox' on parent checkboxes 
(or if you can, I'm not sure what the trick is). My patch doesn't change 
that though, aside from having half-checked boxes be clickable in general.

I could look into writing some automated tests for this, but I don't see 
any existing ones for org-mouse, and I'm not familiar with simulating 
mouse events for Emacs tests.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Improve org-mouse support for checkboxes
  2021-09-18 19:38 [PATCH] Improve org-mouse support for checkboxes Jim Porter
  2021-09-18 20:54 ` Samuel Wales
@ 2021-09-26  5:58 ` Bastien
  2021-09-26 18:11   ` Jim Porter
  1 sibling, 1 reply; 6+ messages in thread
From: Bastien @ 2021-09-26  5:58 UTC (permalink / raw)
  To: Jim Porter; +Cc: emacs-orgmode

Hi Jim,

Jim Porter <jporterbugs@gmail.com> writes:

> 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.

Applied now, thanks.

> My FSF copyright assignment should be on file, but let me know if there 
> are any issues there.

I applied the patch adding the TINYCHANGE cookie, since the assignment
process isn't done yet.  Can you check with copyright-clerk@fsf.org if
it will be done anytime soon?

Thanks!


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Improve org-mouse support for checkboxes
  2021-09-26  5:58 ` Bastien
@ 2021-09-26 18:11   ` Jim Porter
  2021-09-26 20:18     ` Bastien
  0 siblings, 1 reply; 6+ messages in thread
From: Jim Porter @ 2021-09-26 18:11 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

On 9/25/2021 10:58 PM, Bastien wrote:
> I applied the patch adding the TINYCHANGE cookie, since the assignment
> process isn't done yet.  Can you check with copyright-clerk@fsf.org if
> it will be done anytime soon?

Hm, it should be done, since I received confirmation from the copyright 
clerk on the 15th. I think I might be in the database as "James" though; 
that caused a similar hiccup when contributing to Emacs too.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Improve org-mouse support for checkboxes
  2021-09-26 18:11   ` Jim Porter
@ 2021-09-26 20:18     ` Bastien
  0 siblings, 0 replies; 6+ messages in thread
From: Bastien @ 2021-09-26 20:18 UTC (permalink / raw)
  To: Jim Porter; +Cc: emacs-orgmode

Jim Porter <jporterbugs@gmail.com> writes:

> On 9/25/2021 10:58 PM, Bastien wrote:
>> I applied the patch adding the TINYCHANGE cookie, since the assignment
>> process isn't done yet.  Can you check with copyright-clerk@fsf.org if
>> it will be done anytime soon?
>
> I think I might be in the database as "James" though; that caused a
> similar hiccup when contributing to Emacs too.

Er, yes, that was it!  I've updated
https://orgmode.org/worg/org-contribute.html

Thanks,

-- 
 Bastien


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-09-26 20:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-18 19:38 [PATCH] Improve org-mouse support for checkboxes Jim Porter
2021-09-18 20:54 ` Samuel Wales
2021-09-18 22:47   ` Jim Porter
2021-09-26  5:58 ` Bastien
2021-09-26 18:11   ` Jim Porter
2021-09-26 20:18     ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).