diff options
| author | Leo Liu | 2013-05-10 14:26:42 +0800 |
|---|---|---|
| committer | Leo Liu | 2013-05-10 14:26:42 +0800 |
| commit | f71c50d026c228b41892135377aee84442ef755d (patch) | |
| tree | 736ea43a7f4d4728cbaa26acdb4159ae533a2da0 | |
| parent | d5837773e0d82e36c0175f7be917adbce982b641 (diff) | |
| download | emacs-f71c50d026c228b41892135377aee84442ef755d.tar.gz emacs-f71c50d026c228b41892135377aee84442ef755d.zip | |
* progmodes/octave.el (inferior-octave-completion-table): No
longer a function and all uses changed. Use cache to speed up
completion due to bug#11906.
(octave-beginning-of-defun): Re-write to be more general.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/progmodes/octave.el | 66 |
2 files changed, 43 insertions, 30 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 93ee5ce5a0f..6bd304bf815 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2013-05-10 Leo Liu <sdl.web@gmail.com> | ||
| 2 | |||
| 3 | * progmodes/octave.el (inferior-octave-completion-table): No | ||
| 4 | longer a function and all uses changed. Use cache to speed up | ||
| 5 | completion due to bug#11906. | ||
| 6 | (octave-beginning-of-defun): Re-write to be more general. | ||
| 7 | |||
| 1 | 2013-05-10 Glenn Morris <rgm@gnu.org> | 8 | 2013-05-10 Glenn Morris <rgm@gnu.org> |
| 2 | 9 | ||
| 3 | * emacs-lisp/cl-macs.el (cl-loop): Doc fix. | 10 | * emacs-lisp/cl-macs.el (cl-loop): Doc fix. |
diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el index 6e6e6feb772..f6aa3b2ac42 100644 --- a/lisp/progmodes/octave.el +++ b/lisp/progmodes/octave.el | |||
| @@ -732,13 +732,22 @@ startup file, `~/.emacs-octave'." | |||
| 732 | ;; A trick to get the prompt highlighted. | 732 | ;; A trick to get the prompt highlighted. |
| 733 | (comint-send-string proc "\n"))) | 733 | (comint-send-string proc "\n"))) |
| 734 | 734 | ||
| 735 | (defun inferior-octave-completion-table () | 735 | (defvar inferior-octave-completion-table |
| 736 | (completion-table-dynamic | 736 | ;; |
| 737 | (lambda (command) | 737 | ;; Use cache to avod repetitive computation of completions due to |
| 738 | (inferior-octave-send-list-and-digest | 738 | ;; bug#11906 - http://debbugs.gnu.org/11906 - which may cause |
| 739 | (list (concat "completion_matches (\"" command "\");\n"))) | 739 | ;; noticeable delay. CACHE: (CMD TIME VALUE). |
| 740 | (sort (delete-dups inferior-octave-output-list) | 740 | (let ((cache)) |
| 741 | 'string-lessp)))) | 741 | (completion-table-dynamic |
| 742 | (lambda (command) | ||
| 743 | (unless (and (equal (car cache) command) | ||
| 744 | (< (float-time) (+ 5 (cadr cache)))) | ||
| 745 | (inferior-octave-send-list-and-digest | ||
| 746 | (list (concat "completion_matches (\"" command "\");\n"))) | ||
| 747 | (setq cache (list command (float-time) | ||
| 748 | (sort (delete-dups inferior-octave-output-list) | ||
| 749 | 'string-lessp)))) | ||
| 750 | (car (cddr cache)))))) | ||
| 742 | 751 | ||
| 743 | (defun inferior-octave-completion-at-point () | 752 | (defun inferior-octave-completion-at-point () |
| 744 | "Return the data to complete the Octave symbol at point." | 753 | "Return the data to complete the Octave symbol at point." |
| @@ -753,7 +762,7 @@ startup file, `~/.emacs-octave'." | |||
| 753 | (point))))) | 762 | (point))))) |
| 754 | (when (and start (> end start)) | 763 | (when (and start (> end start)) |
| 755 | (list start end (completion-table-in-turn | 764 | (list start end (completion-table-in-turn |
| 756 | (inferior-octave-completion-table) | 765 | inferior-octave-completion-table |
| 757 | 'comint-completion-file-name-table))))) | 766 | 'comint-completion-file-name-table))))) |
| 758 | 767 | ||
| 759 | (define-obsolete-function-alias 'inferior-octave-complete | 768 | (define-obsolete-function-alias 'inferior-octave-complete |
| @@ -878,7 +887,7 @@ directory and makes this the current buffer's default directory." | |||
| 878 | (completing-read | 887 | (completing-read |
| 879 | (format (if def "Function (default %s): " | 888 | (format (if def "Function (default %s): " |
| 880 | "Function: ") def) | 889 | "Function: ") def) |
| 881 | (inferior-octave-completion-table) | 890 | inferior-octave-completion-table |
| 882 | nil nil nil nil def))) | 891 | nil nil nil nil def))) |
| 883 | 892 | ||
| 884 | (defun octave-goto-function-definition () | 893 | (defun octave-goto-function-definition () |
| @@ -1155,26 +1164,23 @@ The block marked is the one that contains point or follows point." | |||
| 1155 | (mark-sexp)) | 1164 | (mark-sexp)) |
| 1156 | 1165 | ||
| 1157 | (defun octave-beginning-of-defun (&optional arg) | 1166 | (defun octave-beginning-of-defun (&optional arg) |
| 1158 | "Move backward to the beginning of an Octave function. | 1167 | "Octave-specific `beginning-of-defun-function' (which see)." |
| 1159 | With positive ARG, do it that many times. Negative argument -N means | 1168 | (or arg (setq arg 1)) |
| 1160 | move forward to Nth following beginning of a function. | 1169 | ;; Move out of strings or comments. |
| 1161 | Returns t unless search stops at the beginning or end of the buffer." | 1170 | (when (octave-in-string-or-comment-p) |
| 1162 | (let* ((arg (or arg 1)) | 1171 | (goto-char (octave-in-string-or-comment-p))) |
| 1163 | (inc (if (> arg 0) 1 -1)) | 1172 | (letrec ((orig (point)) |
| 1164 | (found nil) | 1173 | (toplevel (lambda (pos) |
| 1165 | (case-fold-search nil)) | 1174 | (condition-case nil |
| 1166 | (and (not (eobp)) | 1175 | (progn |
| 1167 | (not (and (> arg 0) (looking-at "\\_<function\\_>"))) | 1176 | (backward-up-list 1) |
| 1168 | (skip-syntax-forward "w")) | 1177 | (funcall toplevel (point))) |
| 1169 | (while (and (/= arg 0) | 1178 | (scan-error pos))))) |
| 1170 | (setq found | 1179 | (goto-char (funcall toplevel (point))) |
| 1171 | (re-search-backward "\\_<function\\_>" inc))) | 1180 | (when (and (> arg 0) (/= orig (point))) |
| 1172 | (unless (octave-in-string-or-comment-p) | 1181 | (setq arg (1- arg))) |
| 1173 | (setq arg (- arg inc)))) | 1182 | (forward-sexp (- arg)) |
| 1174 | (if found | 1183 | (/= orig (point)))) |
| 1175 | (progn | ||
| 1176 | (and (< inc 0) (goto-char (match-beginning 0))) | ||
| 1177 | t)))) | ||
| 1178 | 1184 | ||
| 1179 | 1185 | ||
| 1180 | ;;; Filling | 1186 | ;;; Filling |
| @@ -1322,7 +1328,7 @@ otherwise." | |||
| 1322 | (when (> end beg) | 1328 | (when (> end beg) |
| 1323 | (list beg end (or (and inferior-octave-process | 1329 | (list beg end (or (and inferior-octave-process |
| 1324 | (process-live-p inferior-octave-process) | 1330 | (process-live-p inferior-octave-process) |
| 1325 | (inferior-octave-completion-table)) | 1331 | inferior-octave-completion-table) |
| 1326 | octave-reserved-words))))) | 1332 | octave-reserved-words))))) |
| 1327 | 1333 | ||
| 1328 | (define-obsolete-function-alias 'octave-complete-symbol | 1334 | (define-obsolete-function-alias 'octave-complete-symbol |