aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Nazarewicz2013-06-30 18:29:23 -0400
committerStefan Monnier2013-06-30 18:29:23 -0400
commitef099a941f7fb2d74ce1768388463f18b284f9c5 (patch)
tree1573bfacf90fc940c297c5428c132e9e65318716
parent6d89e343ab402851d94e37b2ca79a67e4c6fb474 (diff)
downloademacs-ef099a941f7fb2d74ce1768388463f18b284f9c5.tar.gz
emacs-ef099a941f7fb2d74ce1768388463f18b284f9c5.zip
Add `remember-notes' function to store random notes across Emacs
restarts. * remember.el (remember-data-file): Add :set callback to affect notes buffer (if any). (remember-notes): New command. (remember-notes-buffer-name, bury-remember-notes-on-kill): New defcustoms for the `remember-notes' function. (remember-notes-save-and-bury-buffer): New command. (remember-notes-mode-map): New variable. (remember-mode): New minor mode. (remember-notes--kill-buffer-query): New function. * lisp/startup.el (initial-buffer-choice): Add notes to custom type. * src/buffer.c (FKill_buffer): Run `kill-buffer-query-functions' before checking whether buffer is modified. This lets `kill-buffer-query-functions' cancel killing of the buffer or save its content before `kill-buffer' asks user the "Buffer %s modified; kill anyway?" question. * remember.el (remember-append-to-file): Don't mix `find-buffer-visiting' and `get-file-buffer'. * lisp/files.el (find-file-noselect): Simplify conditional expression.
-rw-r--r--doc/lispref/buffers.texi2
-rw-r--r--etc/NEWS8
-rw-r--r--lisp/ChangeLog33
-rw-r--r--lisp/files.el13
-rw-r--r--lisp/startup.el3
-rw-r--r--lisp/textmodes/remember.el133
-rw-r--r--src/ChangeLog34
-rw-r--r--src/buffer.c28
-rw-r--r--src/xdisp.c2
9 files changed, 207 insertions, 49 deletions
diff --git a/doc/lispref/buffers.texi b/doc/lispref/buffers.texi
index 40fd0176116..01269851250 100644
--- a/doc/lispref/buffers.texi
+++ b/doc/lispref/buffers.texi
@@ -1065,7 +1065,7 @@ Buffer foo.changed modified; kill anyway? (yes or no) @kbd{yes}
1065@end deffn 1065@end deffn
1066 1066
1067@defvar kill-buffer-query-functions 1067@defvar kill-buffer-query-functions
1068After confirming unsaved changes, @code{kill-buffer} calls the functions 1068Before confirming unsaved changes, @code{kill-buffer} calls the functions
1069in the list @code{kill-buffer-query-functions}, in order of appearance, 1069in the list @code{kill-buffer-query-functions}, in order of appearance,
1070with no arguments. The buffer being killed is the current buffer when 1070with no arguments. The buffer being killed is the current buffer when
1071they are called. The idea of this feature is that these functions will 1071they are called. The idea of this feature is that these functions will
diff --git a/etc/NEWS b/etc/NEWS
index c8bf903c579..3a8ef2314a8 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -90,6 +90,14 @@ simply disabling Transient Mark mode does the same thing.
90** `initial-buffer-choice' can now specify a function to set up the 90** `initial-buffer-choice' can now specify a function to set up the
91initial buffer. 91initial buffer.
92 92
93** `remember-notes' creates a buffer whose content is saved on kill-emacs.
94You may think of it as a *scratch* buffer whose content is preserved.
95In fact, it was designed as a replacement for *scratch* buffer and can
96be used that way by setting `initial-buffer-choice' to `remember-notes'
97and `remember-notes-buffer-name' to "*scratch*". Without the second
98change, *scratch* buffer will still be there for notes that do not
99need to be preserved.
100
93** `write-region-inhibit-fsync' now defaults to t in batch mode. 101** `write-region-inhibit-fsync' now defaults to t in batch mode.
94 102
95** ACL support has been added. 103** ACL support has been added.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c9582b1c81b..1234e513a96 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,18 +1,37 @@
12013-06-30 Michal Nazarewicz <mina86@mina86.com>
2
3 * files.el (find-file-noselect): Simplify conditional expression.
4
5 * remember.el (remember-append-to-file):
6 Don't mix `find-buffer-visiting' and `get-file-buffer'.
7
8 Add `remember-notes' function to store random notes across Emacs
9 restarts.
10 * remember.el (remember-data-file): Add :set callback to affect
11 notes buffer (if any).
12 (remember-notes): New command.
13 (remember-notes-buffer-name, bury-remember-notes-on-kill):
14 New defcustoms for the `remember-notes' function.
15 (remember-notes-save-and-bury-buffer): New command.
16 (remember-notes-mode-map): New variable.
17 (remember-mode): New minor mode.
18 (remember-notes--kill-buffer-query): New function.
19 * startup.el (initial-buffer-choice): Add notes to custom type.
20
12013-06-30 Eli Zaretskii <eliz@gnu.org> 212013-06-30 Eli Zaretskii <eliz@gnu.org>
2 22
3 * bindings.el (right-char, left-char): Don't call sit-for, this is 23 * bindings.el (right-char, left-char): Don't call sit-for, this is
4 no longer needed. Use arithmetic comparison only for numerical 24 no longer needed. Use arithmetic comparison only for numerical
5 arguments. 25 arguments.
6 26
7 * international/mule-cmds.el (select-safe-coding-system): Handle 27 * international/mule-cmds.el (select-safe-coding-system):
8 the case of FROM being a string correctly. (Bug#14755) 28 Handle the case of FROM being a string correctly. (Bug#14755)
9 29
102013-06-30 Lars Magne Ingebrigtsen <larsi@gnus.org> 302013-06-30 Lars Magne Ingebrigtsen <larsi@gnus.org>
11 31
12 * net/shr.el (shr-make-table-1): Add a sanity check that allows 32 * net/shr.el (shr-make-table-1): Add a sanity check that allows
13 progression on degenerate tables. 33 progression on degenerate tables.
14 (shr-rescale-image): ImageMagick animated images currently doesn't 34 (shr-rescale-image): ImageMagick animated images currently don't work.
15 work.
16 35
172013-06-30 Juanma Barranquero <lekktu@gmail.com> 362013-06-30 Juanma Barranquero <lekktu@gmail.com>
18 37
@@ -28,8 +47,8 @@
28 47
292013-06-30 Dmitry Gutov <dgutov@yandex.ru> 482013-06-30 Dmitry Gutov <dgutov@yandex.ru>
30 49
31 * progmodes/ruby-mode.el (ruby-syntax-propertize-function): Don't 50 * progmodes/ruby-mode.el (ruby-syntax-propertize-function):
32 start heredoc inside a string or comment. 51 Don't start heredoc inside a string or comment.
33 52
342013-06-29 Eli Zaretskii <eliz@gnu.org> 532013-06-29 Eli Zaretskii <eliz@gnu.org>
35 54
@@ -80,7 +99,7 @@
80 99
812013-06-27 Lars Magne Ingebrigtsen <larsi@gnus.org> 1002013-06-27 Lars Magne Ingebrigtsen <larsi@gnus.org>
82 101
83 * net/shr.el (add-face-text-property): Removed compat definition. 102 * net/shr.el (add-face-text-property): Remove compat definition.
84 103
852013-06-27 Stephen Berman <stephen.berman@gmx.net> 1042013-06-27 Stephen Berman <stephen.berman@gmx.net>
86 105
diff --git a/lisp/files.el b/lisp/files.el
index 871a4b0548b..e59a9acb7b9 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -1859,13 +1859,12 @@ the various files."
1859 (setq buffer-read-only read-only))) 1859 (setq buffer-read-only read-only)))
1860 (setq buffer-file-read-only read-only)) 1860 (setq buffer-file-read-only read-only))
1861 1861
1862 (when (and (not (eq (not (null rawfile)) 1862 (unless (or (eq (null rawfile) (null find-file-literally))
1863 (not (null find-file-literally)))) 1863 nonexistent
1864 (not nonexistent) 1864 ;; It is confusing to ask whether to visit
1865 ;; It is confusing to ask whether to visit 1865 ;; non-literally if they have the file in
1866 ;; non-literally if they have the file in 1866 ;; hexl-mode or image-mode.
1867 ;; hexl-mode or image-mode. 1867 (memq major-mode '(hexl-mode image-mode)))
1868 (not (memq major-mode '(hexl-mode image-mode))))
1869 (if (buffer-modified-p) 1868 (if (buffer-modified-p)
1870 (if (y-or-n-p 1869 (if (y-or-n-p
1871 (format 1870 (format
diff --git a/lisp/startup.el b/lisp/startup.el
index 77b2bcec5b7..44eea7745f7 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -53,7 +53,8 @@ or directory when no target file is specified."
53 (const :tag "Startup screen" nil) 53 (const :tag "Startup screen" nil)
54 (directory :tag "Directory" :value "~/") 54 (directory :tag "Directory" :value "~/")
55 (file :tag "File" :value "~/.emacs") 55 (file :tag "File" :value "~/.emacs")
56 (function :tag "Function") 56 (const :tag "Notes buffer" remember-notes)
57 (function :tag "Function")
57 (const :tag "Lisp scratch buffer" t)) 58 (const :tag "Lisp scratch buffer" t))
58 :version "24.4" 59 :version "24.4"
59 :group 'initialization) 60 :group 'initialization)
diff --git a/lisp/textmodes/remember.el b/lisp/textmodes/remember.el
index 5782f25e48d..39f3acd2c4c 100644
--- a/lisp/textmodes/remember.el
+++ b/lisp/textmodes/remember.el
@@ -382,8 +382,18 @@ Subject: %s\n\n"
382;; Remembering to plain files 382;; Remembering to plain files
383 383
384(defcustom remember-data-file (locate-user-emacs-file "notes" ".notes") 384(defcustom remember-data-file (locate-user-emacs-file "notes" ".notes")
385 "The file in which to store unprocessed data." 385 "The file in which to store unprocessed data.
386When set via customize, visited file of the notes buffer (if it
387exists) might be changed."
386 :type 'file 388 :type 'file
389 :set (lambda (symbol value)
390 (let ((buf (find-buffer-visiting (default-value symbol))))
391 (set-default symbol value)
392 (when (buffer-live-p buf)
393 (with-current-buffer buf
394 (set-visited-file-name
395 (expand-file-name remember-data-file))))))
396 :initialize 'custom-initialize-default
387 :group 'remember) 397 :group 'remember)
388 398
389(defcustom remember-leader-text "** " 399(defcustom remember-leader-text "** "
@@ -393,21 +403,20 @@ Subject: %s\n\n"
393 403
394(defun remember-append-to-file () 404(defun remember-append-to-file ()
395 "Remember, with description DESC, the given TEXT." 405 "Remember, with description DESC, the given TEXT."
396 (let ((text (buffer-string)) 406 (let* ((text (buffer-string))
397 (desc (remember-buffer-desc))) 407 (desc (remember-buffer-desc))
398 (with-temp-buffer 408 (remember-text (concat "\n" remember-leader-text (current-time-string)
399 (insert "\n" remember-leader-text (current-time-string) 409 " (" desc ")\n\n" text
400 " (" desc ")\n\n" text) 410 (save-excursion (goto-char (point-max))
401 (if (not (bolp)) 411 (if (bolp) nil "\n"))))
402 (insert "\n")) 412 (buf (find-buffer-visiting remember-data-file)))
403 (if (find-buffer-visiting remember-data-file) 413 (if buf
404 (let ((remember-text (buffer-string))) 414 (with-current-buffer buf
405 (set-buffer (get-file-buffer remember-data-file)) 415 (save-excursion
406 (save-excursion 416 (goto-char (point-max))
407 (goto-char (point-max)) 417 (insert remember-text))
408 (insert remember-text) 418 (if remember-save-after-remembering (save-buffer)))
409 (when remember-save-after-remembering (save-buffer)))) 419 (append-to-file remember-text nil remember-data-file))))
410 (append-to-file (point-min) (point-max) remember-data-file)))))
411 420
412(defun remember-region (&optional beg end) 421(defun remember-region (&optional beg end)
413 "Remember the data from BEG to END. 422 "Remember the data from BEG to END.
@@ -551,4 +560,96 @@ the data away for latter retrieval, and possible indexing.
551\\{remember-mode-map}" 560\\{remember-mode-map}"
552 (set-keymap-parent remember-mode-map nil)) 561 (set-keymap-parent remember-mode-map nil))
553 562
563;; Notes buffer showing the notes:
564
565(defcustom remember-notes-buffer-name "*notes*"
566 "Name of the notes buffer.
567Setting it to *scratch* will hijack the *scratch* buffer for the
568purpose of storing notes."
569 :type 'string
570 :version "24.4")
571
572(defcustom remember-notes-initial-major-mode nil
573 "Major mode to set to notes buffer when it's created.
574If set to nil will use the same mode as `initial-major-mode'."
575 :type '(choice (const :tag "Same as `initial-major-mode'" nil)
576 (function :tag "Major mode" text-mode))
577 :version "24.4")
578
579(defcustom remember-notes-bury-on-kill t
580 "Whether to bury notes buffer instead of killing."
581 :type 'boolean
582 :version "24.4")
583
584(defun remember-notes-save-and-bury-buffer ()
585 "Saves and buries current buffer.
586Buffer is saved only if `buffer-modified-p' returns non-nil."
587 (interactive)
588 (when (buffer-modified-p)
589 (save-buffer))
590 (bury-buffer))
591
592
593
594(defvar remember-notes-mode-map
595 (let ((map (make-sparse-keymap)))
596 (define-key map "\C-c\C-c" 'remember-notes-save-and-bury-buffer)
597 map)
598 "Keymap used in remember-notes mode.")
599
600(define-minor-mode remember-notes-mode
601 "Minor mode for the `remember-notes' buffer."
602 nil nil nil
603 (cond
604 (remember-notes-mode
605 (add-hook 'kill-buffer-query-functions
606 #'remember-notes--kill-buffer-query nil t)
607 (setq buffer-save-without-query t))))
608
609;;;###autoload
610(defun remember-notes (&optional switch-to)
611 "Creates notes buffer and switches to it if called interactively.
612
613If a notes buffer created by a previous invocation of this
614function already exist, it will be returned. Otherwise a new
615buffer will be created whose content will be read from file
616pointed by `remember-data-file'. If a buffer visiting this file
617already exist, that buffer will be used instead of creating a new
618one (see `find-file-noselect' function for more details).
619
620Name of the created buffer is taken from `remember-notes-buffer-name'
621variable and if a buffer with that name already exist (but was not
622created by this function), it will be first killed.
623\\<remember-notes-mode-map>
624`remember-notes-mode' is active in the notes buffer which by default
625contains only one \\[save-and-bury-buffer] binding which saves and
626buries the buffer.
627
628Function returns notes buffer. When called interactively,
629switches to it as well.
630
631Notes buffer is meant for keeping random notes which you'd like to
632preserve across Emacs restarts. The notes will be stored in the
633`remember-data-file'."
634 (interactive "p")
635 (let ((buf (or (find-buffer-visiting remember-data-file)
636 (with-current-buffer (find-file-noselect remember-data-file)
637 (and remember-notes-buffer-name
638 (not (get-buffer remember-notes-buffer-name))
639 (rename-buffer remember-notes-buffer-name))
640 (funcall (or remember-notes-initial-major-mode
641 initial-major-mode))
642 (remember-notes-mode 1)
643 (current-buffer)))))
644 (when switch-to
645 (switch-to-buffer buf))
646 buf))
647
648(defun remember-notes--kill-buffer-query ()
649 (when (buffer-modified-p)
650 (save-buffer))
651 (if remember-notes-bury-on-kill
652 (bury-buffer)
653 t))
654
554;;; remember.el ends here 655;;; remember.el ends here
diff --git a/src/ChangeLog b/src/ChangeLog
index 9dc1b989e3f..8b3f98fe9f3 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
12013-06-30 Michal Nazarewicz <mina86@mina86.com>
2
3 * buffer.c (FKill_buffer): Run `kill-buffer-query-functions'
4 before checking whether buffer is modified. This lets
5 `kill-buffer-query-functions' cancel killing of the buffer or save
6 its content before `kill-buffer' asks user the "Buffer %s
7 modified; kill anyway?" question.
8
12013-06-30 Jan Djärv <jan.h.d@swipnet.se> 92013-06-30 Jan Djärv <jan.h.d@swipnet.se>
2 10
3 * nsfns.m (handlePanelKeys): Don't process Command+Function keys. 11 * nsfns.m (handlePanelKeys): Don't process Command+Function keys.
@@ -59,6 +67,24 @@
59 :prefer-utf-8. 67 :prefer-utf-8.
60 (syms_of_coding): Adjust for coding_arg_undecided_max. 68 (syms_of_coding): Adjust for coding_arg_undecided_max.
61 69
702013-06-28 Kenichi Handa <handa@gnu.org>
71
72 * coding.h (define_coding_undecided_arg_index): New enum.
73 (coding_attr_index): New members
74 coding_attr_undecided_inhibit_null_byte_detection,
75 coding_attr_undecided_inhibit_iso_escape_detection,
76 coding_attr_undecided_prefer_utf_8.
77 (undecided_spec): New struct.
78 (struct coding_system): New member `undecided' of the member `spec'.
79
80 * coding.c (setup_coding_system): Handle CODING->spec.undecided.
81 (detect_coding): Likewise.
82 (detect_coding_system): Likewise.
83 (Fdefine_coding_system_internal): New coding system properties
84 :inhibit-null-byte-detection, :inhibit-iso-escape-detection, and
85 :prefer-utf-8.
86 (syms_of_coding): Adjust for coding_arg_undecided_max.
87
622013-06-28 Paul Eggert <eggert@cs.ucla.edu> 882013-06-28 Paul Eggert <eggert@cs.ucla.edu>
63 89
64 * image.c (x_from_xcolors): Remove unused local. 90 * image.c (x_from_xcolors): Remove unused local.
@@ -75,8 +101,8 @@
75 (x_clear_image_1): New arg `flags' instead of 3 bools `pixmap_p', 101 (x_clear_image_1): New arg `flags' instead of 3 bools `pixmap_p',
76 `mask_p', and `colors_p'. All uses changed. 102 `mask_p', and `colors_p'. All uses changed.
77 (x_clear_image_1) [HAVE_X_WINDOWS]: Destroy `ximg' and `mask_img'. 103 (x_clear_image_1) [HAVE_X_WINDOWS]: Destroy `ximg' and `mask_img'.
78 (CLEAR_IMAGE_PIXMAP, CLEAR_IMAGE_MASK, CLEAR_IMAGE_COLORS): New 104 (CLEAR_IMAGE_PIXMAP, CLEAR_IMAGE_MASK, CLEAR_IMAGE_COLORS):
79 macros for `flags' arg to x_clear_image_1. 105 New macros for `flags' arg to x_clear_image_1.
80 (postprocess_image, xpm_load_image, x_build_heuristic_mask) 106 (postprocess_image, xpm_load_image, x_build_heuristic_mask)
81 (png_load_body): Use x_clear_image_1 instead of Free_Pixmap. 107 (png_load_body): Use x_clear_image_1 instead of Free_Pixmap.
82 (ZPixmap, XGetImage) [HAVE_NS]: Remove. 108 (ZPixmap, XGetImage) [HAVE_NS]: Remove.
@@ -343,7 +369,7 @@
343 * textprop.c (property_set_type): New enum. 369 * textprop.c (property_set_type): New enum.
344 (add_properties): Allow appending/prepending text properties. 370 (add_properties): Allow appending/prepending text properties.
345 (add_text_properties_1): Factored out of Fadd_text_properties. 371 (add_text_properties_1): Factored out of Fadd_text_properties.
346 (Fadd_text_properties): Moved all the code into 372 (Fadd_text_properties): Move all the code into
347 add_text_properties_1. 373 add_text_properties_1.
348 (Fadd_face_text_property): New function that calls 374 (Fadd_face_text_property): New function that calls
349 add_text_properties_1. 375 add_text_properties_1.
@@ -914,7 +940,7 @@
914 (Fxw_color_values): Use EmacsCGFloat 940 (Fxw_color_values): Use EmacsCGFloat
915 (Fns_display_monitor_attributes_list): Only get screen number for 941 (Fns_display_monitor_attributes_list): Only get screen number for
916 Cocoa. 942 Cocoa.
917 (getDirectory, getFilename): Removed from EmacsOpenPanel and 943 (getDirectory, getFilename): Remove from EmacsOpenPanel and
918 EmacsSavePanel. 944 EmacsSavePanel.
919 (EmacsOpenPanel:ok:): Use ns_filename_from_panel and 945 (EmacsOpenPanel:ok:): Use ns_filename_from_panel and
920 ns_directory_from_panel. 946 ns_directory_from_panel.
diff --git a/src/buffer.c b/src/buffer.c
index 08299daa7dc..ad670e0a121 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1734,18 +1734,6 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1734 if (!BUFFER_LIVE_P (b)) 1734 if (!BUFFER_LIVE_P (b))
1735 return Qnil; 1735 return Qnil;
1736 1736
1737 /* Query if the buffer is still modified. */
1738 if (INTERACTIVE && !NILP (BVAR (b, filename))
1739 && BUF_MODIFF (b) > BUF_SAVE_MODIFF (b))
1740 {
1741 GCPRO1 (buffer);
1742 tem = do_yes_or_no_p (format2 ("Buffer %s modified; kill anyway? ",
1743 BVAR (b, name), make_number (0)));
1744 UNGCPRO;
1745 if (NILP (tem))
1746 return Qnil;
1747 }
1748
1749 /* Run hooks with the buffer to be killed the current buffer. */ 1737 /* Run hooks with the buffer to be killed the current buffer. */
1750 { 1738 {
1751 ptrdiff_t count = SPECPDL_INDEX (); 1739 ptrdiff_t count = SPECPDL_INDEX ();
@@ -1761,6 +1749,22 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1761 if (NILP (tem)) 1749 if (NILP (tem))
1762 return unbind_to (count, Qnil); 1750 return unbind_to (count, Qnil);
1763 1751
1752 /* Query if the buffer is still modified. */
1753 if (INTERACTIVE && !NILP (BVAR (b, filename))
1754 && BUF_MODIFF (b) > BUF_SAVE_MODIFF (b))
1755 {
1756 GCPRO1 (buffer);
1757 tem = do_yes_or_no_p (format2 ("Buffer %s modified; kill anyway? ",
1758 BVAR (b, name), make_number (0)));
1759 UNGCPRO;
1760 if (NILP (tem))
1761 return unbind_to (count, Qnil);
1762 }
1763
1764 /* If the hooks have killed the buffer, exit now. */
1765 if (!BUFFER_LIVE_P (b))
1766 return unbind_to (count, Qt);
1767
1764 /* Then run the hooks. */ 1768 /* Then run the hooks. */
1765 Frun_hooks (1, &Qkill_buffer_hook); 1769 Frun_hooks (1, &Qkill_buffer_hook);
1766 unbind_to (count, Qnil); 1770 unbind_to (count, Qnil);
diff --git a/src/xdisp.c b/src/xdisp.c
index 89761a0cfdc..3fa80336a61 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -20110,7 +20110,7 @@ Value is the new character position of point. */)
20110 w->cursor.vpos = -1; 20110 w->cursor.vpos = -1;
20111 return make_number (PT); 20111 return make_number (PT);
20112 } 20112 }
20113 else if (!INTEGERP (g->object) && g->object != gpt->object) 20113 else if (!INTEGERP (g->object) && !EQ (g->object, gpt->object))
20114 { 20114 {
20115 ptrdiff_t new_pos; 20115 ptrdiff_t new_pos;
20116 20116