org-list: Change `org-list-to-subtree' signature
* lisp/org-list.el (org-list-to-subtree): Add optional argument to specify level of the subtree. (org-list-make-subtree): * lisp/org.el (org-toggle-heading): Adapt to signature change. Reported-by: Felix Wiemuth <felixwiemuth@hotmail.de> <http://lists.gnu.org/r/emacs-orgmode/2019-06/msg00010.html>
This commit is contained in:
parent
bba9116cb8
commit
0ff65e9f4c
|
@ -246,6 +246,9 @@ dynamic block in ~org-dynamic-block-alist~.
|
|||
It was unused throughout the code base.
|
||||
|
||||
** Miscellaneous
|
||||
*** Change signature for ~org-list-to-subtree~
|
||||
The function now accepts the level of the subtree as an optional
|
||||
argument. It no longer deduces it from the current level.
|
||||
*** LaTeX preview is simplified
|
||||
|
||||
Function ~org-latex-preview~, formerly known as
|
||||
|
|
|
@ -3153,10 +3153,14 @@ Point is left at list's end."
|
|||
(defun org-list-make-subtree ()
|
||||
"Convert the plain list at point into a subtree."
|
||||
(interactive)
|
||||
(if (not (ignore-errors (goto-char (org-in-item-p))))
|
||||
(error "Not in a list")
|
||||
(let ((list (save-excursion (org-list-to-lisp t))))
|
||||
(insert (org-list-to-subtree list) "\n"))))
|
||||
(let ((item (org-in-item-p)))
|
||||
(unless item (error "Not in a list"))
|
||||
(goto-char item)
|
||||
(let ((level (pcase (org-current-level)
|
||||
(`nil 1)
|
||||
(l (1+ (org-reduced-level l)))))
|
||||
(list (save-excursion (org-list-to-lisp t))))
|
||||
(insert (org-list-to-subtree list level) "\n"))))
|
||||
|
||||
(defun org-list-to-generic (list params)
|
||||
"Convert a LIST parsed through `org-list-to-lisp' to a custom format.
|
||||
|
@ -3465,21 +3469,22 @@ with overruling parameters for `org-list-to-generic'."
|
|||
:cbtrans "[-] ")))
|
||||
(org-list-to-generic list (org-combine-plists defaults params))))
|
||||
|
||||
(defun org-list-to-subtree (list &optional params)
|
||||
(defun org-list-to-subtree (list &optional start-level params)
|
||||
"Convert LIST into an Org subtree.
|
||||
LIST is as returned by `org-list-to-lisp'. PARAMS is a property
|
||||
list with overruling parameters for `org-list-to-generic'."
|
||||
LIST is as returned by `org-list-to-lisp'. Subtree starts at
|
||||
START-LEVEL or level 1 if nil. PARAMS is a property list with
|
||||
overruling parameters for `org-list-to-generic'."
|
||||
(let* ((blank (pcase (cdr (assq 'heading org-blank-before-new-entry))
|
||||
(`t t)
|
||||
(`auto (save-excursion
|
||||
(org-with-limited-levels (outline-previous-heading))
|
||||
(org-previous-line-empty-p)))))
|
||||
(level (org-reduced-level (or (org-current-level) 0)))
|
||||
(level (or start-level 1))
|
||||
(make-stars
|
||||
(lambda (_type depth &optional _count)
|
||||
;; Return the string for the heading, depending on DEPTH
|
||||
;; of current sub-list.
|
||||
(let ((oddeven-level (+ level depth)))
|
||||
(let ((oddeven-level (+ level (1- depth))))
|
||||
(concat (make-string (if org-odd-levels-only
|
||||
(1- (* 2 oddeven-level))
|
||||
oddeven-level)
|
||||
|
|
13
lisp/org.el
13
lisp/org.el
|
@ -18154,7 +18154,12 @@ number of stars to add."
|
|||
(min (org-list-get-bottom-point struct) (1+ end))))
|
||||
(save-restriction
|
||||
(narrow-to-region (point) list-end)
|
||||
(insert (org-list-to-subtree (org-list-to-lisp t)) "\n")))
|
||||
(insert (org-list-to-subtree
|
||||
(org-list-to-lisp t)
|
||||
(pcase (org-current-level)
|
||||
(`nil 1)
|
||||
(l (1+ (org-reduced-level l)))))
|
||||
"\n")))
|
||||
(setq toggled t))
|
||||
(forward-line)))
|
||||
;; Case 3. Started at normal text: make every line an heading,
|
||||
|
@ -18163,10 +18168,10 @@ number of stars to add."
|
|||
(make-string
|
||||
(if (numberp nstars) nstars (or (org-current-level) 0)) ?*))
|
||||
(add-stars
|
||||
(cond (nstars "") ; stars from prefix only
|
||||
((equal stars "") "*") ; before first heading
|
||||
(cond (nstars "") ; stars from prefix only
|
||||
((equal stars "") "*") ; before first heading
|
||||
(org-odd-levels-only "**") ; inside heading, odd
|
||||
(t "*"))) ; inside heading, oddeven
|
||||
(t "*"))) ; inside heading, oddeven
|
||||
(rpl (concat stars add-stars " "))
|
||||
(lend (when (listp nstars) (save-excursion (end-of-line) (point)))))
|
||||
(while (< (point) (if (equal nstars '(4)) lend end))
|
||||
|
|
Loading…
Reference in New Issue