diff options
author | Ondřej Lysoněk <olysonek@redhat.com> | 2020-06-09 15:12:35 +0200 |
---|---|---|
committer | Jean Delvare <jdelvare@suse.de> | 2020-06-09 15:12:35 +0200 |
commit | 97e59ae6ffeef1a6d54eeab11f0fbdea59cb6425 (patch) | |
tree | a9b1f9db774406917913f9b9c929388350383430 /lib | |
parent | 8e185cb2f2f0a012cb2a7f458ecff45b6a102b91 (diff) | |
download | quilt-97e59ae6ffeef1a6d54eeab11f0fbdea59cb6425.tar.gz |
quilt.el: Refactor config reading functions
quilt-patches-directory is a copy-paste of
quilt-pc-directory. Refactor the common code into a separate
function.
Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/quilt.el | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/lib/quilt.el b/lib/quilt.el index 9865637..5e36746 100644 --- a/lib/quilt.el +++ b/lib/quilt.el @@ -29,12 +29,12 @@ "Return t if there is on the bottom of patch stack, return nil if otherwise." (if (> (call-process "quilt" nil nil nil "applied") 0) 1)) -(defun quilt-patches-directory () - "Return the location of patch files." +(defun quilt--get-config-variable (var) + "Return the value of a configuration variable. Return nil if it is unset." (or (with-current-buffer (generate-new-buffer " *cmd") (shell-command (concat "test -f ~/.quiltrc && . ~/.quiltrc ;" - "echo -n $QUILT_PATCHES") + "echo -n $" var) t) (unwind-protect (let ((v (buffer-string))) @@ -42,24 +42,17 @@ nil v)) (kill-buffer (current-buffer)))) - (or (getenv "QUILT_PATCHES") - "patches"))) + (getenv var))) + +(defun quilt-patches-directory () + "Return the location of patch files." + (or (quilt--get-config-variable "QUILT_PATCHES") + "patches")) (defun quilt-pc-directory () "Return the location of the quilt working state directory." - (or (with-current-buffer (generate-new-buffer " *cmd") - (shell-command - (concat "test -f ~/.quiltrc && . ~/.quiltrc ;" - "echo -n $QUILT_PC") - t) - (unwind-protect - (let ((v (buffer-string))) - (if (string= "" (buffer-string)) - nil - v)) - (kill-buffer (current-buffer)))) - (or (getenv "QUILT_PC") - ".pc"))) + (or (quilt--get-config-variable "QUILT_PC") + ".pc")) (defun quilt-find-dir (fn &optional prefn) "Return the top level dir of quilt from FN." |