aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoam Postavsky2018-05-12 15:09:18 -0400
committerNoam Postavsky2018-05-15 19:32:49 -0400
commit2fda57c6fb29262261911819ec8f5e4cccb3abbb (patch)
tree1a0a7d98e52bc99669e540354c8ab10cd1f59e4b
parenta4c616e27aa48e7d524e0c5cfaf67f17d04989e4 (diff)
downloademacs-2fda57c6fb29262261911819ec8f5e4cccb3abbb.tar.gz
emacs-2fda57c6fb29262261911819ec8f5e4cccb3abbb.zip
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.
-rw-r--r--lisp/eshell/esh-opt.el11
1 files 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."
200 (if (eq (nth 2 opt) t) 200 (if (eq (nth 2 opt) t)
201 (if (> ai (length eshell--args)) 201 (if (> ai (length eshell--args))
202 (error "%s: missing option argument" name) 202 (error "%s: missing option argument" name)
203 (prog1 (nth ai eshell--args) 203 (pop (nthcdr ai eshell--args)))
204 (if (> ai 0)
205 (setcdr (nthcdr (1- ai) eshell--args)
206 (nthcdr (1+ ai) eshell--args))
207 (setq eshell--args (cdr eshell--args)))))
208 (or (nth 2 opt) t))))) 204 (or (nth 2 opt) t)))))
209 205
210(defun eshell--process-option (name switch kind ai options opt-vals) 206(defun eshell--process-option (name switch kind ai options opt-vals)
@@ -264,10 +260,7 @@ switch is unrecognized."
264 ;; dash or switch argument found, parse 260 ;; dash or switch argument found, parse
265 (let* ((dash (match-string 1 arg)) 261 (let* ((dash (match-string 1 arg))
266 (switch (match-string 2 arg))) 262 (switch (match-string 2 arg)))
267 (if (= ai 0) 263 (pop (nthcdr ai eshell--args))
268 (setq eshell--args (cdr eshell--args))
269 (setcdr (nthcdr (1- ai) eshell--args)
270 (nthcdr (1+ ai) eshell--args)))
271 (if dash 264 (if dash
272 (if (> (length switch) 0) 265 (if (> (length switch) 0)
273 (eshell--process-option name switch 1 ai options opt-vals) 266 (eshell--process-option name switch 1 ai options opt-vals)