bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#13567: 24.1; New remember back-end for storing data in multiple file


From: Reuben Thomas
Subject: bug#13567: 24.1; New remember back-end for storing data in multiple files
Date: Sun, 14 Apr 2013 21:16:39 +0100

On 14 April 2013 08:06, Bastien <address@hidden> wrote:
Hi,

Reuben Thomas <address@hidden> writes:

> I prefer to store my ideas in individual files rather than one big file;
> a simplified version of remember-store-in-mailbox achieves this:
>
> ;; Remember support for storing remember data in individual files.
> (defcustom remember-directory "~/remember"
>   "The directory in which to store remember data as files."
>   :type 'file
>   :group 'remember)

Better use remember-data-directory since there is remember-data-file?

> (defcustom remember-directory-file-name-format "%Y-%m-%d_%T-%z"
>   "The file in which to store unprocessed data."
>   :type 'file
>   :group 'remember)

The docstring needs an update.

> (defcustom remember-handler-functions '(remember-append-to-file)
>   "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
> recorded somewhere by that function. "
>   :type 'hook
>   :options '(remember-store-in-mailbox
>              remember-append-to-file
>              remember-store-in-files
>              remember-diary-extract-entries
>              org-remember-handler)
>   :group 'remember)
>
> (defun remember-store-in-files ()
>   "Store remember data in a file in the directory `remember-directory',
> in a file named by `remember-directory-file-name-format' fed through
> `format-time-string'."

The first line of the docstring should be a sentence.
You can use M-x checkdoc RET to catch those docstring errors.

>   (let ((moment (format-time-string remember-directory-file-name-format (current-time)))
>         (text (buffer-string)))
>     (with-temp-buffer
>       (insert text)
>       (write-file (convert-standard-filename
>                    (format "%s/%s" remember-directory moment))))))
>
> If you can use this code, I've already signed an Emacs copyright
> waiver.

Looks okay to me -- can you provide the change as a patch against
current remember.el?

I guess it's lucky I failed to push my commit earlier! Thanks very much for the review, modified patch below against bzr master tip.

=== modified file 'lisp/textmodes/remember.el'
--- lisp/textmodes/remember.el    2013-03-12 02:08:21 +0000
+++ lisp/textmodes/remember.el    2013-04-14 20:07:22 +0000
@@ -216,10 +216,11 @@
 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
-recorded somewhere by that function. "
+recorded somewhere by that function."
   :type 'hook
   :options '(remember-store-in-mailbox
              remember-append-to-file
+             remember-store-in-files
              remember-diary-extract-entries
              org-remember-handler)
   :group 'remember)
@@ -429,6 +430,30 @@
         (run-hook-with-args-until-success 'remember-handler-functions))
       (remember-destroy))))
 
+;; Remembering to individual files
+
+(defcustom remember-data-directory "~/remember"
+  "The directory in which to store remember data as files."
+  :type 'file
+  :group 'remember)
+
+(defcustom remember-directory-file-name-format "%Y-%m-%d_%T-%z"
+  "A `format-time-string' format for the file name in which to store
+unprocessed data."
+  :type 'file
+  :group 'remember)
+
+(defun remember-store-in-files ()
+  "Store remember data in a file in `remember-data-directory'.
+The file is named by `remember-directory-file-name-format' fed through
+`format-time-string'."
+  (let ((moment (format-time-string remember-directory-file-name-format (current-time)))
+        (text (buffer-string)))
+    (with-temp-buffer
+      (insert text)
+      (write-file (convert-standard-filename
+                   (format "%s/%s" remember-data-directory moment))))))
+
 ;;;###autoload
 (defun remember-clipboard ()
   "Remember the contents of the current clipboard.


--
http://rrt.sc3d.org

reply via email to

[Prev in Thread] Current Thread [Next in Thread]