]> git.eshelyaron.com Git - emacs.git/commitdiff
Simplify eshell arg processing with (pop (nthcdr ...))
authorNoam Postavsky <npostavs@gmail.com>
Sat, 12 May 2018 19:09:18 +0000 (15:09 -0400)
committerNoam Postavsky <npostavs@gmail.com>
Tue, 15 May 2018 23:32:49 +0000 (19:32 -0400)
* 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

index 80eb15359a29ff098a940c8fe4d55b68934af99b..d7a449450f99d77c8cefcae6cda443d3aab23c69 100644 (file)
@@ -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)