emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r112560: * progmodes/octave.el (infer


From: Leo Liu
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r112560: * progmodes/octave.el (inferior-octave-startup): Store the value
Date: Sun, 12 May 2013 12:10:40 +0800
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 112560
committer: Leo Liu <address@hidden>
branch nick: trunk
timestamp: Sun 2013-05-12 12:10:40 +0800
message:
  * 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++.
modified:
  lisp/ChangeLog
  lisp/progmodes/octave.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-05-12 01:34:30 +0000
+++ b/lisp/ChangeLog    2013-05-12 04:10:40 +0000
@@ -1,3 +1,15 @@
+2013-05-12  Leo Liu  <address@hidden>
+
+       * 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++.
+
 2013-05-12  Glenn Morris  <address@hidden>
 
        * calendar/diary-lib.el (diary-outlook-format-1):

=== modified file 'lisp/progmodes/octave.el'
--- a/lisp/progmodes/octave.el  2013-05-11 13:22:06 +0000
+++ b/lisp/progmodes/octave.el  2013-05-12 04:10:40 +0000
@@ -736,6 +736,10 @@
                         (car inferior-octave-output-list))
       (inferior-octave-send-list-and-digest (list "PS2 (\"> \");\n")))
 
+    (inferior-octave-send-list-and-digest
+     (list "if exist(\"__octave_srcdir__\") disp(__octave_srcdir__) endif\n"))
+    (process-put proc 'octave-srcdir (car inferior-octave-output-list))
+
     ;; O.K., now we are ready for the Inferior Octave startup commands.
     (inferior-octave-send-list-and-digest
      (list "more off;\n"
@@ -762,7 +766,7 @@
 
 (defvar inferior-octave-completion-table
   ;;
-  ;; Use cache to avod repetitive computation of completions due to
+  ;; Use cache to avoid repetitive computation of completions due to
   ;; bug#11906 - http://debbugs.gnu.org/11906 - which may cause
   ;; noticeable delay.  CACHE: (CMD TIME VALUE).
   (let ((cache))
@@ -837,14 +841,17 @@
       (setq inferior-octave-receive-in-progress nil))
   (setq inferior-octave-output-string string))
 
+(defun inferior-octave-check-process ()
+  (or (and inferior-octave-process
+           (process-live-p inferior-octave-process))
+      (error (substitute-command-keys
+              "No inferior octave process running. Type \\[run-octave]"))))
+
 (defun inferior-octave-send-list-and-digest (list)
   "Send LIST to the inferior Octave process and digest the output.
 The elements of LIST have to be strings and are sent one by one.  All
 output is passed to the filter `inferior-octave-output-digest'."
-  (or (and inferior-octave-process
-           (process-live-p inferior-octave-process))
-      (error (substitute-command-keys
-              "No inferior octave process running. Type \\[run-octave]")))
+  (inferior-octave-check-process)
   (let* ((proc inferior-octave-process)
         (filter (process-filter proc))
         string)
@@ -1615,16 +1622,50 @@
                                 (match-end 0)
                                 :type 'octave-help-function))))))))
 
-(defcustom octave-binary-file-extensions '("oct" "mex")
-  "A list of binary file extensions for Octave."
-  :type '(repeat string)
+(defcustom octave-source-directories nil
+  "A list of directories for Octave sources."
+  :type '(repeat directory)
   :group 'octave
   :version "24.4")
 
+(defun octave-source-directories ()
+  (inferior-octave-check-process)
+  (let ((srcdir (process-get inferior-octave-process 'octave-srcdir)))
+    (if srcdir
+        (cons srcdir octave-source-directories)
+      octave-source-directories)))
+
+(defvar octave-find-definition-filename-function
+  #'octave-find-definition-default-filename)
+
+(defun octave-find-definition-default-filename (name)
+  "Default value for `octave-find-definition-filename-function'."
+  (pcase (file-name-extension name)
+    (`"oct"
+     (octave-find-definition-default-filename
+      (concat "libinterp/dldfcn/"
+              (file-name-sans-extension (file-name-nondirectory name))
+              ".cc")))
+    (`"cc"
+     (let ((file (or (locate-file name (octave-source-directories))
+                     (locate-file (file-name-nondirectory name)
+                                  (octave-source-directories)))))
+       (or (and file (file-exists-p file))
+           (error "File `%s' not found" name))
+       file))
+    (`"mex"
+     (if (yes-or-no-p (format "File `%s' may be binary; open? "
+                              (file-name-nondirectory name)))
+         name
+       (user-error "Aborted")))
+    (t name)))
+
 (defvar find-tag-marker-ring)
 
 (defun octave-find-definition (fn)
-  "Find the definition of FN."
+  "Find the definition of FN.
+Definitions for functions implemented in C++ can be found if
+`octave-source-directories' is set correctly."
   (interactive (list (octave-completing-read)))
   (inferior-octave-send-list-and-digest
    ;; help NAME is more verbose
@@ -1636,15 +1677,11 @@
                  (match-string 1 line))))
     (if (not file)
         (user-error "%s" (or line (format "`%s' not found" fn)))
-      (when (and (member (file-name-extension file)
-                         octave-binary-file-extensions)
-                 (not (yes-or-no-p (format "File `%s' may be binary; open? "
-                                           (file-name-nondirectory file)))))
-        (error "Aborted"))
       (require 'etags)
       (ring-insert find-tag-marker-ring (point-marker))
-      (find-file file)
-      (octave-goto-function-definition))))
+      (find-file (funcall octave-find-definition-filename-function file))
+      (or (octave-goto-function-definition)
+          (forward-comment (point-max))))))
 
 
 (provide 'octave)


reply via email to

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