summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoão Távora <joaotavora@gmail.com>2018-12-03 11:45:24 +0000
committerJoão Távora <joaotavora@gmail.com>2018-12-03 11:45:24 +0000
commit5986c52d06991159c038782f4ed52e1078e6a63b (patch)
treeee3e59b4b315d43ef33f1666bc0277ae17d1244d
parent1ad08262b1f46310c81e04913f90ea39766e1170 (diff)
downloademacs-scratch/octave-eldoc-fixes.tar.gz
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.el33
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."
(const :tag "Multi Line" multiline))
:version "24.4")
-;; (FN SIGNATURE1 SIGNATURE2 ...)
-(defvar octave-eldoc-cache nil)
+;; (FN -> (SIGNATURE1 SIGNATURE2 ...))
+(defvar octave-eldoc-cache (make-hash-table :test #'equal))
+
+(defun octave-eldoc-flush-cache ()
+ "Flush the cache of function signatures for Eldoc."
+ (clrhash octave-eldoc-cache))
(defun octave-eldoc-function-signatures (fn)
- (unless (equal fn (car octave-eldoc-cache))
- (inferior-octave-send-list-and-digest
- (list (format "print_usage ('%s');\n" fn)))
- (let (result)
- (dolist (line inferior-octave-output-list)
- (when (string-match
- "\\s-*\\(?:--[^:]+\\|usage\\):\\s-*\\(.*\\)$"
- line)
- (push (match-string 1 line) result)))
- (setq octave-eldoc-cache
- (cons (substring-no-properties fn)
- (nreverse result)))))
- (cdr octave-eldoc-cache))
+ (or (gethash fn octave-eldoc-cache)
+ (puthash fn
+ (let (result)
+ (inferior-octave-send-list-and-digest
+ (list (format "print_usage ('%s');\n" fn)))
+ (dolist (line inferior-octave-output-list)
+ (when (string-match
+ "\\s-*\\(?:--\\|usage:\\)\\s-*\\(.*\\)$"
+ line)
+ (push (match-string 1 line) result)))
+ (nreverse result))
+ octave-eldoc-cache)))
(defun octave-eldoc-function ()
"A function for `eldoc-documentation-function' (which see)."