Changeset 1683:f84adc4d0b0e
- Timestamp:
- 11/26/08 21:16:11 (6 weeks ago)
- Author:
- Tobias Billep <t.billep@…>
- Message:
-
fixed communication with emacs
- Location:
- pida
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r1409
|
r1683
|
|
| 190 | 190 | listen_port = self._cb.bind() |
| 191 | 191 | instance_id = 'pida-' + str(os.getpid()) |
| 192 | | self._client = EmacsClient(instance_id) |
| | 192 | self._client = EmacsClient(instance_id, self) |
| 193 | 193 | |
| 194 | 194 | time.sleep(1) |
| … |
… |
|
| 282 | 282 | def goto_line(self, line): |
| 283 | 283 | """Goto a line""" |
| 284 | | self._client.goto_line(line + 1) |
| | 284 | self._client.goto_line(line) |
| 285 | 285 | self.grab_focus() |
| 286 | 286 | |
-
|
r1133
|
r1683
|
|
| 156 | 156 | (pida-disconnect)) |
| 157 | 157 | |
| | 158 | ;; pida-goto-line |
| | 159 | ;; |
| | 160 | ;; called by pida: goto-line |
| | 161 | (defun pida-goto-line (bufn line) |
| | 162 | (set-buffer (get-file-buffer bufn)) |
| | 163 | (goto-line line)) |
| | 164 | |
| | 165 | |
| | 166 | ;; pida-save-buffer |
| | 167 | ;; |
| | 168 | ;; called by pida to save buffer |
| | 169 | (defun pida-save-buffer (buffn) |
| | 170 | (set-buffer (get-file-buffer buffn)) |
| | 171 | (save-buffer)) |
| | 172 | |
| | 173 | ;; pida-save-buffer-as |
| | 174 | ;; |
| | 175 | ;; called by pida to save buffer as new file |
| | 176 | (defun pida-save-buffer (buffn filen) |
| | 177 | (set-buffer (get-file-buffer buffn)) |
| | 178 | (write-file filen)) |
| | 179 | |
| | 180 | ;; pida-cut |
| | 181 | ;; |
| | 182 | ;; called by pida to cut region |
| | 183 | (defun pida-cut (buffn) |
| | 184 | (set-buffer (get-file-buffer buffn)) |
| | 185 | (kill-region (region-beginning) (region-end))) |
| | 186 | |
| | 187 | ;; pida-copy |
| | 188 | ;; |
| | 189 | ;; called by pida to copy region |
| | 190 | (defun pida-copy (buffn) |
| | 191 | (set-buffer (get-file-buffer buffn)) |
| | 192 | (kill-ring-save (region-beginning) (region-end))) |
| | 193 | |
| | 194 | ;; pida-save-buffer-as |
| | 195 | ;; |
| | 196 | ;; called by pida to paste |
| | 197 | (defun pida-paste (buffn) |
| | 198 | (set-buffer (get-file-buffer buffn)) |
| | 199 | (yank)) |
| | 200 | |
| | 201 | |
| 158 | 202 | (setq inhibit-splash-screen 1) |
-
|
r1409
|
r1683
|
|
| 8 | 8 | extracts a request name and arguments, and then tries to invoke the matching |
| 9 | 9 | method on a EmacsCallback object (see editor/emacs/emacs.py). |
| 10 | | |
| | 10 | |
| 11 | 11 | :copyright: 2005-2008 by The PIDA Project |
| 12 | 12 | :license: GPL 2 or later (see README/COPYING/LICENSE) |
| … |
… |
|
| 32 | 32 | """ |
| 33 | 33 | |
| 34 | | def __init__(self, instance_id): |
| | 34 | def __init__(self, instance_id, svc): |
| 35 | 35 | """Constructor.""" |
| 36 | 36 | self._log = logging.getLogger('emacs') |
| … |
… |
|
| 39 | 39 | self._socket_path = _get_socket_path(self._instance_id) |
| 40 | 40 | self._pending_commands = [] |
| | 41 | self._svc = svc |
| 41 | 42 | |
| 42 | 43 | def activate(self): |
| … |
… |
|
| 64 | 65 | |
| 65 | 66 | def save_buffer(self): |
| 66 | | self._send('(save-buffer)') |
| | 67 | self._send('(pida-save-buffer "%s")' % self._svc.current_document.filename) |
| 67 | 68 | |
| 68 | 69 | def save_buffer_as(self, filename): |
| 69 | | self._send('(write-file "%s"))' % filename) |
| | 70 | self._send('(pida-save-buffer-as "%s" "%s"))' % (self._svc.current_document.filename, filename)) |
| 70 | 71 | |
| 71 | 72 | def close_buffer(self, buffer): |
| … |
… |
|
| 76 | 77 | |
| 77 | 78 | def cut(self): |
| 78 | | self._send('(kill-region (region-beginning) (region-end))') |
| | 79 | self._send('(pida-cut "%s")' % self._svc.current_document.filename) |
| 79 | 80 | |
| 80 | 81 | def copy(self): |
| 81 | | self._send('(kill-ring-save (region-beginning) (region-end))') |
| | 82 | self._send('(pida-copy "%s")' % self._svc.current_document.filename) |
| 82 | 83 | |
| 83 | 84 | def paste(self): |
| 84 | | self._send('(yank)') |
| | 85 | self._send('(pida-paste "%s")' % self._svc.current_document.filename) |
| 85 | 86 | |
| 86 | 87 | def goto_line(self, line): |
| 87 | | self._send('(goto-line %s)' % line) |
| | 88 | self._send('(pida-goto-line "%s" %s)' % (self._svc.current_document.filename, line)) |
| 88 | 89 | |
| 89 | 90 | def revert_buffer(self): |