~ubuntu-branches/debian/jessie/ecb/jessie

« back to all changes in this revision

Viewing changes to ecb-eshell.el

  • Committer: Bazaar Package Importer
  • Author(s): Mike O'Connor
  • Date: 2011-06-08 11:20:27 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110608112027-bxhsucmsn8m9z2uz
Tags: 2.40+cvs20110608-1
* New Maintainer
* new upstream release (Closes: #548854)
* add Homepage field to control (Closes: #615403)
* remove obsolete dependencies (Closes: #617303)
* convert to 3.0 (quilt)
* convert to dh7
* change dependency from emacs21 to emacs23
* add dependency on install-info
* add dependency on texinfo
* add ${misc:Depends}
* change doc-base section to Programming
* upgrade Standards-Version to 3.9.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
;;                           Kevin A. Burton,
6
6
;;                           Free Software Foundation, Inc.
7
7
 
8
 
;; Author: Jesper Nordenberg <mayhem@home.se>
9
 
;;         Klaus Berndl <klaus.berndl@sdm.de>
 
8
;; Author: Klaus Berndl <klaus.berndl@sdm.de>
10
9
;;         Kevin A. Burton <burton@openprivacy.org>
11
10
;; Maintainer: Klaus Berndl <klaus.berndl@sdm.de>
12
 
;;             Kevin A. Burton <burton@openprivacy.org>
13
11
;; Keywords: browser, code, programming, tools
14
12
;; Created: 2001
15
13
 
26
24
;; GNU Emacs; see the file COPYING.  If not, write to the Free Software
27
25
;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28
26
 
29
 
;; $Id: ecb-eshell.el,v 1.78 2005/06/20 14:34:20 berndl Exp $
 
27
;; $Id: ecb-eshell.el,v 1.86 2010/02/23 16:08:56 berndl Exp $
30
28
 
31
29
;;; Commentary:
32
30
 
114
112
  :group 'ecb-eshell
115
113
  :type 'boolean)
116
114
 
117
 
(defcustom ecb-eshell-synchronize t
 
115
;; TODO: Klaus Berndl <klaus.berndl@sdm.de>: was ecb-eshell-synchronize -->
 
116
;; rename in texi and also to ecb-upgrade (also with value-upgrade!)
 
117
(defcustom ecb-eshell-buffer-sync 'basic
118
118
  "*Synchronize eshell with the default-directory of current source-buffer.
119
 
The synchronization is done by `ecb-eshell-current-buffer-sync' which can be
120
 
called interactively but normally it is called autom. by the
121
 
`ecb-current-buffer-sync-hook-internal'."
122
 
  :group 'ecb-eshell
123
 
  :type 'boolean)
 
119
 
 
120
This option takes only effect if a permanant compile-window is used in the
 
121
current layout.
 
122
 
 
123
If 'always then the synchronization takes place always a buffer
 
124
changes in the edit window and if after this the
 
125
default-directory of the new edit-buffer is different from the
 
126
default-directory of the current eshell-buffer. If value is nil
 
127
then never a synchronization will take place. If a list of
 
128
major-modes then only if the `major-mode' of the new buffer
 
129
belongs NOT to this list.
 
130
 
 
131
If the special value 'basic is set then ECB uses the setting of the option
 
132
`ecb-basic-buffer-sync'."
 
133
  :group 'ecb-eshell
 
134
  :type '(radio :tag "Synchronize the eshell if in compile-window."
 
135
                (const :tag "Use basic value" :value basic)
 
136
                (const :tag "Always" :value always)
 
137
                (const :tag "Never" nil)
 
138
                (repeat :tag "Not with these modes"
 
139
                        (symbol :tag "mode"))))
 
140
    
 
141
 
 
142
(defcustom ecb-eshell-buffer-sync-delay 'basic
 
143
  "*Time Emacs must be idle before the eshell-buffer of ECB is synchronized.
 
144
Synchronizing is done with the current source displayed in the edit window. If
 
145
nil then there is no delay, means synchronization takes place immediately. A
 
146
small value of about 0.25 seconds saves CPU resources and you get even though
 
147
almost the same effect as if you set no delay.
 
148
 
 
149
If the special value 'basic is set then ECB uses the setting of the option
 
150
`ecb-basic-buffer-sync-delay'."
 
151
  :group 'ecb-eshell
 
152
  :type '(radio (const :tag "Use basic value" :value basic)
 
153
                (const :tag "No synchronizing delay" :value nil)
 
154
                (number :tag "Idle time before synchronizing" :value 2))
 
155
  :set (function (lambda (symbol value)
 
156
                   (set symbol value)
 
157
                   (if (and (boundp 'ecb-minor-mode)
 
158
                            ecb-minor-mode)
 
159
                       (ecb-activate-ecb-autocontrol-function
 
160
                        value 'ecb-analyse-buffer-sync))))
 
161
  :initialize 'custom-initialize-default)
 
162
  
 
163
 
124
164
 
125
165
(defvar ecb-eshell-pre-command-point nil
126
166
  "Point in the buffer we are at before we executed a command.")
131
171
called with an prefix arg!")
132
172
 
133
173
 
134
 
(defconst ecb-eshell-adviced-functions '((eshell . around))
 
174
(defecb-advice-set ecb-eshell-adviced-functions
135
175
  "These functions of eshell are adviced if ehsell is active during ECB is
136
 
active. Each element of the list is a cons-cell where the car is the
137
 
function-symbol and the cdr the advice-class \(before, around or after). If a
138
 
function should be adviced with more than one class \(e.g. with a before and
139
 
an after-advice) then for every class a cons must be added to this list.")
 
176
active.")
140
177
 
141
 
(defadvice eshell (around ecb)
 
178
(defecb-advice eshell around ecb-eshell-adviced-functions
142
179
  "Ensure that ehsell is running in the ECB-compile-window if any."
143
180
  ;; we tell ECB to handle the eshell-buffers as compilation-buffers so they
144
181
  ;; will be displayed in the compile-window (if any). We must add this as
176
213
    (ecb-layout-debug-error "eshell around-advice: comp-win will be toggled.")
177
214
    (ecb-toggle-compile-window 1))
178
215
 
 
216
  (ecb-activate-ecb-autocontrol-function ecb-eshell-buffer-sync-delay
 
217
                                         'ecb-eshell-buffer-sync)
179
218
  ;; some hooks
180
 
  (add-hook 'ecb-current-buffer-sync-hook-internal
181
 
            'ecb-eshell-current-buffer-sync)  
182
219
  (add-hook 'eshell-post-command-hook 'ecb-eshell-recenter)
183
220
  (add-hook 'eshell-post-command-hook 'ecb-eshell-fit-window-to-output)
184
221
  (add-hook 'eshell-pre-command-hook 'ecb-eshell-precommand-hook)
204
241
  (ecb-eshell-recenter)  
205
242
  
206
243
  ;;sync to the current buffer
207
 
  (ecb-eshell-current-buffer-sync))
 
244
  (ecb-eshell-buffer-sync))
208
245
  
209
246
  
210
247
 
211
248
(defun ecb-eshell-activate-integration ()
212
249
  "Does all necessary to activate the eshell-integration. But this doesn not
213
250
load or activate eshell - it just prepares ECB to work perfectly with eshell."
214
 
  (ecb-enable-advices ecb-eshell-adviced-functions))
 
251
  (ecb-enable-advices 'ecb-eshell-adviced-functions))
215
252
 
216
253
(defun ecb-eshell-deactivate-integration ()
217
 
  (ecb-disable-advices ecb-eshell-adviced-functions)
218
 
  (remove-hook 'ecb-current-buffer-sync-hook-internal
219
 
               'ecb-eshell-current-buffer-sync)
 
254
  (ecb-disable-advices 'ecb-eshell-adviced-functions)
 
255
  (ecb-stop-autocontrol/sync-function 'ecb-eshell-buffer-sync)
220
256
  (remove-hook 'eshell-post-command-hook 'ecb-eshell-recenter)
221
257
  (remove-hook 'eshell-post-command-hook 'ecb-eshell-fit-window-to-output)
222
258
  (remove-hook 'eshell-pre-command-hook 'ecb-eshell-precommand-hook)
223
259
  (remove-hook 'window-size-change-functions 'ecb-eshell-window-size-change))
224
260
 
225
 
(defun ecb-eshell-current-buffer-sync()
 
261
(defecb-autocontrol/sync-function ecb-eshell-buffer-sync nil ecb-eshell-buffer-sync t
226
262
  "Synchronize the eshell with the directory of current source-buffer.
227
263
This is only done if the eshell is currently visible in the compile-window of
228
264
ECB and if either this function is called interactively or
229
 
`ecb-eshell-synchronize' is not nil."
230
 
  (interactive)
231
 
 
 
265
`ecb-eshell-buffer-sync' is not nil."
232
266
  (when (and (equal (selected-frame) ecb-frame)
233
 
             (or ecb-eshell-synchronize (interactive-p))
234
267
             (ecb-compile-window-live-p)
235
 
             (not (ecb-point-in-compile-window)))
236
 
 
 
268
             (ecb-point-in-edit-window-number))
237
269
    (let* ((my-eshell-buffer
238
270
            ;; nil or a living eshell-buffer in the ecb-compile-window
239
271
            (car (member (window-buffer ecb-compile-window)
240
272
                         ecb-eshell-buffer-list)))
241
273
           (my-reference-directory default-directory)
242
274
           (my-eshell-directory (and (bufferp my-eshell-buffer)
243
 
                                     (save-excursion
244
 
                                       (set-buffer my-eshell-buffer)
 
275
                                     (with-current-buffer my-eshell-buffer
245
276
                                       default-directory))))
246
277
      (when (and (bufferp my-eshell-buffer)
247
278
                 (stringp my-reference-directory)
249
280
                 (not (ecb-string= (ecb-fix-filename my-reference-directory)
250
281
                                   (ecb-fix-filename my-eshell-directory))))
251
282
        (ecb-eshell-save-buffer-history
252
 
         (save-excursion
253
 
           (set-buffer my-eshell-buffer)
 
283
         (with-current-buffer my-eshell-buffer
254
284
           ;; make sure we have a clean eshell-command-line
255
285
           (goto-char (point-max))
256
286
           (eshell-bol)
327
357
              (ecb-normalize-number ecb-compile-window-height
328
358
                                    (1- (frame-height))))
329
359
             (ecb-enlarged-compilation-window-max-height
330
 
              (max (min (save-excursion
331
 
                          (set-buffer (window-buffer ecb-compile-window))
 
360
              (max (min (with-current-buffer (window-buffer ecb-compile-window)
332
361
                          ;; we want to see the old command line too and 2
333
362
                          ;; must be added because we have a modeline and one
334
363
                          ;; empty line cause of the (recenter -2) in