diff options
author | Tristan Riehs <tristan.riehs@bordeaux-inp.fr> | 2024-03-19 13:09:25 +0100 |
---|---|---|
committer | Tristan Riehs <tristan.riehs@bordeaux-inp.fr> | 2024-03-19 13:09:25 +0100 |
commit | 60eb1227f5ca967107f6e40859f6892483660681 (patch) | |
tree | 6a2196b8121ec9693c27b550d5f5f76a2a061b4e | |
parent | 10541ce5fe70585b6281ceea8cdb638228b52d12 (diff) |
Add the edit-config-missing customization
-rw-r--r-- | edit-config.el | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/edit-config.el b/edit-config.el index 3477024..2dddb3d 100644 --- a/edit-config.el +++ b/edit-config.el @@ -30,6 +30,18 @@ :group 'emacs :prefix "edit-config") +(defcustom edit-config-missing nil + "Whether to propose files that do not exist. + +If set to nil, configuration files that are present in +`edit-config-files' and do not exist on the current machine will no be +proposed by the interactive prompt of `edit-config'. This allows you to +put all the configuration files you have on all your machines, without +polluting the prompt when using a machine that does not have all of +them. If set to non-nil, they will all be proposed anyway." + :group 'edit-config + :type 'boolean) + (defcustom edit-config-files nil "The list of config files. @@ -39,12 +51,24 @@ configuration file." :group 'edit-config :type '(alist :key-type string :value-type string)) +(defun edit-config--completing-read-predicate (config) + "Predicate to use in `edit-config'. + +Used when prompting only when `edit-config-missing' is non-nil. See +`edit-config-files' for the structure of CONFIG." + (file-exists-p (cdr config))) + ;;;###autoload (defun edit-config (label) "Edit the config file associated to LABEL." (interactive (list (if edit-config-files - (completing-read "Config: " edit-config-files nil t) + (completing-read "Config: " + edit-config-files + (if edit-config-missing + 'edit-config--completing-read-predicate + nil) + t) nil))) (if label (find-file (alist-get label edit-config-files nil nil 'string-equal)) |