bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#15935: [PATCH] octave.el: Add `octave-source-file'.


From: Rüdiger Sonderfeld
Subject: bug#15935: [PATCH] octave.el: Add `octave-source-file'.
Date: Wed, 20 Nov 2013 20:46:35 +0100
User-agent: KMail/4.11.2 (Linux/3.11.0-12-generic; KDE/4.11.2; x86_64; ; )

* progmodes/octave.el (octave-mode-map, octave-mode-menu): Add
  `octave-source-file'.
  (octave-source-file): New function.

Signed-off-by: Rüdiger Sonderfeld <ruediger@c-plusplus.de>
---
 lisp/ChangeLog           |  6 ++++++
 lisp/progmodes/octave.el | 18 ++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 357087d..4b3416d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2013-11-20  Rüdiger Sonderfeld  <ruediger@c-plusplus.de>
+
+       * progmodes/octave.el (octave-mode-map, octave-mode-menu): Add
+       `octave-source-file'.
+       (octave-source-file): New function.
+
 2013-11-20  era eriksson  <era+emacsbugs@iki.fi>
 
        * ses.el (ses-mode): Doc fix.  (Bug#14748)
diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el
index f128441..b4af1be 100644
--- a/lisp/progmodes/octave.el
+++ b/lisp/progmodes/octave.el
@@ -110,6 +110,7 @@ (defvar octave-mode-map
     (define-key map "\C-c;" 'octave-update-function-file-comment)
     (define-key map "\C-hd" 'octave-help)
     (define-key map "\C-ha" 'octave-lookfor)
+    (define-key map "\C-c\C-l" 'octave-source-file)
     (define-key map "\C-c\C-f" 'octave-insert-defun)
     (define-key map "\C-c\C-il" 'octave-send-line)
     (define-key map "\C-c\C-ib" 'octave-send-block)
@@ -174,6 +175,7 @@ (easy-menu-define octave-mode-menu octave-mode-map
      ["Send Current Function"   octave-send-defun t]
      ["Send Region"             octave-send-region t]
      ["Send Buffer"             octave-send-buffer t]
+     ["Source Current File"     octave-source-file t]
      ["Show Process Buffer"     octave-show-process-buffer t]
      ["Hide Process Buffer"     octave-hide-process-buffer t]
      ["Kill Process"            octave-kill-process t])
@@ -1463,6 +1465,22 @@ (defun octave-hide-process-buffer ()
       (delete-windows-on inferior-octave-buffer)
     (message "No buffer named %s" inferior-octave-buffer)))
 
+(defun octave-source-file (&optional file)
+  "Parse and execute FILE in the inferior Octave process.
+This is done using Octave's source function.  If FILE is nil then
+the variable `buffer-file-name' is used instead."
+  (interactive)
+  (unless file
+    (setq file buffer-file-name))
+  (unless file
+    (user-error "Current buffer has no file"))
+  (setq file (expand-file-name file))
+  (inferior-octave t)
+  (with-current-buffer inferior-octave-buffer
+    (setq file (file-relative-name file))
+    (comint-send-string inferior-octave-process
+                        (concat "source '" file  "'\n"))))
+
 (defun octave-send-region (beg end)
   "Send current region to the inferior Octave process."
   (interactive "r")
-- 
1.8.4.3






reply via email to

[Prev in Thread] Current Thread [Next in Thread]