[climacs-devel] Fwd: Insert file
David Lewis
d.lewis at gold.ac.uk
Fri Apr 29 15:59:22 UTC 2005
Hi,
I've had to implement an insert-file command for my own work (helped by
Christophe). Hope it's useful.
Change to gui.lisp:
@@ -707,6 +710,20 @@
;; resets the low and high marks after redisplay
(redisplay-frame-panes *application-frame*)))
+(define-named-command com-insert-file ()
+ (let ((filename (accept 'completable-pathname
+ :prompt "Insert File"))
+ (pane (current-window)))
+ (when (probe-file filename)
+ (setf (mark pane) (clone-mark (point pane) :left))
+ (with-open-file (stream filename :direction :input)
+ (input-from-stream stream
+ (buffer pane)
+ (offset (point pane))))
+ (psetf (offset (mark pane)) (offset (point pane))
+ (offset (point pane)) (offset (mark pane))))
+ (redisplay-frame-panes *application-frame*)))
+
(defun save-buffer (buffer)
(let ((filename (or (filename buffer)
(accept 'completable-pathname
@@ -1419,6 +1436,7 @@
(c-x-set-key '(#\t :control) 'com-transpose-lines)
(c-x-set-key '(#\w :control) 'com-write-buffer)
(c-x-set-key '(#\x :control) 'com-exchange-point-and-mark)
+(c-x-set-key '(#\i) 'com-insert-file)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;
;;;
Ta,
David Lewis
More information about the climacs-devel
mailing list