Browse Source

Abort remember if the remember buffer is empty

Following a report by Ryan C. Thompson
Carsten Dominik 16 years ago
parent
commit
28e95ee828
2 changed files with 15 additions and 2 deletions
  1. 3 0
      lisp/ChangeLog
  2. 12 2
      lisp/org-remember.el

+ 3 - 0
lisp/ChangeLog

@@ -1,5 +1,8 @@
 2009-06-08  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-remember.el (org-remember-handler): Abort remember if the
+	buffer is empty.
+
 	* org-src.el (org-edit-src-content-indentation): New option.
 	(org-edit-src-exit): Apply extra indentation.
 

+ 12 - 2
lisp/org-remember.el

@@ -788,11 +788,11 @@ See also the variable `org-reverse-note-order'."
     (replace-match ""))
   (goto-char (point-max))
   (beginning-of-line 1)
-  (while (looking-at "[ \t]*$\\|##.*")
+  (while (and (looking-at "[ \t]*$\\|##.*") (> (point) 1))
     (delete-region (1- (point)) (point-max))
     (beginning-of-line 1))
   (catch 'quit
-    (if org-note-abort (throw 'quit nil))
+    (if org-note-abort (throw 'quit t))
     (let* ((visitp (org-bound-and-true-p org-jump-to-target-location))
 	   (backup-file
 	    (and buffer-file-name
@@ -802,6 +802,16 @@ See also the variable `org-reverse-note-order'."
 		 (string-match "^remember-[0-9]\\{4\\}"
 			       (file-name-nondirectory buffer-file-name))
 		 buffer-file-name))
+
+	   (dummy
+	    (unless (string-match "\\S-" (buffer-string))
+	      (message "Nothing to remember")
+	      (and backup-file
+		   (ignore-errors
+		     (delete-file backup-file)
+		     (delete-file (concat backup-file "~"))))
+	      (set-buffer-modified-p nil)
+	      (throw 'quit t)))
 	   (previousp (and (member current-prefix-arg '((16) 0))
 			   org-remember-previous-location))
 	   (clockp (equal current-prefix-arg 2))