aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2018-04-12 17:50:14 +0200
committerLars Ingebrigtsen2018-04-12 17:50:14 +0200
commitd9d90def6e76e445be965760705b75f9c01b83a5 (patch)
tree483f20481c1d7080687652958c023eefa734feb9
parentf4692fa290e4dca3a636f6872a9b4bc61797b008 (diff)
downloademacs-d9d90def6e76e445be965760705b75f9c01b83a5.tar.gz
emacs-d9d90def6e76e445be965760705b75f9c01b83a5.zip
Make it possible to exit Gnus without saving .newsrc.eld
* lisp/gnus/gnus-start.el (gnus-save-newsrc-file): Don't error out here so that we can proceed with shutting down Gnus without saving the .newsrc.eld file when it has been updated externally (bug#23761).
-rw-r--r--lisp/gnus/gnus-start.el128
1 files changed, 65 insertions, 63 deletions
diff --git a/lisp/gnus/gnus-start.el b/lisp/gnus/gnus-start.el
index bae01aca87d..a20a6e727db 100644
--- a/lisp/gnus/gnus-start.el
+++ b/lisp/gnus/gnus-start.el
@@ -2828,73 +2828,75 @@ If FORCE is non-nil, the .newsrc file is read."
2828 (erase-buffer) 2828 (erase-buffer)
2829 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file) 2829 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
2830 2830
2831 ;; check timestamp of `gnus-current-startup-file'.eld against 2831 ;; Check timestamp of `gnus-current-startup-file'.eld against
2832 ;; `gnus-save-newsrc-file-last-timestamp' 2832 ;; `gnus-save-newsrc-file-last-timestamp'.
2833 (let* ((checkfile (concat gnus-current-startup-file ".eld")) 2833 (if (let* ((checkfile (concat gnus-current-startup-file ".eld"))
2834 (mtime (nth 5 (file-attributes checkfile)))) 2834 (mtime (nth 5 (file-attributes checkfile))))
2835 (when (and gnus-save-newsrc-file-last-timestamp 2835 (and gnus-save-newsrc-file-last-timestamp
2836 (time-less-p gnus-save-newsrc-file-last-timestamp 2836 (time-less-p gnus-save-newsrc-file-last-timestamp
2837 mtime)) 2837 mtime)
2838 (unless (y-or-n-p 2838 (not
2839 (y-or-n-p
2839 (format "%s was updated externally after %s, save?" 2840 (format "%s was updated externally after %s, save?"
2840 checkfile 2841 checkfile
2841 (format-time-string 2842 (format-time-string
2842 "%c" 2843 "%c"
2843 gnus-save-newsrc-file-last-timestamp))) 2844 gnus-save-newsrc-file-last-timestamp))))))
2844 (error "Couldn't save %s: updated externally" checkfile)))) 2845 (gnus-message
2845 2846 4 "Didn't save %s: updated externally"
2846 (if gnus-save-startup-file-via-temp-buffer 2847 (concat gnus-current-startup-file ".eld"))
2848 (if gnus-save-startup-file-via-temp-buffer
2849 (let ((coding-system-for-write gnus-ding-file-coding-system)
2850 (standard-output (current-buffer)))
2851 (gnus-gnus-to-quick-newsrc-format)
2852 (gnus-run-hooks 'gnus-save-quick-newsrc-hook)
2853 (save-buffer)
2854 (setq gnus-save-newsrc-file-last-timestamp
2855 (nth 5 (file-attributes buffer-file-name))))
2847 (let ((coding-system-for-write gnus-ding-file-coding-system) 2856 (let ((coding-system-for-write gnus-ding-file-coding-system)
2848 (standard-output (current-buffer))) 2857 (version-control gnus-backup-startup-file)
2849 (gnus-gnus-to-quick-newsrc-format) 2858 (startup-file (concat gnus-current-startup-file ".eld"))
2850 (gnus-run-hooks 'gnus-save-quick-newsrc-hook) 2859 (working-dir (file-name-directory gnus-current-startup-file))
2851 (save-buffer) 2860 working-file
2852 (setq gnus-save-newsrc-file-last-timestamp 2861 (i -1))
2853 (nth 5 (file-attributes buffer-file-name)))) 2862 ;; Generate the name of a non-existent file.
2854 (let ((coding-system-for-write gnus-ding-file-coding-system) 2863 (while (progn (setq working-file
2855 (version-control gnus-backup-startup-file) 2864 (format
2856 (startup-file (concat gnus-current-startup-file ".eld")) 2865 (if (and (eq system-type 'ms-dos)
2857 (working-dir (file-name-directory gnus-current-startup-file)) 2866 (not (gnus-long-file-names)))
2858 working-file 2867 "%s#%d.tm#" ; MSDOS limits files to 8+3
2859 (i -1)) 2868 "%s#tmp#%d")
2860 ;; Generate the name of a non-existent file. 2869 working-dir (setq i (1+ i))))
2861 (while (progn (setq working-file 2870 (file-exists-p working-file)))
2862 (format 2871
2863 (if (and (eq system-type 'ms-dos) 2872 (unwind-protect
2864 (not (gnus-long-file-names))) 2873 (progn
2865 "%s#%d.tm#" ; MSDOS limits files to 8+3 2874 (gnus-with-output-to-file working-file
2866 "%s#tmp#%d") 2875 (gnus-gnus-to-quick-newsrc-format)
2867 working-dir (setq i (1+ i)))) 2876 (gnus-run-hooks 'gnus-save-quick-newsrc-hook))
2868 (file-exists-p working-file))) 2877
2869 2878 ;; These bindings will mislead the current buffer
2870 (unwind-protect 2879 ;; into thinking that it is visiting the startup
2871 (progn 2880 ;; file.
2872 (gnus-with-output-to-file working-file 2881 (let ((buffer-backed-up nil)
2873 (gnus-gnus-to-quick-newsrc-format) 2882 (buffer-file-name startup-file)
2874 (gnus-run-hooks 'gnus-save-quick-newsrc-hook)) 2883 (file-precious-flag t)
2875 2884 (setmodes (file-modes startup-file)))
2876 ;; These bindings will mislead the current buffer 2885 ;; Backup the current version of the startup file.
2877 ;; into thinking that it is visiting the startup 2886 (backup-buffer)
2878 ;; file. 2887
2879 (let ((buffer-backed-up nil) 2888 ;; Replace the existing startup file with the temp file.
2880 (buffer-file-name startup-file) 2889 (rename-file working-file startup-file t)
2881 (file-precious-flag t) 2890 (gnus-set-file-modes startup-file setmodes)
2882 (setmodes (file-modes startup-file))) 2891 (setq gnus-save-newsrc-file-last-timestamp
2883 ;; Backup the current version of the startup file. 2892 (nth 5 (file-attributes startup-file)))))
2884 (backup-buffer) 2893 (condition-case nil
2885 2894 (delete-file working-file)
2886 ;; Replace the existing startup file with the temp file. 2895 (file-error nil)))))
2887 (rename-file working-file startup-file t) 2896
2888 (gnus-set-file-modes startup-file setmodes) 2897 (gnus-kill-buffer (current-buffer))
2889 (setq gnus-save-newsrc-file-last-timestamp 2898 (gnus-message
2890 (nth 5 (file-attributes startup-file))))) 2899 5 "Saving %s.eld...done" gnus-current-startup-file)))
2891 (condition-case nil
2892 (delete-file working-file)
2893 (file-error nil)))))
2894
2895 (gnus-kill-buffer (current-buffer))
2896 (gnus-message
2897 5 "Saving %s.eld...done" gnus-current-startup-file))
2898 (gnus-dribble-delete-file) 2900 (gnus-dribble-delete-file)
2899 (gnus-group-set-mode-line))))) 2901 (gnus-group-set-mode-line)))))
2900 2902