* [PATCH] Support auto-saving notes into it's own file.
@ 2013-08-23 21:25 Michal Nazarewicz
0 siblings, 0 replies; only message in thread
From: Michal Nazarewicz @ 2013-08-23 21:25 UTC (permalink / raw)
To: emacs-devel, Stefan Monnier
From: Michal Nazarewicz <mina86@mina86.com>
This change introduces a `remember-notes-auto-save-visited-file-name'
custom variable which, if non-nil, causes the `auto-save-visited-file-name'
variable to be set to t in the notes buffer. This is done by the
`remember-notes-mode' minor mode.
Moreover, it also modifies the `remember-notes' function so that buffer
whose name is specified by `remember-notes-buffer-name' variable will be
killed, if it exists, for use for the notes buffer. This is consistant
with the documentation.
Finally, as a minor change, to make `remember-notes' easier to discover,
some of the documentation strings were updated to use a "`remember-notes'
buffer" phrase rather than "notes buffer". With `remember-notes' being
a hyperlink, this should make it easier for users to go to function's
documentation.
---
lisp/ChangeLog | 12 ++++++++++++
lisp/textmodes/remember.el | 38 ++++++++++++++++++++++++++++----------
2 files changed, 40 insertions(+), 10 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 27242fa..46d8746 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
+2013-08-23 Michal Nazarewicz <mina86@mina86.com>
+
+ * textmodes/remember.el
+ (remember-notes-auto-save-visited-file-name): New custom variable
+ for setting whether user wants to auto-save notes into the notes
+ file itself.
+ (remember-notes-mode): Changed to make use of tho
+ remember-notes-auto-save-visited-file-name variable.
+ (remember-notes): Changed to hijack buffer whose name matches
+ `remember-notes-buffer-name' variable as per variable's and
+ function's documentation.
+
2013-08-23 Glenn Morris <rgm@gnu.org>
* files.el (auto-mode-alist): Use sh-mode for .bash_history.
diff --git a/lisp/textmodes/remember.el b/lisp/textmodes/remember.el
index 39f3acd..411dd60 100644
--- a/lisp/textmodes/remember.el
+++ b/lisp/textmodes/remember.el
@@ -383,8 +383,8 @@ Subject: %s\n\n"
(defcustom remember-data-file (locate-user-emacs-file "notes" ".notes")
"The file in which to store unprocessed data.
-When set via customize, visited file of the notes buffer (if it
-exists) might be changed."
+When set via customize, visited file of the `remember-notes' buffer
+\(if it exists) might be changed."
:type 'file
:set (lambda (symbol value)
(let ((buf (find-buffer-visiting (default-value symbol))))
@@ -563,22 +563,36 @@ the data away for latter retrieval, and possible indexing.
;; Notes buffer showing the notes:
(defcustom remember-notes-buffer-name "*notes*"
- "Name of the notes buffer.
+ "Name of the `remember-notes' buffer.
Setting it to *scratch* will hijack the *scratch* buffer for the
purpose of storing notes."
:type 'string
+ :group 'remember
:version "24.4")
(defcustom remember-notes-initial-major-mode nil
- "Major mode to set to notes buffer when it's created.
+ "Major mode to set to `remember-notes' buffer when it's created.
If set to nil will use the same mode as `initial-major-mode'."
:type '(choice (const :tag "Same as `initial-major-mode'" nil)
(function :tag "Major mode" text-mode))
+ :group 'remember
:version "24.4")
(defcustom remember-notes-bury-on-kill t
- "Whether to bury notes buffer instead of killing."
+ "Whether to bury `remember-notes' buffer instead of killing."
:type 'boolean
+ :group 'remember
+ :version "24.4")
+
+(defcustom remember-notes-auto-save-visited-file-name nil
+ "Whether to auto-save `remember-notes' buffer in the notes file itself.
+If non-nil, the contents of the `remember-notes' buffer will be saved
+in the visited file itself thus avoiding the existence of an auto-save
+file and \"consider M-x recover-this-file\" message. If set to nil,
+the value of the `auto-save-visited-file-name' variable will take
+effect."
+ :type 'boolean
+ :group 'remember
:version "24.4")
(defun remember-notes-save-and-bury-buffer ()
@@ -589,8 +603,6 @@ Buffer is saved only if `buffer-modified-p' returns non-nil."
(save-buffer))
(bury-buffer))
-
-
(defvar remember-notes-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "\C-c\C-c" 'remember-notes-save-and-bury-buffer)
@@ -602,6 +614,8 @@ Buffer is saved only if `buffer-modified-p' returns non-nil."
nil nil nil
(cond
(remember-notes-mode
+ (when remember-notes-auto-save-visited-file-name
+ (set (make-local-variable 'auto-save-visited-file-name) t))
(add-hook 'kill-buffer-query-functions
#'remember-notes--kill-buffer-query nil t)
(setq buffer-save-without-query t))))
@@ -625,8 +639,8 @@ created by this function), it will be first killed.
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.
+Function returns notes buffer. When called interactively, or
+SWITCH-TO is non-nil, 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
@@ -635,7 +649,11 @@ preserve across Emacs restarts. The notes will be stored in the
(let ((buf (or (find-buffer-visiting remember-data-file)
(with-current-buffer (find-file-noselect remember-data-file)
(and remember-notes-buffer-name
- (not (get-buffer remember-notes-buffer-name))
+ (not (string-equal remember-notes-buffer-name
+ (buffer-name)))
+ (let ((other (get-buffer remember-notes-buffer-name)))
+ (or (not other)
+ (kill-buffer other)))
(rename-buffer remember-notes-buffer-name))
(funcall (or remember-notes-initial-major-mode
initial-major-mode))
--
1.8.4.rc1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2013-08-23 21:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-23 21:25 [PATCH] Support auto-saving notes into it's own file Michal Nazarewicz
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).