Mercurial > emacs
comparison lisp/comint.el @ 2583:308da27928f2
(comint-mod): Nuked. A call to ring-mod replaces it.
(comint-mem): Nuked. A call to member replaces it.
author | Eric S. Raymond <esr@snark.thyrsus.com> |
---|---|
date | Sun, 25 Apr 1993 22:26:51 +0000 |
parents | 577c77cfd199 |
children | bc86243d1361 |
comparison
equal
deleted
inserted
replaced
2582:e01048f32511 | 2583:308da27928f2 |
---|---|
378 (while old-env | 378 (while old-env |
379 (let* ((vv (car old-env)) ; vv is var=value | 379 (let* ((vv (car old-env)) ; vv is var=value |
380 (var (and (string-match "^[^=]*=" vv) | 380 (var (and (string-match "^[^=]*=" vv) |
381 (substring vv 0 (match-end 0))))) | 381 (substring vv 0 (match-end 0))))) |
382 (setq old-env (cdr old-env)) | 382 (setq old-env (cdr old-env)) |
383 (cond ((not (and var (comint-mem var vars))) | 383 (cond ((not (and var (member var vars))) |
384 (if var (setq var (cons var vars))) | 384 (if var (setq var (cons var vars))) |
385 (setq ans (cons vv ans)))))) | 385 (setq ans (cons vv ans)))))) |
386 (nreverse ans))) | 386 (nreverse ans))) |
387 | |
388 ;;; This should be in emacs, but it isn't. | |
389 (defun comint-mem (item list &optional elt=) | |
390 "Test to see if ITEM is equal to an item in LIST. | |
391 Option comparison function ELT= defaults to equal." | |
392 (let ((elt= (or elt= (function equal))) | |
393 (done nil)) | |
394 (while (and list (not done)) | |
395 (if (funcall elt= item (car list)) | |
396 (setq done list) | |
397 (setq list (cdr list)))) | |
398 done)) | |
399 | 387 |
400 | 388 |
401 ;;; Input history retrieval commands | 389 ;;; Input history retrieval commands |
402 ;;; M-p -- previous input M-n -- next input | 390 ;;; M-p -- previous input M-n -- next input |
403 ;;; M-C-r -- previous input matching | 391 ;;; M-C-r -- previous input matching |
422 (if (null comint-input-ring-index) | 410 (if (null comint-input-ring-index) |
423 (setq comint-input-ring-index | 411 (setq comint-input-ring-index |
424 (if (> arg 0) -1 | 412 (if (> arg 0) -1 |
425 (if (< arg 0) 1 0)))) | 413 (if (< arg 0) 1 0)))) |
426 (setq comint-input-ring-index | 414 (setq comint-input-ring-index |
427 (comint-mod (+ comint-input-ring-index arg) len)) | 415 (ring-mod (+ comint-input-ring-index arg) len)) |
428 (message "%d" (1+ comint-input-ring-index)) | 416 (message "%d" (1+ comint-input-ring-index)) |
429 (insert (ring-ref comint-input-ring comint-input-ring-index)))))) | 417 (insert (ring-ref comint-input-ring comint-input-ring-index)))))) |
430 | |
431 (defun comint-mod (n m) | |
432 "Returns N mod M. M is positive. | |
433 Answer is guaranteed to be non-negative, and less than m." | |
434 (let ((n (% n m))) | |
435 (if (>= n 0) n | |
436 (+ n | |
437 (if (>= m 0) m (- m)))))) ; (abs m) | |
438 | 418 |
439 (defun comint-next-input (arg) | 419 (defun comint-next-input (arg) |
440 "Cycle forwards through input history." | 420 "Cycle forwards through input history." |
441 (interactive "*p") | 421 (interactive "*p") |
442 (comint-previous-input (- arg))) | 422 (comint-previous-input (- arg))) |