summaryrefslogtreecommitdiff
path: root/common.el
diff options
context:
space:
mode:
Diffstat (limited to 'common.el')
-rw-r--r--common.el12
1 files changed, 12 insertions, 0 deletions
diff --git a/common.el b/common.el
index 94cbe3c..7da6129 100644
--- a/common.el
+++ b/common.el
@@ -474,6 +474,18 @@ If the length of LS is less than N, then return the whole LS."
((setq i n))))
(reverse result)))))
+;;; A helper function to remove the last non-cons-cell `cdr'.
+
+(defun remove-last-non-nil-cdr (arg)
+ "Remove the last `cdr' that is not a cons cell."
+ (let ((temp arg))
+ (while (consp temp)
+ (cond
+ ((consp (cdr temp)))
+ ((setcdr temp nil)))
+ (setq temp (cdr temp))))
+ arg)
+
(provide 'common)
;;; common.el ends here.