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:
parent
4028cc731b
commit
eaa220f6a7
|
@ -4537,14 +4537,14 @@ The following commands work with checkboxes:
|
||||||
#+findex: org-toggle-radio-button
|
#+findex: org-toggle-radio-button
|
||||||
#+cindex: radio button, checkbox as
|
#+cindex: radio button, checkbox as
|
||||||
Toggle checkbox status by using the checkbox of the item at point 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
|
a radio button: when the checkbox is turned on, all other checkboxes
|
||||||
level will be turned off. With a universal prefix argument, toggle
|
on the same level will be turned off. With a universal prefix
|
||||||
the presence of the checkbox. With a double prefix argument, set it
|
argument, toggle the presence of the checkbox. With a double prefix
|
||||||
to =[-]=.
|
argument, set it to =[-]=.
|
||||||
|
|
||||||
#+findex: org-list-checkbox-radio-mode
|
#+findex: org-list-checkbox-radio-mode
|
||||||
{{{kdb(C-c C-c)}}} can be told to consider checkboxes as radio buttons by
|
{{{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-x org-list-checkbox-radio-mode)}}} to activate this minor mode.
|
||||||
|
|
||||||
- {{{kbd(M-S-RET)}}} (~org-insert-todo-heading~) ::
|
- {{{kbd(M-S-RET)}}} (~org-insert-todo-heading~) ::
|
||||||
|
|
|
@ -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
|
without turning this minor mode on, you can use =<C-c C-x C-r>= to
|
||||||
call ~org-toggle-radio-button~.
|
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.
|
Org to use radio buttons for this list only.
|
||||||
|
|
||||||
*** Looping agenda commands over headlines
|
*** Looping agenda commands over headlines
|
||||||
|
|
|
@ -2339,13 +2339,14 @@ is an integer, 0 means `-', 1 means `+' etc. If WHICH is
|
||||||
|
|
||||||
(defsubst org-at-radio-list-p ()
|
(defsubst org-at-radio-list-p ()
|
||||||
"Is point in a list with radio buttons?"
|
"Is point in a list with radio buttons?"
|
||||||
(let (attr)
|
(when (org-at-item-p)
|
||||||
(save-excursion
|
(let (attr)
|
||||||
(org-at-item-p)
|
(save-excursion
|
||||||
(goto-char (caar (org-list-struct)))
|
(goto-char (caar (org-list-struct)))
|
||||||
(org-backward-element)
|
(org-backward-element)
|
||||||
(setq attr (car (org-element-property :attr_org (org-element-at-point))))
|
(setq attr (org-export-read-attribute
|
||||||
(when attr (string-match-p ":radio" attr)))))
|
:attr_org (org-element-at-point))))
|
||||||
|
(when (plist-get attr :radio) t))))
|
||||||
|
|
||||||
(defun org-toggle-checkbox (&optional toggle-presence)
|
(defun org-toggle-checkbox (&optional toggle-presence)
|
||||||
"Toggle the checkbox in the current line.
|
"Toggle the checkbox in the current line.
|
||||||
|
|
Loading…
Reference in New Issue