浏览代码

Small code enhancement

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

* lisp/org-list.el (org-at-radio-list-p): Respect the
attributes #+ATTR_* syntax.
Bastien 5 年之前
父节点
当前提交
eaa220f6a7
共有 3 个文件被更改,包括 14 次插入13 次删除
  1. 5 5
      doc/org-manual.org
  2. 1 1
      etc/ORG-NEWS
  3. 8 7
      lisp/org-list.el

+ 5 - 5
doc/org-manual.org

@@ -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~) ::

+ 1 - 1
etc/ORG-NEWS

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

+ 8 - 7
lisp/org-list.el

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