diff options
| author | Glenn Morris | 2013-05-14 09:01:16 -0700 |
|---|---|---|
| committer | Glenn Morris | 2013-05-14 09:01:16 -0700 |
| commit | 0114073ac0fbb12765206eea6db8aab0a2982d25 (patch) | |
| tree | b287279bbb2370567c816458b54cc61c061aba2f | |
| parent | eda9c7d7070741708c8e3a9e2bf927582a96c32a (diff) | |
| download | emacs-0114073ac0fbb12765206eea6db8aab0a2982d25.tar.gz emacs-0114073ac0fbb12765206eea6db8aab0a2982d25.zip | |
* subr.el (user-emacs-directory-warning): New option.
(locate-user-emacs-file): Handle non-accessible .emacs.d.
Not in NEWS, because you only need to know about this if you encounter
it in the wild.
Fixes: debbugs:13930
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/subr.el | 41 |
2 files changed, 37 insertions, 9 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 70431b3f318..ef43f00de1c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2013-05-14 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * subr.el (user-emacs-directory-warning): New option. | ||
| 4 | (locate-user-emacs-file): Handle non-accessible .emacs.d. (Bug#13930) | ||
| 5 | |||
| 1 | 2013-05-14 Leo Liu <sdl.web@gmail.com> | 6 | 2013-05-14 Leo Liu <sdl.web@gmail.com> |
| 2 | 7 | ||
| 3 | * progmodes/octave.el (octave-font-lock-keywords): Fix error | 8 | * progmodes/octave.el (octave-font-lock-keywords): Fix error |
diff --git a/lisp/subr.el b/lisp/subr.el index bb23745df72..4871f3733f9 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -2643,6 +2643,13 @@ Various programs in Emacs store information in this directory. | |||
| 2643 | Note that this should end with a directory separator. | 2643 | Note that this should end with a directory separator. |
| 2644 | See also `locate-user-emacs-file'.") | 2644 | See also `locate-user-emacs-file'.") |
| 2645 | 2645 | ||
| 2646 | (custom-declare-variable-early 'user-emacs-directory-warning t | ||
| 2647 | "Non-nil means warn if cannot access `user-emacs-directory'. | ||
| 2648 | Set this to nil at your own risk..." | ||
| 2649 | :type 'boolean | ||
| 2650 | :group 'initialization | ||
| 2651 | :version "24.4") | ||
| 2652 | |||
| 2646 | (defun locate-user-emacs-file (new-name &optional old-name) | 2653 | (defun locate-user-emacs-file (new-name &optional old-name) |
| 2647 | "Return an absolute per-user Emacs-specific file name. | 2654 | "Return an absolute per-user Emacs-specific file name. |
| 2648 | If NEW-NAME exists in `user-emacs-directory', return it. | 2655 | If NEW-NAME exists in `user-emacs-directory', return it. |
| @@ -2658,17 +2665,33 @@ directory if it does not exist." | |||
| 2658 | (file-readable-p at-home)) | 2665 | (file-readable-p at-home)) |
| 2659 | at-home | 2666 | at-home |
| 2660 | ;; Make sure `user-emacs-directory' exists, | 2667 | ;; Make sure `user-emacs-directory' exists, |
| 2661 | ;; unless we're in batch mode or dumping Emacs | 2668 | ;; unless we're in batch mode or dumping Emacs. |
| 2662 | (or noninteractive | 2669 | (or noninteractive |
| 2663 | purify-flag | 2670 | purify-flag |
| 2664 | (file-accessible-directory-p | 2671 | (let (errtype) |
| 2665 | (directory-file-name user-emacs-directory)) | 2672 | (if (file-directory-p user-emacs-directory) |
| 2666 | (let ((umask (default-file-modes))) | 2673 | (or (file-accessible-directory-p user-emacs-directory) |
| 2667 | (unwind-protect | 2674 | (setq errtype "access")) |
| 2668 | (progn | 2675 | (let ((umask (default-file-modes))) |
| 2669 | (set-default-file-modes ?\700) | 2676 | (unwind-protect |
| 2670 | (make-directory user-emacs-directory)) | 2677 | (progn |
| 2671 | (set-default-file-modes umask)))) | 2678 | (set-default-file-modes ?\700) |
| 2679 | (condition-case nil | ||
| 2680 | (make-directory user-emacs-directory) | ||
| 2681 | (error (setq errtype "create")))) | ||
| 2682 | (set-default-file-modes umask)))) | ||
| 2683 | (when (and errtype | ||
| 2684 | user-emacs-directory-warning | ||
| 2685 | (not (get 'user-emacs-directory-warning 'this-session))) | ||
| 2686 | ;; Only warn once per Emacs session. | ||
| 2687 | (put 'user-emacs-directory-warning 'this-session t) | ||
| 2688 | (display-warning 'initialization | ||
| 2689 | (format "\ | ||
| 2690 | Unable to %s `user-emacs-directory' (%s). | ||
| 2691 | Any data that would normally be written there may be lost! | ||
| 2692 | If you never want to see this message again, | ||
| 2693 | customize the variable `user-emacs-directory-warning'." | ||
| 2694 | errtype user-emacs-directory))))) | ||
| 2672 | bestname)))) | 2695 | bestname)))) |
| 2673 | 2696 | ||
| 2674 | ;;;; Misc. useful functions. | 2697 | ;;;; Misc. useful functions. |