Well I had the same thought few days ago, so I wrote this:
; Shift list with grread - move items one position to the "Left" or to the "Right" :
(defun C:test ( / *error* Lst SysVars LoopFlag UserIn TypeUserIn ReturnChar )
(or ; the starting list - experiment with one of these
; (setq Lst (list "A" "B" "C" "D" "E" "F"))
(setq Lst (list 1 2 3 4 5 6))
)
(defun *error* (msg)
(if SysVars
(mapcar
(function (lambda (a b) (setvar a b)))
(mapcar 'car SysVars)
(mapcar 'cadr SysVars)
)
); if
(princ)
)
(setq SysVars
(mapcar
(function (lambda (x) (list x (getvar x))))
(list 'CMDECHO 'CLIPROMPTLINES )
)
)
(mapcar
(function (lambda (a b) (setvar a b)))
(mapcar 'car SysVars)
(list 0 3)
)
(princ "\nPress [A/D] to Shift the list or e[X]it: ")
(print Lst)
(setq LoopFlag T)
(while LoopFlag
(setq
UserIn (grread T)
TypeUserIn (car UserIn)
ReturnChar (cadr UserIn)
); setq
(cond
((and (= TypeUserIn 2)(= ReturnChar (ascii (strcase "A" T))))
(princ "\nPress [A/D] to Shift the list or e[X]it: ")
(setq Lst (ShiftListLeft Lst))
(princ "\n\"A\" key is pressed, shifting the list to the Left: \n")
(print Lst)
)
((and (= TypeUserIn 2)(= ReturnChar (ascii (strcase "D" T))))
(princ "\nPress [A/D] to Shift the list or e[X]it: ")
(setq Lst (ShiftListRight Lst))
(princ "\n\"D\" key is pressed, shifting the list to the Right: \n")
(print Lst)
)
((and (= TypeUserIn 2)(= ReturnChar (ascii (strcase "X" T))))
(princ "\nExiting! Final list is: \n")
(print Lst)
(setq LoopFlag nil)
)
(T nil)
); cond
); while LoopFlag
(mapcar
(function (lambda (a b) (setvar a b)))
(mapcar 'car SysVars)
(mapcar 'cadr SysVars)
)
(princ)
); defun
(defun ShiftListRight ( Lst / nLst )
(if (listp Lst)
(setq nLst (append (list (last Lst)) (reverse (cdr (reverse Lst)))))
)
)
(defun ShiftListLeft ( Lst / nLst )
(if (listp Lst)
(setq nLst (append (cdr Lst) (list (car Lst))))
)
)
EDIT: Just wanted to make clear:
The "grread" stuff is a template, which I use often, it was posted by fixo, who wrote that the original author is CAB.
About the Shift* functions, I think I took some list-assembling code fragment from Lee Mac, and modified it to perform this "shifting" 1 position to the left/right.
So overall this code is 1 huge assembly, which can be used as a template for something useful.