diff options
| author | Leo Liu | 2013-05-05 12:49:27 +0800 |
|---|---|---|
| committer | Leo Liu | 2013-05-05 12:49:27 +0800 |
| commit | c129b51f4bfbba7b06534661610c7eb6e85826bb (patch) | |
| tree | 20fafce82dd1d486357509af2d3dedc5b2219466 /lisp | |
| parent | f8780a05741c6360921fee341a41721a19ccc611 (diff) | |
| download | emacs-c129b51f4bfbba7b06534661610c7eb6e85826bb.tar.gz emacs-c129b51f4bfbba7b06534661610c7eb6e85826bb.zip | |
* 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.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 12 | ||||
| -rw-r--r-- | lisp/progmodes/octave.el | 72 |
2 files changed, 45 insertions, 39 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 20f293525b4..f7aa1d48fa0 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,15 @@ | |||
| 1 | 2013-05-05 Leo Liu <sdl.web@gmail.com> | ||
| 2 | |||
| 3 | * progmodes/octave.el (inferior-octave-strip-ctrl-g) | ||
| 4 | (inferior-octave-output-filter): Remove. | ||
| 5 | (octave-send-region, inferior-octave-startup): Fix callers. | ||
| 6 | (inferior-octave-mode-map): Don't use comint-dynamic-complete. | ||
| 7 | (octave-binary-file-extensions): New user variable. | ||
| 8 | (octave-find-definition): Confirm if opening binary files. | ||
| 9 | (octave-help-file): Use octave-find-definition to get the binary | ||
| 10 | confirmation. | ||
| 11 | (octave-help): Adjust for octave-help-file change. | ||
| 12 | |||
| 1 | 2013-05-05 Stefan Monnier <monnier@iro.umontreal.ca> | 13 | 2013-05-05 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 14 | ||
| 3 | * progmodes/pascal.el (pascal-font-lock-keywords): Use backquotes. | 15 | * progmodes/pascal.el (pascal-font-lock-keywords): Use backquotes. |
diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el index 10f6007204b..6d06f1a2275 100644 --- a/lisp/progmodes/octave.el +++ b/lisp/progmodes/octave.el | |||
| @@ -590,8 +590,9 @@ mode, set this to (\"-q\" \"--traditional\")." | |||
| 590 | (let ((map (make-sparse-keymap))) | 590 | (let ((map (make-sparse-keymap))) |
| 591 | (set-keymap-parent map comint-mode-map) | 591 | (set-keymap-parent map comint-mode-map) |
| 592 | (define-key map "\M-." 'octave-find-definition) | 592 | (define-key map "\M-." 'octave-find-definition) |
| 593 | (define-key map "\t" 'comint-dynamic-complete) | 593 | (define-key map "\t" 'completion-at-point) |
| 594 | (define-key map "\C-hd" 'octave-help) | 594 | (define-key map "\C-hd" 'octave-help) |
| 595 | ;; Same as in `shell-mode'. | ||
| 595 | (define-key map "\M-?" 'comint-dynamic-list-filename-completions) | 596 | (define-key map "\M-?" 'comint-dynamic-list-filename-completions) |
| 596 | (define-key map "\C-c\C-l" 'inferior-octave-dynamic-list-input-ring) | 597 | (define-key map "\C-c\C-l" 'inferior-octave-dynamic-list-input-ring) |
| 597 | (define-key map [menu-bar inout list-history] | 598 | (define-key map [menu-bar inout list-history] |
| @@ -730,7 +731,7 @@ startup file, `~/.emacs-octave'." | |||
| 730 | inferior-octave-output-string)) | 731 | inferior-octave-output-string)) |
| 731 | 732 | ||
| 732 | ;; And finally, everything is back to normal. | 733 | ;; And finally, everything is back to normal. |
| 733 | (set-process-filter proc 'inferior-octave-output-filter) | 734 | (set-process-filter proc 'comint-output-filter) |
| 734 | ;; Just in case, to be sure a cd in the startup file | 735 | ;; Just in case, to be sure a cd in the startup file |
| 735 | ;; won't have detrimental effects. | 736 | ;; won't have detrimental effects. |
| 736 | (inferior-octave-resync-dirs))) | 737 | (inferior-octave-resync-dirs))) |
| @@ -783,21 +784,6 @@ startup file, `~/.emacs-octave'." | |||
| 783 | (set-window-configuration conf) | 784 | (set-window-configuration conf) |
| 784 | (setq unread-command-events (list ch))))))) | 785 | (setq unread-command-events (list ch))))))) |
| 785 | 786 | ||
| 786 | (defun inferior-octave-strip-ctrl-g (string) | ||
| 787 | "Strip leading `^G' character. | ||
| 788 | If STRING starts with a `^G', ring the bell and strip it." | ||
| 789 | (if (string-match "^\a" string) | ||
| 790 | (progn | ||
| 791 | (ding) | ||
| 792 | (setq string (substring string 1)))) | ||
| 793 | string) | ||
| 794 | |||
| 795 | (defun inferior-octave-output-filter (proc string) | ||
| 796 | "Standard output filter for the inferior Octave process. | ||
| 797 | Ring Emacs bell if process output starts with an ASCII bell, and pass | ||
| 798 | the rest to `comint-output-filter'." | ||
| 799 | (comint-output-filter proc (inferior-octave-strip-ctrl-g string))) | ||
| 800 | |||
| 801 | (defun inferior-octave-output-digest (_proc string) | 787 | (defun inferior-octave-output-digest (_proc string) |
| 802 | "Special output filter for the inferior Octave process. | 788 | "Special output filter for the inferior Octave process. |
| 803 | Save all output between newlines into `inferior-octave-output-list', and | 789 | Save all output between newlines into `inferior-octave-output-list', and |
| @@ -1398,27 +1384,26 @@ entered without parens)." | |||
| 1398 | (interactive "r") | 1384 | (interactive "r") |
| 1399 | (inferior-octave t) | 1385 | (inferior-octave t) |
| 1400 | (let ((proc inferior-octave-process) | 1386 | (let ((proc inferior-octave-process) |
| 1401 | (string (buffer-substring-no-properties beg end)) | 1387 | (string (buffer-substring-no-properties beg end)) |
| 1402 | line) | 1388 | line) |
| 1403 | (with-current-buffer inferior-octave-buffer | 1389 | (with-current-buffer inferior-octave-buffer |
| 1404 | (setq inferior-octave-output-list nil) | 1390 | (setq inferior-octave-output-list nil) |
| 1405 | (while (not (string-equal string "")) | 1391 | (while (not (string-equal string "")) |
| 1406 | (if (string-match "\n" string) | 1392 | (if (string-match "\n" string) |
| 1407 | (setq line (substring string 0 (match-beginning 0)) | 1393 | (setq line (substring string 0 (match-beginning 0)) |
| 1408 | string (substring string (match-end 0))) | 1394 | string (substring string (match-end 0))) |
| 1409 | (setq line string string "")) | 1395 | (setq line string string "")) |
| 1410 | (setq inferior-octave-receive-in-progress t) | 1396 | (setq inferior-octave-receive-in-progress t) |
| 1411 | (inferior-octave-send-list-and-digest (list (concat line "\n"))) | 1397 | (inferior-octave-send-list-and-digest (list (concat line "\n"))) |
| 1412 | (while inferior-octave-receive-in-progress | 1398 | (while inferior-octave-receive-in-progress |
| 1413 | (accept-process-output proc)) | 1399 | (accept-process-output proc)) |
| 1414 | (insert-before-markers | 1400 | (insert-before-markers |
| 1415 | (mapconcat 'identity | 1401 | (mapconcat 'identity |
| 1416 | (append | 1402 | (append |
| 1417 | (if octave-send-echo-input (list line) (list "")) | 1403 | (if octave-send-echo-input (list line) (list "")) |
| 1418 | (mapcar 'inferior-octave-strip-ctrl-g | 1404 | inferior-octave-output-list |
| 1419 | inferior-octave-output-list) | 1405 | (list inferior-octave-output-string)) |
| 1420 | (list inferior-octave-output-string)) | 1406 | "\n"))))) |
| 1421 | "\n"))))) | ||
| 1422 | (if octave-send-show-buffer | 1407 | (if octave-send-show-buffer |
| 1423 | (display-buffer inferior-octave-buffer))) | 1408 | (display-buffer inferior-octave-buffer))) |
| 1424 | 1409 | ||
| @@ -1482,9 +1467,7 @@ code line." | |||
| 1482 | (define-button-type 'octave-help-file | 1467 | (define-button-type 'octave-help-file |
| 1483 | 'follow-link t | 1468 | 'follow-link t |
| 1484 | 'action #'help-button-action | 1469 | 'action #'help-button-action |
| 1485 | 'help-function (lambda (fn) | 1470 | 'help-function 'octave-find-definition) |
| 1486 | (find-file fn) | ||
| 1487 | (octave-goto-function-definition))) | ||
| 1488 | 1471 | ||
| 1489 | (define-button-type 'octave-help-function | 1472 | (define-button-type 'octave-help-function |
| 1490 | 'follow-link t | 1473 | 'follow-link t |
| @@ -1527,7 +1510,7 @@ code line." | |||
| 1527 | (replace-match "" nil nil nil 1) | 1510 | (replace-match "" nil nil nil 1) |
| 1528 | (insert "`") | 1511 | (insert "`") |
| 1529 | (help-insert-xref-button (file-name-nondirectory file) | 1512 | (help-insert-xref-button (file-name-nondirectory file) |
| 1530 | 'octave-help-file file) | 1513 | 'octave-help-file fn) |
| 1531 | (insert "'"))) | 1514 | (insert "'"))) |
| 1532 | ;; Make 'See also' clickable | 1515 | ;; Make 'See also' clickable |
| 1533 | (with-syntax-table octave-mode-syntax-table | 1516 | (with-syntax-table octave-mode-syntax-table |
| @@ -1537,6 +1520,12 @@ code line." | |||
| 1537 | (match-end 0) | 1520 | (match-end 0) |
| 1538 | :type 'octave-help-function)))))))) | 1521 | :type 'octave-help-function)))))))) |
| 1539 | 1522 | ||
| 1523 | (defcustom octave-binary-file-extensions '("oct" "mex") | ||
| 1524 | "A list of binary file extensions for Octave." | ||
| 1525 | :type '(repeat string) | ||
| 1526 | :group 'octave | ||
| 1527 | :version "24.4") | ||
| 1528 | |||
| 1540 | (defvar find-tag-marker-ring) | 1529 | (defvar find-tag-marker-ring) |
| 1541 | 1530 | ||
| 1542 | (defun octave-find-definition (fn) | 1531 | (defun octave-find-definition (fn) |
| @@ -1552,6 +1541,11 @@ if iskeyword(\"%s\") disp(\"`%s' is a keyword\") else which(\"%s\") endif\n" | |||
| 1552 | (match-string 1 line)))) | 1541 | (match-string 1 line)))) |
| 1553 | (if (not file) | 1542 | (if (not file) |
| 1554 | (user-error "%s" (or line (format "`%s' not found" fn))) | 1543 | (user-error "%s" (or line (format "`%s' not found" fn))) |
| 1544 | (when (and (member (file-name-extension file) | ||
| 1545 | octave-binary-file-extensions) | ||
| 1546 | (not (yes-or-no-p (format "File `%s' may be binary; open? " | ||
| 1547 | (file-name-nondirectory file))))) | ||
| 1548 | (error "Aborted")) | ||
| 1555 | (require 'etags) | 1549 | (require 'etags) |
| 1556 | (ring-insert find-tag-marker-ring (point-marker)) | 1550 | (ring-insert find-tag-marker-ring (point-marker)) |
| 1557 | (find-file file) | 1551 | (find-file file) |