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

Contents of /climacs/gui.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.89 - (hide annotations)
Thu Jan 20 19:12:48 2005 UTC (9 years, 3 months ago) by mvilleneuve
Branch: MAIN
Changes since 1.88: +19 -19 lines
Fixed bug in fill-line with words longer than fill-column
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     (defmethod redisplay-frame-panes :around ((frame climacs) &rest args)
92 rstrandh 1.70 (declare (ignore args))
93 rstrandh 1.83 (let ((buffers (remove-duplicates (mapcar #'buffer (windows frame)))))
94     (loop for buffer in buffers
95     do (update-syntax buffer (syntax buffer)))
96 rstrandh 1.80 (call-next-method)
97 rstrandh 1.83 (loop for buffer in buffers
98     do (clear-modify buffer))))
99 rstrandh 1.28
100 ejohnson 1.27 (defun climacs ()
101     "Starts up a climacs session"
102     (let ((frame (make-application-frame 'climacs)))
103     (run-frame-top-level frame)))
104    
105 rstrandh 1.30 (defun display-message (format-string &rest format-args)
106     (apply #'format *standard-input* format-string format-args))
107    
108 ejohnson 1.27 (defun display-info (frame pane)
109 rstrandh 1.81 (declare (ignore frame))
110     (with-slots (climacs-pane) pane
111     (let* ((buf (buffer climacs-pane))
112 mvilleneuve 1.86 (name-info (format nil " ~a ~a Syntax: ~a~a~a ~a"
113 rstrandh 1.81 (if (needs-saving buf) "**" "--")
114     (name buf)
115     (name (syntax buf))
116     (if (slot-value climacs-pane 'overwrite-mode)
117 mvilleneuve 1.86 " Ovwrt"
118 rstrandh 1.85 "")
119 mvilleneuve 1.86 (if (auto-fill-mode buf)
120     " Fill"
121     "")
122 rstrandh 1.85 (if (recordingp *application-frame*)
123     "Def"
124 rstrandh 1.81 ""))))
125     (princ name-info pane))))
126 ejohnson 1.27
127     (defun display-win (frame pane)
128     "The display function used by the climacs application frame."
129     (declare (ignore frame))
130 rstrandh 1.83 (redisplay-pane pane (eq pane (car (windows *application-frame*)))))
131 ejohnson 1.27
132     (defun find-gestures (gestures start-table)
133     (loop with table = (find-command-table start-table)
134     for (gesture . rest) on gestures
135     for item = (find-keystroke-item gesture table :errorp nil)
136     while item
137     do (if (eq (command-menu-item-type item) :command)
138     (return (if (null rest) item nil))
139     (setf table (command-menu-item-value item)))
140     finally (return item)))
141    
142 ejohnson 1.50 (defvar *kill-ring* (make-instance 'kill-ring :max-size 7))
143 ejohnson 1.27 (defparameter *current-gesture* nil)
144    
145 rstrandh 1.36 (defun meta-digit (gesture)
146     (position gesture
147     '((#\0 :meta) (#\1 :meta) (#\2 :meta) (#\3 :meta) (#\4 :meta)
148     (#\5 :meta) (#\6 :meta) (#\7 :meta) (#\8 :meta) (#\9 :meta))
149     :test #'event-matches-gesture-name-p))
150    
151 rstrandh 1.47 (defun climacs-read-gesture ()
152 rstrandh 1.85 (unless (null (remaining-keys *application-frame*))
153     (return-from climacs-read-gesture
154     (pop (remaining-keys *application-frame*))))
155 rstrandh 1.47 (loop for gesture = (read-gesture :stream *standard-input*)
156 rstrandh 1.85 when (event-matches-gesture-name-p gesture '(:keyboard #\g 512)) ; FIXME
157 rstrandh 1.47 do (throw 'outer-loop nil)
158     until (or (characterp gesture)
159     (and (typep gesture 'keyboard-event)
160     (or (keyboard-event-character gesture)
161     (not (member (keyboard-event-key-name
162     gesture)
163     '(:control-left :control-right
164     :shift-left :shift-right
165     :meta-left :meta-right
166     :super-left :super-right
167     :hyper-left :hyper-right
168     :shift-lock :caps-lock
169     :alt-left :alt-right))))))
170 rstrandh 1.85 finally (progn (when (recordingp *application-frame*)
171     (push gesture (recorded-keys *application-frame*)))
172     (return gesture))))
173    
174     (defun climacs-unread-gesture (gesture stream)
175     (cond ((recordingp *application-frame*)
176 rstrandh 1.88 (pop (recorded-keys *application-frame*))
177     (unread-gesture gesture :stream stream))
178 rstrandh 1.85 ((executingp *application-frame*)
179 rstrandh 1.88 (push gesture (remaining-keys *application-frame*)))
180     (t
181     (unread-gesture gesture :stream stream))))
182 rstrandh 1.47
183 rstrandh 1.36 (defun read-numeric-argument (&key (stream *standard-input*))
184 rstrandh 1.47 (let ((gesture (climacs-read-gesture)))
185 rstrandh 1.62 (cond ((event-matches-gesture-name-p gesture '(:keyboard #\u 512)) ; FIXME
186 rstrandh 1.36 (let ((numarg 4))
187 rstrandh 1.47 (loop for gesture = (climacs-read-gesture)
188 rstrandh 1.62 while (event-matches-gesture-name-p gesture '(:keyboard #\u 512)) ; FIXME
189 rstrandh 1.36 do (setf numarg (* 4 numarg))
190 rstrandh 1.85 finally (climacs-unread-gesture gesture stream))
191 rstrandh 1.47 (let ((gesture (climacs-read-gesture)))
192 rstrandh 1.36 (cond ((and (characterp gesture)
193     (digit-char-p gesture 10))
194     (setf numarg (- (char-code gesture) (char-code #\0)))
195 rstrandh 1.47 (loop for gesture = (climacs-read-gesture)
196 rstrandh 1.36 while (and (characterp gesture)
197     (digit-char-p gesture 10))
198 rstrandh 1.62 do (setf numarg (+ (* 10 numarg)
199     (- (char-code gesture) (char-code #\0))))
200 rstrandh 1.85 finally (climacs-unread-gesture gesture stream)
201 rstrandh 1.36 (return (values numarg t))))
202     (t
203 rstrandh 1.85 (climacs-unread-gesture gesture stream)
204 rstrandh 1.36 (values numarg t))))))
205     ((meta-digit gesture)
206     (let ((numarg (meta-digit gesture)))
207 rstrandh 1.47 (loop for gesture = (climacs-read-gesture)
208 rstrandh 1.36 while (meta-digit gesture)
209     do (setf numarg (+ (* 10 numarg) (meta-digit gesture)))
210 rstrandh 1.85 finally (climacs-unread-gesture gesture stream)
211 rstrandh 1.36 (return (values numarg t)))))
212 rstrandh 1.85 (t (climacs-unread-gesture gesture stream)
213 rstrandh 1.36 (values 1 nil)))))
214    
215 rstrandh 1.77 ;;; we know the vbox pane has a scroller pane and an info
216     ;;; pane in it. The scroller pane has a viewport in it,
217     ;;; and the viewport contains the climacs-pane as its only child.
218     (defun find-climacs-pane (vbox)
219     (first (sheet-children
220     (find-if-not (lambda (pane) (typep pane 'scroll-bar-pane))
221     (sheet-children
222     (find-if (lambda (pane) (typep pane 'scroller-pane))
223     (sheet-children vbox)))))))
224    
225 ejohnson 1.27 (defun climacs-top-level (frame &key
226     command-parser command-unparser
227     partial-command-parser prompt)
228     (declare (ignore command-parser command-unparser partial-command-parser prompt))
229 rstrandh 1.83 (with-slots (windows) frame
230     (setf windows (list (find-climacs-pane (find-pane-named frame 'win))))
231     (push (buffer (car windows)) (buffers frame))
232     (let ((*standard-output* (car windows))
233 rstrandh 1.77 (*standard-input* (find-pane-named frame 'int))
234     (*print-pretty* nil)
235     (*abort-gestures* nil))
236     (redisplay-frame-panes frame :force-p t)
237     (loop (catch 'outer-loop
238     (loop for gestures = '()
239     for numarg = (read-numeric-argument :stream *standard-input*)
240     do (loop (setf *current-gesture* (climacs-read-gesture))
241     (setf gestures (nconc gestures (list *current-gesture*)))
242     (let ((item (find-gestures gestures 'global-climacs-table)))
243     (cond ((not item)
244     (beep) (return))
245     ((eq (command-menu-item-type item) :command)
246     (let ((command (command-menu-item-value item)))
247     (unless (consp command)
248     (setf command (list command)))
249     (setf command (substitute-numeric-argument-marker command numarg))
250     (handler-case
251     (execute-frame-command frame command)
252     (error (condition)
253     (beep)
254     (format *error-output* "~a~%" condition)))
255     (setf (previous-command *standard-output*)
256     (if (consp command)
257     (car command)
258     command))
259     (return)))
260     (t nil))))
261 rstrandh 1.83 (let ((buffer (buffer (current-window))))
262 rstrandh 1.77 (when (modified-p buffer)
263     (setf (needs-saving buffer) t)))
264 rstrandh 1.85 (when (null (remaining-keys *application-frame*))
265     (setf (executingp *application-frame*) nil)
266     (redisplay-frame-panes frame))))
267 rstrandh 1.77 (beep)
268 rstrandh 1.83 (let ((buffer (buffer (current-window))))
269 rstrandh 1.77 (when (modified-p buffer)
270     (setf (needs-saving buffer) t)))
271 rstrandh 1.85 (when (null (remaining-keys *application-frame*))
272     (setf (executingp *application-frame*) nil)
273     (redisplay-frame-panes frame))))))
274 ejohnson 1.27
275 mvilleneuve 1.64 (defun region-limits (pane)
276 rstrandh 1.70 (if (mark< (mark pane) (point pane))
277     (values (mark pane) (point pane))
278     (values (point pane) (mark pane))))
279 mvilleneuve 1.64
280 abridgewater 1.34 (defmacro define-named-command (command-name args &body body)
281 rstrandh 1.62 `(define-climacs-command ,(if (listp command-name)
282     `(,@command-name :name t)
283     `(,command-name :name t)) ,args ,@body))
284 abridgewater 1.34
285     (define-named-command (com-quit) ()
286 ejohnson 1.27 (frame-exit *application-frame*))
287    
288 abakic 1.58 (define-named-command com-toggle-overwrite-mode ()
289 abakic 1.87 (with-slots (overwrite-mode) (current-window)
290     (setf overwrite-mode (not overwrite-mode))))
291 abakic 1.58
292 mvilleneuve 1.89 (defun possibly-fill-line ()
293 mvilleneuve 1.86 (let* ((pane (current-window))
294     (buffer (buffer pane)))
295     (when (auto-fill-mode buffer)
296     (let* ((fill-column (auto-fill-column buffer))
297     (point (point pane))
298     (offset (offset point))
299     (tab-width (tab-space-count (stream-default-view pane)))
300     (syntax (syntax buffer)))
301     (when (>= (buffer-display-column buffer offset tab-width)
302     (1- (auto-fill-column buffer)))
303     (fill-line point
304     (lambda (mark)
305     (syntax-line-indentation mark tab-width syntax))
306     fill-column
307 mvilleneuve 1.89 tab-width))))))
308    
309     (defun insert-character (char)
310     (let* ((win (current-window))
311     (point (point win)))
312     (unless (constituentp char)
313     (possibly-expand-abbrev point))
314     (when (whitespacep char)
315     (possibly-fill-line))
316     (if (and (slot-value win 'overwrite-mode) (not (end-of-line-p point)))
317     (progn
318     (delete-range point)
319     (insert-object point char))
320     (insert-object point char))))
321    
322     (define-command com-self-insert ()
323 mvilleneuve 1.86 (insert-character *current-gesture*))
324 ejohnson 1.27
325 abridgewater 1.34 (define-named-command com-beginning-of-line ()
326 rstrandh 1.80 (beginning-of-line (point (current-window))))
327 ejohnson 1.27
328 abridgewater 1.34 (define-named-command com-end-of-line ()
329 rstrandh 1.80 (end-of-line (point (current-window))))
330 ejohnson 1.27
331 rstrandh 1.62 (define-named-command com-delete-object ((count 'integer :prompt "Number of Objects"))
332 rstrandh 1.80 (delete-range (point (current-window)) count))
333 ejohnson 1.27
334 rstrandh 1.62 (define-named-command com-backward-delete-object ((count 'integer :prompt "Number of Objects"))
335 rstrandh 1.80 (delete-range (point (current-window)) (- count)))
336 ejohnson 1.27
337 rstrandh 1.42 (define-named-command com-transpose-objects ()
338 rstrandh 1.80 (let* ((point (point (current-window))))
339 rstrandh 1.42 (unless (beginning-of-buffer-p point)
340     (when (end-of-line-p point)
341 rstrandh 1.43 (backward-object point))
342     (let ((object (object-after point)))
343     (delete-range point)
344     (backward-object point)
345     (insert-object point object)
346     (forward-object point)))))
347    
348 rstrandh 1.62 (define-named-command com-backward-object ((count 'integer :prompt "Number of Objects"))
349 rstrandh 1.80 (backward-object (point (current-window)) count))
350 rstrandh 1.43
351 rstrandh 1.62 (define-named-command com-forward-object ((count 'integer :prompt "Number of Objects"))
352 rstrandh 1.80 (forward-object (point (current-window)) count))
353 rstrandh 1.43
354     (define-named-command com-transpose-words ()
355 rstrandh 1.80 (let* ((point (point (current-window))))
356 rstrandh 1.43 (let (bw1 bw2 ew1 ew2)
357     (backward-word point)
358     (setf bw1 (offset point))
359     (forward-word point)
360     (setf ew1 (offset point))
361     (forward-word point)
362     (when (= (offset point) ew1)
363     ;; this is emacs' message in the minibuffer
364     (error "Don't have two things to transpose"))
365     (setf ew2 (offset point))
366     (backward-word point)
367     (setf bw2 (offset point))
368     (let ((w2 (buffer-sequence (buffer point) bw2 ew2))
369     (w1 (buffer-sequence (buffer point) bw1 ew1)))
370     (delete-word point)
371     (insert-sequence point w1)
372     (backward-word point)
373     (backward-word point)
374     (delete-word point)
375     (insert-sequence point w2)
376     (forward-word point)))))
377 rstrandh 1.42
378 rstrandh 1.45 (define-named-command com-transpose-lines ()
379 rstrandh 1.80 (let ((point (point (current-window))))
380 rstrandh 1.45 (beginning-of-line point)
381     (unless (beginning-of-buffer-p point)
382     (previous-line point))
383     (let* ((bol (offset point))
384     (eol (progn (end-of-line point)
385     (offset point)))
386     (line (buffer-sequence (buffer point) bol eol)))
387     (delete-region bol point)
388     ;; Remove newline at end of line as well.
389     (unless (end-of-buffer-p point)
390     (delete-range point))
391     ;; If the current line is at the end of the buffer, we want to
392     ;; be able to insert past it, so we need to get an extra line
393     ;; at the end.
394 abakic 1.82 (end-of-line point)
395     (when (end-of-buffer-p point)
396 rstrandh 1.45 (insert-object point #\Newline))
397 abakic 1.82 (next-line point 0)
398 rstrandh 1.45 (insert-sequence point line)
399     (insert-object point #\Newline))))
400    
401 abridgewater 1.34 (define-named-command com-previous-line ()
402 rstrandh 1.80 (let* ((win (current-window))
403 rstrandh 1.49 (point (point win)))
404     (unless (or (eq (previous-command win) 'com-previous-line)
405     (eq (previous-command win) 'com-next-line))
406     (setf (slot-value win 'goal-column) (column-number point)))
407     (previous-line point (slot-value win 'goal-column))))
408 ejohnson 1.27
409 abridgewater 1.34 (define-named-command com-next-line ()
410 rstrandh 1.80 (let* ((win (current-window))
411 rstrandh 1.49 (point (point win)))
412     (unless (or (eq (previous-command win) 'com-previous-line)
413     (eq (previous-command win) 'com-next-line))
414     (setf (slot-value win 'goal-column) (column-number point)))
415     (next-line point (slot-value win 'goal-column))))
416 ejohnson 1.27
417 abridgewater 1.34 (define-named-command com-open-line ()
418 rstrandh 1.80 (open-line (point (current-window))))
419 ejohnson 1.27
420 abridgewater 1.34 (define-named-command com-kill-line ()
421 rstrandh 1.80 (let* ((pane (current-window))
422 ejohnson 1.54 (point (point pane))
423     (mark (offset point)))
424 ejohnson 1.56 (cond ((end-of-buffer-p point) nil)
425     ((end-of-line-p point)(forward-object point))
426     (t
427     (end-of-line point)
428     (cond ((beginning-of-buffer-p point) nil)
429     ((beginning-of-line-p point)(forward-object point)))))
430 ejohnson 1.54 (if (eq (previous-command pane) 'com-kill-line)
431 ejohnson 1.51 (kill-ring-concatenating-push *kill-ring*
432 ejohnson 1.54 (region-to-sequence mark point))
433 ejohnson 1.51 (kill-ring-standard-push *kill-ring*
434 ejohnson 1.54 (region-to-sequence mark point)))
435     (delete-region mark point)))
436 ejohnson 1.27
437 abridgewater 1.34 (define-named-command com-forward-word ()
438 rstrandh 1.80 (forward-word (point (current-window))))
439 ejohnson 1.27
440 abridgewater 1.34 (define-named-command com-backward-word ()
441 rstrandh 1.80 (backward-word (point (current-window))))
442 ejohnson 1.27
443 abridgewater 1.34 (define-named-command com-delete-word ()
444 rstrandh 1.80 (delete-word (point (current-window))))
445 rstrandh 1.32
446 abridgewater 1.34 (define-named-command com-backward-delete-word ()
447 rstrandh 1.80 (backward-delete-word (point (current-window))))
448 rstrandh 1.32
449 mvilleneuve 1.64 (define-named-command com-upcase-region ()
450 rstrandh 1.80 (multiple-value-bind (start end) (region-limits (current-window))
451 mvilleneuve 1.64 (upcase-region start end)))
452    
453     (define-named-command com-downcase-region ()
454 rstrandh 1.80 (multiple-value-bind (start end) (region-limits (current-window))
455 mvilleneuve 1.64 (downcase-region start end)))
456    
457     (define-named-command com-capitalize-region ()
458 rstrandh 1.80 (multiple-value-bind (start end) (region-limits (current-window))
459 mvilleneuve 1.64 (capitalize-region start end)))
460    
461 rstrandh 1.60 (define-named-command com-upcase-word ()
462 rstrandh 1.80 (upcase-word (point (current-window))))
463 rstrandh 1.60
464     (define-named-command com-downcase-word ()
465 rstrandh 1.80 (downcase-word (point (current-window))))
466 rstrandh 1.60
467     (define-named-command com-capitalize-word ()
468 rstrandh 1.80 (capitalize-word (point (current-window))))
469 rstrandh 1.60
470 mvilleneuve 1.69 (define-named-command com-tabify-region ()
471 rstrandh 1.80 (let ((pane (current-window)))
472 mvilleneuve 1.69 (multiple-value-bind (start end) (region-limits pane)
473 rstrandh 1.70 (tabify-region start end (tab-space-count (stream-default-view pane))))))
474 mvilleneuve 1.69
475     (define-named-command com-untabify-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 (untabify-region start end (tab-space-count (stream-default-view pane))))))
479 mvilleneuve 1.69
480 mvilleneuve 1.79 (defun indent-current-line (pane point)
481     (let* ((buffer (buffer pane))
482     (view (stream-default-view pane))
483     (tab-space-count (tab-space-count view))
484     (indentation (syntax-line-indentation point
485     tab-space-count
486     (syntax buffer))))
487     (indent-line point indentation (and (indent-tabs-mode buffer)
488     tab-space-count))))
489    
490     (define-named-command com-indent-line ()
491 rstrandh 1.80 (let* ((pane (current-window))
492 mvilleneuve 1.79 (point (point pane)))
493     (indent-current-line pane point)))
494    
495     (define-named-command com-newline-and-indent ()
496 rstrandh 1.80 (let* ((pane (current-window))
497 mvilleneuve 1.79 (point (point pane)))
498     (insert-object point #\Newline)
499     (indent-current-line pane point)))
500    
501 mvilleneuve 1.72 (define-named-command com-delete-indentation ()
502 rstrandh 1.80 (delete-indentation (point (current-window))))
503 ejohnson 1.27
504 mvilleneuve 1.86 (define-named-command com-auto-fill-mode ()
505     (let ((buffer (buffer (current-window))))
506     (setf (auto-fill-mode buffer) (not (auto-fill-mode buffer)))))
507    
508 ejohnson 1.27 (define-command com-extended-command ()
509     (let ((item (accept 'command :prompt "Extended Command")))
510     (execute-frame-command *application-frame* item)))
511    
512 rstrandh 1.41 (eval-when (:compile-toplevel :load-toplevel)
513 ejohnson 1.35 (define-presentation-type completable-pathname ()
514     :inherit-from 'pathname))
515 ejohnson 1.27
516     (defun filename-completer (so-far mode)
517     (flet ((remove-trail (s)
518     (subseq s 0 (let ((pos (position #\/ s :from-end t)))
519     (if pos (1+ pos) 0)))))
520     (let* ((directory-prefix
521     (if (and (plusp (length so-far)) (eql (aref so-far 0) #\/))
522     ""
523 rstrandh 1.78 (namestring #+sbcl *default-pathname-defaults*
524     #+cmu (ext:default-directory)
525     #-(or sbcl cmu) *default-pathname-defaults*)))
526 ejohnson 1.27 (full-so-far (concatenate 'string directory-prefix so-far))
527     (pathnames
528     (loop with length = (length full-so-far)
529     for path in (directory (concatenate 'string
530     (remove-trail so-far)
531     "*.*"))
532     when (let ((mismatch (mismatch (namestring path) full-so-far)))
533     (or (null mismatch) (= mismatch length)))
534     collect path))
535     (strings (mapcar #'namestring pathnames))
536     (first-string (car strings))
537     (length-common-prefix nil)
538     (completed-string nil)
539     (full-completed-string nil))
540     (unless (null pathnames)
541     (setf length-common-prefix
542     (loop with length = (length first-string)
543     for string in (cdr strings)
544     do (setf length (min length (or (mismatch string first-string) length)))
545     finally (return length))))
546     (unless (null pathnames)
547     (setf completed-string
548     (subseq first-string (length directory-prefix)
549     (if (null (cdr pathnames)) nil length-common-prefix)))
550     (setf full-completed-string
551     (concatenate 'string directory-prefix completed-string)))
552     (case mode
553     ((:complete-limited :complete-maximal)
554     (cond ((null pathnames)
555     (values so-far nil nil 0 nil))
556     ((null (cdr pathnames))
557     (values completed-string t (car pathnames) 1 nil))
558     (t
559     (values completed-string nil nil (length pathnames) nil))))
560     (:complete
561     (cond ((null pathnames)
562     (values so-far t so-far 1 nil))
563     ((null (cdr pathnames))
564     (values completed-string t (car pathnames) 1 nil))
565     ((find full-completed-string strings :test #'string-equal)
566     (let ((pos (position full-completed-string strings :test #'string-equal)))
567     (values completed-string
568     t (elt pathnames pos) (length pathnames) nil)))
569     (t
570     (values completed-string nil nil (length pathnames) nil))))
571     (:possibilities
572     (values nil nil nil (length pathnames)
573     (loop with length = (length directory-prefix)
574     for name in pathnames
575     collect (list (subseq (namestring name) length nil)
576     name))))))))
577    
578     (define-presentation-method accept
579     ((type completable-pathname) stream (view textual-view) &key)
580     (multiple-value-bind (pathname success string)
581     (complete-input stream
582     #'filename-completer
583     :partial-completers '(#\Space)
584     :allow-any-input t)
585     (declare (ignore success))
586     (or pathname string)))
587    
588     (defun pathname-filename (pathname)
589     (if (null (pathname-type pathname))
590     (pathname-name pathname)
591     (concatenate 'string (pathname-name pathname)
592     "." (pathname-type pathname))))
593    
594 abridgewater 1.34 (define-named-command com-find-file ()
595 ejohnson 1.27 (let ((filename (accept 'completable-pathname
596 rstrandh 1.70 :prompt "Find File"))
597     (buffer (make-instance 'climacs-buffer))
598 rstrandh 1.80 (pane (current-window)))
599 rstrandh 1.75 (push buffer (buffers *application-frame*))
600 rstrandh 1.80 (setf (buffer (current-window)) buffer)
601 rstrandh 1.70 (setf (syntax buffer) (make-instance 'basic-syntax))
602 rstrandh 1.84 ;; Don't want to create the file if it doesn't exist.
603     (when (probe-file filename)
604     (with-open-file (stream filename :direction :input)
605     (input-from-stream stream buffer 0)))
606 rstrandh 1.70 (setf (filename buffer) filename
607     (name buffer) (pathname-filename filename)
608     (needs-saving buffer) nil)
609     (beginning-of-buffer (point pane))
610     ;; this one is needed so that the buffer modification protocol
611     ;; resets the low and high marks after redisplay
612     (redisplay-frame-panes *application-frame*)))
613 ejohnson 1.27
614 abridgewater 1.34 (define-named-command com-save-buffer ()
615 rstrandh 1.80 (let* ((buffer (buffer (current-window)))
616 rstrandh 1.30 (filename (or (filename buffer)
617     (accept 'completable-pathname
618     :prompt "Save Buffer to File"))))
619     (if (or (null (filename buffer))
620     (needs-saving buffer))
621     (progn (with-open-file (stream filename :direction :output :if-exists :supersede)
622     (output-to-stream stream buffer 0 (size buffer)))
623     (setf (filename buffer) filename
624     (name buffer) (pathname-filename filename))
625     (display-message "Wrote: ~a" (filename buffer)))
626     (display-message "No changes need to be saved from ~a" (name buffer)))
627     (setf (needs-saving buffer) nil)))
628 ejohnson 1.27
629 abridgewater 1.34 (define-named-command com-write-buffer ()
630 ejohnson 1.27 (let ((filename (accept 'completable-pathname
631     :prompt "Write Buffer to File"))
632 rstrandh 1.80 (buffer (buffer (current-window))))
633 ejohnson 1.27 (with-open-file (stream filename :direction :output :if-exists :supersede)
634     (output-to-stream stream buffer 0 (size buffer)))
635     (setf (filename buffer) filename
636 rstrandh 1.28 (name buffer) (pathname-filename filename)
637 rstrandh 1.30 (needs-saving buffer) nil)
638     (display-message "Wrote: ~a" (filename buffer))))
639 ejohnson 1.27
640 rstrandh 1.75 (define-presentation-method accept
641     ((type buffer) stream (view textual-view) &key)
642     (multiple-value-bind (object success string)
643     (complete-input stream
644     (lambda (so-far action)
645     (complete-from-possibilities
646     so-far (buffers *application-frame*) '() :action action
647     :name-key #'name
648     :value-key #'identity))
649     :partial-completers '(#\Space)
650     :allow-any-input t)
651 rstrandh 1.76 (declare (ignore success))
652     (or object
653     (car (push (make-instance 'climacs-buffer :name string)
654     (buffers *application-frame*))))))
655 rstrandh 1.75
656     (define-named-command com-switch-to-buffer ()
657     (let ((buffer (accept 'buffer
658     :prompt "Switch to buffer")))
659 rstrandh 1.80 (setf (buffer (current-window)) buffer)
660 rstrandh 1.75 (setf (syntax buffer) (make-instance 'basic-syntax))
661 rstrandh 1.80 (beginning-of-buffer (point (current-window)))
662     (full-redisplay (current-window))))
663 rstrandh 1.75
664     (define-named-command com-full-redisplay ()
665 rstrandh 1.80 (full-redisplay (current-window)))
666 rstrandh 1.75
667 rstrandh 1.63 (define-named-command com-load-file ()
668     (let ((filename (accept 'completable-pathname
669     :prompt "Load File")))
670     (load filename)))
671    
672 abridgewater 1.34 (define-named-command com-beginning-of-buffer ()
673 rstrandh 1.80 (beginning-of-buffer (point (current-window))))
674 ejohnson 1.27
675 rstrandh 1.39 (define-named-command com-page-down ()
676 rstrandh 1.80 (let ((pane (current-window)))
677 rstrandh 1.70 (page-down pane)))
678 rstrandh 1.39
679 rstrandh 1.40 (define-named-command com-page-up ()
680 rstrandh 1.80 (let ((pane (current-window)))
681 rstrandh 1.70 (page-up pane)))
682 rstrandh 1.40
683 abridgewater 1.34 (define-named-command com-end-of-buffer ()
684 rstrandh 1.80 (end-of-buffer (point (current-window))))
685 ejohnson 1.27
686 abridgewater 1.34 (define-named-command com-back-to-indentation ()
687 rstrandh 1.80 (let ((point (point (current-window))))
688 rstrandh 1.32 (beginning-of-line point)
689     (loop until (end-of-line-p point)
690     while (whitespacep (object-after point))
691     do (incf (offset point)))))
692    
693 abridgewater 1.34 (define-named-command com-goto-position ()
694 rstrandh 1.80 (setf (offset (point (current-window)))
695 rstrandh 1.32 (accept 'integer :prompt "Goto Position")))
696    
697 abridgewater 1.34 (define-named-command com-goto-line ()
698 rstrandh 1.32 (loop with mark = (make-instance 'standard-right-sticky-mark
699 rstrandh 1.80 :buffer (buffer (current-window)))
700 rstrandh 1.32 do (end-of-line mark)
701     until (end-of-buffer-p mark)
702     repeat (accept 'integer :prompt "Goto Line")
703     do (incf (offset mark))
704     (end-of-line mark)
705     finally (beginning-of-line mark)
706 rstrandh 1.80 (setf (offset (point (current-window)))
707 rstrandh 1.32 (offset mark))))
708    
709 abridgewater 1.34 (define-named-command com-browse-url ()
710 ejohnson 1.27 (accept 'url :prompt "Browse URL"))
711    
712 abridgewater 1.34 (define-named-command com-set-mark ()
713 rstrandh 1.80 (let ((pane (current-window)))
714 rstrandh 1.70 (setf (mark pane) (clone-mark (point pane)))))
715 rstrandh 1.45
716     (define-named-command com-exchange-point-and-mark ()
717 rstrandh 1.80 (let ((pane (current-window)))
718 rstrandh 1.70 (psetf (offset (mark pane)) (offset (point pane))
719     (offset (point pane)) (offset (mark pane)))))
720 rstrandh 1.38
721     (define-named-command com-set-syntax ()
722 rstrandh 1.80 (let* ((pane (current-window))
723 rstrandh 1.67 (buffer (buffer pane)))
724 rstrandh 1.70 (setf (syntax buffer)
725     (make-instance (accept 'syntax :prompt "Set Syntax")))
726 rstrandh 1.67 (setf (offset (low-mark buffer)) 0
727     (offset (high-mark buffer)) (size buffer))))
728 ejohnson 1.27
729 rstrandh 1.77 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
730     ;;;
731 rstrandh 1.85 ;;; Keyboard macros
732    
733     (define-named-command com-start-kbd-macro ()
734     (setf (recordingp *application-frame*) t)
735     (setf (recorded-keys *application-frame*) '()))
736    
737     (define-named-command com-end-kbd-macro ()
738     (setf (recordingp *application-frame*) nil)
739     (setf (recorded-keys *application-frame*)
740     ;; this won't work if the command was invoked in any old way
741     (reverse (cddr (recorded-keys *application-frame*)))))
742    
743     (define-named-command com-call-last-kbd-macro ()
744     (setf (remaining-keys *application-frame*)
745     (recorded-keys *application-frame*))
746     (setf (executingp *application-frame*) t))
747    
748     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
749     ;;;
750 rstrandh 1.77 ;;; Commands for splitting windows
751    
752 rstrandh 1.83 (defun replace-constellation (constellation additional-constellation vertical-p)
753     (let* ((parent (sheet-parent constellation))
754     (children (sheet-children parent))
755     (first (first children))
756     (second (second children)))
757     (assert (member constellation children))
758     (cond ((eq constellation first)
759     (sheet-disown-child parent constellation)
760     (let ((new (if vertical-p
761     (vertically () constellation additional-constellation)
762     (horizontally () constellation additional-constellation))))
763     (sheet-adopt-child parent new)
764     (reorder-sheets parent (list new second))))
765     (t
766     (sheet-disown-child parent constellation)
767     (let ((new (if vertical-p
768     (vertically () constellation additional-constellation)
769     (horizontally () constellation additional-constellation))))
770     (sheet-adopt-child parent new)
771     (reorder-sheets parent (list first new)))))))
772    
773     (defun parent3 (sheet)
774     (sheet-parent (sheet-parent (sheet-parent sheet))))
775    
776     (defun make-pane-constellation ()
777     "make a vbox containing a scroller pane as its first child and an
778     info pane as its second child. The scroller pane contains a viewport
779     which contains an extended pane. Return the vbox and the extended pane
780     as two values"
781     (let* ((extended-pane
782     (make-pane 'extended-pane
783     :width 900 :height 400
784     :name 'win
785     :incremental-redisplay t
786     :display-function 'display-win))
787     (vbox
788     (vertically ()
789     (scrolling () extended-pane)
790     (make-pane 'info-pane
791     :climacs-pane extended-pane
792     :width 900 :height 20
793     :max-height 20 :min-height 20
794     ::background +gray85+
795     :scroll-bars nil
796     :borders nil
797     :incremental-redisplay t
798     :display-function 'display-info))))
799     (values vbox extended-pane)))
800    
801 rstrandh 1.77 (define-named-command com-split-window-vertically ()
802     (with-look-and-feel-realization
803     ((frame-manager *application-frame*) *application-frame*)
804 rstrandh 1.83 (multiple-value-bind (vbox new-pane) (make-pane-constellation)
805     (let* ((current-window (current-window))
806     (constellation-root (parent3 current-window)))
807     (setf (buffer new-pane) (buffer current-window))
808     (push new-pane (windows *application-frame*))
809     (replace-constellation constellation-root vbox t)
810     (full-redisplay current-window)
811     (full-redisplay new-pane)))))
812    
813     (define-named-command com-split-window-horizontally ()
814     (with-look-and-feel-realization
815     ((frame-manager *application-frame*) *application-frame*)
816     (multiple-value-bind (vbox new-pane) (make-pane-constellation)
817     (let* ((current-window (current-window))
818     (constellation-root (parent3 current-window)))
819     (setf (buffer new-pane) (buffer current-window))
820     (push new-pane (windows *application-frame*))
821     (replace-constellation constellation-root vbox nil)
822     (full-redisplay current-window)
823     (full-redisplay new-pane)))))
824    
825     (define-named-command com-other-window ()
826     (setf (windows *application-frame*)
827     (append (cdr (windows *application-frame*))
828     (list (car (windows *application-frame*))))))
829    
830     (define-named-command com-delete-window ()
831     (unless (null (cdr (windows *application-frame*)))
832     (let* ((constellation (parent3 (current-window)))
833     (box (sheet-parent constellation))
834     (box-children (sheet-children box))
835     (other (if (eq constellation (first box-children))
836     (second box-children)
837     (first box-children)))
838     (parent (sheet-parent box))
839     (children (sheet-children parent))
840     (first (first children))
841     (second (second children)))
842     (pop (windows *application-frame*))
843     (sheet-disown-child box other)
844     (cond ((eq box first)
845     (sheet-disown-child parent box)
846     (sheet-adopt-child parent other)
847     (reorder-sheets parent (list other second)))
848     (t
849     (sheet-disown-child parent box)
850     (sheet-adopt-child parent other)
851     (reorder-sheets parent (list first other)))))))
852 rstrandh 1.77
853 ejohnson 1.27 ;;;;;;;;;;;;;;;;;;;;
854     ;; Kill ring commands
855    
856 ejohnson 1.31 ;; Copies an element from a kill-ring to a buffer at the given offset
857 ejohnson 1.50 (define-named-command com-yank ()
858 rstrandh 1.80 (insert-sequence (point (current-window)) (kill-ring-yank *kill-ring*)))
859 ejohnson 1.27
860 ejohnson 1.31 ;; Destructively cut a given buffer region into the kill-ring
861 abridgewater 1.34 (define-named-command com-cut-out ()
862 rstrandh 1.80 (multiple-value-bind (start end) (region-limits (current-window))
863 mvilleneuve 1.64 (kill-ring-standard-push *kill-ring* (region-to-sequence start end))
864     (delete-region (offset start) end)))
865 ejohnson 1.27
866 ejohnson 1.31 ;; Non destructively copies in buffer region to the kill ring
867 abridgewater 1.34 (define-named-command com-copy-out ()
868 rstrandh 1.80 (let ((pane (current-window)))
869 rstrandh 1.70 (kill-ring-standard-push *kill-ring* (region-to-sequence (point pane) (mark pane)))))
870 ejohnson 1.27
871 ejohnson 1.50 (define-named-command com-rotate-yank ()
872 rstrandh 1.80 (let* ((pane (current-window))
873 ejohnson 1.54 (point (point pane))
874 ejohnson 1.50 (last-yank (kill-ring-yank *kill-ring*)))
875 ejohnson 1.54 (if (eq (previous-command pane)
876 ejohnson 1.50 'com-rotate-yank)
877 ejohnson 1.54 (progn
878     (delete-range point (* -1 (length last-yank)))
879     (rotate-yank-position *kill-ring*)))
880     (insert-sequence point (kill-ring-yank *kill-ring*))))
881 ejohnson 1.27
882 ejohnson 1.50 (define-named-command com-resize-kill-ring ()
883 ejohnson 1.46 (let ((size (accept 'integer :prompt "New kill ring size")))
884 ejohnson 1.50 (setf (kill-ring-max-size *kill-ring*) size)))
885 rstrandh 1.47
886     (define-named-command com-search-forward ()
887 rstrandh 1.80 (search-forward (point (current-window))
888 rstrandh 1.47 (accept 'string :prompt "Search Forward")
889     :test (lambda (a b)
890     (and (characterp b) (char-equal a b)))))
891    
892     (define-named-command com-search-backward ()
893 rstrandh 1.80 (search-backward (point (current-window))
894 rstrandh 1.47 (accept 'string :prompt "Search Backward")
895     :test (lambda (a b)
896     (and (characterp b) (char-equal a b)))))
897 ejohnson 1.27
898 rstrandh 1.49 (define-named-command com-dabbrev-expand ()
899 rstrandh 1.80 (let* ((win (current-window))
900 rstrandh 1.49 (point (point win)))
901     (with-slots (original-prefix prefix-start-offset dabbrev-expansion-mark) win
902     (flet ((move () (cond ((beginning-of-buffer-p dabbrev-expansion-mark)
903     (setf (offset dabbrev-expansion-mark)
904     (offset point))
905     (forward-word dabbrev-expansion-mark))
906     ((mark< dabbrev-expansion-mark point)
907     (backward-object dabbrev-expansion-mark))
908     (t (forward-object dabbrev-expansion-mark)))))
909     (unless (or (beginning-of-buffer-p point)
910     (not (constituentp (object-before point))))
911     (unless (and (eq (previous-command win) 'com-dabbrev-expand)
912     (not (null prefix-start-offset)))
913     (setf dabbrev-expansion-mark (clone-mark point))
914     (backward-word dabbrev-expansion-mark)
915     (setf prefix-start-offset (offset dabbrev-expansion-mark))
916     (setf original-prefix (region-to-sequence prefix-start-offset point))
917     (move))
918     (loop until (or (end-of-buffer-p dabbrev-expansion-mark)
919     (and (or (beginning-of-buffer-p dabbrev-expansion-mark)
920     (not (constituentp (object-before dabbrev-expansion-mark))))
921     (looking-at dabbrev-expansion-mark original-prefix)))
922     do (move))
923     (if (end-of-buffer-p dabbrev-expansion-mark)
924     (progn (delete-region prefix-start-offset point)
925     (insert-sequence point original-prefix)
926     (setf prefix-start-offset nil))
927     (progn (delete-region prefix-start-offset point)
928     (insert-sequence point
929     (let ((offset (offset dabbrev-expansion-mark)))
930     (prog2 (forward-word dabbrev-expansion-mark)
931     (region-to-sequence offset dabbrev-expansion-mark)
932     (setf (offset dabbrev-expansion-mark) offset))))
933     (move))))))))
934    
935 rstrandh 1.71 (define-named-command com-beginning-of-paragraph ()
936 rstrandh 1.80 (let* ((pane (current-window))
937 rstrandh 1.71 (point (point pane))
938     (syntax (syntax (buffer pane))))
939     (beginning-of-paragraph point syntax)))
940    
941     (define-named-command com-end-of-paragraph ()
942 rstrandh 1.80 (let* ((pane (current-window))
943 rstrandh 1.71 (point (point pane))
944     (syntax (syntax (buffer pane))))
945     (end-of-paragraph point syntax)))
946    
947 ejohnson 1.27 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
948     ;;;
949 rstrandh 1.80 ;;; Global and dead-escape command tables
950 ejohnson 1.27
951     (make-command-table 'global-climacs-table :errorp nil)
952    
953 rstrandh 1.80 (make-command-table 'dead-escape-climacs-table :errorp nil)
954    
955     (add-menu-item-to-command-table 'global-climacs-table "dead-escape"
956     :menu 'dead-escape-climacs-table
957     :keystroke '(:escape))
958    
959     (defun dead-escape-set-key (gesture command)
960     (add-command-to-command-table command 'dead-escape-climacs-table
961     :keystroke gesture :errorp nil))
962    
963 ejohnson 1.27 (defun global-set-key (gesture command)
964     (add-command-to-command-table command 'global-climacs-table
965 rstrandh 1.80 :keystroke gesture :errorp nil)
966     (when (and
967     (listp gesture)
968     (find :meta gesture))
969     (dead-escape-set-key (remove :meta gesture) command)))
970 ejohnson 1.27
971 mvilleneuve 1.89 (loop for code from (char-code #\Space) to (char-code #\~)
972 ejohnson 1.27 do (global-set-key (code-char code) 'com-self-insert))
973    
974 mvilleneuve 1.89 (global-set-key #\Newline 'com-self-insert)
975 mvilleneuve 1.86 (global-set-key #\Tab 'com-indent-line)
976 mvilleneuve 1.79 (global-set-key '(#\j :control) 'com-newline-and-indent)
977 rstrandh 1.62 (global-set-key '(#\f :control) `(com-forward-object ,*numeric-argument-marker*))
978     (global-set-key '(#\b :control) `(com-backward-object ,*numeric-argument-marker*))
979 ejohnson 1.27 (global-set-key '(#\a :control) 'com-beginning-of-line)
980     (global-set-key '(#\e :control) 'com-end-of-line)
981 rstrandh 1.62 (global-set-key '(#\d :control) `(com-delete-object ,*numeric-argument-marker*))
982 ejohnson 1.27 (global-set-key '(#\p :control) 'com-previous-line)
983 rstrandh 1.75 (global-set-key '(#\l :control) 'com-full-redisplay)
984 ejohnson 1.27 (global-set-key '(#\n :control) 'com-next-line)
985     (global-set-key '(#\o :control) 'com-open-line)
986     (global-set-key '(#\k :control) 'com-kill-line)
987 rstrandh 1.42 (global-set-key '(#\t :control) 'com-transpose-objects)
988 ejohnson 1.27 (global-set-key '(#\Space :control) 'com-set-mark)
989 ejohnson 1.50 (global-set-key '(#\y :control) 'com-yank)
990 ejohnson 1.27 (global-set-key '(#\w :control) 'com-cut-out)
991     (global-set-key '(#\f :meta) 'com-forward-word)
992     (global-set-key '(#\b :meta) 'com-backward-word)
993 rstrandh 1.43 (global-set-key '(#\t :meta) 'com-transpose-words)
994 rstrandh 1.60 (global-set-key '(#\u :meta) 'com-upcase-word)
995     (global-set-key '(#\l :meta) 'com-downcase-word)
996     (global-set-key '(#\c :meta) 'com-capitalize-word)
997 ejohnson 1.27 (global-set-key '(#\x :meta) 'com-extended-command)
998 ejohnson 1.50 (global-set-key '(#\y :meta) 'com-rotate-yank)
999 ejohnson 1.27 (global-set-key '(#\w :meta) 'com-copy-out)
1000 rstrandh 1.39 (global-set-key '(#\v :control) 'com-page-down)
1001 rstrandh 1.40 (global-set-key '(#\v :meta) 'com-page-up)
1002 ejohnson 1.27 (global-set-key '(#\< :shift :meta) 'com-beginning-of-buffer)
1003     (global-set-key '(#\> :shift :meta) 'com-end-of-buffer)
1004 rstrandh 1.32 (global-set-key '(#\m :meta) 'com-back-to-indentation)
1005 mvilleneuve 1.74 (global-set-key '(#\^ :shift :meta) 'com-delete-indentation)
1006 rstrandh 1.32 (global-set-key '(#\d :meta) 'com-delete-word)
1007     (global-set-key '(#\Backspace :meta) 'com-backward-delete-word)
1008 rstrandh 1.49 (global-set-key '(#\/ :meta) 'com-dabbrev-expand)
1009 rstrandh 1.71 (global-set-key '(#\a :control :meta) 'com-beginning-of-paragraph)
1010     (global-set-key '(#\e :control :meta) 'com-end-of-paragraph)
1011 ejohnson 1.27
1012     (global-set-key '(:up) 'com-previous-line)
1013     (global-set-key '(:down) 'com-next-line)
1014 rstrandh 1.62 (global-set-key '(:left) `(com-backward-object ,*numeric-argument-marker*))
1015 ejohnson 1.66 (global-set-key '(:right) `(com-forward-object ,*numeric-argument-marker*))
1016 ejohnson 1.27 (global-set-key '(:left :control) 'com-backward-word)
1017     (global-set-key '(:right :control) 'com-forward-word)
1018     (global-set-key '(:home) 'com-beginning-of-line)
1019     (global-set-key '(:end) 'com-end-of-line)
1020 abridgewater 1.57 (global-set-key '(:prior) 'com-page-up)
1021     (global-set-key '(:next) 'com-page-down)
1022 ejohnson 1.27 (global-set-key '(:home :control) 'com-beginning-of-buffer)
1023     (global-set-key '(:end :control) 'com-end-of-buffer)
1024 rstrandh 1.62 (global-set-key #\Rubout `(com-delete-object ,*numeric-argument-marker*))
1025     (global-set-key #\Backspace `(com-backward-delete-object ,*numeric-argument-marker*))
1026 abakic 1.58
1027     (global-set-key '(:insert) 'com-toggle-overwrite-mode)
1028 ejohnson 1.27
1029     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1030     ;;;
1031     ;;; C-x command table
1032    
1033     (make-command-table 'c-x-climacs-table :errorp nil)
1034    
1035     (add-menu-item-to-command-table 'global-climacs-table "C-x"
1036     :menu 'c-x-climacs-table
1037     :keystroke '(#\x :control))
1038    
1039     (defun c-x-set-key (gesture command)
1040     (add-command-to-command-table command 'c-x-climacs-table
1041     :keystroke gesture :errorp nil))
1042    
1043 rstrandh 1.83 (c-x-set-key '(#\0) 'com-delete-window)
1044 rstrandh 1.77 (c-x-set-key '(#\2) 'com-split-window-vertically)
1045 rstrandh 1.83 (c-x-set-key '(#\3) 'com-split-window-horizontally)
1046 rstrandh 1.85 (c-x-set-key '(#\() 'com-start-kbd-macro)
1047     (c-x-set-key '(#\)) 'com-end-kbd-macro)
1048 rstrandh 1.75 (c-x-set-key '(#\b) 'com-switch-to-buffer)
1049 rstrandh 1.85 (c-x-set-key '(#\e) 'com-call-last-kbd-macro)
1050 ejohnson 1.27 (c-x-set-key '(#\c :control) 'com-quit)
1051     (c-x-set-key '(#\f :control) 'com-find-file)
1052 rstrandh 1.63 (c-x-set-key '(#\l :control) 'com-load-file)
1053 rstrandh 1.83 (c-x-set-key '(#\o) 'com-other-window)
1054 ejohnson 1.27 (c-x-set-key '(#\s :control) 'com-save-buffer)
1055 rstrandh 1.45 (c-x-set-key '(#\t :control) 'com-transpose-lines)
1056 ejohnson 1.27 (c-x-set-key '(#\w :control) 'com-write-buffer)
1057 rstrandh 1.45 (c-x-set-key '(#\x :control) 'com-exchange-point-and-mark)
1058 rstrandh 1.44
1059     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1060     ;;;
1061     ;;; Some Unicode stuff
1062    
1063     (define-named-command com-insert-charcode ((code 'integer :prompt "Code point"))
1064 rstrandh 1.80 (insert-object (point (current-window)) (code-char code)))
1065 rstrandh 1.44
1066     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1067     ;;;
1068     ;;; Dead-acute command table
1069    
1070     (make-command-table 'dead-acute-climacs-table :errorp nil)
1071    
1072     (add-menu-item-to-command-table 'global-climacs-table "dead-acute"
1073     :menu 'dead-acute-climacs-table
1074     :keystroke '(:dead--acute))
1075    
1076     (defun dead-acute-set-key (gesture command)
1077     (add-command-to-command-table command 'dead-acute-climacs-table
1078     :keystroke gesture :errorp nil))
1079    
1080     (dead-acute-set-key '(#\A) '(com-insert-charcode 193))
1081     (dead-acute-set-key '(#\E) '(com-insert-charcode 201))
1082     (dead-acute-set-key '(#\I) '(com-insert-charcode 205))
1083     (dead-acute-set-key '(#\O) '(com-insert-charcode 211))
1084     (dead-acute-set-key '(#\U) '(com-insert-charcode 218))
1085     (dead-acute-set-key '(#\Y) '(com-insert-charcode 221))
1086     (dead-acute-set-key '(#\a) '(com-insert-charcode 225))
1087     (dead-acute-set-key '(#\e) '(com-insert-charcode 233))
1088     (dead-acute-set-key '(#\i) '(com-insert-charcode 237))
1089     (dead-acute-set-key '(#\o) '(com-insert-charcode 243))
1090     (dead-acute-set-key '(#\u) '(com-insert-charcode 250))
1091     (dead-acute-set-key '(#\y) '(com-insert-charcode 253))
1092     (dead-acute-set-key '(#\C) '(com-insert-charcode 199))
1093     (dead-acute-set-key '(#\c) '(com-insert-charcode 231))
1094     (dead-acute-set-key '(#\x) '(com-insert-charcode 215))
1095     (dead-acute-set-key '(#\-) '(com-insert-charcode 247))
1096     (dead-acute-set-key '(#\T) '(com-insert-charcode 222))
1097     (dead-acute-set-key '(#\t) '(com-insert-charcode 254))
1098     (dead-acute-set-key '(#\s) '(com-insert-charcode 223))
1099     (dead-acute-set-key '(#\Space) '(com-insert-charcode 39))
1100    
1101 rstrandh 1.45 (make-command-table 'dead-acute-dead-accute-climacs-table :errorp nil)
1102    
1103     (add-menu-item-to-command-table 'dead-acute-climacs-table "dead-acute-dead-accute"
1104     :menu 'dead-acute-dead-accute-climacs-table
1105     :keystroke '(:dead--acute))
1106    
1107     (defun dead-acute-dead-accute-set-key (gesture command)
1108     (add-command-to-command-table command 'dead-acute-dead-accute-climacs-table
1109     :keystroke gesture :errorp nil))
1110    
1111     (dead-acute-dead-accute-set-key '(#\A) '(com-insert-charcode 197))
1112     (dead-acute-dead-accute-set-key '(#\a) '(com-insert-charcode 229))
1113 rstrandh 1.44 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1114     ;;;
1115     ;;; Dead-grave command table
1116    
1117     (make-command-table 'dead-grave-climacs-table :errorp nil)
1118    
1119     (add-menu-item-to-command-table 'global-climacs-table "dead-grave"
1120     :menu 'dead-grave-climacs-table
1121     :keystroke '(:dead--grave))
1122    
1123     (defun dead-grave-set-key (gesture command)
1124     (add-command-to-command-table command 'dead-grave-climacs-table
1125     :keystroke gesture :errorp nil))
1126    
1127     (dead-grave-set-key '(#\A) '(com-insert-charcode 192))
1128     (dead-grave-set-key '(#\E) '(com-insert-charcode 200))
1129     (dead-grave-set-key '(#\I) '(com-insert-charcode 204))
1130     (dead-grave-set-key '(#\O) '(com-insert-charcode 210))
1131     (dead-grave-set-key '(#\U) '(com-insert-charcode 217))
1132     (dead-grave-set-key '(#\a) '(com-insert-charcode 224))
1133     (dead-grave-set-key '(#\e) '(com-insert-charcode 232))
1134     (dead-grave-set-key '(#\i) '(com-insert-charcode 236))
1135     (dead-grave-set-key '(#\o) '(com-insert-charcode 242))
1136     (dead-grave-set-key '(#\u) '(com-insert-charcode 249))
1137     (dead-grave-set-key '(#\Space) '(com-insert-charcode 96))
1138    
1139     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1140     ;;;
1141     ;;; Dead-diaeresis command table
1142    
1143     (make-command-table 'dead-diaeresis-climacs-table :errorp nil)
1144    
1145     (add-menu-item-to-command-table 'global-climacs-table "dead-diaeresis"
1146     :menu 'dead-diaeresis-climacs-table
1147     :keystroke '(:dead--diaeresis :shift))
1148    
1149     (defun dead-diaeresis-set-key (gesture command)
1150     (add-command-to-command-table command 'dead-diaeresis-climacs-table
1151     :keystroke gesture :errorp nil))
1152    
1153     (dead-diaeresis-set-key '(#\A) '(com-insert-charcode 196))
1154     (dead-diaeresis-set-key '(#\E) '(com-insert-charcode 203))
1155     (dead-diaeresis-set-key '(#\I) '(com-insert-charcode 207))
1156     (dead-diaeresis-set-key '(#\O) '(com-insert-charcode 214))
1157     (dead-diaeresis-set-key '(#\U) '(com-insert-charcode 220))
1158     (dead-diaeresis-set-key '(#\a) '(com-insert-charcode 228))
1159     (dead-diaeresis-set-key '(#\e) '(com-insert-charcode 235))
1160     (dead-diaeresis-set-key '(#\i) '(com-insert-charcode 239))
1161     (dead-diaeresis-set-key '(#\o) '(com-insert-charcode 246))
1162     (dead-diaeresis-set-key '(#\u) '(com-insert-charcode 252))
1163     (dead-diaeresis-set-key '(#\y) '(com-insert-charcode 255))
1164     (dead-diaeresis-set-key '(#\Space) '(com-insert-charcode 34))
1165    
1166     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1167     ;;;
1168     ;;; Dead-tilde command table
1169    
1170     (make-command-table 'dead-tilde-climacs-table :errorp nil)
1171    
1172     (add-menu-item-to-command-table 'global-climacs-table "dead-tilde"
1173     :menu 'dead-tilde-climacs-table
1174     :keystroke '(:dead--tilde :shift))
1175    
1176     (defun dead-tilde-set-key (gesture command)
1177     (add-command-to-command-table command 'dead-tilde-climacs-table
1178     :keystroke gesture :errorp nil))
1179    
1180     (dead-tilde-set-key '(#\A) '(com-insert-charcode 195))
1181     (dead-tilde-set-key '(#\N) '(com-insert-charcode 209))
1182     (dead-tilde-set-key '(#\a) '(com-insert-charcode 227))
1183     (dead-tilde-set-key '(#\n) '(com-insert-charcode 241))
1184     (dead-tilde-set-key '(#\E) '(com-insert-charcode 198))
1185     (dead-tilde-set-key '(#\e) '(com-insert-charcode 230))
1186     (dead-tilde-set-key '(#\D) '(com-insert-charcode 208))
1187     (dead-tilde-set-key '(#\d) '(com-insert-charcode 240))
1188     (dead-tilde-set-key '(#\O) '(com-insert-charcode 216))
1189     (dead-tilde-set-key '(#\o) '(com-insert-charcode 248))
1190     (dead-tilde-set-key '(#\Space) '(com-insert-charcode 126))
1191    
1192     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1193     ;;;
1194     ;;; Dead-circumflex command table
1195    
1196     (make-command-table 'dead-circumflex-climacs-table :errorp nil)
1197    
1198     (add-menu-item-to-command-table 'global-climacs-table "dead-circumflex"
1199     :menu 'dead-circumflex-climacs-table
1200     :keystroke '(:dead--circumflex :shift))
1201    
1202     (defun dead-circumflex-set-key (gesture command)
1203     (add-command-to-command-table command 'dead-circumflex-climacs-table
1204     :keystroke gesture :errorp nil))
1205    
1206     (dead-circumflex-set-key '(#\A) '(com-insert-charcode 194))
1207     (dead-circumflex-set-key '(#\E) '(com-insert-charcode 202))
1208     (dead-circumflex-set-key '(#\I) '(com-insert-charcode 206))
1209     (dead-circumflex-set-key '(#\O) '(com-insert-charcode 212))
1210     (dead-circumflex-set-key '(#\U) '(com-insert-charcode 219))
1211     (dead-circumflex-set-key '(#\a) '(com-insert-charcode 226))
1212     (dead-circumflex-set-key '(#\e) '(com-insert-charcode 234))
1213     (dead-circumflex-set-key '(#\i) '(com-insert-charcode 238))
1214     (dead-circumflex-set-key '(#\o) '(com-insert-charcode 244))
1215     (dead-circumflex-set-key '(#\u) '(com-insert-charcode 251))
1216     (dead-circumflex-set-key '(#\Space) '(com-insert-charcode 94))

  ViewVC Help
Powered by ViewVC 1.1.5