Mercurial > emacs
comparison lisp/subr.el @ 83219:e86fc76a45e4
Merged in changes from CVS trunk.
Patches applied:
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-611
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-612
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-613
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-614
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-615
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-46
Update from CVS
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-47
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-48
Update from CVS
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-49
Add {arch}/=commit-merge-make-log
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-50
{arch}/=commit-merge-make-log: Don't die if there are no ChangeLog changes
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-259
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Thu, 14 Oct 2004 14:42:03 +0000 |
parents | 47f53c5c9620 db7d00351c33 |
children | 0fc4928cc48e |
comparison
equal
deleted
inserted
replaced
83218:47f53c5c9620 | 83219:e86fc76a45e4 |
---|---|
365 (setq loop ?0) | 365 (setq loop ?0) |
366 (while (<= loop ?9) | 366 (while (<= loop ?9) |
367 (define-key map (char-to-string loop) 'digit-argument) | 367 (define-key map (char-to-string loop) 'digit-argument) |
368 (setq loop (1+ loop)))))) | 368 (setq loop (1+ loop)))))) |
369 | 369 |
370 ;Moved to keymap.c | |
371 ;(defun copy-keymap (keymap) | |
372 ; "Return a copy of KEYMAP" | |
373 ; (while (not (keymapp keymap)) | |
374 ; (setq keymap (signal 'wrong-type-argument (list 'keymapp keymap)))) | |
375 ; (if (vectorp keymap) | |
376 ; (copy-sequence keymap) | |
377 ; (copy-alist keymap))) | |
378 | |
379 (defvar key-substitution-in-progress nil | 370 (defvar key-substitution-in-progress nil |
380 "Used internally by substitute-key-definition.") | 371 "Used internally by substitute-key-definition.") |
381 | 372 |
382 (defun substitute-key-definition (olddef newdef keymap &optional oldmap prefix) | 373 (defun substitute-key-definition (olddef newdef keymap &optional oldmap prefix) |
383 "Replace OLDDEF with NEWDEF for any keys in KEYMAP now defined as OLDDEF. | 374 "Replace OLDDEF with NEWDEF for any keys in KEYMAP now defined as OLDDEF. |
394 ;; If optional argument PREFIX is specified, it should be a key | 385 ;; If optional argument PREFIX is specified, it should be a key |
395 ;; prefix, a string. Redefined bindings will then be bound to the | 386 ;; prefix, a string. Redefined bindings will then be bound to the |
396 ;; original key, with PREFIX added at the front. | 387 ;; original key, with PREFIX added at the front. |
397 (or prefix (setq prefix "")) | 388 (or prefix (setq prefix "")) |
398 (let* ((scan (or oldmap keymap)) | 389 (let* ((scan (or oldmap keymap)) |
399 (vec1 (vector nil)) | 390 (prefix1 (vconcat prefix [nil])) |
400 (prefix1 (vconcat prefix vec1)) | |
401 (key-substitution-in-progress | 391 (key-substitution-in-progress |
402 (cons scan key-substitution-in-progress))) | 392 (cons scan key-substitution-in-progress))) |
403 ;; Scan OLDMAP, finding each char or event-symbol that | 393 ;; Scan OLDMAP, finding each char or event-symbol that |
404 ;; has any definition, and act on it with hack-key. | 394 ;; has any definition, and act on it with hack-key. |
405 (while (consp scan) | 395 (map-keymap |
406 (if (consp (car scan)) | 396 (lambda (char defn) |
407 (let ((char (car (car scan))) | 397 (aset prefix1 (length prefix) char) |
408 (defn (cdr (car scan)))) | 398 (substitute-key-definition-key defn olddef newdef prefix1 keymap)) |
409 ;; The inside of this let duplicates exactly | 399 scan))) |
410 ;; the inside of the following let that handles array elements. | 400 |
411 (aset vec1 0 char) | 401 (defun substitute-key-definition-key (defn olddef newdef prefix keymap) |
412 (aset prefix1 (length prefix) char) | 402 (let (inner-def skipped menu-item) |
413 (let (inner-def skipped) | 403 ;; Find the actual command name within the binding. |
414 ;; Skip past menu-prompt. | 404 (if (eq (car-safe defn) 'menu-item) |
415 (while (stringp (car-safe defn)) | 405 (setq menu-item defn defn (nth 2 defn)) |
416 (setq skipped (cons (car defn) skipped)) | 406 ;; Skip past menu-prompt. |
417 (setq defn (cdr defn))) | 407 (while (stringp (car-safe defn)) |
418 ;; Skip past cached key-equivalence data for menu items. | 408 (push (pop defn) skipped)) |
419 (and (consp defn) (consp (car defn)) | 409 ;; Skip past cached key-equivalence data for menu items. |
420 (setq defn (cdr defn))) | 410 (if (consp (car-safe defn)) |
421 (setq inner-def defn) | 411 (setq defn (cdr defn)))) |
422 ;; Look past a symbol that names a keymap. | 412 (if (or (eq defn olddef) |
423 (while (and (symbolp inner-def) | 413 ;; Compare with equal if definition is a key sequence. |
424 (fboundp inner-def)) | 414 ;; That is useful for operating on function-key-map. |
425 (setq inner-def (symbol-function inner-def))) | 415 (and (or (stringp defn) (vectorp defn)) |
426 (if (or (eq defn olddef) | 416 (equal defn olddef))) |
427 ;; Compare with equal if definition is a key sequence. | 417 (define-key keymap prefix |
428 ;; That is useful for operating on function-key-map. | 418 (if menu-item |
429 (and (or (stringp defn) (vectorp defn)) | 419 (let ((copy (copy-sequence menu-item))) |
430 (equal defn olddef))) | 420 (setcar (nthcdr 2 copy) newdef) |
431 (define-key keymap prefix1 (nconc (nreverse skipped) newdef)) | 421 copy) |
432 (if (and (keymapp defn) | 422 (nconc (nreverse skipped) newdef))) |
433 ;; Avoid recursively scanning | 423 ;; Look past a symbol that names a keymap. |
434 ;; where KEYMAP does not have a submap. | 424 (setq inner-def |
435 (let ((elt (lookup-key keymap prefix1))) | 425 (condition-case nil (indirect-function defn) (error defn))) |
436 (or (null elt) | 426 ;; For nested keymaps, we use `inner-def' rather than `defn' so as to |
437 (keymapp elt))) | 427 ;; avoid autoloading a keymap. This is mostly done to preserve the |
438 ;; Avoid recursively rescanning keymap being scanned. | 428 ;; original non-autoloading behavior of pre-map-keymap times. |
439 (not (memq inner-def | 429 (if (and (keymapp inner-def) |
440 key-substitution-in-progress))) | 430 ;; Avoid recursively scanning |
441 ;; If this one isn't being scanned already, | 431 ;; where KEYMAP does not have a submap. |
442 ;; scan it now. | 432 (let ((elt (lookup-key keymap prefix))) |
443 (substitute-key-definition olddef newdef keymap | 433 (or (null elt) (natnump elt) (keymapp elt))) |
444 inner-def | 434 ;; Avoid recursively rescanning keymap being scanned. |
445 prefix1))))) | 435 (not (memq inner-def key-substitution-in-progress))) |
446 (if (vectorp (car scan)) | 436 ;; If this one isn't being scanned already, scan it now. |
447 (let* ((array (car scan)) | 437 (substitute-key-definition olddef newdef keymap inner-def prefix))))) |
448 (len (length array)) | |
449 (i 0)) | |
450 (while (< i len) | |
451 (let ((char i) (defn (aref array i))) | |
452 ;; The inside of this let duplicates exactly | |
453 ;; the inside of the previous let. | |
454 (aset vec1 0 char) | |
455 (aset prefix1 (length prefix) char) | |
456 (let (inner-def skipped) | |
457 ;; Skip past menu-prompt. | |
458 (while (stringp (car-safe defn)) | |
459 (setq skipped (cons (car defn) skipped)) | |
460 (setq defn (cdr defn))) | |
461 (and (consp defn) (consp (car defn)) | |
462 (setq defn (cdr defn))) | |
463 (setq inner-def defn) | |
464 (while (and (symbolp inner-def) | |
465 (fboundp inner-def)) | |
466 (setq inner-def (symbol-function inner-def))) | |
467 (if (or (eq defn olddef) | |
468 (and (or (stringp defn) (vectorp defn)) | |
469 (equal defn olddef))) | |
470 (define-key keymap prefix1 | |
471 (nconc (nreverse skipped) newdef)) | |
472 (if (and (keymapp defn) | |
473 (let ((elt (lookup-key keymap prefix1))) | |
474 (or (null elt) | |
475 (keymapp elt))) | |
476 (not (memq inner-def | |
477 key-substitution-in-progress))) | |
478 (substitute-key-definition olddef newdef keymap | |
479 inner-def | |
480 prefix1))))) | |
481 (setq i (1+ i)))) | |
482 (if (char-table-p (car scan)) | |
483 (map-char-table | |
484 (function (lambda (char defn) | |
485 (let () | |
486 ;; The inside of this let duplicates exactly | |
487 ;; the inside of the previous let, | |
488 ;; except that it uses set-char-table-range | |
489 ;; instead of define-key. | |
490 (aset vec1 0 char) | |
491 (aset prefix1 (length prefix) char) | |
492 (let (inner-def skipped) | |
493 ;; Skip past menu-prompt. | |
494 (while (stringp (car-safe defn)) | |
495 (setq skipped (cons (car defn) skipped)) | |
496 (setq defn (cdr defn))) | |
497 (and (consp defn) (consp (car defn)) | |
498 (setq defn (cdr defn))) | |
499 (setq inner-def defn) | |
500 (while (and (symbolp inner-def) | |
501 (fboundp inner-def)) | |
502 (setq inner-def (symbol-function inner-def))) | |
503 (if (or (eq defn olddef) | |
504 (and (or (stringp defn) (vectorp defn)) | |
505 (equal defn olddef))) | |
506 (define-key keymap prefix1 | |
507 (nconc (nreverse skipped) newdef)) | |
508 (if (and (keymapp defn) | |
509 (let ((elt (lookup-key keymap prefix1))) | |
510 (or (null elt) | |
511 (keymapp elt))) | |
512 (not (memq inner-def | |
513 key-substitution-in-progress))) | |
514 (substitute-key-definition olddef newdef keymap | |
515 inner-def | |
516 prefix1))))))) | |
517 (car scan))))) | |
518 (setq scan (cdr scan))))) | |
519 | 438 |
520 (defun define-key-after (keymap key definition &optional after) | 439 (defun define-key-after (keymap key definition &optional after) |
521 "Add binding in KEYMAP for KEY => DEFINITION, right after AFTER's binding. | 440 "Add binding in KEYMAP for KEY => DEFINITION, right after AFTER's binding. |
522 This is like `define-key' except that the binding for KEY is placed | 441 This is like `define-key' except that the binding for KEY is placed |
523 just after the binding for the event AFTER, instead of at the beginning | 442 just after the binding for the event AFTER, instead of at the beginning |
659 (cdr (get type 'event-symbol-elements)) | 578 (cdr (get type 'event-symbol-elements)) |
660 (let ((list nil) | 579 (let ((list nil) |
661 (char (logand type (lognot (logior ?\M-\^@ ?\C-\^@ ?\S-\^@ | 580 (char (logand type (lognot (logior ?\M-\^@ ?\C-\^@ ?\S-\^@ |
662 ?\H-\^@ ?\s-\^@ ?\A-\^@))))) | 581 ?\H-\^@ ?\s-\^@ ?\A-\^@))))) |
663 (if (not (zerop (logand type ?\M-\^@))) | 582 (if (not (zerop (logand type ?\M-\^@))) |
664 (setq list (cons 'meta list))) | 583 (push 'meta list)) |
665 (if (or (not (zerop (logand type ?\C-\^@))) | 584 (if (or (not (zerop (logand type ?\C-\^@))) |
666 (< char 32)) | 585 (< char 32)) |
667 (setq list (cons 'control list))) | 586 (push 'control list)) |
668 (if (or (not (zerop (logand type ?\S-\^@))) | 587 (if (or (not (zerop (logand type ?\S-\^@))) |
669 (/= char (downcase char))) | 588 (/= char (downcase char))) |
670 (setq list (cons 'shift list))) | 589 (push 'shift list)) |
671 (or (zerop (logand type ?\H-\^@)) | 590 (or (zerop (logand type ?\H-\^@)) |
672 (setq list (cons 'hyper list))) | 591 (push 'hyper list)) |
673 (or (zerop (logand type ?\s-\^@)) | 592 (or (zerop (logand type ?\s-\^@)) |
674 (setq list (cons 'super list))) | 593 (push 'super list)) |
675 (or (zerop (logand type ?\A-\^@)) | 594 (or (zerop (logand type ?\A-\^@)) |
676 (setq list (cons 'alt list))) | 595 (push 'alt list)) |
677 list)))) | 596 list)))) |
678 | 597 |
679 (defun event-basic-type (event) | 598 (defun event-basic-type (event) |
680 "Return the basic type of the given event (all modifiers removed). | 599 "Return the basic type of the given event (all modifiers removed). |
681 The value is a printing character (not upper case) or a symbol. | 600 The value is a printing character (not upper case) or a symbol. |
689 (let ((base (logand event (1- ?\A-\^@)))) | 608 (let ((base (logand event (1- ?\A-\^@)))) |
690 (downcase (if (< base 32) (logior base 64) base))))) | 609 (downcase (if (< base 32) (logior base 64) base))))) |
691 | 610 |
692 (defsubst mouse-movement-p (object) | 611 (defsubst mouse-movement-p (object) |
693 "Return non-nil if OBJECT is a mouse movement event." | 612 "Return non-nil if OBJECT is a mouse movement event." |
694 (and (consp object) | 613 (eq (car-safe object) 'mouse-movement)) |
695 (eq (car object) 'mouse-movement))) | |
696 | 614 |
697 (defsubst event-start (event) | 615 (defsubst event-start (event) |
698 "Return the starting position of EVENT. | 616 "Return the starting position of EVENT. |
699 If EVENT is a mouse or key press or a mouse click, this returns the location | 617 If EVENT is a mouse or key press or a mouse click, this returns the location |
700 of the event. | 618 of the event. |
1893 (defmacro with-temp-buffer (&rest body) | 1811 (defmacro with-temp-buffer (&rest body) |
1894 "Create a temporary buffer, and evaluate BODY there like `progn'. | 1812 "Create a temporary buffer, and evaluate BODY there like `progn'. |
1895 See also `with-temp-file' and `with-output-to-string'." | 1813 See also `with-temp-file' and `with-output-to-string'." |
1896 (declare (indent 0) (debug t)) | 1814 (declare (indent 0) (debug t)) |
1897 (let ((temp-buffer (make-symbol "temp-buffer"))) | 1815 (let ((temp-buffer (make-symbol "temp-buffer"))) |
1898 `(let ((,temp-buffer | 1816 `(let ((,temp-buffer (generate-new-buffer " *temp*"))) |
1899 (get-buffer-create (generate-new-buffer-name " *temp*")))) | |
1900 (unwind-protect | 1817 (unwind-protect |
1901 (with-current-buffer ,temp-buffer | 1818 (with-current-buffer ,temp-buffer |
1902 ,@body) | 1819 ,@body) |
1903 (and (buffer-name ,temp-buffer) | 1820 (and (buffer-name ,temp-buffer) |
1904 (kill-buffer ,temp-buffer)))))) | 1821 (kill-buffer ,temp-buffer)))))) |