Forráskód Böngészése

Fixed some corner-case when inserting item.

Nicolas Goaziou 14 éve
szülő
commit
905ad49e9a
2 módosított fájl, 20 hozzáadás és 12 törlés
  1. 19 11
      lisp/org-list.el
  2. 1 1
      lisp/org-timer.el

+ 19 - 11
lisp/org-list.el

@@ -143,7 +143,7 @@ When nil, no bullet will have two spaces after them.
 When a string, it will be used as a regular expression. When the
 When a string, it will be used as a regular expression. When the
 bullet type of a list is changed, the new bullet type will be
 bullet type of a list is changed, the new bullet type will be
 matched against this regexp. If it matches, there will be two
 matched against this regexp. If it matches, there will be two
-spaces instead of one after the bullet in each item of he list."
+spaces instead of one after the bullet in each item of the list."
   :group 'org-plain-lists
   :group 'org-plain-lists
   :type '(choice
   :type '(choice
 	  (const :tag "never" nil)
 	  (const :tag "never" nil)
@@ -167,8 +167,8 @@ precedence over it."
 (defcustom org-auto-renumber-ordered-lists t
 (defcustom org-auto-renumber-ordered-lists t
   "Non-nil means automatically renumber ordered plain lists.
   "Non-nil means automatically renumber ordered plain lists.
 Renumbering happens when the sequence have been changed with
 Renumbering happens when the sequence have been changed with
-\\[org-shiftmetaup] or \\[org-shiftmetadown].  After other editing commands,
-use \\[org-ctrl-c-ctrl-c] to trigger renumbering."
+\\[org-shiftmetaup] or \\[org-shiftmetadown].  After other editing
+commands, use \\[org-ctrl-c-ctrl-c] to trigger renumbering."
   :group 'org-plain-lists
   :group 'org-plain-lists
   :type 'boolean)
   :type 'boolean)
 
 
@@ -366,7 +366,7 @@ function end."
 		    (1+ (org-back-over-empty-lines))
 		    (1+ (org-back-over-empty-lines))
 		  0))))))
 		  0))))))
 	 (insert-fun
 	 (insert-fun
-	  (lambda (&optional text)
+	  (lambda (text)
 	    ;; insert bullet above item in order to avoid bothering
 	    ;; insert bullet above item in order to avoid bothering
 	    ;; with possible blank lines ending last item.
 	    ;; with possible blank lines ending last item.
 	    (org-beginning-of-item)
 	    (org-beginning-of-item)
@@ -381,13 +381,13 @@ function end."
     (goto-char true-pos)
     (goto-char true-pos)
     (cond
     (cond
      (before-p
      (before-p
-      (funcall insert-fun)
+      (funcall insert-fun nil)
       ;; Not taking advantage of renumbering while moving down. Need
       ;; Not taking advantage of renumbering while moving down. Need
       ;; to call it directly.
       ;; to call it directly.
       (org-maybe-renumber-ordered-list) t)
       (org-maybe-renumber-ordered-list) t)
      ;; Can't split item: insert bullet at the end of item.
      ;; Can't split item: insert bullet at the end of item.
      ((not (org-get-alist-option org-M-RET-may-split-line 'item))
      ((not (org-get-alist-option org-M-RET-may-split-line 'item))
-      (funcall insert-fun) t)
+      (funcall insert-fun nil) t)
      ;; else, insert a new bullet along with everything from point
      ;; else, insert a new bullet along with everything from point
      ;; down to last non-blank line of item.
      ;; down to last non-blank line of item.
      (t
      (t
@@ -395,10 +395,16 @@ function end."
       ;; Get pos again in case previous command modified line.
       ;; Get pos again in case previous command modified line.
       (let* ((pos (point))
       (let* ((pos (point))
 	     (end-before-blank (org-end-of-item-before-blank))
 	     (end-before-blank (org-end-of-item-before-blank))
-	     (after-text (when (< pos end-before-blank)
-			   (prog1
-			       (buffer-substring pos end-before-blank)
-			     (delete-region pos end-before-blank)))))
+	     (after-text
+	      (when (< pos end-before-blank)
+		(prog1
+		    (buffer-substring pos end-before-blank)
+		  (delete-region pos end-before-blank)
+		  ;; delete any blank line at and before point.
+		  (beginning-of-line)
+		  (while (looking-at "^[ \t]*$")
+		    (delete-region (point-at-bol) (1+ (point-at-eol)))
+		    (backward-char))))))
 	(funcall insert-fun after-text) t)))))
 	(funcall insert-fun after-text) t)))))
 
 
 ;;; Predicates
 ;;; Predicates
@@ -696,7 +702,9 @@ things worked, nil when we are not in an item, or item is
 invisible."
 invisible."
   (unless (or (not (org-in-item-p))
   (unless (or (not (org-in-item-p))
 	      (org-invisible-p))
 	      (org-invisible-p))
-    (if (org-at-item-timer-p)
+    (if (save-excursion
+	  (org-beginning-of-item)
+	  (org-at-item-timer-p))
 	;; Timer list: delegate to `org-timer-item'.
 	;; Timer list: delegate to `org-timer-item'.
 	(progn (org-timer-item) t)
 	(progn (org-timer-item) t)
       ;; if we're in a description list, ask for the new term.
       ;; if we're in a description list, ask for the new term.

+ 1 - 1
lisp/org-timer.el

@@ -203,7 +203,7 @@ it in the buffer."
   (cond
   (cond
    ;; In a timer list, insert with `org-insert-item-internal'.
    ;; In a timer list, insert with `org-insert-item-internal'.
    ((and (org-in-item-p)
    ((and (org-in-item-p)
-	 (org-at-item-timer-p))
+	 (save-excursion (org-beginning-of-item) (org-at-item-timer-p)))
     (org-insert-item-internal
     (org-insert-item-internal
      (point) nil (concat (org-timer (when arg '(4)) t) ":: ")))
      (point) nil (concat (org-timer (when arg '(4)) t) ":: ")))
    ;; In a list of another type, don't break anything: throw an error.
    ;; In a list of another type, don't break anything: throw an error.