Compare commits

...

2 commits

Author SHA1 Message Date
João Távora
5986c52d06 Make octave.el's cache a multiple-entry hash-table
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.
2018-12-03 11:45:24 +00:00
João Távora
1ad08262b1 Prevent accept-process-output with quit inhibited in octave.el
* lisp/progmodes/octave.el (inferior-octave-send-list-and-digest):
accept-process-output within with-local-quit.
2018-12-03 11:24:25 +00:00

View file

@ -960,8 +960,9 @@ output is passed to the filter `inferior-octave-output-digest'."
(setq inferior-octave-output-string nil
inferior-octave-receive-in-progress t)
(comint-send-string proc string)
(while inferior-octave-receive-in-progress
(accept-process-output proc))
(while (and inferior-octave-receive-in-progress
(with-local-quit
(accept-process-output proc))))
(setq list (cdr list)))
(set-process-filter proc filter))))
@ -1605,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)."