Mercurial > hg > xemacs-beta
annotate lisp/symbol-syntax.el @ 5679:a81a739181dc
Add command remapping, a more robust alternative to #'substitute-key-definition
src/ChangeLog addition:
2012-09-02 Aidan Kehoe <kehoea@parhasard.net>
* keymap.c:
Add command remapping, a more robust equivalent to
#'substitute-key-definition.
* keymap.c (CHECK_REMAPPING_POSITION): New.
* keymap.c (keymap_equal): Correct a comment here.
* keymap.c (Fdefine_key): Document the command remapping syntax.
* keymap.c (Fremap_command): New.
* keymap.c (command_remapping): New.
* keymap.c (Fcommand_remapping): New.
* keymap.c (commands_remapped_to_mapper): New.
* keymap.c (commands_remapped_to_traverser): New.
* keymap.c (Fcommands_remapped_to): New.
* keymap.c (get_relevant_keymaps): Take a new POSITION argument.
* keymap.c (Fcurrent_keymaps, event_binding):
Supply the new POSITION argument to get_relevant_keymaps.
* keymap.c (Fkey_binding):
Add new arguments, NO-REMAP and POSITION.
* keymap.c (map_keymap_mapper):
* keymap.c (Fwhere_is_internal):
* keymap.c (where_is_to_char):
* keymap.c (where_is_recursive_mapper):
Don't expose the key remapping in these functions. This conflicts
with GNU, but is more sane for our callers. Access to command
remapping is with the functions #'command-remapping,
#'commands-remapped-to, and #'remap-command, not with the general
keymap functions, apart from the compatibility hack in #'define-key.
* keymap.c (syms_of_keymap):
* keymap.c (vars_of_keymap):
* keymap.c (complex_vars_of_keymap):
* lisp.h: New CHECK_COMMAND macro.
man/ChangeLog addition:
2012-09-02 Aidan Kehoe <kehoea@parhasard.net>
* lispref/keymaps.texi (Keymaps):
* lispref/keymaps.texi (Changing Key Bindings):
* lispref/keymaps.texi (Scanning Keymaps):
* lispref/keymaps.texi (Remapping commands):
* lispref/keymaps.texi (XEmacs): New.
* lispref/keymaps.texi (Other Keymap Functions):
Document the new command remapping functionality in this file.
lisp/ChangeLog addition:
2012-09-02 Aidan Kehoe <kehoea@parhasard.net>
* help.el (describe-function-1):
Document any command remapping that has been done in this function.
tests/ChangeLog addition:
2012-09-02 Aidan Kehoe <kehoea@parhasard.net>
* automated/keymap-tests.el:
Test the new command remapping functionality.
| author | Aidan Kehoe <kehoea@parhasard.net> |
|---|---|
| date | Sun, 02 Sep 2012 14:31:40 +0100 |
| parents | 308d34e9f07d |
| children |
| rev | line source |
|---|---|
| 428 | 1 ;;; symbol-syntax.el --- find chars with symbol syntax |
| 2 | |
| 3 ;; Copyright (C) 1992, 1993, 1997 Free Software Foundation, Inc. | |
| 4 ;; Copyright (C) 1995 Sun Microsystems. | |
| 5 | |
| 6 ;; Author: JBW, JBW@_CORTEZ | |
| 7 ;; Created: Wed Jun 20 15:15:34 1990 | |
| 8 ;; Maintainer: XEmacs Development Team | |
| 9 ;; Keywords: matching | |
| 10 | |
| 11 ;; This file is part of XEmacs. | |
| 12 | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
428
diff
changeset
|
13 ;; XEmacs is free software: you can redistribute it and/or modify it |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
428
diff
changeset
|
14 ;; under the terms of the GNU General Public License as published by the |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
428
diff
changeset
|
15 ;; Free Software Foundation, either version 3 of the License, or (at your |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
428
diff
changeset
|
16 ;; option) any later version. |
| 428 | 17 |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
428
diff
changeset
|
18 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
428
diff
changeset
|
19 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
428
diff
changeset
|
20 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
428
diff
changeset
|
21 ;; for more details. |
| 428 | 22 |
| 23 ;; You should have received a copy of the GNU General Public License | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
428
diff
changeset
|
24 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>. |
| 428 | 25 |
| 26 ;;; Synched up with: Not in FSF. | |
| 27 | |
| 28 ;;; Commentary: | |
| 29 | |
| 30 ;; Last modified by: Ben Wing, ben@xemacs.org | |
| 31 ;; Last modified on: Mon Oct 2 02:32:05 GMT 1995 | |
| 32 | |
| 33 ;;; Code: | |
| 34 | |
| 35 (defvar symbol-syntax-table-alist nil) | |
| 36 ;; '((c-mode-syntax-table) | |
| 37 ;; (emacs-lisp-mode-syntax-table) | |
| 38 ;; (lisp-mode-syntax-table) | |
| 39 ;; (text-mode-syntax-table))) | |
| 40 | |
| 41 (defun update-symbol-syntax-table-alist () | |
| 42 (let ((alist symbol-syntax-table-alist) | |
| 43 item) | |
| 44 (while (consp alist) | |
| 45 (cond ((null (car alist)) | |
| 46 (error "Missing alist item")) | |
| 47 ((null (car (car alist))) | |
| 48 (error "Alist item with null car")) | |
| 49 ;; this functionality not used | |
| 50 ((symbolp (setq item (car (car alist)))) | |
| 51 (or (null (cdr (car alist))) | |
| 52 (error "Alist item expected to have null cdr")) | |
| 53 (while (symbolp item) | |
| 54 (setq item (symbol-value item))) | |
| 55 (setcar (car alist) item))) | |
| 56 (cond ((not (syntax-table-p (car (car alist)))) | |
| 57 (error "Alist item car expected to be symbol table")) | |
| 58 ((null (cdr (car alist))) | |
| 59 (setcdr (car alist) | |
| 60 (make-symbol-syntax-table (car (car alist)))))) | |
| 61 (setq alist (cdr alist))))) | |
| 62 | |
| 63 (defun get-symbol-syntax-table (norm-table) | |
| 64 (let (result) | |
| 65 (if (setq result (assq norm-table symbol-syntax-table-alist)) | |
| 66 nil | |
| 67 (update-symbol-syntax-table-alist) | |
| 68 (if (setq result (assq norm-table symbol-syntax-table-alist)) | |
| 69 nil | |
| 70 (setq symbol-syntax-table-alist | |
| 71 (cons (list norm-table) | |
| 72 symbol-syntax-table-alist)) | |
| 73 (update-symbol-syntax-table-alist) | |
| 74 (or (setq result (assq norm-table symbol-syntax-table-alist)) | |
| 75 (error "Syntax table missing from symbol-syntax-table-alist")))) | |
| 76 (or (setq result (cdr result)) | |
| 77 (error "Alist item has null cdr")) | |
| 78 (or (syntax-table-p result) | |
| 79 (error "Non-syntax-table item in alist")) | |
| 80 result)) | |
| 81 | |
| 82 (defun make-symbol-syntax-table (in-table) | |
| 83 (let ((out-table (copy-syntax-table in-table))) | |
| 84 (map-syntax-table | |
| 85 #'(lambda (key value) | |
| 86 (if (eq ?_ (char-syntax-from-code value)) | |
| 87 (put-char-table key (set-char-syntax-in-code value ?w) | |
| 88 out-table)) | |
| 89 nil) | |
| 90 out-table) | |
| 91 out-table)) | |
| 92 | |
| 93 ;; stuff for examining contents of syntax tables | |
| 94 ;;(show-chars-with-syntax | |
| 95 ;; '(c-mode-syntax-table | |
| 96 ;; emacs-lisp-mode-syntax-table | |
| 97 ;; lisp-mode-syntax-table | |
| 98 ;; text-mode-syntax-table) | |
| 99 ;; ?_) | |
| 100 | |
| 101 (defun show-chars-with-syntax (tables syntax) | |
| 102 (let ((schars nil)) | |
| 103 (unwind-protect | |
| 104 (while (consp tables) | |
| 105 (let* ((chars nil) | |
| 106 (table-symbol (car tables)) | |
| 107 (table table-symbol)) | |
| 108 (or (symbolp table-symbol) | |
| 109 (error "bad argument non-symbol")) | |
| 110 (while (symbolp table) | |
| 111 (setq table (symbol-value table))) | |
| 112 (map-syntax-table | |
| 113 #'(lambda (key value) | |
| 114 (if (eq syntax (char-syntax-from-code value)) | |
| 115 (setq chars (cons key chars))) | |
| 116 nil) | |
| 117 table) | |
| 118 (setq schars (cons (list table-symbol (nreverse chars)) | |
| 119 schars))) | |
| 120 (setq tables (cdr tables)))) | |
| 121 (nreverse schars))) | |
| 122 | |
| 123 (provide 'symbol-syntax) | |
| 124 | |
| 125 ;;; symbol-syntax.el ends here |
