From 2fda57c6fb29262261911819ec8f5e4cccb3abbb Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 12 May 2018 15:09:18 -0400 Subject: [PATCH] Simplify eshell arg processing with (pop (nthcdr ...)) * lisp/eshell/esh-opt.el (eshell--set-option) (eshell--process-args): Use (pop (nthcdr ...)) instead of writing it out by hand. --- lisp/eshell/esh-opt.el | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lisp/eshell/esh-opt.el b/lisp/eshell/esh-opt.el index 80eb15359a2..d7a449450f9 100644 --- a/lisp/eshell/esh-opt.el +++ b/lisp/eshell/esh-opt.el @@ -200,11 +200,7 @@ will be modified." (if (eq (nth 2 opt) t) (if (> ai (length eshell--args)) (error "%s: missing option argument" name) - (prog1 (nth ai eshell--args) - (if (> ai 0) - (setcdr (nthcdr (1- ai) eshell--args) - (nthcdr (1+ ai) eshell--args)) - (setq eshell--args (cdr eshell--args))))) + (pop (nthcdr ai eshell--args))) (or (nth 2 opt) t))))) (defun eshell--process-option (name switch kind ai options opt-vals) @@ -264,10 +260,7 @@ switch is unrecognized." ;; dash or switch argument found, parse (let* ((dash (match-string 1 arg)) (switch (match-string 2 arg))) - (if (= ai 0) - (setq eshell--args (cdr eshell--args)) - (setcdr (nthcdr (1- ai) eshell--args) - (nthcdr (1+ ai) eshell--args))) + (pop (nthcdr ai eshell--args)) (if dash (if (> (length switch) 0) (eshell--process-option name switch 1 ai options opt-vals) -- 2.11.4.GIT