Small code enhancement

* doc/org-manual.org (Checkboxes): Minor update.

* lisp/org-list.el (org-at-radio-list-p): Respect the
attributes #+ATTR_* syntax.
This commit is contained in:
Bastien 2020-02-12 08:40:46 +01:00
parent 4028cc731b
commit eaa220f6a7
3 changed files with 14 additions and 13 deletions

View File

@ -4537,14 +4537,14 @@ The following commands work with checkboxes:
#+findex: org-toggle-radio-button
#+cindex: radio button, checkbox as
Toggle checkbox status by using the checkbox of the item at point as
a radio button: when turned on, all other checkboxes on the same
level will be turned off. With a universal prefix argument, toggle
the presence of the checkbox. With a double prefix argument, set it
to =[-]=.
a radio button: when the checkbox is turned on, all other checkboxes
on the same level will be turned off. With a universal prefix
argument, toggle the presence of the checkbox. With a double prefix
argument, set it to =[-]=.
#+findex: org-list-checkbox-radio-mode
{{{kdb(C-c C-c)}}} can be told to consider checkboxes as radio buttons by
setting =#+ATTR_ORG: :radio= right before the list or by calling
setting =#+ATTR_ORG: :radio t= right before the list or by calling
{{{kbd(M-x org-list-checkbox-radio-mode)}}} to activate this minor mode.
- {{{kbd(M-S-RET)}}} (~org-insert-todo-heading~) ::

View File

@ -54,7 +54,7 @@ If you want to occasionally toggle a checkbox as a radio button
without turning this minor mode on, you can use =<C-c C-x C-r>= to
call ~org-toggle-radio-button~.
You can also add =#+ATTR_ORG: :radio= right before the list to tell
You can also add =#+ATTR_ORG: :radio t= right before the list to tell
Org to use radio buttons for this list only.
*** Looping agenda commands over headlines

View File

@ -2339,13 +2339,14 @@ is an integer, 0 means `-', 1 means `+' etc. If WHICH is
(defsubst org-at-radio-list-p ()
"Is point in a list with radio buttons?"
(let (attr)
(save-excursion
(org-at-item-p)
(goto-char (caar (org-list-struct)))
(org-backward-element)
(setq attr (car (org-element-property :attr_org (org-element-at-point))))
(when attr (string-match-p ":radio" attr)))))
(when (org-at-item-p)
(let (attr)
(save-excursion
(goto-char (caar (org-list-struct)))
(org-backward-element)
(setq attr (org-export-read-attribute
:attr_org (org-element-at-point))))
(when (plist-get attr :radio) t))))
(defun org-toggle-checkbox (&optional toggle-presence)
"Toggle the checkbox in the current line.