diff options
| author | João Távora | 2018-12-03 11:45:24 +0000 |
|---|---|---|
| committer | João Távora | 2018-12-03 11:45:24 +0000 |
| commit | 5986c52d06991159c038782f4ed52e1078e6a63b (patch) | |
| tree | ee3e59b4b315d43ef33f1666bc0277ae17d1244d | |
| parent | 1ad08262b1f46310c81e04913f90ea39766e1170 (diff) | |
| download | emacs-scratch/octave-eldoc-fixes.tar.gz emacs-scratch/octave-eldoc-fixes.zip | |
Make octave.el's cache a multiple-entry hash-tablescratch/octave-eldoc-fixes
Provide a way for the user to flush the cache manually.
* lisp/progmodes/octave.el (octave-eldoc-flush-cache): New function.
(octave-eldoc-function-signatures): Use new hash-table cache.
(octave-eldoc-cache): Now a hash-table.
| -rw-r--r-- | lisp/progmodes/octave.el | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el index 950c4ca33fa..47e1d017ffd 100644 --- a/lisp/progmodes/octave.el +++ b/lisp/progmodes/octave.el | |||
| @@ -1606,23 +1606,26 @@ code line." | |||
| 1606 | (const :tag "Multi Line" multiline)) | 1606 | (const :tag "Multi Line" multiline)) |
| 1607 | :version "24.4") | 1607 | :version "24.4") |
| 1608 | 1608 | ||
| 1609 | ;; (FN SIGNATURE1 SIGNATURE2 ...) | 1609 | ;; (FN -> (SIGNATURE1 SIGNATURE2 ...)) |
| 1610 | (defvar octave-eldoc-cache nil) | 1610 | (defvar octave-eldoc-cache (make-hash-table :test #'equal)) |
| 1611 | |||
| 1612 | (defun octave-eldoc-flush-cache () | ||
| 1613 | "Flush the cache of function signatures for Eldoc." | ||
| 1614 | (clrhash octave-eldoc-cache)) | ||
| 1611 | 1615 | ||
| 1612 | (defun octave-eldoc-function-signatures (fn) | 1616 | (defun octave-eldoc-function-signatures (fn) |
| 1613 | (unless (equal fn (car octave-eldoc-cache)) | 1617 | (or (gethash fn octave-eldoc-cache) |
| 1614 | (inferior-octave-send-list-and-digest | 1618 | (puthash fn |
| 1615 | (list (format "print_usage ('%s');\n" fn))) | 1619 | (let (result) |
| 1616 | (let (result) | 1620 | (inferior-octave-send-list-and-digest |
| 1617 | (dolist (line inferior-octave-output-list) | 1621 | (list (format "print_usage ('%s');\n" fn))) |
| 1618 | (when (string-match | 1622 | (dolist (line inferior-octave-output-list) |
| 1619 | "\\s-*\\(?:--[^:]+\\|usage\\):\\s-*\\(.*\\)$" | 1623 | (when (string-match |
| 1620 | line) | 1624 | "\\s-*\\(?:--\\|usage:\\)\\s-*\\(.*\\)$" |
| 1621 | (push (match-string 1 line) result))) | 1625 | line) |
| 1622 | (setq octave-eldoc-cache | 1626 | (push (match-string 1 line) result))) |
| 1623 | (cons (substring-no-properties fn) | 1627 | (nreverse result)) |
| 1624 | (nreverse result))))) | 1628 | octave-eldoc-cache))) |
| 1625 | (cdr octave-eldoc-cache)) | ||
| 1626 | 1629 | ||
| 1627 | (defun octave-eldoc-function () | 1630 | (defun octave-eldoc-function () |
| 1628 | "A function for `eldoc-documentation-function' (which see)." | 1631 | "A function for `eldoc-documentation-function' (which see)." |