mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2025-01-30 20:41:41 +00:00
org-list: Allow multiple receiver locations for radio lists
* lisp/org-list.el (org-list-send-list): Allow multiple receiver locations. * testing/lisp/test-org-list.el (test-org-list/send-list): Add test.
This commit is contained in:
parent
3781a3dbbd
commit
ee7ca3cc43
@ -3066,7 +3066,7 @@ for this list."
|
||||
"[ \t]*#\\+ORGLST:[ \t]+SEND[ \t]+\\(\\S-+\\)[ \t]+\\([^ \t\n]+\\)")
|
||||
(if maybe (throw 'exit nil)
|
||||
(error "Don't know how to transform this list")))))
|
||||
(let* ((name (match-string 1))
|
||||
(let* ((name (regexp-quote (match-string 1)))
|
||||
(transform (intern (match-string 2)))
|
||||
(bottom-point
|
||||
(save-excursion
|
||||
@ -3080,29 +3080,32 @@ for this list."
|
||||
(match-beginning 0)))
|
||||
(plain-list (save-excursion
|
||||
(goto-char top-point)
|
||||
(org-list-to-lisp)))
|
||||
beg)
|
||||
(org-list-to-lisp))))
|
||||
(unless (fboundp transform)
|
||||
(error "No such transformation function %s" transform))
|
||||
(let ((txt (funcall transform plain-list)))
|
||||
;; Find the insertion place
|
||||
;; Find the insertion(s) place(s).
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(unless (re-search-forward
|
||||
(concat "BEGIN RECEIVE ORGLST +"
|
||||
name
|
||||
"\\([ \t]\\|$\\)")
|
||||
nil t)
|
||||
(error "Don't know where to insert translated list"))
|
||||
(goto-char (match-beginning 0))
|
||||
(beginning-of-line 2)
|
||||
(setq beg (point))
|
||||
(unless (re-search-forward (concat "END RECEIVE ORGLST +" name) nil t)
|
||||
(error "Cannot find end of insertion region"))
|
||||
(delete-region beg (point-at-bol))
|
||||
(goto-char beg)
|
||||
(insert txt "\n")))
|
||||
(message "List converted and installed at receiver location"))))
|
||||
(let ((receiver-count 0)
|
||||
(begin-re (format "BEGIN +RECEIVE +ORGLST +%s\\([ \t]\\|$\\)"
|
||||
name))
|
||||
(end-re (format "END +RECEIVE +ORGLST +%s\\([ \t]\\|$\\)"
|
||||
name)))
|
||||
(while (re-search-forward begin-re nil t)
|
||||
(cl-incf receiver-count)
|
||||
(let ((beg (line-beginning-position 2)))
|
||||
(unless (re-search-forward end-re nil t)
|
||||
(user-error "Cannot find end of receiver location at %d" beg))
|
||||
(beginning-of-line)
|
||||
(delete-region beg (point))
|
||||
(insert txt "\n")))
|
||||
(cond
|
||||
((> receiver-count 1)
|
||||
(message "List converted and installed at receiver locations"))
|
||||
((= receiver-count 1)
|
||||
(message "List converted and installed at receiver location"))
|
||||
(t (user-error "No valid receiver location found")))))))))
|
||||
|
||||
(defun org-list-to-generic (list params)
|
||||
"Convert a LIST parsed through `org-list-to-lisp' to a custom format.
|
||||
|
@ -906,7 +906,23 @@
|
||||
- item
|
||||
@end ignore"
|
||||
(forward-line 3)
|
||||
(org-list-send-list))))
|
||||
(org-list-send-list)))
|
||||
;; Allow multiple receiver locations.
|
||||
(should
|
||||
(org-test-with-temp-text "
|
||||
@c BEGIN RECEIVE ORGLST list
|
||||
@c END RECEIVE ORGLST list
|
||||
|
||||
@ignore
|
||||
#+ORGLST: SEND list org-list-to-texinfo
|
||||
<point>- item contents
|
||||
@end ignore
|
||||
|
||||
@c BEGIN RECEIVE ORGLST list
|
||||
@c END RECEIVE ORGLST list"
|
||||
(org-list-send-list)
|
||||
(goto-char (point-min))
|
||||
(search-forward "item contents" nil t 3))))
|
||||
|
||||
(ert-deftest test-org-list/to-generic ()
|
||||
"Test `org-list-to-generic' specifications."
|
||||
|
Loading…
Reference in New Issue
Block a user