]> code.delx.au - gnu-emacs/commitdiff
Merge from origin/emacs-24
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 19 Jun 2015 23:45:50 +0000 (16:45 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 19 Jun 2015 23:45:50 +0000 (16:45 -0700)
a5e6f33 Fixes: debbugs:20832
b9f02cf Fixes: debbugs:20832

1  2 
lisp/calendar/todo-mode.el

index 7369ec28c290b25673f9f17feef8f167786fd9f3,c869727f4c19a60cab7c5a805f1cbe5ddca516e2..962f425ecf526aa676fbc5315fcf1e958afce67e
@@@ -672,7 -672,7 +672,7 @@@ corresponding todo file, displaying th
                                                      todo-filtered-items-mode))))
                          (if (funcall todo-files-function)
                              (todo-read-file-name "Choose a todo file to visit: "
-                                                   nil t)
+                                                  nil t)
                            (user-error "There are no todo files")))
                         ((and (eq major-mode 'todo-archive-mode)
                               ;; Called noninteractively via todo-quit
        (when (or (member file todo-visited)
                  (eq todo-show-first 'first))
          (unless (todo-check-file file) (throw 'end nil))
-         (set-window-buffer (selected-window)
+           ;; If todo-show is called from the minibuffer, don't visit
+           ;; the todo file there.
+         (set-window-buffer (if (minibufferp) (minibuffer-selected-window)
+                              (selected-window))
                             (set-buffer (find-file-noselect file 'nowarn)))
          (if (equal (file-name-extension (buffer-file-name)) "toda")
              (unless (derived-mode-p 'todo-archive-mode) (todo-archive-mode))
            (setq todo-category-number (todo-category-number cat)))
          ;; If this is a new todo file, add its first category.
          (when (zerop (buffer-size))
+             ;; Don't confuse an erased buffer with a fresh buffer for
+             ;; adding a new todo file -- it might have been erased by
+             ;; mistake or due to a bug (e.g. Bug#20832).
+             (when (buffer-modified-p)
+               (error "Buffer is empty but modified, please report a bug"))
            (let (cat-added)
              (unwind-protect
                  (setq todo-category-number
@@@ -2606,8 -2614,7 +2614,8 @@@ meaning to raise or lower the item's pr
            ;; separator.
            (when (looking-back (concat "^"
                                        (regexp-quote todo-category-done)
 -                                      "\n"))
 +                                      "\n")
 +                                (line-beginning-position 0))
              (todo-backward-item))))
        (todo-insert-with-overlays item)
        ;; If item was marked, restore the mark.
@@@ -4232,8 -4239,7 +4240,8 @@@ the values of FILTER and FILE-LIST.
                           (if (and (eobp)
                                    (looking-back
                                     (concat (regexp-quote todo-done-string)
 -                                           "\n")))
 +                                           "\n")
 +                                     (line-beginning-position 0)))
                               (delete-region (point) (progn
                                                        (forward-line -2)
                                                        (point))))))
@@@ -4650,7 -4656,7 +4658,7 @@@ name in `todo-directory'.  See also th
                ;; If the item ends with a non-comment parenthesis not
                ;; followed by a period, we lose (but we inherit that
                ;; problem from the legacy code).
 -              (when (looking-back "(\\(.*\\)) ")
 +              (when (looking-back "(\\(.*\\)) " (line-beginning-position))
                  (setq comment (match-string 1))
                  (replace-match "")
                  (insert "[" todo-comment-string ": " comment "]"))
@@@ -5344,8 -5350,7 +5352,8 @@@ of each other.
                     (looking-at todo-done-string-start)
                     (looking-back (concat "^"
                                           (regexp-quote todo-category-done)
 -                                         "\n")))
 +                                         "\n")
 +                                   (line-beginning-position 0)))
            (setq num 1
                  done t))
          (setq prefix (concat (propertize
@@@ -5443,7 -5448,7 +5451,7 @@@ dynamically create item insertion comma
  The list consists of item insertion parameters that can be passed
  as insertion command arguments in fixed positions.  If a position
  in the list is not occupied by the corresponding parameter, it is
 -occupied by `nil'."
 +occupied by nil."
    (let* ((arg (list (car todo-insert-item--args)))
         (args (nconc (cdr todo-insert-item--args)
                      (list (car (todo-insert-item--argsleft