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

Contents of /climacs/gui.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.146 - (show annotations)
Sat Jun 18 02:01:56 2005 UTC (8 years, 10 months ago) by bmastenbrook
Branch: MAIN
Changes since 1.145: +7 -0 lines
Current state of slidemacs
1 ;;; -*- Mode: Lisp; Package: CLIMACS-GUI -*-
2
3 ;;; (c) copyright 2004-2005 by
4 ;;; Robert Strandh (strandh@labri.fr)
5 ;;; (c) copyright 2004-2005 by
6 ;;; Elliott Johnson (ejohnson@fasl.info)
7 ;;; (c) copyright 2005 by
8 ;;; Matthieu Villeneuve (matthieu.villeneuve@free.fr)
9 ;;; (c) copyright 2005 by
10 ;;; Aleksandar Bakic (a_bakic@yahoo.com)
11
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 (defclass extended-pane (climacs-pane)
32 (;; allows a certain number of commands to have some minimal memory
33 (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 (dabbrev-expansion-mark :initform nil)
40 (overwrite-mode :initform nil)))
41
42 (defclass info-pane (application-pane)
43 ((climacs-pane :initarg :climacs-pane)))
44
45 (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 (define-application-frame climacs ()
52 ((windows :accessor windows)
53 (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 (:panes
59 (win (let* ((extended-pane
60 (make-pane 'extended-pane
61 :width 900 :height 400
62 :name 'bla
63 :end-of-line-action :scroll
64 :incremental-redisplay t
65 :display-function 'display-win))
66 (info-pane
67 (make-pane 'info-pane
68 :climacs-pane extended-pane
69 :width 900 :height 20 :max-height 20 :min-height 20
70 ::background +gray85+
71 :scroll-bars nil
72 :borders nil
73 :incremental-redisplay t
74 :display-function 'display-info)))
75 (vertically ()
76 (scrolling ()
77 extended-pane)
78 info-pane)))
79 (int (make-pane 'minibuffer-pane
80 :width 900 :height 20 :max-height 20 :min-height 20
81 :display-function 'display-minibuffer
82 :scroll-bars nil)))
83 (:layouts
84 (default
85 (vertically (:scroll-bars nil)
86 win
87 int)))
88 (:top-level (climacs-top-level)))
89
90 (defparameter *message* nil)
91
92 (defun display-message (format-string &rest format-args)
93 (setf *message*
94 (apply #'format nil format-string format-args)))
95
96 (defun display-minibuffer (frame pane)
97 (declare (ignore frame))
98 (unless (null *message*)
99 (princ *message* pane)
100 (setf *message* nil)))
101
102 (defmacro current-window () ; shouldn't this be an inlined function? --amb
103 `(car (windows *application-frame*)))
104
105 (defmethod execute-frame-command :around ((frame climacs) command)
106 (declare (ignore command))
107 (with-undo ((buffer (current-window)))
108 (call-next-method)))
109
110 (defmethod redisplay-frame-panes :around ((frame climacs) &rest args)
111 (declare (ignore args))
112 (let ((buffers (remove-duplicates (mapcar #'buffer (windows frame)))))
113 (loop for buffer in buffers
114 do (update-syntax buffer (syntax buffer)))
115 (call-next-method)
116 (loop for buffer in buffers
117 do (clear-modify buffer))))
118
119 (defun climacs ()
120 "Starts up a climacs session"
121 (let ((frame (make-application-frame 'climacs)))
122 (run-frame-top-level frame)))
123
124 (defun display-info (frame pane)
125 (declare (ignore frame))
126 (with-slots (climacs-pane) pane
127 (let* ((buf (buffer climacs-pane))
128 (name-info (format nil " ~a ~a Syntax: ~a~a~a~a ~a"
129 (if (needs-saving buf) "**" "--")
130 (name buf)
131 (name (syntax buf))
132 (if (slot-value climacs-pane 'overwrite-mode)
133 " Ovwrt"
134 "")
135 (if (auto-fill-mode climacs-pane)
136 " Fill"
137 "")
138 (if (isearch-mode climacs-pane)
139 " Isearch"
140 "")
141 (if (recordingp *application-frame*)
142 "Def"
143 ""))))
144 (princ name-info pane))))
145
146 (defun display-win (frame pane)
147 "The display function used by the climacs application frame."
148 (declare (ignore frame))
149 (redisplay-pane pane (eq pane (current-window))))
150
151 (defmethod handle-repaint :before ((pane extended-pane) region)
152 (declare (ignore region))
153 (redisplay-frame-panes *application-frame*))
154
155 (defun find-gestures (gestures start-table)
156 (loop with table = (find-command-table start-table)
157 for (gesture . rest) on gestures
158 for item = (find-keystroke-item gesture table :errorp nil)
159 while item
160 do (if (eq (command-menu-item-type item) :command)
161 (return (if (null rest) item nil))
162 (setf table (command-menu-item-value item)))
163 finally (return item)))
164
165 (defvar *kill-ring* (make-instance 'kill-ring :max-size 7))
166 (defparameter *current-gesture* nil)
167
168 (defun meta-digit (gesture)
169 (position gesture
170 '((#\0 :meta) (#\1 :meta) (#\2 :meta) (#\3 :meta) (#\4 :meta)
171 (#\5 :meta) (#\6 :meta) (#\7 :meta) (#\8 :meta) (#\9 :meta))
172 :test #'event-matches-gesture-name-p))
173
174 (defun climacs-read-gesture ()
175 (unless (null (remaining-keys *application-frame*))
176 (return-from climacs-read-gesture
177 (pop (remaining-keys *application-frame*))))
178 (loop for gesture = (read-gesture :stream *standard-input*)
179 until (or (characterp gesture)
180 (and (typep gesture 'keyboard-event)
181 (or (keyboard-event-character gesture)
182 (not (member (keyboard-event-key-name
183 gesture)
184 '(:control-left :control-right
185 :shift-left :shift-right
186 :meta-left :meta-right
187 :super-left :super-right
188 :hyper-left :hyper-right
189 :shift-lock :caps-lock
190 :alt-left :alt-right))))))
191 finally (progn (when (recordingp *application-frame*)
192 (push gesture (recorded-keys *application-frame*)))
193 (return gesture))))
194
195 (defun climacs-unread-gesture (gesture stream)
196 (cond ((recordingp *application-frame*)
197 (pop (recorded-keys *application-frame*))
198 (unread-gesture gesture :stream stream))
199 ((executingp *application-frame*)
200 (push gesture (remaining-keys *application-frame*)))
201 (t
202 (unread-gesture gesture :stream stream))))
203
204 (defun read-numeric-argument (&key (stream *standard-input*))
205 (let ((gesture (climacs-read-gesture)))
206 (cond ((event-matches-gesture-name-p gesture '(:keyboard #\u 512)) ; FIXME
207 (let ((numarg 4))
208 (loop for gesture = (climacs-read-gesture)
209 while (event-matches-gesture-name-p gesture '(:keyboard #\u 512)) ; FIXME
210 do (setf numarg (* 4 numarg))
211 finally (climacs-unread-gesture gesture stream))
212 (let ((gesture (climacs-read-gesture)))
213 (cond ((and (characterp gesture)
214 (digit-char-p gesture 10))
215 (setf numarg (- (char-code gesture) (char-code #\0)))
216 (loop for gesture = (climacs-read-gesture)
217 while (and (characterp gesture)
218 (digit-char-p gesture 10))
219 do (setf numarg (+ (* 10 numarg)
220 (- (char-code gesture) (char-code #\0))))
221 finally (climacs-unread-gesture gesture stream)
222 (return (values numarg t))))
223 (t
224 (climacs-unread-gesture gesture stream)
225 (values numarg t))))))
226 ((meta-digit gesture)
227 (let ((numarg (meta-digit gesture)))
228 (loop for gesture = (climacs-read-gesture)
229 while (meta-digit gesture)
230 do (setf numarg (+ (* 10 numarg) (meta-digit gesture)))
231 finally (climacs-unread-gesture gesture stream)
232 (return (values numarg t)))))
233 (t (climacs-unread-gesture gesture stream)
234 (values 1 nil)))))
235
236 ;;; we know the vbox pane has a scroller pane and an info
237 ;;; pane in it. The scroller pane has a viewport in it,
238 ;;; and the viewport contains the climacs-pane as its only child.
239 (defun find-climacs-pane (vbox)
240 (first (sheet-children
241 (find-if-not (lambda (pane) (typep pane 'scroll-bar-pane))
242 (sheet-children
243 (find-if (lambda (pane) (typep pane 'scroller-pane))
244 (sheet-children vbox)))))))
245
246 (defvar *numeric-argument-p* (list nil))
247
248 (defun substitute-numeric-argument-p (command numargp)
249 (substitute numargp *numeric-argument-p* command :test #'eq))
250
251 (defun climacs-top-level (frame &key
252 command-parser command-unparser
253 partial-command-parser prompt)
254 (declare (ignore command-parser command-unparser partial-command-parser prompt))
255 (with-slots (windows) frame
256 (setf windows (list (find-climacs-pane (find-pane-named frame 'win))))
257 (push (buffer (car windows)) (buffers frame))
258 (let ((*standard-output* (car windows))
259 (*standard-input* (find-pane-named frame 'int))
260 (*print-pretty* nil)
261 (*abort-gestures* '((:keyboard #\g 512))))
262 (redisplay-frame-panes frame :force-p t)
263 (flet ((do-command (command)
264 (handler-case
265 (execute-frame-command frame command)
266 (offset-before-beginning ()
267 (beep) (display-message "Beginning of buffer"))
268 (offset-after-end ()
269 (beep) (display-message "End of buffer"))
270 (motion-before-beginning ()
271 (beep) (display-message "Beginning of buffer"))
272 (motion-after-end ()
273 (beep) (display-message "End of buffer"))
274 (no-expression ()
275 (beep) (display-message "No expression around point"))
276 (no-such-operation ()
277 (beep) (display-message "Operation unavailable for syntax")))
278 (setf (previous-command *standard-output*)
279 (if (consp command)
280 (car command)
281 command)))
282 (update-climacs ()
283 (let ((buffer (buffer (current-window))))
284 (when (modified-p buffer)
285 (setf (needs-saving buffer) t)))
286 (when (null (remaining-keys *application-frame*))
287 (setf (executingp *application-frame*) nil)
288 (redisplay-frame-panes frame))))
289 (flet ((process-gestures ()
290 (loop
291 for gestures = '()
292 do (multiple-value-bind (numarg numargp)
293 (read-numeric-argument :stream *standard-input*)
294 (loop
295 (setf *current-gesture* (climacs-read-gesture))
296 (setf gestures
297 (nconc gestures (list *current-gesture*)))
298 (let ((item (find-gestures gestures 'global-climacs-table)))
299 (cond
300 ((not item)
301 (beep) (return))
302 ((eq (command-menu-item-type item) :command)
303 (let ((command (command-menu-item-value item)))
304 (unless (consp command)
305 (setf command (list command)))
306 (setf command (substitute-numeric-argument-marker command numarg))
307 (setf command (substitute-numeric-argument-p command numargp))
308 (do-command command)
309 (return)))
310 (t nil)))))
311 do (update-climacs))))
312 (loop
313 for maybe-error = t
314 do (restart-case
315 (progn
316 (handler-case
317 (with-input-context
318 ('(command :command-table global-climacs-table))
319 (object)
320 (process-gestures)
321 (t
322 (do-command object)
323 (setq maybe-error nil)))
324 (abort-gesture () (display-message "Quit")))
325 (when maybe-error
326 (beep))
327 (update-climacs))
328 (return-to-climacs () nil))))))))
329
330 (defmacro simple-command-loop (command-table loop-condition end-clauses)
331 (let ((gesture (gensym))
332 (item (gensym))
333 (command (gensym)))
334 `(progn
335 (redisplay-frame-panes *application-frame*)
336 (loop while ,loop-condition
337 as ,gesture = (climacs-read-gesture)
338 as ,item = (find-gestures (list ,gesture) ,command-table)
339 do (cond ((and ,item (eq (command-menu-item-type ,item) :command))
340 (setf *current-gesture* ,gesture)
341 (let ((,command (command-menu-item-value ,item)))
342 (unless (consp ,command)
343 (setf ,command (list ,command)))
344 (handler-case
345 (execute-frame-command *application-frame*
346 ,command)
347 (offset-before-beginning ()
348 (beep) (display-message "Beginning of buffer"))
349 (offset-after-end ()
350 (beep) (display-message "End of buffer"))
351 (motion-before-beginning ()
352 (beep) (display-message "Beginning of buffer"))
353 (motion-after-end ()
354 (beep) (display-message "End of buffer")))))
355 (t
356 (unread-gesture ,gesture)
357 ,@end-clauses))
358 (redisplay-frame-panes *application-frame*)))))
359
360 (defmacro define-named-command (command-name args &body body)
361 `(define-climacs-command ,(if (listp command-name)
362 `(,@command-name :name t)
363 `(,command-name :name t)) ,args ,@body))
364
365 (define-named-command com-toggle-overwrite-mode ()
366 (with-slots (overwrite-mode) (current-window)
367 (setf overwrite-mode (not overwrite-mode))))
368
369 (defun possibly-fill-line ()
370 (let* ((pane (current-window))
371 (buffer (buffer pane)))
372 (when (auto-fill-mode pane)
373 (let* ((fill-column (auto-fill-column pane))
374 (point (point pane))
375 (offset (offset point))
376 (tab-width (tab-space-count (stream-default-view pane)))
377 (syntax (syntax buffer)))
378 (when (>= (buffer-display-column buffer offset tab-width)
379 (1- fill-column))
380 (fill-line point
381 (lambda (mark)
382 (syntax-line-indentation mark tab-width syntax))
383 fill-column
384 tab-width))))))
385
386 (defun insert-character (char)
387 (let* ((win (current-window))
388 (point (point win)))
389 (unless (constituentp char)
390 (possibly-expand-abbrev point))
391 (when (whitespacep char)
392 (possibly-fill-line))
393 (if (and (slot-value win 'overwrite-mode) (not (end-of-line-p point)))
394 (progn
395 (delete-range point)
396 (insert-object point char))
397 (insert-object point char))))
398
399 (define-command com-self-insert ()
400 (insert-character *current-gesture*))
401
402 (define-named-command com-beginning-of-line ()
403 (beginning-of-line (point (current-window))))
404
405 (define-named-command com-end-of-line ()
406 (end-of-line (point (current-window))))
407
408 (define-named-command com-delete-object ((count 'integer :prompt "Number of Objects"))
409 (delete-range (point (current-window)) count))
410
411 (define-named-command com-backward-delete-object ((count 'integer :prompt "Number of Objects"))
412 (delete-range (point (current-window)) (- count)))
413
414 (define-named-command com-transpose-objects ()
415 (let* ((point (point (current-window))))
416 (unless (beginning-of-buffer-p point)
417 (when (end-of-line-p point)
418 (backward-object point))
419 (let ((object (object-after point)))
420 (delete-range point)
421 (backward-object point)
422 (insert-object point object)
423 (forward-object point)))))
424
425 (define-named-command com-backward-object ((count 'integer :prompt "Number of Objects"))
426 (backward-object (point (current-window)) count))
427
428 (define-named-command com-forward-object ((count 'integer :prompt "Number of Objects"))
429 (forward-object (point (current-window)) count))
430
431 (define-named-command com-transpose-words ()
432 (let* ((point (point (current-window))))
433 (let (bw1 bw2 ew1 ew2)
434 (backward-word point)
435 (setf bw1 (offset point))
436 (forward-word point)
437 (setf ew1 (offset point))
438 (forward-word point)
439 (when (= (offset point) ew1)
440 ;; this is emacs' message in the minibuffer
441 (error "Don't have two things to transpose"))
442 (setf ew2 (offset point))
443 (backward-word point)
444 (setf bw2 (offset point))
445 (let ((w2 (buffer-sequence (buffer point) bw2 ew2))
446 (w1 (buffer-sequence (buffer point) bw1 ew1)))
447 (delete-word point)
448 (insert-sequence point w1)
449 (backward-word point)
450 (backward-word point)
451 (delete-word point)
452 (insert-sequence point w2)
453 (forward-word point)))))
454
455 (define-named-command com-transpose-lines ()
456 (let ((point (point (current-window))))
457 (beginning-of-line point)
458 (unless (beginning-of-buffer-p point)
459 (previous-line point))
460 (let* ((bol (offset point))
461 (eol (progn (end-of-line point)
462 (offset point)))
463 (line (buffer-sequence (buffer point) bol eol)))
464 (delete-region bol point)
465 ;; Remove newline at end of line as well.
466 (unless (end-of-buffer-p point)
467 (delete-range point))
468 ;; If the current line is at the end of the buffer, we want to
469 ;; be able to insert past it, so we need to get an extra line
470 ;; at the end.
471 (end-of-line point)
472 (when (end-of-buffer-p point)
473 (insert-object point #\Newline))
474 (next-line point 0)
475 (insert-sequence point line)
476 (insert-object point #\Newline))))
477
478 (define-named-command com-previous-line ((numarg 'integer :prompt "How many lines?"))
479 (let* ((win (current-window))
480 (point (point win)))
481 (unless (or (eq (previous-command win) 'com-previous-line)
482 (eq (previous-command win) 'com-next-line))
483 (setf (slot-value win 'goal-column) (column-number point)))
484 (previous-line point (slot-value win 'goal-column) numarg)))
485
486 (define-named-command com-next-line ((numarg 'integer :prompt "How many lines?"))
487 (let* ((win (current-window))
488 (point (point win)))
489 (unless (or (eq (previous-command win) 'com-previous-line)
490 (eq (previous-command win) 'com-next-line))
491 (setf (slot-value win 'goal-column) (column-number point)))
492 (next-line point (slot-value win 'goal-column) numarg)))
493
494 (define-named-command com-open-line ((numarg 'integer :prompt "How many lines?"))
495 (open-line (point (current-window)) numarg))
496
497 (define-named-command com-kill-line ((numarg 'integer :prompt "Kill how many lines?")
498 (numargp 'boolean :prompt "Kill entire lines?"))
499 (let* ((pane (current-window))
500 (point (point pane))
501 (mark (offset point)))
502 (cond ((or numargp (> numarg 1))
503 (loop repeat numarg
504 until (end-of-buffer-p point)
505 do (end-of-line point)
506 until (end-of-buffer-p point)
507 do (forward-object point)))
508 (t
509 (cond ((end-of-buffer-p point) nil)
510 ((end-of-line-p point)(forward-object point))
511 (t (end-of-line point)))))
512 (unless (mark= point mark)
513 (if (eq (previous-command pane) 'com-kill-line)
514 (kill-ring-concatenating-push *kill-ring*
515 (region-to-sequence mark point))
516 (kill-ring-standard-push *kill-ring*
517 (region-to-sequence mark point)))
518 (delete-region mark point))))
519
520 (define-named-command com-forward-word ((count 'integer :prompt "Number of words"))
521 (forward-word (point (current-window)) count))
522
523 (define-named-command com-backward-word ((count 'integer :prompt "Number of words"))
524 (backward-word (point (current-window)) count))
525
526 (define-named-command com-delete-word ((count 'integer :prompt "Number of words"))
527 (delete-word (point (current-window)) count))
528
529 (define-named-command com-backward-delete-word ((count 'integer :prompt "Number of words"))
530 (backward-delete-word (point (current-window)) count))
531
532 (define-named-command com-upcase-region ()
533 (let ((cw (current-window)))
534 (upcase-region (mark cw) (point cw))))
535
536 (define-named-command com-downcase-region ()
537 (let ((cw (current-window)))
538 (downcase-region (mark cw) (point cw))))
539
540 (define-named-command com-capitalize-region ()
541 (let ((cw (current-window)))
542 (capitalize-region (mark cw) (point cw))))
543
544 (define-named-command com-upcase-word ()
545 (upcase-word (point (current-window))))
546
547 (define-named-command com-downcase-word ()
548 (downcase-word (point (current-window))))
549
550 (define-named-command com-capitalize-word ()
551 (capitalize-word (point (current-window))))
552
553 (define-named-command com-tabify-region ()
554 (let ((pane (current-window)))
555 (tabify-region
556 (mark pane) (point pane) (tab-space-count (stream-default-view pane)))))
557
558 (define-named-command com-untabify-region ()
559 (let ((pane (current-window)))
560 (untabify-region
561 (mark pane) (point pane) (tab-space-count (stream-default-view pane)))))
562
563 (defun indent-current-line (pane point)
564 (let* ((buffer (buffer pane))
565 (view (stream-default-view pane))
566 (tab-space-count (tab-space-count view))
567 (indentation (syntax-line-indentation point
568 tab-space-count
569 (syntax buffer))))
570 (indent-line point indentation (and (indent-tabs-mode buffer)
571 tab-space-count))))
572
573 (define-named-command com-indent-line ()
574 (let* ((pane (current-window))
575 (point (point pane)))
576 (indent-current-line pane point)))
577
578 (define-named-command com-newline-and-indent ()
579 (let* ((pane (current-window))
580 (point (point pane)))
581 (insert-object point #\Newline)
582 (indent-current-line pane point)))
583
584 (define-named-command com-delete-indentation ()
585 (delete-indentation (point (current-window))))
586
587 (define-named-command com-auto-fill-mode ()
588 (let ((pane (current-window)))
589 (setf (auto-fill-mode pane) (not (auto-fill-mode pane)))))
590
591 (define-named-command com-fill-paragraph ()
592 (let* ((pane (current-window))
593 (buffer (buffer pane))
594 (syntax (syntax buffer))
595 (point (point pane))
596 (begin-mark (clone-mark point))
597 (end-mark (clone-mark point)))
598 (unless (eql (object-before begin-mark) #\Newline)
599 (beginning-of-paragraph begin-mark syntax))
600 (unless (eql (object-after end-mark) #\Newline)
601 (end-of-paragraph end-mark syntax))
602 (do-buffer-region (object offset buffer
603 (offset begin-mark) (offset end-mark))
604 (when (eql object #\Newline)
605 (setf object #\Space)))
606 (let ((point-backup (clone-mark point)))
607 (setf (offset point) (offset end-mark))
608 (possibly-fill-line)
609 (setf (offset point) (offset point-backup)))))
610
611 (define-command com-extended-command ()
612 (let ((item (handler-case (accept 'command :prompt "Extended Command")
613 (error () (progn (beep)
614 (display-message "No such command")
615 (return-from com-extended-command nil))))))
616 (execute-frame-command *application-frame* item)))
617
618 (eval-when (:compile-toplevel :load-toplevel)
619 (define-presentation-type completable-pathname ()
620 :inherit-from 'pathname))
621
622 (defun filename-completer (so-far mode)
623 (flet ((remove-trail (s)
624 (subseq s 0 (let ((pos (position #\/ s :from-end t)))
625 (if pos (1+ pos) 0)))))
626 (let* ((directory-prefix
627 (if (and (plusp (length so-far)) (eql (aref so-far 0) #\/))
628 ""
629 (namestring #+sbcl *default-pathname-defaults*
630 #+cmu (ext:default-directory)
631 #-(or sbcl cmu) *default-pathname-defaults*)))
632 (full-so-far (concatenate 'string directory-prefix so-far))
633 (pathnames
634 (loop with length = (length full-so-far)
635 and wildcard = (concatenate 'string (remove-trail so-far) "*.*")
636 for path in
637 #+(or sbcl cmu lispworks) (directory wildcard)
638 #+openmcl (directory wildcard :directories t)
639 #+allegro (directory wildcard :directories-are-files nil)
640 #+cormanlisp (nconc (directory wildcard)
641 (cl::directory-subdirs dirname))
642 #-(or sbcl cmu lispworks openmcl allegro cormanlisp)
643 (directory wildcard)
644 when (let ((mismatch (mismatch (namestring path) full-so-far)))
645 (or (null mismatch) (= mismatch length)))
646 collect path))
647 (strings (mapcar #'namestring pathnames))
648 (first-string (car strings))
649 (length-common-prefix nil)
650 (completed-string nil)
651 (full-completed-string nil))
652 (unless (null pathnames)
653 (setf length-common-prefix
654 (loop with length = (length first-string)
655 for string in (cdr strings)
656 do (setf length (min length (or (mismatch string first-string) length)))
657 finally (return length))))
658 (unless (null pathnames)
659 (setf completed-string
660 (subseq first-string (length directory-prefix)
661 (if (null (cdr pathnames)) nil length-common-prefix)))
662 (setf full-completed-string
663 (concatenate 'string directory-prefix completed-string)))
664 (case mode
665 ((:complete-limited :complete-maximal)
666 (cond ((null pathnames)
667 (values so-far nil nil 0 nil))
668 ((null (cdr pathnames))
669 (values completed-string t (car pathnames) 1 nil))
670 (t
671 (values completed-string nil nil (length pathnames) nil))))
672 (:complete
673 (cond ((null pathnames)
674 (values so-far t so-far 1 nil))
675 ((null (cdr pathnames))
676 (values completed-string t (car pathnames) 1 nil))
677 ((find full-completed-string strings :test #'string-equal)
678 (let ((pos (position full-completed-string strings :test #'string-equal)))
679 (values completed-string
680 t (elt pathnames pos) (length pathnames) nil)))
681 (t
682 (values completed-string nil nil (length pathnames) nil))))
683 (:possibilities
684 (values nil nil nil (length pathnames)
685 (loop with length = (length directory-prefix)
686 for name in pathnames
687 collect (list (subseq (namestring name) length nil)
688 name))))))))
689
690 (define-presentation-method accept
691 ((type completable-pathname) stream (view textual-view) &key)
692 (multiple-value-bind (pathname success string)
693 (complete-input stream
694 #'filename-completer
695 :partial-completers '(#\Space)
696 :allow-any-input t)
697 (declare (ignore success))
698 (or pathname string)))
699
700 (defun filepath-filename (pathname)
701 (if (null (pathname-type pathname))
702 (pathname-name pathname)
703 (concatenate 'string (pathname-name pathname)
704 "." (pathname-type pathname))))
705
706 (defun syntax-class-name-for-filepath (filepath)
707 (or (climacs-syntax::syntax-description-class-name
708 (find (or (pathname-type filepath)
709 (pathname-name filepath))
710 climacs-syntax::*syntaxes*
711 :test (lambda (x y)
712 (member x y :test #'string=))
713 :key #'climacs-syntax::syntax-description-pathname-types))
714 'basic-syntax))
715
716 (define-named-command com-find-file ()
717 (let ((filepath (accept 'completable-pathname
718 :prompt "Find File"))
719 (buffer (make-instance 'climacs-buffer))
720 (pane (current-window)))
721 (setf (point (buffer pane)) (clone-mark (point pane)))
722 (push buffer (buffers *application-frame*))
723 (setf (buffer (current-window)) buffer)
724 (setf (syntax buffer)
725 (make-instance
726 (syntax-class-name-for-filepath filepath)
727 :buffer (buffer (point pane))))
728 ;; Don't want to create the file if it doesn't exist.
729 (when (probe-file filepath)
730 (with-open-file (stream filepath :direction :input)
731 (input-from-stream stream buffer 0)))
732 (setf (filepath buffer) filepath
733 (name buffer) (filepath-filename filepath)
734 (needs-saving buffer) nil)
735 (beginning-of-buffer (point pane))
736 ;; this one is needed so that the buffer modification protocol
737 ;; resets the low and high marks after redisplay
738 (redisplay-frame-panes *application-frame*)))
739
740 (define-named-command com-insert-file ()
741 (let ((filename (accept 'completable-pathname
742 :prompt "Insert File"))
743 (pane (current-window)))
744 (when (probe-file filename)
745 (setf (mark pane) (clone-mark (point pane) :left))
746 (with-open-file (stream filename :direction :input)
747 (input-from-stream stream
748 (buffer pane)
749 (offset (point pane))))
750 (psetf (offset (mark pane)) (offset (point pane))
751 (offset (point pane)) (offset (mark pane))))
752 (redisplay-frame-panes *application-frame*)))
753
754 (defun save-buffer (buffer)
755 (let ((filepath (or (filepath buffer)
756 (accept 'completable-pathname
757 :prompt "Save Buffer to File"))))
758 (with-open-file (stream filepath :direction :output :if-exists :supersede)
759 (output-to-stream stream buffer 0 (size buffer)))
760 (setf (filepath buffer) filepath
761 (name buffer) (filepath-filename filepath))
762 (display-message "Wrote: ~a" (filepath buffer))
763 (setf (needs-saving buffer) nil)))
764
765 (define-named-command com-save-buffer ()
766 (let ((buffer (buffer (current-window))))
767 (if (or (null (filepath buffer))
768 (needs-saving buffer))
769 (save-buffer buffer)
770 (display-message "No changes need to be saved from ~a" (name buffer)))))
771
772 (define-named-command (com-quit) ()
773 (loop for buffer in (buffers *application-frame*)
774 when (and (needs-saving buffer)
775 (filepath buffer)
776 (handler-case (accept 'boolean
777 :prompt (format nil "Save buffer: ~a ?" (name buffer)))
778 (error () (progn (beep)
779 (display-message "Invalid answer")
780 (return-from com-quit nil)))))
781 do (save-buffer buffer))
782 (when (or (notany #'(lambda (buffer) (and (needs-saving buffer) (filepath buffer)))
783 (buffers *application-frame*))
784 (handler-case (accept 'boolean :prompt "Modified buffers exist. Quit anyway?")
785 (error () (progn (beep)
786 (display-message "Invalid answer")
787 (return-from com-quit nil)))))
788 (frame-exit *application-frame*)))
789
790 (define-named-command com-write-buffer ()
791 (let ((filepath (accept 'completable-pathname
792 :prompt "Write Buffer to File"))
793 (buffer (buffer (current-window))))
794 (with-open-file (stream filepath :direction :output :if-exists :supersede)
795 (output-to-stream stream buffer 0 (size buffer)))
796 (setf (filepath buffer) filepath
797 (name buffer) (filepath-filename filepath)
798 (needs-saving buffer) nil)
799 (display-message "Wrote: ~a" (filepath buffer))))
800
801 (define-presentation-method accept
802 ((type buffer) stream (view textual-view) &key)
803 (multiple-value-bind (object success string)
804 (complete-input stream
805 (lambda (so-far action)
806 (complete-from-possibilities
807 so-far (buffers *application-frame*) '() :action action
808 :name-key #'name
809 :value-key #'identity))
810 :partial-completers '(#\Space)
811 :allow-any-input t)
812 (declare (ignore success))
813 (or object
814 (car (push (make-instance 'climacs-buffer :name string)
815 (buffers *application-frame*))))))
816
817 (define-named-command com-switch-to-buffer ()
818 (let ((buffer (accept 'buffer
819 :prompt "Switch to buffer"))
820 (pane (current-window)))
821 (setf (point (buffer pane)) (clone-mark (point pane)))
822 (setf (buffer pane) buffer)
823 (full-redisplay pane)))
824
825 (define-named-command com-kill-buffer ()
826 (with-slots (buffers) *application-frame*
827 (let ((buffer (buffer (current-window))))
828 (when (and (needs-saving buffer)
829 (handler-case (accept 'boolean :prompt "Save buffer first?")
830 (error () (progn (beep)
831 (display-message "Invalid answer")
832 (return-from com-kill-buffer nil)))))
833 (com-save-buffer))
834 (setf buffers (remove buffer buffers))
835 ;; Always need one buffer.
836 (when (null buffers)
837 (push (make-instance 'climacs-buffer :name "*scratch*")
838 buffers))
839 (setf (buffer (current-window)) (car buffers)))))
840
841 (define-named-command com-full-redisplay ()
842 (full-redisplay (current-window)))
843
844 (define-named-command com-load-file ()
845 (let ((filepath (accept 'completable-pathname
846 :prompt "Load File")))
847 (load filepath)))
848
849 (define-named-command com-beginning-of-buffer ()
850 (beginning-of-buffer (point (current-window))))
851
852 (define-named-command com-page-down ()
853 (let ((pane (current-window)))
854 (page-down pane)))
855
856 (define-named-command com-page-up ()
857 (let ((pane (current-window)))
858 (page-up pane)))
859
860 (define-named-command com-end-of-buffer ()
861 (end-of-buffer (point (current-window))))
862
863 (define-named-command com-back-to-indentation ()
864 (let ((point (point (current-window))))
865 (beginning-of-line point)
866 (loop until (end-of-line-p point)
867 while (whitespacep (object-after point))
868 do (incf (offset point)))))
869
870 (define-named-command com-goto-position ()
871 (setf (offset (point (current-window)))
872 (handler-case (accept 'integer :prompt "Goto Position")
873 (error () (progn (beep)
874 (display-message "Not a valid position")
875 (return-from com-goto-position nil))))))
876
877 (define-named-command com-goto-line ()
878 (loop with mark = (let ((m (clone-mark
879 (low-mark (buffer (current-window)))
880 :right)))
881 (beginning-of-buffer m)
882 m)
883 do (end-of-line mark)
884 until (end-of-buffer-p mark)
885 repeat (handler-case (accept 'integer :prompt "Goto Line")
886 (error () (progn (beep)
887 (display-message "Not a valid line number")
888 (return-from com-goto-line nil))))
889 do (incf (offset mark))
890 (end-of-line mark)
891 finally (beginning-of-line mark)
892 (setf (offset (point (current-window)))
893 (offset mark))))
894
895 (define-named-command com-browse-url ()
896 (accept 'url :prompt "Browse URL"))
897
898 (define-named-command com-set-mark ()
899 (let ((pane (current-window)))
900 (setf (mark pane) (clone-mark (point pane)))))
901
902 (define-named-command com-exchange-point-and-mark ()
903 (let ((pane (current-window)))
904 (psetf (offset (mark pane)) (offset (point pane))
905 (offset (point pane)) (offset (mark pane)))))
906
907 (defun set-syntax (syntax)
908 (let* ((pane (current-window))
909 (buffer (buffer pane)))
910 (setf (syntax buffer) syntax)
911 (setf (offset (low-mark buffer)) 0
912 (offset (high-mark buffer)) (size buffer))))
913
914 (define-named-command com-set-syntax ()
915 (let* ((pane (current-window))
916 (buffer (buffer pane)))
917 (setf (syntax buffer)
918 (make-instance (or (accept 'syntax :prompt "Set Syntax")
919 (progn (beep)
920 (display-message "No such syntax")
921 (return-from com-set-syntax nil)))
922 :buffer (buffer (point pane))))
923 (setf (offset (low-mark buffer)) 0
924 (offset (high-mark buffer)) (size buffer))))
925
926 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
927 ;;;
928 ;;; Keyboard macros
929
930 (define-named-command com-start-kbd-macro ()
931 (setf (recordingp *application-frame*) t)
932 (setf (recorded-keys *application-frame*) '()))
933
934 (define-named-command com-end-kbd-macro ()
935 (setf (recordingp *application-frame*) nil)
936 (setf (recorded-keys *application-frame*)
937 ;; this won't work if the command was invoked in any old way
938 (reverse (cddr (recorded-keys *application-frame*)))))
939
940 (define-named-command com-call-last-kbd-macro ()
941 (setf (remaining-keys *application-frame*)
942 (recorded-keys *application-frame*))
943 (setf (executingp *application-frame*) t))
944
945 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
946 ;;;
947 ;;; Commands for splitting windows
948
949 (defun replace-constellation (constellation additional-constellation vertical-p)
950 (let* ((parent (sheet-parent constellation))
951 (children (sheet-children parent))
952 (first (first children))
953 (second (second children))
954 (third (third children))
955 (adjust (make-pane 'clim-extensions:box-adjuster-gadget)))
956 (assert (member constellation children))
957 (sheet-disown-child parent constellation)
958 (let ((new (if vertical-p
959 (vertically ()
960 constellation adjust additional-constellation)
961 (horizontally ()
962 constellation adjust additional-constellation))))
963 (sheet-adopt-child parent new)
964 (reorder-sheets parent
965 (if (eq constellation first)
966 (if third
967 (list new second third)
968 (list new second))
969 (if third
970 (list first second new)
971 (list first new)))))))
972
973 (defun parent3 (sheet)
974 (sheet-parent (sheet-parent (sheet-parent sheet))))
975
976 (defun make-pane-constellation ()
977 "make a vbox containing a scroller pane as its first child and an
978 info pane as its second child. The scroller pane contains a viewport
979 which contains an extended pane. Return the vbox and the extended pane
980 as two values"
981 (let* ((extended-pane
982 (make-pane 'extended-pane
983 :width 900 :height 400
984 :name 'win
985 :end-of-line-action :scroll
986 :incremental-redisplay t
987 :display-function 'display-win))
988 (vbox
989 (vertically ()
990 (scrolling () extended-pane)
991 (make-pane 'info-pane
992 :climacs-pane extended-pane
993 :width 900 :height 20
994 :max-height 20 :min-height 20
995 ::background +gray85+
996 :scroll-bars nil
997 :borders nil
998 :incremental-redisplay t
999 :display-function 'display-info))))
1000 (values vbox extended-pane)))
1001
1002 (define-named-command com-split-window-vertically ()
1003 (with-look-and-feel-realization
1004 ((frame-manager *application-frame*) *application-frame*)
1005 (multiple-value-bind (vbox new-pane) (make-pane-constellation)
1006 (let* ((current-window (current-window))
1007 (constellation-root (parent3 current-window)))
1008 (setf (point (buffer current-window)) (clone-mark (point current-window))
1009 (buffer new-pane) (buffer current-window)
1010 (auto-fill-mode new-pane) (auto-fill-mode current-window)
1011 (auto-fill-column new-pane) (auto-fill-column current-window))
1012 (push new-pane (windows *application-frame*))
1013 (replace-constellation constellation-root vbox t)
1014 (full-redisplay current-window)
1015 (full-redisplay new-pane)))))
1016
1017 (define-named-command com-split-window-horizontally ()
1018 (with-look-and-feel-realization
1019 ((frame-manager *application-frame*) *application-frame*)
1020 (multiple-value-bind (vbox new-pane) (make-pane-constellation)
1021 (let* ((current-window (current-window))
1022 (constellation-root (parent3 current-window)))
1023 (setf (point (buffer current-window)) (clone-mark (point current-window))
1024 (buffer new-pane) (buffer current-window)
1025 (auto-fill-mode new-pane) (auto-fill-mode current-window)
1026 (auto-fill-column new-pane) (auto-fill-column current-window))
1027 (push new-pane (windows *application-frame*))
1028 (replace-constellation constellation-root vbox nil)
1029 (full-redisplay current-window)
1030 (full-redisplay new-pane)))))
1031
1032 (define-named-command com-other-window ()
1033 (setf (windows *application-frame*)
1034 (append (cdr (windows *application-frame*))
1035 (list (car (windows *application-frame*))))))
1036
1037 (define-named-command com-single-window ()
1038 (loop until (null (cdr (windows *application-frame*)))
1039 do (rotatef (car (windows *application-frame*))
1040 (cadr (windows *application-frame*)))
1041 (com-delete-window)))
1042
1043 (define-named-command com-delete-window ()
1044 (unless (null (cdr (windows *application-frame*)))
1045 (let* ((constellation (parent3 (current-window)))
1046 (box (sheet-parent constellation))
1047 (box-children (sheet-children box))
1048 (other (if (eq constellation (first box-children))
1049 (third box-children)
1050 (first box-children)))
1051 (parent (sheet-parent box))
1052 (children (sheet-children parent))
1053 (first (first children))
1054 (second (second children))
1055 (third (third children)))
1056 (pop (windows *application-frame*))
1057 (sheet-disown-child box other)
1058 (sheet-disown-child parent box)
1059 (sheet-adopt-child parent other)
1060 (reorder-sheets parent (if (eq box first)
1061 (if third
1062 (list other second third)
1063 (list other second))
1064 (if third
1065 (list first second other)
1066 (list first other)))))))
1067
1068 ;;;;;;;;;;;;;;;;;;;;
1069 ;; Kill ring commands
1070
1071 ;; Copies an element from a kill-ring to a buffer at the given offset
1072 (define-named-command com-yank ()
1073 (insert-sequence (point (current-window)) (kill-ring-yank *kill-ring*)))
1074
1075 ;; Destructively cut a given buffer region into the kill-ring
1076 (define-named-command com-cut-out ()
1077 (let ((pane (current-window)))
1078 (kill-ring-standard-push
1079 *kill-ring* (region-to-sequence (mark pane) (point pane)))
1080 (delete-region (mark pane) (point pane))))
1081
1082 ;; Non destructively copies in buffer region to the kill ring
1083 (define-named-command com-copy-out ()
1084 (let ((pane (current-window)))
1085 (kill-ring-standard-push *kill-ring* (region-to-sequence (point pane) (mark pane)))))
1086
1087 (define-named-command com-rotate-yank ()
1088 (let* ((pane (current-window))
1089 (point (point pane))
1090 (last-yank (kill-ring-yank *kill-ring*)))
1091 (if (eq (previous-command pane)
1092 'com-rotate-yank)
1093 (progn
1094 (delete-range point (* -1 (length last-yank)))
1095 (rotate-yank-position *kill-ring*)))
1096 (insert-sequence point (kill-ring-yank *kill-ring*))))
1097
1098 (define-named-command com-resize-kill-ring ()
1099 (let ((size (handler-case (accept 'integer :prompt "New kill ring size")
1100 (error () (progn (beep)
1101 (display-message "Not a valid kill ring size")
1102 (return-from com-resize-kill-ring nil))))))
1103 (setf (kill-ring-max-size *kill-ring*) size)))
1104
1105 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1106 ;;;
1107 ;;; Incremental search
1108
1109 (defun isearch-command-loop (pane forwardp)
1110 (let ((point (point pane)))
1111 (unless (endp (isearch-states pane))
1112 (setf (isearch-previous-string pane)
1113 (search-string (first (isearch-states pane)))))
1114 (setf (isearch-mode pane) t)
1115 (setf (isearch-states pane)
1116 (list (make-instance 'isearch-state
1117 :search-string ""
1118 :search-mark (clone-mark point)
1119 :search-forward-p forwardp
1120 :search-success-p t)))
1121 (simple-command-loop 'isearch-climacs-table
1122 (isearch-mode pane)
1123 ((setf (isearch-mode pane) nil)))))
1124
1125 (defun isearch-from-mark (pane mark string forwardp)
1126 (flet ((object-equal (x y)
1127 (if (characterp x)
1128 (and (characterp y) (char-equal x y))
1129 (eql x y))))
1130 (let* ((point (point pane))
1131 (mark2 (clone-mark mark))
1132 (success (funcall (if forwardp #'search-forward #'search-backward)
1133 mark2
1134 string
1135 :test #'object-equal)))
1136 (when success
1137 (setf (offset point) (offset mark2)
1138 (offset mark) (if forwardp
1139 (- (offset mark2) (length string))
1140 (+ (offset mark2) (length string)))))
1141 (display-message "~:[Failing ~;~]Isearch~:[ backward~;~]: ~A"
1142 success forwardp string)
1143 (push (make-instance 'isearch-state
1144 :search-string string
1145 :search-mark mark
1146 :search-forward-p forwardp
1147 :search-success-p success)
1148 (isearch-states pane))
1149 (unless success
1150 (beep)))))
1151
1152 (define-named-command com-isearch-mode-forward ()
1153 (display-message "Isearch: ")
1154 (isearch-command-loop (current-window) t))
1155
1156 (define-named-command com-isearch-mode-backward ()
1157 (display-message "Isearch backward: ")
1158 (isearch-command-loop (current-window) nil))
1159
1160 (define-named-command com-isearch-append-char ()
1161 (let* ((pane (current-window))
1162 (states (isearch-states pane))
1163 (string (concatenate 'string
1164 (search-string (first states))
1165 (string *current-gesture*)))
1166 (mark (clone-mark (search-mark (first states))))
1167 (forwardp (search-forward-p (first states))))
1168 (unless forwardp
1169 (incf (offset mark)))
1170 (isearch-from-mark pane mark string forwardp)))
1171
1172 (define-named-command com-isearch-delete-char ()
1173 (let* ((pane (current-window)))
1174 (cond ((null (second (isearch-states pane)))
1175 (display-message "Isearch: ")
1176 (beep))
1177 (t
1178 (pop (isearch-states pane))
1179 (loop until (endp (rest (isearch-states pane)))
1180 until (search-success-p (first (isearch-states pane)))
1181 do (pop (isearch-states pane)))
1182 (let ((state (first (isearch-states pane))))
1183 (setf (offset (point pane))
1184 (if (search-forward-p state)
1185 (+ (offset (search-mark state))
1186 (length (search-string state)))
1187 (- (offset (search-mark state))
1188 (length (search-string state)))))
1189 (display-message "Isearch~:[ backward~;~]: ~A"
1190 (search-forward-p state)
1191 (search-string state)))))))
1192
1193 (define-named-command com-isearch-forward ()
1194 (let* ((pane (current-window))
1195 (point (point pane))
1196 (states (isearch-states pane))
1197 (string (if (null (second states))
1198 (isearch-previous-string pane)
1199 (search-string (first states))))
1200 (mark (clone-mark point)))
1201 (isearch-from-mark pane mark string t)))
1202
1203 (define-named-command com-isearch-backward ()
1204 (let* ((pane (current-window))
1205 (point (point pane))
1206 (states (isearch-states pane))
1207 (string (if (null (second states))
1208 (isearch-previous-string pane)
1209 (search-string (first states))))
1210 (mark (clone-mark point)))
1211 (isearch-from-mark pane mark string nil)))
1212
1213 (define-named-command com-isearch-exit ()
1214 (setf (isearch-mode (current-window)) nil))
1215
1216 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1217 ;;;
1218 ;;; Query replace
1219
1220 (defun query-replace-find-next-match (mark string)
1221 (flet ((object-equal (x y)
1222 (and (characterp x)
1223 (characterp y)
1224 (char-equal x y))))
1225 (let ((offset-before (offset mark)))
1226 (search-forward mark string :test #'object-equal)
1227 (/= (offset mark) offset-before))))
1228
1229 (define-named-command com-query-replace ()
1230 (let* ((pane (current-window))
1231 (old-state (query-replace-state pane))
1232 (old-string1 (when old-state (string1 old-state)))
1233 (old-string2 (when old-state (string2 old-state)))
1234 (string1 (handler-case
1235 (if old-string1
1236 (accept 'string
1237 :prompt "Query Replace"
1238 :default old-string1
1239 :default-type 'string)
1240 (accept 'string :prompt "Query Replace"))
1241 (error () (progn (beep)
1242 (display-message "Empty string")
1243 (return-from com-query-replace nil)))))
1244 (string2 (handler-case
1245 (if old-string2
1246 (accept 'string
1247 :prompt (format nil "Query Replace ~A with"
1248 string1)
1249 :default old-string2
1250 :default-type 'string)
1251 (accept 'string
1252 :prompt (format nil "Query Replace ~A with" string1)))
1253 (error () (progn (beep)
1254 (display-message "Empty string")
1255 (return-from com-query-replace nil)))))
1256 (point (point pane))
1257 (occurrences 0))
1258 (declare (special string1 string2 occurrences))
1259 (when (query-replace-find-next-match point string1)
1260 (setf (query-replace-state pane) (make-instance 'query-replace-state
1261 :string1 string1
1262 :string2 string2)
1263 (query-replace-mode pane) t)
1264 (display-message "Query Replace ~A with ~A:"
1265 string1 string2)
1266 (simple-command-loop 'query-replace-climacs-table
1267 (query-replace-mode pane)
1268 ((setf (query-replace-mode pane) nil))))
1269 (display-message "Replaced ~A occurrence~:P" occurrences)))
1270
1271 (define-named-command com-query-replace-replace ()
1272 (declare (special string1 string2 occurrences))
1273 (let* ((pane (current-window))
1274 (point (point pane))
1275 (buffer (buffer pane))
1276 (string1-length (length string1)))
1277 (backward-object point string1-length)
1278 (let* ((offset1 (offset point))
1279 (offset2 (+ offset1 string1-length))
1280 (region-case (buffer-region-case buffer offset1 offset2)))
1281 (delete-range point string1-length)
1282 (insert-sequence point string2)
1283 (setf offset2 (+ offset1 (length string2)))
1284 (finish-output *error-output*)
1285 (case region-case
1286 (:upper-case (upcase-buffer-region buffer offset1 offset2))
1287 (:lower-case (downcase-buffer-region buffer offset1 offset2))
1288 (:capitalized (capitalize-buffer-region buffer offset1 offset2))))
1289 (incf occurrences)
1290 (if (query-replace-find-next-match point string1)
1291 (display-message "Query Replace ~A with ~A:"
1292 string1 string2)
1293 (setf (query-replace-mode pane) nil))))
1294
1295 (define-named-command com-query-replace-skip ()
1296 (declare (special string1 string2))
1297 (let* ((pane (current-window))
1298 (point (point pane)))
1299 (if (query-replace-find-next-match point string1)
1300 (display-message "Query Replace ~A with ~A:"
1301 string1 string2)
1302 (setf (query-replace-mode pane) nil))))
1303
1304 (define-named-command com-query-replace-exit ()
1305 (setf (query-replace-mode (current-window)) nil))
1306
1307 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1308 ;;;
1309 ;;; Undo/redo
1310
1311 (define-named-command com-undo ()
1312 (undo (undo-tree (buffer (current-window))))
1313 (full-redisplay (current-window)))
1314
1315 (define-named-command com-redo ()
1316 (redo (undo-tree (buffer (current-window))))
1317 (full-redisplay (current-window)))
1318
1319 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1320 ;;;
1321 ;;; Dynamic abbrevs
1322
1323 (define-named-command com-dabbrev-expand ()
1324 (let* ((win (current-window))
1325 (point (point win)))
1326 (with-slots (original-prefix prefix-start-offset dabbrev-expansion-mark) win
1327 (flet ((move () (cond ((beginning-of-buffer-p dabbrev-expansion-mark)
1328 (setf (offset dabbrev-expansion-mark)
1329 (offset point))
1330 (forward-word dabbrev-expansion-mark))
1331 ((mark< dabbrev-expansion-mark point)
1332 (backward-object dabbrev-expansion-mark))
1333 (t (forward-object dabbrev-expansion-mark)))))
1334 (unless (or (beginning-of-buffer-p point)
1335 (not (constituentp (object-before point))))
1336 (unless (and (eq (previous-command win) 'com-dabbrev-expand)
1337 (not (null prefix-start-offset)))
1338 (setf dabbrev-expansion-mark (clone-mark point))
1339 (backward-word dabbrev-expansion-mark)
1340 (setf prefix-start-offset (offset dabbrev-expansion-mark))
1341 (setf original-prefix (region-to-sequence prefix-start-offset point))
1342 (move))
1343 (loop until (or (end-of-buffer-p dabbrev-expansion-mark)
1344 (and (or (beginning-of-buffer-p dabbrev-expansion-mark)
1345 (not (constituentp (object-before dabbrev-expansion-mark))))
1346 (looking-at dabbrev-expansion-mark original-prefix)))
1347 do (move))
1348 (if (end-of-buffer-p dabbrev-expansion-mark)
1349 (progn (delete-region prefix-start-offset point)
1350 (insert-sequence point original-prefix)
1351 (setf prefix-start-offset nil))
1352 (progn (delete-region prefix-start-offset point)
1353 (insert-sequence point
1354 (let ((offset (offset dabbrev-expansion-mark)))
1355 (prog2 (forward-word dabbrev-expansion-mark)
1356 (region-to-sequence offset dabbrev-expansion-mark)
1357 (setf (offset dabbrev-expansion-mark) offset))))
1358 (move))))))))
1359
1360 (define-named-command com-beginning-of-paragraph ()
1361 (let* ((pane (current-window))
1362 (point (point pane))
1363 (syntax (syntax (buffer pane))))
1364 (beginning-of-paragraph point syntax)))
1365
1366 (define-named-command com-end-of-paragraph ()
1367 (let* ((pane (current-window))
1368 (point (point pane))
1369 (syntax (syntax (buffer pane))))
1370 (end-of-paragraph point syntax)))
1371
1372 (define-named-command com-eval-expression ((insertp 'boolean :prompt "Insert?"))
1373 (let* ((*package* (find-package :climacs-gui))
1374 (string (handler-case (accept 'string :prompt "Eval")
1375 (error () (progn (beep)
1376 (display-message "Empty string")
1377 (return-from com-eval-expression nil)))))
1378 (result (format nil "~a"
1379 (handler-case (eval (read-from-string string))
1380 (error (condition) (progn (beep)
1381 (display-message "~a" condition)
1382 (return-from com-eval-expression nil)))))))
1383 (if insertp
1384 (insert-sequence (point (current-window)) result)
1385 (display-message result))))
1386
1387 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1388 ;;;
1389 ;;; For testing purposes
1390
1391 (define-named-command com-reset-profile ()
1392 #+sbcl (sb-profile:reset)
1393 #-sbcl nil)
1394
1395 (define-named-command com-report-profile ()
1396 #+sbcl (sb-profile:report)
1397 #-sbcl nil)
1398
1399 (define-named-command com-recompile ()
1400 (asdf:operate 'asdf:load-op :climacs))
1401
1402 (define-named-command com-backward-expression ((count 'integer :prompt "Number of expressions"))
1403 (declare (ignore count))
1404 (let* ((pane (current-window))
1405 (point (point pane))
1406 (syntax (syntax (buffer pane))))
1407 (backward-expression point syntax)))
1408
1409 (define-named-command com-forward-expression ((count 'integer :prompt "Number of expresssions"))
1410 (declare (ignore count))
1411 (let* ((pane (current-window))
1412 (point (point pane))
1413 (syntax (syntax (buffer pane))))
1414 (forward-expression point syntax)))
1415
1416 (define-named-command com-eval-defun ()
1417 (let* ((pane (current-window))
1418 (point (point pane))
1419 (syntax (syntax (buffer pane))))
1420 (eval-defun point syntax)))
1421
1422 (define-named-command com-package ()
1423 (let* ((pane (current-window))
1424 (syntax (syntax (buffer pane)))
1425 (package (climacs-lisp-syntax::package-of syntax)))
1426 (display-message (format nil "~s" package))))
1427
1428 (define-named-command com-accept-string ()
1429 (display-message (format nil "~s" (accept 'string))))
1430
1431 (define-named-command com-accept-symbol ()
1432 (display-message (format nil "~s" (accept 'symbol))))
1433
1434 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1435 ;;;
1436 ;;; Global and dead-escape command tables
1437
1438 (make-command-table 'global-climacs-table :errorp nil)
1439
1440 (make-command-table 'dead-escape-climacs-table :errorp nil)
1441
1442 (add-menu-item-to-command-table 'global-climacs-table "dead-escape"
1443 :menu 'dead-escape-climacs-table
1444 :keystroke '(:escape))
1445
1446 (defun dead-escape-set-key (gesture command)
1447 (add-command-to-command-table command 'dead-escape-climacs-table
1448 :keystroke gesture :errorp nil))
1449
1450 (defun global-set-key (gesture command)
1451 (add-command-to-command-table command 'global-climacs-table
1452 :keystroke gesture :errorp nil)
1453 (when (and
1454 (listp gesture)
1455 (find :meta gesture))
1456 (dead-escape-set-key (remove :meta gesture) command)))
1457
1458 (loop for code from (char-code #\Space) to (char-code #\~)
1459 do (global-set-key (code-char code) 'com-self-insert))
1460
1461 (global-set-key #\Newline 'com-self-insert)
1462 (global-set-key #\Tab 'com-indent-line)
1463 (global-set-key '(#\: :shift :meta) `(com-eval-expression ,*numeric-argument-p*))
1464 (global-set-key '(#\j :control) 'com-newline-and-indent)
1465 (global-set-key '(#\f :control) `(com-forward-object ,*numeric-argument-marker*))
1466 (global-set-key '(#\b :control) `(com-backward-object ,*numeric-argument-marker*))
1467 (global-set-key '(#\a :control) 'com-beginning-of-line)
1468 (global-set-key '(#\e :control) 'com-end-of-line)
1469 (global-set-key '(#\d :control) `(com-delete-object ,*numeric-argument-marker*))
1470 (global-set-key '(#\p :control) `(com-previous-line ,*numeric-argument-marker*))
1471 (global-set-key '(#\l :control) 'com-full-redisplay)
1472 (global-set-key '(#\n :control) `(com-next-line ,*numeric-argument-marker*))
1473 (global-set-key '(#\o :control) `(com-open-line ,*numeric-argument-marker*))
1474 (global-set-key '(#\k :control) `(com-kill-line ,*numeric-argument-marker* ,*numeric-argument-p*))
1475 (global-set-key '(#\t :control) 'com-transpose-objects)
1476 (global-set-key '(#\Space :control) 'com-set-mark)
1477 (global-set-key '(#\y :control) 'com-yank)
1478 (global-set-key '(#\w :control) 'com-cut-out)
1479 (global-set-key '(#\f :meta) `(com-forward-word ,*numeric-argument-marker*))
1480 (global-set-key '(#\b :meta) `(com-backward-word ,*numeric-argument-marker*))
1481 (global-set-key '(#\t :meta) 'com-transpose-words)
1482 (global-set-key '(#\u :meta) 'com-upcase-word)
1483 (global-set-key '(#\l :meta) 'com-downcase-word)
1484 (global-set-key '(#\c :meta) 'com-capitalize-word)
1485 (global-set-key '(#\x :meta) 'com-extended-command)
1486 (global-set-key '(#\y :meta) 'com-rotate-yank)
1487 (global-set-key '(#\w :meta) 'com-copy-out)
1488 (global-set-key '(#\v :control) 'com-page-down)
1489 (global-set-key '(#\v :meta) 'com-page-up)
1490 (global-set-key '(#\< :shift :meta) 'com-beginning-of-buffer)
1491 (global-set-key '(#\> :shift :meta) 'com-end-of-buffer)
1492 (global-set-key '(#\m :meta) 'com-back-to-indentation)
1493 (global-set-key '(#\^ :shift :meta) 'com-delete-indentation)
1494 (global-set-key '(#\q :meta) 'com-fill-paragraph)
1495 (global-set-key '(#\d :meta) `(com-delete-word ,*numeric-argument-marker*))
1496 (global-set-key '(#\Backspace :meta) `(com-backward-delete-word ,*numeric-argument-marker*))
1497 (global-set-key '(#\/ :meta) 'com-dabbrev-expand)
1498 (global-set-key '(#\a :control :meta) 'com-beginning-of-paragraph)
1499 (global-set-key '(#\e :control :meta) 'com-end-of-paragraph)
1500 (global-set-key '(#\s :control) 'com-isearch-mode-forward)
1501 (global-set-key '(#\r :control) 'com-isearch-mode-backward)
1502 (global-set-key '(#\% :shift :meta) 'com-query-replace)
1503
1504 (global-set-key '(:up) `(com-previous-line ,*numeric-argument-marker*))
1505 (global-set-key '(:down) `(com-next-line ,*numeric-argument-marker*))
1506 (global-set-key '(:left) `(com-backward-object ,*numeric-argument-marker*))
1507 (global-set-key '(:right) `(com-forward-object ,*numeric-argument-marker*))
1508 (global-set-key '(:left :control) `(com-backward-word ,*numeric-argument-marker*))
1509 (global-set-key '(:right :control) `(com-forward-word ,*numeric-argument-marker*))
1510 (global-set-key '(:home) 'com-beginning-of-line)
1511 (global-set-key '(:end) 'com-end-of-line)
1512 (global-set-key '(:prior) 'com-page-up)
1513 (global-set-key '(:next) 'com-page-down)
1514 (global-set-key '(:home :control) 'com-beginning-of-buffer)
1515 (global-set-key '(:end :control) 'com-end-of-buffer)
1516 (global-set-key #\Rubout `(com-delete-object ,*numeric-argument-marker*))
1517 (global-set-key #\Backspace `(com-backward-delete-object ,*numeric-argument-marker*))
1518
1519 (global-set-key '(:insert) 'com-toggle-overwrite-mode)
1520
1521 (global-set-key '(#\b :control :meta) `(com-backward-expression ,*numeric-argument-marker*))
1522 (global-set-key '(#\f :control :meta) `(com-forward-expression ,*numeric-argument-marker*))
1523 (global-set-key '(#\x :control :meta) '(com-eval-defun))
1524
1525 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1526 ;;;
1527 ;;; C-x command table
1528
1529 (make-command-table 'c-x-climacs-table :errorp nil)
1530
1531 (add-menu-item-to-command-table 'global-climacs-table "C-x"
1532 :menu 'c-x-climacs-table
1533 :keystroke '(#\x :control))
1534
1535 (defun c-x-set-key (gesture command)
1536 (add-command-to-command-table command 'c-x-climacs-table
1537 :keystroke gesture :errorp nil))
1538
1539 (c-x-set-key '(#\0) 'com-delete-window)
1540 (c-x-set-key '(#\1) 'com-single-window)
1541 (c-x-set-key '(#\2) 'com-split-window-vertically)
1542 (c-x-set-key '(#\3) 'com-split-window-horizontally)
1543 (c-x-set-key '(#\() 'com-start-kbd-macro)
1544 (c-x-set-key '(#\)) 'com-end-kbd-macro)
1545 (c-x-set-key '(#\b) 'com-switch-to-buffer)
1546 (c-x-set-key '(#\e) 'com-call-last-kbd-macro)
1547 (c-x-set-key '(#\c :control) 'com-quit)
1548 (c-x-set-key '(#\f :control) 'com-find-file)
1549 (c-x-set-key '(#\i) 'com-insert-file)
1550 (c-x-set-key '(#\k) 'com-kill-buffer)
1551 (c-x-set-key '(#\l :control) 'com-load-file)
1552 (c-x-set-key '(#\o) 'com-other-window)
1553 (c-x-set-key '(#\r) 'com-redo)
1554 (c-x-set-key '(#\u) 'com-undo)
1555 (c-x-set-key '(#\s :control) 'com-save-buffer)
1556 (c-x-set-key '(#\t :control) 'com-transpose-lines)
1557 (c-x-set-key '(#\w :control) 'com-write-buffer)
1558 (c-x-set-key '(#\x :control) 'com-exchange-point-and-mark)
1559
1560 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1561 ;;;
1562 ;;; Some Unicode stuff
1563
1564 (define-named-command com-insert-charcode ((code 'integer :prompt "Code point"))
1565 (insert-object (point (current-window)) (code-char code)))
1566
1567 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1568 ;;;
1569 ;;; Dead-acute command table
1570
1571 (make-command-table 'dead-acute-climacs-table :errorp nil)
1572
1573 (add-menu-item-to-command-table 'global-climacs-table "dead-acute"
1574 :menu 'dead-acute-climacs-table
1575 :keystroke '(:dead--acute))
1576
1577 (defun dead-acute-set-key (gesture command)
1578 (add-command-to-command-table command 'dead-acute-climacs-table
1579 :keystroke gesture :errorp nil))
1580
1581 (dead-acute-set-key '(#\A) '(com-insert-charcode 193))
1582 (dead-acute-set-key '(#\E) '(com-insert-charcode 201))
1583 (dead-acute-set-key '(#\I) '(com-insert-charcode 205))
1584 (dead-acute-set-key '(#\O) '(com-insert-charcode 211))
1585 (dead-acute-set-key '(#\U) '(com-insert-charcode 218))
1586 (dead-acute-set-key '(#\Y) '(com-insert-charcode 221))
1587 (dead-acute-set-key '(#\a) '(com-insert-charcode 225))
1588 (dead-acute-set-key '(#\e) '(com-insert-charcode 233))
1589 (dead-acute-set-key '(#\i) '(com-insert-charcode 237))
1590 (dead-acute-set-key '(#\o) '(com-insert-charcode 243))
1591 (dead-acute-set-key '(#\u) '(com-insert-charcode 250))
1592 (dead-acute-set-key '(#\y) '(com-insert-charcode 253))
1593 (dead-acute-set-key '(#\C) '(com-insert-charcode 199))
1594 (dead-acute-set-key '(#\c) '(com-insert-charcode 231))
1595 (dead-acute-set-key '(#\x) '(com-insert-charcode 215))
1596 (dead-acute-set-key '(#\-) '(com-insert-charcode 247))
1597 (dead-acute-set-key '(#\T) '(com-insert-charcode 222))
1598 (dead-acute-set-key '(#\t) '(com-insert-charcode 254))
1599 (dead-acute-set-key '(#\s) '(com-insert-charcode 223))
1600 (dead-acute-set-key '(#\Space) '(com-insert-charcode 39))
1601
1602 (make-command-table 'dead-acute-dead-accute-climacs-table :errorp nil)
1603
1604 (add-menu-item-to-command-table 'dead-acute-climacs-table "dead-acute-dead-accute"
1605 :menu 'dead-acute-dead-accute-climacs-table
1606 :keystroke '(:dead--acute))
1607
1608 (defun dead-acute-dead-accute-set-key (gesture command)
1609 (add-command-to-command-table command 'dead-acute-dead-accute-climacs-table
1610 :keystroke gesture :errorp nil))
1611
1612 (dead-acute-dead-accute-set-key '(#\A) '(com-insert-charcode 197))
1613 (dead-acute-dead-accute-set-key '(#\a) '(com-insert-charcode 229))
1614 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1615 ;;;
1616 ;;; Dead-grave command table
1617
1618 (make-command-table 'dead-grave-climacs-table :errorp nil)
1619
1620 (add-menu-item-to-command-table 'global-climacs-table "dead-grave"
1621 :menu 'dead-grave-climacs-table
1622 :keystroke '(:dead--grave))
1623
1624 (defun dead-grave-set-key (gesture command)
1625 (add-command-to-command-table command 'dead-grave-climacs-table
1626 :keystroke gesture :errorp nil))
1627
1628 (dead-grave-set-key '(#\A) '(com-insert-charcode 192))
1629 (dead-grave-set-key '(#\E) '(com-insert-charcode 200))
1630 (dead-grave-set-key '(#\I) '(com-insert-charcode 204))
1631 (dead-grave-set-key '(#\O) '(com-insert-charcode 210))
1632 (dead-grave-set-key '(#\U) '(com-insert-charcode 217))
1633 (dead-grave-set-key '(#\a) '(com-insert-charcode 224))
1634 (dead-grave-set-key '(#\e) '(com-insert-charcode 232))
1635 (dead-grave-set-key '(#\i) '(com-insert-charcode 236))
1636 (dead-grave-set-key '(#\o) '(com-insert-charcode 242))
1637 (dead-grave-set-key '(#\u) '(com-insert-charcode 249))
1638 (dead-grave-set-key '(#\Space) '(com-insert-charcode 96))
1639
1640 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1641 ;;;
1642 ;;; Dead-diaeresis command table
1643
1644 (make-command-table 'dead-diaeresis-climacs-table :errorp nil)
1645
1646 (add-menu-item-to-command-table 'global-climacs-table "dead-diaeresis"
1647 :menu 'dead-diaeresis-climacs-table
1648 :keystroke '(:dead--diaeresis :shift))
1649
1650 (defun dead-diaeresis-set-key (gesture command)
1651 (add-command-to-command-table command 'dead-diaeresis-climacs-table
1652 :keystroke gesture :errorp nil))
1653
1654 (dead-diaeresis-set-key '(#\A) '(com-insert-charcode 196))
1655 (dead-diaeresis-set-key '(#\E) '(com-insert-charcode 203))
1656 (dead-diaeresis-set-key '(#\I) '(com-insert-charcode 207))
1657 (dead-diaeresis-set-key '(#\O) '(com-insert-charcode 214))
1658 (dead-diaeresis-set-key '(#\U) '(com-insert-charcode 220))
1659 (dead-diaeresis-set-key '(#\a) '(com-insert-charcode 228))
1660 (dead-diaeresis-set-key '(#\e) '(com-insert-charcode 235))
1661 (dead-diaeresis-set-key '(#\i) '(com-insert-charcode 239))
1662 (dead-diaeresis-set-key '(#\o) '(com-insert-charcode 246))
1663 (dead-diaeresis-set-key '(#\u) '(com-insert-charcode 252))
1664 (dead-diaeresis-set-key '(#\y) '(com-insert-charcode 255))
1665 (dead-diaeresis-set-key '(#\Space) '(com-insert-charcode 34))
1666
1667 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1668 ;;;
1669 ;;; Dead-tilde command table
1670
1671 (make-command-table 'dead-tilde-climacs-table :errorp nil)
1672
1673 (add-menu-item-to-command-table 'global-climacs-table "dead-tilde"
1674 :menu 'dead-tilde-climacs-table
1675 :keystroke '(:dead--tilde :shift))
1676
1677 (defun dead-tilde-set-key (gesture command)
1678 (add-command-to-command-table command 'dead-tilde-climacs-table
1679 :keystroke gesture :errorp nil))
1680
1681 (dead-tilde-set-key '(#\A) '(com-insert-charcode 195))
1682 (dead-tilde-set-key '(#\N) '(com-insert-charcode 209))
1683 (dead-tilde-set-key '(#\a) '(com-insert-charcode 227))
1684 (dead-tilde-set-key '(#\n) '(com-insert-charcode 241))
1685 (dead-tilde-set-key '(#\E) '(com-insert-charcode 198))
1686 (dead-tilde-set-key '(#\e) '(com-insert-charcode 230))
1687 (dead-tilde-set-key '(#\D) '(com-insert-charcode 208))
1688 (dead-tilde-set-key '(#\d) '(com-insert-charcode 240))
1689 (dead-tilde-set-key '(#\O) '(com-insert-charcode 216))
1690 (dead-tilde-set-key '(#\o) '(com-insert-charcode 248))
1691 (dead-tilde-set-key '(#\Space) '(com-insert-charcode 126))
1692
1693 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1694 ;;;
1695 ;;; Dead-circumflex command table
1696
1697 (make-command-table 'dead-circumflex-climacs-table :errorp nil)
1698
1699 (add-menu-item-to-command-table 'global-climacs-table "dead-circumflex"
1700 :menu 'dead-circumflex-climacs-table
1701 :keystroke '(:dead--circumflex :shift))
1702
1703 (defun dead-circumflex-set-key (gesture command)
1704 (add-command-to-command-table command 'dead-circumflex-climacs-table
1705 :keystroke gesture :errorp nil))
1706
1707 (dead-circumflex-set-key '(#\A) '(com-insert-charcode 194))
1708 (dead-circumflex-set-key '(#\E) '(com-insert-charcode 202))
1709 (dead-circumflex-set-key '(#\I) '(com-insert-charcode 206))
1710 (dead-circumflex-set-key '(#\O) '(com-insert-charcode 212))
1711 (dead-circumflex-set-key '(#\U) '(com-insert-charcode 219))
1712 (dead-circumflex-set-key '(#\a) '(com-insert-charcode 226))
1713 (dead-circumflex-set-key '(#\e) '(com-insert-charcode 234))
1714 (dead-circumflex-set-key '(#\i) '(com-insert-charcode 238))
1715 (dead-circumflex-set-key '(#\o) '(com-insert-charcode 244))
1716 (dead-circumflex-set-key '(#\u) '(com-insert-charcode 251))
1717 (dead-circumflex-set-key '(#\Space) '(com-insert-charcode 94))
1718
1719 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1720 ;;;
1721 ;;; Isearch command table
1722
1723 (make-command-table 'isearch-climacs-table :errorp nil)
1724
1725 (defun isearch-set-key (gesture command)
1726 (add-command-to-command-table command 'isearch-climacs-table
1727 :keystroke gesture :errorp nil))
1728
1729 (loop for code from (char-code #\Space) to (char-code #\~)
1730 do (isearch-set-key (code-char code) 'com-isearch-append-char))
1731
1732 (isearch-set-key '(#\Newline) 'com-isearch-exit)
1733 (isearch-set-key '(#\Backspace) 'com-isearch-delete-char)
1734 (isearch-set-key '(#\s :control) 'com-isearch-forward)
1735 (isearch-set-key '(#\r :control) 'com-isearch-backward)
1736
1737 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1738 ;;;
1739 ;;; Query replace command table
1740
1741 (make-command-table 'query-replace-climacs-table :errorp nil)
1742
1743 (defun query-replace-set-key (gesture command)
1744 (add-command-to-command-table command 'query-replace-climacs-table
1745 :keystroke gesture :errorp nil))
1746
1747 (query-replace-set-key '(#\Newline) 'com-query-replace-exit)
1748 (query-replace-set-key '(#\Space) 'com-query-replace-replace)
1749 (query-replace-set-key '(#\Backspace) 'com-query-replace-skip)
1750 (query-replace-set-key '(#\Rubout) 'com-query-replace-skip)
1751 (query-replace-set-key '(#\q) 'com-query-replace-exit)
1752 (query-replace-set-key '(#\y) 'com-query-replace-replace)
1753 (query-replace-set-key '(#\n) 'com-query-replace-skip)

  ViewVC Help
Powered by ViewVC 1.1.5