Function: nbutlast
nbutlast is a byte-compiled function defined in subr.el.gz.
Signature
(nbutlast LIST &optional N)
Documentation
Modify LIST to remove the last N elements.
If N is omitted or nil, remove the last element.
Other relevant functions are documented in the list group.
Probably introduced at or before Emacs version 21.1.
Shortdoc
;; list
(nbutlast (list 'one 'two 'three))
=> (one two)
Source Code
;; Defined in /usr/src/emacs/lisp/subr.el.gz
(defun nbutlast (list &optional n)
"Modify LIST to remove the last N elements.
If N is omitted or nil, remove the last element."
(let ((m (length list)))
(or n (setq n 1))
(and (< n m)
(progn
(if (plusp n) (setcdr (nthcdr (- (1- m) n) list) nil))
list))))