aboutsummaryrefslogtreecommitdiff
path: root/edit-config.el
diff options
context:
space:
mode:
Diffstat (limited to 'edit-config.el')
-rw-r--r--edit-config.el26
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))