Mercurial > hg > xemacs-beta
comparison lisp/simple.el @ 284:558f606b08ae r21-0b40
Import from CVS: tag r21-0b40
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:34:13 +0200 |
parents | c42ec1d1cded |
children | 57709be46d1b |
comparison
equal
deleted
inserted
replaced
283:fa3d41851a08 | 284:558f606b08ae |
---|---|
217 this function useful in editing binary files." | 217 this function useful in editing binary files." |
218 (interactive "*p") | 218 (interactive "*p") |
219 (let ((char (if (or (not overwrite-mode) | 219 (let ((char (if (or (not overwrite-mode) |
220 (eq overwrite-mode 'overwrite-mode-binary)) | 220 (eq overwrite-mode 'overwrite-mode-binary)) |
221 (read-quoted-char) | 221 (read-quoted-char) |
222 (read-char)))) | 222 ;; read-char obeys C-g, so we should protect. FSF |
223 ;; doesn't have the protection here, but it's a bug in | |
224 ;; FSF. | |
225 (let ((inhibit-quit t)) | |
226 (read-char))))) | |
223 (if (> arg 0) | 227 (if (> arg 0) |
224 (if (eq overwrite-mode 'overwrite-mode-binary) | 228 (if (eq overwrite-mode 'overwrite-mode-binary) |
225 (delete-char arg))) | 229 (delete-char arg))) |
226 (while (> arg 0) | 230 (while (> arg 0) |
227 (insert char) | 231 (insert char) |
455 (kill-region (point) (progn | 459 (kill-region (point) (progn |
456 (search-forward (char-to-string char) nil nil arg) | 460 (search-forward (char-to-string char) nil nil arg) |
457 ; (goto-char (if (> arg 0) (1- (point)) (1+ (point)))) | 461 ; (goto-char (if (> arg 0) (1- (point)) (1+ (point)))) |
458 (point)))) | 462 (point)))) |
459 | 463 |
464 (defun zap-up-to-char (arg char) | |
465 "Kill up to ARG'th occurrence of CHAR. | |
466 Goes backward if ARG is negative; error if CHAR not found." | |
467 (interactive "*p\ncZap up to char: ") | |
468 (kill-region (point) (progn | |
469 (search-forward (char-to-string char) nil nil arg) | |
470 (goto-char (if (> arg 0) (1- (point)) (1+ (point)))) | |
471 (point)))) | |
472 | |
460 (defun beginning-of-buffer (&optional arg) | 473 (defun beginning-of-buffer (&optional arg) |
461 "Move point to the beginning of the buffer; leave mark at previous position. | 474 "Move point to the beginning of the buffer; leave mark at previous position. |
462 With arg N, put point N/10 of the way from the beginning. | 475 With arg N, put point N/10 of the way from the beginning. |
463 | 476 |
464 If the buffer is narrowed, this command uses the beginning and size | 477 If the buffer is narrowed, this command uses the beginning and size |
563 nil means discard it; anything else is stream for print." | 576 nil means discard it; anything else is stream for print." |
564 (interactive) | 577 (interactive) |
565 (eval-buffer (current-buffer) printflag)) | 578 (eval-buffer (current-buffer) printflag)) |
566 | 579 |
567 ;; XEmacs | 580 ;; XEmacs |
568 (defun count-words-buffer (buffer) | 581 (defun count-words-buffer (&optional buffer) |
569 "Print the number of words in BUFFER. | 582 "Print the number of words in BUFFER. |
570 If called noninteractively, the value is returned rather than printed. | 583 If called noninteractively, the value is returned rather than printed. |
571 BUFFER defaults to the current buffer." | 584 BUFFER defaults to the current buffer." |
572 (interactive "_bBuffer: ") | 585 (interactive) |
573 (let ((words (count-words-region (point-min) (point-max) buffer))) | 586 (let ((words (count-words-region (point-min) (point-max) buffer))) |
574 (when (interactive-p) | 587 (when (interactive-p) |
575 (message "Buffer has %d words" words)) | 588 (message "Buffer has %d words" words)) |
576 words)) | 589 words)) |
577 | 590 |
598 (interactive "_r") | 611 (interactive "_r") |
599 (message "Region has %d lines, %d characters" | 612 (message "Region has %d lines, %d characters" |
600 (count-lines start end) (- end start))) | 613 (count-lines start end) (- end start))) |
601 | 614 |
602 ;; XEmacs | 615 ;; XEmacs |
603 (defun count-lines-buffer (buffer) | 616 (defun count-lines-buffer (&optional buffer) |
604 "Print number of lines and characters in BUFFER." | 617 "Print number of lines and characters in BUFFER." |
605 (interactive "_bBuffer: ") | 618 (interactive) |
606 (save-excursion | 619 (with-current-buffer (or buffer (current-buffer)) |
607 (set-buffer (or buffer (current-buffer))) | |
608 (let ((cnt (count-lines (point-min) (point-max)))) | 620 (let ((cnt (count-lines (point-min) (point-max)))) |
609 (message "Buffer has %d lines, %d characters" | 621 (message "Buffer has %d lines, %d characters" |
610 cnt (- (point-max) (point-min))) | 622 cnt (- (point-max) (point-min))) |
611 cnt))) | 623 cnt))) |
612 | 624 |
735 | 747 |
736 ;(defvar read-expression-history nil) | 748 ;(defvar read-expression-history nil) |
737 | 749 |
738 ;; We define this, rather than making `eval' interactive, | 750 ;; We define this, rather than making `eval' interactive, |
739 ;; for the sake of completion of names like eval-region, eval-current-buffer. | 751 ;; for the sake of completion of names like eval-region, eval-current-buffer. |
740 (defun eval-expression (expression) | 752 (defun eval-expression (expression &optional eval-expression-insert-value) |
741 "Evaluate EXPRESSION and print value in minibuffer. | 753 "Evaluate EXPRESSION and print value in minibuffer. |
742 Value is also consed on to front of the variable `values'." | 754 Value is also consed on to front of the variable `values'. |
755 With prefix argument, insert the result to the current buffer." | |
743 ;(interactive "xEval: ") | 756 ;(interactive "xEval: ") |
744 (interactive | 757 (interactive |
745 (list (read-from-minibuffer "Eval: " | 758 (list (read-from-minibuffer "Eval: " |
746 nil read-expression-map t | 759 nil read-expression-map t |
747 'read-expression-history))) | 760 'read-expression-history) |
761 current-prefix-arg)) | |
748 (setq values (cons (eval expression) values)) | 762 (setq values (cons (eval expression) values)) |
749 (prin1 (car values) t)) | 763 (prin1 (car values) |
764 (if eval-expression-insert-value (current-buffer) t))) | |
750 | 765 |
751 ;; XEmacs -- extra parameter (variant, but equivalent logic) | 766 ;; XEmacs -- extra parameter (variant, but equivalent logic) |
752 (defun edit-and-eval-command (prompt command &optional history) | 767 (defun edit-and-eval-command (prompt command &optional history) |
753 "Prompting with PROMPT, let user edit COMMAND and eval result. | 768 "Prompting with PROMPT, let user edit COMMAND and eval result. |
754 COMMAND is a Lisp expression. Let user edit that expression in | 769 COMMAND is a Lisp expression. Let user edit that expression in |