emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* new list item minor bug
@ 2009-09-27 23:35 Dan Davison
  2009-09-27 23:41 ` Dan Davison
  2009-09-28  6:38 ` Carsten Dominik
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Davison @ 2009-09-27 23:35 UTC (permalink / raw)
  To: emacs org-mode mailing list

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: new list item minor bug
  2009-09-27 23:35 new list item minor bug Dan Davison
@ 2009-09-27 23:41 ` Dan Davison
  2009-09-28  6:38 ` Carsten Dominik
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Davison @ 2009-09-27 23:41 UTC (permalink / raw)
  To: emacs org-mode mailing list

Dan Davison <davison@stats.ox.ac.uk> 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.'.

Sorry, what I meant to say is that there is a space, but that point is
in front of the space.

> 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.
>
> 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)))
>  
> Dan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: new list item minor bug
  2009-09-27 23:35 new list item minor bug Dan Davison
  2009-09-27 23:41 ` Dan Davison
@ 2009-09-28  6:38 ` Carsten Dominik
  1 sibling, 0 replies; 3+ messages in thread
From: Carsten Dominik @ 2009-09-28  6:38 UTC (permalink / raw)
  To: Dan Davison; +Cc: emacs org-mode mailing list

Applied, thanks.

- Carsten

On Sep 28, 2009, at 12:35 AM, Dan Davison wrote:

> 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
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-09-28  7:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-27 23:35 new list item minor bug Dan Davison
2009-09-27 23:41 ` Dan Davison
2009-09-28  6:38 ` Carsten Dominik

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).