diff options
| author | Richard M. Stallman | 1992-08-03 02:02:37 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1992-08-03 02:02:37 +0000 |
| commit | 1586b965b927d9111abb209d04568da330867dfa (patch) | |
| tree | 8f7668ac589d1cc601df12279cc089277836882a | |
| parent | df01170b2817a8131751a2c549eca43dc43d4210 (diff) | |
| download | emacs-1586b965b927d9111abb209d04568da330867dfa.tar.gz emacs-1586b965b927d9111abb209d04568da330867dfa.zip | |
*** empty log message ***
| -rw-r--r-- | lisp/comint.el | 241 | ||||
| -rw-r--r-- | lisp/files.el | 4 | ||||
| -rw-r--r-- | lisp/map-ynp.el | 2 | ||||
| -rw-r--r-- | lisp/progmodes/c-mode.el | 54 | ||||
| -rw-r--r-- | lisp/view.el | 12 |
5 files changed, 134 insertions, 179 deletions
diff --git a/lisp/comint.el b/lisp/comint.el index 965268dcdb7..957fafda67e 100644 --- a/lisp/comint.el +++ b/lisp/comint.el | |||
| @@ -1,26 +1,26 @@ | |||
| 1 | ;;; comint.el --- general command interpreter in a window stuff | 1 | ;;; comint.el --- general command interpreter in a window stuff |
| 2 | 2 | ||
| 3 | ;;; Copyright Olin Shivers (1988). | 3 | ;; Author: Olin Shivers <shivers@cs.cmu.edu> |
| 4 | ;; Keyword: processes | ||
| 4 | 5 | ||
| 5 | ;; Maintainer: Olin Shivers <shivers@cs.cmu.edu> | 6 | ;; Copyright (C) 1988, 1990, 1992 Free Software Foundation, Inc. |
| 6 | ;; Version: 2.03 | 7 | ;; Written by Olin Shivers. |
| 7 | ;; Keyword: estensions, processes | ||
| 8 | 8 | ||
| 9 | ;;; This file is part of GNU Emacs. | 9 | ;; This file is part of GNU Emacs. |
| 10 | 10 | ||
| 11 | ;;; GNU Emacs is free software; you can redistribute it and/or modify | 11 | ;; GNU Emacs is free software; you can redistribute it and/or modify |
| 12 | ;;; it under the terms of the GNU General Public License as published by | 12 | ;; it under the terms of the GNU General Public License as published by |
| 13 | ;;; the Free Software Foundation; either version 2, or (at your option) | 13 | ;; the Free Software Foundation; either version 2, or (at your option) |
| 14 | ;;; any later version. | 14 | ;; any later version. |
| 15 | 15 | ||
| 16 | ;;; GNU Emacs is distributed in the hope that it will be useful, | 16 | ;; GNU Emacs is distributed in the hope that it will be useful, |
| 17 | ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | ;;; GNU General Public License for more details. | 19 | ;; GNU General Public License for more details. |
| 20 | 20 | ||
| 21 | ;;; You should have received a copy of the GNU General Public License | 21 | ;; You should have received a copy of the GNU General Public License |
| 22 | ;;; along with GNU Emacs; see the file COPYING. If not, write to | 22 | ;; along with GNU Emacs; see the file COPYING. If not, write to |
| 23 | ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | 23 | ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
| 24 | 24 | ||
| 25 | ;;; Commentary: | 25 | ;;; Commentary: |
| 26 | 26 | ||
| @@ -71,7 +71,8 @@ | |||
| 71 | ;;; | 71 | ;;; |
| 72 | ;;; m-p comint-previous-input Cycle backwards in input history | 72 | ;;; m-p comint-previous-input Cycle backwards in input history |
| 73 | ;;; m-n comint-next-input Cycle forwards | 73 | ;;; m-n comint-next-input Cycle forwards |
| 74 | ;;; m-s comint-previous-similar-input Previous similar input | 74 | ;;; m-r comint-previous-similar-input Previous similar input |
| 75 | ;;; m-s comint-next-similar-input Next similar input | ||
| 75 | ;;; c-m-r comint-previous-input-matching Search backwards in input history | 76 | ;;; c-m-r comint-previous-input-matching Search backwards in input history |
| 76 | ;;; return comint-send-input | 77 | ;;; return comint-send-input |
| 77 | ;;; c-a comint-bol Beginning of line; skip prompt. | 78 | ;;; c-a comint-bol Beginning of line; skip prompt. |
| @@ -262,7 +263,8 @@ Entry to this mode runs the hooks on comint-mode-hook" | |||
| 262 | (setq comint-mode-map (make-sparse-keymap)) | 263 | (setq comint-mode-map (make-sparse-keymap)) |
| 263 | (define-key comint-mode-map "\ep" 'comint-previous-input) | 264 | (define-key comint-mode-map "\ep" 'comint-previous-input) |
| 264 | (define-key comint-mode-map "\en" 'comint-next-input) | 265 | (define-key comint-mode-map "\en" 'comint-next-input) |
| 265 | (define-key comint-mode-map "\es" 'comint-previous-similar-input) | 266 | (define-key comint-mode-map "\er" 'comint-previous-similar-input) |
| 267 | (define-key comint-mode-map "\es" 'comint-next-similar-input) | ||
| 266 | (define-key comint-mode-map "\C-m" 'comint-send-input) | 268 | (define-key comint-mode-map "\C-m" 'comint-send-input) |
| 267 | (define-key comint-mode-map "\C-d" 'comint-delchar-or-maybe-eof) | 269 | (define-key comint-mode-map "\C-d" 'comint-delchar-or-maybe-eof) |
| 268 | (define-key comint-mode-map "\C-a" 'comint-bol) | 270 | (define-key comint-mode-map "\C-a" 'comint-bol) |
| @@ -393,107 +395,6 @@ Option comparison function ELT= defaults to equal." | |||
| 393 | done)) | 395 | done)) |
| 394 | 396 | ||
| 395 | 397 | ||
| 396 | ;;; Ring Code | ||
| 397 | ;;;============================================================================ | ||
| 398 | ;;; This code defines a ring data structure. A ring is a | ||
| 399 | ;;; (hd-index tl-index . vector) | ||
| 400 | ;;; list. You can insert to, remove from, and rotate a ring. When the ring | ||
| 401 | ;;; fills up, insertions cause the oldest elts to be quietly dropped. | ||
| 402 | ;;; | ||
| 403 | ;;; HEAD = index of the newest item on the ring. | ||
| 404 | ;;; TAIL = index of the oldest item on the ring. | ||
| 405 | ;;; | ||
| 406 | ;;; These functions are used by the input history mechanism, but they can | ||
| 407 | ;;; be used for other purposes as well. | ||
| 408 | |||
| 409 | (defun ring-p (x) | ||
| 410 | "T if X is a ring; NIL otherwise." | ||
| 411 | (and (consp x) (integerp (car x)) | ||
| 412 | (consp (cdr x)) (integerp (car (cdr x))) | ||
| 413 | (vectorp (cdr (cdr x))))) | ||
| 414 | |||
| 415 | (defun make-ring (size) | ||
| 416 | "Make a ring that can contain SIZE elts" | ||
| 417 | (cons 1 (cons 0 (make-vector (+ size 1) nil)))) | ||
| 418 | |||
| 419 | (defun ring-plus1 (index veclen) | ||
| 420 | "INDEX+1, with wraparound" | ||
| 421 | (let ((new-index (+ index 1))) | ||
| 422 | (if (= new-index veclen) 0 new-index))) | ||
| 423 | |||
| 424 | (defun ring-minus1 (index veclen) | ||
| 425 | "INDEX-1, with wraparound" | ||
| 426 | (- (if (= 0 index) veclen index) 1)) | ||
| 427 | |||
| 428 | (defun ring-length (ring) | ||
| 429 | "Number of elts in the ring." | ||
| 430 | (let ((hd (car ring)) (tl (car (cdr ring))) (siz (length (cdr (cdr ring))))) | ||
| 431 | (let ((len (if (<= hd tl) (+ 1 (- tl hd)) (+ 1 tl (- siz hd))))) | ||
| 432 | (if (= len siz) 0 len)))) | ||
| 433 | |||
| 434 | (defun ring-empty-p (ring) | ||
| 435 | (= 0 (ring-length ring))) | ||
| 436 | |||
| 437 | (defun ring-insert (ring item) | ||
| 438 | "Insert a new item onto the ring. If the ring is full, dump the oldest | ||
| 439 | item to make room." | ||
| 440 | (let* ((vec (cdr (cdr ring))) (len (length vec)) | ||
| 441 | (new-hd (ring-minus1 (car ring) len))) | ||
| 442 | (setcar ring new-hd) | ||
| 443 | (aset vec new-hd item) | ||
| 444 | (if (ring-empty-p ring) ;overflow -- dump one off the tail. | ||
| 445 | (setcar (cdr ring) (ring-minus1 (car (cdr ring)) len))))) | ||
| 446 | |||
| 447 | (defun ring-remove (ring) | ||
| 448 | "Remove the oldest item retained on the ring." | ||
| 449 | (if (ring-empty-p ring) (error "Ring empty") | ||
| 450 | (let ((tl (car (cdr ring))) (vec (cdr (cdr ring)))) | ||
| 451 | (setcar (cdr ring) (ring-minus1 tl (length vec))) | ||
| 452 | (aref vec tl)))) | ||
| 453 | |||
| 454 | ;;; This isn't actually used in this package. I just threw it in in case | ||
| 455 | ;;; someone else wanted it. If you want rotating-ring behavior on your history | ||
| 456 | ;;; retrieval (analagous to kill ring behavior), this function is what you | ||
| 457 | ;;; need. I should write the yank-input and yank-pop-input-or-kill to go with | ||
| 458 | ;;; this, and not bind it to a key by default, so it would be available to | ||
| 459 | ;;; people who want to bind it to a key. But who would want it? Blech. | ||
| 460 | (defun ring-rotate (ring n) | ||
| 461 | (if (not (= n 0)) | ||
| 462 | (if (ring-empty-p ring) ;Is this the right error check? | ||
| 463 | (error "ring empty") | ||
| 464 | (let ((hd (car ring)) (tl (car (cdr ring))) (vec (cdr (cdr ring)))) | ||
| 465 | (let ((len (length vec))) | ||
| 466 | (while (> n 0) | ||
| 467 | (setq tl (ring-plus1 tl len)) | ||
| 468 | (aset ring tl (aref ring hd)) | ||
| 469 | (setq hd (ring-plus1 hd len)) | ||
| 470 | (setq n (- n 1))) | ||
| 471 | (while (< n 0) | ||
| 472 | (setq hd (ring-minus1 hd len)) | ||
| 473 | (aset vec hd (aref vec tl)) | ||
| 474 | (setq tl (ring-minus1 tl len)) | ||
| 475 | (setq n (- n 1)))) | ||
| 476 | (setcar ring hd) | ||
| 477 | (setcar (cdr ring) tl))))) | ||
| 478 | |||
| 479 | (defun comint-mod (n m) | ||
| 480 | "Returns N mod M. M is positive. Answer is guaranteed to be non-negative, | ||
| 481 | and less than m." | ||
| 482 | (let ((n (% n m))) | ||
| 483 | (if (>= n 0) n | ||
| 484 | (+ n | ||
| 485 | (if (>= m 0) m (- m)))))) ; (abs m) | ||
| 486 | |||
| 487 | (defun ring-ref (ring index) | ||
| 488 | (let ((numelts (ring-length ring))) | ||
| 489 | (if (= numelts 0) (error "indexed empty ring") | ||
| 490 | (let* ((hd (car ring)) (tl (car (cdr ring))) (vec (cdr (cdr ring))) | ||
| 491 | (index (comint-mod index numelts)) | ||
| 492 | (vec-index (comint-mod (+ index hd) | ||
| 493 | (length vec)))) | ||
| 494 | (aref vec vec-index))))) | ||
| 495 | |||
| 496 | |||
| 497 | ;;; Input history retrieval commands | 398 | ;;; Input history retrieval commands |
| 498 | ;;; M-p -- previous input M-n -- next input | 399 | ;;; M-p -- previous input M-n -- next input |
| 499 | ;;; M-C-r -- previous input matching | 400 | ;;; M-C-r -- previous input matching |
| @@ -510,22 +411,28 @@ and less than m." | |||
| 510 | (message "Not after process mark") | 411 | (message "Not after process mark") |
| 511 | (ding)) | 412 | (ding)) |
| 512 | (t | 413 | (t |
| 513 | (cond ((eq last-command 'comint-previous-input) | 414 | (delete-region (point) |
| 514 | (delete-region (mark) (point))) | 415 | (process-mark (get-buffer-process (current-buffer)))) |
| 515 | ((eq last-command 'comint-previous-similar-input) | 416 | ;; Initialize the index on the first use of this command |
| 516 | (delete-region | 417 | ;; so that the first M-p gets index 0, and the first M-n gets |
| 517 | (process-mark (get-buffer-process (current-buffer))) | 418 | ;; index -1. |
| 518 | (point))) | 419 | (if (null comint-input-ring-index) |
| 519 | (t | 420 | (setq comint-input-ring-index |
| 520 | (setq comint-input-ring-index | 421 | (if (> arg 0) -1 |
| 521 | (if (> arg 0) -1 | 422 | (if (< arg 0) 1 0)))) |
| 522 | (if (< arg 0) 1 0))) | 423 | (setq comint-input-ring-index |
| 523 | (push-mark (point)))) | 424 | (comint-mod (+ comint-input-ring-index arg) len)) |
| 524 | (setq comint-input-ring-index (comint-mod (+ comint-input-ring-index arg) len)) | ||
| 525 | (message "%d" (1+ comint-input-ring-index)) | 425 | (message "%d" (1+ comint-input-ring-index)) |
| 526 | (insert (ring-ref comint-input-ring comint-input-ring-index)) | 426 | (insert (ring-ref comint-input-ring comint-input-ring-index)))))) |
| 527 | (setq this-command 'comint-previous-input))))) | 427 | |
| 528 | 428 | (defun comint-mod (n m) | |
| 429 | "Returns N mod M. M is positive. | ||
| 430 | Answer is guaranteed to be non-negative, and less than m." | ||
| 431 | (let ((n (% n m))) | ||
| 432 | (if (>= n 0) n | ||
| 433 | (+ n | ||
| 434 | (if (>= m 0) m (- m)))))) ; (abs m) | ||
| 435 | |||
| 529 | (defun comint-next-input (arg) | 436 | (defun comint-next-input (arg) |
| 530 | "Cycle forwards through input history." | 437 | "Cycle forwards through input history." |
| 531 | (interactive "*p") | 438 | (interactive "*p") |
| @@ -544,7 +451,7 @@ Buffer local variable.") | |||
| 544 | (list (if (string= s "") comint-last-input-match s)))) | 451 | (list (if (string= s "") comint-last-input-match s)))) |
| 545 | ; (interactive "sCommand substring: ") | 452 | ; (interactive "sCommand substring: ") |
| 546 | (setq comint-last-input-match str) ; update default | 453 | (setq comint-last-input-match str) ; update default |
| 547 | (if (not (eq last-command 'comint-previous-input)) | 454 | (if (null comint-input-ring-index) |
| 548 | (setq comint-input-ring-index -1)) | 455 | (setq comint-input-ring-index -1)) |
| 549 | (let ((str (regexp-quote str)) | 456 | (let ((str (regexp-quote str)) |
| 550 | (len (ring-length comint-input-ring)) | 457 | (len (ring-length comint-input-ring)) |
| @@ -553,10 +460,7 @@ Buffer local variable.") | |||
| 553 | (setq n (+ n 1))) | 460 | (setq n (+ n 1))) |
| 554 | (cond ((< n len) | 461 | (cond ((< n len) |
| 555 | (comint-previous-input (- n comint-input-ring-index))) | 462 | (comint-previous-input (- n comint-input-ring-index))) |
| 556 | (t (if (eq last-command 'comint-previous-input) | 463 | (t (error "Not found"))))) |
| 557 | (setq this-command 'comint-previous-input)) | ||
| 558 | (message "Not found.") | ||
| 559 | (ding))))) | ||
| 560 | 464 | ||
| 561 | 465 | ||
| 562 | ;;; These next three commands are alternatives to the input history commands | 466 | ;;; These next three commands are alternatives to the input history commands |
| @@ -621,15 +525,20 @@ Buffer local variable.") | |||
| 621 | (defvar comint-last-similar-string "" | 525 | (defvar comint-last-similar-string "" |
| 622 | "The string last used in a similar string search.") | 526 | "The string last used in a similar string search.") |
| 623 | (defun comint-previous-similar-input (arg) | 527 | (defun comint-previous-similar-input (arg) |
| 624 | "Reenters the last input that matches the string typed so far. If repeated | 528 | "Fetch the previous (older) input that matches the string typed so far. |
| 625 | successively older inputs are reentered. If arg is 1, it will go back | 529 | Successive repetitions find successively older matching inputs. |
| 626 | in the history, if -1 it will go forward." | 530 | A prefix argument serves as a repeat count; a negative argument |
| 531 | fetches following (more recent) inputs." | ||
| 627 | (interactive "p") | 532 | (interactive "p") |
| 628 | (if (not (comint-after-pmark-p)) | 533 | (if (not (comint-after-pmark-p)) |
| 629 | (error "Not after process mark")) | 534 | (error "Not after process mark")) |
| 630 | (if (not (eq last-command 'comint-previous-similar-input)) | 535 | (if (null comint-input-ring-index) |
| 631 | (setq comint-input-ring-index -1 | 536 | (setq comint-input-ring-index |
| 632 | comint-last-similar-string | 537 | (if (> arg 0) -1 |
| 538 | (if (< arg 0) 1 0)))) | ||
| 539 | (if (not (or (eq last-command 'comint-previous-similar-input) | ||
| 540 | (eq last-command 'comint-next-similar-input))) | ||
| 541 | (setq comint-last-similar-string | ||
| 633 | (buffer-substring | 542 | (buffer-substring |
| 634 | (process-mark (get-buffer-process (current-buffer))) | 543 | (process-mark (get-buffer-process (current-buffer))) |
| 635 | (point)))) | 544 | (point)))) |
| @@ -644,13 +553,21 @@ in the history, if -1 it will go forward." | |||
| 644 | (setq n (+ n arg))) | 553 | (setq n (+ n arg))) |
| 645 | (cond ((< n len) | 554 | (cond ((< n len) |
| 646 | (setq comint-input-ring-index n) | 555 | (setq comint-input-ring-index n) |
| 647 | (if (eq last-command 'comint-previous-similar-input) | 556 | (if (or (eq last-command 'comint-previous-similar-input) |
| 557 | (eq last-command 'comint-next-similar-input)) | ||
| 648 | (delete-region (mark) (point)) ; repeat | 558 | (delete-region (mark) (point)) ; repeat |
| 649 | (push-mark (point))) ; 1st time | 559 | (push-mark (point))) ; 1st time |
| 650 | (insert (substring entry size))) | 560 | (insert (substring entry size))) |
| 651 | (t (message "Not found.") (ding) (sit-for 1))) | 561 | (t (error "Not found"))) |
| 652 | (message "%d" (1+ comint-input-ring-index)))) | 562 | (message "%d" (1+ comint-input-ring-index)))) |
| 653 | 563 | ||
| 564 | (defun comint-next-similar-input (arg) | ||
| 565 | "Fetch the next (newer) input that matches the string typed so far. | ||
| 566 | Successive repetitions find successively newer matching inputs. | ||
| 567 | A prefix argument serves as a repeat count; a negative argument | ||
| 568 | fetches previous (older) inputs." | ||
| 569 | (interactive "p") | ||
| 570 | (comint-previous-similar-input (- arg))) | ||
| 654 | 571 | ||
| 655 | (defun comint-send-input () | 572 | (defun comint-send-input () |
| 656 | "Send input to process. After the process output mark, sends all text | 573 | "Send input to process. After the process output mark, sends all text |
| @@ -681,7 +598,7 @@ If the comint is Lucid Common Lisp, | |||
| 681 | comint-input-filter returns NIL if the input matches input-filter-regexp, | 598 | comint-input-filter returns NIL if the input matches input-filter-regexp, |
| 682 | which matches (1) all whitespace (2) :a, :c, etc. | 599 | which matches (1) all whitespace (2) :a, :c, etc. |
| 683 | 600 | ||
| 684 | Similarly for Soar, Scheme, etc.." | 601 | Similarly for Soar, Scheme, etc." |
| 685 | (interactive) | 602 | (interactive) |
| 686 | ;; Note that the input string does not include its terminal newline. | 603 | ;; Note that the input string does not include its terminal newline. |
| 687 | (let ((proc (get-buffer-process (current-buffer)))) | 604 | (let ((proc (get-buffer-process (current-buffer)))) |
| @@ -700,6 +617,7 @@ Similarly for Soar, Scheme, etc.." | |||
| 700 | (ring-insert comint-input-ring input)) | 617 | (ring-insert comint-input-ring input)) |
| 701 | (funcall comint-input-sentinel input) | 618 | (funcall comint-input-sentinel input) |
| 702 | (funcall comint-input-sender proc input) | 619 | (funcall comint-input-sender proc input) |
| 620 | (setq comint-input-ring-index nil) | ||
| 703 | (set-marker comint-last-input-start pmark) | 621 | (set-marker comint-last-input-start pmark) |
| 704 | (set-marker comint-last-input-end (point)) | 622 | (set-marker comint-last-input-end (point)) |
| 705 | (set-marker (process-mark proc) (point)))))) | 623 | (set-marker (process-mark proc) (point)))))) |
| @@ -1087,8 +1005,6 @@ Useful if you accidentally suspend the top-level process." | |||
| 1087 | ;;; Filename completion in a buffer | 1005 | ;;; Filename completion in a buffer |
| 1088 | ;;; =========================================================================== | 1006 | ;;; =========================================================================== |
| 1089 | ;;; Useful completion functions, courtesy of the Ergo group. | 1007 | ;;; Useful completion functions, courtesy of the Ergo group. |
| 1090 | ;;; M-<Tab> will complete the filename at the cursor as much as possible | ||
| 1091 | ;;; M-? will display a list of completions in the help buffer. | ||
| 1092 | 1008 | ||
| 1093 | ;;; Three commands: | 1009 | ;;; Three commands: |
| 1094 | ;;; comint-dynamic-complete Complete filename at point. | 1010 | ;;; comint-dynamic-complete Complete filename at point. |
| @@ -1098,15 +1014,11 @@ Useful if you accidentally suspend the top-level process." | |||
| 1098 | 1014 | ||
| 1099 | ;;; These are not installed in the comint-mode keymap. But they are | 1015 | ;;; These are not installed in the comint-mode keymap. But they are |
| 1100 | ;;; available for people who want them. Shell-mode installs them: | 1016 | ;;; available for people who want them. Shell-mode installs them: |
| 1101 | ;;; (define-key cmushell-mode-map "\M-\t" 'comint-dynamic-complete) | 1017 | ;;; (define-key cmushell-mode-map "\t" 'comint-dynamic-complete) |
| 1102 | ;;; (define-key cmushell-mode-map "\M-?" 'comint-dynamic-list-completions))) | 1018 | ;;; (define-key cmushell-mode-map "\M-?" 'comint-dynamic-list-completions))) |
| 1103 | ;;; | 1019 | ;;; |
| 1104 | ;;; Commands like this are fine things to put in load hooks if you | 1020 | ;;; Commands like this are fine things to put in load hooks if you |
| 1105 | ;;; want them present in specific modes. Example: | 1021 | ;;; want them present in specific modes. |
| 1106 | ;;; (setq cmushell-load-hook | ||
| 1107 | ;;; '((lambda () (define-key lisp-mode-map "\M-\t" | ||
| 1108 | ;;; 'comint-replace-by-expanded-filename)))) | ||
| 1109 | ;;; | ||
| 1110 | 1022 | ||
| 1111 | 1023 | ||
| 1112 | (defun comint-match-partial-pathname () | 1024 | (defun comint-match-partial-pathname () |
| @@ -1136,10 +1048,10 @@ comint-dynamic-complete." | |||
| 1136 | (completion (file-name-completion pathnondir | 1048 | (completion (file-name-completion pathnondir |
| 1137 | (or pathdir default-directory)))) | 1049 | (or pathdir default-directory)))) |
| 1138 | (cond ((null completion) | 1050 | (cond ((null completion) |
| 1139 | (message "No completions of %s." pathname) | 1051 | (message "No completions of %s" pathname) |
| 1140 | (ding)) | 1052 | (ding)) |
| 1141 | ((eql completion t) | 1053 | ((eql completion t) |
| 1142 | (message "Unique completion.")) | 1054 | (message "Unique completion")) |
| 1143 | (t ; this means a string was returned. | 1055 | (t ; this means a string was returned. |
| 1144 | (delete-region (match-beginning 0) (match-end 0)) | 1056 | (delete-region (match-beginning 0) (match-end 0)) |
| 1145 | (insert (expand-file-name (concat pathdir completion))))))) | 1057 | (insert (expand-file-name (concat pathdir completion))))))) |
| @@ -1157,10 +1069,10 @@ it just adds completion characters to the end of the filename." | |||
| 1157 | (completion (file-name-completion pathnondir | 1069 | (completion (file-name-completion pathnondir |
| 1158 | (or pathdir default-directory)))) | 1070 | (or pathdir default-directory)))) |
| 1159 | (cond ((null completion) | 1071 | (cond ((null completion) |
| 1160 | (message "No completions of %s." pathname) | 1072 | (message "No completions of %s" pathname) |
| 1161 | (ding)) | 1073 | (ding)) |
| 1162 | ((eql completion t) | 1074 | ((eql completion t) |
| 1163 | (message "Unique completion.")) | 1075 | (message "Unique completion")) |
| 1164 | (t ; this means a string was returned. | 1076 | (t ; this means a string was returned. |
| 1165 | (goto-char (match-end 0)) | 1077 | (goto-char (match-end 0)) |
| 1166 | (insert (substring completion (length pathnondir))))))) | 1078 | (insert (substring completion (length pathnondir))))))) |
| @@ -1175,23 +1087,18 @@ it just adds completion characters to the end of the filename." | |||
| 1175 | (file-name-all-completions pathnondir | 1087 | (file-name-all-completions pathnondir |
| 1176 | (or pathdir default-directory)))) | 1088 | (or pathdir default-directory)))) |
| 1177 | (cond ((null completions) | 1089 | (cond ((null completions) |
| 1178 | (message "No completions of %s." pathname) | 1090 | (message "No completions of %s" pathname) |
| 1179 | (ding)) | 1091 | (ding)) |
| 1180 | (t | 1092 | (t |
| 1181 | (let ((conf (current-window-configuration))) | 1093 | (let ((conf (current-window-configuration))) |
| 1182 | (with-output-to-temp-buffer "*Help*" | 1094 | (with-output-to-temp-buffer "*Help*" |
| 1183 | (display-completion-list completions)) | 1095 | (display-completion-list completions)) |
| 1184 | (sit-for 0) | 1096 | (sit-for 0) |
| 1185 | (message "Hit space to flush.") | 1097 | (message "Hit space to flush") |
| 1186 | (let ((ch (read-char))) | 1098 | (let ((ch (read-char))) |
| 1187 | (if (= ch ?\ ) | 1099 | (if (= ch ?\ ) |
| 1188 | (set-window-configuration conf) | 1100 | (set-window-configuration conf) |
| 1189 | (setq unread-command-char ch)))))))) | 1101 | (setq unread-command-char ch)))))))) |
| 1190 | |||
| 1191 | ; Ergo bindings | ||
| 1192 | ; (global-set-key "\M-\t" 'comint-replace-by-expanded-filename) | ||
| 1193 | ; (global-set-key "\M-?" 'comint-dynamic-list-completions) | ||
| 1194 | ; (define-key shell-mode-map "\M-\t" 'comint-dynamic-complete) | ||
| 1195 | 1102 | ||
| 1196 | ;;; Converting process modes to use comint mode | 1103 | ;;; Converting process modes to use comint mode |
| 1197 | ;;; =========================================================================== | 1104 | ;;; =========================================================================== |
diff --git a/lisp/files.el b/lisp/files.el index 25b0bac389f..118e4d697d6 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -1083,7 +1083,9 @@ Optional second argument EXITING means ask about certain non-file buffers | |||
| 1083 | '("buffer" "buffers" "save") | 1083 | '("buffer" "buffers" "save") |
| 1084 | (list (list ?\C-r (lambda (buf) | 1084 | (list (list ?\C-r (lambda (buf) |
| 1085 | (view-buffer buf) | 1085 | (view-buffer buf) |
| 1086 | (setq view-exit-action 'exit-recursive-edit) | 1086 | (setq view-exit-action |
| 1087 | '(lambda (ignore) | ||
| 1088 | (exit-recursive-edit))) | ||
| 1087 | (recursive-edit) | 1089 | (recursive-edit) |
| 1088 | ;; Return nil to ask about BUF again. | 1090 | ;; Return nil to ask about BUF again. |
| 1089 | nil) | 1091 | nil) |
diff --git a/lisp/map-ynp.el b/lisp/map-ynp.el index acd013d4612..edec2d8c80c 100644 --- a/lisp/map-ynp.el +++ b/lisp/map-ynp.el | |||
| @@ -118,7 +118,7 @@ the current %s and exit." | |||
| 118 | (progn | 118 | (progn |
| 119 | ;; Prompt the user about this object. | 119 | ;; Prompt the user about this object. |
| 120 | (let ((cursor-in-echo-area t)) | 120 | (let ((cursor-in-echo-area t)) |
| 121 | (message "%s(y, n, ! ., q, %sor %s)" | 121 | (message "%s(y, n, !, ., q, %sor %s) " |
| 122 | prompt user-keys | 122 | prompt user-keys |
| 123 | (key-description (char-to-string help-char))) | 123 | (key-description (char-to-string help-char))) |
| 124 | (setq char (read-char))) | 124 | (setq char (read-char))) |
diff --git a/lisp/progmodes/c-mode.el b/lisp/progmodes/c-mode.el index 87046a0a6a3..2a64da0971f 100644 --- a/lisp/progmodes/c-mode.el +++ b/lisp/progmodes/c-mode.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; c-mode.el --- C code editing commands for Emacs | 1 | ;;; c-mode.el --- C code editing commands for Emacs |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1985, 1986, 1987 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1985, 1986, 1987, 1992 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Maintainer: FSF | 5 | ;; Maintainer: FSF |
| 6 | ;; Keywords: c | 6 | ;; Keywords: c |
| @@ -1122,5 +1122,57 @@ definition and conveniently use this command." | |||
| 1122 | (if (looking-at "\\\\") | 1122 | (if (looking-at "\\\\") |
| 1123 | (delete-region (1+ (point)) | 1123 | (delete-region (1+ (point)) |
| 1124 | (progn (skip-chars-backward " \t") (point))))) | 1124 | (progn (skip-chars-backward " \t") (point))))) |
| 1125 | |||
| 1126 | (defun c-up-conditional (count) | ||
| 1127 | "Move back to the containing preprocessor conditional, leaving mark behind. | ||
| 1128 | A prefix argument acts as a repeat count. With a negative argument, | ||
| 1129 | move forward to the end of the containing preprocessor conditional. | ||
| 1130 | When going backwards, `#elif' is treated like `#else' followed by `#if'. | ||
| 1131 | When going forwards, `#elif' is ignored." | ||
| 1132 | (interactive "p") | ||
| 1133 | (let* ((forward (< count 0)) | ||
| 1134 | (increment (if forward -1 1)) | ||
| 1135 | (search-function (if forward 're-search-forward 're-search-backward)) | ||
| 1136 | (opoint (point)) | ||
| 1137 | (new)) | ||
| 1138 | (save-excursion | ||
| 1139 | (while (/= count 0) | ||
| 1140 | (if forward (end-of-line)) | ||
| 1141 | (let ((depth 0) found) | ||
| 1142 | (save-excursion | ||
| 1143 | ;; Find the "next" significant line in the proper direction. | ||
| 1144 | (while (and (not found) | ||
| 1145 | ;; Rather than searching for a # sign that comes | ||
| 1146 | ;; at the beginning of a line aside from whitespace, | ||
| 1147 | ;; search first for a string starting with # sign. | ||
| 1148 | ;; Then verify what precedes it. | ||
| 1149 | ;; This is faster on account of the fastmap feature of | ||
| 1150 | ;; the regexp matcher. | ||
| 1151 | (funcall search-function | ||
| 1152 | "#[ \t]*\\(if\\|elif\\|endif\\)" | ||
| 1153 | nil t) | ||
| 1154 | (progn | ||
| 1155 | (beginning-of-line) | ||
| 1156 | (looking-at "^[ \t]*#[ \t]*\\(if\\|elif\\|endif\\)"))) | ||
| 1157 | ;; Update depth according to what we found. | ||
| 1158 | (beginning-of-line) | ||
| 1159 | (cond ((looking-at "[ \t]*#[ \t]*endif") | ||
| 1160 | (setq depth (+ depth increment))) | ||
| 1161 | ((looking-at "[ \t]*#[ \t]*elif") | ||
| 1162 | (if (and forward (= depth 0)) | ||
| 1163 | (setq found (point)))) | ||
| 1164 | (t (setq depth (- depth increment)))) | ||
| 1165 | ;; If this line exits a level of conditional, exit inner loop. | ||
| 1166 | (if (< depth 0) | ||
| 1167 | (setq found (point))) | ||
| 1168 | ;; When searching forward, start from end of line | ||
| 1169 | ;; so that we don't find the same line again. | ||
| 1170 | (if forward (end-of-line)))) | ||
| 1171 | (or found | ||
| 1172 | (error "No containing preprocessor conditional")) | ||
| 1173 | (goto-char (setq new found))) | ||
| 1174 | (setq count (- count increment)))) | ||
| 1175 | (push-mark) | ||
| 1176 | (goto-char new))) | ||
| 1125 | 1177 | ||
| 1126 | ;;; c-mode.el ends here | 1178 | ;;; c-mode.el ends here |
diff --git a/lisp/view.el b/lisp/view.el index 0cfc52676f4..50dbc77d815 100644 --- a/lisp/view.el +++ b/lisp/view.el | |||
| @@ -287,7 +287,7 @@ If you viewed a file that was not present in Emacs, its buffer is killed." | |||
| 287 | (eq (key-binding "\C-c") 'view-exit)) | 287 | (eq (key-binding "\C-c") 'view-exit)) |
| 288 | "Type C-h for help, ? for commands, C-c to quit" | 288 | "Type C-h for help, ? for commands, C-c to quit" |
| 289 | (substitute-command-keys | 289 | (substitute-command-keys |
| 290 | "Type \\[Helper-help] for help, \\[Helper-describe-bindings] for commands, \\[exit-recursive-edit] to quit.")))) | 290 | "Type \\[Helper-help] for help, \\[Helper-describe-bindings] for commands, \\[view-exit] to quit.")))) |
| 291 | 291 | ||
| 292 | (defun View-undefined () | 292 | (defun View-undefined () |
| 293 | (interactive) | 293 | (interactive) |
| @@ -330,7 +330,7 @@ No arg means whole window full, or number of lines set by \\[View-scroll-lines-f | |||
| 330 | Arg is number of lines to scroll." | 330 | Arg is number of lines to scroll." |
| 331 | (interactive "P") | 331 | (interactive "P") |
| 332 | (if (pos-visible-in-window-p (point-max)) | 332 | (if (pos-visible-in-window-p (point-max)) |
| 333 | (exit-recursive-edit)) | 333 | (view-exit)) |
| 334 | (setq lines | 334 | (setq lines |
| 335 | (if lines (prefix-numeric-value lines) | 335 | (if lines (prefix-numeric-value lines) |
| 336 | (view-scroll-size))) | 336 | (view-scroll-size))) |
| @@ -344,7 +344,7 @@ Arg is number of lines to scroll." | |||
| 344 | (goto-char (point-max)) | 344 | (goto-char (point-max)) |
| 345 | (recenter -1) | 345 | (recenter -1) |
| 346 | (message (substitute-command-keys | 346 | (message (substitute-command-keys |
| 347 | "End. Type \\[exit-recursive-edit] to quit viewing.")))) | 347 | "End. Type \\[view-exit] to quit viewing.")))) |
| 348 | (move-to-window-line -1) | 348 | (move-to-window-line -1) |
| 349 | (beginning-of-line)) | 349 | (beginning-of-line)) |
| 350 | 350 | ||
| @@ -435,12 +435,6 @@ invocations return to earlier marks." | |||
| 435 | (sit-for 4)))) | 435 | (sit-for 4)))) |
| 436 | 436 | ||
| 437 | 437 | ||
| 438 | ;;;###autoload | ||
| 439 | (define-key ctl-x-map "v" 'view-file) | ||
| 440 | |||
| 441 | ;;;###autoload | ||
| 442 | (define-key ctl-x-4-map "v" 'view-file-other-window) | ||
| 443 | |||
| 444 | (provide 'view) | 438 | (provide 'view) |
| 445 | 439 | ||
| 446 | ;;; view.el ends here | 440 | ;;; view.el ends here |