Changeset 8748


Ignore:
Timestamp:
03/07/05 20:23:56 (16 years ago)
Author:
piso
Message:

Work in progress.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/emacs.lisp

    r8738 r8748  
    22;;;
    33;;; Copyright (C) 2005 Peter Graves
    4 ;;; $Id: emacs.lisp,v 1.11 2005-03-07 03:34:53 piso Exp $
     4;;; $Id: emacs.lisp,v 1.12 2005-03-07 20:23:56 piso Exp $
    55;;;
    66;;; This program is free software; you can redistribute it and/or
     
    2020(in-package #:j)
    2121
    22 (export '(emacs-mode java-mode-map lisp-mode-map))
     22(export '(emacs-mode
     23          java-mode-map
     24          lisp-mode-map
     25          directory-mode-map))
    2326
    2427(defpackage #:emacs
     
    9194;; // Goto menu.
    9295;; mapKey(KeyEvent.VK_J, CTRL_MASK, "jumpToLine");
     96(define-key *emacs-global-map* "Alt G" "jumpToLine")
     97(define-key *esc-map* #\g "jumpToLine")
    9398;; mapKey(KeyEvent.VK_J, CTRL_MASK | SHIFT_MASK, "jumpToColumn");
    9499;; mapKey(KeyEvent.VK_M, CTRL_MASK, "findMatchingChar");
     
    179184    (#\>                        "eob")
    180185    (#\.                        "findTagAtDot")
     186    (#\,                        "listMatchingTagsAtDot")
    181187    (#\%                        "replace")
    182188    ))
     
    217223    ("Ctrl J"                   "newlineAndIndent")))
    218224
    219 ;; keyboard-quit
    220 (define-key *emacs-global-map* "Ctrl G" "escape")
    221 
    222 ;; mapKey(KeyEvent.VK_G, CTRL_MASK | SHIFT_MASK, "gotoFile");
    223 ;; mapKey(KeyEvent.VK_B, CTRL_MASK | SHIFT_MASK, "browseFileAtDot");
    224 
    225 ;; mapKey(KeyEvent.VK_D, CTRL_MASK, "dir");
     225(define-key *emacs-global-map* "Shift Alt 9" "insertParentheses")
     226(define-key *emacs-global-map* "Shift Alt 0" "movePastCloseAndReindent")
     227
     228(define-key *emacs-global-map* "Ctrl G" "escape") ; keyboard-quit
     229
     230(define-key *emacs-global-map* "Ctrl Shift G" "gotoFile")
     231(define-key *emacs-global-map* "Ctrl Shift B" "browsefileatdot")
     232
    226233(define-key *control-x-map* #\d "dir")
    227234
     
    294301;; mapKey(KeyEvent.VK_W, ALT_MASK, "selectWord");
    295302
    296 ;; mapKey(VK_MOUSE_1, 0, "mouseMoveDotToPoint");
    297 (define-key *emacs-global-map* "Mouse-1" "mouseMoveDotToPoint")
    298 ;; mapKey(VK_MOUSE_1, SHIFT_MASK, "mouseSelect");
    299 ;; mapKey(VK_MOUSE_1, CTRL_MASK | SHIFT_MASK, "mouseSelectColumn");
    300 ;; mapKey(VK_DOUBLE_MOUSE_1, 0, "selectWord");
    301 (define-key *emacs-global-map* "Double Mouse-1" "selectWord")
    302 
    303 ;; if (Platform.isPlatformUnix()) {
    304 ;; mapKey(VK_MOUSE_2, 0, "pastePrimarySelection");
    305 ;; mapKey(KeyEvent.VK_INSERT, SHIFT_MASK, "pastePrimarySelection");
    306 ;; }
    307 
    308 ;; mapKey(VK_MOUSE_3, 0, "mouseShowContextMenu");
    309 
    310 ;; mapKey(KeyEvent.VK_F7, 0, "recordMacro");
    311 ;; mapKey(KeyEvent.VK_F8, 0, "playbackMacro");
     303;; FIXME These are j's normal mouse bindings. We don't have the required
     304;; functionality in the right form to support the emacs mouse bindings.
     305(define-keys *emacs-global-map*
     306  '(("Mouse-1"                  "mouseMoveDotToPoint")
     307    ("Shift Mouse-1"            "mouseSelect")
     308    ("Ctrl Shift Mouse-1"       "mouseSelectColumn")
     309    ("Double Mouse-1"           "selectWord")
     310    ("Mouse-3"                  "mouseShowContextMenu")))
     311
     312(when (featurep :unix)
     313  (define-key *emacs-global-map* "Mouse-2" "pastePrimarySelection"))
     314
     315(define-keys *control-x-map*
     316  '((#\(                        "startMacro")
     317    (#\)                        "endMacro")
     318    (#\e                        "playbackMacro")))
    312319
    313320;; mapKey(KeyEvent.VK_W, CTRL_MASK | SHIFT_MASK, "killFrame");
     
    324331    ("o"                        "otherwindow")))
    325332
    326 ;; if (Editor.preferences().getBooleanProperty(Property.ENABLE_EXPERIMENTAL_FEATURES))
    327 ;; mapKey(KeyEvent.VK_F9, ALT_MASK, "shell");
    328 
    329 ;; // Map these globally so they're available in the compilation buffer too.
    330 ;; mapKey(KeyEvent.VK_F4, 0, "nextError");
     333(when (variable-value 'enable-experimental-features)
     334  (define-key *emacs-global-map* "Alt F9" "shell"))
     335
    331336(define-key *control-x-map* "`" "nextError")
    332337(define-key *emacs-global-map* "F4" "nextError")
    333 ;; mapKey(KeyEvent.VK_F4, SHIFT_MASK, "previousError");
    334338(define-key *emacs-global-map* "Shift F4" "previousError")
    335 ;; mapKey(KeyEvent.VK_M, CTRL_MASK | ALT_MASK, "showMessage");
    336339(define-key *emacs-global-map* "Ctrl Alt M" "showMessage")
    337340
    338 ;; // Windows VM seems to need this mapping for the tab key to work properly.
    339 ;; // There's also code in Dispatcher.dispatchKeyTyped to handle the tab key.
    340 ;; mapKey(KeyEvent.VK_TAB, 0, "insertTab");
    341 
    342 ;; if (Platform.isPlatformLinux()) {
    343 ;; // These mappings work with Blackdown 1.2.2 (and 1.2 pre-release v2).
    344 ;; mapKey(0x2d, CTRL_MASK, "toCenter"); // Ctrl -
    345 ;; mapKey(0x5f, CTRL_MASK | SHIFT_MASK, "toTop"); // Ctrl Shift -
    346 
    347 ;; // IBM 1.3, Sun 1.4.0 beta 2.
    348 ;; mapKey(0x2d, CTRL_MASK | SHIFT_MASK, "toTop"); // Ctrl Shift -
    349 ;; } else if (Platform.isPlatformWindows()) {
    350 ;; mapKey(0x2d, CTRL_MASK, "toCenter"); // Ctrl -
    351 ;; mapKey(0x2d, CTRL_MASK | SHIFT_MASK, "toTop"); // Ctrl Shift -
    352 ;; }
    353 
     341;; FIXME We need a binding for findTag.
    354342(define-key *emacs-global-map* "Alt ." "findTagAtDot")
    355 
    356 ;; Help.
     343(define-key *emacs-global-map* "Alt ," "listMatchingTagsAtDot")
     344
     345;;; Help.
     346
    357347(define-keys *help-map*
    358348  '(("a"                        "apropos")
    359349    ("b"                        "describeBindings")
     350    ("c"                        "describeKey") ; describe-key-briefly
    360351    ("i"                        "help")
    361352    ("k"                        "describeKey")))
    362353
    363 ;; Java mode.
    364 (define-key *java-mode-map* "{" "electricOpenBrace")
    365 (define-key *java-mode-map* "}" "electricCloseBrace")
    366 (define-key *java-mode-map* "Tab" "tab")
    367 (define-key *java-mode-map* "Ctrl Tab" "insertTab")
    368 (define-key *java-mode-map* "';'" "electricSemi")
    369 ;;                km.mapKey(':', "electricColon");
    370 (define-key *java-mode-map* #\: "electricColon")
    371 ;;                km.mapKey('*', "electricStar");
    372 ;;                km.mapKey(KeyEvent.VK_T, CTRL_MASK, "findTag");
    373 ;;                km.mapKey(KeyEvent.VK_PERIOD, ALT_MASK, "findTagAtDot");
    374 ;;                km.mapKey(KeyEvent.VK_COMMA, ALT_MASK, "listMatchingTagsAtDot");
    375 ;;                km.mapKey(KeyEvent.VK_PERIOD, CTRL_MASK | ALT_MASK, "findTagAtDotOtherWindow");
    376 ;;                km.mapKey(')', "closeParen");
    377 ;; km.mapKey(KeyEvent.VK_I, ALT_MASK, "cycleIndentSize");
    378 
    379 ;; km.mapKey(KeyEvent.VK_9, CTRL_MASK | SHIFT_MASK, "insertParentheses");
    380 ;; km.mapKey(KeyEvent.VK_0, CTRL_MASK | SHIFT_MASK, "movePastCloseAndReindent");
    381 
    382 ;; km.mapKey(KeyEvent.VK_OPEN_BRACKET, CTRL_MASK | SHIFT_MASK, "insertBraces");
    383 (define-key *java-mode-map* "Ctrl Shift [" "insertBraces")
    384 ;; // Duplicate mapping for 1.4.
    385 ;; km.mapKey(KeyEvent.VK_BRACELEFT, CTRL_MASK | SHIFT_MASK, "insertBraces");
    386 
    387 ;; km.mapKey(KeyEvent.VK_F12, 0, "wrapComment");
    388 (define-key *java-mode-map* "F12" "wrapComment")
    389 
    390 ;; // Duplicate mapping to support IBM 1.3 for Linux.
    391 ;; km.mapKey(0xffc9, 0, "wrapComment"); // F12
    392 
    393 ;; km.mapKey(KeyEvent.VK_OPEN_BRACKET, CTRL_MASK, "fold");
    394 ;; km.mapKey(KeyEvent.VK_CLOSE_BRACKET, CTRL_MASK, "unfold");
    395 
    396 ;; km.mapKey(KeyEvent.VK_F9, 0, "compile");
    397 (define-key *java-mode-map* "F9" "compile")
    398 ;; km.mapKey(KeyEvent.VK_F9, CTRL_MASK, "recompile");
    399 (define-key *java-mode-map* "Ctrl F9" "recompile")
    400 ;; km.mapKey(KeyEvent.VK_F1, ALT_MASK, "jdkHelp");
    401 ;; km.mapKey(KeyEvent.VK_F1, CTRL_MASK, "source");
    402 
    403 ;; // This is the "normal" mapping.
    404 ;; km.mapKey(KeyEvent.VK_COMMA,  CTRL_MASK | SHIFT_MASK, "htmlInsertTag");
    405 ;; // The "normal" mapping doesn't work for Linux, but this does.
    406 ;; km.mapKey(0x7c, CTRL_MASK | SHIFT_MASK, "htmlInsertTag");
    407 
    408 ;; if (Editor.checkExperimental()) {
    409 ;; km.mapKey(KeyEvent.VK_SEMICOLON, ALT_MASK, "JavaMode.insertComment");
    410 ;; km.mapKey(KeyEvent.VK_ENTER, ALT_MASK, "JavaMode.newlineAndIndentForComment");
    411 ;; }
    412 
    413 ;; if (Platform.isPlatformLinux()) {
    414 ;; // Blackdown 1.1.7v3, 1.2pre2, IBM 1.1.8.
    415 ;; // Duplicate mappings needed for VK_9, VK_0 and VK_OPEN_BRACKET.
    416 ;; km.mapKey(0x68, CTRL_MASK | SHIFT_MASK, "insertParentheses");
    417 ;; km.mapKey(0x69, CTRL_MASK | SHIFT_MASK, "movePastCloseAndReindent");
    418 ;; km.mapKey(0xbb, CTRL_MASK | SHIFT_MASK, "insertBraces");
    419 ;; }
    420 
     354;;; Java mode.
     355
     356(define-key *java-mode-map*
     357  '(("{"                        "electricOpenBrace")
     358    ("}"                        "electricCloseBrace")
     359    ("Tab"                      "tab")
     360    ("Ctrl Tab"                 "insertTab")
     361    ("';'"                      "electricSemi")
     362    (#\:                        "electricColon")
     363    (#\*                        "electricStar")
     364    (#\)                        "closeParen")
     365    ("Ctrl Shift ["             "insertBraces")
     366    ("F12"                      "wrapComment")
     367    ("F9"                       "compile")
     368    ("Ctrl F9"                  "recompile")
     369    ("Alt F1"                   "jdkHelp")
     370    ("Ctrl F1"                  "source")))
     371
     372(defun java-mode-map ()
     373  *java-mode-map*)
     374
     375;;; Lisp mode
     376
     377(defparameter *lisp-mode-map* (make-keymap))
     378(defparameter *lisp-mode-control-c-map* (make-keymap))
     379(define-key *lisp-mode-map* "Ctrl C" *lisp-mode-control-c-map*)
     380
     381(define-keys *lisp-mode-map*
     382  '(("Tab"                      "tab")
     383    ("Ctrl Tab"                 "insertTab")
     384    ("F12"                      "wrapComment")
     385    (#\)                        "closeParen")
     386    ("Alt F1"                   "hyperspec")
     387    ("Ctrl Alt F"               "forwardSexp")
     388    ("Ctrl Alt B"               "backwardSexp")
     389    ("Ctrl Alt Space"           "markSexp")
     390    ("Ctrl Alt D"               "downList")
     391    ("Ctrl Alt U"               "backwardUpList")
     392    ("Ctrl Alt X"               "evalDefunLisp")))
     393
     394(define-keys *lisp-mode-control-c-map*
     395  '(("Ctrl C"                   "compileDefunLisp")
     396    ("Ctrl R"                   "evalRegionLisp")))
     397
     398(defun lisp-mode-map ()
     399  *lisp-mode-map*)
     400
     401;;; Directory mode.
     402
     403(defparameter *directory-mode-map* (make-keymap))
     404
     405;; These are basically j's normal directory mode bindings. J's directory mode
     406;; doesn't really work like dired in emacs.
     407(define-keys *directory-mode-map*
     408  '(("Enter"                    "dirOpenFile")
     409    ("Ctrl Shift G"             "diropenfile")
     410    ("Double Mouse-1"           "dirOpenFile")
     411    ("Mouse-2"                  "dirOpenFile")
     412    ("Ctrl Enter"               "diropenfileandkilldirectory")
     413    ("Ctrl Shift B"             "dirBrowseFile")
     414    ("Backspace"                "dirUpDir")
     415    (#\u                        "dirUpDir")
     416    (#\l                        "dirLimit")
     417    (#\L                        "dirUnlimit")
     418    (#\s                        "dirCycleSortBy")
     419    (#\r                        "dirRescan")
     420    ("Delete"                   "dirDeleteFiles")
     421    (#\c                        "dirCopyFile")
     422    (#\g                        "dirGetFile")
     423    (#\m                        "dirMoveFile")
     424    (#\t                        "dirTagFile")
     425    (#\!                        "dirDoShellCommand")
     426    ("Home"                     "dirHome")
     427    (#\b                        "dirBack")
     428    (#\f                        "dirForward")))
     429
     430(defun directory-mode-map ()
     431  *directory-mode-map*)
    421432
    422433(defun emacs-mode (&optional (arg t))
     
    429440         (j::%execute-command "reloadKeyMaps"))
    430441        ((null arg)
    431          (set-global-property "useMenuMnemonics" "false")
     442         (set-global-property "useMenuMnemonics" "true")
    432443         (set-global-property "emulation" nil)
    433444         (j::%execute-command "defaultKeyMaps"))))
    434 
    435 (defun java-mode-map ()
    436   *java-mode-map*)
    437 
    438 ;;; Lisp mode
    439 
    440 (defparameter *lisp-mode-map* (make-keymap))
    441 
    442 ;; km.mapKey(KeyEvent.VK_TAB, 0, "tab");
    443 (define-key *lisp-mode-map* "Tab" "tab")
    444 ;; km.mapKey(KeyEvent.VK_TAB, CTRL_MASK, "insertTab");
    445 (define-key *lisp-mode-map* "Ctrl Tab" "insertTab")
    446 ;; km.mapKey(KeyEvent.VK_F12, 0, "wrapComment");
    447 (define-key *lisp-mode-map* "F12" "wrapComment")
    448 ;; km.mapKey(KeyEvent.VK_T, CTRL_MASK, "findTag");
    449 ;; km.mapKey(KeyEvent.VK_COMMA, ALT_MASK, "listMatchingTagsAtDot");
    450 ;; km.mapKey(KeyEvent.VK_PERIOD, CTRL_MASK | ALT_MASK, "findTagAtDotOtherWindow");
    451 (define-key *lisp-mode-map* #\) "closeParen")
    452 ;; km.mapKey(KeyEvent.VK_F1, ALT_MASK, "hyperspec");
    453 (define-key *lisp-mode-map* "Alt F1" "hyperspec")
    454 ;; km.mapKey(KeyEvent.VK_F, CTRL_MASK | ALT_MASK, "forwardSexp");
    455 (define-key *lisp-mode-map* "Ctrl Alt F" "forwardSexp")
    456 ;; km.mapKey(KeyEvent.VK_B, CTRL_MASK | ALT_MASK, "backwardSexp");
    457 (define-key *lisp-mode-map* "Ctrl Alt B" "backwardSexp")
    458 (define-key *lisp-mode-map* "Ctrl Alt Space" "markSexp")
    459 ;; km.mapKey(KeyEvent.VK_D, CTRL_MASK | ALT_MASK, "downList");
    460 (define-key *lisp-mode-map* "Ctrl Alt D" "downList")
    461 ;; km.mapKey(KeyEvent.VK_U, CTRL_MASK | ALT_MASK, "backwardUpList");
    462 (define-key *lisp-mode-map* "Ctrl Alt U" "backwardUpList")
    463 ;; km.mapKey(KeyEvent.VK_X, CTRL_MASK | ALT_MASK, "evalDefunLisp");
    464 ;; km.mapKey(KeyEvent.VK_C, CTRL_MASK | ALT_MASK, "compileDefunLisp");
    465 ;; km.mapKey(KeyEvent.VK_R, CTRL_MASK | ALT_MASK, "evalRegionLisp");
    466 ;; km.mapKey(KeyEvent.VK_M, CTRL_MASK, "lispFindMatchingChar");
    467 ;; km.mapKey(KeyEvent.VK_M, CTRL_MASK | SHIFT_MASK, "lispSelectSyntax");
    468 ;; km.mapKey(KeyEvent.VK_9, CTRL_MASK | SHIFT_MASK, "insertParentheses");
    469 ;; km.mapKey(KeyEvent.VK_0, CTRL_MASK | SHIFT_MASK, "movePastCloseAndReindent");
    470 
    471 (defun lisp-mode-map ()
    472   *lisp-mode-map*)
    473 
    474 (provide 'emacs)
Note: See TracChangeset for help on using the changeset viewer.