/[climacs]/climacs/c-syntax-commands.lisp
ViewVC logotype

Contents of /climacs/c-syntax-commands.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Tue May 1 20:54:53 2007 UTC (6 years, 11 months ago) by dmurray
Branch: MAIN
Changes since 1.1: +13 -13 lines
Improved, if not completely correct, list navigation.
1 thenriksen 1.1 ;;; -*- Mode: Lisp; Package: CLIMACS-C-SYNTAX; -*-
2    
3     ;;; (c) copyright 2004-2005 by
4     ;;; Robert Strandh (strandh@labri.fr)
5     ;;; (c) copyright 2004-2005 by
6     ;;; Elliott Johnson (ejohnson@fasl.info)
7     ;;; (c) copyright 2005 by
8     ;;; Matthieu Villeneuve (matthieu.villeneuve@free.fr)
9     ;;; (c) copyright 2005 by
10     ;;; Aleksandar Bakic (a_bakic@yahoo.com)
11     ;;; (c) copyright 2006 by
12     ;;; Troels Henriksen (athas@sigkill.dk)
13     ;;; (c) copyright 2007 by
14     ;;; John Q. Splittist (splittist@splittist.com)
15     ;;;
16     ;;; This library is free software; you can redistribute it and/or
17     ;;; modify it under the terms of the GNU Library General Public
18     ;;; License as published by the Free Software Foundation; either
19     ;;; version 2 of the License, or (at your option) any later version.
20     ;;;
21     ;;; This library is distributed in the hope that it will be useful,
22     ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
23     ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24     ;;; Library General Public License for more details.
25     ;;;
26     ;;; You should have received a copy of the GNU Library General Public
27     ;;; License along with this library; if not, write to the
28     ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
29     ;;; Boston, MA 02111-1307 USA.
30    
31     ;;; Commands specific to the C syntax for Climacs.
32    
33     (in-package :climacs-c-syntax)
34    
35     ;;; This command table is used when Drei runs as a pane.
36     (make-command-table 'pane-c-table
37     :errorp nil)
38    
39     (defmethod additional-command-tables append ((drei drei-pane) (command-table c-table))
40     '(pane-c-table))
41    
42     ;; Movement commands.
43     (drei-commands:define-motion-commands expression c-table)
44 dmurray 1.2 ;; (drei-commands:define-motion-commands definition c-table)
45     (drei-commands:define-motion-commands up c-table
46     :noun "nesting level up"
47     :plural "levels")
48     (drei-commands:define-motion-commands down c-table
49     :noun "nesting level down"
50     :plural "levels")
51 thenriksen 1.1 (drei-commands:define-motion-commands list c-table)
52    
53     (drei-commands:define-editing-commands expression c-table)
54     (drei-commands:define-deletion-commands expression c-table)
55    
56     (define-command (com-fill-paragraph :name t :command-table c-table)
57     ()
58     "Fill paragraph at point. Will have no effect unless there is a
59     string at point."
60     (let* ((pane *current-window*)
61     (buffer (buffer pane))
62     (implementation (implementation buffer))
63     (syntax (syntax buffer))
64     (token (form-around syntax (offset (point pane))))
65     (fill-column (auto-fill-column pane))
66     (tab-width (tab-space-count (stream-default-view pane))))
67     (when (form-string-p token)
68     (with-accessors ((offset1 start-offset)
69     (offset2 end-offset)) token
70     (fill-region (make-instance 'standard-right-sticky-mark
71     :buffer implementation
72     :offset offset1)
73     (make-instance 'standard-right-sticky-mark
74     :buffer implementation
75     :offset offset2)
76     #'(lambda (mark)
77     (syntax-line-indentation mark tab-width syntax))
78     fill-column
79     tab-width
80     syntax
81     t)))))
82    
83     (define-command (com-indent-expression :name t :command-table c-table)
84     ((count 'integer :prompt "Number of expressions"))
85     (let* ((pane *current-window*)
86     (point (point pane))
87     (mark (clone-mark point))
88     (syntax (syntax (buffer pane))))
89     (if (plusp count)
90     (loop repeat count do (forward-expression mark syntax))
91     (loop repeat (- count) do (backward-expression mark syntax)))
92     (indent-region pane (clone-mark point) mark)))
93    
94     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
95     ;;;
96     ;;; Gesture bindings
97    
98     (set-key 'com-fill-paragraph
99     'c-table
100     '((#\q :meta)))
101    
102     (set-key `(com-indent-expression ,*numeric-argument-marker*)
103     'c-table
104     '((#\q :meta :control)))
105    
106 dmurray 1.2 (set-key `(com-backward-up ,*numeric-argument-marker*)
107     'c-table
108     '((#\u :control :meta)))
109 thenriksen 1.1
110 dmurray 1.2 (set-key `(com-forward-down ,*numeric-argument-marker*)
111     'c-table
112     '((#\d :control :meta)))
113 thenriksen 1.1
114     (set-key `(com-backward-expression ,*numeric-argument-marker*)
115     'c-table
116     '((#\b :control :meta)))
117    
118     (set-key `(com-forward-expression ,*numeric-argument-marker*)
119     'c-table
120     '((#\f :control :meta)))
121    
122     ;; (set-key `(com-backward-definition ,*numeric-argument-marker*)
123     ;; 'c-table
124     ;; '((#\a :control :meta)))
125    
126     ;; (set-key `(com-forward-definition ,*numeric-argument-marker*)
127     ;; 'c-table
128     ;; '((#\e :control :meta)))
129    
130     (set-key `(com-forward-list ,*numeric-argument-marker*)
131     'c-table
132     '((#\n :control :meta)))
133    
134     (set-key `(com-backward-list ,*numeric-argument-marker*)
135     'c-table
136     '((#\p :control :meta)))
137    
138     (set-key `(com-kill-expression ,*numeric-argument-marker*)
139     'c-table
140     '((#\k :control :meta)))
141    
142     (set-key `(com-transpose-expressions)
143     'c-table
144     '((#\t :control :meta)))

  ViewVC Help
Powered by ViewVC 1.1.5