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

Contents of /climacs/gui.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.90 - (hide annotations)
Thu Jan 20 23:42:04 2005 UTC (9 years, 2 months ago) by mvilleneuve
Branch: MAIN
Changes since 1.89: +21 -0 lines
Added command fill-paragraph (bound to M-q)
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 mvilleneuve 1.90 (define-named-command com-fill-paragraph ()
509     (let* ((pane (current-window))
510     (buffer (buffer pane))
511     (syntax (syntax buffer))
512     (point (point pane))
513     (begin-mark (clone-mark point))
514     (end-mark (clone-mark point)))
515     (unless (eql (object-before begin-mark) #\Newline)
516     (beginning-of-paragraph begin-mark syntax))
517     (unless (eql (object-after end-mark) #\Newline)
518     (end-of-paragraph end-mark syntax))
519     (do-buffer-region (object offset buffer
520     (offset begin-mark) (offset end-mark))
521     (when (eql object #\Newline)
522     (setf object #\Space)))
523     (let ((point-backup (clone-mark point)))
524     (setf (offset point) (offset end-mark))
525     (possibly-fill-line)
526     (setf (offset point) (offset point-backup)))))
527    
528 ejohnson 1.27 (define-command com-extended-command ()
529     (let ((item (accept 'command :prompt "Extended Command")))
530     (execute-frame-command *application-frame* item)))
531    
532 rstrandh 1.41 (eval-when (:compile-toplevel :load-toplevel)
533 ejohnson 1.35 (define-presentation-type completable-pathname ()
534     :inherit-from 'pathname))
535 ejohnson 1.27
536     (defun filename-completer (so-far mode)
537     (flet ((remove-trail (s)
538     (subseq s 0 (let ((pos (position #\/ s :from-end t)))
539     (if pos (1+ pos) 0)))))
540     (let* ((directory-prefix
541     (if (and (plusp (length so-far)) (eql (aref so-far 0) #\/))
542     ""
543 rstrandh 1.78 (namestring #+sbcl *default-pathname-defaults*
544     #+cmu (ext:default-directory)
545     #-(or sbcl cmu) *default-pathname-defaults*)))
546 ejohnson 1.27 (full-so-far (concatenate 'string directory-prefix so-far))
547     (pathnames
548     (loop with length = (length full-so-far)
549     for path in (directory (concatenate 'string
550     (remove-trail so-far)
551     "*.*"))
552     when (let ((mismatch (mismatch (namestring path) full-so-far)))
553     (or (null mismatch) (= mismatch length)))
554     collect path))
555     (strings (mapcar #'namestring pathnames))
556     (first-string (car strings))
557     (length-common-prefix nil)
558     (completed-string nil)
559     (full-completed-string nil))
560     (unless (null pathnames)
561     (setf length-common-prefix
562     (loop with length = (length first-string)
563     for string in (cdr strings)
564     do (setf length (min length (or (mismatch string first-string) length)))
565     finally (return length))))
566     (unless (null pathnames)
567     (setf completed-string
568     (subseq first-string (length directory-prefix)
569     (if (null (cdr pathnames)) nil length-common-prefix)))
570     (setf full-completed-string
571     (concatenate 'string directory-prefix completed-string)))
572     (case mode
573     ((:complete-limited :complete-maximal)
574     (cond ((null pathnames)
575     (values so-far nil nil 0 nil))
576     ((null (cdr pathnames))
577     (values completed-string t (car pathnames) 1 nil))
578     (t
579     (values completed-string nil nil (length pathnames) nil))))
580     (:complete
581     (cond ((null pathnames)
582     (values so-far t so-far 1 nil))
583     ((null (cdr pathnames))
584     (values completed-string t (car pathnames) 1 nil))
585     ((find full-completed-string strings :test #'string-equal)
586     (let ((pos (position full-completed-string strings :test #'string-equal)))
587     (values completed-string
588     t (elt pathnames pos) (length pathnames) nil)))
589     (t
590     (values completed-string nil nil (length pathnames) nil))))
591     (:possibilities
592     (values nil nil nil (length pathnames)
593     (loop with length = (length directory-prefix)
594     for name in pathnames
595     collect (list (subseq (namestring name) length nil)
596     name))))))))
597    
598     (define-presentation-method accept
599     ((type completable-pathname) stream (view textual-view) &key)
600     (multiple-value-bind (pathname success string)
601     (complete-input stream
602     #'filename-completer
603     :partial-completers '(#\Space)
604     :allow-any-input t)
605     (declare (ignore success))
606     (or pathname string)))
607    
608     (defun pathname-filename (pathname)
609     (if (null (pathname-type pathname))
610     (pathname-name pathname)
611     (concatenate 'string (pathname-name pathname)
612     "." (pathname-type pathname))))
613    
614 abridgewater 1.34 (define-named-command com-find-file ()
615 ejohnson 1.27 (let ((filename (accept 'completable-pathname
616 rstrandh 1.70 :prompt "Find File"))
617     (buffer (make-instance 'climacs-buffer))
618 rstrandh 1.80 (pane (current-window)))
619 rstrandh 1.75 (push buffer (buffers *application-frame*))
620 rstrandh 1.80 (setf (buffer (current-window)) buffer)
621 rstrandh 1.70 (setf (syntax buffer) (make-instance 'basic-syntax))
622 rstrandh 1.84 ;; Don't want to create the file if it doesn't exist.
623     (when (probe-file filename)
624     (with-open-file (stream filename :direction :input)
625     (input-from-stream stream buffer 0)))
626 rstrandh 1.70 (setf (filename buffer) filename
627     (name buffer) (pathname-filename filename)
628     (needs-saving buffer) nil)
629     (beginning-of-buffer (point pane))
630     ;; this one is needed so that the buffer modification protocol
631     ;; resets the low and high marks after redisplay
632     (redisplay-frame-panes *application-frame*)))
633 ejohnson 1.27
634 abridgewater 1.34 (define-named-command com-save-buffer ()
635 rstrandh 1.80 (let* ((buffer (buffer (current-window)))
636 rstrandh 1.30 (filename (or (filename buffer)
637     (accept 'completable-pathname
638     :prompt "Save Buffer to File"))))
639     (if (or (null (filename buffer))
640     (needs-saving buffer))
641     (progn (with-open-file (stream filename :direction :output :if-exists :supersede)
642     (output-to-stream stream buffer 0 (size buffer)))
643     (setf (filename buffer) filename
644     (name buffer) (pathname-filename filename))
645     (display-message "Wrote: ~a" (filename buffer)))
646     (display-message "No changes need to be saved from ~a" (name buffer)))
647     (setf (needs-saving buffer) nil)))
648 ejohnson 1.27
649 abridgewater 1.34 (define-named-command com-write-buffer ()
650 ejohnson 1.27 (let ((filename (accept 'completable-pathname
651     :prompt "Write Buffer to File"))
652 rstrandh 1.80 (buffer (buffer (current-window))))
653 ejohnson 1.27 (with-open-file (stream filename :direction :output :if-exists :supersede)
654     (output-to-stream stream buffer 0 (size buffer)))
655     (setf (filename buffer) filename
656 rstrandh 1.28 (name buffer) (pathname-filename filename)
657 rstrandh 1.30 (needs-saving buffer) nil)
658     (display-message "Wrote: ~a" (filename buffer))))
659 ejohnson 1.27
660 rstrandh 1.75 (define-presentation-method accept
661     ((type buffer) stream (view textual-view) &key)
662     (multiple-value-bind (object success string)
663     (complete-input stream
664     (lambda (so-far action)
665     (complete-from-possibilities
666     so-far (buffers *application-frame*) '() :action action
667     :name-key #'name
668     :value-key #'identity))
669     :partial-completers '(#\Space)
670     :allow-any-input t)
671 rstrandh 1.76 (declare (ignore success))
672     (or object
673     (car (push (make-instance 'climacs-buffer :name string)
674     (buffers *application-frame*))))))
675 rstrandh 1.75
676     (define-named-command com-switch-to-buffer ()
677     (let ((buffer (accept 'buffer
678     :prompt "Switch to buffer")))
679 rstrandh 1.80 (setf (buffer (current-window)) buffer)
680 rstrandh 1.75 (setf (syntax buffer) (make-instance 'basic-syntax))
681 rstrandh 1.80 (beginning-of-buffer (point (current-window)))
682     (full-redisplay (current-window))))
683 rstrandh 1.75
684     (define-named-command com-full-redisplay ()
685 rstrandh 1.80 (full-redisplay (current-window)))
686 rstrandh 1.75
687 rstrandh 1.63 (define-named-command com-load-file ()
688     (let ((filename (accept 'completable-pathname
689     :prompt "Load File")))
690     (load filename)))
691    
692 abridgewater 1.34 (define-named-command com-beginning-of-buffer ()
693 rstrandh 1.80 (beginning-of-buffer (point (current-window))))
694 ejohnson 1.27
695 rstrandh 1.39 (define-named-command com-page-down ()
696 rstrandh 1.80 (let ((pane (current-window)))
697 rstrandh 1.70 (page-down pane)))
698 rstrandh 1.39
699 rstrandh 1.40 (define-named-command com-page-up ()
700 rstrandh 1.80 (let ((pane (current-window)))
701 rstrandh 1.70 (page-up pane)))
702 rstrandh 1.40
703 abridgewater 1.34 (define-named-command com-end-of-buffer ()
704 rstrandh 1.80 (end-of-buffer (point (current-window))))
705 ejohnson 1.27
706 abridgewater 1.34 (define-named-command com-back-to-indentation ()
707 rstrandh 1.80 (let ((point (point (current-window))))
708 rstrandh 1.32 (beginning-of-line point)
709     (loop until (end-of-line-p point)
710     while (whitespacep (object-after point))
711     do (incf (offset point)))))
712    
713 abridgewater 1.34 (define-named-command com-goto-position ()
714 rstrandh 1.80 (setf (offset (point (current-window)))
715 rstrandh 1.32 (accept 'integer :prompt "Goto Position")))
716    
717 abridgewater 1.34 (define-named-command com-goto-line ()
718 rstrandh 1.32 (loop with mark = (make-instance 'standard-right-sticky-mark
719 rstrandh 1.80 :buffer (buffer (current-window)))
720 rstrandh 1.32 do (end-of-line mark)
721     until (end-of-buffer-p mark)
722     repeat (accept 'integer :prompt "Goto Line")
723     do (incf (offset mark))
724     (end-of-line mark)
725     finally (beginning-of-line mark)
726 rstrandh 1.80 (setf (offset (point (current-window)))
727 rstrandh 1.32 (offset mark))))
728    
729 abridgewater 1.34 (define-named-command com-browse-url ()
730 ejohnson 1.27 (accept 'url :prompt "Browse URL"))
731    
732 abridgewater 1.34 (define-named-command com-set-mark ()
733 rstrandh 1.80 (let ((pane (current-window)))
734 rstrandh 1.70 (setf (mark pane) (clone-mark (point pane)))))
735 rstrandh 1.45
736     (define-named-command com-exchange-point-and-mark ()
737 rstrandh 1.80 (let ((pane (current-window)))
738 rstrandh 1.70 (psetf (offset (mark pane)) (offset (point pane))
739     (offset (point pane)) (offset (mark pane)))))
740 rstrandh 1.38
741     (define-named-command com-set-syntax ()
742 rstrandh 1.80 (let* ((pane (current-window))
743 rstrandh 1.67 (buffer (buffer pane)))
744 rstrandh 1.70 (setf (syntax buffer)
745     (make-instance (accept 'syntax :prompt "Set Syntax")))
746 rstrandh 1.67 (setf (offset (low-mark buffer)) 0
747     (offset (high-mark buffer)) (size buffer))))
748 ejohnson 1.27
749 rstrandh 1.77 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
750     ;;;
751 rstrandh 1.85 ;;; Keyboard macros
752    
753     (define-named-command com-start-kbd-macro ()
754     (setf (recordingp *application-frame*) t)
755     (setf (recorded-keys *application-frame*) '()))
756    
757     (define-named-command com-end-kbd-macro ()
758     (setf (recordingp *application-frame*) nil)
759     (setf (recorded-keys *application-frame*)
760     ;; this won't work if the command was invoked in any old way
761     (reverse (cddr (recorded-keys *application-frame*)))))
762    
763     (define-named-command com-call-last-kbd-macro ()
764     (setf (remaining-keys *application-frame*)
765     (recorded-keys *application-frame*))
766     (setf (executingp *application-frame*) t))
767    
768     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
769     ;;;
770 rstrandh 1.77 ;;; Commands for splitting windows
771    
772 rstrandh 1.83 (defun replace-constellation (constellation additional-constellation vertical-p)
773     (let* ((parent (sheet-parent constellation))
774     (children (sheet-children parent))
775     (first (first children))
776     (second (second children)))
777     (assert (member constellation children))
778     (cond ((eq constellation first)
779     (sheet-disown-child parent constellation)
780     (let ((new (if vertical-p
781     (vertically () constellation additional-constellation)
782     (horizontally () constellation additional-constellation))))
783     (sheet-adopt-child parent new)
784     (reorder-sheets parent (list new second))))
785     (t
786     (sheet-disown-child parent constellation)
787     (let ((new (if vertical-p
788     (vertically () constellation additional-constellation)
789     (horizontally () constellation additional-constellation))))
790     (sheet-adopt-child parent new)
791     (reorder-sheets parent (list first new)))))))
792    
793     (defun parent3 (sheet)
794     (sheet-parent (sheet-parent (sheet-parent sheet))))
795    
796     (defun make-pane-constellation ()
797     "make a vbox containing a scroller pane as its first child and an
798     info pane as its second child. The scroller pane contains a viewport
799     which contains an extended pane. Return the vbox and the extended pane
800     as two values"
801     (let* ((extended-pane
802     (make-pane 'extended-pane
803     :width 900 :height 400
804     :name 'win
805     :incremental-redisplay t
806     :display-function 'display-win))
807     (vbox
808     (vertically ()
809     (scrolling () extended-pane)
810     (make-pane 'info-pane
811     :climacs-pane extended-pane
812     :width 900 :height 20
813     :max-height 20 :min-height 20
814     ::background +gray85+
815     :scroll-bars nil
816     :borders nil
817     :incremental-redisplay t
818     :display-function 'display-info))))
819     (values vbox extended-pane)))
820    
821 rstrandh 1.77 (define-named-command com-split-window-vertically ()
822     (with-look-and-feel-realization
823     ((frame-manager *application-frame*) *application-frame*)
824 rstrandh 1.83 (multiple-value-bind (vbox new-pane) (make-pane-constellation)
825     (let* ((current-window (current-window))
826     (constellation-root (parent3 current-window)))
827     (setf (buffer new-pane) (buffer current-window))
828     (push new-pane (windows *application-frame*))
829     (replace-constellation constellation-root vbox t)
830     (full-redisplay current-window)
831     (full-redisplay new-pane)))))
832    
833     (define-named-command com-split-window-horizontally ()
834     (with-look-and-feel-realization
835     ((frame-manager *application-frame*) *application-frame*)
836     (multiple-value-bind (vbox new-pane) (make-pane-constellation)
837     (let* ((current-window (current-window))
838     (constellation-root (parent3 current-window)))
839     (setf (buffer new-pane) (buffer current-window))
840     (push new-pane (windows *application-frame*))
841     (replace-constellation constellation-root vbox nil)
842     (full-redisplay current-window)
843     (full-redisplay new-pane)))))
844    
845     (define-named-command com-other-window ()
846     (setf (windows *application-frame*)
847     (append (cdr (windows *application-frame*))
848     (list (car (windows *application-frame*))))))
849    
850     (define-named-command com-delete-window ()
851     (unless (null (cdr (windows *application-frame*)))
852     (let* ((constellation (parent3 (current-window)))
853     (box (sheet-parent constellation))
854     (box-children (sheet-children box))
855     (other (if (eq constellation (first box-children))
856     (second box-children)
857     (first box-children)))
858     (parent (sheet-parent box))
859     (children (sheet-children parent))
860     (first (first children))
861     (second (second children)))
862     (pop (windows *application-frame*))
863     (sheet-disown-child box other)
864     (cond ((eq box first)
865     (sheet-disown-child parent box)
866     (sheet-adopt-child parent other)
867     (reorder-sheets parent (list other second)))
868     (t
869     (sheet-disown-child parent box)
870     (sheet-adopt-child parent other)
871     (reorder-sheets parent (list first other)))))))
872 rstrandh 1.77
873 ejohnson 1.27 ;;;;;;;;;;;;;;;;;;;;
874     ;; Kill ring commands
875    
876 ejohnson 1.31 ;; Copies an element from a kill-ring to a buffer at the given offset
877 ejohnson 1.50 (define-named-command com-yank ()
878 rstrandh 1.80 (insert-sequence (point (current-window)) (kill-ring-yank *kill-ring*)))
879 ejohnson 1.27
880 ejohnson 1.31 ;; Destructively cut a given buffer region into the kill-ring
881 abridgewater 1.34 (define-named-command com-cut-out ()
882 rstrandh 1.80 (multiple-value-bind (start end) (region-limits (current-window))
883 mvilleneuve 1.64 (kill-ring-standard-push *kill-ring* (region-to-sequence start end))
884     (delete-region (offset start) end)))
885 ejohnson 1.27
886 ejohnson 1.31 ;; Non destructively copies in buffer region to the kill ring
887 abridgewater 1.34 (define-named-command com-copy-out ()
888 rstrandh 1.80 (let ((pane (current-window)))
889 rstrandh 1.70 (kill-ring-standard-push *kill-ring* (region-to-sequence (point pane) (mark pane)))))
890 ejohnson 1.27
891 ejohnson 1.50 (define-named-command com-rotate-yank ()
892 rstrandh 1.80 (let* ((pane (current-window))
893 ejohnson 1.54 (point (point pane))
894 ejohnson 1.50 (last-yank (kill-ring-yank *kill-ring*)))
895 ejohnson 1.54 (if (eq (previous-command pane)
896 ejohnson 1.50 'com-rotate-yank)
897 ejohnson 1.54 (progn
898     (delete-range point (* -1 (length last-yank)))
899     (rotate-yank-position *kill-ring*)))
900     (insert-sequence point (kill-ring-yank *kill-ring*))))
901 ejohnson 1.27
902 ejohnson 1.50 (define-named-command com-resize-kill-ring ()
903 ejohnson 1.46 (let ((size (accept 'integer :prompt "New kill ring size")))
904 ejohnson 1.50 (setf (kill-ring-max-size *kill-ring*) size)))
905 rstrandh 1.47
906     (define-named-command com-search-forward ()
907 rstrandh 1.80 (search-forward (point (current-window))
908 rstrandh 1.47 (accept 'string :prompt "Search Forward")
909     :test (lambda (a b)
910     (and (characterp b) (char-equal a b)))))
911    
912     (define-named-command com-search-backward ()
913 rstrandh 1.80 (search-backward (point (current-window))
914 rstrandh 1.47 (accept 'string :prompt "Search Backward")
915     :test (lambda (a b)
916     (and (characterp b) (char-equal a b)))))
917 ejohnson 1.27
918 rstrandh 1.49 (define-named-command com-dabbrev-expand ()
919 rstrandh 1.80 (let* ((win (current-window))
920 rstrandh 1.49 (point (point win)))
921     (with-slots (original-prefix prefix-start-offset dabbrev-expansion-mark) win
922     (flet ((move () (cond ((beginning-of-buffer-p dabbrev-expansion-mark)
923     (setf (offset dabbrev-expansion-mark)
924     (offset point))
925     (forward-word dabbrev-expansion-mark))
926     ((mark< dabbrev-expansion-mark point)
927     (backward-object dabbrev-expansion-mark))
928     (t (forward-object dabbrev-expansion-mark)))))
929     (unless (or (beginning-of-buffer-p point)
930     (not (constituentp (object-before point))))
931     (unless (and (eq (previous-command win) 'com-dabbrev-expand)
932     (not (null prefix-start-offset)))
933     (setf dabbrev-expansion-mark (clone-mark point))
934     (backward-word dabbrev-expansion-mark)
935     (setf prefix-start-offset (offset dabbrev-expansion-mark))
936     (setf original-prefix (region-to-sequence prefix-start-offset point))
937     (move))
938     (loop until (or (end-of-buffer-p dabbrev-expansion-mark)
939     (and (or (beginning-of-buffer-p dabbrev-expansion-mark)
940     (not (constituentp (object-before dabbrev-expansion-mark))))
941     (looking-at dabbrev-expansion-mark original-prefix)))
942     do (move))
943     (if (end-of-buffer-p dabbrev-expansion-mark)
944     (progn (delete-region prefix-start-offset point)
945     (insert-sequence point original-prefix)
946     (setf prefix-start-offset nil))
947     (progn (delete-region prefix-start-offset point)
948     (insert-sequence point
949     (let ((offset (offset dabbrev-expansion-mark)))
950     (prog2 (forward-word dabbrev-expansion-mark)
951     (region-to-sequence offset dabbrev-expansion-mark)
952     (setf (offset dabbrev-expansion-mark) offset))))
953     (move))))))))
954    
955 rstrandh 1.71 (define-named-command com-beginning-of-paragraph ()
956 rstrandh 1.80 (let* ((pane (current-window))
957 rstrandh 1.71 (point (point pane))
958     (syntax (syntax (buffer pane))))
959     (beginning-of-paragraph point syntax)))
960    
961     (define-named-command com-end-of-paragraph ()
962 rstrandh 1.80 (let* ((pane (current-window))
963 rstrandh 1.71 (point (point pane))
964     (syntax (syntax (buffer pane))))
965     (end-of-paragraph point syntax)))
966    
967 ejohnson 1.27 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
968     ;;;
969 rstrandh 1.80 ;;; Global and dead-escape command tables
970 ejohnson 1.27
971     (make-command-table 'global-climacs-table :errorp nil)
972    
973 rstrandh 1.80 (make-command-table 'dead-escape-climacs-table :errorp nil)
974    
975     (add-menu-item-to-command-table 'global-climacs-table "dead-escape"
976     :menu 'dead-escape-climacs-table
977     :keystroke '(:escape))
978    
979     (defun dead-escape-set-key (gesture command)
980     (add-command-to-command-table command 'dead-escape-climacs-table
981     :keystroke gesture :errorp nil))
982    
983 ejohnson 1.27 (defun global-set-key (gesture command)
984     (add-command-to-command-table command 'global-climacs-table
985 rstrandh 1.80 :keystroke gesture :errorp nil)
986     (when (and
987     (listp gesture)
988     (find :meta gesture))
989     (dead-escape-set-key (remove :meta gesture) command)))
990 ejohnson 1.27
991 mvilleneuve 1.89 (loop for code from (char-code #\Space) to (char-code #\~)
992 ejohnson 1.27 do (global-set-key (code-char code) 'com-self-insert))
993    
994 mvilleneuve 1.89 (global-set-key #\Newline 'com-self-insert)
995 mvilleneuve 1.86 (global-set-key #\Tab 'com-indent-line)
996 mvilleneuve 1.79 (global-set-key '(#\j :control) 'com-newline-and-indent)
997 rstrandh 1.62 (global-set-key '(#\f :control) `(com-forward-object ,*numeric-argument-marker*))
998     (global-set-key '(#\b :control) `(com-backward-object ,*numeric-argument-marker*))
999 ejohnson 1.27 (global-set-key '(#\a :control) 'com-beginning-of-line)
1000     (global-set-key '(#\e :control) 'com-end-of-line)
1001 rstrandh 1.62 (global-set-key '(#\d :control) `(com-delete-object ,*numeric-argument-marker*))
1002 ejohnson 1.27 (global-set-key '(#\p :control) 'com-previous-line)
1003 rstrandh 1.75 (global-set-key '(#\l :control) 'com-full-redisplay)
1004 ejohnson 1.27 (global-set-key '(#\n :control) 'com-next-line)
1005     (global-set-key '(#\o :control) 'com-open-line)
1006     (global-set-key '(#\k :control) 'com-kill-line)
1007 rstrandh 1.42 (global-set-key '(#\t :control) 'com-transpose-objects)
1008 ejohnson 1.27 (global-set-key '(#\Space :control) 'com-set-mark)
1009 ejohnson 1.50 (global-set-key '(#\y :control) 'com-yank)
1010 ejohnson 1.27 (global-set-key '(#\w :control) 'com-cut-out)
1011     (global-set-key '(#\f :meta) 'com-forward-word)
1012     (global-set-key '(#\b :meta) 'com-backward-word)
1013 rstrandh 1.43 (global-set-key '(#\t :meta) 'com-transpose-words)
1014 rstrandh 1.60 (global-set-key '(#\u :meta) 'com-upcase-word)
1015     (global-set-key '(#\l :meta) 'com-downcase-word)
1016     (global-set-key '(#\c :meta) 'com-capitalize-word)
1017 ejohnson 1.27 (global-set-key '(#\x :meta) 'com-extended-command)
1018 ejohnson 1.50 (global-set-key '(#\y :meta) 'com-rotate-yank)
1019 ejohnson 1.27 (global-set-key '(#\w :meta) 'com-copy-out)
1020 rstrandh 1.39 (global-set-key '(#\v :control) 'com-page-down)
1021 rstrandh 1.40 (global-set-key '(#\v :meta) 'com-page-up)
1022 ejohnson 1.27 (global-set-key '(#\< :shift :meta) 'com-beginning-of-buffer)
1023     (global-set-key '(#\> :shift :meta) 'com-end-of-buffer)
1024 rstrandh 1.32 (global-set-key '(#\m :meta) 'com-back-to-indentation)
1025 mvilleneuve 1.74 (global-set-key '(#\^ :shift :meta) 'com-delete-indentation)
1026 mvilleneuve 1.90 (global-set-key '(#\q :meta) 'com-fill-paragraph)
1027 rstrandh 1.32 (global-set-key '(#\d :meta) 'com-delete-word)
1028     (global-set-key '(#\Backspace :meta) 'com-backward-delete-word)
1029 rstrandh 1.49 (global-set-key '(#\/ :meta) 'com-dabbrev-expand)
1030 rstrandh 1.71 (global-set-key '(#\a :control :meta) 'com-beginning-of-paragraph)
1031     (global-set-key '(#\e :control :meta) 'com-end-of-paragraph)
1032 ejohnson 1.27
1033     (global-set-key '(:up) 'com-previous-line)
1034     (global-set-key '(:down) 'com-next-line)
1035 rstrandh 1.62 (global-set-key '(:left) `(com-backward-object ,*numeric-argument-marker*))
1036 ejohnson 1.66 (global-set-key '(:right) `(com-forward-object ,*numeric-argument-marker*))
1037 ejohnson 1.27 (global-set-key '(:left :control) 'com-backward-word)
1038     (global-set-key '(:right :control) 'com-forward-word)
1039     (global-set-key '(:home) 'com-beginning-of-line)
1040     (global-set-key '(:end) 'com-end-of-line)
1041 abridgewater 1.57 (global-set-key '(:prior) 'com-page-up)
1042     (global-set-key '(:next) 'com-page-down)
1043 ejohnson 1.27 (global-set-key '(:home :control) 'com-beginning-of-buffer)
1044     (global-set-key '(:end :control) 'com-end-of-buffer)
1045 rstrandh 1.62 (global-set-key #\Rubout `(com-delete-object ,*numeric-argument-marker*))
1046     (global-set-key #\Backspace `(com-backward-delete-object ,*numeric-argument-marker*))
1047 abakic 1.58
1048     (global-set-key '(:insert) 'com-toggle-overwrite-mode)
1049 ejohnson 1.27
1050     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1051     ;;;
1052     ;;; C-x command table
1053    
1054     (make-command-table 'c-x-climacs-table :errorp nil)
1055    
1056     (add-menu-item-to-command-table 'global-climacs-table "C-x"
1057     :menu 'c-x-climacs-table
1058     :keystroke '(#\x :control))
1059    
1060     (defun c-x-set-key (gesture command)
1061     (add-command-to-command-table command 'c-x-climacs-table
1062     :keystroke gesture :errorp nil))
1063    
1064 rstrandh 1.83 (c-x-set-key '(#\0) 'com-delete-window)
1065 rstrandh 1.77 (c-x-set-key '(#\2) 'com-split-window-vertically)
1066 rstrandh 1.83 (c-x-set-key '(#\3) 'com-split-window-horizontally)
1067 rstrandh 1.85 (c-x-set-key '(#\() 'com-start-kbd-macro)
1068     (c-x-set-key '(#\)) 'com-end-kbd-macro)
1069 rstrandh 1.75 (c-x-set-key '(#\b) 'com-switch-to-buffer)
1070 rstrandh 1.85 (c-x-set-key '(#\e) 'com-call-last-kbd-macro)
1071 ejohnson 1.27 (c-x-set-key '(#\c :control) 'com-quit)
1072     (c-x-set-key '(#\f :control) 'com-find-file)
1073 rstrandh 1.63 (c-x-set-key '(#\l :control) 'com-load-file)
1074 rstrandh 1.83 (c-x-set-key '(#\o) 'com-other-window)
1075 ejohnson 1.27 (c-x-set-key '(#\s :control) 'com-save-buffer)
1076 rstrandh 1.45 (c-x-set-key '(#\t :control) 'com-transpose-lines)
1077 ejohnson 1.27 (c-x-set-key '(#\w :control) 'com-write-buffer)
1078 rstrandh 1.45 (c-x-set-key '(#\x :control) 'com-exchange-point-and-mark)
1079 rstrandh 1.44
1080     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1081     ;;;
1082     ;;; Some Unicode stuff
1083    
1084     (define-named-command com-insert-charcode ((code 'integer :prompt "Code point"))
1085 rstrandh 1.80 (insert-object (point (current-window)) (code-char code)))
1086 rstrandh 1.44
1087     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1088     ;;;
1089     ;;; Dead-acute command table
1090    
1091     (make-command-table 'dead-acute-climacs-table :errorp nil)
1092    
1093     (add-menu-item-to-command-table 'global-climacs-table "dead-acute"
1094     :menu 'dead-acute-climacs-table
1095     :keystroke '(:dead--acute))
1096    
1097     (defun dead-acute-set-key (gesture command)
1098     (add-command-to-command-table command 'dead-acute-climacs-table
1099     :keystroke gesture :errorp nil))
1100    
1101     (dead-acute-set-key '(#\A) '(com-insert-charcode 193))
1102     (dead-acute-set-key '(#\E) '(com-insert-charcode 201))
1103     (dead-acute-set-key '(#\I) '(com-insert-charcode 205))
1104     (dead-acute-set-key '(#\O) '(com-insert-charcode 211))
1105     (dead-acute-set-key '(#\U) '(com-insert-charcode 218))
1106     (dead-acute-set-key '(#\Y) '(com-insert-charcode 221))
1107     (dead-acute-set-key '(#\a) '(com-insert-charcode 225))
1108     (dead-acute-set-key '(#\e) '(com-insert-charcode 233))
1109     (dead-acute-set-key '(#\i) '(com-insert-charcode 237))
1110     (dead-acute-set-key '(#\o) '(com-insert-charcode 243))
1111     (dead-acute-set-key '(#\u) '(com-insert-charcode 250))
1112     (dead-acute-set-key '(#\y) '(com-insert-charcode 253))
1113     (dead-acute-set-key '(#\C) '(com-insert-charcode 199))
1114     (dead-acute-set-key '(#\c) '(com-insert-charcode 231))
1115     (dead-acute-set-key '(#\x) '(com-insert-charcode 215))
1116     (dead-acute-set-key '(#\-) '(com-insert-charcode 247))
1117     (dead-acute-set-key '(#\T) '(com-insert-charcode 222))
1118     (dead-acute-set-key '(#\t) '(com-insert-charcode 254))
1119     (dead-acute-set-key '(#\s) '(com-insert-charcode 223))
1120     (dead-acute-set-key '(#\Space) '(com-insert-charcode 39))
1121    
1122 rstrandh 1.45 (make-command-table 'dead-acute-dead-accute-climacs-table :errorp nil)
1123    
1124     (add-menu-item-to-command-table 'dead-acute-climacs-table "dead-acute-dead-accute"
1125     :menu 'dead-acute-dead-accute-climacs-table
1126     :keystroke '(:dead--acute))
1127    
1128     (defun dead-acute-dead-accute-set-key (gesture command)
1129     (add-command-to-command-table command 'dead-acute-dead-accute-climacs-table
1130     :keystroke gesture :errorp nil))
1131    
1132     (dead-acute-dead-accute-set-key '(#\A) '(com-insert-charcode 197))
1133     (dead-acute-dead-accute-set-key '(#\a) '(com-insert-charcode 229))
1134 rstrandh 1.44 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1135     ;;;
1136     ;;; Dead-grave command table
1137    
1138     (make-command-table 'dead-grave-climacs-table :errorp nil)
1139    
1140     (add-menu-item-to-command-table 'global-climacs-table "dead-grave"
1141     :menu 'dead-grave-climacs-table
1142     :keystroke '(:dead--grave))
1143    
1144     (defun dead-grave-set-key (gesture command)
1145     (add-command-to-command-table command 'dead-grave-climacs-table
1146     :keystroke gesture :errorp nil))
1147    
1148     (dead-grave-set-key '(#\A) '(com-insert-charcode 192))
1149     (dead-grave-set-key '(#\E) '(com-insert-charcode 200))
1150     (dead-grave-set-key '(#\I) '(com-insert-charcode 204))
1151     (dead-grave-set-key '(#\O) '(com-insert-charcode 210))
1152     (dead-grave-set-key '(#\U) '(com-insert-charcode 217))
1153     (dead-grave-set-key '(#\a) '(com-insert-charcode 224))
1154     (dead-grave-set-key '(#\e) '(com-insert-charcode 232))
1155     (dead-grave-set-key '(#\i) '(com-insert-charcode 236))
1156     (dead-grave-set-key '(#\o) '(com-insert-charcode 242))
1157     (dead-grave-set-key '(#\u) '(com-insert-charcode 249))
1158     (dead-grave-set-key '(#\Space) '(com-insert-charcode 96))
1159    
1160     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1161     ;;;
1162     ;;; Dead-diaeresis command table
1163    
1164     (make-command-table 'dead-diaeresis-climacs-table :errorp nil)
1165    
1166     (add-menu-item-to-command-table 'global-climacs-table "dead-diaeresis"
1167     :menu 'dead-diaeresis-climacs-table
1168     :keystroke '(:dead--diaeresis :shift))
1169    
1170     (defun dead-diaeresis-set-key (gesture command)
1171     (add-command-to-command-table command 'dead-diaeresis-climacs-table
1172     :keystroke gesture :errorp nil))
1173    
1174     (dead-diaeresis-set-key '(#\A) '(com-insert-charcode 196))
1175     (dead-diaeresis-set-key '(#\E) '(com-insert-charcode 203))
1176     (dead-diaeresis-set-key '(#\I) '(com-insert-charcode 207))
1177     (dead-diaeresis-set-key '(#\O) '(com-insert-charcode 214))
1178     (dead-diaeresis-set-key '(#\U) '(com-insert-charcode 220))
1179     (dead-diaeresis-set-key '(#\a) '(com-insert-charcode 228))
1180     (dead-diaeresis-set-key '(#\e) '(com-insert-charcode 235))
1181     (dead-diaeresis-set-key '(#\i) '(com-insert-charcode 239))
1182     (dead-diaeresis-set-key '(#\o) '(com-insert-charcode 246))
1183     (dead-diaeresis-set-key '(#\u) '(com-insert-charcode 252))
1184     (dead-diaeresis-set-key '(#\y) '(com-insert-charcode 255))
1185     (dead-diaeresis-set-key '(#\Space) '(com-insert-charcode 34))
1186    
1187     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1188     ;;;
1189     ;;; Dead-tilde command table
1190    
1191     (make-command-table 'dead-tilde-climacs-table :errorp nil)
1192    
1193     (add-menu-item-to-command-table 'global-climacs-table "dead-tilde"
1194     :menu 'dead-tilde-climacs-table
1195     :keystroke '(:dead--tilde :shift))
1196    
1197     (defun dead-tilde-set-key (gesture command)
1198     (add-command-to-command-table command 'dead-tilde-climacs-table
1199     :keystroke gesture :errorp nil))
1200    
1201     (dead-tilde-set-key '(#\A) '(com-insert-charcode 195))
1202     (dead-tilde-set-key '(#\N) '(com-insert-charcode 209))
1203     (dead-tilde-set-key '(#\a) '(com-insert-charcode 227))
1204     (dead-tilde-set-key '(#\n) '(com-insert-charcode 241))
1205     (dead-tilde-set-key '(#\E) '(com-insert-charcode 198))
1206     (dead-tilde-set-key '(#\e) '(com-insert-charcode 230))
1207     (dead-tilde-set-key '(#\D) '(com-insert-charcode 208))
1208     (dead-tilde-set-key '(#\d) '(com-insert-charcode 240))
1209     (dead-tilde-set-key '(#\O) '(com-insert-charcode 216))
1210     (dead-tilde-set-key '(#\o) '(com-insert-charcode 248))
1211     (dead-tilde-set-key '(#\Space) '(com-insert-charcode 126))
1212    
1213     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1214     ;;;
1215     ;;; Dead-circumflex command table
1216    
1217     (make-command-table 'dead-circumflex-climacs-table :errorp nil)
1218    
1219     (add-menu-item-to-command-table 'global-climacs-table "dead-circumflex"
1220     :menu 'dead-circumflex-climacs-table
1221     :keystroke '(:dead--circumflex :shift))
1222    
1223     (defun dead-circumflex-set-key (gesture command)
1224     (add-command-to-command-table command 'dead-circumflex-climacs-table
1225     :keystroke gesture :errorp nil))
1226    
1227     (dead-circumflex-set-key '(#\A) '(com-insert-charcode 194))
1228     (dead-circumflex-set-key '(#\E) '(com-insert-charcode 202))
1229     (dead-circumflex-set-key '(#\I) '(com-insert-charcode 206))
1230     (dead-circumflex-set-key '(#\O) '(com-insert-charcode 212))
1231     (dead-circumflex-set-key '(#\U) '(com-insert-charcode 219))
1232     (dead-circumflex-set-key '(#\a) '(com-insert-charcode 226))
1233     (dead-circumflex-set-key '(#\e) '(com-insert-charcode 234))
1234     (dead-circumflex-set-key '(#\i) '(com-insert-charcode 238))
1235     (dead-circumflex-set-key '(#\o) '(com-insert-charcode 244))
1236     (dead-circumflex-set-key '(#\u) '(com-insert-charcode 251))
1237     (dead-circumflex-set-key '(#\Space) '(com-insert-charcode 94))

  ViewVC Help
Powered by ViewVC 1.1.5