Changeset 120
- Timestamp:
- 10/13/02 16:51:57 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/j/src/org/armedbear/j/LispMode.java
r2 r120 3 3 * 4 4 * Copyright (C) 1998-2002 Peter Graves 5 * $Id: LispMode.java,v 1. 1.1.1 2002-09-24 16:08:17 piso Exp $5 * $Id: LispMode.java,v 1.2 2002-10-13 16:51:57 piso Exp $ 6 6 * 7 7 * This program is free software; you can redistribute it and/or … … 32 32 super(LISP_MODE, LISP_MODE_NAME); 33 33 keywords = new Keywords(this); 34 setProperty(Property.INDENT_SIZE, 2); 34 35 } 35 36 … … 56 57 protected void setKeyMapDefaults(KeyMap km) 57 58 { 59 km.mapKey(KeyEvent.VK_TAB, 0, "tab"); 58 60 km.mapKey(KeyEvent.VK_ENTER, 0, "newlineAndIndent"); 59 61 km.mapKey(KeyEvent.VK_T, CTRL_MASK, "findTag"); … … 106 108 return inQuote; 107 109 } 110 111 public boolean canIndent() 112 { 113 return true; 114 } 115 116 public int getCorrectIndentation(Line line, Buffer buffer) 117 { 118 Position here = new Position(line, 0); 119 Position start = findStartOfDefun(here); 120 LispSyntaxIterator it = new LispSyntaxIterator(start); 121 int depth = 0; 122 while (it.getPosition().isBefore(here)) { 123 char c = it.nextChar(); 124 if (c == '(') 125 ++depth; 126 else if (c == ')') 127 --depth; 128 } 129 return buffer.getIndentSize() * depth; 130 } 131 132 private Position findStartOfDefun(Position pos) 133 { 134 Line line = pos.getLine(); 135 while (true) { 136 if (line.getText().startsWith("(def")) 137 return new Position(line, 0); 138 Line prev = line.previous(); 139 if (prev == null) 140 return new Position(line, 0); 141 line = prev; 142 } 143 } 108 144 }
Note: See TracChangeset
for help on using the changeset viewer.