emacs-diffs
[Top][All Lists]
Advanced

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

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


From: Leo Liu
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r112456: * progmodes/octave.el (inferior-octave-strip-ctrl-g)
Date: Sun, 05 May 2013 12:49:27 +0800
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 112456
committer: Leo Liu <address@hidden>
branch nick: trunk
timestamp: Sun 2013-05-05 12:49:27 +0800
message:
  * progmodes/octave.el (inferior-octave-strip-ctrl-g)
  (inferior-octave-output-filter): Remove.
  (octave-send-region, inferior-octave-startup): Fix callers.
  (inferior-octave-mode-map): Don't use comint-dynamic-complete.
  (octave-binary-file-extensions): New user variable.
  (octave-find-definition): Confirm if opening binary files.
  (octave-help-file): Use octave-find-definition to get the binary
  confirmation.
  (octave-help): Adjust for octave-help-file change.
modified:
  lisp/ChangeLog
  lisp/progmodes/octave.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-05-05 02:26:38 +0000
+++ b/lisp/ChangeLog    2013-05-05 04:49:27 +0000
@@ -1,3 +1,15 @@
+2013-05-05  Leo Liu  <address@hidden>
+
+       * progmodes/octave.el (inferior-octave-strip-ctrl-g)
+       (inferior-octave-output-filter): Remove.
+       (octave-send-region, inferior-octave-startup): Fix callers.
+       (inferior-octave-mode-map): Don't use comint-dynamic-complete.
+       (octave-binary-file-extensions): New user variable.
+       (octave-find-definition): Confirm if opening binary files.
+       (octave-help-file): Use octave-find-definition to get the binary
+       confirmation.
+       (octave-help): Adjust for octave-help-file change.
+
 2013-05-05  Stefan Monnier  <address@hidden>
 
        * progmodes/pascal.el (pascal-font-lock-keywords): Use backquotes.

=== modified file 'lisp/progmodes/octave.el'
--- a/lisp/progmodes/octave.el  2013-05-03 07:52:17 +0000
+++ b/lisp/progmodes/octave.el  2013-05-05 04:49:27 +0000
@@ -590,8 +590,9 @@
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map comint-mode-map)
     (define-key map "\M-." 'octave-find-definition)
-    (define-key map "\t" 'comint-dynamic-complete)
+    (define-key map "\t" 'completion-at-point)
     (define-key map "\C-hd" 'octave-help)
+    ;; Same as in `shell-mode'.
     (define-key map "\M-?" 'comint-dynamic-list-filename-completions)
     (define-key map "\C-c\C-l" 'inferior-octave-dynamic-list-input-ring)
     (define-key map [menu-bar inout list-history]
@@ -730,7 +731,7 @@
       inferior-octave-output-string))
 
     ;; And finally, everything is back to normal.
-    (set-process-filter proc 'inferior-octave-output-filter)
+    (set-process-filter proc 'comint-output-filter)
     ;; Just in case, to be sure a cd in the startup file
     ;; won't have detrimental effects.
     (inferior-octave-resync-dirs)))
@@ -783,21 +784,6 @@
             (set-window-configuration conf)
           (setq unread-command-events (list ch)))))))
 
-(defun inferior-octave-strip-ctrl-g (string)
-  "Strip leading `^G' character.
-If STRING starts with a `^G', ring the bell and strip it."
-  (if (string-match "^\a" string)
-      (progn
-        (ding)
-        (setq string (substring string 1))))
-  string)
-
-(defun inferior-octave-output-filter (proc string)
-  "Standard output filter for the inferior Octave process.
-Ring Emacs bell if process output starts with an ASCII bell, and pass
-the rest to `comint-output-filter'."
-  (comint-output-filter proc (inferior-octave-strip-ctrl-g string)))
-
 (defun inferior-octave-output-digest (_proc string)
   "Special output filter for the inferior Octave process.
 Save all output between newlines into `inferior-octave-output-list', and
@@ -1398,27 +1384,26 @@
   (interactive "r")
   (inferior-octave t)
   (let ((proc inferior-octave-process)
-       (string (buffer-substring-no-properties beg end))
-       line)
+        (string (buffer-substring-no-properties beg end))
+        line)
     (with-current-buffer inferior-octave-buffer
       (setq inferior-octave-output-list nil)
       (while (not (string-equal string ""))
-       (if (string-match "\n" string)
-           (setq line (substring string 0 (match-beginning 0))
-                 string (substring string (match-end 0)))
-         (setq line string string ""))
-       (setq inferior-octave-receive-in-progress t)
-       (inferior-octave-send-list-and-digest (list (concat line "\n")))
-       (while inferior-octave-receive-in-progress
-         (accept-process-output proc))
-       (insert-before-markers
-        (mapconcat 'identity
-                   (append
-                    (if octave-send-echo-input (list line) (list ""))
-                    (mapcar 'inferior-octave-strip-ctrl-g
-                            inferior-octave-output-list)
-                    (list inferior-octave-output-string))
-                   "\n")))))
+        (if (string-match "\n" string)
+            (setq line (substring string 0 (match-beginning 0))
+                  string (substring string (match-end 0)))
+          (setq line string string ""))
+        (setq inferior-octave-receive-in-progress t)
+        (inferior-octave-send-list-and-digest (list (concat line "\n")))
+        (while inferior-octave-receive-in-progress
+          (accept-process-output proc))
+        (insert-before-markers
+         (mapconcat 'identity
+                    (append
+                     (if octave-send-echo-input (list line) (list ""))
+                     inferior-octave-output-list
+                     (list inferior-octave-output-string))
+                    "\n")))))
   (if octave-send-show-buffer
       (display-buffer inferior-octave-buffer)))
 
@@ -1482,9 +1467,7 @@
 (define-button-type 'octave-help-file
   'follow-link t
   'action #'help-button-action
-  'help-function (lambda (fn)
-                   (find-file fn)
-                   (octave-goto-function-definition)))
+  'help-function 'octave-find-definition)
 
 (define-button-type 'octave-help-function
   'follow-link t
@@ -1527,7 +1510,7 @@
             (replace-match "" nil nil nil 1)
             (insert "`")
             (help-insert-xref-button (file-name-nondirectory file)
-                                     'octave-help-file file)
+                                     'octave-help-file fn)
             (insert "'")))
         ;; Make 'See also' clickable
         (with-syntax-table octave-mode-syntax-table
@@ -1537,6 +1520,12 @@
                                 (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)
+  :group 'octave
+  :version "24.4")
+
 (defvar find-tag-marker-ring)
 
 (defun octave-find-definition (fn)
@@ -1552,6 +1541,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)


reply via email to

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