unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#15935: [PATCH] octave.el: Add `octave-source-file'.
@ 2013-11-20 19:46 Rüdiger Sonderfeld
  2013-11-21 17:20 ` Leo Liu
  0 siblings, 1 reply; 2+ messages in thread
From: Rüdiger Sonderfeld @ 2013-11-20 19:46 UTC (permalink / raw)
  To: 15935; +Cc: Leo Liu

* 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






^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-11-21 17:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-20 19:46 bug#15935: [PATCH] octave.el: Add `octave-source-file' Rüdiger Sonderfeld
2013-11-21 17:20 ` Leo Liu

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).