Structure editing: Improved item/headline conversion
The conversion commands `C-c -' and `C-c *' are now better behaved and therefore more useful, I hope. If there is an active region, these commands will act on the region, otherwise on the current line. - C-c - :: This command turns headings or normal lines into items, or items into normal lines. When there is a region, everything depends on the first line of the region: - if it is a item, turn all items in the region into normal lines. - if it is a headline, turn all headlines in the region into items. - if it is a normal line, turn all lines into items. - special case: if there is no active region and the current line is an item, cycle the bullet type of the current list. - C-c * :: This command turns items and normal lines into headings, or headings into normal lines. When there is a region, everything depends on the first line of the region: - if it is a item, turn all items in the region into headlines. - if it is a headline, turn all headlines in the region into normal lines. - if it is a normal line, turn all lines into headlines.
This commit is contained in:
parent
039d28fbb0
commit
ac2347589e
|
@ -10,11 +10,45 @@
|
||||||
#+LINK_UP: index.html
|
#+LINK_UP: index.html
|
||||||
#+LINK_HOME: http://orgmode.org
|
#+LINK_HOME: http://orgmode.org
|
||||||
|
|
||||||
* Version 6.18
|
* Version 6.19 (in preparation)
|
||||||
|
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:VISIBILITY: content
|
:VISIBILITY: content
|
||||||
:END:
|
:END:
|
||||||
|
|
||||||
|
** Details
|
||||||
|
|
||||||
|
*** Improved behavior of conversion commands =C-c -= and =C-c *=
|
||||||
|
|
||||||
|
The conversion commands =C-c -= and =C-c *= are now better
|
||||||
|
behaved and therefore more useful, I hope.
|
||||||
|
|
||||||
|
If there is an active region, these commands will act on the
|
||||||
|
region, otherwise on the current line.
|
||||||
|
|
||||||
|
- C-c - :: This command turns headings or normal lines into
|
||||||
|
items, or items into normal lines. When there is a
|
||||||
|
region, everything depends on the first line of the
|
||||||
|
region:
|
||||||
|
- if it is a item, turn all items in the region into
|
||||||
|
normal lines.
|
||||||
|
- if it is a headline, turn all headlines in the region
|
||||||
|
into items.
|
||||||
|
- if it is a normal line, turn all lines into items.
|
||||||
|
- special case: if there is no active region and the
|
||||||
|
current line is an item, cycle the bullet type of the
|
||||||
|
current list.
|
||||||
|
- C-c * :: This command turns items and normal lines into
|
||||||
|
headings, or headings into normal lines. When there is
|
||||||
|
a region, everything depends on the first line of the
|
||||||
|
region:
|
||||||
|
- if it is a item, turn all items in the region into
|
||||||
|
headlines.
|
||||||
|
- if it is a headline, turn all headlines in the region
|
||||||
|
into normal lines.
|
||||||
|
- if it is a normal line, turn all lines into headlines.
|
||||||
|
|
||||||
|
* Version 6.18
|
||||||
** Incompatible changes
|
** Incompatible changes
|
||||||
|
|
||||||
*** Short examples must have a space after the colon
|
*** Short examples must have a space after the colon
|
||||||
|
|
|
@ -995,10 +995,11 @@ Narrow buffer to current subtree.
|
||||||
Widen buffer to remove a narrowing.
|
Widen buffer to remove a narrowing.
|
||||||
@kindex C-c *
|
@kindex C-c *
|
||||||
@item C-c *
|
@item C-c *
|
||||||
Turn a normal line or plain list item into a headline (so that it
|
Turn a normal line or plain list item into a headline (so that it becomes a
|
||||||
becomes a subheading at its location). Also turn a headline into a
|
subheading at its location). Also turn a headline into a normal line by
|
||||||
normal line by removing the stars. If there is an active region, turn
|
removing the stars. If there is an active region, turn all lines in the
|
||||||
all lines in the region into headlines. Or, if the first line is a
|
region into headlines. If the first line in the region was an item, turn
|
||||||
|
only the item lines into headlines. Finally, if the first line is a
|
||||||
headline, remove the stars from all headlines in the region.
|
headline, remove the stars from all headlines in the region.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
|
|
@ -308,17 +308,16 @@ are preserved on all copies.
|
||||||
\key{insert new heading after subtree}{C-RET}
|
\key{insert new heading after subtree}{C-RET}
|
||||||
\key{insert new TODO entry/checkbox item}{M-S-RET}
|
\key{insert new TODO entry/checkbox item}{M-S-RET}
|
||||||
\key{insert TODO entry/ckbx after subtree}{C-S-RET}
|
\key{insert TODO entry/ckbx after subtree}{C-S-RET}
|
||||||
|
\key{turn (head)line into item, cycle item type}{C-c -}
|
||||||
|
\key{turn item/line into headline}{C-c *}
|
||||||
\key{promote/demote heading}{M-LEFT/RIGHT}
|
\key{promote/demote heading}{M-LEFT/RIGHT}
|
||||||
\metax{promote/demote current subtree}{M-S-LEFT/RIGHT}
|
\metax{promote/demote current subtree}{M-S-LEFT/RIGHT}
|
||||||
|
|
||||||
\key{move subtree/list item up/down}{M-S-UP/DOWN}
|
\metax{move subtree/list item up/down}{M-S-UP/DOWN}
|
||||||
\key{refile subtree}{C-c C-w}
|
\metax{refile subtree}{C-c C-w}
|
||||||
\key{kill subtree}{C-c C-x C-w}
|
\metax{kill/copy subtree}{C-c C-x C-w/M-w}
|
||||||
\key{copy subtree}{C-c C-x M-w}
|
|
||||||
\metax{yank subtree}{C-c C-x C-y or C-y}
|
\metax{yank subtree}{C-c C-x C-y or C-y}
|
||||||
\key{narrow buffer to current subtree}{C-x n s}
|
\metax{narrow buffer to subtree / widen}{C-x n s/w}
|
||||||
\key{widen restriction to full buffer}{C-x n w}
|
|
||||||
|
|
||||||
\section{Archiving}
|
\section{Archiving}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,9 @@ insert new heading/item at current level M-RET
|
||||||
insert new heading after subtree C-RET
|
insert new heading after subtree C-RET
|
||||||
insert new TODO entry/checkbox item M-S-RET
|
insert new TODO entry/checkbox item M-S-RET
|
||||||
insert TODO entry/ckbx after subtree C-S-RET
|
insert TODO entry/ckbx after subtree C-S-RET
|
||||||
|
turn (head)line into item, cycle bullet type C-c -
|
||||||
|
turn item/line into headline, and back into line C-c *
|
||||||
|
|
||||||
promote/demote current heading up one level M-LEFT/RIGHT
|
promote/demote current heading up one level M-LEFT/RIGHT
|
||||||
promote/demote current subtree up one level M-S-LEFT/RIGHT
|
promote/demote current subtree up one level M-S-LEFT/RIGHT
|
||||||
move subtree/list item up/down M-S-UP/DOWN
|
move subtree/list item up/down M-S-UP/DOWN
|
||||||
|
|
|
@ -1,5 +1,15 @@
|
||||||
2009-01-21 Carsten Dominik <carsten.dominik@gmail.com>
|
2009-01-21 Carsten Dominik <carsten.dominik@gmail.com>
|
||||||
|
|
||||||
|
* org.el (org-toggle-heading): Renamed from
|
||||||
|
`org-toggel-region-headings'.
|
||||||
|
No longer needs a region defined, but will use it if there is one.
|
||||||
|
(org-ctrl-c-star): Simplified, relying more on the internal
|
||||||
|
workings of `org-toggle-heading'.
|
||||||
|
(org-toggle-item): Renamed from `org-toggle-region-items'.
|
||||||
|
No longer needs a region defined, but will use it if there is one.
|
||||||
|
(org-ctrl-c-minus): Simplified, relying more on the inernal
|
||||||
|
workings of `org-toggle-item'.
|
||||||
|
|
||||||
* org-export-latex.el (org-export-latex-preprocess): Fix bug in
|
* org-export-latex.el (org-export-latex-preprocess): Fix bug in
|
||||||
environment detection. Also, do real changes only in unprotected
|
environment detection. Also, do real changes only in unprotected
|
||||||
places.
|
places.
|
||||||
|
|
132
lisp/org.el
132
lisp/org.el
|
@ -13266,65 +13266,47 @@ context. See the individual commands for more information."
|
||||||
|
|
||||||
(defun org-ctrl-c-star ()
|
(defun org-ctrl-c-star ()
|
||||||
"Compute table, or change heading status of lines.
|
"Compute table, or change heading status of lines.
|
||||||
Calls `org-table-recalculate' or `org-toggle-region-headings',
|
Calls `org-table-recalculate' or `org-toggle-heading',
|
||||||
depending on context. This will also turn a plain list item or a normal
|
depending on context."
|
||||||
line into a subheading."
|
|
||||||
(interactive)
|
(interactive)
|
||||||
(cond
|
(cond
|
||||||
((org-at-table-p)
|
((org-at-table-p)
|
||||||
(call-interactively 'org-table-recalculate))
|
(call-interactively 'org-table-recalculate))
|
||||||
((org-region-active-p)
|
(t
|
||||||
;; Convert all lines in region to list items
|
;; Convert all lines in region to list items
|
||||||
(call-interactively 'org-toggle-region-headings))
|
(call-interactively 'org-toggle-heading))))
|
||||||
((org-on-heading-p)
|
|
||||||
(org-toggle-region-headings (point-at-bol)
|
|
||||||
(min (1+ (point-at-eol)) (point-max))))
|
|
||||||
((org-at-item-p)
|
|
||||||
;; Convert to heading
|
|
||||||
(let ((level (save-match-data
|
|
||||||
(save-excursion
|
|
||||||
(condition-case nil
|
|
||||||
(progn
|
|
||||||
(org-back-to-heading t)
|
|
||||||
(funcall outline-level))
|
|
||||||
(error 0))))))
|
|
||||||
(replace-match
|
|
||||||
(concat (make-string (org-get-valid-level level 1) ?*) " ") t t)))
|
|
||||||
(t (org-toggle-region-headings (point-at-bol)
|
|
||||||
(min (1+ (point-at-eol)) (point-max))))))
|
|
||||||
|
|
||||||
(defun org-ctrl-c-minus ()
|
(defun org-ctrl-c-minus ()
|
||||||
"Insert separator line in table or modify bullet status of line.
|
"Insert separator line in table or modify bullet status of line.
|
||||||
Also turns a plain line or a region of lines into list items.
|
Also turns a plain line or a region of lines into list items.
|
||||||
Calls `org-table-insert-hline', `org-toggle-region-items', or
|
Calls `org-table-insert-hline', `org-toggle-item', or
|
||||||
`org-cycle-list-bullet', depending on context."
|
`org-cycle-list-bullet', depending on context."
|
||||||
(interactive)
|
(interactive)
|
||||||
(cond
|
(cond
|
||||||
((org-at-table-p)
|
((org-at-table-p)
|
||||||
(call-interactively 'org-table-insert-hline))
|
(call-interactively 'org-table-insert-hline))
|
||||||
((org-on-heading-p)
|
|
||||||
;; Convert to item
|
|
||||||
(save-excursion
|
|
||||||
(beginning-of-line 1)
|
|
||||||
(if (looking-at "\\*+ ")
|
|
||||||
(replace-match
|
|
||||||
(concat (make-string
|
|
||||||
(- (match-end 0) (point) (if org-odd-levels-only 2 1)) ?\ )
|
|
||||||
"- ")))))
|
|
||||||
((org-region-active-p)
|
((org-region-active-p)
|
||||||
;; Convert all lines in region to list items
|
(call-interactively 'org-toggle-item))
|
||||||
(call-interactively 'org-toggle-region-items))
|
|
||||||
((org-in-item-p)
|
((org-in-item-p)
|
||||||
(call-interactively 'org-cycle-list-bullet))
|
(call-interactively 'org-cycle-list-bullet))
|
||||||
(t (org-toggle-region-items (point-at-bol)
|
(t
|
||||||
(min (1+ (point-at-eol)) (point-max))))))
|
(call-interactively 'org-toggle-item))))
|
||||||
|
|
||||||
(defun org-toggle-region-items (beg end)
|
(defun org-toggle-item ()
|
||||||
"Convert all lines in region to list items.
|
"Convert headings or normal lines to items, items to normal lines.
|
||||||
If the first line is already an item, convert all list items in the region
|
If there is no active region, only the current line is considered.
|
||||||
to normal lines."
|
|
||||||
(interactive "r")
|
If the first line in the region is a headline, convert all headlines to items.
|
||||||
(let (l2 l)
|
|
||||||
|
If the first line in the region is an item, convert all items to normal lines.
|
||||||
|
|
||||||
|
If the first line is normal text, add an item bullet to each line."
|
||||||
|
(interactive)
|
||||||
|
(let (l2 l beg end)
|
||||||
|
(if (org-region-active-p)
|
||||||
|
(setq beg (region-beginning) end (region-end))
|
||||||
|
(setq beg (point-at-bol)
|
||||||
|
end (min (1+ (point-at-eol)) (point-max))))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char end)
|
(goto-char end)
|
||||||
(setq l2 (org-current-line))
|
(setq l2 (org-current-line))
|
||||||
|
@ -13339,18 +13321,41 @@ to normal lines."
|
||||||
(delete-region (match-beginning 2) (match-end 2))
|
(delete-region (match-beginning 2) (match-end 2))
|
||||||
(and (looking-at "[ \t]+") (replace-match "")))
|
(and (looking-at "[ \t]+") (replace-match "")))
|
||||||
(beginning-of-line 2))
|
(beginning-of-line 2))
|
||||||
(while (< (setq l (1+ l)) l2)
|
(if (org-on-heading-p)
|
||||||
(unless (org-at-item-p)
|
;; Headings, convert to items
|
||||||
(if (looking-at "\\([ \t]*\\)\\(\\S-\\)")
|
(while (< (setq l (1+ l)) l2)
|
||||||
(replace-match "\\1- \\2")))
|
(if (looking-at org-outline-regexp)
|
||||||
(beginning-of-line 2))))))
|
(replace-match "- " t t))
|
||||||
|
(beginning-of-line 2))
|
||||||
|
;; normal lines, turn them into items
|
||||||
|
(while (< (setq l (1+ l)) l2)
|
||||||
|
(unless (org-at-item-p)
|
||||||
|
(if (looking-at "\\([ \t]*\\)\\(\\S-\\)")
|
||||||
|
(replace-match "\\1- \\2")))
|
||||||
|
(beginning-of-line 2)))))))
|
||||||
|
|
||||||
(defun org-toggle-region-headings (beg end)
|
(defun org-toggle-heading (&optional nstars)
|
||||||
"Convert all lines in region to list items.
|
"Convert headings to normal text, or items or text to headings.
|
||||||
If the first line is already an item, convert all list items in the region
|
If there is no active region, only the current line is considered.
|
||||||
to normal lines."
|
|
||||||
(interactive "r")
|
If the first line is a heading, remove the stars from all headlines
|
||||||
(let (l2 l)
|
in the region.
|
||||||
|
|
||||||
|
If the first line is a plain list item, turn all plain list items into
|
||||||
|
headings.
|
||||||
|
|
||||||
|
If the first line is a normal line, turn each and every line in the region
|
||||||
|
into a heading.
|
||||||
|
|
||||||
|
When converting a line into a heading, the number of stars is chosen
|
||||||
|
such that the lines become children of the current entry. However, when
|
||||||
|
a prefix argument is given, its value determines the number of stars to add."
|
||||||
|
(interactive "P")
|
||||||
|
(let (l2 l itemp beg end)
|
||||||
|
(if (org-region-active-p)
|
||||||
|
(setq beg (region-beginning) end (region-end))
|
||||||
|
(setq beg (point-at-bol)
|
||||||
|
end (min (1+ (point-at-eol)) (point-max))))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char end)
|
(goto-char end)
|
||||||
(setq l2 (org-current-line))
|
(setq l2 (org-current-line))
|
||||||
|
@ -13363,15 +13368,22 @@ to normal lines."
|
||||||
(when (org-on-heading-p t)
|
(when (org-on-heading-p t)
|
||||||
(and (looking-at outline-regexp) (replace-match "")))
|
(and (looking-at outline-regexp) (replace-match "")))
|
||||||
(beginning-of-line 2))
|
(beginning-of-line 2))
|
||||||
(let* ((stars (save-excursion
|
(setq itemp (org-at-item-p))
|
||||||
(re-search-backward org-complex-heading-regexp nil t)
|
(let* ((stars
|
||||||
(or (match-string 1) "*")))
|
(if nstars
|
||||||
(add-stars (if org-odd-levels-only "**" "*"))
|
(make-string (prefix-numeric-value current-prefix-arg)
|
||||||
(rpl (concat stars add-stars " \\2")))
|
?*)
|
||||||
|
(save-excursion
|
||||||
|
(re-search-backward org-complex-heading-regexp nil t)
|
||||||
|
(or (match-string 1) "*"))))
|
||||||
|
(add-stars (if nstars "" (if org-odd-levels-only "**" "*")))
|
||||||
|
(rpl (concat stars add-stars " ")))
|
||||||
(while (< (setq l (1+ l)) l2)
|
(while (< (setq l (1+ l)) l2)
|
||||||
(unless (org-on-heading-p)
|
(if itemp
|
||||||
(if (looking-at "\\([ \t]*\\)\\(\\S-\\)")
|
(and (org-at-item-p) (replace-match rpl t t))
|
||||||
(replace-match rpl)))
|
(unless (org-on-heading-p)
|
||||||
|
(if (looking-at "\\([ \t]*\\)\\(\\S-\\)")
|
||||||
|
(replace-match (concat rpl (match-string 2))))))
|
||||||
(beginning-of-line 2)))))))
|
(beginning-of-line 2)))))))
|
||||||
|
|
||||||
(defun org-meta-return (&optional arg)
|
(defun org-meta-return (&optional arg)
|
||||||
|
|
Loading…
Reference in New Issue