]> code.delx.au - gnu-emacs/blobdiff - lisp/textmodes/remember.el
Merge from emacs-24; up to 2012-04-24T08:35:02Z!lekktu@gmail.com
[gnu-emacs] / lisp / textmodes / remember.el
index 1fd830afac706faae04d9fdc3820e313ab712204..6500160a7d3c2f0d8836283f790131d76dd8c06d 100644 (file)
@@ -1,20 +1,19 @@
 ;;; remember --- a mode for quickly jotting down things to remember
 
-;; Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007,
-;;   2008  Free Software Foundation, Inc.
+;; Copyright (C) 1999-2001, 2003-2012  Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw@gnu.org>
 ;; Created: 29 Mar 1999
-;; Version: 1.9
+;; Version: 2.0
 ;; Keywords: data memory todo pim
 ;; URL: http://gna.org/projects/remember-el/
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -22,9 +21,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
 ;;  - Allowing particular views of the initially amorphous data pool
 ;;    (ala the Xanadu concept).
 ;;
-;;  - Storage of the data in a manner most appopriate to that data,
+;;  - Storage of the data in a manner most appropriate to that data,
 ;;    such as keeping address-book type information in BBDB, etc.
 ;;
 ;; * Using "remember"
 
 (provide 'remember)
 
-(defconst remember-version "1.9"
+(defconst remember-version "2.0"
   "This version of remember.")
 
 (defgroup remember nil
   :group 'remember)
 
 (defcustom remember-filter-functions nil
-  "*Functions run to filter remember data.
+  "Functions run to filter remember data.
 All functions are run in the remember buffer."
   :type 'hook
   :group 'remember)
 
 (defcustom remember-handler-functions '(remember-append-to-file)
-  "*Functions run to process remember data.
+  "Functions run to process remember data.
 Each function is called with the current buffer narrowed to what the
 user wants remembered.
 If any function returns non-nil, the data is assumed to have been
@@ -228,8 +225,7 @@ recorded somewhere by that function. "
   :group 'remember)
 
 (defcustom remember-all-handler-functions nil
-  "If non-nil every function in `remember-handler-functions' is
-called."
+  "If non-nil every function in `remember-handler-functions' is called."
   :type 'boolean
   :group 'remember)
 
@@ -239,7 +235,7 @@ called."
   "The name of the remember data entry buffer.")
 
 (defcustom remember-save-after-remembering t
-  "*Non-nil means automatically save after remembering."
+  "Non-nil means automatically save after remembering."
   :type 'boolean
   :group 'remember)
 
@@ -262,8 +258,7 @@ called."
   :group 'remember)
 
 (defcustom remember-run-all-annotation-functions-flag nil
-  "Non-nil means use all annotations returned by
-`remember-annotation-functions'."
+  "Non-nil means use all annotations returned by `remember-annotation-functions'."
   :type 'boolean
   :group 'remember)
 
@@ -319,12 +314,6 @@ With a prefix or a visible region, use the region as INITIAL."
   (let ((remember-in-new-frame t))
     (remember initial)))
 
-(defsubst remember-time-to-seconds (time)
-  "Convert TIME to a floating point number."
-  (+ (* (car time) 65536.0)
-     (cadr time)
-     (/ (or (car (cdr (cdr time))) 0) 1000000.0)))
-
 (defsubst remember-mail-date (&optional rfc822-p)
   "Return a simple date.  Nothing fancy."
   (if rfc822-p
@@ -344,23 +333,22 @@ With a prefix or a visible region, use the region as INITIAL."
 ;; Remembering to UNIX mailboxes
 
 (defcustom remember-mailbox "~/Mail/remember"
-  "*The file in which to store remember data as mail."
+  "The file in which to store remember data as mail."
   :type 'file
   :group 'remember)
 
 (defcustom remember-default-priority "medium"
-  "*The default priority for remembered mail messages."
+  "The default priority for remembered mail messages."
   :type 'string
   :group 'remember)
 
 (defun remember-store-in-mailbox ()
   "Store remember data as if it were incoming mail.
 In which case `remember-mailbox' should be the name of the mailbox.
-Each piece of psuedo-mail created will have an `X-Todo-Priority'
+Each piece of pseudo-mail created will have an `X-Todo-Priority'
 field, for the purpose of appropriate splitting."
   (let ((who (read-string "Who is this item related to? "))
-        (moment
-         (format "%.0f" (remember-time-to-seconds (current-time))))
+        (moment (format "%.0f" (float-time)))
         (desc (remember-buffer-desc))
         (text (buffer-string)))
     (with-temp-buffer
@@ -392,13 +380,13 @@ Subject: %s\n\n"
 
 ;; Remembering to plain files
 
-(defcustom remember-data-file "~/.notes"
-  "*The file in which to store unprocessed data."
+(defcustom remember-data-file (convert-standard-filename "~/.notes")
+  "The file in which to store unprocessed data."
   :type 'file
   :group 'remember)
 
 (defcustom remember-leader-text "** "
-  "*The text used to begin each remember item."
+  "The text used to begin each remember item."
   :type 'string
   :group 'remember)
 
@@ -428,7 +416,7 @@ that was entered.
 If BEG and END are nil, the entire buffer will be remembered.
 
 If you want to remember a region, supply a universal prefix to
-`remember' instead.  For example: C-u M-x remember RET."
+`remember' instead.  For example: \\[universal-argument] \\[remember] RET."
   ;; Sacha: I have no idea where remember.el gets this context information, but
   ;; you can just use remember-annotation-functions.
   (interactive)
@@ -455,7 +443,7 @@ application."
   (remember-region (point-min) (point-max)))
 
 ;; Org needs this
-(define-obsolete-function-alias 'remember-buffer 'remember-finalize)
+(define-obsolete-function-alias 'remember-buffer 'remember-finalize "23.1")
 
 (defun remember-destroy ()
   "Destroy the current *Remember* buffer."
@@ -467,7 +455,7 @@ application."
 ;;; Diary integration
 
 (defcustom remember-diary-file nil
-  "*File for extracted diary entries.
+  "File for extracted diary entries.
 If this is nil, then `diary-file' will be used instead."
   :type 'file
   :group 'remember)
@@ -478,28 +466,33 @@ If this is nil, then `diary-file' will be used instead."
     (when remember-annotation
         (setq entry (concat entry " " remember-annotation)))
     (if (string-match "\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)" entry)
-        (replace-match
-         (let ((style (if (boundp 'calendar-date-style)
-                          calendar-date-style
-                        ;; Don't complain about obsoleteness.
-                        (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) "-"
-                          (match-string 2 entry) "-"
-                          (match-string 3 entry)))
-                 (t (concat (match-string 2 entry) "/"
-                            (match-string 3 entry) "/"
-                            (match-string 1 entry)))))
-         t t entry)
+        (progn
+          ;; For calendar-date-style.  This costs us nothing because
+          ;; the call to diary-make-entry below loads diary-lib
+          ;; 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) "-"
+                            (match-string 2 entry) "-"
+                            (match-string 3 entry)))
+                   (t (concat (match-string 2 entry) "/"
+                              (match-string 3 entry) "/"
+                              (match-string 1 entry)))))
+           t t entry))
       entry)))
 
-(autoload 'make-diary-entry "diary-lib")
+(autoload 'diary-make-entry "diary-lib")
 
 ;;;###autoload
 (defun remember-diary-extract-entries ()
@@ -510,8 +503,8 @@ If this is nil, then `diary-file' will be used instead."
       (while (re-search-forward "^DIARY:\\s-*\\(.+\\)" nil t)
         (add-to-list 'list (remember-diary-convert-entry (match-string 1))))
       (when list
-        (make-diary-entry (mapconcat 'identity list "\n")
-                          nil (or remember-diary-file diary-file)))
+        (diary-make-entry (mapconcat 'identity list "\n")
+                          nil remember-diary-file))
       nil))) ;; Continue processing
 
 ;;; Internal Functions:
@@ -521,25 +514,17 @@ If this is nil, then `diary-file' will be used instead."
     (define-key map "\C-x\C-s" 'remember-finalize)
     (define-key map "\C-c\C-c" 'remember-finalize)
     (define-key map "\C-c\C-k" 'remember-destroy)
-
     map)
   "Keymap used in Remember mode.")
 
-(defun remember-mode ()
+(define-derived-mode remember-mode indented-text-mode "Remember"
   "Major mode for output from \\[remember].
 This buffer is used to collect data that you want to remember.
-
-Just hit `C-c C-c' when you're done entering, and it will file
+\\<remember-mode-map>
+Just hit \\[remember-finalize] when you're done entering, and it will file
 the data away for latter retrieval, and possible indexing.
 
 \\{remember-mode-map}"
-  (interactive)
-  (kill-all-local-variables)
-  (indented-text-mode)
-  (use-local-map remember-mode-map)
-  (setq major-mode 'remember-mode
-        mode-name "Remember")
-  (run-hooks 'remember-mode-hook))
-
-;; arch-tag: 59312a05-06c7-4da1-b6f7-5ea41c9d5577
+  (set-keymap-parent remember-mode-map nil))
+
 ;;; remember.el ends here