diff options
author | Carsten Dominik <carsten.dominik@gmail.com> | 2009-09-28 07:37:31 +0100 |
---|---|---|
committer | Carsten Dominik <carsten.dominik@gmail.com> | 2009-09-28 07:37:50 +0100 |
commit | 44259b323181ec167bdbba1fd06cea24f7786374 (patch) | |
tree | 21366e3dc30a3b4aa43f8d5caded46b58e5762c5 | |
parent | dbd63e97238ed3150c8df0707e72e19a7ec80211 (diff) | |
download | org-mode-44259b323181ec167bdbba1fd06cea24f7786374.tar.gz |
Fix cursor position when bullet length has changed
Dan Davison writes:
> If you start a numbered list with
>
> 1.
>
> and hit M-RET then you get
>
> 2.
> ^
> with a space, i.e. '2. '
>
> However, when creating the 10th list item, there is no space after
> '10.'. Same for 99 -> 100. This isn't entirely trivial, because if you
> start typing blindly after hitting M-RET, then the line you have created
> (lacking the space) will not be recognised as a list item and so
> e.g. the next M-RET will create a new heading, not a list item. [Has
> this changed recently? This seems like something obvious that others
> would have noticed.]
>
> Here's my patch.
>
> --8<---------------cut here---------------start------------->8---
> diff --git a/lisp/org-list.el b/lisp/org-list.el
> index 2fea57b..8ece3ea 100644
> --- a/lisp/org-list.el
> +++ b/lisp/org-list.el
> @@ -813,7 +813,7 @@ with something like \"1.\" or \"2)\"."
> (buffer-substring (point-at-bol) (match-beginning 3))))
> ;; (term (substring (match-string 3) -1))
> ind1 (n (1- arg))
> - fmt bobp old new)
> + fmt bobp old new delta)
> ;; find where this list begins
> (org-beginning-of-item-list)
> (setq bobp (bobp))
> @@ -835,7 +835,9 @@ with something like \"1.\" or \"2)\"."
> (delete-region (match-beginning 2) (match-end 2))
> (goto-char (match-beginning 2))
> (insert (setq new (format fmt (setq n (1+ n)))))
> - (org-shift-item-indentation (- (length new) (length old))))))
> + (setq delta (- (length new) (length old)))
> + (org-shift-item-indentation delta)
> + (if (= (org-current-line) line) (setq col (+ col delta))))))
> (org-goto-line line)
> (org-move-to-column col)))
> --8<---------------cut here---------------end--------------->8---
>
> Dan
-rwxr-xr-x | lisp/ChangeLog | 5 | ||||
-rw-r--r-- | lisp/org-list.el | 6 |
2 files changed, 9 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c624cc8..9b64806 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2009-09-28 Carsten Dominik <carsten.dominik@gmail.com> + + * org-list.el (org-renumber-ordered-list): Fix cursor position + when bullet length has changed. + 2009-09-26 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-format-latex): Mention `org-format-latex-options' in diff --git a/lisp/org-list.el b/lisp/org-list.el index 2fea57b..8ece3ea 100644 --- a/lisp/org-list.el +++ b/lisp/org-list.el @@ -813,7 +813,7 @@ with something like \"1.\" or \"2)\"." (buffer-substring (point-at-bol) (match-beginning 3)))) ;; (term (substring (match-string 3) -1)) ind1 (n (1- arg)) - fmt bobp old new) + fmt bobp old new delta) ;; find where this list begins (org-beginning-of-item-list) (setq bobp (bobp)) @@ -835,7 +835,9 @@ with something like \"1.\" or \"2)\"." (delete-region (match-beginning 2) (match-end 2)) (goto-char (match-beginning 2)) (insert (setq new (format fmt (setq n (1+ n))))) - (org-shift-item-indentation (- (length new) (length old)))))) + (setq delta (- (length new) (length old))) + (org-shift-item-indentation delta) + (if (= (org-current-line) line) (setq col (+ col delta)))))) (org-goto-line line) (org-move-to-column col))) |