Update upstream source from tag 'upstream/1.4.0'
Update to upstream version '1.4.0'
with Debian dir f3acb9efe246a39c6becfacd1f96b199bf48e4bf
Lev Lamberov
10 months ago
4 | 4 | ELS = $(PKG).el |
5 | 5 | ELCS = $(ELS:.el=.elc) |
6 | 6 | |
7 | DEPS = | |
7 | DEPS = compat | |
8 | 8 | |
9 | 9 | EMACS ?= emacs |
10 | 10 | EMACS_ARGS ?= |
20 | 20 | $(info make clean - remove generated files) |
21 | 21 | @printf "\n" |
22 | 22 | |
23 | lisp: $(ELCS) loaddefs | |
23 | lisp: $(ELCS) loaddefs check-declare | |
24 | 24 | |
25 | 25 | loaddefs: $(PKG)-autoloads.el |
26 | 26 | |
28 | 28 | @printf "Compiling $<\n" |
29 | 29 | @$(EMACS) -Q --batch $(EMACS_ARGS) $(LOAD_PATH) -f batch-byte-compile $< |
30 | 30 | |
31 | check-declare: | |
32 | @printf " Checking function declarations\n" | |
33 | @$(EMACS) -Q --batch $(EMACS_ARGS) $(LOAD_PATH) \ | |
34 | --eval "(check-declare-directory default-directory)" | |
35 | ||
31 | 36 | CLEAN = $(ELCS) $(PKG)-autoloads.el |
32 | 37 | |
33 | 38 | clean: |
34 | @printf "Cleaning...\n" | |
39 | @printf " Cleaning...\n" | |
35 | 40 | @rm -rf $(CLEAN) |
36 | 41 | |
37 | define LOADDEFS_TMPL | |
38 | ;;; $(PKG)-autoloads.el --- automatically extracted autoloads | |
39 | ;; | |
40 | ;;; Code: | |
41 | (add-to-list 'load-path (directory-file-name \ | |
42 | (or (file-name-directory #$$) (car load-path)))) | |
43 | ||
44 | ;; Local Variables: | |
45 | ;; version-control: never | |
46 | ;; no-byte-compile: t | |
47 | ;; no-update-autoloads: t | |
48 | ;; End: | |
49 | ;;; $(PKG)-autoloads.el ends here | |
50 | endef | |
51 | export LOADDEFS_TMPL | |
52 | #' | |
53 | ||
54 | 42 | $(PKG)-autoloads.el: $(ELS) |
55 | @printf "Generating $@\n" | |
56 | @printf "%s" "$$LOADDEFS_TMPL" > $@ | |
57 | @$(EMACS) -Q --batch --eval "(progn\ | |
58 | (setq make-backup-files nil)\ | |
59 | (setq vc-handled-backends nil)\ | |
60 | (setq default-directory (file-truename default-directory))\ | |
61 | (setq generated-autoload-file (expand-file-name \"$@\"))\ | |
62 | (setq find-file-visit-truename t)\ | |
63 | (update-directory-autoloads default-directory))" | |
43 | @printf " Creating $@\n" | |
44 | @$(EMACS) -Q --batch -l autoload -l cl-lib --eval "\ | |
45 | (let ((file (expand-file-name \"$@\"))\ | |
46 | (autoload-timestamps nil) \ | |
47 | (backup-inhibited t)\ | |
48 | (version-control 'never)\ | |
49 | (coding-system-for-write 'utf-8-emacs-unix))\ | |
50 | (write-region (autoload-rubric file \"package\" nil) nil file nil 'silent)\ | |
51 | (cl-letf (((symbol-function 'progress-reporter-do-update) (lambda (&rest _)))\ | |
52 | ((symbol-function 'progress-reporter-done) (lambda (_))))\ | |
53 | (let ((generated-autoload-file file))\ | |
54 | (update-directory-autoloads default-directory))))" \ | |
55 | 2>&1 | sed "/^Package autoload is deprecated$$/d" |
0 | Help keeping `~/.emacs.d` clean | |
1 | =============================== | |
2 | ||
3 | The default paths used to store configuration files and persistent | |
4 | data are not consistent across Emacs packages. This isn't just a | |
5 | problem with third-party packages but even with built-in packages. | |
6 | ||
7 | Some packages put these files directly in `user-emacs-directory` | |
8 | or `$HOME` or in a subdirectory of either of the two or elsewhere. | |
9 | Furthermore sometimes file names are used that don't provide any | |
10 | insight into what package might have created them. | |
11 | ||
12 | This package sets out to fix this by changing the values of path | |
13 | variables to put configuration files in `no-littering-etc-directory` | |
14 | (defaulting to "etc/" under `user-emacs-directory`, thus usually | |
15 | `"~/.emacs.d/etc/"`) and persistent data files in | |
16 | `no-littering-var-directory` (defaulting to `"var/"` under | |
17 | `user-emacs-directory`, thus usually `"~/.emacs.d/var/"`), and | |
18 | by using descriptive file names and subdirectories when appropriate. | |
19 | This is similar to a color-theme; a "path-theme" if you will. | |
20 | ||
21 | We still have a long way to go until most built-in and many | |
22 | third-party path variables are properly "themed". Like a color-theme, | |
23 | this package depends on user contributions to accomplish decent | |
24 | coverage. Pull requests are highly welcome (but please follow the | |
25 | conventions described below and in the pull request template). | |
26 | ||
27 | `no-littering` cannot help with moving existing files to the new | |
28 | location. You will have to move the files manually. See issue | |
29 | [#79](https://github.com/emacscollective/no-littering/issues/79) | |
30 | for more information. | |
31 | ||
32 | Usage | |
33 | ----- | |
34 | ||
35 | Load the feature `no-littering` as early as possible in your init | |
36 | file. Make sure you load it at least before you change any path | |
37 | variables using some other method. | |
38 | ||
39 | (require 'no-littering) | |
40 | ||
41 | If you would like to use base directories different from what | |
42 | `no-littering` uses by default, then you have to set the respective | |
43 | variables before loading the feature. | |
44 | ||
45 | (setq no-littering-etc-directory | |
46 | (expand-file-name "config/" user-emacs-directory)) | |
47 | (setq no-littering-var-directory | |
48 | (expand-file-name "data/" user-emacs-directory)) | |
49 | (require 'no-littering) | |
50 | ||
51 | ### Suggested Settings | |
52 | ||
53 | If you use `recentf` then you might find it convenient to exclude all | |
54 | of the files in the `no-littering` directories using something like | |
55 | the following. | |
56 | ||
57 | (require 'recentf) | |
58 | (add-to-list 'recentf-exclude no-littering-var-directory) | |
59 | (add-to-list 'recentf-exclude no-littering-etc-directory) | |
60 | ||
61 | #### Auto-save settings | |
62 | ||
63 | One of the most common types of files that Emacs creates automatically | |
64 | is auto-save files. By default, these appear in the current directory | |
65 | of a visited file. No-littering does not change this, but you can add | |
66 | the following code to your `init.el` file to store these files in the | |
67 | `var` directory: | |
68 | ||
69 | (setq auto-save-file-name-transforms | |
70 | `((".*" ,(no-littering-expand-var-file-name "auto-save/") t))) | |
71 | ||
72 | #### Saved customizations | |
73 | ||
74 | Emacs will save [customizations] into your `init.el` file by default. | |
75 | If you don't want that, you might want to store them in a sibling file | |
76 | or even in the `etc/` directory: | |
77 | ||
78 | (setq custom-file (expand-file-name "custom.el" user-emacs-directory)) | |
79 | ;; or | |
80 | (setq custom-file (no-littering-expand-etc-file-name "custom.el")) | |
81 | ||
82 | #### Native compilation cache | |
83 | ||
84 | The location of the native compilation cache has to be changed using a | |
85 | function, preferably in `early-init.el`: | |
86 | ||
87 | (when (fboundp 'startup-redirect-eln-cache) | |
88 | (startup-redirect-eln-cache | |
89 | (convert-standard-filename | |
90 | (expand-file-name "var/eln-cache/" user-emacs-directory)))) | |
91 | ||
92 | Conventions | |
93 | ----------- | |
94 | ||
95 | ### (A) File names | |
96 | ||
97 | 1. File names are based on the name of the respective Emacs lisp | |
98 | variables and the name of the respective Emacs package. | |
99 | ||
100 | 2. The name of the respective Emacs package should serve as the | |
101 | prefix of the file name, unless the file is in a subdirectory in | |
102 | which case the name of the subdirectory serves as the prefix. | |
103 | ||
104 | 3. If the name of the package and the prefix of the variable do not | |
105 | match, then we prefer the name of the package. | |
106 | ||
107 | 4. If the name of a path variable ends with `-file`, `-default-file`, | |
108 | `-directory`, `-default-directory`, or something similar, then that | |
109 | suffix is usually dropped from the file name. | |
110 | ||
111 | 5. If applicable, the appropriate extension is added to the file name | |
112 | so that files are visited using the appropriate major-modes and | |
113 | also to provide a hint about the kind of data stored in the file. | |
114 | E.g. if a file contains an S-expression, then the suffix should be | |
115 | `*.el`. | |
116 | ||
117 | ### (B) File location and subdirectories | |
118 | ||
119 | 1. If a package has only one data file, then that is usually placed in | |
120 | `no-littering-var-directory` itself. Likewise if a package has | |
121 | only one config file, then that is placed in | |
122 | `no-littering-etc-directory` itself. | |
123 | ||
124 | 2. If a package has multiple data (or config files), then those files | |
125 | are placed in a subdirectory of `no-littering-var-directory` (or | |
126 | `no-littering-etc-directory`). | |
127 | ||
128 | 3. If a subdirectory is used for a package's data (or config) file | |
129 | variables, then the name of the directory should match the name of | |
130 | the package in most cases. The subdirectory name may serve as the | |
131 | package prefix of the file name. | |
132 | ||
133 | 4. If a package provides a "framework" for other packages to use, | |
134 | then we may reuse its directories for other packages that make use | |
135 | of that framework or otherwise "extend" the "main package". | |
136 | E.g. we place all `helm` related files in `helm/`. | |
137 | ||
138 | 5. If a package only defines a single variable that specifies a data | |
139 | (or config) directory, then the directory name should | |
140 | nevertheless be just the package name. E.g. the path used for | |
141 | `sx-cache-directory` from the `sx` package is `sx/cache/`, not | |
142 | `sx-cache/`. | |
143 | ||
144 | 6. However if the name of the directory variable implies that the | |
145 | package won't ever define any data (or config) files that won't be | |
146 | placed in that directory, then we use a top-level directory. E.g. | |
147 | when the name of the variable is `<package>-directory`, in which | |
148 | case we would use just `<package>/` as the path. | |
149 | ||
150 | ### (C) Ordering and alignment | |
151 | ||
152 | 1. The code that sets the values of themed variables is split into two | |
153 | groups. The first group sets the value of variables that belong to | |
154 | packages that are part of Emacs, and the second group is used for | |
155 | variables that are defined by packages that are not part of Emacs. | |
156 | ||
157 | 2. Each of these lists is sorted alphabetically (usually by variable | |
158 | name). Please keep it that way. | |
159 | ||
160 | 3. We attempt to align the value forms inside different `setq` forms. | |
161 | If the symbol part for a particular variable is too long to allow | |
162 | doing so, then don't worry about it and just break the alignment. | |
163 | If it turns out that this happens very often, then we will adjust | |
164 | the alignment eventually. | |
165 | ||
166 | ### (D) Commit messages | |
167 | ||
168 | 1. Please theme each package using a separate commit and use commit | |
169 | messages of the form `PACKAGE: theme VARIABLE`. | |
170 | ||
171 | 2. If a package has several path variables, then you should theme them | |
172 | all in one commit. | |
173 | ||
174 | 3. If the variable names do not fit nicely on the summary line, then | |
175 | use a message such as: | |
176 | ||
177 | ``` | |
178 | foo: theme variables | |
179 | ||
180 | Theme `foo-config-file', `foo-cache-directory', | |
181 | and `foo-persistent-file'. | |
182 | ``` | |
183 | ||
184 | 4. When appropriate add statements like the following to the commit | |
185 | message: | |
186 | ||
187 | - This file is used to store an s-expression. | |
188 | - This file is used to store raw text. | |
189 | - This is the only configuration/data file of the package. | |
190 | - This package does/doesn't take care of creating the containing | |
191 | directory if necessary. (If the package does not do it, then you | |
192 | should also fix that and submit an upstream pull request.) | |
193 | ||
194 | 5. If you are uncertain, then be explicit about it by adding a comment | |
195 | to the pull-request. | |
196 | ||
197 | [customizations]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Saving-Customizations.html | |
198 | ||
199 | <!-- Local Variables: --> | |
200 | <!-- fill-column: 70 --> | |
201 | <!-- End: --> |
0 | * Help keeping ~/.config/emacs clean | |
1 | ||
2 | The default paths used to store configuration files and persistent | |
3 | data are not consistent across Emacs packages. This isn't just a | |
4 | problem with third-party packages but even with built-in packages. | |
5 | ||
6 | Some packages put these files directly in ~user-emacs-directory~ | |
7 | or ~$HOME~ or in a subdirectory of either of the two or elsewhere. | |
8 | Furthermore sometimes file names are used that don't provide any | |
9 | insight into what package might have created them. | |
10 | ||
11 | This package sets out to fix this by changing the values of path | |
12 | variables to put configuration files in ~no-littering-etc-directory~ | |
13 | (defaulting to "etc/" under ~user-emacs-directory~, thus usually | |
14 | "$HOME/.config/emacs/etc/") and persistent data files in | |
15 | ~no-littering-var-directory~ (defaulting to "var/" under | |
16 | ~user-emacs-directory~, thus usually "$HOME/.config/emacs/var/"), and | |
17 | by using descriptive file names and subdirectories when appropriate. | |
18 | This is similar to a color-theme; a "path-theme" if you will. | |
19 | ||
20 | We still have a long way to go until most built-in and many | |
21 | third-party path variables are properly "themed". Like a color-theme, | |
22 | this package depends on user contributions to accomplish decent | |
23 | coverage. Pull requests are highly welcome (but please follow the | |
24 | conventions described below and in the pull request template). | |
25 | ||
26 | ~no-littering~ cannot help with moving existing files to the new | |
27 | location. You will have to move the files manually. See issue | |
28 | [[https://github.com/emacscollective/no-littering/issues/79][#79]] for more information. | |
29 | ||
30 | ** Usage | |
31 | ||
32 | Load the feature ~no-littering~ as early as possible in your init | |
33 | file. Make sure you load it at least before you change any path | |
34 | variables using some other method. | |
35 | ||
36 | #+begin_src emacs-lisp | |
37 | (require 'no-littering) | |
38 | #+end_src | |
39 | ||
40 | If you would like to use base directories different from what | |
41 | ~no-littering~ uses by default, then you have to set the respective | |
42 | variables before loading the feature. | |
43 | ||
44 | #+begin_src emacs-lisp | |
45 | (setq no-littering-etc-directory | |
46 | (expand-file-name "config/" user-emacs-directory)) | |
47 | (setq no-littering-var-directory | |
48 | (expand-file-name "data/" user-emacs-directory)) | |
49 | (require 'no-littering) | |
50 | #+end_src | |
51 | ||
52 | *** Suggested Settings | |
53 | **** Auto-save, backup and undo-tree files | |
54 | ||
55 | Creating backups increases the odds that secret information, which | |
56 | would otherwise never be stored in clear text, is written to disk. | |
57 | Likewise backups increase the odds that leaked secrets persist longer. | |
58 | ||
59 | This topic is beyond the scope of this documentation, but as the | |
60 | author of this package, I want to at least ensure that its use does | |
61 | not make matters worse. | |
62 | ||
63 | For that reason, simply loading ~no-littering~, does not theme the | |
64 | built-in backup and auto-save functionality, and the third-party | |
65 | ~undo-tree~ package. | |
66 | ||
67 | A function ~no-littering-theme-backups~ is provided, which does theme | |
68 | these features. Before calling that function from your init files, | |
69 | you should read its docstring and implementation. | |
70 | ||
71 | **** Recent files | |
72 | ||
73 | If you use ~recentf~ then you might find it convenient to exclude all | |
74 | of the files in the ~no-littering~ directories using something like | |
75 | the following. | |
76 | ||
77 | #+begin_src emacs-lisp | |
78 | (require 'recentf) | |
79 | (add-to-list 'recentf-exclude | |
80 | (recentf-expand-file-name no-littering-var-directory)) | |
81 | (add-to-list 'recentf-exclude | |
82 | (recentf-expand-file-name no-littering-etc-directory)) | |
83 | #+end_src | |
84 | ||
85 | **** Saved customizations | |
86 | ||
87 | Emacs will save [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Saving-Customizations.html][customizations]] into your ~init.el~ file by default. | |
88 | If you don't want that, you might want to store them in a sibling file | |
89 | or even in the ~etc/~ directory: | |
90 | ||
91 | #+begin_src emacs-lisp | |
92 | (setq custom-file (expand-file-name "custom.el" user-emacs-directory)) | |
93 | ;; or | |
94 | (setq custom-file (no-littering-expand-etc-file-name "custom.el")) | |
95 | #+end_src | |
96 | ||
97 | **** Native compilation cache | |
98 | ||
99 | When using Emacs 29, the location of the native compilation cache can | |
100 | be changed using a function, preferably in ~early-init.el~: | |
101 | ||
102 | #+begin_src emacs-lisp | |
103 | (when (fboundp 'startup-redirect-eln-cache) | |
104 | (startup-redirect-eln-cache | |
105 | (convert-standard-filename | |
106 | (expand-file-name "var/eln-cache/" user-emacs-directory)))) | |
107 | #+end_src | |
108 | ||
109 | ** Conventions | |
110 | ||
111 | *** (A) File names | |
112 | ||
113 | 1. File names are based on the name of the respective Emacs lisp | |
114 | variables and the name of the respective Emacs package. | |
115 | ||
116 | 2. The name of the respective Emacs package should serve as the | |
117 | prefix of the file name, unless the file is in a subdirectory in | |
118 | which case the name of the subdirectory serves as the prefix. | |
119 | ||
120 | 3. If the name of the package and the prefix of the variable do not | |
121 | match, then we prefer the name of the package. | |
122 | ||
123 | 4. If the name of a path variable ends with ~-file~, ~-default-file~, | |
124 | ~-directory~, ~-default-directory~, or something similar, then that | |
125 | suffix is usually dropped from the file name. | |
126 | ||
127 | 5. If applicable, the appropriate extension is added to the file name | |
128 | so that files are visited using the appropriate major-modes and | |
129 | also to provide a hint about the kind of data stored in the file. | |
130 | E.g. if a file contains an S-expression, then the suffix should be | |
131 | ~*.el~. | |
132 | ||
133 | *** (B) File location and subdirectories | |
134 | ||
135 | 1. If a package has only one data file, then that is usually placed in | |
136 | ~no-littering-var-directory~ itself. Likewise if a package has | |
137 | only one config file, then that is placed in | |
138 | ~no-littering-etc-directory~ itself. | |
139 | ||
140 | 2. If a package has multiple data (or config files), then those files | |
141 | are placed in a subdirectory of ~no-littering-var-directory~ (or | |
142 | ~no-littering-etc-directory~). | |
143 | ||
144 | 3. If a subdirectory is used for a package's data (or config) file | |
145 | variables, then the name of the directory should match the name of | |
146 | the package in most cases. The subdirectory name may serve as the | |
147 | package prefix of the file name. | |
148 | ||
149 | 4. If a package provides a "framework" for other packages to use, | |
150 | then we may reuse its directories for other packages that make use | |
151 | of that framework or otherwise "extend" the "main package". | |
152 | E.g. we place all ~helm~ related files in ~helm/~. | |
153 | ||
154 | 5. If a package only defines a single variable that specifies a data | |
155 | (or config) directory, then the directory name should | |
156 | nevertheless be just the package name. E.g. the path used for | |
157 | ~sx-cache-directory~ from the ~sx~ package is ~sx/cache/~, not | |
158 | ~sx-cache/~. | |
159 | ||
160 | 6. However if the name of the directory variable implies that the | |
161 | package won't ever define any data (or config) files that won't be | |
162 | placed in that directory, then we use a top-level directory. E.g. | |
163 | when the name of the variable is ~<package>-directory~, in which | |
164 | case we would use just ~<package>/~ as the path. | |
165 | ||
166 | *** (C) Ordering and alignment | |
167 | ||
168 | 1. The code that sets the values of themed variables is split into two | |
169 | groups. The first group sets the value of variables that belong to | |
170 | packages that are part of Emacs, and the second group is used for | |
171 | variables that are defined by packages that are not part of Emacs. | |
172 | ||
173 | 2. Each of these lists is sorted alphabetically (usually by variable | |
174 | name). Please keep it that way. | |
175 | ||
176 | 3. We attempt to align the value forms inside different ~setq~ forms. | |
177 | If the symbol part for a particular variable is too long to allow | |
178 | doing so, then don't worry about it and just break the alignment. | |
179 | If it turns out that this happens very often, then we will adjust | |
180 | the alignment eventually. | |
181 | ||
182 | *** (D) Commit messages | |
183 | ||
184 | 1. Please theme each package using a separate commit and use commit | |
185 | messages of the form ~PACKAGE: theme VARIABLE~. | |
186 | ||
187 | 2. If a package has several path variables, then you should theme them | |
188 | all in one commit. | |
189 | ||
190 | 3. If the variable names do not fit nicely on the summary line, then | |
191 | use a message such as: | |
192 | ||
193 | #+begin_src text | |
194 | foo: theme variables | |
195 | ||
196 | Theme `foo-config-file', `foo-cache-directory', | |
197 | and `foo-persistent-file'. | |
198 | #+end_src | |
199 | ||
200 | 4. When appropriate add statements like the following to the commit | |
201 | message: | |
202 | ||
203 | - This file is used to store an s-expression. | |
204 | - This file is used to store raw text. | |
205 | - This is the only configuration/data file of the package. | |
206 | - This package does/doesn't take care of creating the containing | |
207 | directory if necessary. (If the package does not do it, then you | |
208 | should also fix that and submit an upstream pull request.) | |
209 | ||
210 | 5. If you are uncertain, then be explicit about it by adding a comment | |
211 | to the pull-request. | |
212 | ||
213 | # Local Variables: | |
214 | # fill-column: 70 | |
215 | # End: | |
216 | ||
217 | #+html: <br><br> | |
218 | #+html: <a href="https://github.com/emacscollective/no-littering/actions/workflows/compile.yml"><img alt="Compile" src="https://github.com/emacscollective/no-littering/actions/workflows/compile.yml/badge.svg"/></a> | |
219 | #+html: <a href="https://stable.melpa.org/#/no-littering"><img alt="MELPA Stable" src="https://stable.melpa.org/packages/no-littering-badge.svg"/></a> | |
220 | #+html: <a href="https://melpa.org/#/no-littering"><img alt="MELPA" src="https://melpa.org/packages/no-littering-badge.svg"/></a> |
0 | #+TITLE: Migrating to use no-littering | |
1 | ||
2 | * Introduction | |
3 | ||
4 | This document describes migration towards using no-littering for path | |
5 | theming. | |
6 | ||
7 | * Steps | |
8 | ** Prepare code | |
9 | ||
10 | You must not install no-littering with a package manager because it | |
11 | might automatically get loaded. Make sure installing it won't load | |
12 | it. If you are not sure, clone the repository somewhere but do not | |
13 | load or require the package. We need this to preserve the existing | |
14 | values set to themed variables. | |
15 | ||
16 | Before you start, tangle this file by running ~M-x org-babel-tangle~ and | |
17 | load =no-littering-migration.el=, for example by opening dired and | |
18 | hitting ~L~ on the file. | |
19 | ||
20 | ** Save current values of your settings | |
21 | ||
22 | First, we need to save the current values of the themed variables to | |
23 | be able to move the files from their existing locations. Execute the | |
24 | code below: | |
25 | ||
26 | #+begin_src elisp | |
27 | (setq no-littering-current-values | |
28 | (no-littering-get-current-variables)) | |
29 | #+end_src | |
30 | ||
31 | ** Load =no-littering= package | |
32 | ||
33 | Now you can install the package with your package manager of choice. | |
34 | After installation, run: | |
35 | ||
36 | #+begin_src | |
37 | (require 'no-littering) | |
38 | #+end_src | |
39 | ||
40 | ** Save new values | |
41 | ||
42 | Now we save the new themed values set by no-littering. | |
43 | ||
44 | #+begin_src elisp | |
45 | (setq no-littering-new-values (no-littering-get-current-variables)) | |
46 | #+end_src | |
47 | ||
48 | ** Generate migrations | |
49 | ||
50 | We now have the old list and a new list and we can compare the | |
51 | existing values to new values. The script below generates a migration | |
52 | script which you have to review and execute manually. | |
53 | ||
54 | #+begin_src elisp :wrap src elisp :results value | |
55 | (no-littering-generate-migration no-littering-current-values | |
56 | no-littering-new-values) | |
57 | #+end_src | |
58 | ||
59 | The result is a list of =progn= forms which can be evaluated by placing | |
60 | the point at the end of the =progn= form and calling =M-x eval-last-sexp= | |
61 | (sometimes bound to ~C-x C-e~). | |
62 | ||
63 | The form looks like this: | |
64 | ||
65 | #+begin_src elisp | |
66 | (progn | |
67 | "abbrev-file-name" ; name of the variable | |
68 | (make-directory | |
69 | ;; create a parent dir for target | |
70 | "/home/matus/.config/emacs/etc/" t) | |
71 | (rename-file | |
72 | ;; old (current) file | |
73 | "/home/matus/.config/emacs/abbrev_defs" | |
74 | ;; new file | |
75 | "/home/matus/.config/emacs/etc/abbrev.el" | |
76 | 1)) | |
77 | #+end_src | |
78 | ||
79 | If you are satisfied, execute it and move to the next one. | |
80 | ||
81 | Some of the forms might error out when the source file does not exist. | |
82 | In that case there's nothing to do and you can move to the next one. | |
83 | ||
84 | Occasionally, the code generate is not valid and you need to do the | |
85 | migration manually. For now, the only value which wasn't readily | |
86 | supported is =backup-directory-alist= which is not a string but an | |
87 | alist. | |
88 | ||
89 | ** Remove customized values | |
90 | ||
91 | If you were using =customize-variable= before, you need to remove | |
92 | customized settings or they will keep overwriting the values managed | |
93 | by =no-littering=. Simply run the following to remove all | |
94 | customizations. | |
95 | ||
96 | *Make sure to backup your custom file before running this so you can | |
97 | compare he results.* | |
98 | ||
99 | #+begin_src elisp | |
100 | (no-littering-custom-reset) | |
101 | (custom-save-all) | |
102 | #+end_src | |
103 | ||
104 | Likewise, remove any other customization of the paths managed by | |
105 | =no-littering=. | |
106 | ||
107 | * Code | |
108 | :PROPERTIES: | |
109 | :ID: 5097feb0-d1e3-49b7-8129-276a40f8ec8a | |
110 | :END: | |
111 | ||
112 | #+begin_src elisp :tangle no-littering-migration.el | |
113 | (defun no-littering-get-themed-variables () | |
114 | "Return all variables recognized by no-littering." | |
115 | (with-temp-buffer | |
116 | (insert-file-contents "no-littering.el") | |
117 | (goto-char (point-min)) | |
118 | (re-search-forward "^(cl-letf") | |
119 | (beginning-of-line) | |
120 | (down-list) | |
121 | (forward-sexp 4) | |
122 | (let* ((data (cdr (read (current-buffer)))) | |
123 | (vars (cl-remove-if-not | |
124 | (lambda (form) (eq (car form) 'setq)) data)) | |
125 | (current-values | |
126 | (mapcar | |
127 | (lambda (form) | |
128 | (let* ((var (cadr form)) | |
129 | (value (and (boundp var) | |
130 | (symbol-value var)))) | |
131 | (when (stringp value) | |
132 | (setq value (file-truename value))) | |
133 | (cons var value))) | |
134 | vars))) | |
135 | current-values))) | |
136 | ||
137 | (defun no-littering-get-current-variables () | |
138 | "Return all variables recognized by no-littering currently used." | |
139 | (cl-remove-if | |
140 | (lambda (var) (not (cdr var))) | |
141 | (no-littering-get-themed-variables))) | |
142 | ||
143 | (defun no-littering-generate-migration (old-values new-values) | |
144 | (let* ((migrations | |
145 | (mapcar (lambda (var) | |
146 | (list (car var) | |
147 | (cdr var) | |
148 | (cdr (assq (car var) new-values)))) | |
149 | old-values)) | |
150 | (commands | |
151 | (mapcar (lambda (var) | |
152 | (if (stringp (nth 2 var)) | |
153 | (when (not (equal (nth 1 var) (nth 2 var))) | |
154 | `(progn | |
155 | ,(format "%s" (car var)) | |
156 | (make-directory | |
157 | ,(file-name-directory (nth 2 var)) | |
158 | t) | |
159 | (rename-file ,(nth 1 var) ,(nth 2 var) 1))) | |
160 | `(progn ,(car var) "Value is not a directory"))) | |
161 | migrations))) | |
162 | commands)) | |
163 | ||
164 | (defun no-littering--custom-reset-symbol (symbol) | |
165 | (put symbol 'variable-comment nil) | |
166 | (put symbol 'standard-value nil) | |
167 | (put symbol 'customized-value nil) | |
168 | (put symbol 'customized-variable-comment nil) | |
169 | (when (or (get symbol 'saved-value) | |
170 | (get symbol 'saved-variable-comment)) | |
171 | (put symbol 'saved-value nil) | |
172 | (put symbol 'saved-variable-comment nil))) | |
173 | ||
174 | (defun no-littering-custom-reset () | |
175 | (dolist (var (no-littering-get-themed-variables)) | |
176 | (no-littering--custom-reset-symbol (car var)))) | |
177 | #+end_src |
0 | ;;; no-littering.el --- help keeping ~/.emacs.d clean -*- lexical-binding: t; -*- | |
1 | ||
2 | ;; Copyright (C) 2016-2022 Jonas Bernoulli | |
0 | ;;; no-littering.el --- Help keeping ~/.config/emacs clean -*- lexical-binding:t -*- | |
1 | ||
2 | ;; Copyright (C) 2016-2023 Jonas Bernoulli | |
3 | 3 | |
4 | 4 | ;; Author: Jonas Bernoulli <jonas@bernoul.li> |
5 | 5 | ;; Homepage: https://github.com/emacscollective/no-littering |
6 | ;; Package-Requires: ((cl-lib "0.5")) | |
7 | ||
8 | ;; This file is not part of GNU Emacs. | |
9 | ||
10 | ;; This file is free software; you can redistribute it and/or modify | |
11 | ;; it under the terms of the GNU General Public License as published by | |
12 | ;; the Free Software Foundation; either version 3, or (at your option) | |
13 | ;; any later version. | |
14 | ||
6 | ;; Keywords: convenience | |
7 | ||
8 | ;; Package-Requires: ((emacs "25.1") (compat "29.1.4.1")) | |
9 | ||
10 | ;; SPDX-License-Identifier: GPL-3.0-or-later | |
11 | ||
12 | ;; This file is free software: you can redistribute it and/or modify | |
13 | ;; it under the terms of the GNU General Public License as published | |
14 | ;; by the Free Software Foundation, either version 3 of the License, | |
15 | ;; or (at your option) any later version. | |
16 | ;; | |
15 | 17 | ;; This file is distributed in the hope that it will be useful, |
16 | 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | 20 | ;; GNU General Public License for more details. |
19 | ||
20 | ;; For a full copy of the GNU General Public License | |
21 | ;; see https://www.gnu.org/licenses. | |
21 | ;; | |
22 | ;; You should have received a copy of the GNU General Public License | |
23 | ;; along with this file. If not, see <https://www.gnu.org/licenses/>. | |
22 | 24 | |
23 | 25 | ;;; Commentary: |
24 | 26 | |
25 | ;; Help keeping ~/.emacs.d clean. | |
27 | ;; Help keeping ~/.config/emacs clean. | |
26 | 28 | |
27 | 29 | ;; The default paths used to store configuration files and persistent |
28 | 30 | ;; data are not consistent across Emacs packages. This isn't just a |
36 | 38 | ;; This package sets out to fix this by changing the values of path |
37 | 39 | ;; variables to put configuration files in `no-littering-etc-directory' |
38 | 40 | ;; (defaulting to "etc/" under `user-emacs-directory', thus usually |
39 | ;; "~/.emacs.d/etc/") and persistent data files in | |
41 | ;; "~/.config/emacs/etc/") and persistent data files in | |
40 | 42 | ;; `no-littering-var-directory' (defaulting to "var/" under |
41 | 43 | ;; `user-emacs-directory', thus usually "~/.emacs.d/var/"), and |
42 | 44 | ;; by using descriptive file names and subdirectories when appropriate. |
175 | 177 | ;;; Code: |
176 | 178 | |
177 | 179 | (require 'cl-lib) |
180 | (require 'compat) | |
178 | 181 | |
179 | 182 | (defvar no-littering-etc-directory |
180 | 183 | (expand-file-name (convert-standard-filename "etc/") user-emacs-directory) |
211 | 214 | (setq abbrev-file-name (etc "abbrev.el")) |
212 | 215 | (setq auto-insert-directory (etc "auto-insert/")) |
213 | 216 | (setq auto-save-list-file-prefix (var "auto-save/sessions/")) |
214 | (setq backup-directory-alist (list (cons "." (var "backup/")))) | |
215 | 217 | (setq bookmark-default-file (var "bookmark-default.el")) |
216 | 218 | (setq calc-settings-file (etc "calc-settings.el")) |
217 | (eval-after-load 'desktop | |
218 | `(make-directory ,(var "desktop/") t)) | |
219 | 219 | (setq desktop-dirname (var "desktop/")) |
220 | 220 | (setq desktop-path (list desktop-dirname)) |
221 | 221 | (setq diary-file (var "diary")) |
222 | 222 | (setq ecomplete-database-file (var "ecomplete-database.el")) |
223 | 223 | (setq ede-project-placeholder-cache-file (var "ede-projects.el")) |
224 | (eval-after-load 'erc | |
225 | `(make-directory ,(var "erc/dcc/") t)) | |
226 | 224 | (setq erc-dcc-get-default-directory (var "erc/dcc/")) |
227 | 225 | (setq erc-log-channels-directory (var "erc/log-channels/")) |
228 | (eval-after-load 'eshell | |
229 | `(make-directory ,(etc "eshell/") t)) | |
230 | 226 | (setq eshell-aliases-file (etc "eshell/aliases")) |
231 | 227 | (setq eshell-directory-name (var "eshell/")) |
228 | (setq eshell-login-script (etc "eshell/login")) | |
229 | (setq eshell-rc-script (etc "eshell/rc")) | |
232 | 230 | (setq eudc-options-file (etc "eudc-options.el")) |
233 | (eval-after-load 'eww | |
234 | `(make-directory ,(var "eww/") t)) | |
235 | 231 | (setq eww-bookmarks-directory (var "eww/")) |
236 | 232 | (setq filesets-menu-cache-file (var "filesets-menu-cache.el")) |
237 | 233 | (setq gamegrid-user-score-file-directory (var "gamegrid-user-score/")) |
238 | (eval-after-load 'gnus | |
239 | `(make-directory ,(var "gnus/dribble/") t)) | |
240 | 234 | (setq gnus-dribble-directory (var "gnus/dribble/")) |
241 | 235 | (setq gnus-init-file (etc "gnus/init.el")) |
236 | ;; Gnus hardcodes newsrc.eld to be based on gnus-startup-file. | |
237 | (setq gnus-startup-file (etc "gnus/newsrc")) | |
242 | 238 | (setq ido-save-directory-list-file (var "ido-save-directory-list.el")) |
243 | 239 | (setq image-dired-db-file (var "image-dired/db.el")) |
244 | 240 | (setq image-dired-dir (var "image-dired/")) |
247 | 243 | (setq image-dired-temp-rotate-image-file (var "image-dired/temp-rotate-image")) |
248 | 244 | (setq kkc-init-file-name (var "kkc-init.el")) |
249 | 245 | (setq multisession-directory (var "multisession/")) |
250 | (eval-after-load 'newsticker | |
251 | `(make-directory ,(var "newsticker/") t)) | |
252 | 246 | (setq newsticker-cache-filename (var "newsticker/cache.el")) |
253 | 247 | (setq newsticker-dir (var "newsticker/data/")) |
254 | 248 | (setq nsm-settings-file (var "nsm-settings.el")) |
255 | (eval-after-load 'org | |
256 | `(make-directory ,(var "org/") t)) | |
257 | 249 | (setq org-clock-persist-file (var "org/clock-persist.el")) |
258 | 250 | (setq org-id-locations-file (var "org/id-locations.el")) |
259 | 251 | (setq org-persist-directory (var "org/persist/")) |
262 | 254 | (setq quickurl-url-file (var "quickurl-url.el")) |
263 | 255 | (setq rcirc-log-directory (var "rcirc-log/")) |
264 | 256 | (setq recentf-save-file (var "recentf-save.el")) |
257 | (setq remember-data-directory (var "remember/data.d/")) | |
265 | 258 | (setq remember-data-file (var "remember/data")) |
266 | (setq remember-data-directory (var "remember/data.d/")) | |
267 | 259 | (setq save-place-file (var "save-place.el")) |
268 | 260 | (setq savehist-file (var "savehist.el")) |
269 | (setq srecode-map-save-file (var "srecode-map.el")) | |
270 | 261 | (setq semanticdb-default-save-directory (var "semantic/")) |
271 | (eval-after-load 'shadowfile | |
272 | `(make-directory ,(var "shadow/") t)) | |
273 | 262 | (setq shadow-info-file (var "shadow/info.el")) |
274 | 263 | (setq shadow-todo-file (var "shadow/todo.el")) |
275 | 264 | (setq shared-game-score-directory (var "shared-game-score/")) |
265 | (setq srecode-map-save-file (var "srecode-map.el")) | |
276 | 266 | (setq timeclock-file (var "timeclock")) |
277 | 267 | (setq tramp-auto-save-directory (var "tramp/auto-save/")) |
278 | 268 | (setq tramp-persistency-file-name (var "tramp/persistency.el")) |
282 | 272 | (setq url-cookie-file (var "url/cookies.el")) |
283 | 273 | (setq url-history-file (var "url/history.el")) |
284 | 274 | |
275 | (eval-after-load 'desktop '(make-directory desktop-dirname t)) | |
276 | (eval-after-load 'erc '(make-directory erc-dcc-get-default-directory t)) | |
277 | (eval-after-load 'eshell '(make-directory eshell-directory-name t)) | |
278 | (eval-after-load 'eww '(make-directory eww-bookmarks-directory t)) | |
279 | (eval-after-load 'gnus `(make-directory ,(etc "gnus/") t)) | |
280 | (eval-after-load 'gnus '(make-directory gnus-dribble-directory t)) | |
281 | (eval-after-load 'newsticker `(make-directory ,(var "newsticker/") t)) | |
282 | (eval-after-load 'org `(make-directory ,(var "org/") t)) | |
283 | (eval-after-load 'shadowfile `(make-directory ,(var "shadow/") t)) | |
284 | ||
285 | 285 | ;;; Third-party packages |
286 | 286 | |
287 | (setq abm-file (var "autobookmarks.el")) | |
287 | 288 | (setq ac-comphist-file (var "ac-comphist.el")) |
288 | 289 | (setq amx-save-file (var "amx-save.el")) |
289 | 290 | (setq anaconda-mode-installation-directory (var "anaconda-mode/")) |
290 | 291 | (setq annotate-file (var "annotations.el")) |
291 | 292 | (setq async-byte-compile-log-file (var "async-bytecomp.log")) |
292 | 293 | (setq auto-package-update-last-update-day-path (var "auto-package-update-last-update-day")) |
293 | (eval-after-load 'bbdb | |
294 | `(make-directory ,(var "bbdb/") t)) | |
295 | 294 | (setq bbdb-file (var "bbdb/bbdb.el")) |
296 | 295 | (setq bbdb-vcard-directory (var "bbdb/vcard/")) |
297 | 296 | (setq bm-repository-file (var "bm-repository.el")) |
298 | (eval-after-load 'bookmark+-1 | |
299 | `(make-directory ,(var "bmkp/") t)) | |
300 | 297 | (setq bmkp-bmenu-commands-file (var "bmkp/bmenu-commands.el")) |
301 | 298 | (setq bmkp-current-bookmark-file (var "bmkp/current-bookmark.el")) |
302 | 299 | (setq bmkp-last-bookmark-file (var "bmkp/last-bookmark.el")) |
303 | 300 | (setq bookiez-file (var "bookiez")) |
304 | 301 | (setq cider-repl-history-file (var "cider-repl-history.el")) |
302 | (setq clm/logging-dir (var "command-log-mode/logging/")) | |
305 | 303 | (setq code-review-db-database-file (var "code-review/database.sqlite")) |
306 | 304 | (setq code-review-download-dir (var "code-review/downloads/")) |
307 | 305 | (setq code-review-log-file (var "code-review/log")) |
308 | (eval-after-load 'command-log-mode | |
309 | `(make-directory ,(var "command-log-mode-logging/") t)) | |
310 | (setq clm/logging-dir (var "command-log-mode/logging/")) | |
311 | (eval-after-load 'company | |
312 | `(make-directory ,(var "company/") t)) | |
313 | 306 | (setq company-statistics-file (var "company/statistics.el")) |
314 | 307 | (setq company-tabnine-binaries-folder (var "company/tabnine-binaries")) |
315 | 308 | (setq conventional-changelog-tmp-dir (var "conventional-changelog/")) |
317 | 310 | (setq dap-java-test-runner (var "lsp-java/eclipse.jdt.ls/test-runner/junit-platform-console-standalone.jar")) |
318 | 311 | (setq dap-utils-extension-path (var "dap/extensions/")) |
319 | 312 | (setq debbugs-gnu-persistency-file (var "debbugs.el")) |
313 | (setq detached-db-directory (var "detached/db/")) | |
314 | (setq detached-session-directory (var "detached/sessions/")) | |
320 | 315 | (setq devdocs-browser-cache-directory (var "devdocs/browser-cache/")) |
321 | 316 | (setq devdocs-data-dir (var "devdocs/data/")) |
322 | 317 | (setq dired-recent-directories-file (var "dired-recent-directories.el")) |
323 | 318 | (setq dirvish-cache-dir (var "dirvish/cache")) |
324 | 319 | (setq elbank-data-file (var "elbank-data.el")) |
325 | (setq elmo-msgdb-directory (var "elmo/")) | |
326 | (setq elmo-split-log-file (var "elmo/split-log")) | |
327 | (eval-after-load 'elfeed | |
328 | `(make-directory ,(var "elfeed/") t)) | |
320 | (setq elfeed-autotag-files (list (etc "elfeed/autotags.org"))) | |
329 | 321 | (setq elfeed-db-directory (var "elfeed/db/")) |
330 | 322 | (setq elfeed-enclosure-default-dir (var "elfeed/enclosures/")) |
331 | 323 | (setq elfeed-score-score-file (etc "elfeed/score/score.el")) |
324 | (setq elgrep-data-file (var "elgrep-data.el")) | |
325 | (setq elmo-msgdb-directory (var "elmo/")) | |
326 | (setq elmo-split-log-file (var "elmo/split-log")) | |
332 | 327 | (setq elpher-bookmarks-file (var "elpher-bookmarks.el")) |
333 | (eval-after-load 'x-win | |
334 | (let ((session-dir (var "emacs-session/"))) | |
335 | `(progn | |
336 | (make-directory ,session-dir t) | |
337 | (defun emacs-session-filename (session-id) | |
338 | "Construct a filename to save the session in based on SESSION-ID. | |
339 | This function overrides the one on `x-win' to use `no-littering' | |
340 | directories." | |
341 | (expand-file-name session-id ,session-dir))))) | |
342 | 328 | (setq emms-directory (var "emms/")) |
343 | (eval-after-load 'emojify | |
344 | `(make-directory ,(var "emojify/") t)) | |
345 | 329 | (setq emojify-emojis-dir (var "emojify/")) |
346 | 330 | (setq epkg-repository (var "epkgs/")) |
347 | 331 | (setq equake-persistent-display-file (var "equake-persistent-display")) |
332 | (setq fontaine-latest-state-file (var "fontaine-latest-state.eld")) | |
348 | 333 | (setq forge-database-file (var "forge/database.sqlite")) |
349 | 334 | (setq forge-post-directory (var "forge/posts/")) |
350 | 335 | (setq geben-temporary-file-directory (var "geben/")) |
351 | (eval-after-load 'geiser | |
352 | `(make-directory ,(var "geiser/") t)) | |
353 | 336 | (setq geiser-repl-history-filename (var "geiser/repl-history")) |
337 | (setq gnus-notes-file (var "gnus-notes/articles.el")) | |
338 | (setq gnus-notes-top-dir (var "gnus-notes/")) | |
339 | (setq grammalecte-settings-file (etc "grammalecte-settings.el")) | |
354 | 340 | (setq hackernews-visited-links-file (var "hackernews/visited-links.el")) |
355 | (eval-after-load 'helm | |
356 | `(make-directory ,(var "helm/") t)) | |
341 | (setq harpoon-cache-file (var "harpoon/")) | |
357 | 342 | (setq helm-adaptive-history-file (var "helm/adaptive-history.el")) |
358 | 343 | (setq helm-backup-path (var "helm/backup/")) |
359 | 344 | (setq helm-github-stars-cache-file (var "helm/github-stars-cache.el")) |
363 | 348 | (setq irfc-directory (var "irfc/")) |
364 | 349 | (setq irony-user-dir (var "irony/")) |
365 | 350 | (setq jabber-avatar-cache-directory (var "jabber/avatar-cache")) |
366 | (eval-after-load 'jabber | |
367 | `(make-directory ,(var "jabber/avatar-cache/") t)) | |
368 | 351 | (setq jabber-history-dir (var "jabber/history")) |
369 | (eval-after-load 'jabber | |
370 | `(make-directory ,(var "jabber/history/") t)) | |
371 | 352 | (setq keyfreq-file (var "keyfreq.el")) |
372 | 353 | (setq keyfreq-file-lock (var "keyfreq.lock")) |
373 | 354 | (setq libbcel-oauth-store-filename (var "libbcel-oauth-store.el.gpg")) |
374 | 355 | (setq litable-list-file (var "litable-list.el")) |
375 | 356 | (setq logview-cache-filename (var "logview-cache")) |
376 | 357 | (setq logview-views-file (etc "logview-views")) |
377 | (eval-after-load 'lookup | |
378 | `(make-directory ,(etc "lookup/") t)) | |
379 | 358 | (setq lookup-init-directory (etc "lookup/")) |
380 | 359 | (setq lsp-clojure-workspace-dir (var "lsp-clojure/workspace/")) |
381 | 360 | (setq lsp-eslint-library-choices-file (var "lsp/eslint-library-choices.el")) |
361 | (setq lsp-java-server-install-dir (var "lsp-java/eclipse.jdt.ls/server/")) | |
362 | (setq lsp-java-workspace-dir (var "lsp-java/workspace/")) | |
363 | (setq lsp-ltex-user-rules-path (var "lsp-ltex/")) | |
382 | 364 | (setq lsp-python-ms-dir (var "lsp-python-ms/")) |
383 | (eval-after-load 'lsp-mode | |
384 | `(make-directory ,(var "lsp/") t)) | |
385 | 365 | (setq lsp-server-install-dir (var "lsp/server/")) |
386 | 366 | (setq lsp-session-file (var "lsp/session.el")) |
387 | (setq lsp-java-workspace-dir (var "lsp-java/workspace/")) | |
388 | (setq lsp-java-server-install-dir (var "lsp-java/eclipse.jdt.ls/server/")) | |
367 | (setq magithub-cache-file (var "magithub/cache.el")) | |
389 | 368 | (setq magithub-dir (var "magithub/")) |
390 | (setq magithub-cache-file (var "magithub/cache.el")) | |
391 | 369 | (setq mc/list-file (var "mc-list.el")) |
392 | 370 | (setq meghanada-server-install-dir (var "meghanada/")) |
393 | 371 | (setq multi-compile-history-file (var "multi-compile-history.el")) |
394 | 372 | (setq nix-buffer-directory-name (var "nix-buffer/")) |
373 | (setq nomad-tramp-script-directory (var "nomad-tramp/")) | |
395 | 374 | ;; The value of this variable MUST NOT end with ".el" but the |
396 | 375 | ;; actual file name MUST end with ".el". Use "git blame" for |
397 | 376 | ;; more information. |
398 | 377 | (setq notmuch-init-file (etc "notmuch-init")) |
399 | 378 | (setq nov-save-place-file (var "nov-save-place.el")) |
400 | 379 | (setq omnisharp-cache-directory (var "omnisharp/cache")) |
401 | (setq org-gcal-dir (var "org/gcal/")) | |
402 | (eval-after-load 'org-caldav | |
403 | `(make-directory ,(var "org/caldav/save") t)) | |
404 | 380 | (setq org-caldav-backup-file (var "org/caldav/backup.org")) |
405 | 381 | (setq org-caldav-save-directory (var "org/caldav/save")) |
382 | (setq org-gcal-dir (var "org/gcal/")) | |
406 | 383 | (setq org-journal-cache-file (var "org/journal-cache.el")) |
407 | 384 | (setq org-recent-headings-save-file (var "org/recent-headings.el")) |
408 | 385 | (setq org-registry-file (var "org/registry.el")) |
414 | 391 | (setq persist--directory-location (var "persist/")) |
415 | 392 | (setq persistent-scratch-save-file (var "persistent-scratch.el")) |
416 | 393 | (setq persp-save-dir (var "persp-mode/")) |
417 | (eval-after-load 'projectile | |
418 | `(make-directory ,(var "projectile/") t)) | |
419 | 394 | (setq prescient-save-file (var "prescient-save.el")) |
420 | 395 | (setq projectile-cache-file (var "projectile/cache.el")) |
421 | 396 | (setq projectile-known-projects-file (var "projectile/known-projects.el")) |
424 | 399 | (setq purpose-layout-dirs (list (etc "window-purpose/layouts/"))) |
425 | 400 | (setq pyim-dcache-directory (var "pyim/dcache/")) |
426 | 401 | (setq quack-dir (var "quack/")) |
402 | (setq racket-repl-history-directory (var "racket-mode/repl-history/")) | |
403 | (setq request-storage-directory (var "request/storage/")) | |
427 | 404 | (setq rfc-mode-directory (var "rfc-mode/")) |
428 | (setq request-storage-directory (var "request/storage/")) | |
429 | 405 | (setq rime-user-data-dir (var "rime/")) |
430 | (setq rmh-elfeed-org-files (list (var "elfeed/rmh-elfeed.org"))) | |
406 | (setq rmh-elfeed-org-files (list (etc "elfeed/rmh-elfeed.org"))) | |
431 | 407 | (setq runner-init-file (var "runner-init.el")) |
432 | 408 | (setq save-kill-file-name (var "save-kill.el")) |
433 | 409 | (setq save-visited-files-location (var "save-visited-files-location")) |
434 | (eval-after-load 'sly | |
435 | `(make-directory ,(var "sly/") t)) | |
410 | (setq session-save-file (var "session.el")) | |
436 | 411 | (setq sly-mrepl-history-file-name (var "sly/mrepl-history")) |
437 | 412 | (setq smex-save-file (var "smex-save.el")) |
438 | 413 | (setq speed-type-gb-dir (var "speed-type/")) |
439 | (eval-after-load 'sx | |
440 | `(make-directory ,(var "sx/cache/") t)) | |
414 | (setq spell-fu-directory (var "spell-fu/")) | |
415 | (setq svg-lib-icons-dir (var "svg-lib/icons/")) | |
441 | 416 | (setq sx-cache-directory (var "sx/cache/")) |
442 | 417 | (setq tldr-directory-path (var "tldr/")) |
443 | 418 | (setq transient-history-file (var "transient/history.el")) |
444 | 419 | (setq transient-levels-file (etc "transient/levels.el")) |
445 | 420 | (setq transient-values-file (etc "transient/values.el")) |
421 | (setq treemacs-last-error-persist-file (var "treemacs/persist-last-error.org")) | |
446 | 422 | (setq treemacs-persist-file (var "treemacs/persist.org")) |
447 | (setq treemacs-last-error-persist-file (var "treemacs/persist-last-error.org")) | |
448 | 423 | (setq undo-fu-session-directory (var "undo-fu-session/")) |
449 | 424 | (setq undohist-directory (var "undohist/")) |
450 | (setq undo-tree-history-directory-alist (list (cons "." (var "undo-tree-hist/")))) | |
425 | (setq uptimes-database (var "uptimes.el")) | |
451 | 426 | (setq user-emacs-ensime-directory (var "ensime/")) |
452 | 427 | (setq vimish-fold-dir (var "vimish-fold/")) |
453 | (eval-after-load 'wl | |
454 | `(make-directory ,(etc "wanderlust") t)) | |
455 | (setq wl-init-file (etc "wanderlust/init.el")) | |
456 | (setq wl-folders-file (etc "wanderlust/folders")) | |
457 | 428 | (setq wl-address-file (etc "wanderlust/address")) |
458 | 429 | (setq wl-alias-file (etc "wanderlust/alias")) |
430 | (setq wl-folders-file (etc "wanderlust/folders")) | |
431 | (setq wl-init-file (etc "wanderlust/init.el")) | |
432 | (setq wl-temporary-file-directory (var "wanderlust-tmp")) | |
459 | 433 | (setq wl-x-face-file (etc "wanderlust/x-face")) |
460 | (setq wl-temporary-file-directory (var "wanderlust-tmp")) | |
461 | 434 | (setq x86-lookup-cache-directory (var "x86-lookup/cache/")) |
462 | (eval-after-load 'xkcd | |
463 | `(make-directory ,(var "xkcd/") t)) | |
464 | 435 | (setq xkcd-cache-dir (var "xkcd/")) |
465 | (eval-after-load 'yasnippet | |
466 | `(make-directory ,(etc "yasnippet/snippets/") t)) | |
467 | 436 | (setq yas-snippet-dirs (list (etc "yasnippet/snippets/"))) |
437 | ||
438 | (eval-after-load 'bbdb `(make-directory ,(var "bbdb/") t)) | |
439 | (eval-after-load 'bookmark+-1 `(make-directory ,(var "bmkp/") t)) | |
440 | (eval-after-load 'command-log-mode '(make-directory clm/logging-dir t)) | |
441 | (eval-after-load 'company `(make-directory ,(var "company/") t)) | |
442 | (eval-after-load 'elfeed `(make-directory ,(var "elfeed/") t)) | |
443 | (eval-after-load 'emojify '(make-directory emojify-emojis-dir t)) | |
444 | (eval-after-load 'geiser `(make-directory ,(var "geiser/") t)) | |
445 | (eval-after-load 'helm `(make-directory ,(var "helm/") t)) | |
446 | (eval-after-load 'jabber '(make-directory jabber-avatar-cache-directory t)) | |
447 | (eval-after-load 'jabber '(make-directory jabber-history-dir t)) | |
448 | (eval-after-load 'lookup '(make-directory lookup-init-directory t)) | |
449 | (eval-after-load 'lsp-mode `(make-directory ,(var "lsp/") t)) | |
450 | (eval-after-load 'org-caldav '(make-directory org-caldav-save-directory t)) | |
451 | (eval-after-load 'projectile `(make-directory ,(var "projectile/") t)) | |
452 | (eval-after-load 'sly `(make-directory ,(var "sly/") t)) | |
453 | (eval-after-load 'sx '(make-directory sx-cache-directory t)) | |
454 | (eval-after-load 'wl `(make-directory ,(etc "wanderlust") t)) | |
455 | (eval-after-load 'xkcd '(make-directory xkcd-cache-dir t)) | |
456 | (eval-after-load 'yasnippet '(make-directory (car yas-snippet-dirs) t)) | |
468 | 457 | )) |
458 | ||
459 | ;;; Advices | |
460 | ||
461 | (defun no-littering-emacs-session-filename (session-id) | |
462 | "Construct a filename to save the session in, based on SESSION-ID. | |
463 | Unconditionally return a filename in `no-littering-var-directory'." | |
464 | (let ((dir (no-littering-expand-var-file-name "emacs-session/"))) | |
465 | (make-directory dir t) | |
466 | (expand-file-name session-id dir))) | |
467 | ||
468 | (advice-add 'emacs-session-filename :override | |
469 | #'no-littering-emacs-session-filename) | |
470 | ||
471 | ;;; Backups | |
472 | ||
473 | (defvar undo-tree-history-directory-alist) | |
474 | ||
475 | (defun no-littering-theme-backups () | |
476 | "Theme locations where backups of various sorts are created. | |
477 | ||
478 | The purpose of this package is to store data files of various | |
479 | sorts in a handful of central locations, instead of spreading | |
480 | them all over the place. When doing that for temporary files, | |
481 | which contain backups of some sort, that increases the odds that | |
482 | sensitive data is written to disk in clear text and/or that such | |
483 | clear text files persist longer, if they would be created anyway. | |
484 | ||
485 | Because of that, simply loading `no-littering' does not theme | |
486 | certain, potentially unsafe variables. Instead, this function is | |
487 | provided, so that you can decide whether to take the risk or not. | |
488 | ||
489 | Calling this function sets these variables: | |
490 | - `auto-save-file-name-transforms' (built-in) | |
491 | - `backup-directory-alist' (built-in) | |
492 | - `undo-tree-history-directory-alist' (from `undo-tree') | |
493 | ||
494 | The default values of these variables cause additional files to | |
495 | be created in the same directories as the files that are being | |
496 | visited. Calling this function changes the values of these | |
497 | variables, so that this is only done for visited files located in | |
498 | certain directories. For all other visited files, the additional | |
499 | files are created in files inside `no-littering-var-directory'. | |
500 | ||
501 | Additional files are created in the same directory as the visited | |
502 | file, for files located in: | |
503 | - \"/tmp/\" | |
504 | - \"/dev/shm\" | |
505 | - `temporary-file-directory' | |
506 | ||
507 | With these settings it is still possible that sensitive data is | |
508 | written to additional files, but you are more likely to spot it, | |
509 | and because these directories usually use a `tmpfs' file-system, | |
510 | the leaked secrets should not persist after a reboot. | |
511 | ||
512 | If you do *not* call this function, then these additional files | |
513 | are always created in the same directory as the visited files, | |
514 | regardless of the location of the visited files. In other words, | |
515 | even when using the default values, there is a significant risk | |
516 | of leaking sensitive data, and if you want to reduce that, then | |
517 | you must turn of these features completely." | |
518 | (setq auto-save-file-name-transforms | |
519 | `(("\\`/[^/]*:\\([^/]*/\\)*\\([^/]*\\)\\'" | |
520 | ,(concat (file-name-as-directory temporary-file-directory) "\\2") t) | |
521 | ("\\`/tmp\\([^/]*/\\)*\\(.*\\)\\'" "\\2") | |
522 | ("\\`/dev/shm\\([^/]*/\\)*\\(.*\\)\\'" "\\2") | |
523 | (".*" ,(no-littering-expand-var-file-name "auto-save/") t))) | |
524 | (setq backup-directory-alist | |
525 | `((,(concat "\\`" (file-name-as-directory temporary-file-directory))) | |
526 | ("\\`/tmp/" . nil) | |
527 | ("\\`/dev/shm/" . nil) | |
528 | ("." . ,(no-littering-expand-var-file-name "backup/")))) | |
529 | (setq undo-tree-history-directory-alist | |
530 | `((,(concat "\\`" (file-name-as-directory temporary-file-directory))) | |
531 | ("\\`/tmp/" . nil) | |
532 | ("\\`/dev/shm/" . nil) | |
533 | ("." . ,(no-littering-expand-var-file-name "undo-tree-hist/")))) | |
534 | ) | |
469 | 535 | |
470 | 536 | ;;; _ |
471 | 537 | (provide 'no-littering) |