Changeset 4085 for trunk/lisp/subr.el
- Timestamp:
- 05/18/06 16:19:18 (3 years ago)
- Files:
-
- trunk/lisp/subr.el (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lisp/subr.el
r4079 r4085 1124 1124 oa))))))) 1125 1125 1126 (defun add-to-history (history-var newelt &optional maxelt )1126 (defun add-to-history (history-var newelt &optional maxelt keep-all) 1127 1127 "Add NEWELT to the history list stored in the variable HISTORY-VAR. 1128 1128 Return the new history list. … … 1131 1131 property on symbol HISTORY-VAR, if set, or the value of the `history-length' 1132 1132 variable. 1133 Remove duplicates of NEWELT unless `history-delete-duplicates' is nil." 1133 Remove duplicates of NEWELT if `history-delete-duplicates' is non-nil. 1134 If optional fourth arg KEEP-ALL is non-nil, add NEWELT to history even 1135 if it is empty or a duplicate." 1134 1136 (unless maxelt 1135 1137 (setq maxelt (or (get history-var 'history-length) … … 1137 1139 (let ((history (symbol-value history-var)) 1138 1140 tail) 1139 (if history-delete-duplicates 1140 (setq history (delete newelt history))) 1141 (setq history (cons newelt history)) 1142 (when (integerp maxelt) 1143 (if (= 0 maxelt) 1144 (setq history nil) 1145 (setq tail (nthcdr (1- maxelt) history)) 1146 (when (consp tail) 1147 (setcdr tail nil)))) 1141 (when (and (listp history) 1142 (or keep-all 1143 (not (stringp newelt)) 1144 (> (length newelt) 0)) 1145 (or keep-all 1146 (not (equal (car history) newelt)))) 1147 (if history-delete-duplicates 1148 (delete newelt history)) 1149 (setq history (cons newelt history)) 1150 (when (integerp maxelt) 1151 (if (= 0 maxelt) 1152 (setq history nil) 1153 (setq tail (nthcdr (1- maxelt) history)) 1154 (when (consp tail) 1155 (setcdr tail nil))))) 1148 1156 (set history-var history))) 1149 1157
