aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeo Liu2013-05-12 12:10:40 +0800
committerLeo Liu2013-05-12 12:10:40 +0800
commit30ea8374a7e9d72df61b6097302102494ab1df96 (patch)
tree4f62a0c78025b808f15f13234c9b42fe23a981aa
parent472a3834deff659bbd78f49020c2b8aa6dd0ff9c (diff)
downloademacs-30ea8374a7e9d72df61b6097302102494ab1df96.tar.gz
emacs-30ea8374a7e9d72df61b6097302102494ab1df96.zip
* progmodes/octave.el (inferior-octave-startup): Store the value
of __octave_srcdir__ for octave-source-directories. (inferior-octave-check-process): New function refactored out of inferior-octave-send-list-and-digest. (octave-source-directories) (octave-find-definition-filename-function): New variables. (octave-source-directories) (octave-find-definition-default-filename): New functions. (octave-find-definition): Improve to find functions implemented in C++.
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/progmodes/octave.el69
2 files changed, 65 insertions, 16 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 6d82c799ca0..5a2d5c991d4 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12013-05-12 Leo Liu <sdl.web@gmail.com>
2
3 * progmodes/octave.el (inferior-octave-startup): Store the value
4 of __octave_srcdir__ for octave-source-directories.
5 (inferior-octave-check-process): New function refactored out of
6 inferior-octave-send-list-and-digest.
7 (octave-source-directories)
8 (octave-find-definition-filename-function): New variables.
9 (octave-source-directories)
10 (octave-find-definition-default-filename): New functions.
11 (octave-find-definition): Improve to find functions implemented in C++.
12
12013-05-12 Glenn Morris <rgm@gnu.org> 132013-05-12 Glenn Morris <rgm@gnu.org>
2 14
3 * calendar/diary-lib.el (diary-outlook-format-1): 15 * calendar/diary-lib.el (diary-outlook-format-1):
diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el
index b4fae808df6..75c2508dd30 100644
--- a/lisp/progmodes/octave.el
+++ b/lisp/progmodes/octave.el
@@ -736,6 +736,10 @@ startup file, `~/.emacs-octave'."
736 (car inferior-octave-output-list)) 736 (car inferior-octave-output-list))
737 (inferior-octave-send-list-and-digest (list "PS2 (\"> \");\n"))) 737 (inferior-octave-send-list-and-digest (list "PS2 (\"> \");\n")))
738 738
739 (inferior-octave-send-list-and-digest
740 (list "if exist(\"__octave_srcdir__\") disp(__octave_srcdir__) endif\n"))
741 (process-put proc 'octave-srcdir (car inferior-octave-output-list))
742
739 ;; O.K., now we are ready for the Inferior Octave startup commands. 743 ;; O.K., now we are ready for the Inferior Octave startup commands.
740 (inferior-octave-send-list-and-digest 744 (inferior-octave-send-list-and-digest
741 (list "more off;\n" 745 (list "more off;\n"
@@ -762,7 +766,7 @@ startup file, `~/.emacs-octave'."
762 766
763(defvar inferior-octave-completion-table 767(defvar inferior-octave-completion-table
764 ;; 768 ;;
765 ;; Use cache to avod repetitive computation of completions due to 769 ;; Use cache to avoid repetitive computation of completions due to
766 ;; bug#11906 - http://debbugs.gnu.org/11906 - which may cause 770 ;; bug#11906 - http://debbugs.gnu.org/11906 - which may cause
767 ;; noticeable delay. CACHE: (CMD TIME VALUE). 771 ;; noticeable delay. CACHE: (CMD TIME VALUE).
768 (let ((cache)) 772 (let ((cache))
@@ -837,14 +841,17 @@ the rest to `inferior-octave-output-string'."
837 (setq inferior-octave-receive-in-progress nil)) 841 (setq inferior-octave-receive-in-progress nil))
838 (setq inferior-octave-output-string string)) 842 (setq inferior-octave-output-string string))
839 843
844(defun inferior-octave-check-process ()
845 (or (and inferior-octave-process
846 (process-live-p inferior-octave-process))
847 (error (substitute-command-keys
848 "No inferior octave process running. Type \\[run-octave]"))))
849
840(defun inferior-octave-send-list-and-digest (list) 850(defun inferior-octave-send-list-and-digest (list)
841 "Send LIST to the inferior Octave process and digest the output. 851 "Send LIST to the inferior Octave process and digest the output.
842The elements of LIST have to be strings and are sent one by one. All 852The elements of LIST have to be strings and are sent one by one. All
843output is passed to the filter `inferior-octave-output-digest'." 853output is passed to the filter `inferior-octave-output-digest'."
844 (or (and inferior-octave-process 854 (inferior-octave-check-process)
845 (process-live-p inferior-octave-process))
846 (error (substitute-command-keys
847 "No inferior octave process running. Type \\[run-octave]")))
848 (let* ((proc inferior-octave-process) 855 (let* ((proc inferior-octave-process)
849 (filter (process-filter proc)) 856 (filter (process-filter proc))
850 string) 857 string)
@@ -1615,16 +1622,50 @@ if ismember(exist(\"%s\"), [2 3 5 103]) print_usage(\"%s\") endif\n"
1615 (match-end 0) 1622 (match-end 0)
1616 :type 'octave-help-function)))))))) 1623 :type 'octave-help-function))))))))
1617 1624
1618(defcustom octave-binary-file-extensions '("oct" "mex") 1625(defcustom octave-source-directories nil
1619 "A list of binary file extensions for Octave." 1626 "A list of directories for Octave sources."
1620 :type '(repeat string) 1627 :type '(repeat directory)
1621 :group 'octave 1628 :group 'octave
1622 :version "24.4") 1629 :version "24.4")
1623 1630
1631(defun octave-source-directories ()
1632 (inferior-octave-check-process)
1633 (let ((srcdir (process-get inferior-octave-process 'octave-srcdir)))
1634 (if srcdir
1635 (cons srcdir octave-source-directories)
1636 octave-source-directories)))
1637
1638(defvar octave-find-definition-filename-function
1639 #'octave-find-definition-default-filename)
1640
1641(defun octave-find-definition-default-filename (name)
1642 "Default value for `octave-find-definition-filename-function'."
1643 (pcase (file-name-extension name)
1644 (`"oct"
1645 (octave-find-definition-default-filename
1646 (concat "libinterp/dldfcn/"
1647 (file-name-sans-extension (file-name-nondirectory name))
1648 ".cc")))
1649 (`"cc"
1650 (let ((file (or (locate-file name (octave-source-directories))
1651 (locate-file (file-name-nondirectory name)
1652 (octave-source-directories)))))
1653 (or (and file (file-exists-p file))
1654 (error "File `%s' not found" name))
1655 file))
1656 (`"mex"
1657 (if (yes-or-no-p (format "File `%s' may be binary; open? "
1658 (file-name-nondirectory name)))
1659 name
1660 (user-error "Aborted")))
1661 (t name)))
1662
1624(defvar find-tag-marker-ring) 1663(defvar find-tag-marker-ring)
1625 1664
1626(defun octave-find-definition (fn) 1665(defun octave-find-definition (fn)
1627 "Find the definition of FN." 1666 "Find the definition of FN.
1667Definitions for functions implemented in C++ can be found if
1668`octave-source-directories' is set correctly."
1628 (interactive (list (octave-completing-read))) 1669 (interactive (list (octave-completing-read)))
1629 (inferior-octave-send-list-and-digest 1670 (inferior-octave-send-list-and-digest
1630 ;; help NAME is more verbose 1671 ;; help NAME is more verbose
@@ -1636,15 +1677,11 @@ if iskeyword(\"%s\") disp(\"`%s' is a keyword\") else which(\"%s\") endif\n"
1636 (match-string 1 line)))) 1677 (match-string 1 line))))
1637 (if (not file) 1678 (if (not file)
1638 (user-error "%s" (or line (format "`%s' not found" fn))) 1679 (user-error "%s" (or line (format "`%s' not found" fn)))
1639 (when (and (member (file-name-extension file)
1640 octave-binary-file-extensions)
1641 (not (yes-or-no-p (format "File `%s' may be binary; open? "
1642 (file-name-nondirectory file)))))
1643 (error "Aborted"))
1644 (require 'etags) 1680 (require 'etags)
1645 (ring-insert find-tag-marker-ring (point-marker)) 1681 (ring-insert find-tag-marker-ring (point-marker))
1646 (find-file file) 1682 (find-file (funcall octave-find-definition-filename-function file))
1647 (octave-goto-function-definition)))) 1683 (or (octave-goto-function-definition)
1684 (forward-comment (point-max))))))
1648 1685
1649 1686
1650(provide 'octave) 1687(provide 'octave)