]> code.delx.au - gnu-emacs/blobdiff - lisp/textmodes/remember.el
* lisp/textmodes/flyspell.el: Use lexical-binding and cl-lib.
[gnu-emacs] / lisp / textmodes / remember.el
index a9eb7ad4ec87bfa7d2bea44641d658e2a863e63d..35eaffa9284b07218159fe919c1464c5597f560e 100644 (file)
@@ -1,8 +1,9 @@
 ;;; remember --- a mode for quickly jotting down things to remember
 
-;; Copyright (C) 1999-2001, 2003-2014 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2001, 2003-2015 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw@gnu.org>
+;; Maintainer: emacs-devel@gnu.org
 ;; Created: 29 Mar 1999
 ;; Version: 2.0
 ;; Keywords: data memory todo pim
 
 ;;; Code:
 
-(provide 'remember)
-
 (defconst remember-version "2.0"
   "This version of remember.")
 
@@ -230,6 +229,8 @@ recorded somewhere by that function."
   :type 'boolean
   :group 'remember)
 
+;; See below for more user variables.
+
 ;;; Internal Variables:
 
 (defvar remember-buffer "*Remember*"
@@ -318,9 +319,7 @@ With a prefix or a visible region, use the region as INITIAL."
 
 (defsubst remember-mail-date (&optional rfc822-p)
   "Return a simple date.  Nothing fancy."
-  (if rfc822-p
-      (format-time-string "%a, %e %b %Y %T %z" (current-time))
-    (format-time-string "%a %b %e %T %Y" (current-time))))
+  (format-time-string (if rfc822-p "%a, %e %b %Y %T %z" "%a %b %e %T %Y")))
 
 (defun remember-buffer-desc ()
   "Using the first line of the current buffer, create a short description."
@@ -460,8 +459,7 @@ Used by `remember-store-in-files'."
   "Store remember data in a file in `remember-data-directory'.
 The file is named by calling `format-time-string' using
 `remember-directory-file-name-format' as the format string."
-  (let ((name (format-time-string
-              remember-directory-file-name-format (current-time)))
+  (let ((name (format-time-string remember-directory-file-name-format))
         (text (buffer-string)))
     (with-temp-buffer
       (insert text)
@@ -498,6 +496,8 @@ If this is nil, then `diary-file' will be used instead."
   :type '(choice (const :tag "diary-file" nil) file)
   :group 'remember)
 
+(defvar calendar-date-style)            ; calendar.el
+
 (defun remember-diary-convert-entry (entry)
   "Translate MSG to an entry readable by diary."
   (save-match-data
@@ -510,23 +510,17 @@ If this is nil, then `diary-file' will be used instead."
           ;; which requires calendar.
           (require 'calendar)
           (replace-match
-           (let ((style (if (boundp 'calendar-date-style)
-                            calendar-date-style
-                          ;; Don't complain about obsolescence.
-                          (if (with-no-warnings european-calendar-style)
-                              'european
-                            'american))))
-             (cond ((eq style 'european)
-                    (concat (match-string 3 entry) "/"
-                            (match-string 2 entry) "/"
-                            (match-string 1 entry)))
-                   ((eq style 'iso)
-                    (concat (match-string 1 entry) "-"
+           (cond ((eq calendar-date-style 'european)
+                  (concat (match-string 3 entry) "/"
+                          (match-string 2 entry) "/"
+                          (match-string 1 entry)))
+                 ((eq calendar-date-style 'iso)
+                  (concat (match-string 1 entry) "-"
                             (match-string 2 entry) "-"
                             (match-string 3 entry)))
-                   (t (concat (match-string 2 entry) "/"
-                              (match-string 3 entry) "/"
-                              (match-string 1 entry)))))
+                 (t (concat (match-string 2 entry) "/"
+                            (match-string 3 entry) "/"
+                            (match-string 1 entry))))
            t t entry))
       entry)))
 
@@ -553,7 +547,7 @@ If this is nil, then `diary-file' will be used instead."
     (define-key map "\C-c\C-c" 'remember-finalize)
     (define-key map "\C-c\C-k" 'remember-destroy)
     map)
-  "Keymap used in Remember mode.")
+  "Keymap used in `remember-mode'.")
 
 (define-derived-mode remember-mode indented-text-mode "Remember"
   "Major mode for output from \\[remember].
@@ -599,10 +593,14 @@ If this is nil, use `initial-major-mode'."
   (let ((map (make-sparse-keymap)))
     (define-key map "\C-c\C-c" 'remember-notes-save-and-bury-buffer)
     map)
-  "Keymap used in remember-notes mode.")
+  "Keymap used in `remember-notes-mode'.")
 
 (define-minor-mode remember-notes-mode
-  "Minor mode for the `remember-notes' buffer."
+  "Minor mode for the `remember-notes' buffer.
+This sets `buffer-save-without-query' so that `save-some-buffers' will
+save the notes buffer without asking.
+
+\\{remember-notes-mode-map}"
   nil nil nil
   (cond
    (remember-notes-mode
@@ -612,29 +610,25 @@ If this is nil, use `initial-major-mode'."
 
 ;;;###autoload
 (defun remember-notes (&optional switch-to)
-  "Creates notes buffer and switches to it if called interactively.
-
-If a notes buffer created by a previous invocation of this
-function already exist, it will be returned.  Otherwise a new
-buffer will be created whose content will be read from file
-pointed by `remember-data-file'.  If a buffer visiting this file
-already exist, that buffer will be used instead of creating a new
-one (see `find-file-noselect' function for more details).
-
-Name of the created buffer is taken from `remember-notes-buffer-name'
-variable and if a buffer with that name already exist (but was not
-created by this function), it will be first killed.
-\\<remember-notes-mode-map>
-`remember-notes-mode' is active in the notes buffer which by default
-contains only one \\[save-and-bury-buffer] binding which saves and
-buries the buffer.
-
-Function returns notes buffer.  When called interactively,
-switches to it as well.
-
-Notes buffer is meant for keeping random notes which you'd like to
-preserve across Emacs restarts.  The notes will be stored in the
-`remember-data-file'."
+  "Return the notes buffer, creating it if needed, and maybe switch to it.
+This buffer is for notes that you want to preserve across Emacs sessions.
+The notes are saved in `remember-data-file'.
+
+If a buffer is already visiting that file, just return it.
+
+Otherwise, create the buffer, and rename it to `remember-notes-buffer-name',
+unless a buffer of that name already exists.  Set the major mode according
+to `remember-notes-initial-major-mode', and enable `remember-notes-mode'
+minor mode.
+
+Use \\<remember-notes-mode-map>\\[remember-notes-save-and-bury-buffer] to save and bury the notes buffer.
+
+Interactively, or if SWITCH-TO is non-nil, switch to the buffer.
+Return the buffer.
+
+Set `initial-buffer-choice' to `remember-notes' to visit your notes buffer
+when Emacs starts.  Set `remember-notes-buffer-name' to \"*scratch*\"
+to turn the *scratch* buffer into your notes buffer."
   (interactive "p")
   (let ((buf (or (find-buffer-visiting remember-data-file)
                  (with-current-buffer (find-file-noselect remember-data-file)
@@ -662,4 +656,6 @@ is non-nil, bury it and return nil; otherwise return t."
         nil)
     t))
 
+(provide 'remember)
+
 ;;; remember.el ends here