/[climacs]/climacs/gui.lisp
ViewVC logotype

Contents of /climacs/gui.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.99 - (hide annotations)
Wed Jan 26 16:10:40 2005 UTC (9 years, 2 months ago) by abakic
Branch: MAIN
Changes since 1.98: +1 -1 lines
Persistent/balanced-tree buffer implementations with tests.
1 ejohnson 1.27 ;;; -*- Mode: Lisp; Package: CLIMACS-GUI -*-
2    
3 mvilleneuve 1.65 ;;; (c) copyright 2004-2005 by
4 ejohnson 1.27 ;;; Robert Strandh (strandh@labri.fr)
5 mvilleneuve 1.65 ;;; (c) copyright 2004-2005 by
6 ejohnson 1.27 ;;; Elliott Johnson (ejohnson@fasl.info)
7 mvilleneuve 1.65 ;;; (c) copyright 2005 by
8     ;;; Matthieu Villeneuve (matthieu.villeneuve@free.fr)
9 abakic 1.68 ;;; (c) copyright 2005 by
10     ;;; Aleksandar Bakic (a_bakic@yahoo.com)
11 ejohnson 1.27
12     ;;; This library is free software; you can redistribute it and/or
13     ;;; modify it under the terms of the GNU Library General Public
14     ;;; License as published by the Free Software Foundation; either
15     ;;; version 2 of the License, or (at your option) any later version.
16     ;;;
17     ;;; This library is distributed in the hope that it will be useful,
18     ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19     ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20     ;;; Library General Public License for more details.
21     ;;;
22     ;;; You should have received a copy of the GNU Library General Public
23     ;;; License along with this library; if not, write to the
24     ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25     ;;; Boston, MA 02111-1307 USA.
26    
27     ;;; GUI for the Climacs editor.
28    
29     (in-package :climacs-gui)
30    
31 rstrandh 1.70 (defclass extended-pane (climacs-pane)
32     (;; allows a certain number of commands to have some minimal memory
33 rstrandh 1.49 (previous-command :initform nil :accessor previous-command)
34     ;; for next-line and previous-line commands
35     (goal-column :initform nil)
36     ;; for dynamic abbrev expansion
37     (original-prefix :initform nil)
38     (prefix-start-offset :initform nil)
39 abakic 1.68 (dabbrev-expansion-mark :initform nil)
40     (overwrite-mode :initform nil)))
41 ejohnson 1.27
42 rstrandh 1.81 (defclass info-pane (application-pane)
43     ((climacs-pane :initarg :climacs-pane)))
44    
45 rstrandh 1.28 (defclass minibuffer-pane (application-pane) ())
46    
47     (defmethod stream-accept :before ((pane minibuffer-pane) type &rest args)
48     (declare (ignore type args))
49     (window-clear pane))
50    
51 ejohnson 1.27 (define-application-frame climacs ()
52 rstrandh 1.83 ((windows :accessor windows)
53 rstrandh 1.85 (buffers :initform '() :accessor buffers)
54     (recordingp :initform nil :accessor recordingp)
55     (executingp :initform nil :accessor executingp)
56     (recorded-keys :initform '() :accessor recorded-keys)
57     (remaining-keys :initform '() :accessor remaining-keys))
58 ejohnson 1.27 (:panes
59 rstrandh 1.81 (win (let* ((extended-pane
60     (make-pane 'extended-pane
61     :width 900 :height 400
62     :name 'bla
63     :incremental-redisplay t
64     :display-function 'display-win))
65     (info-pane
66     (make-pane 'info-pane
67     :climacs-pane extended-pane
68     :width 900 :height 20 :max-height 20 :min-height 20
69     ::background +gray85+
70     :scroll-bars nil
71     :borders nil
72     :incremental-redisplay t
73     :display-function 'display-info)))
74     (vertically ()
75     (scrolling ()
76     extended-pane)
77     info-pane)))
78 rstrandh 1.62 (int (make-pane 'minibuffer-pane
79     :width 900 :height 20 :max-height 20 :min-height 20
80     :scroll-bars nil)))
81 ejohnson 1.27 (:layouts
82     (default
83     (vertically (:scroll-bars nil)
84 rstrandh 1.77 win
85 rstrandh 1.80 int)))
86 ejohnson 1.27 (:top-level (climacs-top-level)))
87    
88 abakic 1.87 (defmacro current-window () ; shouldn't this be an inlined function? --amb
89 rstrandh 1.83 `(car (windows *application-frame*)))
90 rstrandh 1.80
91 rstrandh 1.98 (defmethod execute-frame-command :around ((frame climacs) command)
92     (declare (ignore command))
93     (with-undo ((buffer (current-window)))
94     (call-next-method)))
95    
96 rstrandh 1.80 (defmethod redisplay-frame-panes :around ((frame climacs) &rest args)
97 rstrandh 1.70 (declare (ignore args))
98 rstrandh 1.83 (let ((buffers (remove-duplicates (mapcar #'buffer (windows frame)))))
99     (loop for buffer in buffers
100     do (update-syntax buffer (syntax buffer)))
101 rstrandh 1.80 (call-next-method)
102 rstrandh 1.83 (loop for buffer in buffers
103     do (clear-modify buffer))))
104 rstrandh 1.28
105 ejohnson 1.27 (defun climacs ()
106     "Starts up a climacs session"
107     (let ((frame (make-application-frame 'climacs)))
108     (run-frame-top-level frame)))
109    
110 rstrandh 1.30 (defun display-message (format-string &rest format-args)
111     (apply #'format *standard-input* format-string format-args))
112    
113 ejohnson 1.27 (defun display-info (frame pane)
114 rstrandh 1.81 (declare (ignore frame))
115     (with-slots (climacs-pane) pane
116     (let* ((buf (buffer climacs-pane))
117 mvilleneuve 1.96 (name-info (format nil " ~a ~a Syntax: ~a~a~a~a ~a"
118 rstrandh 1.81 (if (needs-saving buf) "**" "--")
119     (name buf)
120     (name (syntax buf))
121     (if (slot-value climacs-pane 'overwrite-mode)
122 mvilleneuve 1.86 " Ovwrt"
123 rstrandh 1.85 "")
124 mvilleneuve 1.92 (if (auto-fill-mode climacs-pane)
125 mvilleneuve 1.86 " Fill"
126     "")
127 mvilleneuve 1.96 (if (isearch-mode climacs-pane)
128     " Isearch"
129     "")
130 rstrandh 1.85 (if (recordingp *application-frame*)
131     "Def"
132 rstrandh 1.81 ""))))
133     (princ name-info pane))))
134 ejohnson 1.27
135     (defun display-win (frame pane)
136     "The display function used by the climacs application frame."
137     (declare (ignore frame))
138 rstrandh 1.83 (redisplay-pane pane (eq pane (car (windows *application-frame*)))))
139 ejohnson 1.27
140     (defun find-gestures (gestures start-table)
141     (loop with table = (find-command-table start-table)
142     for (gesture . rest) on gestures
143     for item = (find-keystroke-item gesture table :errorp nil)
144     while item
145     do (if (eq (command-menu-item-type item) :command)
146     (return (if (null rest) item nil))
147     (setf table (command-menu-item-value item)))
148     finally (return item)))
149    
150 ejohnson 1.50 (defvar *kill-ring* (make-instance 'kill-ring :max-size 7))
151 ejohnson 1.27 (defparameter *current-gesture* nil)
152    
153 rstrandh 1.36 (defun meta-digit (gesture)
154     (position gesture
155     '((#\0 :meta) (#\1 :meta) (#\2 :meta) (#\3 :meta) (#\4 :meta)
156     (#\5 :meta) (#\6 :meta) (#\7 :meta) (#\8 :meta) (#\9 :meta))
157     :test #'event-matches-gesture-name-p))
158    
159 rstrandh 1.47 (defun climacs-read-gesture ()
160 rstrandh 1.85 (unless (null (remaining-keys *application-frame*))
161     (return-from climacs-read-gesture
162     (pop (remaining-keys *application-frame*))))
163 rstrandh 1.47 (loop for gesture = (read-gesture :stream *standard-input*)
164 rstrandh 1.85 when (event-matches-gesture-name-p gesture '(:keyboard #\g 512)) ; FIXME
165 rstrandh 1.47 do (throw 'outer-loop nil)
166     until (or (characterp gesture)
167     (and (typep gesture 'keyboard-event)
168     (or (keyboard-event-character gesture)
169     (not (member (keyboard-event-key-name
170     gesture)
171     '(:control-left :control-right
172     :shift-left :shift-right
173     :meta-left :meta-right
174     :super-left :super-right
175     :hyper-left :hyper-right
176     :shift-lock :caps-lock
177     :alt-left :alt-right))))))
178 rstrandh 1.85 finally (progn (when (recordingp *application-frame*)
179     (push gesture (recorded-keys *application-frame*)))
180     (return gesture))))
181    
182     (defun climacs-unread-gesture (gesture stream)
183     (cond ((recordingp *application-frame*)
184 rstrandh 1.88 (pop (recorded-keys *application-frame*))
185     (unread-gesture gesture :stream stream))
186 rstrandh 1.85 ((executingp *application-frame*)
187 rstrandh 1.88 (push gesture (remaining-keys *application-frame*)))
188     (t
189     (unread-gesture gesture :stream stream))))
190 rstrandh 1.47
191 rstrandh 1.36 (defun read-numeric-argument (&key (stream *standard-input*))
192 rstrandh 1.47 (let ((gesture (climacs-read-gesture)))
193 rstrandh 1.62 (cond ((event-matches-gesture-name-p gesture '(:keyboard #\u 512)) ; FIXME
194 rstrandh 1.36 (let ((numarg 4))
195 rstrandh 1.47 (loop for gesture = (climacs-read-gesture)
196 rstrandh 1.62 while (event-matches-gesture-name-p gesture '(:keyboard #\u 512)) ; FIXME
197 rstrandh 1.36 do (setf numarg (* 4 numarg))
198 rstrandh 1.85 finally (climacs-unread-gesture gesture stream))
199 rstrandh 1.47 (let ((gesture (climacs-read-gesture)))
200 rstrandh 1.36 (cond ((and (characterp gesture)
201     (digit-char-p gesture 10))
202     (setf numarg (- (char-code gesture) (char-code #\0)))
203 rstrandh 1.47 (loop for gesture = (climacs-read-gesture)
204 rstrandh 1.36 while (and (characterp gesture)
205     (digit-char-p gesture 10))
206 rstrandh 1.62 do (setf numarg (+ (* 10 numarg)
207     (- (char-code gesture) (char-code #\0))))
208 rstrandh 1.85 finally (climacs-unread-gesture gesture stream)
209 rstrandh 1.36 (return (values numarg t))))
210     (t
211 rstrandh 1.85 (climacs-unread-gesture gesture stream)
212 rstrandh 1.36 (values numarg t))))))
213     ((meta-digit gesture)
214     (let ((numarg (meta-digit gesture)))
215 rstrandh 1.47 (loop for gesture = (climacs-read-gesture)
216 rstrandh 1.36 while (meta-digit gesture)
217     do (setf numarg (+ (* 10 numarg) (meta-digit gesture)))
218 rstrandh 1.85 finally (climacs-unread-gesture gesture stream)
219 rstrandh 1.36 (return (values numarg t)))))
220 rstrandh 1.85 (t (climacs-unread-gesture gesture stream)
221 rstrandh 1.36 (values 1 nil)))))
222    
223 rstrandh 1.77 ;;; we know the vbox pane has a scroller pane and an info
224     ;;; pane in it. The scroller pane has a viewport in it,
225     ;;; and the viewport contains the climacs-pane as its only child.
226     (defun find-climacs-pane (vbox)
227     (first (sheet-children
228     (find-if-not (lambda (pane) (typep pane 'scroll-bar-pane))
229     (sheet-children
230     (find-if (lambda (pane) (typep pane 'scroller-pane))
231     (sheet-children vbox)))))))
232    
233 ejohnson 1.27 (defun climacs-top-level (frame &key
234     command-parser command-unparser
235     partial-command-parser prompt)
236     (declare (ignore command-parser command-unparser partial-command-parser prompt))
237 rstrandh 1.83 (with-slots (windows) frame
238     (setf windows (list (find-climacs-pane (find-pane-named frame 'win))))
239     (push (buffer (car windows)) (buffers frame))
240     (let ((*standard-output* (car windows))
241 rstrandh 1.77 (*standard-input* (find-pane-named frame 'int))
242     (*print-pretty* nil)
243     (*abort-gestures* nil))
244     (redisplay-frame-panes frame :force-p t)
245     (loop (catch 'outer-loop
246     (loop for gestures = '()
247     for numarg = (read-numeric-argument :stream *standard-input*)
248     do (loop (setf *current-gesture* (climacs-read-gesture))
249     (setf gestures (nconc gestures (list *current-gesture*)))
250     (let ((item (find-gestures gestures 'global-climacs-table)))
251     (cond ((not item)
252     (beep) (return))
253     ((eq (command-menu-item-type item) :command)
254     (let ((command (command-menu-item-value item)))
255     (unless (consp command)
256     (setf command (list command)))
257     (setf command (substitute-numeric-argument-marker command numarg))
258     (handler-case
259     (execute-frame-command frame command)
260     (error (condition)
261     (beep)
262     (format *error-output* "~a~%" condition)))
263     (setf (previous-command *standard-output*)
264     (if (consp command)
265     (car command)
266     command))
267     (return)))
268     (t nil))))
269 rstrandh 1.83 (let ((buffer (buffer (current-window))))
270 rstrandh 1.77 (when (modified-p buffer)
271     (setf (needs-saving buffer) t)))
272 rstrandh 1.85 (when (null (remaining-keys *application-frame*))
273     (setf (executingp *application-frame*) nil)
274     (redisplay-frame-panes frame))))
275 rstrandh 1.77 (beep)
276 rstrandh 1.83 (let ((buffer (buffer (current-window))))
277 rstrandh 1.77 (when (modified-p buffer)
278     (setf (needs-saving buffer) t)))
279 rstrandh 1.85 (when (null (remaining-keys *application-frame*))
280     (setf (executingp *application-frame*) nil)
281     (redisplay-frame-panes frame))))))
282 ejohnson 1.27
283 mvilleneuve 1.64 (defun region-limits (pane)
284 rstrandh 1.70 (if (mark< (mark pane) (point pane))
285     (values (mark pane) (point pane))
286     (values (point pane) (mark pane))))
287 mvilleneuve 1.64
288 abridgewater 1.34 (defmacro define-named-command (command-name args &body body)
289 rstrandh 1.62 `(define-climacs-command ,(if (listp command-name)
290     `(,@command-name :name t)
291     `(,command-name :name t)) ,args ,@body))
292 abridgewater 1.34
293 abakic 1.58 (define-named-command com-toggle-overwrite-mode ()
294 abakic 1.87 (with-slots (overwrite-mode) (current-window)
295     (setf overwrite-mode (not overwrite-mode))))
296 abakic 1.58
297 mvilleneuve 1.89 (defun possibly-fill-line ()
298 mvilleneuve 1.86 (let* ((pane (current-window))
299     (buffer (buffer pane)))
300 mvilleneuve 1.92 (when (auto-fill-mode pane)
301 mvilleneuve 1.95 (let* ((fill-column (auto-fill-column pane))
302 mvilleneuve 1.86 (point (point pane))
303     (offset (offset point))
304     (tab-width (tab-space-count (stream-default-view pane)))
305     (syntax (syntax buffer)))
306     (when (>= (buffer-display-column buffer offset tab-width)
307 mvilleneuve 1.95 (1- fill-column))
308 mvilleneuve 1.86 (fill-line point
309     (lambda (mark)
310     (syntax-line-indentation mark tab-width syntax))
311     fill-column
312 mvilleneuve 1.89 tab-width))))))
313    
314     (defun insert-character (char)
315     (let* ((win (current-window))
316     (point (point win)))
317     (unless (constituentp char)
318     (possibly-expand-abbrev point))
319     (when (whitespacep char)
320     (possibly-fill-line))
321     (if (and (slot-value win 'overwrite-mode) (not (end-of-line-p point)))
322     (progn
323     (delete-range point)
324     (insert-object point char))
325     (insert-object point char))))
326    
327     (define-command com-self-insert ()
328 mvilleneuve 1.86 (insert-character *current-gesture*))
329 ejohnson 1.27
330 abridgewater 1.34 (define-named-command com-beginning-of-line ()
331 rstrandh 1.80 (beginning-of-line (point (current-window))))
332 ejohnson 1.27
333 abridgewater 1.34 (define-named-command com-end-of-line ()
334 rstrandh 1.80 (end-of-line (point (current-window))))
335 ejohnson 1.27
336 rstrandh 1.62 (define-named-command com-delete-object ((count 'integer :prompt "Number of Objects"))
337 rstrandh 1.80 (delete-range (point (current-window)) count))
338 ejohnson 1.27
339 rstrandh 1.62 (define-named-command com-backward-delete-object ((count 'integer :prompt "Number of Objects"))
340 rstrandh 1.80 (delete-range (point (current-window)) (- count)))
341 ejohnson 1.27
342 rstrandh 1.42 (define-named-command com-transpose-objects ()
343 rstrandh 1.80 (let* ((point (point (current-window))))
344 rstrandh 1.42 (unless (beginning-of-buffer-p point)
345     (when (end-of-line-p point)
346 rstrandh 1.43 (backward-object point))
347     (let ((object (object-after point)))
348     (delete-range point)
349     (backward-object point)
350     (insert-object point object)
351     (forward-object point)))))
352    
353 rstrandh 1.62 (define-named-command com-backward-object ((count 'integer :prompt "Number of Objects"))
354 rstrandh 1.80 (backward-object (point (current-window)) count))
355 rstrandh 1.43
356 rstrandh 1.62 (define-named-command com-forward-object ((count 'integer :prompt "Number of Objects"))
357 rstrandh 1.80 (forward-object (point (current-window)) count))
358 rstrandh 1.43
359     (define-named-command com-transpose-words ()
360 rstrandh 1.80 (let* ((point (point (current-window))))
361 rstrandh 1.43 (let (bw1 bw2 ew1 ew2)
362     (backward-word point)
363     (setf bw1 (offset point))
364     (forward-word point)
365     (setf ew1 (offset point))
366     (forward-word point)
367     (when (= (offset point) ew1)
368     ;; this is emacs' message in the minibuffer
369     (error "Don't have two things to transpose"))
370     (setf ew2 (offset point))
371     (backward-word point)
372     (setf bw2 (offset point))
373     (let ((w2 (buffer-sequence (buffer point) bw2 ew2))
374     (w1 (buffer-sequence (buffer point) bw1 ew1)))
375     (delete-word point)
376     (insert-sequence point w1)
377     (backward-word point)
378     (backward-word point)
379     (delete-word point)
380     (insert-sequence point w2)
381     (forward-word point)))))
382 rstrandh 1.42
383 rstrandh 1.45 (define-named-command com-transpose-lines ()
384 rstrandh 1.80 (let ((point (point (current-window))))
385 rstrandh 1.45 (beginning-of-line point)
386     (unless (beginning-of-buffer-p point)
387     (previous-line point))
388     (let* ((bol (offset point))
389     (eol (progn (end-of-line point)
390     (offset point)))
391     (line (buffer-sequence (buffer point) bol eol)))
392     (delete-region bol point)
393     ;; Remove newline at end of line as well.
394     (unless (end-of-buffer-p point)
395     (delete-range point))
396     ;; If the current line is at the end of the buffer, we want to
397     ;; be able to insert past it, so we need to get an extra line
398     ;; at the end.
399 abakic 1.82 (end-of-line point)
400     (when (end-of-buffer-p point)
401 rstrandh 1.45 (insert-object point #\Newline))
402 abakic 1.82 (next-line point 0)
403 rstrandh 1.45 (insert-sequence point line)
404     (insert-object point #\Newline))))
405    
406 abridgewater 1.34 (define-named-command com-previous-line ()
407 rstrandh 1.80 (let* ((win (current-window))
408 rstrandh 1.49 (point (point win)))
409     (unless (or (eq (previous-command win) 'com-previous-line)
410     (eq (previous-command win) 'com-next-line))
411     (setf (slot-value win 'goal-column) (column-number point)))
412     (previous-line point (slot-value win 'goal-column))))
413 ejohnson 1.27
414 abridgewater 1.34 (define-named-command com-next-line ()
415 rstrandh 1.80 (let* ((win (current-window))
416 rstrandh 1.49 (point (point win)))
417     (unless (or (eq (previous-command win) 'com-previous-line)
418     (eq (previous-command win) 'com-next-line))
419     (setf (slot-value win 'goal-column) (column-number point)))
420     (next-line point (slot-value win 'goal-column))))
421 ejohnson 1.27
422 abridgewater 1.34 (define-named-command com-open-line ()
423 rstrandh 1.80 (open-line (point (current-window))))
424 ejohnson 1.27
425 abridgewater 1.34 (define-named-command com-kill-line ()
426 rstrandh 1.80 (let* ((pane (current-window))
427 ejohnson 1.54 (point (point pane))
428     (mark (offset point)))
429 ejohnson 1.56 (cond ((end-of-buffer-p point) nil)
430     ((end-of-line-p point)(forward-object point))
431     (t
432     (end-of-line point)
433     (cond ((beginning-of-buffer-p point) nil)
434     ((beginning-of-line-p point)(forward-object point)))))
435 ejohnson 1.54 (if (eq (previous-command pane) 'com-kill-line)
436 ejohnson 1.51 (kill-ring-concatenating-push *kill-ring*
437 ejohnson 1.54 (region-to-sequence mark point))
438 ejohnson 1.51 (kill-ring-standard-push *kill-ring*
439 ejohnson 1.54 (region-to-sequence mark point)))
440     (delete-region mark point)))
441 ejohnson 1.27
442 abridgewater 1.34 (define-named-command com-forward-word ()
443 rstrandh 1.80 (forward-word (point (current-window))))
444 ejohnson 1.27
445 abridgewater 1.34 (define-named-command com-backward-word ()
446 rstrandh 1.80 (backward-word (point (current-window))))
447 ejohnson 1.27
448 abridgewater 1.34 (define-named-command com-delete-word ()
449 rstrandh 1.80 (delete-word (point (current-window))))
450 rstrandh 1.32
451 abridgewater 1.34 (define-named-command com-backward-delete-word ()
452 rstrandh 1.80 (backward-delete-word (point (current-window))))
453 rstrandh 1.32
454 mvilleneuve 1.64 (define-named-command com-upcase-region ()
455 rstrandh 1.80 (multiple-value-bind (start end) (region-limits (current-window))
456 mvilleneuve 1.64 (upcase-region start end)))
457    
458     (define-named-command com-downcase-region ()
459 rstrandh 1.80 (multiple-value-bind (start end) (region-limits (current-window))
460 mvilleneuve 1.64 (downcase-region start end)))
461    
462     (define-named-command com-capitalize-region ()
463 rstrandh 1.80 (multiple-value-bind (start end) (region-limits (current-window))
464 mvilleneuve 1.64 (capitalize-region start end)))
465    
466 rstrandh 1.60 (define-named-command com-upcase-word ()
467 rstrandh 1.80 (upcase-word (point (current-window))))
468 rstrandh 1.60
469     (define-named-command com-downcase-word ()
470 rstrandh 1.80 (downcase-word (point (current-window))))
471 rstrandh 1.60
472     (define-named-command com-capitalize-word ()
473 rstrandh 1.80 (capitalize-word (point (current-window))))
474 rstrandh 1.60
475 mvilleneuve 1.69 (define-named-command com-tabify-region ()
476 rstrandh 1.80 (let ((pane (current-window)))
477 mvilleneuve 1.69 (multiple-value-bind (start end) (region-limits pane)
478 rstrandh 1.70 (tabify-region start end (tab-space-count (stream-default-view pane))))))
479 mvilleneuve 1.69
480     (define-named-command com-untabify-region ()
481 rstrandh 1.80 (let ((pane (current-window)))
482 mvilleneuve 1.69 (multiple-value-bind (start end) (region-limits pane)
483 rstrandh 1.70 (untabify-region start end (tab-space-count (stream-default-view pane))))))
484 mvilleneuve 1.69
485 mvilleneuve 1.79 (defun indent-current-line (pane point)
486     (let* ((buffer (buffer pane))
487     (view (stream-default-view pane))
488     (tab-space-count (tab-space-count view))
489     (indentation (syntax-line-indentation point
490     tab-space-count
491     (syntax buffer))))
492     (indent-line point indentation (and (indent-tabs-mode buffer)
493     tab-space-count))))
494    
495     (define-named-command com-indent-line ()
496 rstrandh 1.80 (let* ((pane (current-window))
497 mvilleneuve 1.79 (point (point pane)))
498     (indent-current-line pane point)))
499    
500     (define-named-command com-newline-and-indent ()
501 rstrandh 1.80 (let* ((pane (current-window))
502 mvilleneuve 1.79 (point (point pane)))
503     (insert-object point #\Newline)
504     (indent-current-line pane point)))
505    
506 mvilleneuve 1.72 (define-named-command com-delete-indentation ()
507 rstrandh 1.80 (delete-indentation (point (current-window))))
508 ejohnson 1.27
509 mvilleneuve 1.86 (define-named-command com-auto-fill-mode ()
510 mvilleneuve 1.92 (let ((pane (current-window)))
511     (setf (auto-fill-mode pane) (not (auto-fill-mode pane)))))
512 mvilleneuve 1.86
513 mvilleneuve 1.90 (define-named-command com-fill-paragraph ()
514     (let* ((pane (current-window))
515     (buffer (buffer pane))
516     (syntax (syntax buffer))
517     (point (point pane))
518     (begin-mark (clone-mark point))
519     (end-mark (clone-mark point)))
520     (unless (eql (object-before begin-mark) #\Newline)
521     (beginning-of-paragraph begin-mark syntax))
522     (unless (eql (object-after end-mark) #\Newline)
523     (end-of-paragraph end-mark syntax))
524     (do-buffer-region (object offset buffer
525     (offset begin-mark) (offset end-mark))
526     (when (eql object #\Newline)
527     (setf object #\Space)))
528     (let ((point-backup (clone-mark point)))
529     (setf (offset point) (offset end-mark))
530     (possibly-fill-line)
531     (setf (offset point) (offset point-backup)))))
532    
533 ejohnson 1.27 (define-command com-extended-command ()
534     (let ((item (accept 'command :prompt "Extended Command")))
535     (execute-frame-command *application-frame* item)))
536    
537 rstrandh 1.41 (eval-when (:compile-toplevel :load-toplevel)
538 ejohnson 1.35 (define-presentation-type completable-pathname ()
539     :inherit-from 'pathname))
540 ejohnson 1.27
541     (defun filename-completer (so-far mode)
542     (flet ((remove-trail (s)
543     (subseq s 0 (let ((pos (position #\/ s :from-end t)))
544     (if pos (1+ pos) 0)))))
545     (let* ((directory-prefix
546     (if (and (plusp (length so-far)) (eql (aref so-far 0) #\/))
547     ""
548 rstrandh 1.78 (namestring #+sbcl *default-pathname-defaults*
549     #+cmu (ext:default-directory)
550     #-(or sbcl cmu) *default-pathname-defaults*)))
551 ejohnson 1.27 (full-so-far (concatenate 'string directory-prefix so-far))
552     (pathnames
553     (loop with length = (length full-so-far)
554     for path in (directory (concatenate 'string
555     (remove-trail so-far)
556     "*.*"))
557     when (let ((mismatch (mismatch (namestring path) full-so-far)))
558     (or (null mismatch) (= mismatch length)))
559     collect path))
560     (strings (mapcar #'namestring pathnames))
561     (first-string (car strings))
562     (length-common-prefix nil)
563     (completed-string nil)
564     (full-completed-string nil))
565     (unless (null pathnames)
566     (setf length-common-prefix
567     (loop with length = (length first-string)
568     for string in (cdr strings)
569     do (setf length (min length (or (mismatch string first-string) length)))
570     finally (return length))))
571     (unless (null pathnames)
572     (setf completed-string
573     (subseq first-string (length directory-prefix)
574     (if (null (cdr pathnames)) nil length-common-prefix)))
575     (setf full-completed-string
576     (concatenate 'string directory-prefix completed-string)))
577     (case mode
578     ((:complete-limited :complete-maximal)
579     (cond ((null pathnames)
580     (values so-far nil nil 0 nil))
581     ((null (cdr pathnames))
582     (values completed-string t (car pathnames) 1 nil))
583     (t
584     (values completed-string nil nil (length pathnames) nil))))
585     (:complete
586     (cond ((null pathnames)
587     (values so-far t so-far 1 nil))
588     ((null (cdr pathnames))
589     (values completed-string t (car pathnames) 1 nil))
590     ((find full-completed-string strings :test #'string-equal)
591     (let ((pos (position full-completed-string strings :test #'string-equal)))
592     (values completed-string
593     t (elt pathnames pos) (length pathnames) nil)))
594     (t
595     (values completed-string nil nil (length pathnames) nil))))
596     (:possibilities
597     (values nil nil nil (length pathnames)
598     (loop with length = (length directory-prefix)
599     for name in pathnames
600     collect (list (subseq (namestring name) length nil)
601     name))))))))
602    
603     (define-presentation-method accept
604     ((type completable-pathname) stream (view textual-view) &key)
605     (multiple-value-bind (pathname success string)
606     (complete-input stream
607     #'filename-completer
608     :partial-completers '(#\Space)
609     :allow-any-input t)
610     (declare (ignore success))
611     (or pathname string)))
612    
613     (defun pathname-filename (pathname)
614     (if (null (pathname-type pathname))
615     (pathname-name pathname)
616     (concatenate 'string (pathname-name pathname)
617     "." (pathname-type pathname))))
618    
619 abridgewater 1.34 (define-named-command com-find-file ()
620 ejohnson 1.27 (let ((filename (accept 'completable-pathname
621 rstrandh 1.70 :prompt "Find File"))
622     (buffer (make-instance 'climacs-buffer))
623 rstrandh 1.80 (pane (current-window)))
624 rstrandh 1.75 (push buffer (buffers *application-frame*))
625 rstrandh 1.80 (setf (buffer (current-window)) buffer)
626 rstrandh 1.70 (setf (syntax buffer) (make-instance 'basic-syntax))
627 rstrandh 1.84 ;; Don't want to create the file if it doesn't exist.
628     (when (probe-file filename)
629     (with-open-file (stream filename :direction :input)
630     (input-from-stream stream buffer 0)))
631 rstrandh 1.70 (setf (filename buffer) filename
632     (name buffer) (pathname-filename filename)
633     (needs-saving buffer) nil)
634     (beginning-of-buffer (point pane))
635     ;; this one is needed so that the buffer modification protocol
636     ;; resets the low and high marks after redisplay
637     (redisplay-frame-panes *application-frame*)))
638 ejohnson 1.27
639 rstrandh 1.93 (defun save-buffer (buffer)
640     (let ((filename (or (filename buffer)
641     (accept 'completable-pathname
642     :prompt "Save Buffer to File"))))
643     (with-open-file (stream filename :direction :output :if-exists :supersede)
644     (output-to-stream stream buffer 0 (size buffer)))
645     (setf (filename buffer) filename
646     (name buffer) (pathname-filename filename))
647     (display-message "Wrote: ~a" (filename buffer))
648     (setf (needs-saving buffer) nil)))
649    
650 abridgewater 1.34 (define-named-command com-save-buffer ()
651 rstrandh 1.93 (let ((buffer (buffer (current-window))))
652 rstrandh 1.30 (if (or (null (filename buffer))
653     (needs-saving buffer))
654 rstrandh 1.93 (save-buffer buffer)
655     (display-message "No changes need to be saved from ~a" (name buffer)))))
656    
657     (define-named-command (com-quit) ()
658     (loop for buffer in (buffers *application-frame*)
659     when (and (needs-saving buffer)
660     (accept 'boolean
661     :prompt (format nil "Save buffer: ~a ?" (name buffer))))
662     do (save-buffer buffer))
663     (when (or (notany #'needs-saving
664     (buffers *application-frame*))
665     (accept 'boolean :prompt "Modified buffers exist. Quit anyway?"))
666     (frame-exit *application-frame*)))
667 ejohnson 1.27
668 abridgewater 1.34 (define-named-command com-write-buffer ()
669 ejohnson 1.27 (let ((filename (accept 'completable-pathname
670     :prompt "Write Buffer to File"))
671 rstrandh 1.80 (buffer (buffer (current-window))))
672 ejohnson 1.27 (with-open-file (stream filename :direction :output :if-exists :supersede)
673     (output-to-stream stream buffer 0 (size buffer)))
674     (setf (filename buffer) filename
675 rstrandh 1.28 (name buffer) (pathname-filename filename)
676 rstrandh 1.30 (needs-saving buffer) nil)
677     (display-message "Wrote: ~a" (filename buffer))))
678 ejohnson 1.27
679 rstrandh 1.75 (define-presentation-method accept
680     ((type buffer) stream (view textual-view) &key)
681     (multiple-value-bind (object success string)
682     (complete-input stream
683     (lambda (so-far action)
684     (complete-from-possibilities
685     so-far (buffers *application-frame*) '() :action action
686     :name-key #'name
687     :value-key #'identity))
688     :partial-completers '(#\Space)
689     :allow-any-input t)
690 rstrandh 1.76 (declare (ignore success))
691     (or object
692     (car (push (make-instance 'climacs-buffer :name string)
693     (buffers *application-frame*))))))
694 rstrandh 1.75
695     (define-named-command com-switch-to-buffer ()
696     (let ((buffer (accept 'buffer
697     :prompt "Switch to buffer")))
698 rstrandh 1.80 (setf (buffer (current-window)) buffer)
699 rstrandh 1.75 (setf (syntax buffer) (make-instance 'basic-syntax))
700 rstrandh 1.80 (beginning-of-buffer (point (current-window)))
701     (full-redisplay (current-window))))
702 rstrandh 1.75
703 rstrandh 1.91 (define-named-command com-kill-buffer ()
704     (with-slots (buffers) *application-frame*
705     (let ((buffer (buffer (current-window))))
706     (when (and (needs-saving buffer)
707     (accept 'boolean :prompt "Save buffer first?"))
708     (com-save-buffer))
709     (setf buffers (remove buffer buffers))
710     ;; Always need one buffer.
711     (when (null buffers)
712     (push (make-instance 'climacs-buffer :name "*scratch*")
713     buffers))
714     (setf (buffer (current-window)) (car buffers)))))
715    
716 rstrandh 1.75 (define-named-command com-full-redisplay ()
717 rstrandh 1.80 (full-redisplay (current-window)))
718 rstrandh 1.75
719 rstrandh 1.63 (define-named-command com-load-file ()
720     (let ((filename (accept 'completable-pathname
721     :prompt "Load File")))
722     (load filename)))
723    
724 abridgewater 1.34 (define-named-command com-beginning-of-buffer ()
725 rstrandh 1.80 (beginning-of-buffer (point (current-window))))
726 ejohnson 1.27
727 rstrandh 1.39 (define-named-command com-page-down ()
728 rstrandh 1.80 (let ((pane (current-window)))
729 rstrandh 1.70 (page-down pane)))
730 rstrandh 1.39
731 rstrandh 1.40 (define-named-command com-page-up ()
732 rstrandh 1.80 (let ((pane (current-window)))
733 rstrandh 1.70 (page-up pane)))
734 rstrandh 1.40
735 abridgewater 1.34 (define-named-command com-end-of-buffer ()
736 rstrandh 1.80 (end-of-buffer (point (current-window))))
737 ejohnson 1.27
738 abridgewater 1.34 (define-named-command com-back-to-indentation ()
739 rstrandh 1.80 (let ((point (point (current-window))))
740 rstrandh 1.32 (beginning-of-line point)
741     (loop until (end-of-line-p point)
742     while (whitespacep (object-after point))
743     do (incf (offset point)))))
744    
745 abridgewater 1.34 (define-named-command com-goto-position ()
746 rstrandh 1.80 (setf (offset (point (current-window)))
747 rstrandh 1.32 (accept 'integer :prompt "Goto Position")))
748    
749 abridgewater 1.34 (define-named-command com-goto-line ()
750 abakic 1.99 (loop with mark = (make-instance 'standard-right-sticky-mark ;PB
751 rstrandh 1.80 :buffer (buffer (current-window)))
752 rstrandh 1.32 do (end-of-line mark)
753     until (end-of-buffer-p mark)
754     repeat (accept 'integer :prompt "Goto Line")
755     do (incf (offset mark))
756     (end-of-line mark)
757     finally (beginning-of-line mark)
758 rstrandh 1.80 (setf (offset (point (current-window)))
759 rstrandh 1.32 (offset mark))))
760    
761 abridgewater 1.34 (define-named-command com-browse-url ()
762 ejohnson 1.27 (accept 'url :prompt "Browse URL"))
763    
764 abridgewater 1.34 (define-named-command com-set-mark ()
765 rstrandh 1.80 (let ((pane (current-window)))
766 rstrandh 1.70 (setf (mark pane) (clone-mark (point pane)))))
767 rstrandh 1.45
768     (define-named-command com-exchange-point-and-mark ()
769 rstrandh 1.80 (let ((pane (current-window)))
770 rstrandh 1.70 (psetf (offset (mark pane)) (offset (point pane))
771     (offset (point pane)) (offset (mark pane)))))
772 rstrandh 1.38
773     (define-named-command com-set-syntax ()
774 rstrandh 1.80 (let* ((pane (current-window))
775 rstrandh 1.67 (buffer (buffer pane)))
776 rstrandh 1.70 (setf (syntax buffer)
777     (make-instance (accept 'syntax :prompt "Set Syntax")))
778 rstrandh 1.67 (setf (offset (low-mark buffer)) 0
779     (offset (high-mark buffer)) (size buffer))))
780 ejohnson 1.27
781 rstrandh 1.77 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
782     ;;;
783 rstrandh 1.85 ;;; Keyboard macros
784    
785     (define-named-command com-start-kbd-macro ()
786     (setf (recordingp *application-frame*) t)
787     (setf (recorded-keys *application-frame*) '()))
788    
789     (define-named-command com-end-kbd-macro ()
790     (setf (recordingp *application-frame*) nil)
791     (setf (recorded-keys *application-frame*)
792     ;; this won't work if the command was invoked in any old way
793     (reverse (cddr (recorded-keys *application-frame*)))))
794    
795     (define-named-command com-call-last-kbd-macro ()
796     (setf (remaining-keys *application-frame*)
797     (recorded-keys *application-frame*))
798     (setf (executingp *application-frame*) t))
799    
800     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
801     ;;;
802 rstrandh 1.77 ;;; Commands for splitting windows
803    
804 rstrandh 1.91 ;;; put this in for real when we find a solution for the problem
805     ;;; it causes for com-delete-window
806     ;; (defun replace-constellation (constellation additional-constellation vertical-p)
807     ;; (let* ((parent (sheet-parent constellation))
808     ;; (children (sheet-children parent))
809     ;; (first (first children))
810     ;; (second (second children))
811     ;; (adjust (make-pane 'clim-extensions:box-adjuster-gadget)))
812     ;; (assert (member constellation children))
813     ;; (cond ((eq constellation first)
814     ;; (sheet-disown-child parent constellation)
815     ;; (let ((new (if vertical-p
816     ;; (vertically ()
817     ;; constellation adjust additional-constellation)
818     ;; (horizontally ()
819     ;; constellation adjust additional-constellation))))
820     ;; (sheet-adopt-child parent new)
821     ;; (reorder-sheets parent (list new second))))
822     ;; (t
823     ;; (sheet-disown-child parent constellation)
824     ;; (let ((new (if vertical-p
825     ;; (vertically ()
826     ;; constellation adjust additional-constellation)
827     ;; (horizontally ()
828     ;; constellation adjust additional-constellation))))
829     ;; (sheet-adopt-child parent new)
830     ;; (reorder-sheets parent (list first new)))))))
831    
832 rstrandh 1.83 (defun replace-constellation (constellation additional-constellation vertical-p)
833     (let* ((parent (sheet-parent constellation))
834     (children (sheet-children parent))
835     (first (first children))
836     (second (second children)))
837     (assert (member constellation children))
838     (cond ((eq constellation first)
839     (sheet-disown-child parent constellation)
840     (let ((new (if vertical-p
841     (vertically () constellation additional-constellation)
842     (horizontally () constellation additional-constellation))))
843     (sheet-adopt-child parent new)
844     (reorder-sheets parent (list new second))))
845     (t
846     (sheet-disown-child parent constellation)
847     (let ((new (if vertical-p
848     (vertically () constellation additional-constellation)
849     (horizontally () constellation additional-constellation))))
850     (sheet-adopt-child parent new)
851     (reorder-sheets parent (list first new)))))))
852    
853     (defun parent3 (sheet)
854     (sheet-parent (sheet-parent (sheet-parent sheet))))
855    
856     (defun make-pane-constellation ()
857     "make a vbox containing a scroller pane as its first child and an
858     info pane as its second child. The scroller pane contains a viewport
859     which contains an extended pane. Return the vbox and the extended pane
860     as two values"
861     (let* ((extended-pane
862     (make-pane 'extended-pane
863     :width 900 :height 400
864     :name 'win
865     :incremental-redisplay t
866     :display-function 'display-win))
867     (vbox
868     (vertically ()
869     (scrolling () extended-pane)
870     (make-pane 'info-pane
871     :climacs-pane extended-pane
872     :width 900 :height 20
873     :max-height 20 :min-height 20
874     ::background +gray85+
875     :scroll-bars nil
876     :borders nil
877     :incremental-redisplay t
878     :display-function 'display-info))))
879     (values vbox extended-pane)))
880    
881 rstrandh 1.77 (define-named-command com-split-window-vertically ()
882     (with-look-and-feel-realization
883     ((frame-manager *application-frame*) *application-frame*)
884 rstrandh 1.83 (multiple-value-bind (vbox new-pane) (make-pane-constellation)
885     (let* ((current-window (current-window))
886     (constellation-root (parent3 current-window)))
887 mvilleneuve 1.95 (setf (buffer new-pane) (buffer current-window)
888     (auto-fill-mode new-pane) (auto-fill-mode current-window)
889     (auto-fill-column new-pane) (auto-fill-column current-window))
890 rstrandh 1.83 (push new-pane (windows *application-frame*))
891     (replace-constellation constellation-root vbox t)
892     (full-redisplay current-window)
893     (full-redisplay new-pane)))))
894    
895     (define-named-command com-split-window-horizontally ()
896     (with-look-and-feel-realization
897     ((frame-manager *application-frame*) *application-frame*)
898     (multiple-value-bind (vbox new-pane) (make-pane-constellation)
899     (let* ((current-window (current-window))
900     (constellation-root (parent3 current-window)))
901 mvilleneuve 1.95 (setf (buffer new-pane) (buffer current-window)
902     (auto-fill-mode new-pane) (auto-fill-mode current-window)
903     (auto-fill-column new-pane) (auto-fill-column current-window))
904 rstrandh 1.83 (push new-pane (windows *application-frame*))
905     (replace-constellation constellation-root vbox nil)
906     (full-redisplay current-window)
907     (full-redisplay new-pane)))))
908    
909     (define-named-command com-other-window ()
910     (setf (windows *application-frame*)
911     (append (cdr (windows *application-frame*))
912     (list (car (windows *application-frame*))))))
913    
914     (define-named-command com-delete-window ()
915     (unless (null (cdr (windows *application-frame*)))
916     (let* ((constellation (parent3 (current-window)))
917     (box (sheet-parent constellation))
918     (box-children (sheet-children box))
919     (other (if (eq constellation (first box-children))
920     (second box-children)
921     (first box-children)))
922     (parent (sheet-parent box))
923     (children (sheet-children parent))
924     (first (first children))
925     (second (second children)))
926     (pop (windows *application-frame*))
927     (sheet-disown-child box other)
928     (cond ((eq box first)
929     (sheet-disown-child parent box)
930     (sheet-adopt-child parent other)
931     (reorder-sheets parent (list other second)))
932     (t
933     (sheet-disown-child parent box)
934     (sheet-adopt-child parent other)
935     (reorder-sheets parent (list first other)))))))
936 rstrandh 1.77
937 rstrandh 1.94 ;; (define-named-command com-delete-window ()
938     ;; (unless (null (cdr (windows *application-frame*)))
939     ;; (let* ((constellation (parent3 (current-window)))
940     ;; (box (sheet-parent constellation))
941     ;; (box-children (sheet-children box))
942     ;; (other (if (eq constellation (first box-children))
943     ;; (third box-children)
944     ;; (first box-children)))
945     ;; (parent (sheet-parent box))
946     ;; (children (sheet-children parent))
947     ;; (first (first children))
948     ;; (second (second children))
949     ;; (third (third children)))
950     ;; (pop (windows *application-frame*))
951     ;; (sheet-disown-child box other)
952     ;; (cond ((eq box first)
953     ;; (sheet-disown-child parent box)
954     ;; (sheet-adopt-child parent other)
955     ;; (reorder-sheets parent (list other second third)))
956     ;; (t
957     ;; (sheet-disown-child parent box)
958     ;; (sheet-adopt-child parent other)
959     ;; (reorder-sheets parent (list first second other)))))))
960    
961 ejohnson 1.27 ;;;;;;;;;;;;;;;;;;;;
962     ;; Kill ring commands
963    
964 ejohnson 1.31 ;; Copies an element from a kill-ring to a buffer at the given offset
965 ejohnson 1.50 (define-named-command com-yank ()
966 rstrandh 1.80 (insert-sequence (point (current-window)) (kill-ring-yank *kill-ring*)))
967 ejohnson 1.27
968 ejohnson 1.31 ;; Destructively cut a given buffer region into the kill-ring
969 abridgewater 1.34 (define-named-command com-cut-out ()
970 rstrandh 1.80 (multiple-value-bind (start end) (region-limits (current-window))
971 mvilleneuve 1.64 (kill-ring-standard-push *kill-ring* (region-to-sequence start end))
972     (delete-region (offset start) end)))
973 ejohnson 1.27
974 ejohnson 1.31 ;; Non destructively copies in buffer region to the kill ring
975 abridgewater 1.34 (define-named-command com-copy-out ()
976 rstrandh 1.80 (let ((pane (current-window)))
977 rstrandh 1.70 (kill-ring-standard-push *kill-ring* (region-to-sequence (point pane) (mark pane)))))
978 ejohnson 1.27
979 ejohnson 1.50 (define-named-command com-rotate-yank ()
980 rstrandh 1.80 (let* ((pane (current-window))
981 ejohnson 1.54 (point (point pane))
982 ejohnson 1.50 (last-yank (kill-ring-yank *kill-ring*)))
983 ejohnson 1.54 (if (eq (previous-command pane)
984 ejohnson 1.50 'com-rotate-yank)
985 ejohnson 1.54 (progn
986     (delete-range point (* -1 (length last-yank)))
987     (rotate-yank-position *kill-ring*)))
988     (insert-sequence point (kill-ring-yank *kill-ring*))))
989 ejohnson 1.27
990 ejohnson 1.50 (define-named-command com-resize-kill-ring ()
991 ejohnson 1.46 (let ((size (accept 'integer :prompt "New kill ring size")))
992 ejohnson 1.50 (setf (kill-ring-max-size *kill-ring*) size)))
993 rstrandh 1.47
994 mvilleneuve 1.96 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
995     ;;;
996     ;;; Incremental search
997    
998 mvilleneuve 1.97 (defun isearch-command-loop (pane forwardp)
999     (let ((point (point pane)))
1000 mvilleneuve 1.96 (unless (endp (isearch-states pane))
1001     (setf (isearch-previous-string pane)
1002     (search-string (first (isearch-states pane)))))
1003     (setf (isearch-mode pane) t)
1004     (setf (isearch-states pane)
1005     (list (make-instance 'isearch-state
1006     :search-string ""
1007 mvilleneuve 1.97 :search-mark (clone-mark point)
1008     :search-forward-p forwardp)))
1009 mvilleneuve 1.96 (redisplay-frame-panes *application-frame*)
1010     (loop while (isearch-mode pane)
1011     as gesture = (climacs-read-gesture)
1012     as item = (find-gestures (list gesture) 'isearch-climacs-table)
1013     do (cond ((and item (eq (command-menu-item-type item) :command))
1014     (setf *current-gesture* gesture)
1015     (let ((command (command-menu-item-value item)))
1016     (unless (consp command)
1017     (setf command (list command)))
1018     (handler-case
1019     (execute-frame-command *application-frame* command)
1020     (error (condition)
1021     (beep)
1022     (format *error-output* "~a~%" condition)))))
1023     (t
1024     (unread-gesture gesture)
1025     (setf (isearch-mode pane) nil)))
1026     (redisplay-frame-panes *application-frame*))))
1027    
1028 mvilleneuve 1.97 (defun isearch-from-mark (pane mark string forwardp)
1029     (flet ((object-equal (x y)
1030     (if (characterp x)
1031     (and (characterp y) (char-equal x y))
1032     (eql x y))))
1033     (let* ((point (point pane))
1034     (mark2 (clone-mark mark))
1035     (success (funcall (if forwardp #'search-forward #'search-backward)
1036     mark2
1037     string
1038     :test #'object-equal)))
1039     (cond (success
1040     (setf (offset point) (offset mark2)
1041     (offset mark) (if forwardp
1042     (- (offset mark2) (length string))
1043     (+ (offset mark2) (length string))))
1044     (push (make-instance 'isearch-state
1045     :search-string string
1046     :search-mark mark
1047     :search-forward-p forwardp)
1048     (isearch-states pane)))
1049     (t
1050     (beep))))))
1051    
1052     (define-named-command com-isearch-mode-forward ()
1053     (isearch-command-loop (current-window) t))
1054    
1055     (define-named-command com-isearch-mode-backward ()
1056     (isearch-command-loop (current-window) nil))
1057 mvilleneuve 1.96
1058     (define-named-command com-isearch-append-char ()
1059     (let* ((pane (current-window))
1060     (states (isearch-states pane))
1061     (string (concatenate 'string
1062     (search-string (first states))
1063     (string *current-gesture*)))
1064     (mark (clone-mark (search-mark (first states))))
1065 mvilleneuve 1.97 (forwardp (search-forward-p (first states))))
1066     (unless forwardp
1067     (incf (offset mark)))
1068     (isearch-from-mark pane mark string forwardp)))
1069 mvilleneuve 1.96
1070     (define-named-command com-isearch-delete-char ()
1071     (let* ((pane (current-window)))
1072     (cond ((null (second (isearch-states pane)))
1073     (beep))
1074     (t
1075     (pop (isearch-states pane))
1076     (let ((state (first (isearch-states pane))))
1077     (setf (offset (point pane))
1078 mvilleneuve 1.97 (if (search-forward-p state)
1079     (+ (offset (search-mark state))
1080     (length (search-string state)))
1081     (- (offset (search-mark state))
1082     (length (search-string state))))))))))
1083 mvilleneuve 1.96
1084     (define-named-command com-isearch-forward ()
1085     (let* ((pane (current-window))
1086     (point (point pane))
1087     (states (isearch-states pane))
1088     (string (if (null (second states))
1089     (isearch-previous-string pane)
1090     (search-string (first states))))
1091 mvilleneuve 1.97 (mark (clone-mark point)))
1092     (isearch-from-mark pane mark string t)))
1093    
1094     (define-named-command com-isearch-backward ()
1095     (let* ((pane (current-window))
1096     (point (point pane))
1097     (states (isearch-states pane))
1098     (string (if (null (second states))
1099     (isearch-previous-string pane)
1100     (search-string (first states))))
1101     (mark (clone-mark point)))
1102     (isearch-from-mark pane mark string nil)))
1103 mvilleneuve 1.96
1104     (define-named-command com-isearch-exit ()
1105     (setf (isearch-mode (current-window)) nil))
1106    
1107 rstrandh 1.98 (define-named-command com-undo ()
1108     (undo (undo-tree (buffer (current-window)))))
1109    
1110     (define-named-command com-redo ()
1111     (redo (undo-tree (buffer (current-window)))))
1112    
1113 mvilleneuve 1.96 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1114     ;;;
1115     ;;; Dynamic abbrevs
1116 ejohnson 1.27
1117 rstrandh 1.49 (define-named-command com-dabbrev-expand ()
1118 rstrandh 1.80 (let* ((win (current-window))
1119 rstrandh 1.49 (point (point win)))
1120     (with-slots (original-prefix prefix-start-offset dabbrev-expansion-mark) win
1121     (flet ((move () (cond ((beginning-of-buffer-p dabbrev-expansion-mark)
1122     (setf (offset dabbrev-expansion-mark)
1123     (offset point))
1124     (forward-word dabbrev-expansion-mark))
1125     ((mark< dabbrev-expansion-mark point)
1126     (backward-object dabbrev-expansion-mark))
1127     (t (forward-object dabbrev-expansion-mark)))))
1128     (unless (or (beginning-of-buffer-p point)
1129     (not (constituentp (object-before point))))
1130     (unless (and (eq (previous-command win) 'com-dabbrev-expand)
1131     (not (null prefix-start-offset)))
1132     (setf dabbrev-expansion-mark (clone-mark point))
1133     (backward-word dabbrev-expansion-mark)
1134     (setf prefix-start-offset (offset dabbrev-expansion-mark))
1135     (setf original-prefix (region-to-sequence prefix-start-offset point))
1136     (move))
1137     (loop until (or (end-of-buffer-p dabbrev-expansion-mark)
1138     (and (or (beginning-of-buffer-p dabbrev-expansion-mark)
1139     (not (constituentp (object-before dabbrev-expansion-mark))))
1140     (looking-at dabbrev-expansion-mark original-prefix)))
1141     do (move))
1142     (if (end-of-buffer-p dabbrev-expansion-mark)
1143     (progn (delete-region prefix-start-offset point)
1144     (insert-sequence point original-prefix)
1145     (setf prefix-start-offset nil))
1146     (progn (delete-region prefix-start-offset point)
1147     (insert-sequence point
1148     (let ((offset (offset dabbrev-expansion-mark)))
1149     (prog2 (forward-word dabbrev-expansion-mark)
1150     (region-to-sequence offset dabbrev-expansion-mark)
1151     (setf (offset dabbrev-expansion-mark) offset))))
1152     (move))))))))
1153    
1154 rstrandh 1.71 (define-named-command com-beginning-of-paragraph ()
1155 rstrandh 1.80 (let* ((pane (current-window))
1156 rstrandh 1.71 (point (point pane))
1157     (syntax (syntax (buffer pane))))
1158     (beginning-of-paragraph point syntax)))
1159    
1160     (define-named-command com-end-of-paragraph ()
1161 rstrandh 1.80 (let* ((pane (current-window))
1162 rstrandh 1.71 (point (point pane))
1163     (syntax (syntax (buffer pane))))
1164     (end-of-paragraph point syntax)))
1165    
1166 ejohnson 1.27 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1167     ;;;
1168 rstrandh 1.80 ;;; Global and dead-escape command tables
1169 ejohnson 1.27
1170     (make-command-table 'global-climacs-table :errorp nil)
1171    
1172 rstrandh 1.80 (make-command-table 'dead-escape-climacs-table :errorp nil)
1173    
1174     (add-menu-item-to-command-table 'global-climacs-table "dead-escape"
1175     :menu 'dead-escape-climacs-table
1176     :keystroke '(:escape))
1177    
1178     (defun dead-escape-set-key (gesture command)
1179     (add-command-to-command-table command 'dead-escape-climacs-table
1180     :keystroke gesture :errorp nil))
1181    
1182 ejohnson 1.27 (defun global-set-key (gesture command)
1183     (add-command-to-command-table command 'global-climacs-table
1184 rstrandh 1.80 :keystroke gesture :errorp nil)
1185     (when (and
1186     (listp gesture)
1187     (find :meta gesture))
1188     (dead-escape-set-key (remove :meta gesture) command)))
1189 ejohnson 1.27
1190 mvilleneuve 1.89 (loop for code from (char-code #\Space) to (char-code #\~)
1191 ejohnson 1.27 do (global-set-key (code-char code) 'com-self-insert))
1192    
1193 mvilleneuve 1.89 (global-set-key #\Newline 'com-self-insert)
1194 mvilleneuve 1.86 (global-set-key #\Tab 'com-indent-line)
1195 mvilleneuve 1.79 (global-set-key '(#\j :control) 'com-newline-and-indent)
1196 rstrandh 1.62 (global-set-key '(#\f :control) `(com-forward-object ,*numeric-argument-marker*))
1197     (global-set-key '(#\b :control) `(com-backward-object ,*numeric-argument-marker*))
1198 ejohnson 1.27 (global-set-key '(#\a :control) 'com-beginning-of-line)
1199     (global-set-key '(#\e :control) 'com-end-of-line)
1200 rstrandh 1.62 (global-set-key '(#\d :control) `(com-delete-object ,*numeric-argument-marker*))
1201 ejohnson 1.27 (global-set-key '(#\p :control) 'com-previous-line)
1202 rstrandh 1.75 (global-set-key '(#\l :control) 'com-full-redisplay)
1203 ejohnson 1.27 (global-set-key '(#\n :control) 'com-next-line)
1204     (global-set-key '(#\o :control) 'com-open-line)
1205     (global-set-key '(#\k :control) 'com-kill-line)
1206 rstrandh 1.42 (global-set-key '(#\t :control) 'com-transpose-objects)
1207 ejohnson 1.27 (global-set-key '(#\Space :control) 'com-set-mark)
1208 ejohnson 1.50 (global-set-key '(#\y :control) 'com-yank)
1209 ejohnson 1.27 (global-set-key '(#\w :control) 'com-cut-out)
1210     (global-set-key '(#\f :meta) 'com-forward-word)
1211     (global-set-key '(#\b :meta) 'com-backward-word)
1212 rstrandh 1.43 (global-set-key '(#\t :meta) 'com-transpose-words)
1213 rstrandh 1.60 (global-set-key '(#\u :meta) 'com-upcase-word)
1214     (global-set-key '(#\l :meta) 'com-downcase-word)
1215     (global-set-key '(#\c :meta) 'com-capitalize-word)
1216 ejohnson 1.27 (global-set-key '(#\x :meta) 'com-extended-command)
1217 ejohnson 1.50 (global-set-key '(#\y :meta) 'com-rotate-yank)
1218 ejohnson 1.27 (global-set-key '(#\w :meta) 'com-copy-out)
1219 rstrandh 1.39 (global-set-key '(#\v :control) 'com-page-down)
1220 rstrandh 1.40 (global-set-key '(#\v :meta) 'com-page-up)
1221 ejohnson 1.27 (global-set-key '(#\< :shift :meta) 'com-beginning-of-buffer)
1222     (global-set-key '(#\> :shift :meta) 'com-end-of-buffer)
1223 rstrandh 1.32 (global-set-key '(#\m :meta) 'com-back-to-indentation)
1224 mvilleneuve 1.74 (global-set-key '(#\^ :shift :meta) 'com-delete-indentation)
1225 mvilleneuve 1.90 (global-set-key '(#\q :meta) 'com-fill-paragraph)
1226 rstrandh 1.32 (global-set-key '(#\d :meta) 'com-delete-word)
1227     (global-set-key '(#\Backspace :meta) 'com-backward-delete-word)
1228 rstrandh 1.49 (global-set-key '(#\/ :meta) 'com-dabbrev-expand)
1229 rstrandh 1.71 (global-set-key '(#\a :control :meta) 'com-beginning-of-paragraph)
1230     (global-set-key '(#\e :control :meta) 'com-end-of-paragraph)
1231 mvilleneuve 1.97 (global-set-key '(#\s :control) 'com-isearch-mode-forward)
1232     (global-set-key '(#\r :control) 'com-isearch-mode-backward)
1233 ejohnson 1.27
1234     (global-set-key '(:up) 'com-previous-line)
1235     (global-set-key '(:down) 'com-next-line)
1236 rstrandh 1.62 (global-set-key '(:left) `(com-backward-object ,*numeric-argument-marker*))
1237 ejohnson 1.66 (global-set-key '(:right) `(com-forward-object ,*numeric-argument-marker*))
1238 ejohnson 1.27 (global-set-key '(:left :control) 'com-backward-word)
1239     (global-set-key '(:right :control) 'com-forward-word)
1240     (global-set-key '(:home) 'com-beginning-of-line)
1241     (global-set-key '(:end) 'com-end-of-line)
1242 abridgewater 1.57 (global-set-key '(:prior) 'com-page-up)
1243     (global-set-key '(:next) 'com-page-down)
1244 ejohnson 1.27 (global-set-key '(:home :control) 'com-beginning-of-buffer)
1245     (global-set-key '(:end :control) 'com-end-of-buffer)
1246 rstrandh 1.62 (global-set-key #\Rubout `(com-delete-object ,*numeric-argument-marker*))
1247     (global-set-key #\Backspace `(com-backward-delete-object ,*numeric-argument-marker*))
1248 abakic 1.58
1249     (global-set-key '(:insert) 'com-toggle-overwrite-mode)
1250 ejohnson 1.27
1251     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1252     ;;;
1253     ;;; C-x command table
1254    
1255     (make-command-table 'c-x-climacs-table :errorp nil)
1256    
1257     (add-menu-item-to-command-table 'global-climacs-table "C-x"
1258     :menu 'c-x-climacs-table
1259     :keystroke '(#\x :control))
1260    
1261     (defun c-x-set-key (gesture command)
1262     (add-command-to-command-table command 'c-x-climacs-table
1263     :keystroke gesture :errorp nil))
1264    
1265 rstrandh 1.83 (c-x-set-key '(#\0) 'com-delete-window)
1266 rstrandh 1.77 (c-x-set-key '(#\2) 'com-split-window-vertically)
1267 rstrandh 1.83 (c-x-set-key '(#\3) 'com-split-window-horizontally)
1268 rstrandh 1.85 (c-x-set-key '(#\() 'com-start-kbd-macro)
1269     (c-x-set-key '(#\)) 'com-end-kbd-macro)
1270 rstrandh 1.75 (c-x-set-key '(#\b) 'com-switch-to-buffer)
1271 rstrandh 1.85 (c-x-set-key '(#\e) 'com-call-last-kbd-macro)
1272 ejohnson 1.27 (c-x-set-key '(#\c :control) 'com-quit)
1273     (c-x-set-key '(#\f :control) 'com-find-file)
1274 rstrandh 1.91 (c-x-set-key '(#\k) 'com-kill-buffer)
1275 rstrandh 1.63 (c-x-set-key '(#\l :control) 'com-load-file)
1276 rstrandh 1.83 (c-x-set-key '(#\o) 'com-other-window)
1277 rstrandh 1.98 (c-x-set-key '(#\r) 'com-redo)
1278     (c-x-set-key '(#\u) 'com-undo)
1279 ejohnson 1.27 (c-x-set-key '(#\s :control) 'com-save-buffer)
1280 rstrandh 1.45 (c-x-set-key '(#\t :control) 'com-transpose-lines)
1281 ejohnson 1.27 (c-x-set-key '(#\w :control) 'com-write-buffer)
1282 rstrandh 1.45 (c-x-set-key '(#\x :control) 'com-exchange-point-and-mark)
1283 rstrandh 1.44
1284     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1285     ;;;
1286     ;;; Some Unicode stuff
1287    
1288     (define-named-command com-insert-charcode ((code 'integer :prompt "Code point"))
1289 rstrandh 1.80 (insert-object (point (current-window)) (code-char code)))
1290 rstrandh 1.44
1291     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1292     ;;;
1293     ;;; Dead-acute command table
1294    
1295     (make-command-table 'dead-acute-climacs-table :errorp nil)
1296    
1297     (add-menu-item-to-command-table 'global-climacs-table "dead-acute"
1298     :menu 'dead-acute-climacs-table
1299     :keystroke '(:dead--acute))
1300    
1301     (defun dead-acute-set-key (gesture command)
1302     (add-command-to-command-table command 'dead-acute-climacs-table
1303     :keystroke gesture :errorp nil))
1304    
1305     (dead-acute-set-key '(#\A) '(com-insert-charcode 193))
1306     (dead-acute-set-key '(#\E) '(com-insert-charcode 201))
1307     (dead-acute-set-key '(#\I) '(com-insert-charcode 205))
1308     (dead-acute-set-key '(#\O) '(com-insert-charcode 211))
1309     (dead-acute-set-key '(#\U) '(com-insert-charcode 218))
1310     (dead-acute-set-key '(#\Y) '(com-insert-charcode 221))
1311     (dead-acute-set-key '(#\a) '(com-insert-charcode 225))
1312     (dead-acute-set-key '(#\e) '(com-insert-charcode 233))
1313     (dead-acute-set-key '(#\i) '(com-insert-charcode 237))
1314     (dead-acute-set-key '(#\o) '(com-insert-charcode 243))
1315     (dead-acute-set-key '(#\u) '(com-insert-charcode 250))
1316     (dead-acute-set-key '(#\y) '(com-insert-charcode 253))
1317     (dead-acute-set-key '(#\C) '(com-insert-charcode 199))
1318     (dead-acute-set-key '(#\c) '(com-insert-charcode 231))
1319     (dead-acute-set-key '(#\x) '(com-insert-charcode 215))
1320     (dead-acute-set-key '(#\-) '(com-insert-charcode 247))
1321     (dead-acute-set-key '(#\T) '(com-insert-charcode 222))
1322     (dead-acute-set-key '(#\t) '(com-insert-charcode 254))
1323     (dead-acute-set-key '(#\s) '(com-insert-charcode 223))
1324     (dead-acute-set-key '(#\Space) '(com-insert-charcode 39))
1325    
1326 rstrandh 1.45 (make-command-table 'dead-acute-dead-accute-climacs-table :errorp nil)
1327    
1328     (add-menu-item-to-command-table 'dead-acute-climacs-table "dead-acute-dead-accute"
1329     :menu 'dead-acute-dead-accute-climacs-table
1330     :keystroke '(:dead--acute))
1331    
1332     (defun dead-acute-dead-accute-set-key (gesture command)
1333     (add-command-to-command-table command 'dead-acute-dead-accute-climacs-table
1334     :keystroke gesture :errorp nil))
1335    
1336     (dead-acute-dead-accute-set-key '(#\A) '(com-insert-charcode 197))
1337     (dead-acute-dead-accute-set-key '(#\a) '(com-insert-charcode 229))
1338 rstrandh 1.44 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1339     ;;;
1340     ;;; Dead-grave command table
1341    
1342     (make-command-table 'dead-grave-climacs-table :errorp nil)
1343    
1344     (add-menu-item-to-command-table 'global-climacs-table "dead-grave"
1345     :menu 'dead-grave-climacs-table
1346     :keystroke '(:dead--grave))
1347    
1348     (defun dead-grave-set-key (gesture command)
1349     (add-command-to-command-table command 'dead-grave-climacs-table
1350     :keystroke gesture :errorp nil))
1351    
1352     (dead-grave-set-key '(#\A) '(com-insert-charcode 192))
1353     (dead-grave-set-key '(#\E) '(com-insert-charcode 200))
1354     (dead-grave-set-key '(#\I) '(com-insert-charcode 204))
1355     (dead-grave-set-key '(#\O) '(com-insert-charcode 210))
1356     (dead-grave-set-key '(#\U) '(com-insert-charcode 217))
1357     (dead-grave-set-key '(#\a) '(com-insert-charcode 224))
1358     (dead-grave-set-key '(#\e) '(com-insert-charcode 232))
1359     (dead-grave-set-key '(#\i) '(com-insert-charcode 236))
1360     (dead-grave-set-key '(#\o) '(com-insert-charcode 242))
1361     (dead-grave-set-key '(#\u) '(com-insert-charcode 249))
1362     (dead-grave-set-key '(#\Space) '(com-insert-charcode 96))
1363    
1364     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1365     ;;;
1366     ;;; Dead-diaeresis command table
1367    
1368     (make-command-table 'dead-diaeresis-climacs-table :errorp nil)
1369    
1370     (add-menu-item-to-command-table 'global-climacs-table "dead-diaeresis"
1371     :menu 'dead-diaeresis-climacs-table
1372     :keystroke '(:dead--diaeresis :shift))
1373    
1374     (defun dead-diaeresis-set-key (gesture command)
1375     (add-command-to-command-table command 'dead-diaeresis-climacs-table
1376     :keystroke gesture :errorp nil))
1377    
1378     (dead-diaeresis-set-key '(#\A) '(com-insert-charcode 196))
1379     (dead-diaeresis-set-key '(#\E) '(com-insert-charcode 203))
1380     (dead-diaeresis-set-key '(#\I) '(com-insert-charcode 207))
1381     (dead-diaeresis-set-key '(#\O) '(com-insert-charcode 214))
1382     (dead-diaeresis-set-key '(#\U) '(com-insert-charcode 220))
1383     (dead-diaeresis-set-key '(#\a) '(com-insert-charcode 228))
1384     (dead-diaeresis-set-key '(#\e) '(com-insert-charcode 235))
1385     (dead-diaeresis-set-key '(#\i) '(com-insert-charcode 239))
1386     (dead-diaeresis-set-key '(#\o) '(com-insert-charcode 246))
1387     (dead-diaeresis-set-key '(#\u) '(com-insert-charcode 252))
1388     (dead-diaeresis-set-key '(#\y) '(com-insert-charcode 255))
1389     (dead-diaeresis-set-key '(#\Space) '(com-insert-charcode 34))
1390    
1391     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1392     ;;;
1393     ;;; Dead-tilde command table
1394    
1395     (make-command-table 'dead-tilde-climacs-table :errorp nil)
1396    
1397     (add-menu-item-to-command-table 'global-climacs-table "dead-tilde"
1398     :menu 'dead-tilde-climacs-table
1399     :keystroke '(:dead--tilde :shift))
1400    
1401     (defun dead-tilde-set-key (gesture command)
1402     (add-command-to-command-table command 'dead-tilde-climacs-table
1403     :keystroke gesture :errorp nil))
1404    
1405     (dead-tilde-set-key '(#\A) '(com-insert-charcode 195))
1406     (dead-tilde-set-key '(#\N) '(com-insert-charcode 209))
1407     (dead-tilde-set-key '(#\a) '(com-insert-charcode 227))
1408     (dead-tilde-set-key '(#\n) '(com-insert-charcode 241))
1409     (dead-tilde-set-key '(#\E) '(com-insert-charcode 198))
1410     (dead-tilde-set-key '(#\e) '(com-insert-charcode 230))
1411     (dead-tilde-set-key '(#\D) '(com-insert-charcode 208))
1412     (dead-tilde-set-key '(#\d) '(com-insert-charcode 240))
1413     (dead-tilde-set-key '(#\O) '(com-insert-charcode 216))
1414     (dead-tilde-set-key '(#\o) '(com-insert-charcode 248))
1415     (dead-tilde-set-key '(#\Space) '(com-insert-charcode 126))
1416    
1417     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1418     ;;;
1419     ;;; Dead-circumflex command table
1420    
1421     (make-command-table 'dead-circumflex-climacs-table :errorp nil)
1422    
1423     (add-menu-item-to-command-table 'global-climacs-table "dead-circumflex"
1424     :menu 'dead-circumflex-climacs-table
1425     :keystroke '(:dead--circumflex :shift))
1426    
1427     (defun dead-circumflex-set-key (gesture command)
1428     (add-command-to-command-table command 'dead-circumflex-climacs-table
1429     :keystroke gesture :errorp nil))
1430    
1431     (dead-circumflex-set-key '(#\A) '(com-insert-charcode 194))
1432     (dead-circumflex-set-key '(#\E) '(com-insert-charcode 202))
1433     (dead-circumflex-set-key '(#\I) '(com-insert-charcode 206))
1434     (dead-circumflex-set-key '(#\O) '(com-insert-charcode 212))
1435     (dead-circumflex-set-key '(#\U) '(com-insert-charcode 219))
1436     (dead-circumflex-set-key '(#\a) '(com-insert-charcode 226))
1437     (dead-circumflex-set-key '(#\e) '(com-insert-charcode 234))
1438     (dead-circumflex-set-key '(#\i) '(com-insert-charcode 238))
1439     (dead-circumflex-set-key '(#\o) '(com-insert-charcode 244))
1440     (dead-circumflex-set-key '(#\u) '(com-insert-charcode 251))
1441     (dead-circumflex-set-key '(#\Space) '(com-insert-charcode 94))
1442 mvilleneuve 1.96
1443     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1444     ;;;
1445     ;;; Isearch command table
1446    
1447     (make-command-table 'isearch-climacs-table :errorp nil)
1448    
1449     (defun isearch-set-key (gesture command)
1450     (add-command-to-command-table command 'isearch-climacs-table
1451     :keystroke gesture :errorp nil))
1452    
1453     (loop for code from (char-code #\Space) to (char-code #\~)
1454     do (isearch-set-key (code-char code) 'com-isearch-append-char))
1455    
1456     (isearch-set-key '(#\Newline) 'com-isearch-exit)
1457     (isearch-set-key '(#\Backspace) 'com-isearch-delete-char)
1458     (isearch-set-key '(#\s :control) 'com-isearch-forward)
1459 mvilleneuve 1.97 (isearch-set-key '(#\r :control) 'com-isearch-backward)

  ViewVC Help
Powered by ViewVC 1.1.5