]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/pcomplete.el (pcomplete-arg): Simplify
authorStefan Monnier <monnier@iro.umontreal.ca>
Fri, 7 Oct 2022 16:54:29 +0000 (12:54 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Fri, 7 Oct 2022 16:54:29 +0000 (12:54 -0400)
lisp/pcomplete.el

index 6fe29d9dcfb70b0119cebbcd5313a7b60ab92de0..8cb0aa3b7ad106aa93a4d05847ee2fe3163cec80 100644 (file)
@@ -646,15 +646,12 @@ parts of the list.
 The OFFSET argument is added to/taken away from the index that will be
 used.  This is really only useful with `first' and `last', for
 accessing absolute argument positions."
-  (setq index
-       (if (eq index 'first)
-           0
-         (if (eq index 'last)
-             pcomplete-last
-           (- pcomplete-index (or index 0)))))
-  (if offset
-      (setq index (+ index offset)))
-  (nth index pcomplete-args))
+  (nth (+ (pcase index
+          ('first 0)
+          ('last  pcomplete-last)
+          (_      (- pcomplete-index (or index 0))))
+         (or offset 0))
+       pcomplete-args))
 
 (defun pcomplete-begin (&optional index offset)
   "Return the beginning position of the INDEXth argument.